Mitech Preloader
Magento

shipping restriction based on Postal/Zip code in magento

postal

Check whether the shipment is available on your location depends on Postal/Zip code.

Here we will be discuss on product’s shipment is available on your location or not.

You have to follow this steps given below.

Step 1 : Open your app\code\core\Mage\Customer\Model\customer.php from your magento directory.

Go to the public function validate() and add following code given below.

[php]

$postCode = Mage::app()->getRequest()->getPost();

if(!$this->validatePincode($postCode[‘billing’][‘postcode’])){
$errors[] = Mage::helper(‘customer’)->__(‘Service is not available on this Postal/Zip code.’);
}

[/php]

Just Below of the public function validate() function you have to add another function to check the Postal/Zip code.

[php]

public function validatePincode($code){

$pins = array(12345,67891,23456);
if(in_array($code, $pins)){
return true;
}
return false;
}

[/php]

In this function we have put the static Postal/Zip code to check but You can make it dynamic from database.

I Hope it will be helpful!

blank