-2

I have a high traffic WooCommerce Subscriptions site. I need to call a 3rd party API every time an order is generated and send information about the customer (if they still have an active subscription or not), this includes new and renewal orders.

For this purpose I choose the "woocommerce_subscription_status_updated" hook. It fires every time a subscription changes state, lets me know what the current state is and then I can send that info to the API.

The issue is that when a subscription gets renewed successfully, this hook is fired twice (once if the renewal fails). Subscription get changed from "active" to "on-hold" and then "on-hold" to "active" (this is how Wc Subscription renews a subscription). The API gets called twice even though it did not needed to. What would be a better way to implement this?

1 Answers1

1

I think you can set a CRON with storing the last checked date time and get a list of data whose status are updated since the last time and call an API in some interval through CRON if it works for you.