Docly Child

Change The Order Status Based on The Shipment Status

This code snippet is a WordPress function that uses the “trackship_shipment_status_trigger” action hook provided by the TrackShip plugin to change the order status of a WooCommerce order when the shipment status changes.

You will also have to add to that custom order status for delivery automation.

How to use this code snippet:

  1. Make sure you have the TrackShip plugin and WooCommerce plugin installed and activated on your WordPress website.
  2. Copy the code snippet and paste it into the functions.php file of your active WordPress theme.
  3. Replace the “in_transit” status in the code snippet with the custom order status you want to change to. For example, if you want to change the order status to “shipped”, you would replace ‘in_transit’ with ‘shipped’
  4. You also need to add that order status for delivery automation
  5. Save the changes to the functions.php file and upload it to your website.
  6. Test the code by creating an order and tracking it via TrackShip, the order status should update to the custom status you have set in the code snippet.

Note: Keep in mind that, This snippet will only work when the shipment status is changed via TrackShip.

Download Now