For this specific project i need to set woocommerce order and subscription status to ‘on-hold’ before it is set ‘cancelled’/’expired’/’pending cancellation’ by woocommerce it self or payment gateway.

I looked up dev docs and found couple of action that i could use.

First i tried dynamic action 'woocommerce_subscription_status_cancelled' but it gives the same data as dynamic actions such as 'woocommerce_subscription_status_cancelled' but as i understand these hooks are fired after the subscription status has already been changed…

And so executing this code in any of the hooks is unsuccessful :

$subscription->update_status( 'on-hold', 'reason text' ); 

Since updating Subscription status from Expired/cancelled is not possible apparently, woocommerce gives me this error

1 subscription could not be updated: Unable to change subscription
status to “on-hold”.

Can this be achived with other hooks/actions?

Read more here: how change woocommerce subscriptions status to ‘on-hold’ before it is set to canceled/expired


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Wordpress related questions and answers: