Question

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.

Was it helpful?

Solution

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);
    }
    }
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange
scroll top