Skip to content

Commit 7b60cb9

Browse files
authored
Replace the deprecated wcs_renewal_order_meta_query with a new hook (#5052)
* Replace the deprecated wcs_renewal_order_meta_query with a new hook * Add changelog * Add the missing s
1 parent a3e9e0f commit 7b60cb9

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: minor
2+
Type: dev
3+
4+
Replace the use of the deprecated wcs_renewal_order_meta_query hook with wc_subscription_renewal_order_data

includes/compat/subscriptions/trait-wc-payment-gateway-wcpay-subscriptions.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@ public function maybe_init_subscriptions() {
140140
add_filter( 'woocommerce_my_subscriptions_payment_method', [ $this, 'maybe_render_subscription_payment_method' ], 10, 2 );
141141

142142
// Used to filter out unwanted metadata on new renewal orders.
143-
add_filter( 'wcs_renewal_order_meta_query', [ $this, 'update_renewal_meta_data' ], 10, 3 );
143+
if ( ! class_exists( 'WC_Subscriptions_Data_Copier' ) ) {
144+
add_filter( 'wcs_renewal_order_meta_query', [ $this, 'update_renewal_meta_data' ], 10, 3 );
145+
} else {
146+
add_filter( 'wc_subscriptions_renewal_order_data', [ $this, 'remove_data_renewal_order' ], 10, 3 );
147+
}
144148

145149
// Allow store managers to manually set Stripe as the payment method on a subscription.
146150
add_filter( 'woocommerce_subscription_payment_meta', [ $this, 'add_subscription_payment_meta' ], 10, 2 );
@@ -733,6 +737,18 @@ public function update_renewal_meta_data( $order_meta_query, $to_order, $from_or
733737
return $order_meta_query;
734738
}
735739

740+
/**
741+
* Removes the data that we don't need to copy to renewal orders.
742+
*
743+
* @param array $order_data Renewal order data.
744+
*
745+
* @return array The renewal order data with the data we don't want copied removed
746+
*/
747+
public function remove_data_renewal_order( $order_data ) {
748+
unset( $order_data['_new_order_tracking_complete'] );
749+
return $order_data;
750+
}
751+
736752
/**
737753
* Adds the failed SCA auth email to WooCommerce.
738754
*

0 commit comments

Comments
 (0)