1

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.

1

for view page : http://www.nextbits.eu/check-delivery-availability-magento-extension.html

for checkout page , All you need is to edit the file /app/code/local/Mage/Payment/Model/Method/Cashondelivery.php

public function getInstructions()
        {
            return trim($this->getConfigData('instructions'));
        }

        public function isAvailable($quote = null)
    {
        if ($quote) {

            // Here is the list of restricted Zip Codes
            $restrictedZips = array(
    '641004'
    ,'641006'


    );

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

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

        return parent::isAvailable($quote);
    }
    }
  • It didn't worked – Vithal Reddy Apr 17 '16 at 4:29
  • @vithalreddy for both checkout page & view page, it did't worlked ? – Baby in Magento Apr 17 '16 at 5:15
  • It worked in view page but not in checkout page – Vithal Reddy Apr 17 '16 at 5:35
  • strange, it worked for me. – Baby in Magento Apr 17 '16 at 5:56
  • did you added zip codes in the above code i posted ? – Baby in Magento Apr 17 '16 at 5:57

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.