function action_wcs_create_subscription($subscription) {
$NewSubscriptionId = $subscription->get_id();
update_option('NewSubscriptionId',$NewSubscriptionId);
$order = wc_get_order($NewSubscriptionId);
$cancelledSubscriptionId = $order->get_meta('_subscription_resubscribe');
update_option('cancelledSubscriptionId',$cancelledSubscriptionId);
}
add_action('wcs_create_subscription',action_wcs_create_subscription', 10, 20);
I need to fetch the parent subscription id during resubscription process , I used the above hook , which returns the newly created subscription id , also i need to fetch the meta value of ‘_subscription_resubscribe’ , It return null value but there exist a value in DB.
Also i tried the hook ‘woocommerce_subscription_renewal_order_created’ still not works.
add_action('wcs_create_subscription', 'action_wcs_create_subscription', 10, 20);
add_action(‘woocommerce_subscription_renewal_order_created’, ‘action_wcs_create_subscription’, 10, 20);
I tried the above 2 hooks but ‘_subscription_resubscribe’ always returns null.
$order = wc_get_order($NewSubscriptionId); $cancelledSubscriptionId = $order->get_meta('_subscription_resubscribe');
Please suggest which hook is suitable to fetch the above meta data.