@@ 122-141 (lines=20) @@ | ||
119 | * @since 3.1.0 |
|
120 | * @version 4.0.0 |
|
121 | */ |
|
122 | public function save_source_to_order( $order, $source ) { |
|
123 | parent::save_source_to_order( $order, $source ); |
|
124 | ||
125 | $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
126 | ||
127 | // Also store it on the subscriptions being purchased or paid for in the order. |
|
128 | if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) { |
|
129 | $subscriptions = wcs_get_subscriptions_for_order( $order_id ); |
|
130 | } elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) { |
|
131 | $subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id ); |
|
132 | } else { |
|
133 | $subscriptions = array(); |
|
134 | } |
|
135 | ||
136 | foreach ( $subscriptions as $subscription ) { |
|
137 | $subscription_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id(); |
|
138 | update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer ); |
|
139 | update_post_meta( $subscription_id, '_stripe_source_id', $source->source ); |
|
140 | } |
|
141 | } |
|
142 | ||
143 | /** |
|
144 | * Process the payment based on type. |
@@ 282-301 (lines=20) @@ | ||
279 | * @since 3.1.0 |
|
280 | * @version 4.0.0 |
|
281 | */ |
|
282 | public function save_source_to_order( $order, $source ) { |
|
283 | parent::save_source_to_order( $order, $source ); |
|
284 | ||
285 | $order_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $order->id : $order->get_id(); |
|
286 | ||
287 | // Also store it on the subscriptions being purchased or paid for in the order |
|
288 | if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) { |
|
289 | $subscriptions = wcs_get_subscriptions_for_order( $order_id ); |
|
290 | } elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) { |
|
291 | $subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id ); |
|
292 | } else { |
|
293 | $subscriptions = array(); |
|
294 | } |
|
295 | ||
296 | foreach ( $subscriptions as $subscription ) { |
|
297 | $subscription_id = WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->id : $subscription->get_id(); |
|
298 | update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer ); |
|
299 | update_post_meta( $subscription_id, '_stripe_source_id', $source->source ); |
|
300 | } |
|
301 | } |
|
302 | ||
303 | /** |
|
304 | * Don't transfer Stripe customer/token meta to resubscribe orders. |