Hi, all,
For emenu categories, how to display the number of total product quantity for each category behind the category name ? So, people will know how many products include in each category. And of course, no need for the main categories, just for subcategories.
Like this: Digital Camera COLOR=“Red”[/COLOR]
Thanks.
[quote name=‘michael’]Hi, all,
For emenu categories, how to display the number of total product quantity for each category behind the category name ? So, people will know how many products include in each category. And of course, no need for the main categories, just for subcategories.
Like this: Digital Camera COLOR=“Red”[/COLOR]
Thanks.[/QUOTE]
In this case try to replace the following part of code:
if ($simple == true) {
$select_fields = "$db_tables[categories].category_id, $db_tables[categories].parent_id, $db_tables[categories].id_path, $db_tables[category_descriptions].category, $db_tables[categories].position";
} else {
$select_fields = "$db_tables[categories].category_id, $db_tables[categories].parent_id, $db_tables[categories].id_path, $db_tables[category_descriptions].category, $db_tables[categories].position, $db_tables[categories].avail, $db_tables[categories].product_count";
}
with this one:
if ($simple == true) {
$select_fields = "$db_tables[categories].category_id, $db_tables[categories].parent_id, $db_tables[categories].id_path, $db_tables[category_descriptions].category, $db_tables[categories].position, $db_tables[categories].product_count";
} else {
$select_fields = "$db_tables[categories].category_id, $db_tables[categories].parent_id, $db_tables[categories].id_path, $db_tables[category_descriptions].category, $db_tables[categories].position, $db_tables[categories].avail, $db_tables[categories].product_count";
}
in the “/core/fn_catalog.php” file and replace the following part of code:
{foreach from=$ssubcateg item=category name="ssubcateg"}
{if $category.category_id}
{/foreach}
with this one:
{foreach from=$ssubcateg item=category name="ssubcateg"}
{if $category.category_id}
{/foreach}
in the “/skins/[CUSTOMER_ACTIVE_SKIN]/customer/categories_pages/categories.tpl” file.
Hello, thanks for your kindly support. But this only available for categories page, If I want to make it available for drop down menu, how can I do ? thanks.
I just figure it out by myself, in "skins/basic/customer/categories_pages/menu_items.tpl, add this CODE
``` behind{$category.category|escape:html}
But there is still got one thing I want to resolve, no counts for main categories, only available for subcategories. Any solution ?
Thanks for all !
I am on 1.3.4 sp3, but I have it working just fine.
I think what you are asking is this:
```php
[COLOR=“Red”]{if $category.product_count == “0”}[/COLOR]
{$category.category}
[COLOR=“Red”]{else}[/COLOR]
{$category.category}[COLOR="Red"] ({$category.product_count})[/COLOR]
[COLOR="Red"]{/if}[/COLOR]
```
This displays nothing if the product count is Zero.
See it in action on my site-
CLICK Playboy Back Issues.....The subcats 1960's....etc..have each year as a subcat, but the bottom 2 have products
[COLOR="Red"][B]NOTE: THIS IS for 1.3.4 sp3 code. Yours may differ.[/B][/COLOR]
Hi, Mike, in sp3, you can try this: {if $category.product_count == "0"}
{$category.category|escape:html}
{else}
{$category.category|escape:html}({$category.product_count})
{/if}
But I still want to disable this count for the main categories (the first level menus), do you know how to ?
Thanks !
it disables all category numbers in my main menu…maybe it depends on which template you insert it in
mine is in dtree-child
and it seems to do what you are asking
[quote name=‘michael’]Hi, Mike, in sp3, you can try this: {if $category.product_count == "0"}
But I still want to disable this count for the main categories (the first level menus), do you know how to ?
{$category.category|escape:html}
{else}
{$category.category|escape:html}({$category.product_count})
{/if}
Thanks ![/quote]
Mine version - works great - no product counts in main categories:
[COLOR=Green]{$category.category|escape:html}
{else}
{$category.category|escape:html}{if $category.product_count} ({$category.product_count}){/if}
{/if}[/COLOR]
Thanks, pianofo, I tried your code for menu_items.tpl, but there is still got product_count for main categories, I just need this for subcategories, could you please kindly help to check again ?
Thank you all !
[quote name=‘michael’]Thanks, pianofo, I tried your code for menu_items.tpl, but there is still got product_count for main categories, I just need this for subcategories, could you please kindly help to check again ?
Thank you all ![/QUOTE]
Oh, sorry! I forgot 1 line. Here is my whole menu_items.tpl
{* $Id: menu_items.tpl 3496 2007-07-30 10:40:45Z zeke $ *}
{strip}
{assign var=“foreach_name” value=“cats_$cid”}
{foreach from=$items item=“category” name=$foreach_name}
{if $category.subcategories}
{include file="categories_pages/menu_items.tpl" items=$category.subcategories separated=false submenu=true cid=$category.category_id}
{/if}
```php {if $category.level == "0"}
{$category.category|escape:html}
{else}
{$category.category|escape:html}{if $category.product_count} ({$category.product_count}){/if}
{/if} ```
{if $separated && (!$smarty.foreach.$foreach_name.last || !$submenu)}
{/if}
{/foreach}
{/strip}
hello, pianofo, thanks so much for your help, yes, the above code is correct. Very appreciate !
How can we do it in CS-Cart v3?
Thank you,
Does anyone have an idea?
Anyone figured this out yet?
Hi All,
Did you see this one: [url=“http://www.cscart-templates-addons.com/cs-cart-addons/cs-cart-3-addons/cs-cart-3-addon-mashmedia-number-of-products-in-category-menu-for-cs-cart-3.html”]http://www.cscart-templates-addons.com/cs-cart-addons/cs-cart-3-addons/cs-cart-3-addon-mashmedia-number-of-products-in-category-menu-for-cs-cart-3.html[/url]
Today we have released a CS-Cart 4 add-on that shows the number of products behind the category name.
https://www.cscartthemes.com/en/category-product-count/
The add-on removes the default subcategory overview and creates a new subcategory block with a product count behind the category name. For example:
- Books (39)
- Videogames (200)
- Music DVD (105)