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.


2 Answers 2


add observer and doing code in

config.xml file like bwlok


and right require code in observer file


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',

        $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 and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.