I will get you some idea on how to do this as you didn’t mention from where count data will come. Add following code to your theme/child-theme functions.php
file
function custom_admin_bar_menu() {
$pending_count = wc_orders_count('pending');
$on_hold_count = wc_orders_count('on-hold');
$processing_count = wc_orders_count('processing');
if ( current_user_can( 'manage_options' ) ) {
global $wp_admin_bar;
//Add an icon with count
$wp_admin_bar->add_menu( array(
'id' => 'custom-1', //Change this to yours
'title' => '<span class="ab-icon dashicons dashicons-cart"></span><span class="ab-label">'.$pending_count.'</span>',
'href' => get_admin_url( NULL, 'edit.php?post_status=wc-pending&post_type=shop_order' ),//Replace with your resired destination
) );
//Add another icon with count
$wp_admin_bar->add_menu( array(
'id' => 'custom-2', //Change this to yours
'title' => '<span class="ab-icon dashicons dashicons-chart-line"></span><span class="ab-label">'.$on_hold_count.'</span>',
'href' => get_admin_url( NULL, 'edit.php?post_status=wc-on-hold&post_type=shop_order' ),//Replace with your resired destination
) );
//Add another icon with count
$wp_admin_bar->add_menu( array(
'id' => 'custom-3', //Change this to yours
'title' => '<span class="ab-icon dashicons dashicons-carrot"></span><span class="ab-label">'.$processing_count.'</span>',
'href' => get_admin_url( NULL, 'edit.php?post_status=wc-processing&post_type=shop_order' ),//Replace with your resired destination
) );
//You can add more as per your need.
}
}
add_action( 'admin_bar_menu', 'custom_admin_bar_menu' , 500 );
The 0
inside <span class="ab-label">0</span>
represents the count. You can easily replace that by using a variable and some custom query.