How to Show a Product Category Price Range in WooCommerce

How to Show a Product Category Price Range in WooCommerce
On this page
  1. Why Show a Price Range Per Category
  2. Step 1: Filter the Subcategory Count HTML
  3. Troubleshooting
  4. Frequently Asked Questions
  5. Conclusion

You can show a product category price range in WooCommerce by filtering the subcategory count HTML on the shop page and calculating the minimum and maximum prices across every product in that category, replacing or supplementing the default product counter.

Why Show a Price Range Per Category

  • Shoppers browsing categories rather than individual products often want a quick sense of price level before clicking in
  • It sets expectations upfront, reducing bounce from customers who click into a category outside their budget
  • It’s a small addition that can meaningfully improve the browsing experience on category-heavy shops

Step 1: Filter the Subcategory Count HTML

PHP
/** Replace the category product counter with a min-max price range */
add_filter( 'woocommerce_subcategory_count_html', 'display_category_price_range', 9999, 2 );

function display_category_price_range( $html, $category ) {

    $min = PHP_FLOAT_MAX;
    $max = 0.00;

    $product_ids = get_posts( array(
        'post_type'   => 'product',
        'numberposts' => -1,
        'post_status' => 'publish',
        'fields'      => 'ids',
        'tax_query'   => array(
            array(
                'taxonomy' => 'product_cat',
                'field'    => 'slug',
                'terms'    => $category->slug,
            ),
        ),
    ) );

    foreach ( $product_ids as $id ) {

        $product = wc_get_product( $id );

        if ( $product->is_type( 'simple' ) ) {
            $min = min( $min, (float) $product->get_price() );
            $max = max( $max, (float) $product->get_price() );
        } elseif ( $product->is_type( 'variable' ) ) {
            $prices = $product->get_variation_prices();
            if ( ! empty( $prices['price'] ) ) {
                $min = min( $min, (float) current( $prices['price'] ) );
                $max = max( $max, (float) end( $prices['price'] ) );
            }
        }
    }

    return ' (' . wc_format_price_range( $min, $max ) . ')';
}
Show a product category price range in WooCommerce: the page before adding the code
Before
Show a product category price range in WooCommerce: the page after adding the code
After

Troubleshooting

The price range shows for categories with zero visible products

Add a check that skips returning a range (or falls back to the original count) when no matching products were found, to avoid showing a meaningless “(0-0)”.

The page slows down noticeably with many categories

This query runs once per category shown, which can add up on shop pages with many subcategories — consider caching the computed range with a transient that refreshes periodically rather than recalculating on every page load.

Frequently Asked Questions

Can I show both the product count and the price range together?

Yes, adjust the returned string to include both — e.g. append the price range after the original $html count instead of replacing it entirely.

Does this account for sale prices?

As written it uses get_price(), which already reflects the active sale price if one is set — swap to get_regular_price() if you specifically want the range before discounts.

Will this work with excluded/hidden products?

Add a product_visibility taxonomy exclusion to the query if you want to exclude catalog-hidden products from the calculated range.

Conclusion

The woocommerce_subcategory_count_html filter makes it possible to show a product category price range in WooCommerce, giving shoppers a useful price signal before they click into a category.

See also How to Remove Product Category Counters in WooCommerce. Then read How to Show the Product Category on the WooCommerce Shop Page.

Prefer no code? All-in-One Utilities Woo Add-on adds over 50 WooCommerce features, so you can switch them on without code.

Leave a Reply

Schedule a call