Use transaction id from parent order on first renewal

This commit is contained in:
dinamiko 2022-09-13 17:25:25 +02:00
parent d3b319ab11
commit ca9fb3e9fa

View file

@ -113,8 +113,12 @@ class SubscriptionModule implements ModuleInterface {
if ( is_a( $latest_subscription, WC_Subscription::class ) ) {
$related_renewal_orders = $latest_subscription->get_related_orders( 'ids', 'renewal' );
$latest_order_id_with_transaction = array_slice( $related_renewal_orders, 1, 1, false );
$order_id = ! empty( $latest_order_id_with_transaction ) ? $latest_order_id_with_transaction[0] : 0;
if ( count( $related_renewal_orders ) === 1 ) {
$order_id = $latest_subscription->get_parent_id();
}
$wc_order = wc_get_order( $latest_order_id_with_transaction[0] );
$wc_order = wc_get_order( $order_id );
if ( is_a( $wc_order, WC_Order::class ) ) {
$transaction_id = $wc_order->get_transaction_id();
$data['application_context']['stored_payment_source'] = array(