Auto Update Order Status for Default and Custom Order Statuses

The PHP code in this download dynamically updates the order status on order creation in WooCommerce. You can automatically update any of the default order status slugs like ‘pending’, ‘on-hold’, ‘processing’ and any custom order status slugs with default or custom order statuses.

Custom order statuses can be added using custom code or code from within plugins for WooCommerce. The code in this download works either way.

In this example we change the order status from processing to prep ( a custom order status added using code available in this download ) on order creation.

To sum up, this code enables you to programmatically, upon order creation :

  • Update one or more default order statuses to any default status
  • Update one or more custom order statuses to any custom status
  • Update one or more custom and/ore default status to any default or custom status

And, if needed, create a custom order status named anything you like.

Note : This code only changes the order status for new orders, not existing orders.

Demo Video

Installation

Copy and paste the PHP code to the end of your child themes functions file or custom functionality/code snippets plugin.

Order Status Slugs

Swap out the order status slugs based on your own requirements.

If using the code to create a custom order status, modify the slug on line 11 with the slug you want to use, 20 characters or less and modify the label name on line 12.

Note : If you don’t want to use the code to create a custom order status, don’t add the code between lines 8 – 19.

On line 33, modify the slugs for the order statuses you want to change and one line 44, modify the slug for the order status you want to change to.

Download Folder

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.