Back to Top

Calculate The Distance Between Two Zip codes

Updated 21 November 2016

In most of the online store websites are providing the feature to check the delivery to your zip code. You only have to enter your shipping zip code to check whether product can be delivered to your address or not. If you are a developer then I think some questions must arise in your mind that how this online store checks the delivery and calculates the cost of the shipping. Most of the shipping process calculates the shipping cost and delivery check by calculating the distance between the pick-up points to the shipping point with some other things like weights, size etc. So today we will learn to calculate the distance between the two zip codes in PHP. This is very simple to calculate the distance through google API.

Lets take an example

Pick-up point zip code – 201301

shipping zip code – 110044

you have to call an google API by passing this zip codes one by one then have to get the latitude and longitude of both the zip codes.

Start your headless eCommerce
now.
Find out More

here is the pick-up point zip code latitude and longitude

screenshot_2

screenshot_3

here is the shipping point zip code latitude and longitude

screenshot_4

screenshot_5

Then calculate the distance in km

screenshot_6

So the Distance is 9 km .

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


2 comments

  • naina Patel
    • Neelesh Singh (Moderator)
  • Back to Top

    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home