Oliver Evans
Oliver Evans

Reputation: 989

Display cart Grand Total instead of Sub Total

On my magento theme I have a cart total in the header. At the moment it displays the sub total, I was just wondering how I could change this value to display the grand total instead.

This is the code in the template already

<?php echo Mage::helper('checkout')->formatPrice($this->getSubtotal()) ?>

I have tried changing getSubtotal() to getGrandtotal() but it just returns 0.

Anyone got any ideas? Thank you

Upvotes: 1

Views: 7572

Answers (2)

Hiboomedia
Hiboomedia

Reputation: 283

Not enough Reputation to Comment so I'm writing this here.

liyakat's answer worked for me on community 1.7 but I don't understand why he wants to round up the numbers.

I wanted to display the exact total (€21.50 not rounded up to €22.00) so I removed "round(" and the last ")" which gives me:

        <?php 
         $totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
         $grandtotal = $totals["grand_total"]->getValue(); //Grandtotal value 
         echo $formattedPrice = Mage::helper('core')->currency($grandtotal , true, false);
        ?>

Which works PERFECT!

Thanks a lot, I gave it +1

Upvotes: 1

liyakat
liyakat

Reputation: 11853

you can get with total object

used my working code to get grand total any where in magento

<?php 
 $totals = Mage::getSingleton('checkout/session')->getQuote()->getTotals(); //Total object
 $grandtotal = round($totals["grand_total"]->getValue()); //Grandtotal value 
 echo $formattedPrice = Mage::helper('core')->currency($grandtotal , true, false);
?>

hope this will sure help you.

Upvotes: 9

Related Questions