we are using Cash On Delivery Payment method in magento 1.9.0
we need this payment option only for certain zip codes/pin codes.
here someone got solution :
How to restrict default COD in magento to certain zip codes only?
i really can't able to implement that solution with some ideas.
can anyone explain me step by step in detail about that solution.
All you need is to edit the file /app/code/core/Mage/Payment/Model/Method/Cashondelivery.php
Open it and add the code below to the very end of the class (just before the last “}” in the file):
public function isAvailable($quote = null)
{
if ($quote) {
// Here is the list of restricted Zip Codes
$restrictedZips = array(
'85001',
'87965'
);
$address = $quote->isVirtual() ? $quote->getBillingAddress() : $quote->getShippingAddress();
$customerZip = $address->getPostcode();
if (in_array($customerZip, $restrictedZips)) {
return false;
}
}
return parent::isAvailable($quote);
}
P.S.: Note, that with this solution you will need to enter zip-codes right in the code. If you would like to avoid this, and get the ability to enter zip ranges via the admin's panel, contact us for more detail.