Jump to content

  • You cannot start a new topic
  • You cannot reply to this topic

How to display the product total number behind the category name ? Rate Topic   - - - - -

 
  • michael
  • Senior Member
  • Authorized Reseller
  • Join Date: 27-Oct 06
  • 200 posts

Posted 11 October 2008 - 06:49 AM #1

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 (567)
Thanks.
Do whatever you want to do....

 
  • forward
  • Developer
  • Authorized Reseller
  • Join Date: 23-Nov 06
  • 110 posts

Posted 13 October 2008 - 01:21 PM #2

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 (567)
Thanks.


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}<li><a href="{$index_script}?{$target_name}=categories&category_id={$category.category_id}" class="underlined-bold">{$category.category|escape:html}</a></li>{/if}
		{/foreach}

with this one:

{foreach from=$ssubcateg item=category name="ssubcateg"}
			{if $category.category_id}<li><a href="{$index_script}?{$target_name}=categories&category_id={$category.category_id}" class="underlined-bold">{$category.category|escape:html}({$category.product_count})</a></li>{/if}
		{/foreach}

in the "/skins/[CUSTOMER_ACTIVE_SKIN]/customer/categories_pages/categories.tpl" file.
Simtech Development | sales@simtechdev.com | www.simtechdev.com
CERTIFIED CS-CART PARTNER
LICENSES | DEVELOPMENT | ADD-ONS | DESIGNS | UPGRADES

 
  • michael
  • Senior Member
  • Authorized Reseller
  • Join Date: 27-Oct 06
  • 200 posts

Posted 13 October 2008 - 02:20 PM #3

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.
Do whatever you want to do....

 
  • michael
  • Senior Member
  • Authorized Reseller
  • Join Date: 27-Oct 06
  • 200 posts

Posted 13 October 2008 - 03:06 PM #4

I just figure it out by myself, in "skins/basic/customer/categories_pages/menu_items.tpl, add this
({$category.product_count})
behind
<a {if $category.subcategories}class="has-children"{/if} href="{$index_script}?{$target_name}

=categories&category_id={$category.category_id}">{$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 !
Do whatever you want to do....

 
  • MikeFold
  • Senior Member
  • Members
  • Join Date: 24-Nov 06
  • 1034 posts

Posted 13 October 2008 - 03:23 PM #5

I am on 1.3.4 sp3, but I have it working just fine.

I think what you are asking is this:

[COLOR="Red"]{if $category.product_count == "0"}[/COLOR]
	<td colspan="2" width="100%">
		<a href="{$index_script}?{$target_name}=categories&category_id={$category.category_id}" class="sidebox-subcategory">{$category.category}</a></td>
[COLOR="Red"]{else}[/COLOR]
<td colspan="2" width="100%">
		<a href="{$index_script}?{$target_name}=categories&category_id={$category.category_id}" class="sidebox-subcategory">{$category.category}[COLOR="Red"] ({$category.product_count})[/COLOR]</a></td>
[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

NOTE: THIS IS for 1.3.4 sp3 code. Yours may differ.
[SIZE="1"]Seamlessly Upgraded to 1.3.5sp4 from 1.3.4sp3
Live: Playboy Collectors Gallery
(Adult)[/SIZE]

[SIZE="2"]LOOKING FOR A FEW COPIES OF THE NEW LITHUANIA PLAYBOY ISSUES...AND COLOMBIA ISSUES.....
FEEL FREE TO Private Message Me....THANKS[/SIZE]


[SIZE="1"]Slightly Modded Default Red | Zardos Lightbox | Sitemap | Multicards Payment Mod |
Cart & Checkout Pages Modified |
[/SIZE]

 
  • michael
  • Senior Member
  • Authorized Reseller
  • Join Date: 27-Oct 06
  • 200 posts

Posted 13 October 2008 - 05:38 PM #6

Hi, Mike, in sp3, you can try this:
{if $category.product_count == "0"}
	<a {if $category.subcategories}class="has-children"{/if} href="{$index_script}?{$target_name}=categories&category_id={$category.category_id}">{$category.category|escape:html}</a>
{else}
        <a {if $category.subcategories}class="has-children"{/if} href="{$index_script}?{$target_name}=categories&category_id={$category.category_id}">{$category.category|escape:html}({$category.product_count})</a>
{/if}

But I still want to disable this count for the main categories (the first level menus), do you know how to ?

Thanks !
Do whatever you want to do....

 
  • MikeFold
  • Senior Member
  • Members
  • Join Date: 24-Nov 06
  • 1034 posts

Posted 13 October 2008 - 06:22 PM #7

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
[SIZE="1"]Seamlessly Upgraded to 1.3.5sp4 from 1.3.4sp3
Live: Playboy Collectors Gallery
(Adult)[/SIZE]

[SIZE="2"]LOOKING FOR A FEW COPIES OF THE NEW LITHUANIA PLAYBOY ISSUES...AND COLOMBIA ISSUES.....
FEEL FREE TO Private Message Me....THANKS[/SIZE]


[SIZE="1"]Slightly Modded Default Red | Zardos Lightbox | Sitemap | Multicards Payment Mod |
Cart & Checkout Pages Modified |
[/SIZE]

 
  • pianofo
  • Junior Member
  • Members
  • Join Date: 29-Nov 07
  • 17 posts

Posted 14 October 2008 - 08:22 AM #8

Hi, Mike, in sp3, you can try this:

{if $category.product_count == "0"}
    <a {if $category.subcategories}class="has-children"{/if} href="{$index_script}?{$target_name}=categories&category_id={$category.category_id}">{$category.category|escape:html}</a>
{else}
        <a {if $category.subcategories}class="has-children"{/if} href="{$index_script}?{$target_name}=categories&category_id={$category.category_id}">{$category.category|escape:html}({$category.product_count})</a>
{/if}
But I still want to disable this count for the main categories (the first level menus), do you know how to ?

Thanks !


Mine version - works great - no product counts in main categories:


<a {if $category.subcategories}class="has-children"{/if} href="{$index_script}?{$target_name}=categories&category_id={$category.category_id}">{$category.category|escape:html}</a>
{else}
<a {if $category.subcategories}class="has-children"{/if} href="{$index_script}?{$target_name}=categories&category_id={$category.category_id}">{$category.category|escape:html}{if $category.product_count} (<b>{$category.product_count}</b>){/if} </a>
{/if}


 
  • michael
  • Senior Member
  • Authorized Reseller
  • Join Date: 27-Oct 06
  • 200 posts

Posted 14 October 2008 - 12:58 PM #9

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 !
Do whatever you want to do....

 
  • pianofo
  • Junior Member
  • Members
  • Join Date: 29-Nov 07
  • 17 posts

Posted 15 October 2008 - 06:51 AM #10

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 !



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}
<li {if $category.subcategories}class="has-children"{/if}>
{if $category.subcategories}
<ul>
{include file="categories_pages/menu_items.tpl" items=$category.subcategories separated=false submenu=true cid=$category.category_id}
</ul>
{/if}
 {if $category.level == "0"}
<a {if $category.subcategories}class="has-children"{/if} href="{$index_script}?{$target_name}=categories&category_id={$category.category_id}">{$category.category|escape:html}</a>
{else}
<a {if $category.subcategories}class="has-children"{/if} href="{$index_script}?{$target_name}=categories&category_id={$category.category_id}">{$category.category|escape:html}{if $category.product_count} (<b>{$category.product_count}</b>){/if} </a>
{/if}


</li>
{if $separated && (!$smarty.foreach.$foreach_name.last || !$submenu)}
<li class="h-sep"> </li>
{/if}
{/foreach}
{/strip}

 
  • michael
  • Senior Member
  • Authorized Reseller
  • Join Date: 27-Oct 06
  • 200 posts

Posted 15 October 2008 - 01:10 PM #11

hello, pianofo, thanks so much for your help, yes, the above code is correct. Very appreciate !
Do whatever you want to do....

 
  • word2media
  • Junior Member
  • Members
  • Join Date: 13-Oct 10
  • 11 posts

Posted 10 October 2012 - 11:04 AM #12

How can we do it in CS-Cart v3?

Thank you,

 
  • word2media
  • Junior Member
  • Members
  • Join Date: 13-Oct 10
  • 11 posts

Posted 18 October 2012 - 01:42 PM #13

Does anyone have an idea?

 
  • jp1981
  • Member
  • Members
  • Join Date: 04-Oct 12
  • 23 posts

Posted 09 April 2013 - 08:30 PM #14

Anyone figured this out yet?

 
  • Mashmedia
  • Advanced Member
  • Authorized Reseller
  • Join Date: 02-Mar 12
  • 55 posts

Posted 13 August 2013 - 07:20 PM #15

Hi All,

Did you see this one: http://www.cscart-te...-cs-cart-3.html
Mashmedia - Your professional CS-Cart partner.
Check out our CS-Cart templates and add-ons.

 

Posted 05 February 2019 - 10:43 AM #16

Today we have released a CS-Cart 4 add-on that shows the number of products behind the category name.

https://www.cscartth...-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)