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.

0

1 Answer 1

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);
    }
    }
11
  • It didn't worked Apr 17, 2016 at 4:29
  • @vithalreddy for both checkout page & view page, it did't worlked ? Apr 17, 2016 at 5:15
  • It worked in view page but not in checkout page Apr 17, 2016 at 5:35
  • strange, it worked for me. Apr 17, 2016 at 5:56
  • did you added zip codes in the above code i posted ? Apr 17, 2016 at 5:57

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.