woocommerce subscriptions – get expiration date [closed]

I had a similar problem to the one you have described. In the end i had to hook into woocommerce_subscription_status_active from which you can access the related $subscription object as a single argument. If you need any further details from the standard $order object also then you can access that via $subscription->get_parent() within your function.

The issue seems to be that the end date value attached to a subscription only gets set really late in the order of hooks/actions, so any of the standard hooks you would usually use post-checkout may not have access to the subscription dates yet since they are still not set.

I tried all of the following before i got it to work for me;

woocommerce_thankyou
woocommerce_payment_complete
woocommerce_checkout_order_processed
woocommerce_order_status_completed
woocommerce_subscription_payment_complete

and in each case the end date (and next payment date) were both empty even though i could see them in the wordpress admin later on.