Getting the grand total from Magento shopping cart
Getting the grand total, the final checkout price after all discounts and taxes are applied.
[code language=”php”]
$quote = Mage::getModel(‘checkout/session’)->getQuote();
$quoteData= $quote->getData();
$grandTotal=$quoteData[‘grand_total’];
[/code]
Caculating the grand total without the promotion rules.
[code language=”php”]
$quote = Mage::getModel(‘checkout/session’)->getQuote();
$grandTotal = 0;
foreach ($quote->getAllItems() as $item) {
$grandTotal += $item->getPriceInclTax()*$item->getQty();
}
[/code]
This code will show all available shopping cart related values.
[code language=”php”]
$quote = Mage::getModel(‘checkout/session’)->getQuote();
print_r($quote->getData());
[/code]
Note: Shipping cost are not included in the above grand totals.
Questions
What is ‘checkout/session’?
‘checkout/session’ tells the function Mage::getModel where to look for the Model class. In this case, checkout is the module name, session is the model class name. Mage::getModel('checkout/session')
will return the instance of the class Mage_Checkout_Model_Session, which resides in app/code/core/Mage/Checkout/Model/Session.php
Search within Codexpedia

Search the entire web
