Magento Forum

What is the code to display number of items in cart and cart total $? 
 
EDS_Magento
Member
 
Total Posts:  35
Joined:  2009-09-25
 

I would like to display the total number of items in the user’s cart and the total dollar value of the items in their cart in the header of my site.  I have figured out where to edit in order to make these changes, but I’m having trouble figuring out exactly what the code snippet is that will display these values.

Any help would be appreciated.

 
Magento Community Magento Community
Magento Community
Magento Community
 
tzyganu
Mentor
 
Avatar
Total Posts:  2205
Joined:  2009-11-18
Bucharest, Romania
 

To display items in cart do this:

$this->helper('checkout/cart')->getSummaryCount();
or
Mage::helper('checkout/cart')->getSummaryCount();
And for the total:
Mage::getSingleton('checkout/session')->getQuote()->getSubtotal();
This will display only the total amount for the products.
If you want the grand total (including shipping & handling) do this:
Mage::getSingleton('checkout/session')->getQuote()->getGrandTotal();

For security reasons you can find a copy of this post here
http://marius-strajeru.blogspot.com/2010/01/how-to-display-number-of-items-in-cart.html

 
Magento Community Magento Community
Magento Community
Magento Community
 
davedavedave
Sr. Member
 
Avatar
Total Posts:  238
Joined:  2007-08-31
 

Thanks, this works.  What about outputting the number of items on your wishlist?

 
Magento Community Magento Community
Magento Community
Magento Community
 
davedavedave
Sr. Member
 
Avatar
Total Posts:  238
Joined:  2007-08-31
 
callmedpit - 23 August 2010 09:21 PM

Thanks, this works.  What about outputting the number of items on your wishlist?

Answer to this is:

$this->helper('wishlist')->getItemCount();
 
Magento Community Magento Community
Magento Community
Magento Community
 
ajay1357
Jr. Member
 
Total Posts:  3
Joined:  2011-08-28
 

Works perfectly for me as well with magento 5.1

beautykafe.com

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top