Dashboard add count menu subscription

function tzn_custom_change_shop_subscription_menu_label()
{
    global $submenu;
    if (isset($submenu['woocommerce'])) {
        foreach ($submenu['woocommerce'] as $key => $menu_item) {
            $subscription_ids = get_posts( array(
				'post_type'      => 'shop_subscription',
				// 'post_status'    => array( 'wc-pending', 'wc-active', 'wc-on-hold' ),
                'post_status' => 'any',
				'posts_per_page' => -1,
				'fields'         => 'ids',
			) );
            $order_count = count($subscription_ids );
            if ($key == 2) {
                $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>';
                break;
            }
        }
    }
}
add_action('admin_menu', 'tzn_custom_change_shop_subscription_menu_label', 10, 1);

Leave a Reply

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