skip to Main Content

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


  1. Chosen as BEST ANSWER

    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:

    <?php
    add_action('woocommerce_subscription_date_updated', 'subscription_date_update', 10, 3);
    
    function subscription_date_update($subscription, $date_type, $datetime)
    {
      //Do your stuff here...
    }
    

  2. 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.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search