Setting Up Distance Calculations
To utilize distance calculations in your forms, input a valid “Google Maps browser key” first. Obtain a JavaScript API key for Google Maps here: Get Google Maps API Key.
Activate these services in the Google API Console:
- Distance Matrix API
- Maps JavaScript API
- Places API
- Geocoding API
Within the “Price & quantity” tab of your desired item, enable “Price calculation” or “Quantity calculation.” Then, hit the “Add a distance” to access the distance calculation panel:
Select the appropriate form fields for departure and arrival from dropdowns. If a field is absent, set the dropdown to “Nothing.” The plugin detects available address fields using the “Type of information” option for text and select fields. Decide whether the output should be in km or miles, then click “Insert.”
Use the “Distances calculation mode” setting under the “General” tab to specify if distances from the Google Maps API should be as “route” or “direct” travel. In cases where Google Maps cannot calculate the distance, an editable error message will show (configurable in the “Texts” tab), and the form will not proceed until the user rectifies the input fields.