Remove Porduct Category Product Count - by longislanddarts

This topic has 4 replies, 3 voices, and was last updated 7 years, 3 months ago ago by Rose Tyler

  • Avatar: longislanddarts
    longislanddarts
    Participant
    October 10, 2016 at 03:54

    Hello:

    I want to remove the product count that appears in parenthesis in each of my product categories.

    Please tell me how

    Thanks
    LT

    3 Answers
    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    October 10, 2016 at 08:31

    Hello,

    To hide products count you need to comment the code in the wp-content/themes/legenda/woocommerce/content-product_cat.php file:

    if ( $category->count > 0 )
    echo apply_filters( 'woocommerce_subcategory_count_html', ' (' . $category->count . ')', $category );

    We recommend to make any changes in theme source files in child theme https://codex.wordpress.org/Child_Themes so you won’t lose your customizations after the next theme update.

    Regards,
    Rose Tyler.

    Avatar: shoparah
    shoparah
    Participant
    July 27, 2017 at 17:51

    I copied the folder into my child theme under a woo commerce folder I already previously had in my child theme. However when copy pasting the code at the bottom of content-product_cat.php and saving it it would just show those words on my front end shop page and didn’t hide the count it did not work.

    I noticed in the php folder the code you’re telling me to add into the file already exists, as you can see below I copy pasted the entire code from the folder below and the code already exists in there:

    <?php
    /**
    * The template for displaying product category thumbnails within loops.
    *
    * Override this template by copying it to yourtheme/woocommerce/content-product_cat.php
    *
    * @author WooThemes
    * @package WooCommerce/Templates
    * @version 2.6.1
    */

    if ( ! defined( ‘ABSPATH’ ) ) exit; // Exit if accessed directly

    global $woocommerce_loop;

    // Store loop count we’re currently on
    if ( empty( $woocommerce_loop[‘loop’] ) )
    $woocommerce_loop[‘loop’] = 0;

    // Store column count for displaying the grid
    if ( empty( $woocommerce_loop[‘columns’] ) )
    $woocommerce_loop[‘columns’] = apply_filters( ‘loop_shop_columns’, 4 );

    // Increase loop count
    $woocommerce_loop[‘loop’]++;

    if ( etheme_get_option( ‘product_page_image_width’ ) != ” && etheme_get_option( ‘product_page_image_height’ ) != ” ) {
    $image_size = array();
    $image_size[] = etheme_get_option(‘product_page_image_width’);
    $image_size[] = etheme_get_option(‘product_page_image_height’);
    } else {
    $image_size = apply_filters( ‘single_product_large_thumbnail_size’, ‘shop_catalog’ );
    }

    ?>
    <div class=”span4 product-category <?php
    if ( ( $woocommerce_loop[‘loop’] – 1 ) % $woocommerce_loop[‘columns’] == 0 || $woocommerce_loop[‘columns’] == 1)
    echo ‘ first’;
    if ( $woocommerce_loop[‘loop’] % $woocommerce_loop[‘columns’] == 0 )
    echo ‘ last’;
    ?>”>

    <?php do_action( ‘woocommerce_before_subcategory’, $category ); ?>

    <div class=”mask-container”>

    <?php

    $thumbnail_id = get_woocommerce_term_meta( $category->term_id, ‘thumbnail_id’, true );

    if ( $thumbnail_id ) {
    $image = wp_get_attachment_image_url( $thumbnail_id, $image_size );
    echo ‘name . ‘” />’;
    } else {
    echo wc_placeholder_img( $image_size );
    }

    ?>

    <div class=”block-mask”>
    <div class=”mask-content”>
    slug, ‘product_cat’ ); ?>”><i class=”icon-link”></i>
    </div>
    </div>
    </div>

    slug, ‘product_cat’ ); ?>”><h5>
    <?php
    echo $category->name;

    if ( $category->count > 0 )
    echo apply_filters( ‘woocommerce_subcategory_count_html’, ‘ (‘ . $category->count . ‘)’, $category );
    ?>
    </h5>

    <?php
    /**
    * woocommerce_after_subcategory_title hook
    */
    do_action( ‘woocommerce_after_subcategory_title’, $category );
    ?>

    <?php do_action( ‘woocommerce_after_subcategory’, $category ); ?>

    </div>

    Avatar: Rose Tyler
    Rose Tyler
    Support staff
    July 28, 2017 at 09:00

    Hello, @shoparah,

    You’ve been replied in other topic.
    Please check.

    Regards

  • Viewing 4 results - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.Log in/Sign up

8theme customization service
We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.