Digibooks Posted November 4, 2013 Posted November 4, 2013 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)
burt Posted November 4, 2013 Posted November 4, 2013 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>
Digibooks Posted November 4, 2013 Author Posted November 4, 2013 Thank you so much. I will give this a try tonight!
Digibooks Posted November 5, 2013 Author Posted November 5, 2013 Thank you again - this works an absolute treat - and I have managed to get it running nicely in header.php
Recommended Posts
Archived
This topic is now archived and is closed to further replies.