Search the site:

Home Blog How to Rename Order Status Messages in WooCommerce

How to Rename Order Status Messages in WooCommerce

Sometimes, for various reasons, you may want to rename order status messages for your customers, or even for your store administrators. This could be for various reasons e.g. because you want the tone or language of your status messages to be consistent with that of the rest of your store, or to maintain exclusivity, or to offer a personalised touch to the orders placed by your customers or even to make it easier for your shop managers to understand what the status means. Let’s dive into this post to see how you can rename order status messages in WooCommerce.

By default, WooCommerce order status messages look like this:

Rename Order Status Messages in WooCommerce - Default Order Status Messages

These messages also get displayed on the front-end whenever a customer tries to place an order. We can use a simple code snippet to use custom messages in place of these.

Just insert the following code in the functions.php file of your child theme:

add_filter( 'wc_order_statuses', 'ts_rename_order_status_msg', 20, 1 );
function ts_rename_order_status_msg( $order_statuses ) {
    $order_statuses['wc-completed']  = _x( 'Order Received', 'Order status', 'woocommerce' );
    $order_statuses['wc-processing'] = _x( 'Your Order is being processed', 'Order status', 'woocommerce' );
    $order_statuses['wc-on-hold']    = _x( 'Your Order is on hold', 'Order status', 'woocommerce' );
    $order_statuses['wc-pending']    = _x( 'Your Order is pending', 'Order status', 'woocommerce' );

    return $order_statuses;
}

Rename Order Status Messages in WooCommerce - Order Status Messages changed

You will see that the order status has changed. We used the hook wc_order_statuses here, and attached our function ts_rename_order_status_msg to it. The $order_statuses array that we passed as the argument contains the status messages as its first value.

The status messages also change in the front-end, where you check your order status under My account->Orders:

Rename Order Status Messages in WooCommerce - Order Status Messages changed in the front end

There are two other places though where the order status message gets displayed i.e. in the top menu inside the Admin Dashboard, and also in the dropdown for Bulk Actions:

Rename Order Status Messages in WooCommerce - Order Status Messages in the Top Menu and Bulk Actions in the Admin Dashboard

These status messages can be changed too using two other hooks to which we will attach two other functions.

Add the below code to the functions.php file of your child theme to change the status message in the top menu:

foreach( array( 'post', 'shop_order' ) as $hook )
    add_filter( "views_edit-shop_order", 'ts_order_status_top_changed' );

function ts_order_status_top_changed( $views ){
    if( isset( $views['wc-completed'] ) )
        $views['wc-completed'] = str_replace( 'Completed', __( 'Order Received', 'woocommerce'), $views['wc-completed'] );

    if( isset( $views['wc-processing'] ) )
        $views['wc-processing'] = str_replace( 'Processing', __( 'In Process', 'woocommerce'), $views['wc-processing'] );

    if( isset( $views['wc-on-hold'] ) )
        $views['wc-on-hold'] = str_replace( 'On hold', __( 'Order on Hold', 'woocommerce'), $views['wc-on-hold'] );

    if( isset( $views['wc-pending'] ) )
        $views['wc-pending'] = str_replace( 'Pending payment', __( 'Payment Pending', 'woocommerce'), $views['wc-pending'] );

        return $views;
}

You can see that we have used views_edit-shop_order hook here to simply replace the String values that each array key (for different order status messages) contains.

Rename Order Status Messages in WooCommerce - Order Status Message changed in Admin Top Menu

 

Now, the last place that we have to change the order status messages (if necessary) is the Bulk Actions dropdown that we highlighted above. For this, we will use yet another code snippet and add it to the same functions.php file:

add_filter( 'bulk_actions-edit-shop_order', 'ts_bulk_actions_order_status', 20, 1 );

function ts_bulk_actions_order_status( $actions ) {
    $actions['mark_processing'] = __( 'Mark as In Process', 'woocommerce' );
    $actions['mark_on-hold']    = __( 'Mark as Order on Hold', 'woocommerce' );
    $actions['mark_completed']  = __( 'Mark as Order Received', 'woocommerce' );

    return $actions;
}

Here, the bulk_actions-edit-shop_order hook is being used to change the values of the different actions that are applied to orders.

You can see that the order status messages will have changed in this dropdown:

Rename Order Status Messages in WooCommerce - Bulk Actions Order Status Message changed

In this manner, you can change the order status messages at all places depending on your preference.

While these code snippets will help you change the order status messages, if you want to add a custom order status instead or even send custom emails to your customers based on these order status messages, you can use our plugin Custom Order Status to do so.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of
from purchased

Subscribe Now