Woocommerce hook before order status change

偶尔善良 提交于 2020-07-09 16:49:30

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/48569105/woocommerce-hook-before-order-status-change

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!