Base fee combined with price per kilometer or mile
Written by Jelizaveta
Updated over a week ago

This article will explain a more complicated rates setup, when you would like to combine base fee with price per kilometer or mile.

 Rate name Base fee Delivery price per km Delivery radius Delivery up to 5 km £10 0 5 km Local Delivery £5 £1 From 5 to 30 km

Like in the example table above, let's add a fixed price of £10 for the first 5 km, and then charge £1 per km after 5 km.

# Requirements

• The Carrier Service API is required when using Zapiet - Rates by Distance, in order to show the rates in the checkout. You can learn more in our Shopify Carrier API guide.

• You need to create a delivery location before adding the rates.

• All physical products need to be marked as This product requires shipping in Shopify.

2. Add a Rate name and the Rate description if needed.

3. Set the Maximum distance to 5 km.

4. Set the Base delivery price to £10.

5. Click Create rate.

6. Your Delivery up to 5 km rate is now set up. Click Add price-based rate to add the second rate.

7. Add a Rate name and the Rate description if needed.

8. Set the Minimum distance to 5.01 km, and the Maximum distance to 30 km.

The minimum distance for rate 2 and maximum distance for rate 1 should not be the same. In this example, the maximum order distance for Delivery up to 5 km is 5 km, but the minimum order distance for Local delivery is 5.01 km.

9. Set the Base delivery price to £5, and the Delivery price per kilometer to £1.

10. Click Create rate.

You should now have two delivery rates added to your store's location. One will ensure that orders within 5 km radius will get £10 flat fee, while orders over 5 km radius will be charged £1 per kilometer + £5 base fee.

# Explanation

Delivery cost per kilometer disregards the minimum distance. In other words, regardless of what minimum distance you include, the delivery cost per km will always begin from 0km. This means you may have to do some simple calculations to get the base delivery fee for second rate set up correctly.

You can use this formula to help you calculate that base delivery fee:

`Base Fee from Rate 1 - (Minimum Distance * Price per Distance) = Base fee for Rate 2`

## Example 1

For the first example, let’s use the numbers we used at the beginning of this article.

• Base fee (for Rate 1) is \$10 for the first 5 km

• \$1 per km (Price per distance) after 5 km (Minimum distance)

`10 - (5 * 1) = 5`

## Example 2

For this example, let’s use something straightforward.

• Base fee (for Rate 1) is \$5 for the first 5 km

• \$1 per km (Price per distance) after 5 km (Minimum distance)

`5 - (5 * 1) = 0`

## Example 3

Let’s use bigger numbers this time.

• Base fee (for Rate 1) is \$30 for the first 15km

• Price per km is \$5 (Price per distance) after 15km (Minimum distance)

`30 - (15 * 5) = -45`

As you can see here, base delivery fee can go into negatives.

# Test the rates

2. Enter an email, delivery address and a valid zip code. Click Continue to delivery methods.

3. Zapiet - Rates by Distance will find a delivery radius that includes the address you're testing with, and use its rate settings to show you a rate.

Earlier in this article, we've set up a £10 Delivery up to 5 km fee for 5 km delivery radius.

4. We've set up a Local Delivery fee for 5 to 30 km delivery radius.

We've tested with the address located within 11.41km from the store, therefore this rate received £16 delivery rate: £5 base fee + £1 per km * 11.

Repeat testing for all price ranges/distances that you've added to Zapiet - Rates by Distance.

# Limitations

• Zapiet - Rates by Distance calculates the delivery rate based on the order total before any discounts have been applied.

• This is because the post-discount cart total is not available via the Shopify Carrier Service API—it is a Shopify limitation. We recommend adjusting your rates accordingly.

If you would like to see this implemented in the future, you can contact Shopify support in order to report this as a feature request.

• Zapiet - Rates by Distance rounds up distances. If you have a £1/km fee, then delivery 2.49 km away would be £2, but delivery 2.51 km away would be £3.

• Zapiet - Rates by Distance is not compatible with Shopify Local Delivery.

• If you have rates with identical names added to both Zapiet - Rates by Distance and Shopify Shipping profile, only one rates will show.

• If you have Local Delivery rate added to Zapiet - Rates by Distance, and Local Delivery rate added to Shopify Shipping profile, only one of those rates will show at the checkout.

# Troubleshooting

If you didn't get the rate you were expecting, please double-check your rate settings first.

1. Make sure you have the Shopify Carrier API enabled on your store.

2. Make sure that Zapiet - Rates by Distance is added as a carrier in Shopify Shipping and delivery settings.

3. Check if Zapiet - Rates by Distance is enabled in Zapiet - Rates by Distance > Settings.

4. All non-digital products need to be marked as a physical product in Shopify.

5. Please ensure that you are testing with a valid address that is included in the area set for delivery by the Zapiet - Rates by Distance.

6. Please ensure that there are no weight or price gaps between the delivery rates.

7. If you're testing weight-based rates, make sure you added weight to your products in Shopify.

8. If you've set both price-based and weight-based rates, both rates will appear at the checkout.

9. If you're using Google Maps as a route provider, make sure that your Google Maps API is valid, and your billing is enabled.

10. If the distances calculated are not accurate, we recommend trying a different route provider. Also, if your store is not located within Europe, you may find Google Maps to be more accurate.

11. Check if you can see a rate being generated in Zapiet - Rates by Distance > Logs.

If you're still not seeing the correct rate after checking your settings, let us know the details at support@zapiet.com and we’ll be happy to help!