2

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.

  • Try to use this event "controller_action_predispatch_checkout_onepage_savePayment" – Asheem Patro Jan 16 '17 at 6:37
  • Check this link also stackoverflow.com/questions/4363876/… – Asheem Patro Jan 16 '17 at 6:40
  • Do I just need to change event name or something else @AsheemPatro – Ramkishan Suthar Jan 16 '17 at 6:41
  • After using this event it is not moving from payment information tab in checkout page – Ramkishan Suthar Jan 16 '17 at 6:43
  • Check my answer and use a parent::collect(); then only you will be able to edit the grand total. – Asheem Patro Jan 16 '17 at 6:47
4

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

  • in this case grand total will modify in every case plz see my code I need to change granttotal when payment method is cash on delivery. – Ramkishan Suthar Jan 16 '17 at 6:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.