Automatically update order status when shipment tracking is input in WooCommerce on child sites.
Snippet Type
Execute on Child Sites
Snippet
function update_order_status_when_shipment_tracking_input( $meta_id, $object_id, $meta_key, $meta_value ){
if( $meta_key == '_wc_shipment_tracking_items' ){
error_log('update_order_status_when_shipment_tracking_input');
$order = wc_get_order( $object_id );
if( $order ){
$order->update_status( 'completed' );
}
}
}
add_action( 'update_postmeta', 'update_order_status_when_shipment_tracking_input', 10, 4 );
Fecso
(Ferenc Sarosi)
October 28, 2021, 7:20am
2
Hi Sebastian,
What is the prerequisites of this code? The order should have a field ‘_wc_shipment_tracking_items’? If yes is it OK to add as ACF field?
Thanks,
Ferenc
If you set the custom field (_wc_shipment_tracking_items
) for shipment tracking on orders using say ACF or Pods then you could use the code.
Also applies if you are using the Shipment Tracking plugin from WooCommerce.
The Shipment Tracking extension provides customers with an easy way to track shipments by adding a link to emails and order pages. Installation Ensure your store meets the plugin requirements. Download the extension from your WooCommerce dashboard....
Est. reading time: 4 minutes
system
(system)
Closed
November 27, 2021, 1:27pm
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.