4
votes

I'm trying to rename multiple WooCommerce order status by editing my theme's functions.php file. I found some code posted here a couple years ago that works to change a single order status, but since I'm very inexperienced with php, I don't know how to expand on it to change multiple statuses. Ideally I'd also like to rename 'wc-processing' to 'Paid' and 'wc-on-hold' to 'Pending'.

Here's the code I found to edit a single order status:

function wc_renaming_order_status( $order_statuses ) {
    foreach ( $order_statuses as $key => $status ) {
        $new_order_statuses[ $key ] = $status;
        if ( 'wc-completed' === $key ) {
            $order_statuses['wc-completed'] = _x( 'Order Received', 'Order status', 'woocommerce' );
        }
    }
    return $order_statuses;
}
add_filter( 'wc_order_statuses', 'wc_renaming_order_status' );

Anyone know what changes I need to make to change additional statuses?

1

1 Answers

16
votes

As Pending order status exist, you need also to rename the existing "Pending" status. If not you will get 2 different statuses with the same "Pending" label.

First to rename those order statuses:

add_filter( 'wc_order_statuses', 'rename_order_statuses', 20, 1 );
function rename_order_statuses( $order_statuses ) {
    $order_statuses['wc-completed']  = _x( 'Order Received', 'Order status', 'woocommerce' );
    $order_statuses['wc-processing'] = _x( 'Paid', 'Order status', 'woocommerce' );
    $order_statuses['wc-on-hold']    = _x( 'Pending', 'Order status', 'woocommerce' );
    $order_statuses['wc-pending']    = _x( 'Waiting', 'Order status', 'woocommerce' );

    return $order_statuses;
}

And Also in the bulk edit order list dropdown:

add_filter( 'bulk_actions-edit-shop_order', 'custom_dropdown_bulk_actions_shop_order', 20, 1 );
function custom_dropdown_bulk_actions_shop_order( $actions ) {
    $actions['mark_processing'] = __( 'Mark paid', 'woocommerce' );
    $actions['mark_on-hold']    = __( 'Mark pending', 'woocommerce' );
    $actions['mark_completed']  = __( 'Mark order received', 'woocommerce' );

    return $actions;
}

enter image description here

And also this is needed (for the top menu):

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

function shop_order_modified_views( $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', __( 'Paid', 'woocommerce'), $views['wc-processing'] );

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

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

    return $views;
}

(Thanks to brasofilo : Change WP admin post status filter for custom post type)

enter image description here

Code goes in function.php file of your active child theme (or active theme). Tested and works.

Since Woocommerce 3.3 to handle the preview popup (eye symbol) in admin order list:

Replace order status names everywhere incl. Woocommerce admin order preview