I am displaying the total items present in the cart at header. I am able to display the count of items.

But I am bit confused between two methods of cart

1. Mage::helper('checkout/cart')->getItemsCount()
2. Mage::helper('checkout/cart')->getSummaryCount();

For me 1st one returns 1 item in cart and 2nd one returns 6 items in cart, Which is correct one and what is the difference these two functions..


2 Answers 2

Mage::helper('checkout/cart')->getItemsCount() -- return shopping cart items count means how many sku add to shopping cart.
Mage::helper('checkout/cart')->getSummaryCount() -- return shopping cart items summary (suppose you add sku1 6 qty and sku2 3 qty = total 9 qty return)
  • Note: it's getItemCount() not getItemsCount() on CE 1.9.2 for Mage_Checkout_Block_Cart_Sidebar. getItemsCount() will fail silently (returning empty string) and can cause bugs due to this behaviour. Commented Aug 9, 2015 at 19:59

This way getItemsCount will work:


If not then try adding this above the getItemsCount line:

Mage::getSingleton('core/session', array('name'=>'frontend'));

And For Summary Count:

$count = $this->helper('checkout/cart')->getSummaryCount();  //get total
  • I'm pretty sure the reason you were downvoted is that the OP was asking what the difference between the two is, not the syntax for using them.
    – joeybab3
    Commented Aug 30, 2019 at 20:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.