Reputation: 7277
Is there no Shopify API call to know the ip/location/country of the user?
Here the user means any public user in the fronted.
Upvotes: 2
Views: 3494
Reputation: 551
Kinda late to the party, but yes, it can be easily done. Make an app proxy and shopify will send you a lot of data (incl. his IP) about the client. The only major thing NOT included are the cookies (kinda weird, but whatever).
So this is how you would do it - download and save an IP-to-country database (many free ones available on the net) and put the database where you put your apps. Make an app that looks at the request header and takes the IP and uses it to figure out the country. Now create an app proxy and then simply use ajax from any page to access it, the client need not know. If you want more, you can send the cart cookie (using JS) along with it to track which IP belongs to which cart. If you allow user login, you can send that too.
Upvotes: 4
Reputation: 4976
The Shopify API can give you access to customer data, but it only goes as far as giving you the shipping and billing addresses they entered during checkout.
If you want live location information in the browser, that's a different kettle of fish entirely. I'd recommend starting at a site like this: http://www.browsergeolocation.com/
Upvotes: 2