I'm currently trying to add new quick filters (subsubsub) to the WooCommerce admin orders list:
I've a custom order status which is named "wc-test-accepted". How can I add a new quick filter for my custom order status to the top?
I'm currently trying to add new quick filters (subsubsub) to the WooCommerce admin orders list:
I've a custom order status which is named "wc-test-accepted". How can I add a new quick filter for my custom order status to the top?
To get the related filter to your custom order status "wc-test-accepted" in the orders statuses menu filter, you just need to change the status of at least one order and the filter will appear.
The following code will add new a custom order status "wc-test-accepted" (Accepted):
// Register new custom order status
add_action('init', 'register_custom_order_statuses');
function register_custom_order_statuses() {
register_post_status('wc-test-accepted ', array(
'label' => __( 'Accepted', 'woocommerce' ),
'public' => true,
'exclude_from_search' => false,
'show_in_admin_all_list' => true,
'show_in_admin_status_list' => true,
'label_count' => _n_noop('Accepted <span class="count">(%s)</span>', 'Accepted <span class="count">(%s)</span>')
));
}
// Add new custom order status to list of WC Order statuses
add_filter('wc_order_statuses', 'add_custom_order_statuses');
function add_custom_order_statuses($order_statuses) {
$new_order_statuses = array();
// add new order status before processing
foreach ($order_statuses as $key => $status) {
$new_order_statuses[$key] = $status;
if ('wc-processing' === $key) {
$new_order_statuses['wc-test-accepted'] = __('Accepted', 'woocommerce' );
}
}
return $new_order_statuses;
}
// Adding new custom status to admin order list bulk dropdown
add_filter( 'bulk_actions-edit-shop_order', 'custom_dropdown_bulk_actions_shop_order', 50, 1 );
function custom_dropdown_bulk_actions_shop_order( $actions ) {
$new_actions = array();
// add new order status before processing
foreach ($actions as $key => $action) {
if ('mark_processing' === $key)
$new_actions['mark_test-accepted'] = __( 'Change status to Accepted', 'woocommerce' );
$new_actions[$key] = $action;
}
return $new_actions;
}
Code goes in function.php file of your active child theme (or active theme). Tested and works.
Once you change at least one order to "Accepted" order status, It appears as a filter: