Magento – restrict user to place order if ZIP (PIN/Postcode) code is not from pre define ZIP (PIN/Postcode) code list

addressce-1.7.0.2checkoutordersshipping

One of our client's shipper allow shipping to only specific ZIP codes.
So we do have list of allowed ZIP codes.

We want to restrict user to place order on checkout page or cart page if shipping address ZIP code in not from allowed ZIP codes.

How we can do this?

is there any already existing solution for this?

Best Answer

The cleanest way to do this is to add extra validation functions in the Onepage Controller, the shipping and billing actions.

Take a look at this article by Inchoo on Magento validation. Also, if possible, add the validation to the javascript validation library so no form submit is required.

This custom validation function could test the user submitted zipcode against your list of allowed ones and return false if it doesn't match

Related Topic