Question

I am using event observer on checkout page for modifying grandTotal on checkout page config.xml

<?xml version="1.0"?>
<config>
<modules>
    <Ranosys_SpecialPrice>
        <version>0.1.3</version>
    </Ranosys_SpecialPrice>
</modules>

<global>
    <events>
        <payment_method_is_active>
            <observers>
                <observer>
                    <type>singleton</type>
                    <class>Ranosys_SpecialPrice_Model_Observer</class>
                    <method>paymentmethod</method>
                </observer>
            </observers>
        </payment_method_is_active>
    </events>   
</global>

Observer.php

<?php

class Ranosys_SpecialPrice_Model_Observer {

public function paymentmethod(Varien_Event_Observer $observer) 
{
    $method = $observer->getEvent()->getMethodInstance();
    $quote = $observer->getEvent()->getQuote();
    if($method->getCode()=='cashondelivery')
    {
        $quote->setGrandTotal(round($quote->getGrandTotal()));
        $quote->save();
        Mage::log(var_export($quote->debug(), TRUE), null, 'order.log');
    }
    return $this;
} 
}

When I check order.log it is showing round of value of grand total but it is not showing on checkout page. How can I show changed grand total on checkout page.

Was it helpful?

Solution

You can do it by using a collector after the

Mage_Sales_Model_Quote_Address_Total_Grand

and set the grandTotal using setGrandTotal.

Check this link for reference you can just use the collector for updating only grand total. Reference

Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top