I’m using Woocommerce Subscriptions plugin in my Woocommerce site. I want to post the new renewal date for a subscription to an external API when a subscription is renewed. I’m trying to use the ‘woocommerce_subscription_renewal_payment_complete’ action hook so whenever a subscription is renewed I can access the $subscription object and the $last_order object. But when I try to get the $subscription->get_date(‘nex_payment’) date, it will always return the last renewal date and not the next renewal date. I looks like the $subscription has not really been updated before this hook and the ‘next_payment’ date is still not updated to the next value when firing this action hook.
Does anybody know how to get the real ‘next_payment’ date after a renewal has been completed?
Thank you!
2
Answers
for those that could be interested in a solution, I've finally found that there's an action hook called 'woocommerce_subscription_date_updated' that fires when a date of the subscription has been updated.
Simply add an action to this hook:
I believe that "woocommerce_subscription_date_updated" is an action in woosubscriptions v3 (although not in the API documentation) and was a filter in woosubscriptions v2 that is now depreciated. Since its not in the API documentation, I suppose that means it could change without notice. It is used internally in woosubscriptions.