🎉 Celebrate with 10% OFF on All Products! Use Code: GFEX10 Or Buy Any 2+ Items for 30% OFF with Code: GFEX30!
Guides & Tutorials October 10, 2026

Gravity Forms Distance Calculation: Charge by Mileage for Delivery & Service Calls

GravityExtra
Gravity Forms Distance Calculation: Charge by Mileage for Delivery & Service Calls

If your business drives to its customers, every quote starts with the same question: how far is it? Florists, caterers, movers, cleaners, mobile mechanics, towing companies and pet groomers all lose money on flat travel fees. Short trips get overcharged and walk away, long trips get undercharged and eat your margin, and every manual lookup in Google Maps slows down your reply.

Gravity Forms is excellent at pricing products and running calculations, but it does not know how far a customer lives from you. This guide shows how to add a real Gravity Forms distance calculation to your quote or order form, turn the driving distance into a price automatically, and stop accepting jobs outside your service area.

What a flat travel fee really costs you
1. Underpriced long trips: a 35-mile job pays the same travel fee as a 3-mile job, so the furthest customers are your least profitable.
2. Overpriced short trips: nearby customers see a padded fee and book a competitor who looks cheaper.
3. Slow replies: someone on your team has to look up the route, do the math and email a price, often hours after the lead came in.
4. Out-of-area leads: you still receive (and sometimes accept) requests from addresses you cannot serve profitably.

Can Gravity Forms calculate distance on its own?

Not out of the box. A Gravity Forms Number field with calculation enabled can multiply, add and round, but it needs a distance value to work with. That value has to come from a mapping service such as the Google Maps Platform. In practice you have three options:

  • Custom code: a developer calls the Google Routes API from your site, stores the result and feeds it into a calculation. Flexible, but you own the maintenance, the API key security and the edge cases.
  • A distance field plus your own formulas: some add-ons return the distance and travel time so you can build the pricing yourself with calculation formulas and conditional logic. For example, some address autocomplete add-ons offer a travel estimate field that calculates distance and travel time with Google’s Routes API for use in calculations, conditional logic and merge tags.
  • A distance field with pricing built in: the distance, the price list and the service area live in one field, and the result is added to the order total for you. That is what the GravityExtra Distance & Location Pricing Add-on does.

What the Distance & Location Pricing add-on does

The add-on adds a new Distance field to the Pricing Fields group in the form editor. When a customer enters an address, the field measures the driving distance and travel time with Google Maps and converts it into a price using your own rules:

  • Start from your business address or from another address on the form, such as a pickup address.
  • Miles or kilometers, one-way or round trip (round trip doubles the distance and travel time before pricing).
  • Base fee, distance tiers, a per-mile or per-km rate beyond an included distance, a minimum charge and ZIP/postcode surcharges.
  • Service area limits by maximum one-way distance or by a list of allowed ZIP/postcodes. Addresses outside the area cannot be submitted.
  • A live estimate on the form, with optional Google address suggestions while the customer types.
  • The price is added to the order as its own product line, so the Total field and payment add-ons such as Stripe and PayPal charge the right amount.
  • Server-side recalculation: every Distance field is recalculated on your server when the form is submitted, so a price changed in the browser is replaced or rejected.

How to set up distance pricing in Gravity Forms

You need WordPress 6.5+, Gravity Forms 2.9+ and a Google Cloud project with billing enabled. The full walkthrough is in the Distance & Location Pricing setup guide; here is the short version.

Step 1: Connect Google Maps Platform

Install and activate the add-on, activate your GravityExtra license under Forms → Settings → Distance Pricing, then paste two keys from the Google Cloud console:

  • A server key with the Routes API enabled. It calculates distances on your server, is stored encrypted and is never sent to visitors.
  • An optional browser key with the Maps JavaScript API and Places API (New) enabled, restricted to your website. It powers address suggestions.

Click Test browser key and Test server key to confirm both work before you build the form.

Google Maps Platform settings with browser key, masked server key and successful connection tests
Both connection tests passed. The saved server key is only ever shown masked.

Step 2: Add a Distance field to your form

Open your quote or order form, add a Distance field from Pricing Fields and choose the starting point (your business address or an address field on the form), the destination, the unit and what customers see: distance and travel time, distance only, travel time only, price only, or nothing at all if you prefer to calculate silently.

Step 3: Enter your price list and service area

Under Pricing & Area, tick Charge for distance. The price is calculated as base fee + matching tier price + rate per mile/km beyond the included distance + ZIP surcharge. If the result is below your minimum charge, the minimum is used. Zone surcharges use one rule per line (for example 78664|5), and the longest matching ZIP prefix wins.

Pricing and Area settings with base fee, distance tiers, rate, zone surcharges and service area
A delivery price list: three distance tiers, $2 per mile beyond 10 miles, ZIP surcharges and a 50-mile service area.

Step 4: Check what your customers see

Preview the form and enter an address. The live estimate shows the distance, travel time and price, and the Total field updates immediately. With the price list above, a 19-mile trip to ZIP 78664 costs $25 base + $10 tier + $18 (9 miles × $2) + $5 zone surcharge = $58.00.

Front-end form with live distance, travel time and price estimate and the updated total
The customer sees the distance, travel time and delivery fee before submitting.

Addresses beyond your maximum distance, or outside your allowed ZIP codes, show your own message and the form cannot be submitted:

Distance field showing the outside service area message
Out-of-area addresses are stopped before they reach your inbox.

Step 5: Use the distance in totals, logic and notifications

Each entry stores the server-calculated distance, travel time, price and both addresses, and the order summary shows the distance price as its own line. Merge tags such as {distance:ID}, {distance_duration:ID} and {distance_price:ID} put the numbers into notifications and confirmations. The Distance field also works in conditional logic (greater than, less than, is, is not) and in calculation formulas.

Entry detail showing distance, travel time, price, origin and destination plus the order line item
The entry keeps the calculated distance and adds the delivery fee to the order.

Real-world examples

Local delivery: florists, caterers, bakeries and furniture stores

Start from your shop address, add two or three distance tiers (for example 0–5 miles, 5–10 miles, 10+ miles) and set a maximum delivery distance. If certain neighborhoods need an extra fee, add ZIP surcharges instead of building separate forms. Because the fee is a product line, it flows straight into Stripe or PayPal at checkout.

Moving companies: pickup to drop-off

Set the starting point to the pickup address field and the destination to the drop-off address, so the price reflects the actual move rather than the distance from your yard. Show the distance and travel time on the form, and use conditional logic to reveal extra questions for long-distance moves. If you run your sales pipeline in SmartMoving, the SmartMoving add-on can send the same quote request straight in as a lead.

Mobile services: cleaning, detailing, mobile repair, towing and grooming

Turn on round trip so the price covers the drive back, set a minimum charge so very short trips still pay for the call-out, and limit the service area to the distance your crew can reach in a working day. Use {distance_duration:ID} in the team notification so dispatchers can see the travel time at a glance. Home-service teams on Workiz can pass the request to their schedule with the Workiz add-on.

Multi-location businesses

When each branch has its own bank account, pair distance pricing with the Multi-Account Payment Router so payments for each location go to that location’s Stripe or PayPal account.

Comparison: ways to charge by distance

What you need Distance & Location Pricing Distance field + own formulas Manual quotes
Driving distance on the form Yes, live estimate Yes No, looked up later
Base fee, tiers, per-mile rate, minimum Built-in settings Build your own formulas Spreadsheet or memory
ZIP / postcode surcharges Built-in Extra fields and logic Manual
Block addresses outside your area Max distance or ZIP list Set up yourself After the lead arrives
Fee added to Stripe / PayPal total Automatic product line Via a calculated product Separate invoice
Price recalculated on your server Yes, on every submission Check the add-on’s docs Not applicable
Which option fits?

If you only need to display a distance or build an unusual formula, a distance-only field works. If you want customers to see a final travel price, pay it online and stay inside your service area without writing formulas, the Distance & Location Pricing Add-on keeps everything in one field.

Frequently asked questions

How does Gravity Forms calculate the distance between two addresses?

With the add-on installed, the Distance field sends the starting and destination addresses from your server to the Google Routes API and receives the driving distance and travel time. The result is used for the price, the service-area check, conditional logic and merge tags.

How much does Google charge for distance lookups?

Google bills the Routes API per request after its monthly free usage; check your Google Cloud billing page for exact charges. To keep the bill low, the add-on remembers results for the same pair of addresses (24 hours by default), rate-limits live estimates per visitor and shows a monthly usage summary with the number of requests saved by the cache.

Can I charge per mile and per kilometer?

Yes. Each Distance field uses miles or kilometers, and the per-unit rate, tiers and maximum distance follow that unit.

Does round trip change the service area?

No. Round trip doubles the distance and travel time before pricing, but the maximum-distance check always uses the one-way distance.

Does it work with Stripe and PayPal?

Yes. The distance price is added as a product line item, so the order total sent to payment add-ons includes it.

What happens if Google is unavailable?

The customer sees a friendly message and the form cannot be submitted, so nobody is charged a wrong price.

Quote every trip at the right price

Add live distance pricing, service-area limits and Stripe/PayPal-ready totals to Gravity Forms. Plans start at $39 per year for one site ($69 for 5 sites, $149 for 10 sites).

Get Distance Pricing →

Want to see every setting first? Read the setup guide

0
0
Your Cart
Your cart is emptyReturn to Shop
🔥 FREQUENTLY BOUGHT TOGETHER
Complete Combo & Save 40%!
ITEM IN YOUR CART
Gravity Forms Klaviyo Add-on
$39.00/yr
+
🎁 RECOMMENDED ADD-ON SAVE 40% OFF
Original Price: $39.00/yr
Bundle Special Price: $23.40/yr