Author Topic: How to add product quantities to category pages  (Read 3995 times)

Offline dharding

  • Newbie
  • *
  • Posts: 41
  • Karma: +7/-0
    • View Profile
How to add product quantities to category pages
« on: January 05, 2018, 12:51:21 PM »
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.

Offline abantecart

  • Administrator
  • Hero Member
  • *****
  • Posts: 4358
  • Karma: +298/-10
    • View Profile
    • Ideal Open Source Ecommerce Solution
Re: How to add product quantities to category pages
« Reply #1 on: January 06, 2018, 11:29:28 PM »
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:
Code: [Select]
<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

Offline dharding

  • Newbie
  • *
  • Posts: 41
  • Karma: +7/-0
    • View Profile
Re: How to add product quantities to category pages
« Reply #2 on: January 07, 2018, 05:08:35 PM »
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.

Offline dharding

  • Newbie
  • *
  • Posts: 41
  • Karma: +7/-0
    • View Profile
Re: How to add product quantities to category pages
« Reply #3 on: January 24, 2018, 10:35:49 PM »
Bumping this thread, since I didn't get a reply to my last response. Thanks.

 

Powered by SMFPacks Social Login Mod