On your WordPress dashboard, choose Plugins – Add new.

Search for “WebData Distance Based Fee for WooCommerce” and click “Install now” and after that “Activate”.

Google Distance Matrix API key

In order to use the plugin, you need to have a Google Account and you need to generate Google Distance Matrix API key. You also need to have following APIs enabled:

  • Distance Matrix API
  • Places API for Web
  • Google Maps Geocoding API

Instructions how to enable APIs can be found here:

Instructions to get the API key can be found here:

Above, view on the API key generation page.

Please note, you also need to have billing enabled in order to use the Google Matrix API. To enable billing, please visit here:

Once you have generated your API key, go to the plugin settings: “Settings – Distance based fee settings” and paste your API key to the “Google API key” field and save settings. After this configure rest of the settings as you wish.


Choose “Settings – Distance based fee settings” on your WordPress Dashboard to open the plugin settings page.

On the main settings page, you need to enter the Google Matrix API key. After that you can set fee name, divider, price, units and shipping methods which your distance based fee is used for.


Fee can also be manipulated by dbf_calculated_fee filter hook, which takes 4 parameters: $calculatedFee, $kiloMeters, $divider and $price.

The hook function would look something like this:

function my_dbf_calculated_fee_callback( $calculatedFee, $kiloMeters, $divider, $price ) {
if($kiloMeters < 10) {
// Do something
} else {
// Do something else

return $calculatedFee;
add_filter( ‘dbf_calculated_fee’, ‘my_dbf_calculated_fee_callback’, 10, 4 );

You can also manipulate the starting address, e.g. in case you want the distance to be calculated on different starting points. Hooks are: dbf_origin_city_filter, dbf_origin_zip_filter and dbf_origin_address_filter.

The hook function would look something like this:

function my_dbf_calculated_fee_callback( $originAddress ) {

$originAddress = ”1234 Fake Street;

return $originAddress;
add_filter( ‘dbf_origin_address_filter’, ‘my_dbf_calculated_fee_callback’, 10, 1 );


Free support is available at:


See FAQ section here:

webdata_logoSend a message!




  • Home
  • Hire
  • Support
  • Docs
  • Contact