🎉 Celebrate with 10% OFF on All Products! Use Code: GFEX10 Or Buy Any 2+ Items for 30% OFF with Code: GFEX30!

Gravity Forms Distance & Location Pricing Add-on Setup Guide

Updated 8 min read Gravity Forms Payments & Pricing
On this page
  1. Step 1: Activate Your License
  2. Step 2: Connect Google Maps Platform
  3. Save and test your keys
  4. Suggestions, performance and customer messages
  5. Step 3: Add a Distance Field to Your Form
  6. Step 4: Set Your Prices and Service Area
  7. What your customers see
  8. Step 5: Use the Distance in Totals, Logic and Notifications
  9. Security, Privacy and Data Handling
  10. Developer Hooks
  11. Troubleshooting & FAQ
  12. Resource Hub

The Gravity Forms Distance & Location Pricing Premium Add-on turns any Gravity Form into an instant quote for businesses that travel to their customers: delivery, moving, cleaning, towing, mobile repair and more. A new Distance field measures the driving distance and travel time with Google Maps, converts it into a price using your base fee, distance tiers, per-mile or per-kilometer rate and ZIP/postcode surcharges, and adds that price to the order total. Prices are always recalculated on your server when the form is submitted, so they cannot be changed in the browser.

This guide walks you through activating the add-on, connecting Google Maps Platform, building a priced Distance field, limiting your service area and using the results in calculations, notifications and payment add-ons.

System Requirements & Prerequisites

  • WordPress: Version 6.5 or higher
  • PHP: Version 7.4 or higher
  • Gravity Forms: Version 2.9 or higher
  • Google Maps Platform: A Google Cloud project with the Routes API enabled (and, for address suggestions, the Maps JavaScript API and Places API (New)). Google bills the Routes API per request after its monthly free usage.
  • Add-on: Installed and activated with an active GravityExtra license key

Step 1: Activate Your License

Upload and activate the plugin, then go to Forms → Settings → Distance Pricing. Paste your GravityExtra license key into the Gravity Extra License panel and click Activate License. The Google Maps settings appear once the license is active.

Gravity Extra License panel on the Distance Pricing settings page
Activate your GravityExtra license under Forms → Settings → Distance Pricing.

Until a license is active, a Distance field shows a short notice instead of an address box, and submissions that include an address are blocked so that nobody is ever charged an incorrect price.

Step 2: Connect Google Maps Platform

The add-on uses two separate API keys. As the settings page explains, create both in the Google Cloud console under APIs & Services → Credentials.

Key Required APIs Recommended restriction Used for
Server key (required) Routes API Restrict to the Routes API and, if possible, to your server’s IP address Calculating driving distance and travel time on your server
Browser key (optional) Maps JavaScript API and Places API (New) Restrict to your website (HTTP referrers) Address suggestions while customers type

Save and test your keys

  1. Paste the browser key into Browser key and the server key into Server key, then click Save Settings.
  2. Click Test browser key. A green message confirms that address suggestions are available.
  3. Click Test server key. The add-on requests a sample route from Google and shows the result, for example “Server key works. Sample route: 2.0 mi.”
Google Maps Platform settings with browser key, masked server key and successful connection tests
Both connection tests passed. The saved server key is shown masked and is never printed back into the page.

Without a browser key, customers can still type their full address; they simply do not see suggestions. To change the server key later, type the new key and save. Leave the box blank to keep the saved key, or tick Remove the saved server key to delete it.

Suggestions, performance and customer messages

Setting Default What it does
Limit suggestions to countries Empty Optional. Up to 15 two-letter country codes, separated by commas (for example us, ca).
Remember distances for (hours) 24 Repeat lookups for the same pair of addresses are answered from your site instead of Google, which keeps your Google bill low.
Live estimates per visitor (every 10 minutes) 30 Protects your Google quota from abuse. Form submissions are always calculated.
Distance unavailable / Address not found / Outside service area Built-in text The messages customers see. Each Distance field can override the outside-area message.
Address Suggestions, Performance and Protection, and Customer Messages settings panels
Fine-tune suggestions, caching, rate limiting and the wording of customer messages.

The Usage This Month panel counts Google Routes requests, lookups answered from your cache and the percentage of requests saved. Check your Google Cloud billing page for exact charges.

Usage This Month panel showing Google Routes requests, cache answers and requests saved
Monthly usage summary: every cached answer is one Google request you do not pay for.

Step 3: Add a Distance Field to Your Form

Edit a form, open the Pricing Fields group and add a Distance field. Its General settings decide where the trip starts and ends and what customers see.

Distance field General settings in the Gravity Forms editor
General settings of a Distance field: starting point, destination, unit and display.
Setting Options
Starting point Business address (type your address once) or Address entered in another field, for example a pickup address on the same form.
Destination Address box in this field (with suggestions) or Address field on this form.
Unit Miles (mi) or Kilometers (km).
Show customers Distance and travel time, Distance only, Travel time only, Price only, or Nothing (calculate silently).
Round trip Doubles the distance and travel time before pricing.

Step 4: Set Your Prices and Service Area

Open the field’s Pricing & Area section and tick Charge for distance. The price is calculated as base fee + matching tier price + rate per unit beyond the included distance + zone surcharge. If the result is below the Minimum charge, the minimum is used.

Pricing and Area settings with base fee, distance tiers, rate, zone surcharges and service area
A delivery price list with three distance tiers, a per-mile rate beyond 10 miles, ZIP surcharges and a 50-mile service area.
Setting How it works
Line item name The name of the price on the order summary. Defaults to the field label.
Base fee / Minimum charge A fixed amount added to every quote, and the lowest price you will charge.
Distance tiers A flat price for the band the distance falls in. Leave “To” empty for the last band.
Price per mile / km and Charged beyond A per-unit rate for the distance above the included amount. Example from the editor: base fee 25, rate 2 beyond 10 → 15 mi costs 25 + 5 × 2 = 35.
Zone surcharges One rule per line in the format prefix|amount, such as 78664|5. The longest matching ZIP/postcode prefix applies.
Maximum one-way distance Blocks addresses that are further away. This limit always uses the one-way distance, even with round trip enabled.
Allowed ZIP / postcodes Only accept these codes. Use * for prefixes, for example 787*.
Message when outside the area Overrides the default outside-area message for this field.

What your customers see

As customers type, address suggestions appear (when a browser key is saved). After they pick an address, the live estimate shows the distance, travel time and price, and the Total field updates immediately.

Address suggestions shown below the Distance field while a customer types
Address suggestions powered by the Places API (New).
Front-end form with live distance, travel time and price estimate and the updated total
With the price list above, 19.0 mi to ZIP 78664 costs 25 + 10 (tier) + 18 (9 mi × 2) + 5 (zone) = $58.00.

Addresses outside your service area show your message and the form cannot be submitted:

Distance field showing the outside service area message
An address beyond the 50-mile limit is blocked with the field’s own message.

Step 5: Use the Distance in Totals, Logic and Notifications

The distance price is added to the order as its own product line, so the Total field, {pricing_fields} and payment add-ons such as Stripe and PayPal charge the correct amount. Each entry shows the distance, travel time, price and both addresses.

Entry detail showing distance, travel time, price, origin and destination plus the order line item
The entry stores the server-calculated distance and adds the “Delivery fee” line to the order.
Merge tag Returns
{distance:ID} Formatted distance, for example 19.0 mi
{distance_duration:ID} Travel time, for example 25 mins
{distance_price:ID} Distance price in the form currency
{distance_origin:ID} / {distance_destination:ID} Starting and destination address
Field merge tag with :value The plain number, for use in calculation formulas

The Distance field can also drive conditional logic with the operators *is*, *is not*, *greater than* and *less than*, and it can be used in calculation formulas. In the example form, a “Gate or building access code” field appears only when the distance is greater than 15. Conditional logic is re-checked on the server against the recalculated distance.

Security, Privacy and Data Handling

  • Server-side pricing: the browser only sends addresses. Unit, round trip, business address and prices are read from the saved field, and every Distance field is recalculated on submission. A changed distance or Total in the browser is replaced or rejected.
  • Encrypted server key: the Routes API key is stored encrypted with a key derived from your WordPress salts, shown masked, and never sent to visitors. If your salts change, the settings page asks you to enter the key again.
  • Restricted keys: restrict the server key to the Routes API (and your server IP) and the browser key to your website’s HTTP referrers, as recommended on the settings page.
  • Abuse protection: live estimates are rate-limited per visitor and protected by a security token.
  • Customer data: the origin and destination addresses are stored with the entry and sent to Google to calculate the route, and to the Places API for suggestions when a browser key is used. Mention this in your privacy policy.

Developer Hooks

Filter Arguments Purpose
gf_distprice_routes_request_body $body, $origin, $destination Modify the Routes API request, for example to add route modifiers.
gf_distprice_result $result, $field, $form Adjust the evaluated result, including price.
gf_distprice_cache_ttl $seconds Change how long routes are cached.
gf_distprice_rate_limit $limit Live estimates per visitor every 10 minutes (0 disables the limit).
gf_distprice_server_key $key Supply the server key from a constant or secrets manager.
gf_distprice_test_origin / gf_distprice_test_destination $address Sample route used by the Test server key button.
functions.php
PHP
// Avoid toll roads when calculating driving routes.
add_filter( 'gf_distprice_routes_request_body', function( $body ) {
    $body[ 'routeModifiers' ] = array( 'avoidTolls' => true );
    return $body;
} );

// Add a $15 after-hours fee to every distance price.
add_filter( 'gf_distprice_result', function( $result, $field, $form ) {
    if ( 'ok' === $result[ 'status' ] ) {
        $result[ 'price' ] += 15;
    }
    return $result;
}, 10, 3 );

// Load the server key from wp-config.php instead of the database.
add_filter( 'gf_distprice_server_key', function() {
    return defined( 'MY_ROUTES_KEY' ) ? MY_ROUTES_KEY : '';
} );

Troubleshooting & FAQ

Customers see “We couldn’t calculate the distance right now.”

Google returned an error or no server key is saved. Click Test server key on the settings page; the message shows Google’s reason (for example an API that is not enabled or a key restriction). Errors are never cached, so the next attempt asks Google again.

ZIP surcharges or allowed postcodes do not apply.

Postcodes are read reliably from the ZIP input of a Gravity Forms Address field. When customers type into the Distance field’s own address box, the postcode is detected from the address text on a best-effort basis. Use an Address field as the destination when ZIP rules matter.

Does round trip change the price and the service area?

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

My site uses page caching. Will estimates still work?

Yes. If the security token on a cached page has expired, the form fetches a fresh one and retries once automatically.

The settings page says the saved key can no longer be read.

Your WordPress salts have changed, so the encrypted key cannot be decrypted. Enter the server key again and save.

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.

Resource Hub

Still need help?

Our support team answers tickets every day, usually within a few hours.

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