Sultan Posted June 9, 2010 Share Posted June 9, 2010 Hi,Is there a way to show the total number of Orders placed & the total number of items (not products) sold in the FO?I need this...Thanks in advance for any tips or helps. Link to comment Share on other sites More sharing options...
Sultan Posted June 12, 2010 Author Share Posted June 12, 2010 Hi,Any Help Please?? Link to comment Share on other sites More sharing options...
rocky Posted June 12, 2010 Share Posted June 12, 2010 You'll need to add code like this to header.php or footer.php, depending on where you want the information displayed, before the $smarty->display: $totalOrders = Db::getInstance()->executeS('SELECT COUNT(*) as total_orders FROM `'._DB_PREFIX_.'orders`'); $totalOrderProducts = Db::getInstance()->executeS('SELECT COUNT(*) as total_order_products FROM `'._DB_PREFIX_.'order_detail`'); $smarty->assign(array('totalOrders' => $totalOrders[0]['total_orders'], 'totalOrderProducts' => $totalOrderProducts[0]['total_order_products'])); Then you can use the following in header.tpl or footer.tpl: Number of orders: {$totalOrders} Number of order products: {$totalOrderProducts} Link to comment Share on other sites More sharing options...
Sultan Posted June 14, 2010 Author Share Posted June 14, 2010 Thank you rocky sooo much,I did that as described; However, I didn't get any number on the header!What could be going wrong?thanks Link to comment Share on other sites More sharing options...
rocky Posted June 14, 2010 Share Posted June 14, 2010 I made a couple of mistakes. I've updated my code above. Please try it again. Link to comment Share on other sites More sharing options...
Sultan Posted June 15, 2010 Author Share Posted June 15, 2010 Solved :-)THAAAAAAANKS a lot rocky,I appreciate your time and efforts... Thanks again & always... Link to comment Share on other sites More sharing options...
Sultan Posted June 20, 2010 Author Share Posted June 20, 2010 Tip:if you need to show the exact number of how much items sold you need to use this code in header.php or footer.php $totalOrders = Db::getInstance()->executeS('SELECT COUNT(*) as total_orders FROM `'._DB_PREFIX_.'orders`'); $totalOrderProducts = Db::getInstance()->executeS('SELECT SUM(product_quantity) as total_order_products FROM `'._DB_PREFIX_.'order_detail`'); $smarty->assign(array('totalOrders' => $totalOrders[0]['total_orders'], 'totalOrderProducts' => $totalOrderProducts[0]['total_order_products'])); the difference here between $totalOrderProducts = Db::getInstance()->executeS('SELECT COUNT(*) as total_order_products FROM `'._DB_PREFIX_.'order_detail`'); and $totalOrderProducts = Db::getInstance()->executeS('SELECT SUM(product_quantity) as total_order_products FROM `'._DB_PREFIX_.'order_detail`'); is that the first line of code showing how many records in the table ._DB_PREFIX_.'order_detail by using SELECT COUNT(*). where the second code calculate the total number of quantities sold by using SELECT SUM(product_quantity).HTHs someone.Again, thanks for rocky for his help... without his help I couldn't get that done. Link to comment Share on other sites More sharing options...
yesiam Posted July 9, 2011 Share Posted July 9, 2011 Hello, I find very interesting subject, and I wonder if I can help with any questions I have about the code provided, I could show the total number of orders "but only for the current month" and I can solve it, thank you very much for your help, greetings.For example:Number of orders: {$totalOrders} for the current month ?Edit: The code displays the total of orders placed, but also includes canceled orders, how can you do to show only orders validated ?One idea:That with the sentence they between fodder that could be solved, but not like making it without I have to introduce the dates manually, want that become automatic for the present monthBETWEEN value1 AND value2Sorry for my bad english ! Link to comment Share on other sites More sharing options...
yesiam Posted July 10, 2011 Share Posted July 10, 2011 My Solution: $totalOrders = Db::getInstance()->executeS('SELECT COUNT(*) as total_orders FROM `'._DB_PREFIX_.'orders` WHERE MONTH(`date_add`) = MONTH(NOW()) AND YEAR(`date_add`) = YEAR(NOW())'); $totalOrderProducts = Db::getInstance()->executeS('SELECT COUNT(*) as total_order_products FROM `'._DB_PREFIX_.'order_detail` WHERE MONTH(`date_add`) = MONTH(NOW()) AND YEAR(`date_add`) = YEAR(NOW())'); $smarty->assign(array('totalOrders' => $totalOrders[0]['total_orders'], 'totalOrderProducts' => $totalOrderProducts[0]['total_order_products'])); Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now