Wednesday 17 February 2016

How to get total items in cart in Magento

Here is a simple code to get the total products/items in cart in Magento. The below code is return only total products/items count,  did not return total quantity of different products/items. For example - ProductA has 5 quantity in cart and ProductB has 2 quantity in cart then below code return 2 counts because there are total 2 products/items added in cart.



<?php  

$_cartTotalItems = Mage::getSingleton('checkout/cart')->getItemsCount(); 


echo $_cartTotalItems;


?>


7 comments: