Magento Forum

   
How to get shopping cart grand total, subtotal, discount in Magento? 
 
jayanta1988
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2012-09-19
 

Hi freinds, I’m trying to do this with this code:

$quote Mage::getSingleton('checkout/cart')->getQuote();

$grandTotal $quote->getGrandTotal();

$subTotal =  $quote->getSubtotal();

    OR

$totals =  $quote->getTotals();

$subtotal $totals["subtotal"]->getValue();

$Discount $totals["discount"]->getValue();
=======================================

Do you have another one??

 
Magento Community Magento Community
Magento Community
Magento Community
 
ec0mmerce
Sr. Member
 
Avatar
Total Posts:  197
Joined:  2013-01-17
 

Hello

If you want to get shopping cart totals details you can use this code:

$totalItemsInCart Mage::helper(‘checkout/cart’)->getItemsCount(); //total items in cart
$totals Mage::getSingleton(‘checkout/session’)->getQuote()->getTotals(); //Total object
$subtotal round($totals["subtotal"]->getValue()); //Subtotal value
$grandtotal round($totals["grand_total"]->getValue()); //Grandtotal value
>if(isset($totals['discount']) && $totals['discount']->getValue()) {
$discount 
round($totals['discount']->getValue()); //Discount value if applied
else {
$discount 
;
}

if(isset($totals['tax']) && $totals['tax']->getValue()) {
$tax 
round($totals['tax']->getValue()); //Tax value if present
else {
$tax 
;
}

 
Magento Community Magento Community
Magento Community
Magento Community
 
jayanta1988
Jr. Member
 
Avatar
Total Posts:  16
Joined:  2012-09-19
 

Thanks for your reply..  smirk

 
Magento Community Magento Community
Magento Community
Magento Community
 
Jongosi
Jr. Member
 
Total Posts:  15
Joined:  2012-11-18
 

Just a hint guys, be very careful using

Mage::getModel('checkout/cart')->...
This can cause a 500 error (memory leak) in Magento CE 1.3 - 1.7 when chagning currency. See the full post here: http://www.magentocommerce.com/boards/viewthread/275096/#t405490

 
Magento Community Magento Community
Magento Community
Magento Community
 
vasuscoin
Member
 
Avatar
Total Posts:  34
Joined:  2011-11-20
India
 

Thank you so much!!!

I got help through this code!!!

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top