2

I am using the one-page checkout module. I want to change the grand total when user/customer selects the payment method. If customer/user selects the online payment option then grand total should change.

app/code/local/Bliss/Onlinepayment/etc/config.xml

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

app/code/local/Bliss/Onlinepayment/Model/Observer.php

<?php

class Bliss_Onlinepayment_Model_Observer {

public function paymentmethod(Varien_Event_Observer $observer) 
    {
        //$method = $observer->getEvent()->getMethodInstance();
        $quote = $observer->getEvent()->getQuote();
        if($quote->getCode()=='checkmo')
        {

   $quote->setGrandTotal(1);
   $quote->setBaseGrandTotal(1);
   $quote->save();

        }


    } 
}
  • I would definitely go for a custom Total Model – adjco Feb 8 '18 at 5:39
  • @adjco can you please send me any extension link or module? when i exit the code in the observer and print the grand total then it is shows me updated grand total but i don't know when i remove the exit from the observer code then after some other events may be applied so the grand total set again default. – Sunny Rahevar Feb 8 '18 at 7:10
  • Why though? How come you have to update the grand total without a - for the frontend user - visible reason? Are you trying to set up some sort of discount for certain payment methods (or fees on other payment methods in reverse)? I'd strongly recommend you to go for a shopping cart price rules in that case... – Christoph Farnleitner Feb 13 '18 at 2:57

Your Answer

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

Browse other questions tagged or ask your own question.