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);
}
PS: 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.
首先,您将在数据库中创建一个邮政编码表,并在产品页面上创建一个简单的输入字段,然后为此创建一个验证,然后创建一个AJAX函数来检查邮政编码COD是否可用。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.