How to add product quantities to category pages

Started by dharding, January 05, 2018, 12:51:21 PM

Previous topic - Next topic

dharding

Doing a search on this forum finds that this question was asked as early as 2013, but I cannot find that it was ever addressed.

On category pages where subcategories are shown, how do I display the number of products within each category next to or below the subcategory link?

I'm not talking about variations or options, just the number of discrete products within that subcategory and its subcategories, i.e., recursive total?

For those storefronts with a large number of categories and subcategories, this is useful for the customer when shopping.

Thank you.

abantecart

I assume you like to show this in the menu for every category.

Product count is available in the data provided to view file in the category.
Depending on the block you use you can add $category['product_count'] to show count

For example in categories at the top:
public_html/storefront/view/default/template/blocks/category.tpl:16

In line 21 add/replace:

<a class="productname" href="<?php echo $item['info_url'?>"><?php echo $item['name']?> - <?php echo $item['product_count']?></a>




Please  rate your experience or leave your review
We need your help to build better free open source ecommerce platform for everyone. See how you can help

dharding

Thank you for the response. I have tried implementing this in several places, but the variable is not populating. No number, no text, nothing. For example if I surround the echo command with parentheses, all I get on the page is "()" regardless of the category or subcategory shown.

I tried posting a code snippet in this post, but I get an error message "Sorry, you are not allowed to post external links" so somehow the php code is being interpreted here as an external link.

dharding

Bumping this thread, since I didn't get a reply to my last response. Thanks.

Forum Rules Code of conduct
AbanteCart.com 2010 -