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.
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.
@ThinhDinh: This is amazing, thank you for sharing such detailed flows!
For our use case, we’re looking to do something along similar but less complex lines, i.e. enable users to search venue listings x miles/hours distance to venues from whatever town/city or postcode they enter, e.g. 2 hours from London, or 50 miles from Manchester etc.
Does the key to making this work lie in Google Scripts?
I was doing something similar but I stopped it due to I had to finish another project. Good to see this idea working fine on other APPs
Let me share my original idea (what I had developed so far to compare to yours):
I saved all my customers (stores/places) in my GS along with their coordinates (I supposed that working with coordinates instead addresses the searching will be faster and more accurate, it was my plan B)
The user writes his address using an Entry Text Field and the searching begins. I let the user use any address instead using the one used in his profile (just a matter of style, no problem)
Using an own function in GS I look for distances (Km) from User address to my customers (each one), something like =DistanceKm(UserAddress, CustAddress)
via Query() I get the 4-5 closest places/stores (I could show more places but I was thinking as my user on my APP) and show those few options on screen
I was thinking of letting a choice component to set the distance to search. I mean, my scope searching could be:
to give more chances to my user to decide where to go or ask for. Again, it’s just a matter of style.
I stopped my APP at step 4 so far but I wonder if your APP was using the same way I was thinking days ago (I use Query() instead of filters and other things than make any sheet something bigger)??