Rather than adding shortcode you have to add the hook which is on the product category page:
// Use this hook for working directly on category page
// add_action( 'woocommerce_archive_description', 'show_category_product_counts', 10 );
// Use this shortcode hook if you want to put on anywhere in the category page if you are using Elementor/WPBakery
add_shortcode( 'product_cat_count', 'show_category_product_counts', 10);
function show_category_product_counts( ) {
// Return if it is product archive/Shop page
if( !is_product_category())
return false;
// Get product category object
$category = get_queried_object();
$categoryId = $category->term_id;
$term = get_term( $categoryId, 'product_cat' );
echo 'Product Category: '
. $term->name . ' ('
. $term->count
. ' Items)';
}
Please add this code to your active theme’s function.php
file.
It will show the product category count on the category page after the category title.
Note: You can make changes in the last line in the function to print the text.