I've found a fair solution. It's a bit hacky... but it works
First, add the submenu to WooCommerce menu:
add_action( 'admin_menu', 'custom_status_menu', 50 );
function custom_status_menu(){
$status_page = add_submenu_page( 'woocommerce', 'Awaiting Shipment', __( 'Awaiting', 'woocommerce' ), 'manage_woocommerce', 'wc-awaiting', 'awaiting_orders_page' );
}
Then, add a function to run when you click this menu item. This function (and here is the hacky part) will redirect the user to the regular orders page, just showing the requested status. (for testing I used "Canceled" status, you should change that)
function awaiting_orders_page(){
header('Location: /wp-admin/edit.php?post_status=wc-cancelled&post_type=shop_order');
}
And lastly, add the counter. Same here, I used "awaiting" status, change it to the one your created
add_action( 'admin_head', 'add_custom_status_count');
function add_custom_status_count(){
global $submenu;
$order_count = wc_orders_count( 'awaiting' );
foreach ( $submenu['woocommerce'] as $key => $menu_item ) {
if ( 0 === strpos( $menu_item[0], 'Awaiting' ) ) {
$submenu['woocommerce'][ $key ][0] .= ' <span class="awaiting-mod update-plugins count-' . esc_attr( $order_count ) . '"><span class="processing-count">' . number_format_i18n( $order_count ) . '</span></span>'; // WPCS: override ok.
break;
}
}
}