0

I've made my admin configuration for cash on delivery payment as applicable only to specific country i.e, USA

Below my cases in checkout page,

Billing Country => USA, Shipping Country => USA | COD Available
Billing Country => USA, Shipping Country => OTHER | COD Available
Billing Country => OTHER, Shipping Country => USA | COD Not Available
Billing Country => OTHER, Shipping Country => OTHER | COD Not Available

So this clearly shows that COD configuration of applicable country is pointing only to billing address.

Any way to make this condition to check shipping country instead of billing country ?

0

You would have to make a extension that observes payment_method_is_active event and decide if your method is active or not

  • I did it and it worked partially. Anyhow thanks for the hint. – Vinoth Feb 9 '16 at 16:11
0

I've figured it out,

Event in config.xml,

            <payment_method_is_active>
                <observers>
                    <disable_cod_non_indian_shipping>
                        <class>Caritor_Mobileapp_Model_Observer</class>
                        <method>disableCOD</method>
                    </disable_cod_non_indian_shipping>
                </observers>
            </payment_method_is_active>

My Observer.php

public function disableCOD($observer){
        $result=$observer->getEvent()->getResult();
        $MethodInstance=$observer->getEvent()->getMethodInstance();
        $quote=$observer->getEvent()->getQuote();
        if($quote && $quote->getId()):
            $ShippingAddress=$quote->getShippingAddress();
            $country_id = $ShippingAddress->getCountryId();
            if($MethodInstance->getCode()=='cashondelivery'){
                if($country_id == 'US'){                
                    $result->isAvailable = true;
                } else {
                    $result->isAvailable = false;
                }
            }
        endif;
    }

Above code makes cashondelivery payment visible only if shipping country is set to United States.

Note: This maked cash on delivery payment available even it's disabled from magento admin.

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.