Get shopping cart items and quote totals in Magento

  • magento get current quote
  • magento get shopping cart total
  • magento getquote
  • magento get cart items
  • magento totals

This article will show you the best way to access Magento shopping cart data and get items information. This is useful when you need to display shopping cart in header or sidebar or in a custom page/module or when you need to get cart totals from a custom module.

– Get products id, name, price, quantity, etc. present in your cart.

– Get number of items in cart and total quantity in cart.

– Get base total price and grand total price of items in cart.

Looking for improvement for your  Magento Store?
Facebook Connector Extension
Product related article extension
Magento Offer popup on exit extension
Unlimited Slideshow Magento Extension
Light Checkout in One Step Magento Extension

Get all items information in cart

// $items = Mage::getModel('checkout/cart')->getQuote()->getAllItems();
$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems();

foreach($items as $item) {
	echo 'ID:  '.$item->getProductId().'<br />';
	echo 'Name: '.$item->getName().'<br />';
	echo 'Sku: '.$item->getSku().'<br />';
	echo 'Quantity: '.$item->getQty().'<br />';
	echo 'Price: '.$item->getPrice().'<br />';
	echo "<br />";
}

Get total items and total quantity in cart

$totalItems = Mage::getModel('checkout/cart')->getQuote()->getItemsCount();
$totalQuantity = Mage::getModel('checkout/cart')->getQuote()->getItemsQty();

Get subtotal and grand total price of cart

$subTotal = Mage::getModel('checkout/cart')->getQuote()->getSubtotal();
$grandTotal = Mage::getModel('checkout/cart')->getQuote()->getGrandTotal();

Hope this helps. Thanks.

Comments Closed