| @@ 456-467 (lines=12) @@ | ||
| 453 | } |
|
| 454 | ||
| 455 | // If we couldn't find a Stripe customer linked to the account, fallback to the order meta data. |
|
| 456 | if ( ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) && false !== $subscription->order ) { |
|
| 457 | $stripe_customer_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_customer_id', true ); |
|
| 458 | $stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_source_id', true ); |
|
| 459 | ||
| 460 | // For BW compat will remove in future. |
|
| 461 | if ( empty( $stripe_source_id ) ) { |
|
| 462 | $stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_card_id', true ); |
|
| 463 | ||
| 464 | // Take this opportunity to update the key name. |
|
| 465 | WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $subscription->order->id, '_stripe_source_id', $stripe_source_id ) : update_post_meta( $subscription->get_parent_id(), '_stripe_source_id', $stripe_source_id ); |
|
| 466 | } |
|
| 467 | } |
|
| 468 | ||
| 469 | $stripe_customer->set_id( $stripe_customer_id ); |
|
| 470 | $sources = $stripe_customer->get_sources(); |
|
| @@ 468-479 (lines=12) @@ | ||
| 465 | } |
|
| 466 | ||
| 467 | // If we couldn't find a Stripe customer linked to the account, fallback to the order meta data. |
|
| 468 | if ( ( ! $stripe_customer_id || ! is_string( $stripe_customer_id ) ) && false !== $subscription->order ) { |
|
| 469 | $stripe_customer_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_customer_id', true ); |
|
| 470 | $stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_source_id', true ); |
|
| 471 | ||
| 472 | // For BW compat will remove in future. |
|
| 473 | if ( empty( $stripe_source_id ) ) { |
|
| 474 | $stripe_source_id = get_post_meta( ( WC_Stripe_Helper::is_wc_lt( '3.0' ) ? $subscription->order->id : $subscription->get_parent_id() ), '_stripe_card_id', true ); |
|
| 475 | ||
| 476 | // Take this opportunity to update the key name. |
|
| 477 | WC_Stripe_Helper::is_wc_lt( '3.0' ) ? update_post_meta( $subscription->order->id, '_stripe_source_id', $stripe_source_id ) : update_post_meta( $subscription->get_parent_id(), '_stripe_source_id', $stripe_source_id ); |
|
| 478 | } |
|
| 479 | } |
|
| 480 | ||
| 481 | $stripe_customer->set_id( $stripe_customer_id ); |
|
| 482 | $sources = $stripe_customer->get_sources(); |
|