I’m not sure which hook/action needs to setup to know when the admin is updating shipping/billing addresses once the order has been created.
So what I’m trying to achieve here is:
- In WooCommerce order section when the admin updates the shipping/billing address then it triggers an action.
- this action basically makes a single curl call to my custom script and lets me know that the address of the order has been changed by the admin.
- I’ll do some magic in my script.
I found below but I don’t think its more from admin side.
// define the woocommerce_admin_order_data_after_shipping_address callback
function action_woocommerce_admin_order_data_after_shipping_address(
$delta_wccs_custom_checkout_details_pro_shipping, $int, $int ) {
// make action magic happen here...
};
// add the action
add_action( 'woocommerce_admin_order_data_after_shipping_address', 'action_woocommerce_admin_order_data_after_shipping_address', 10, 3 );
Please let me know if anyone knows the right action to trigger when order shipping/billing address change.
2
Answers
The
woocommerce_admin_order_data_after_shipping_address
hook is to display extra content on the order edit page (backend)To trigger
$order_item
actions before or after saving to the DB, use:OR
Use the almost identical
woocommerce_before_order_object_save
hook that may be even more suitable, because via$order->get_changes()
you can trigger/log/compare which$order
data has been changedEDIT: it is a known issue that these hooks are called multiple times when they are not intended to be
As a workaround, add:
As first line in your callback function