WooCommerce Hide Quantity in Category List View

For a presentation of the product categories, a gallery of the images, together with their category title, I wished to hide the default showing of the number of products associated with each of the categories.

This is the number in brackets after the category title when in the category list view.

A number of approaches came to mind:

  • CSS
  • functions.php
  • WooCommerce templates

CSS

Using CSS to hide parts of the WooCommerce presentation is often suggested as an answer.

I feel that the CSS approach is rather simplistic. The content is still on the page and just may escape into view dependant upon circumstance, such as differences in browser.

WooCommerce Template

A copy of the relevant WooCommerce template(s) can be copied into the theme and edited appropriately to override the default actions.

The theme files are in the WooCommerce plugin within the templates directory.

The location for these files within the plugin is a directory called WooCommerce.

The idea of copying the relevant WooCommerce from the plugin into the theme and

I also like to avoid copying and editing the default WooCommerce template files if I can.

This approach is particularly subject to changes made to the core WooCommerce templates. Likely to require occasional updated of the files. Event if it is simply amending the version which it pertains to.

Functions.php file

I like using the functions.php file to access and amend WooCommerce presentation via the hooks and overrides.

Its handy to have a set of functions which can be incorporated and individual entries turned on or off.

// Hide Product Category Count
function vntweb_hide_category_product_count() {
  /* empty - no count */
}
add_filter( 'woocommerce_subcategory_count_html', 'vntweb_hide_category_product_count' );

An adaptation of this would be to include your WooCommerce functions and adaptations with a referenced separate file.