How To Add A Custom Order Status in WooCommerce

How To Add A Custom Order Status in WooCommerce

Add More Control of Order Management!

Facebook
Twitter
Reddit

WooCommerce order status helps store owners efficiently monitor the journey of an order, right from its placement to successful delivery. However, it’s crucial to acknowledge that the default options might not cater to the specific requirements of every store. That’s where the flexibility of adding custom order statuses in WooCommerce becomes invaluable.

What is an Order Status?

An order status is a descriptive label that indicates the current stage of an order within the eCommerce process. It provides valuable insights to both store owners and customers about the progress and status of the order. By clearly defining and utilising order statuses, store owners can streamline their order management workflows, provide better customer service, and ensure a seamless shopping experience for their customers. It’s essential to tailor order statuses to the specific needs of each online store to accurately reflect the various stages an order may go through, ensuring a smooth and organized operation.

What are the default Order Status’ in WooCommerce?

WooCommerce provides a set of standard order statuses to help you manage your orders effectively. These default statuses include “Pending Payment,” “Processing,” “On Hold,” “Completed,” “Cancelled,” “Refunded,” and “Failed.” Each status serves a specific purpose in indicating the progress of an order, such as awaiting payment, being processed, or reaching a successful completion.

Why would you need a Custom Order Status?

While WooCommerce provides a range of default order statuses, there are instances where these may not fully align with the specific needs of your online store. This is where the option to create custom order statuses becomes invaluable. By adding custom order statuses, you can tailor the order management process to fit your unique business requirements and enhance the overall efficiency of your store.

Custom order statuses offer the flexibility to reflect additional stages or statuses that are relevant to your specific workflow.

An Example of a Custom Order Status

Let’s consider an example of a custom order status: ‘Shipped.’ This custom order status can be incredibly valuable for online stores that want to provide more precise tracking information to their customers. Once an order has been successfully shipped, changing the order status to ‘Shipped’ helps to clearly communicate to customers that their package is on its way. This not only keeps customers informed but also instills confidence in the ordering process.

Steps on How To Create a Custom Order Status

To create a custom order status in WooCommerce, follow these simple steps. First, open your WordPress dashboard and navigate to the functions.php file of your active theme. Then, add the following WooCommerce function to register the new custom order status:


function add_custom_order_status() {
    register_post_status('wc-shipped', array(
        'label'                     => 'Shipped',
        'public'                    => true,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop('Shipped <span class="count">(%s)</span>', 'Shipped <span class="count">(%s)</span>')
    ));
}
add_action('init', 'add_custom_order_status');

In the above code snippet, we’re using the register_post_status function to create a new custom order status called ‘Shipped.’ This function accepts various parameters, including the label for the status, visibility settings, and display preferences. Once you’ve added the code to the functions.php file (recommended to use a child theme), save it, and the custom order status ‘Shipped’ will be successfully registered in WooCommerce. You can now assign this status to orders as needed, providing more accurate tracking information to your customers throughout the fulfillment process.

Next, you need to add the custom order status ‘Shipped’ to the existing WooCommerce order statuses array, use the following code snippet in your functions.php file:


function add_custom_order_status_to_array($order_statuses) {
    $position = array_search('wc-processing', array_keys($order_statuses));
    $order_statuses = array_slice($order_statuses, 0, $position + 1, true) +
        ['wc-shipped' => 'Shipped'] +
        array_slice($order_statuses, $position + 1, null, true);
    return $order_statuses;
}
add_filter('wc_order_statuses', 'add_custom_order_status_to_array');

In the above code, we’re using the wc_order_statuses filter hook to modify the order statuses array. By leveraging the array_search and array_slice functions, we position the ‘Shipped’ status between ‘Processing’ and ‘Completed’.

How to Select Custom Order Status

Once you’ve added the above code snippets to your functions.php file and saved it, the ‘Shipped’ status will be positioned correctly between ‘Processing’ and ‘Completed’ in the order statuses list within WooCommerce. You can then assign this custom status to orders as needed, ensuring smooth order management and tracking.

WooCommerce Custom Order Status "Shipped" Guide Tutorial by Robert Mullineux

Style the Custom Order Status

WooCommerce assigns a grey color to any new custom order status. However, if you prefer to visually distinguish the order statuses by color, you have the option to apply custom CSS code. This allows you to specify a specific hexadecimal value to display on the All Orders table, making it easier to identify and differentiate between different order statuses at a glance.

To add custom CSS classes to the WordPress admin area for order status labels, you can use the following function in your functions.php file:


function add_custom_order_status_admin_css() {
    $custom_css = "
        /* Change the color of the 'Shipped' order status label */
        .post-type-shop_order .status-shipped {
            color: #C2185B; /* Replace with your desired color */
            background: #F8BBD0; /* Replace with your desired color */
        }
        
    ";

    wp_add_inline_style('wp-admin', $custom_css);
}
add_action('admin_enqueue_scripts', 'add_custom_order_status_admin_css');

After adding this code to your functions.php file and saving it, the custom CSS classes will be added to the WordPress admin area. You can then target these classes in your custom CSS to style the order status labels in the Orders > All Orders table accordingly.

WooCommerce Orders Table - Custom Order Status "Shipped" Robert Mullineux

Order Status Emails: Configuring a new email

When it comes to custom order statuses like “Shipped,” it’s important to ensure that the corresponding email content accurately reflects this status update.

To customise the email text for the “Shipped” status, navigate to WooCommerce Settings > Emails within your WordPress dashboard. There, you’ll find a list of email notifications related to different order statuses. Look for the email template associated with the “Shipped” status, it may be named “Custom Order Status Notification”.

By default, WooCommerce provides basic editing options for modifying the content of these emails. However, to have complete control over the email design and layout, you can consider using the Kadence Email Customizer plugin. This powerful plugin enables you to customise not only the text but also the visual appearance of your WooCommerce emails.

With the Kadence Email Customizer plugin (download here) installed and activated, you can easily access a user-friendly interface to make comprehensive changes to the email content. You can modify the text, adjust the styling, add branding elements, include dynamic order details, and more. This plugin empowers you to create professional, personalised email templates that align perfectly with your brand identity and customer communication preferences.

kadence-email-customizer-plugin

Take control of your WooCommerce order management and enhance the communication with your customers by leveraging custom order statuses. By creating and customizing order statuses to align with your unique business needs, you can streamline your workflow, provide accurate tracking information, and deliver a personalized shopping experience. Explore the possibilities of custom order statuses today and extended your online store. If you require assistance with WooCommerce development or general eCommerce development for your business, please don’t hesitate to reach out today and request a free quote.

Facebook
Twitter
Reddit

Get In Touch