Jump to content
Sign in to follow this  

How to verify a Postal Code matches a State?

Recommended Posts

Is there some way to verify that the Postal Code entered matches with the State entered?

I'm playing around with the 'Ship In Cart' add-on that allows customers to estimate their shipping costs before moving into the checkout process. The customer has to enter their country, state, and postal code. Shipping with the US Post Office, the postal code is used to calculate the shipping cost, and the state is only used to determine if sales tax is applied. It is possible for the customer to enter a state and postal code that to not match, and thus display an incorrect estimate.

I know that there is a Google Address Complete module available, but don't know if it would work in this application.

As an aside, when a customer enters their address, osC / Phoenix uses the default order sequence of: name - address - city - postal code - state - country. I have seen some sites will start with the country, then the postal code, and then auto-fill in the city and state based on the postal code.



Get the latest Responsive osCommerce CE (community edition) here .

Share this post

Link to post
Share on other sites

You can use the google API for it. ( there are if i am correct a limited lookup's of 2500 or 25.000 a month/year, not 100% sure)
The prob is, you first need to know their country, and that only can be be looked up by IP. ( if want it automatic ).
Once you now the country, the google API does the rest for you.

I used it on a multi-shop for ordering xxxx. ( very similar like takeaway system ).
Where shop/menu owners put a delivery range.
Unfortunately i have not yet found a real purpose for this system, but it is very exclusive!

I am looking for some high-rollers who want to invest and take a piece of the cake from takeaway and uber.
( as my system does both)


Edited by fridgebox

- ICECAT specialist.
(Icecat: open feed with product information, data-sheets for oscommerce.)
- CSV IMPORT specialist.
(manage your suppliers via supplier manager)
Contact me via PM.

Share this post

Link to post
Share on other sites

Assuming that ZIP code locations don't change much...and that new ones don't get added very often, you could set up a database table to allow you to insert zip codes into it.  Then you perform a quick and easy lookup at the appropriate time (create_account?  in admin after the order is placed?).

That sounds like a lot of work, but I am sure you know that the first 3 numbers in the zip correspond to States.   EG:  900 to 961 are all CA, 100 to 149 are NY, similar for the rest of the States.. 

A little bit of work on the part of the shopowner, but obviously then no ongoing cost.  

Help shape the future of Phoenix; join the Phoenix Club

Share this post

Link to post
Share on other sites

I used ANC_ukpostarea from the add ons and adapted to include  all european countries and their territories as well - it should be easy to adapt for what you want - Its a combination of a database table as Gary has pointed out above and a shipping rate table

My store is currently running Phoenix

I'm currently working on and hope to get it live before arrives (maybe 🙄 )

I used to have a list of add-ons here but I've found that with the ones that supporters of Phoenix get any other add-ons are not really neccessary

Share this post

Link to post
Share on other sites

Zip code first digits:  https://smartystreets.com/docs/zip-codes-101

Zip code ranges:  https://www.zipcodestogo.com/ZIP-Codes-by-State.htm

But be careful.  Some zip codes cross state lines (e.g. 42223 is in both Tennessee and Kentucky).  So you can't necessarily say that every zip code maps uniquely to a state. 

Always back up before making changes.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this