File tree Expand file tree Collapse file tree
modules/ppcp-wc-subscriptions/src/Helper Expand file tree Collapse file tree Original file line number Diff line number Diff 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 '' ;
You can’t perform that action at this time.
0 commit comments