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?
答案 0 :(得分:0)
您可以加入此操作:woocommerce_order_status_changed()
返回的第二个和第三个变量分别是上一个和新状态。
虽然在更改后仍然会发生这种情况,但您至少可以测试更改并恢复状态。
希望有所帮助