how to get cart value in magento


<div class=”add-qoute-btn”>
<?php
echo  $this->helper(‘checkout/cart’)->getSummaryCount();
echo “<pre>”;
echo$test= Mage::getSingleton(‘core/session’)->getFormKey();
?>
<?php

// $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 />”;

}

?>

Total items added in cart

<?php

Mage::getModel(‘checkout/cart’)->getQuote()->getItemsCount();

Mage::getSingleton(‘checkout/session’)->getQuote()->getItemsCount();

?>

Total Quantity added in cart

<?php

Mage::getModel(‘checkout/cart’)->getQuote()->getItemsQty();

Mage::getSingleton(‘checkout/session’)->getQuote()->getItemsQty();

?>

Sub Total for item added in cart

<?php

Mage::getModel(‘checkout/cart’)->getQuote()->getSubtotal();

Mage::getSingleton(‘checkout/session’)->getQuote()->getSubtotal();

?>

Grand total for item added in cart

<?php

Mage::helper(‘checkout’)->formatPrice(Mage::getModel(‘checkout/cart’)->getQuote()->getGrandTotal());

Mage::helper(‘checkout’)->formatPrice(Mage::getSingleton(‘checkout/session’)->getQuote()->getGrandTotal());

?>

 

Get number of items in cart and total quantity in cart

<?php

$totalItems = Mage::getModel(‘checkout/cart’)->getQuote()->getItemsCount();

$totalQuantity = Mage::getModel(‘checkout/cart’)->getQuote()->getItemsQty();

?>

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s