Skip to content

Commit

Permalink
Merge branch 'trunk' into modularity-module-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrosilva-pt committed Dec 20, 2023
2 parents 4f61ed4 + 425b7b4 commit ab1efa0
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions modules/ppcp-wc-subscriptions/src/Helper/SubscriptionHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,21 @@ public function paypal_subscription_id(): string {
if ( $product->get_type() === 'subscription' && $product->meta_exists( 'ppcp_subscription_plan' ) ) {
return $product->get_meta( 'ppcp_subscription_plan' )['id'];
}

if ( $product->get_type() === 'variable-subscription' ) {
/**
* The method is defined in WC_Product_Variable class.
*
* @psalm-suppress UndefinedMethod
*/
$product_variations = $product->get_available_variations();
foreach ( $product_variations as $variation ) {
$variation_product = wc_get_product( $variation['variation_id'] ) ?? '';
if ( $variation_product && $variation_product->meta_exists( 'ppcp_subscription_plan' ) ) {
return $variation_product->get_meta( 'ppcp_subscription_plan' )['id'];
}
}
}
}

return '';
Expand Down

0 comments on commit ab1efa0

Please sign in to comment.