Skip to content

Commit ab1efa0

Browse files
committed
Merge branch 'trunk' into modularity-module-migration
2 parents 4f61ed4 + 425b7b4 commit ab1efa0

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

modules/ppcp-wc-subscriptions/src/Helper/SubscriptionHelper.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,21 @@ public function paypal_subscription_id(): string {
211211
if ( $product->get_type() === 'subscription' && $product->meta_exists( 'ppcp_subscription_plan' ) ) {
212212
return $product->get_meta( 'ppcp_subscription_plan' )['id'];
213213
}
214+
215+
if ( $product->get_type() === 'variable-subscription' ) {
216+
/**
217+
* The method is defined in WC_Product_Variable class.
218+
*
219+
* @psalm-suppress UndefinedMethod
220+
*/
221+
$product_variations = $product->get_available_variations();
222+
foreach ( $product_variations as $variation ) {
223+
$variation_product = wc_get_product( $variation['variation_id'] ) ?? '';
224+
if ( $variation_product && $variation_product->meta_exists( 'ppcp_subscription_plan' ) ) {
225+
return $variation_product->get_meta( 'ppcp_subscription_plan' )['id'];
226+
}
227+
}
228+
}
214229
}
215230

216231
return '';

0 commit comments

Comments
 (0)