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.
Data flow:
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 ariesarsenal@gmail.com.
Thank you so much to @Robert_Petitto and @Jeff_Hager, I struggled with the flow at first but ultimately I think I made it good enough to integrate to whoever needs this.
Hi @Robert_Petitto, I just checked your input, it seems like when you are too far away (like USA and Spain) in this case the script canât return a value.
When I changed the fixed address to an address closer to your input, it worked.
Nice. Iâd like to see this work dynamically. Get the distance between two people, letâs say. Only thing is that scripts canât see Glide data columns.
Yeah, currently thereâs no way to get Glide data back to script so thatâs it.
Furthermore, if we can get the value of userâs current location then this would make the flow better. Users donât have to manually enter the address anymore.
@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?
@ThinhDinh: Thanks, I may take you up on that but right now weâre getting all our ducks in order first as the distance feature isnât a âmust haveâ for the app at the moment.
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:
2 Km
4 km
7 km
10 Km
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)??
I agree that coordinates would present a more accurate solution, thatâs for sure. Thatâs why getting current userâs coordinates would give our ideas much better results.
At first I got the user to write his address, that would change per order, but later changed it to this. Yeah itâs a matter of style, no problem.