Skip to content

Commit d055e61

Browse files
authored
Merge branch 'trunk' into hpos-sync-duplicate-related-meta-cache
2 parents a6fac96 + 86e24e6 commit d055e61

File tree

2 files changed

+4
-21
lines changed

2 files changed

+4
-21
lines changed

changelog.txt

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* Fix - Added support for previewing payment retry emails in WooCommerce email settings.
1111
* Fix - Updated subscription email item table template to align with WooCommerce 9.7 email improvements.
1212
* Fix - Prevent PHP warning on cart page shipping method updates by removing unused method: maybe_restore_shipping_methods.
13+
* Fix - Removed unnecessary setting of renewal order paid date on status transition, relying on WooCommerce core behavior instead.
1314
* Fix - Ensure the order_awaiting_payment session arg is restored when loading a renewal cart from the session to prevent duplicate orders.
1415
* Fix - Ensure custom placeholders (time_until_renewal, customers_first_name) are included in customer notification email previews.
1516
* Fix - For stores with HPOS + compatibility mode enabled, using the bulk delete related orders cache tool was not correctly deleting the meta from the WP Posts table.

includes/class-wc-subscriptions-renewal-order.php

+3-21
Original file line numberDiff line numberDiff line change
@@ -96,27 +96,9 @@ public static function maybe_record_subscription_payment( $order_id, $orders_old
9696
$order_needed_payment = in_array( $orders_old_status, apply_filters( 'woocommerce_valid_order_statuses_for_payment', array( 'pending', 'on-hold', 'failed' ), $order ) );
9797

9898
if ( $order_completed && $order_needed_payment ) {
99-
100-
if ( wcs_is_woocommerce_pre( '3.0' ) ) {
101-
$update_post_data = array(
102-
'ID' => $order_id,
103-
'post_date' => current_time( 'mysql', 0 ),
104-
'post_date_gmt' => current_time( 'mysql', 1 ),
105-
);
106-
107-
wp_update_post( $update_post_data );
108-
update_post_meta( $order_id, '_paid_date', current_time( 'mysql' ) );
109-
} else {
110-
111-
$current_time = current_time( 'timestamp', 1 );
112-
113-
// Prior to WC 3.0, we need to update the post date (i.e. the date created) to have a reliable representation of the paid date (both because it was in GMT and because it was always set). That's not needed in WC 3.0, but some plugins and store owners still rely on it being updated, so we want to make it possible to update it with 3.0 also.
114-
if ( apply_filters( 'wcs_renewal_order_payment_update_date_created', false, $order, $subscriptions ) ) {
115-
$order->set_date_created( $current_time );
116-
}
117-
118-
// In WC 3.0, only the paid date prop represents the paid date, the post date isn't used anymore, also the paid date is stored and referenced as a MySQL date string in site timezone and a GMT timestamp
119-
$order->set_date_paid( $current_time );
99+
// Prior to WC 3.0, we need to update the post date (i.e. the date created) to have a reliable representation of the paid date (both because it was in GMT and because it was always set). That's not needed in WC 3.0, but some plugins and store owners still rely on it being updated, so we want to make it possible to update it with 3.0 also.
100+
if ( apply_filters( 'wcs_renewal_order_payment_update_date_created', false, $order, $subscriptions ) ) {
101+
$order->set_date_created( time() );
120102
$order->save();
121103
}
122104
}

0 commit comments

Comments
 (0)