Opencart calculate shipping distance

UPDATE 30-09-2018

Some changes have been made by google, unfortunately I can’t support 200 stores to update the extension, so in order to keep using this extension you need to update to the latest version, or follow these steps to make it work again (this might be the quickest, also if you have a customized version):

Opencart 3.0 and up

step 1. open the file catalog\model\extension\shipping\zip_distance.php
step 2. find the getgoogleurl function, and replace it with:

The changes in this function are: replaced http url with https url, added api key to the query params

Save changes, and you are done!

 

Opencart 2.3.0.0, 2.3.0.1, 2.3.0.2:

step 1. open the file catalog\model\extension\shipping\zip_distance.php
step 2. find the getgoogleurl function, and replace it with:

The changes in this function are: replaced http url with https url, added api key to the query params

Save changes, and you are done!

Any Lower versions
The older versions don’t have the apikey yet in the backend, so you need to do it manually:

Find the getgoogleurl function and replace http with https and at the end of the query string add &key=YOURAPIKEY

I created an extension for opencart where you can calculate the distance based on the shippingaddress or the zipcode of the customer & your shop.

  • Choose max distance for this option to be available
  • Shows a google map with a store location marker and client location marker
  • Choose Metric or Imperial settings (km’s or miles).
  • Add a base shipping price
  • add a price per mile / kilometer
  • add a price per mile / kilometer for specifix shoppingcart weights
  • add exception zipcodes (zipcodes near who will only need to pay the base shipping price)
  • Minimum order amount for this extension to be available

 

You can find it here:

http://www.opencart.com/index.php?route=extension/extension/info&extension_id=8410

Changelog:

[b](January 10th 2017) New in 2.7[/b]
– Fixed an issue where for certain countries the ‘estimate shipping’ didn’t work in the cart
– Complete restyling of the admin interface, to make it more intuitive and usable 🙂

[b](Januray 8th 2017) New in 2.3[/b]
[b]Happy New Year![/b]
– Added the option to have free shipping for a certain range (for instance, free shipping for customers within 10km distance)
– Added an option to subtract the free shipping range from the total distance (for instance, free shipping within 10km’s customer with a distance of 21km’s will get charged for 11km extra distance..)

(March 19th 2016) New in 2.0.4
– Fixed a bug that didn’t pay attention to the zones calculation when entered.
– Updated the model to work with the 2.2.0 version of opencart.

(February 21st 2015) New in 2.0.3 & 1.6.2
Fixed Addresses with special characters (quotes amps etc.)

(December 26th 2014) New in 2.0.1:
Fixed exclude zipcodes, and some other fields that didnt work (thank nynex for the headsup :))

(November 16th 2014) New in 2.0:
This version is for the new opencart 2.0

(May 17th 2014) New in 1.6.0:
Added the ability to add a max distance for this option to become visible
Refactored the model into more maintanable functions

(April 11th 2014) Fixed in 1.5.6:
Fixed minimum order amount not working bug (Thanks for the headsup Lacocina)

(March 5th 2014) Fixed in 1.5.5:
Some problems with address not found in the google response. (Thanks for the tip Tom 🙂 )
This fix is probably worth uploading, the only file that changed is upload/catalog/model/shipping/zip_distance.php so replacing that would be enough (if you have the latest 1.5.4)

(November 6th 2013) Fixed in 1.5.4:
Some addresses weren’t found correctly if used address distance calculation.

(September 12th 2013) New in 1.5.2:
You can now set free shipping within a specific zone (e.g. distance 10 miles 0 shipping 10:0 all other will be calculated to the price per mile / km distance)

(August 24th 2013) New in 1.5.2:
Small bugfix if you are using address based shipping calculation the estimate shipping should work now too (thanks for noticing bobby 🙂 )

(August 18th 2013) New in 1.5:
You can add a rate per mile/km based on the total cart weight

(April 18th 2013) New in 1.4:
If the address isn’t found an error will be displayed on the map page.

(January 14th 2013) New in 1.3:
Supports calculation based on shop address and customer shipping address

(November 14th 2012) New in 1.2:
You can now add zones (say if you want people within a range of 5 km to pay €10,- and 5 – 10km €20,-) you can add them to the new zones textbox : 5:10,10:20