Installation

On your WordPress dashboard, choose Plugins – Add new.

Search for “WebData Custom Shipping Methods for WooCommerce” and click “Install now” and after that “Activate”.

Enabling shipping method(s)

Choose WooCommerce – Settings – Shipping – One of the shipping zones you wish to use – And add “WooCommerce Custom shipping method” to the zone.

Unit based shipping

Select “WooCommerce Custom shipping method” by clicking the shipping method’s name to see the plugin settings page.

Unit based shipping allows you to set the pricing based on the cart weight, width, length or height. Pricing is set by using price thresholds.

Below is an example of the settings used for the unit based shipping, which has been setup by using height, weight and width values:

For this example, WooCommerce has been setup to use kilograms for weight units, centimeters for the measurements and euros for pricing. However, you can use what ever units you like to use. This plugin will work with any given units.

Now, if the  cart weight would be less than 1 kg, the plugin would add fee of 5 euros to the total sum. If the total weight exceeds 1 kg but is less than 3 kg, the fee would be 10 euros instead.

Same thing would happen with height. If the cart total height would be 3 centimeters for example, the plugin would add a fee of 15 euros to the total sum.

All these fees would be then calculated together for the total sum. For example if we had a product which height was 3 centimeters and weight 2 kilograms and width of 4 centimeters, the total sum for the unit based fee would be: 15 + 5 + 20 = 40 euros.

Please note!

If the cart total dimensions exceeds the given dimensions in the unit based shipping settings, no fee will be added to the total sum! If you want to hide shipping method if any of the given values exceeds, remember to set the limit to the “Limit settings”, or use fixed price instead.

Coupons

Coupons can be used for free shipping. You can specify which coupon codes are available for the shipping method, or you can use any of the coupon codes that has been set to use “free shipping”.

Area based fees

Area based fees will be set for the given cities. You can add either a single city or multiple cities, separated by comma.

Distance based shipping

In order to use the distance based shipping, you need to have a Google Account and you need to generate Google 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:
https://support.google.com/googleapi/answer/6158841?hl=en

Instructions to get the API key can be found here: https://developers.google.com/maps/documentation/distance-matrix/get-api-key

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: https://console.cloud.google.com/project/_/billing/enable

Once you have generated your API key paste your API key to the “Google API key” field,  configure rest of the settings as you wish and save settings.

Shipping class based fees

You can add a fee based on the shipping class and you can choose the calculation method.

Availability

Availability settings allows you to choose which countries your shipping method is available.

Developers

Distance based fee can be manipulated by woo_custom_shipping_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( ‘woo_custom_shipping_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: woo_custom_shipping_dbf_origin_city_filter, woo_custom_shipping_dbf_origin_zip_filter and woo_custom_shipping_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( ‘woo_custom_shipping_dbf_origin_address_filter‘, ‘my_dbf_calculated_fee_callback’, 10, 1 );

Also wb_woocommerce_custom_rate_filter is available, which allows you to customize the whole calculation logic.