Make Processing Orders display by default

And remove/change certain order statuses. This is powerful but must also be used in conjunction with a template override if you want to make Processing be the default loaded filter on the Vendor Orders list page. You should not be a novice if you are attempting this by yourself, or at the very least try it on a staging site first.

Part 1: Edit the filter drowndown options to make processing show on top, remove the option to show all, and remove certain statuses from the options.

I wanted to make Processing be the default filter option, so I had to remove the “All” orders option and replace it with Processing. Next, I chose which order statuses I did not want to display. I try to keep it simple for my vendors, and they don’t need the clutter of order statuses they’ll never see. Finally, we have the ability to rename current options with this as well, if desired.

Here’s the code snippet for your Child Theme’s functions.php file:

// COMBINED CODE TO MAKE PROCESSING DEFAULT, REMOVE UNWANTED, AND RENAME DROPDOWN OPTIONS

// NOTE: NEED TO ALSO MAKE CHANGES TO TEMPLATE AND OVERRIDE IT FOR PROCESSING TO BE DEFAULT

// 1-- ORDERS LIST PAGE FILTER DROPDOWN CHANGES
add_filter('wcmp_vendor_dashboard_order_filter_status_arr', 'change_default_status');

function change_default_status($arr) {
    unset($arr['all']);  // Unset All orders display
    $new['wc-processing'] = 'Processing Orders';  // Replaces All with Processing to make default

    // Unset unnecessary options
    unset($arr['wc-processing']);  // Unset processing option because it is the new All, above
    unset($arr['wc-failed']);  // Choose which other status to unset
    unset($arr['wc-refunded']);
    unset($arr['wc-pending']);
    unset($arr['wc-on-hold']);
    
    // Rename current statuses if desired
    $arr['wc-completed'] = __('Completed Orders', 'dc-woocommerce-multi-vendor');
    $arr['wc-cancelled'] = __('Cancelled Orders', 'dc-woocommerce-multi-vendor');

    $status= array_merge($new,$arr); //combine everything and return
    
return $status;
}

Important: This first step will force the filter box DISPLAY to default to Processing, but it will not actually load the orders list with only processing orders displayed in the table. To do that, find vendor-orders.php, download it, and override it in your child theme according to the instructions at the top of the file.

Next, find this section, somewhere around line 195 to 207. We are going to find the highlighted line…

ajax: {	
    url: '<?php echo add_query_arg( 'action', 'wcmp_datatable_get_vendor_orders', $WCMp->ajax_url() ); ?>',	
    type: "post",	
    data: function (data) {	
        data.orders_filter_action = $('form#wcmp_order_list_form').serialize();	
        data.start_date = '<?php echo $start_date; ?>';	
        data.end_date = '<?php echo $end_date; ?>';	
        data.bulk_action = $('#order_bulk_actions').val();	
        data.order_status = $('#filter_by_order_status').val();	
                },

And replace it with:

data.order_status = !$('#filter_by_order_status').val() ? 'wc-processing' : $('#filter_by_order_status').val();

This should make the list of orders display only processing orders by default as soon as your vendor loads the page. There are other neat tricks you can do with this file, which you can find browsing the site.


Part 2: Do the same order status edits for the Single Order page, where the vendor clicks “edit” to change that order’s status.

This will actually remove the vendor’s ability to change the order status to one that you don’t want them to. Like, why would a vendor need to manually change an order status to “Failed”? So, this cleans it up and can be adjusted to your needs.

Here’s the code snippet for your Child Theme’s functions.php file:

// 2-- SINGLE ORDER PAGE CHANGES
add_filter('wcmp_vendor_order_statuses', 'remove_wcmp_single_order_status_change_options');

function remove_wcmp_single_order_status_change_options($arr) {

    // Unset unnecessary options
    unset($arr['wc-failed']); 
    unset($arr['wc-refunded']);
    unset($arr['wc-pending']);
    unset($arr['wc-on-hold']);

    // Rename current statuses if desired
    $arr['wc-completed'] = __('Completed', 'dc-woocommerce-multi-vendor');
    $arr['wc-cancelled'] = __('Cancel Order (does not refund)', 'dc-woocommerce-multi-vendor');

return $arr;
}

Tested and working on Woocommerce 4.6.1, WCMp 3.5.10

Is this no longer relevant or not working? Please let us know in the comments!

Comments on this post

Your email address will not be published. Required fields are marked *