Magento 1 - Get Cart Quantity Within A Session

Posted on June 24, 2011 | Magento 1

function getCartQuantity () {
      $cart = Mage::getModel('checkout/cart')->getQuote()->getData();
      if (isset($cart['items_qty']))
         return (int)$cart['items_qty'];
      else
          return 0;
  }
  echo getCartQuantity ().' Item(s)';