$items = Mage::getSingleton('checkout/session')->getQuote()->getAllItems(); foreach($items as $item) { echo 'Product ID: '.$item->getProductId(); echo 'Product Name: '.$item->getName(); echo 'Product Sku: '.$item->getSku(); echo 'Product Quantity: '.$item->getQty(); echo 'Product Price: '.$item->getPrice(); if ($this->helper('tax')->displayCartPriceInclTax() || $this->helper('tax')->displayCartBothPrices()): $_incl = $this->helper('checkout')->getPriceInclTax($item); echo 'Product Price: '. $this->helper('checkout')->formatPrice($_incl- $item->getWeeeTaxDisposition()); else: echo 'Product Price: '. $final_price= Mage::helper('core')->currency($item->getPrice()); endif; } // Total items added in cart $totalItems = Mage::getModel('checkout/cart')->getQuote()->getItemsCount(); // Total Quantity added in cart $totalQuantity = Mage::getModel('checkout/cart')->getQuote()->getItemsQty(); // Sub Total for item added in cart $subTotal = Mage::getModel('checkout/cart')->getQuote()->getSubtotal(); //grand total for for item added in cart $grandTotal = Mage::getModel('checkout/cart')->getQuote()->getGrandTotal();
Get All Items & Totals In Magento Shopping Cart
6 comments:
-
This Code is Very Nice But I need Mage::getSingleton('checkout/session')->getQuote()->setStoreId()->getAllItems(); So, Possible...?
-
In my below code return only returns 'qty' of each products and if do echo then it prints all things but in end it prints null aslo. Do you have any idea how can print all details in json file for rest calls.
Mage::app()->setCurrentStore(4);
$cart = Mage::getModel('sales/quote')->loadByCustomer($this->getApiUser()->getUserId());
$items = array();
foreach ($cart->getAllVisibleItems() as $key => $item) {
$items[] = array(
'name' => $item->getName(),
'entity_id' => $item->getProductId(),
'description' => $item->getDescription(),
'final_price_with_tax' => $item->getBasePriceInclTax(),
'qty' => $item->getQty()
);
}
return $items;
Blog Archive
Popular Posts
-
You can select,insert,update and delete data in the Magento wby using their models concept. For example,a table named ‘testdata‘ with the fo...
-
This article will explain how to create an extension to send all the emails through gmail or other servers.I have created an module to set u...
-
This is an article to show you ,how you can set MySql Master-slave replication in magento for scalability ,handle failover and performance. ...
-
Breadcrumb is necessary for making website pages user navigation friendly. It can be printed out in any of the php or phtml pages by below c...
-
This blog will show you how to get all items in a shopping cart and totals in a magento store : $items = Mage::getSingleton('checkout/...
very good article.well done