Skip to content

Instantly share code, notes, and snippets.

@Dan0sz
Created October 21, 2018 13:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Dan0sz/065ee983db0b090ba3fbf728a1cd8e43 to your computer and use it in GitHub Desktop.
Save Dan0sz/065ee983db0b090ba3fbf728a1cd8e43 to your computer and use it in GitHub Desktop.
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