Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #440307

    Hello

    How Can I Display Product Count View in each Category ?

    I don’t find the Hook to do this

    Example :http://us.levi.com/family/index.jsp?ab=Men_leftNav_Categories_t-shirts&categoryId=24306336&cp=3146842.3146845

    Sorry

    Thx :)

    #441050

    Hi Veesibility!

    I would try contacting Woocommerce support. Maybe there is an extension you can use or someone has done this before and posted their solution.

    Regards,
    Elliott

    #441084

    Ok Thx

    I looked for a solution without success but I will try again

    I built this Hook but it doesn’t work like I want

    add_action( 'woocommerce_before_shop_loop', 'add_product_count_view', 10);
    function add_product_count_view() {
    $terms = get_the_terms( $post->ID,'product_cat' );
    foreach( $terms as $term ) 
    {
        echo 'Product Category: '
            . $term->name
            . ' - Count: '
            . $term->count;
    
    }
    }  
    #442041

    Hi!

    I tested your code on my installation and it works. Maybe, you just need to add a line of code to check if you’re on a particular product category:

    add_action( 'woocommerce_before_shop_loop', 'add_product_count_view', 10);
    function add_product_count_view() {
    	$terms = get_the_terms( $post->ID, 'product_cat');
    	foreach( $terms as $term ) {
    	if(is_tax('product_cat', $term->name)) {
    		echo 'Product Category: '
    			. $term->name
    			. ' - Count: '
    			. $term->count;
    		}
    	}
    }  

    Regards,
    Ismael

    #442399

    Exactly what I Want

    Thx

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Display Product Count View in Categories’ is closed to new replies.