0

How to make magento module for Cash on delivery payment method should visible only for some zip codes/pin codes and it can be check in product page also.

0

add observer and doing code in

config.xml file like bwlok

<events>
            <payment_method_is_active>
                <observers>
                    <codcheck_payment_is_actve>
                        <type>singleton</type>
                        <class>codcheck/observer</class>
                        <method>paymentMethodIsActive</method>
                    </codcheck_payment_is_actve>
                </observers>
            </payment_method_is_active>
        </events>

and right require code in observer file

0

I have add this code here app/code/community/MSP/CashOnDelivery/Model/Cashondelivery.php in my costume COD and it works fine.

 public function isAvailable($quote = null)
   {
    if ($quote) {
        // Here is the list of restricted Zip Codes
        $restrictedZips = array('201301',
                                '201303',
                                '203207',
                                '203155',
                                '201308',
                                '203202',
                                '203207',
                                '203203');

        $address = $quote->isVirtual() ? $quote->getBillingAddress() : $quote->getShippingAddress();
        $customerZip = $address->getPostcode();

        if (!in_array($customerZip, $restrictedZips)) {
            return false;
        }
    }

return parent::isAvailable($quote);
} 

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.