Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Category Counts not Appearing


Gisele

Recommended Posts

Posted

I've taken over a web site for a customer who wants changes to his site.

they want the categories to show the product counts. I've told them it will slow down the load time, but it's not an issue.

I turned it on in the admin and the counts still won't show up.

I checked the database to make sure and it is set to true.

 

Here is the code in catalog/includes/boxes/categories.php

 

if (SHOW_COUNTS == 'true') {

$products_in_category = tep_count_products_in_category($counter);

if ($products_in_category > 0) {

$boxContent .= ' (' . $products_in_category . ')';

 

}

 

it doesn't quite look like what others have posted.

 

any ideas?

 

Thanks in advance.

 

Gisele

Posted

Not sure if it helps,

 

But you could try changing

 

$boxContent

 

to

 

$categories_string

 

You should also have the same variable about 3 lines down from that bit...

 

If it says $boxContent, then I can't help...

Posted

I found the original code thanks to your reply. Thanks so much.

 

 

The categories are like this:

 

category (400)

-sub category (100)

-sub category (200)

-sub category (100)

category (500)

-sub category (200)

-sub category (300)

 

etc. etc.

 

I'm trying to only show the counts for the sub-categories.

 

I tried hiding some of the code but it "hides" everything.

 

Would it be asking too much if I could pick your brain on this one :)

 

The code in categories.php is listed below.

 

Thanks again for your help!

 

Gisele

 

 

 

 

 

 

 

function tep_show_category($counter) {

global $foo, $categories_string, $id;

 

for ($a=0; $a<$foo[$counter]['level']; $a++) {

$categories_string .= "  ";

}

 

$categories_string .= '<a href="';

 

if ($foo[$counter]['parent'] == 0) {

$cPath_new = 'cPath=' . $counter;

} else {

$cPath_new = 'cPath=' . $foo[$counter]['path'];

}

 

$categories_string .= tep_href_link(FILENAME_DEFAULT, $cPath_new);

$categories_string .= '">';

 

if ( ($id) && (in_array($counter, $id)) ) {

$categories_string .= '<b>';

}

 

// display category name

$categories_string .= $foo[$counter]['name'];

 

if ( ($id) && (in_array($counter, $id)) ) {

$categories_string .= '</b>';

}

 

if (tep_has_category_subcategories($counter)) {

$categories_string .= '->';

}

 

//remove arrows next to categories

// if (tep_has_category_subcategories($counter)) {

// $categories_string .= '';

// }

 

 

$categories_string .= '</a>';

//hide category count

if (SHOW_COUNTS == 'true') {

$products_in_category = tep_count_products_in_category($counter);

if ($products_in_category > 0) {

$categories_string .= ' (' . $products_in_category . ')';

}

}

 

$categories_string .= '<br>';

 

if ($foo[$counter]['next_id']) {

tep_show_category($foo[$counter]['next_id']);

}

}

Posted

If I understand what you want...

 

ie.... If the Category has a Subcategory, then do NOT show counts.

 

If the Category does NOT have a subcategory, then DO show counts...

 

If so,

 

Change

if (SHOW_COUNTS == 'true') {

$products_in_category = tep_count_products_in_category($counter);

if ($products_in_category > 0) {

$categories_string .= ' (' . $products_in_category . ')';

}

}

 

near the end to

 

if (SHOW_COUNTS == 'true') {

$products_in_category = tep_count_products_in_category($counter);

if (($products_in_category > 0) && (tep_has_category_subcategories($counter) < 1)) {

$categories_string .= ' (' . $products_in_category . ')';

}

}

 

Try that.

Posted

you rock!!!!

thanks ever so much!!!

 

I've been away from OSC for quite a while and got this project thrown at me in a hurry.

 

Gisele

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...