Inspired by this posts regarding how some businesses can’t offer a delivery outside their 5km radius.
I developed a solution to calculate distance between customer’s input address and
the business’ fixed address. The use of postcode was proposed in some threads, but I don’t think it would have the same effect as taking the exact distance via Google.
My test app link: geocodetest.glideapp.io
Sign in via mail, if user has not filled their name, address and phone number, order options won’t be shown. They can fill up those information via the Profile tab. Thanks @Robert_Petitto for his instructions on this!
Once they have “signed up”, a small profile of them will be shown on the top of the “Dishes” tab, containing their address, how many minutes it takes to deliver to them, and a message for them to see if delivery is available for their address or not.
If they are more than 5km away, the options for ordering won’t be shown, and vice versa. They can edit their address and phone number via the item in “Dishes” tab as well, and it takes some seconds for recalculation once they have entered a new address.
I did not develop the further steps in the process (ordering, add to cart, etc.) since this is concentrated on how to restrict orders outside of a certain radius.
Address, phone number, email and avatar (avatar is not required) will be assigned to a “User Profile” tab in the Sheets.
The script I used will be in charge of calculating the distance and travel duration for user’s address to the fixed business address. For demonstration, the fixed address was set to “Santiago Bernabeu Stadium”.
When the user edits their delivery info in the “Dishes” tab, their user profile info will be edited as well. Next time they log in, the address will be the last one they used.
Calculation of distance and travel time will be done automatically thanks to another script that copies the formulae down (since they do not work with arrayformula).
This was done with the help of Google Scripts. If any people want to integrate this to their app, please drop me a message here or via email email@example.com.