Magento – Magento 1.9 – How to get grand total in Mage_Payment_Block_Info

grand-totalmagento-1.9

I'm looking for how to get grand total in Mage_Payment_Block_Info.phtml.
I know grandtotal comes from $quote so i was trying to bring this data to Mage_Payment_Block_Info.php. But I can't find answer!

app/design/frontend/rwd/default/template/payment/info/default.phtml

#1 . 
<?php echo number_format(Mage::helper('checkout')->getQuote()->getGrandTotal(), 2) ?>
#2 . 
<?php echo number_format(Mage::getModel('checkout/session')->getQuote()->getGrandTotal(),2) ?> 
#3 . 
<?php echo number_format(Mage::getSingleton('checkout/session')->getQuote()->getGrandTotal(), 2) ?>


#4 . 
<?php print_r(Mage::helper('checkout')->getQuote()->getData('grand_total')) ?>
<?php $grandTotal = Mage::getModel('checkout/session')->getQuote()->getGrandTotal();
echo $grandTotal?>

I tested above them but they don't work. Do i have to declare that i use checkout model in Mage_Payment_Block_Info.phtml. If it is, how can i do that?

Best Answer

Write a function at Mage_Payment_Block_Info at

pulbic function getGrantTotalAmount(){

    if ($this instanceof Mage_Sales_Model_Order_Payment) {
         $grand_total = $this->getOrder()->getGrandTotal();
     } else {
         $grand_total = $this->getQuote()->getGrandTotal();
     }
    return $grand_total ;
   }  

Then at your phtml file call this function

Related Topic