How can I add a custom woocommerce order status in bulk update menu and top menu?

Viewed 129

I have added a new woocommerce order status named "Delivered" by adding the following php snippet. But this option is missing from Bulk Actions' dropdown and top bar menu in Woocommerce order section. I have attached screenshot. Plz have a look and help me how can I add my custom order status in these two places.

The custom option I added

Mising in Bulk action

Missing in top bar of order section

// Register new status
function register_delivery_status() {
    register_post_status( 'wc-delivered', array(
        'label'                     => 'Delivered',
        'public'                    => true,
        'exclude_from_search'       => false,
        'show_in_admin_all_list'    => true,
        'show_in_admin_status_list' => true,
        'label_count'               => _n_noop( 'Delivered (%s)', 'Delivered (%s)' )
    ) );
}
add_action( 'init', 'register_delivery_status' );


// Add to list of WC Order statuses
function add_delivered_to_order_statuses( $order_statuses ) {
 
    $new_order_statuses = array();
 
    // add new order status after processing
    foreach ( $order_statuses as $key => $status ) {
 
        $new_order_statuses[ $key ] = $status;
 
        if ( 'wc-processing' === $key ) {
            $new_order_statuses['wc-delivered'] = 'Delivered';
        }
    }
 
    return $new_order_statuses;
}
add_filter( 'wc_order_statuses', 'add_delivered_to_order_statuses' );
0 Answers
Related