we restricted only some zip codes for default COD payment method by adding below code in cashondelivery.php
:
app/code/local/Mage/Payment/Model/Method/Cashondelivery.php
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);
}
Now we are using custom COD & we are using following code :
public function isAvailable($quote = null)
{
if($quote && $quote->getBaseGrandTotal()<Mage::getStoreConfig('payment/mpcashondelivery/max_order_total') && $quote->getBaseGrandTotal()>Mage::getStoreConfig('payment/mpcashondelivery/max_order_total')) {
return false;
}
$specificcountry = explode(",",Mage::getStoreConfig('payment/mpcashondelivery/specificcountry'));
if(Mage::getStoreConfig('payment/mpcashondelivery/allowspecific')!=0 ){
if(!in_array($quote->getBillingAddress()->getCountry(),$specificcountry)){
return false;
}
}
$cod_charges = Mage::getModel('mpcashondelivery/pricerules')->getAppliedPriceRules();
if($cod_charges['error']){
return false;
}
return parent::isAvailable($quote);
}
How to restrict only some zip codes for this custom COD ?