I’ve registered the following woocommerce hook:
add_action('woocommerce_update_order', 'some_func', 300, 2);
function some_func($order_id, $order){
// ...
}
However, I have a few problems:
This fires multiple times instead of only at the end when updating an order. It fires two times with the old order, and once with the one one.
I’ve also tried the following:
add_action('woocommerce_update_order', 'some_func', 300, 2);
function some_func($order_id, $order){
remove_action('woocommerce_update_order', 'some_func');
// ...
}
Which doesn’t change it, either.
Also, I’ve tried modifying the remove_action to include the priority and argument count, like:
add_action('woocommerce_update_order', 'some_func', 300, 2);
function some_func($order_id, $order){
remove_action('woocommerce_update_order', 'some_func', 300, 2);
// ...
}
Now, it does fire only once, but it gives me the old order instead of the newly updated one.
I’m using WooCommerce 3.7.0.
Any suggestions on how I can get the most up-to-date version of the order after an update while only firing the hook exactly once?
Thanks!
2
Answers
These much status change hooks are there. You may use the specific one you need. Hope it may be helpful
Do your action inside post condition