WooCommerce Bulk order status with filter list [Free Php Code]

advert

Learn how to use WooCommerce bulk order status to quickly update your order statuses for all of the orders in a certain order status. You can also tell WooCommerce which orders are included and excluded.

Features we will add in these tutorial:

Bulk order status dropdown.
Order Menu filter
Renamed order status.

The tutorial will be divided in three potion:

  • Rename order status.
  • Add bulk edit order list dropdown.
  • Add filter to order menu.

Use code snippet plugging to facilitate the additional code to your website.

Attached YouTube tutorial attached will offer much guidance on how to add and set up the features

Renaming Order status: For you to be able to rename existing order status you will need to add these code:

/** Rename order status **/
add_filter( 'wc_order_statuses', 'rename_order_statuses', 20, 1 );
function rename_order_statuses( $order_statuses ) {
    $order_statuses['wc-completed']  = _x( 'Order Delivered', 'Order status', 'woocommerce' );
    $order_statuses['wc-processing'] = _x( 'paid', 'Order status', 'woocommerce' );
    $order_statuses['wc-on-hold']    = _x( 'Pending Delivery', 'Order status', 'woocommerce' );
    $order_statuses['wc-pending']    = _x( 'Waiting Payment', 'Order status', 'woocommerce' );

    return $order_statuses;
}

Adding bulk order list dropdown. Use the code below to add dropdown list option.

WooCommerce list dropdown
/** Add 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 Delivery', 'woocommerce' );
    $actions['mark_completed']  = __( 'Mark order received', 'woocommerce' );

    return $actions;
}

Add filter to order menu; Use the code below to add WooCommerce bulk order status filter.

/** Add filter to order 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 Delivered', '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 Delivery', 'woocommerce'), $views['wc-on-hold'] );

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

    return $views;
}

You may also like to read these: How To Temporarily Disable Checkout In WooCommerce

To add all features, use the code below:

/**
  * Author: Thiarara
  * Version: 1.1 0
  * licence: Free GPL
  * Topic: woo bulk order status with filter
  * Email support: contact@thiarara.co.ke
 **/

/** Rename order status **/
add_filter( 'wc_order_statuses', 'rename_order_statuses', 20, 1 );
function rename_order_statuses( $order_statuses ) {
    $order_statuses['wc-completed']  = _x( 'Order Delivered', 'Order status', 'woocommerce' );
    $order_statuses['wc-processing'] = _x( 'paid', 'Order status', 'woocommerce' );
    $order_statuses['wc-on-hold']    = _x( 'Pending Delivery', 'Order status', 'woocommerce' );
    $order_statuses['wc-pending']    = _x( 'Waiting Payment', 'Order status', 'woocommerce' );

    return $order_statuses;
}

/** Add 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 Delivery', 'woocommerce' );
    $actions['mark_completed']  = __( 'Mark order received', 'woocommerce' );

    return $actions;
}

/** Add filter to order 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 Delivered', '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 Delivery', 'woocommerce'), $views['wc-on-hold'] );

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

    return $views;
}

You may also like to read these: WooCommerce Order Status ( Autocomplete paid WooCommerce orders)

advert:

Support us:

1
0
Would love your thoughts, please comment.x
()
x

Login To Access Code Snippet:

Stay UpTo Date with Latest Post And news: