Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Simple product count display


Digibooks

Recommended Posts

Posted

Hi

 

I am still pretty new to OSC and slowly fumbling my way around to change it to fit with my site. One thing I am looking to do is to have a total count of the number of products available on through the site. I have worked out out to use PHP to count the products in the database but I'm not really sure where it would go within the OSC files.

 

I'd be grateful if someone could advise me on how to go about this?

 

Thanks

Alan

 

(Currently running version 2.3.3.4)

Posted

ADD to /includes/functions/general.php

 

 function tep_count_products() {
   $products_query = tep_db_query("select count(*) as total from " . TABLE_PRODUCTS . " WHERE products_status = '1'");
   $products = tep_db_fetch_array($products_query);

   return $products['total'];
 }

 

ADD, includes/languages/english.php

 

define('NUMBER_PRODUCTS', 'Currently we have %s products for sale');

 

Anywhere you like in the shop, use:

 

tep_count_products()

 

EG, in the footer:

 

 

<div class="grid_24 footer">
 <p align="center"><?php echo FOOTER_TEXT_BODY; ?></p>
 <p align="center"><?php echo sprintf(NUMBER_PRODUCTS, tep_count_products()); ?></p>
</div>

 

If you just want the number of products and nothing else, forget the text stuff. In ths case use:

 

<div class="grid_24 footer">
 <p align="center"><?php echo FOOTER_TEXT_BODY; ?></p>
 <p align="center"><?php echo tep_count_products(); ?></p>
</div>

Archived

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

×
×
  • Create New...