Code Duplication    Length = 20-20 lines in 2 locations

includes/compat/class-wc-stripe-sepa-subs-compat.php 1 location

@@ 134-153 (lines=20) @@
131
	 * @since 3.1.0
132
	 * @version 4.0.0
133
	 */
134
	public function save_source_to_order( $order, $source ) {
135
		parent::save_source_to_order( $order, $source );
136
137
		$order_id = $order->get_id();
138
139
		// Also store it on the subscriptions being purchased or paid for in the order.
140
		if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) {
141
			$subscriptions = wcs_get_subscriptions_for_order( $order_id );
142
		} elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) {
143
			$subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id );
144
		} else {
145
			$subscriptions = array();
146
		}
147
148
		foreach ( $subscriptions as $subscription ) {
149
			$subscription_id = $subscription->get_id();
150
			update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer );
151
			update_post_meta( $subscription_id, '_stripe_source_id', $source->source );
152
		}
153
	}
154
155
	/**
156
	 * Process the payment based on type.

includes/compat/class-wc-stripe-subs-compat.php 1 location

@@ 394-413 (lines=20) @@
391
	 * @since 3.1.0
392
	 * @version 4.0.0
393
	 */
394
	public function save_source_to_order( $order, $source ) {
395
		parent::save_source_to_order( $order, $source );
396
397
		$order_id = $order->get_id();
398
399
		// Also store it on the subscriptions being purchased or paid for in the order
400
		if ( function_exists( 'wcs_order_contains_subscription' ) && wcs_order_contains_subscription( $order_id ) ) {
401
			$subscriptions = wcs_get_subscriptions_for_order( $order_id );
402
		} elseif ( function_exists( 'wcs_order_contains_renewal' ) && wcs_order_contains_renewal( $order_id ) ) {
403
			$subscriptions = wcs_get_subscriptions_for_renewal_order( $order_id );
404
		} else {
405
			$subscriptions = array();
406
		}
407
408
		foreach ( $subscriptions as $subscription ) {
409
			$subscription_id = $subscription->get_id();
410
			update_post_meta( $subscription_id, '_stripe_customer_id', $source->customer );
411
			update_post_meta( $subscription_id, '_stripe_source_id', $source->source );
412
		}
413
	}
414
415
	/**
416
	 * Don't transfer Stripe customer/token meta to resubscribe orders.