Tagged: woocommerce
Hello
How Can I Display Product Count View in each Category ?
I don’t find the Hook to do this
Sorry
Thx :)
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
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;
}
}
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
Exactly what I Want
Thx