In this article, I will demonstrate how you could add WooCommerce custom order status actions.
The intent here is to show how you could modify order data, add information to orders, export order data externally, or run any general action that requires order details.
Another important thing in this context is that these statuses trigger further actions. You need to provide WooCommerce code for these actions. In many instances, this code is custom written as a response for particular statuses.
To add a custom order status in WooCommerce, you can follow these steps:
Step 1: Install and activate a child theme (optional) While not mandatory, it’s recommended to use a child theme to make changes to your WooCommerce store. This ensures that your modifications won’t be lost during theme updates. If you already have a child theme, you can skip this step.
Step 2: Access your theme’s functions.php file If you’re using a child theme, go to your WordPress dashboard, navigate to Appearance → Theme Editor, and open your child theme’s functions.php file. If you’re using the parent theme, you can access the functions.php file directly.
Step 3: Add custom code Inside the functions.php file, add the following code:
/** * Add custom order status to WooCommerce */ function add_custom_order_status() { register_post_status('wc-custom-status', array( 'label' => 'Custom Status', 'public' => true, 'exclude_from_search' => false, 'show_in_admin_all_list' => true, 'show_in_admin_status_list' => true, 'label_count' => _n_noop('Custom Status <span class="count">(%s)</span>', 'Custom Status <span class="count">(%s)</span>') )); } add_action('init', 'add_custom_order_status');
Explanation
Here’s the explanation of the above code.
register_shipment_arrival_order_status(): This function registers a new custom order status with the identifier ‘wc-arrival-shipment’. The register_post_status() function is a WordPress function that creates a new post status with the given properties. The array passed to this function contains the following properties:
label: The human-readable name of the order status, ‘Shipment Arrival’ in this case.
public: Setting this to true makes the status publicly accessible.
show_in_admin_status_list: When set to true, this status will be displayed in the order status list in the WordPress admin area.
show_in_admin_all_list: When set to true, orders with this status will appear in the “All” orders list in the admin area.
exclude_from_search: Setting this to false means that orders with this status can be included in search results.
label_count: This property sets the label format for displaying the count of orders with this status in the admin area.
The function is hooked to the ‘init’ action using add_action( ‘init’, ‘register_shipment_arrival_order_status’ );. This ensures the custom order status is registered during the WordPress initialization process.
Add Custom WooCommerce Order Status Into Existing Status
/** * Add custom order status to WooCommerce dropdown */ function add_custom_order_status_to_dropdown($order_statuses) { $order_statuses['wc-custom-status'] = 'Custom Status'; return $order_statuses; } add_filter('wc_order_statuses', 'add_custom_order_status_to_dropdown');
Explanation
add_custom_order_status_to_dropdown(): This function adds the custom order status ‘Custom Status’ to the existing WooCommerce order statuses array.
The function is hooked to the ‘wc_order_statuses’ filter using add_filter( ‘wc_order_statuses’, ‘add_custom_order_status_to_dropdown’ );. This filter allows you to modify the list of WooCommerce order statuses.

Conclusion:
You should now see the “Custom Status” as an option in the order status dropdown when editing an order in the WordPress admin area.
Support
If you need any technical assistance, please reach us by mail at [email protected]. Also, discover various solutions to add more features and enhance your online store by visiting the WooCommerce plugins page. Additionally, if you require expert assistance or want to develop custom unique functionality Hire WooCommerce Developers for your project.
Be the first to comment.