wohi Posted November 3, 2010 Share Posted November 3, 2010 I want to display number of units sold on the product.tpl.Instead of showing number of Number of items in stock, I want to show how many have sold already.Any help would be great.Thank you Link to comment Share on other sites More sharing options...
shokinro Posted November 3, 2010 Share Posted November 3, 2010 Please check this thread, there is a solution there.http://www.prestashop.com/forums/viewthread/58309/ Link to comment Share on other sites More sharing options...
wohi Posted November 3, 2010 Author Share Posted November 3, 2010 Thank you for your reply but I need to show how many units of a particular product have sold.Not all the products in the catalog.Instead of 99 item items in stock, I need to show "99 Items have been sold so far"So I need a count of units sold for a particular product displayed.Thanks Link to comment Share on other sites More sharing options...
shokinro Posted November 4, 2010 Share Posted November 4, 2010 You can use following code at your php file of the page: $product_sold = Db::getInstance()->executeS('SELECT COUNT(*) as product_sold FROM `'._DB_PREFIX_.'order_detail` where product_id = ' . $product_id); $smarty->assign('product_sold', $product_sold); At your tpl file of your page product_sold: {$product_sold} Link to comment Share on other sites More sharing options...
wohi Posted November 4, 2010 Author Share Posted November 4, 2010 Thank you for your reply.Can you elaborate as to which files I should modify.Please also let me know the location to add the code on each file.Thank you once again Link to comment Share on other sites More sharing options...
shokinro Posted November 4, 2010 Share Posted November 4, 2010 It depends where you want this to show up. Here is the code for displaying sold count on product detail page.1. at product.php file, look for following line (on the top of the file) include_once(dirname(__FILE__).'/init.php'); add following code right AFTER above line $product_sold = Db::getInstance()->getRow('SELECT SUM(product_quantity) as total FROM `'._DB_PREFIX_.'order_detail` where product_id = ' . $_GET['id_product']); $smarty->assign('product_sold', $product_sold['total']); 2. At . /themes/yourthemes/product.tpl file, look for following line <p class="price"> add following line right AFTER above line {l s='Sold Count:'}{$product_sold} <br /><br /> And the result will look like attached(I have tested this code) Link to comment Share on other sites More sharing options...
wohi Posted November 5, 2010 Author Share Posted November 5, 2010 Thank you for the detailed instructions.2 issues:1st issue:I got the sold count working but it is not outputting the correct number of items sold.If I order only one then the sold count is increased by one.If I order quantity 10 of the same product then the sold count is still increased by one and NOT 102nd Issue:I want to put the Sold count in the short description box. Can you advise where to insert the code.Thank you for all your help Link to comment Share on other sites More sharing options...
shokinro Posted November 5, 2010 Share Posted November 5, 2010 For Issue 1, I have updated my code above step 1, please redo the changes of step 1, this should fixed the problem.For Issue 2, It is difficult to give instructions without seeing your source code of the page. I don't know what theme you are using. So it is better you figure it out by yourself. If you still have difficulty, I will take a look for you, please send me the information to access your source code by private message.Good Luck Link to comment Share on other sites More sharing options...
wohi Posted November 5, 2010 Author Share Posted November 5, 2010 Thank you for your post and yes it works now.issue 2. I am using default template for prestashop.Thank you once again Link to comment Share on other sites More sharing options...
shokinro Posted November 5, 2010 Share Posted November 5, 2010 Move the new code line in .tpl file to place right after following <div id="short_description_block"> If this solve your problem, please mark it as SOLVED by adding SOLVED to your original post of this thread. Link to comment Share on other sites More sharing options...
Recommended Posts