I am using the script tag API to install a JS file on a shop front end.
The js file sends an ajax request to my server when a form is submitted.
How do I identify the store that the request is coming from?
Thanks for the quick response.
"or include a query parameter that you can use to identify the source."
This is what I'm stuck with.
How can I send a parameter to identify the shop (source). I could probably get the domain name of the shop and check that against the shop in the local database in my app but what if the user is using a custom domain and I only have their *.myshopify.com domain in my db? Then it won't match.
Aha, I think I've just found the answer to my question by looking in the DOM tab in firebug.
There is a Shopify object that contains the shop name - which I guess should always match my database.
My only question on this subject now is... is this object in all themes or something that was added by theme developer in the theme I am using (launchpad)?
Ah ok, I would need to set up some htaccess mod rewriting, unless I could do:
Is there any problem with my previous suggestion of getting the shop name from the Shopify object shop name?
It requires an extra request which isn't necessary.
I've done all this stuff with rails or sinatra routing so I've never had to deal with .htaccess. If you're doing PHP I guess that's what you'll have to do.
And actually, if you look at the script tag it will tell you which shop is requesting the JS. For example here's a request for some JS I needed for the now defunct Google Trusted Stores Shopify integration I worked on.