0

we are using "Cash On Delivery" Payment method in magento 1.9.0 version

we support cash on delivery to only some zip/pin codes locations.

means we will accept cash only from some zip codes [means locations].

under "checkout" in "shipping address", customer will type his/her "zip code" .

using that zip code we have to validation.

means if we deliver the product to that zip code, than "COD" payment method should visible under "payment method"

otherwise "COD" should not visible.

if someone is unclear with above question , please refer following link :

How to restrict default COD in magento to certain zip codes only?

this is the question.

can anyone explain in detail about above solution....

or

also here in following link :

restrict default Cash on delivery for some zip/pin codes in magento 1.9.0

there is an option to enter list of zip codes that are restricted. but we need a solution for list of zip codes that allowed.

Community
  • 1
  • 1

2 Answers2

2

All you need is to edit the file /app/code/core/Mage/Payment/Model/Method/Cashondelivery.php

here you will get an answer :

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);
}

restrict default Cash on delivery for some zip/pin codes in magento 1.9.0

Community
  • 1
  • 1
1

here is free extension for cashondelivery restrict based on zipcode

http://www.magentocommerce.com/magento-connect/cashondelivery-based-on-zipcode.html