How to create a WooCommerce custom order status.

Woocommerce being an open-source and free eCommerce shop you can create using WordPress, All you need is to install the plugin, activate, set up upload the product. Depend on which theme You are using, You may need to do some redesign of the layout. when you manage to set up your you will be able now to sell and deliver the product in your store. If you advance and make a Multivendor store you will need to add some custom order status like Packing and waiting for fulfillment:

Available Order Status:

  • Completed
  • Processing
  • Pending payment
  • On hold
  • Refunded
  • Canceled
  • Failed
How to add Custom Order Status to your WordPress Woocommerce eCommerce website

How can we add the function?

All that is needed is to add these function code:

COPY AND PASTE To use the code.

 * Register new statuses - add an array for each status
 * code created by
 * youtube tutorial: thiarara
function register_new_wc_order_statuses() {
    register_post_status( 'wc-awaiting-shipment', array(
        'label'                     => 'Awaiting shipment',
        'public'                    => true,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'Awaiting shipment (%s)', 'Awaiting shipment (%s)' )
    ) );
    register_post_status( 'wc-packing', array(
        'label'                     => 'Packing',
        'public'                    => true,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'Packing (%s)', 'Packing (%s)' )
    ) );
    // repeat register_post_status() for each new status
add_action( 'init', 'register_new_wc_order_statuses' );
// Add new statuses to list of WC Order statuses
function add_new_wc_statuses_to_order_statuses( $order_statuses ) {
    $new_order_statuses = array();
    // add new order statuses after processing
    foreach ( $order_statuses as $key => $status ) {
        $new_order_statuses[ $key ] = $status;
        if ( 'wc-processing' === $key ) {
            $new_order_statuses['wc-awaiting-shipment'] = 'Awaiting shipment';
            $new_order_statuses['wc-packing'] = 'Packing';
            // Add a $new_order_statuses[key] = value; for each status you've added (in the order you want)
    return $new_order_statuses;
add_filter( 'wc_order_statuses', 'add_new_wc_statuses_to_order_statuses' );

Function added using the code includes:

  • Awaiting Shipment
  • Packing

How can you add the code to your WordPress eCommerce website:

  • All you will need is to go to the plugin repository
  • Install and activate the plugin. After the activation, scroll to your WordPress menu and you will find a button for snippets, and on hover, three options will pop up.
  • Give your snippets a name.
  • Paste your snippets function code
  • save and activate your code.

With that, you will be able to use the WooCommerce custom status on your eCommerce website. Hope the tutorial was of great help to you. Subscribe to our newsletter to never miss out on new post:

Share on facebook
Share on twitter
Share on linkedin
Share on reddit
Share on whatsapp
Share on telegram

One Response

  1. Needed to put you one little bit of note just to thank you very much yet again about the gorgeous strategies you’ve shared
    above. It was simply particularly open-handed with you
    to allow publicly what exactly many individuals might have distributed as an ebook to generate some cash on their own, chiefly considering the fact that you might well have done it if
    you considered necessary. Those inspiring ideas as well worked
    like a easy way to be certain that other people have similar zeal
    really like my personal own to grasp much more when considering
    this problem. I’m sure there are numerous more enjoyable periods in the future for many
    who scan your blog.

Leave a Reply