I’m trying to build an app that sells location-based service. The provider, won’t issue (and therefore won’t sell) their service if a customer is more than 1km away.
Currently, it seems that the checkout feature works like any eCommerce storefront - input your address and we will ship it anywhere.
Is it possible instead to restrict sales per delivery radius? E.g. type your address first, and if we can deliver in your area we will then allow you to complete the purchase.
Thanks guys
You would have to find an API provider able to calculate a distance between your shop address and the client address. But it could be quite long to do the computation (api call a’d get the result back to confirm or reject the delivery).
On my side II had the same kind of constraint, but linked to post codes. So I built a list of post codes and use a choice component to force the delivery address. Not so good, not so bad…
Hi, in my opinion, if you want to get the distance between your shop and the customer’s delivery address, you have 2 methods:
- Input 2 addresses and get a Google Script to calculate the distance for you using Maps API. Consider the scale of your business because after a certain number of runs to get the distances, this will charge your credit card.
- Generate 2 addresses’ latitude and longitude (which also requires a Script), then calculate the distance using haversine formula.
Then it’s an easy IF formula to determine if it’s in your delivery radius.
2 Likes
Thanks Christophe, postcode is not ideal nowadays but it gets the job done 
As I understand, you have enabled a further step before getting to the checkout phase. I imagine, type your postcode and IF we serve that postcode, we will let you order.
Problem is, what if a user inserts a dummy (still, valid) postcode just to be able to order? At that stage I imagine the vendor will have to manually cancel the order and refund?
Thanks ThinhDinh, it sounds like a solution. A bit complex considering my limited development skillset.