user1980232
user1980232

Reputation: 326

Woocommerce hook before order status change

I've been searching for a hook that is triggered before the order status is changed or, for that matter, before the order is updated.

I'm trying to enforce a designed workflow. I've been able to change the options the users have to change the order status so they don't choose a 'wrong' status, but I want to check the updates using code too (never trust user input).

There are hooks triggered after the status has changed (woocommerce_order_status[to]) that do not prevent 'illegal' status changes.

Any ideas?

Upvotes: 1

Views: 12177

Answers (1)

Peter HvD
Peter HvD

Reputation: 1661

There is this action which you could hook into: woocommerce_order_status_changed The 2nd and 3rd variables returned are the previous and the new status respectively.

Although it still happens after the change, you can at least test for the change and revert the status back.

Hope that helps

Upvotes: 3

Related Questions