Store Search by Zip Code

1

I'm developing a website with PHP and MySQL where I register several stores, and each store serves a region of the city.

What would be the best strategy to adopt in this case, where I have CEP of the customer and want to check which is the nearest store in the city that can serve the customer?

I thought about saving% - Lat and Long from the store, and defining a region that it serves with Google Maps, but how can I check after CEP is within that area?

    
asked by anonymous 05.10.2015 / 04:42

1 answer

1

What is the granularity of your stores? City? Neighborhood? Block? Because the zip code is a structured code, you can try to search for successively larger parts of the zip code. For example, if the customer's ZIP code is 89213-123, you could search for 8, 89, 892, 8921 ... the first search could find a store in Curitiba (88xxx-xxx), the second will already isolate the North Coast of SC, the third isolates Joinville, and so on.

A sophistication of this search can be the search for proximity of the non-co-existent digit, for example a store in the ZIP code 8922x-xxx probably caters better to a customer 8923x-xxx than a shop 8927x-xxx, because as far as I understand the Post office Geographically close zip codes with 'near' numbers as well.

Certainly the Mail can sell you a database with the GPS coordinates of the zip codes, but this is charged and you have to pay for the updates.

    
05.10.2015 / 04:58