3

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();

        }


    } 
}
4
  • I would definitely go for a custom Total Model
    – adjco
    Commented Feb 8, 2018 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. Commented Feb 8, 2018 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... Commented Feb 13, 2018 at 2:57
  • Hey dude did you get the solution?
    – SA Soibal
    Commented Jul 12, 2020 at 12:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.