@@ 83-102 (lines=20) @@ | ||
80 | * @since 3.1.0 |
|
81 | * @version 4.0.0 |
|
82 | */ |
|
83 | public function save_source_to_order( $order, $source ) { |
|
84 | parent::save_source_to_order( $order, $source ); |
|
85 | ||
86 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
|
87 | ||
88 | // Also store it on the subscriptions being purchased or paid for in the order. |
|
89 | if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) { |
|
90 | $subscriptions = wcs_get_subscriptions_for_order( $order_id ); |
|
91 | } elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) { |
|
92 | $subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id ); |
|
93 | } else { |
|
94 | $subscriptions = array(); |
|
95 | } |
|
96 | ||
97 | foreach ( $subscriptions as $subscription ) { |
|
98 | $subscription_id = WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id(); |
|
99 | update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer ); |
|
100 | update_post_meta( $subscription_id, '_stripe_source_id', $source->source ); |
|
101 | } |
|
102 | } |
|
103 | ||
104 | /** |
|
105 | * Process the payment based on type. |
@@ 275-294 (lines=20) @@ | ||
272 | * @since 3.1.0 |
|
273 | * @version 4.0.0 |
|
274 | */ |
|
275 | public function save_source_to_order( $order, $source ) { |
|
276 | parent::save_source_to_order( $order, $source ); |
|
277 | ||
278 | $order_id = WC_Stripe_Helper::is_pre_30() ? $order->id : $order->get_id(); |
|
279 | ||
280 | // Also store it on the subscriptions being purchased or paid for in the order |
|
281 | if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) { |
|
282 | $subscriptions = wcs_get_subscriptions_for_order( $order_id ); |
|
283 | } elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) { |
|
284 | $subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id ); |
|
285 | } else { |
|
286 | $subscriptions = array(); |
|
287 | } |
|
288 | ||
289 | foreach ( $subscriptions as $subscription ) { |
|
290 | $subscription_id = WC_Stripe_Helper::is_pre_30() ? $subscription->id : $subscription->get_id(); |
|
291 | update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer ); |
|
292 | update_post_meta( $subscription_id, '_stripe_source_id', $source->source ); |
|
293 | } |
|
294 | } |
|
295 | ||
296 | /** |
|
297 | * Don't transfer Stripe customer/token meta to resubscribe orders. |