문제

How can we round up or down grand totals when payment method is cash on delivery on checkout page. ex. If total is 50.60 then if customer selected cash on delivery payment method then grand total should be 51.00.

How can we do that please help it will be very useful.

도움이 되었습니까?

해결책

Try use event observer.

config.xml

<events>
    <payment_method_is_active>
        <observers>
            <namespace_module>
                <type>singleton</type>
                <class>NamaSpace_Module_Model_Observer</class>
                <method>paymentmethod</method>
            </namespace_module>
        </observers>
    </payment_method_is_active>
</events>

observer.php

<?php 
class NamaSpace_Module_Model_Observer{
    public function paymentmethod(Varien_Event_Observer $observer) 
    {
        $method = $observer->getEvent()->getMethodInstance();
        $quote = $observer->getEvent()->getQuote();
        if($method->getCode()=='COD')
        {
            //get grand total and modified it.
        }

    } 
}

다른 팁

Use the PHP function round() to round off the price.

Example is below:

echo round(3.5); output: 4
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 magento.stackexchange
scroll top