![](/img/trans.png)
[英]Cash on delivery payment method should visible only for some zip codes/pin codes in magento
[英]restrict default Cash on delivery for some zip/pin codes in magento 1.9.0
我们在magento 1.9.0中使用货到付款付款方式
我们仅对某些邮政编码/ PIN码需要此付款方式。
这里有人解决方案:
我真的无法用一些想法来实现该解决方案。
谁能详细解释该解决方案。
您只需要编辑文件/app/code/core/Mage/Payment/Model/Method/Cashondelivery.php
打开它,并将下面的代码添加到类的最后(恰好在文件中的最后一个“}”之前):
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:请注意,使用此解决方案时,您将需要在代码中直接输入邮政编码。 如果您想避免这种情况,并能够通过管理员面板输入邮政编码范围,请与我们联系以获取更多详细信息。
首先,您将在数据库中创建一个邮政编码表,并在产品页面上创建一个简单的输入字段,然后为此创建一个验证,然后创建一个AJAX函数来检查邮政编码COD是否可用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.