Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Return total number of items in Cart in Magento 1
<?php
$_cartQty = $this->helper('checkout/cart')->getItemsCount(); // Shows the different kind of items in cart (NOT TOTAL!)
$_cartQty = $this->helper('checkout/cart')->getSummaryCount(); // Shows the total amount of items in cart
$_cartQty = Mage::getModel('checkout/cart')->getQuote()->getItemsQty(); // Alternative method
$_cartQty = round(Mage::getModel('checkout/cart')->getQuote()->getItemsQty(), 0); // You can strip the decimals (everything after the dot) by wrapping it in a round-function
// To increase readability you could also do the following:
$_cartQty = Mage::getModel('checkout/cart')->getQuote()->getItemsQty();
$_cartQty = round($_cartQty, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.