Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

How to verify a Postal Code matches a State?


ArtcoInc

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.

TIA

Malcolm

Link to comment
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)

 

Link to comment
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.  

Link to comment
Share on other sites

  • 2 months later...

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 1.0.3.0

I'm currently working on 1.0.7.2 and hope to get it live before 1.0.8.0 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

Link to comment
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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...