Get shop name with Embedded App.

nextBigApp
New Member
2 0 0

 

I have built a dashboard in Javascript/React/node.js to sit within a shopify store owners admin page.

Each store owner will have their own data and dashboard, I am trying to get the shop name in the dashboard.

The dashboard is an iFrame of my dashboard that I am hosting. 

I have tried many many methods of trying to get the parent page's URL and data such as below:

None of them work they all return undefined or say 'localhost' is there anyway to capture this with Javascript?

Alternatively I have noticed when the authentication process begins when the user installs the app the domain is collected and stored, is there a way to capture this each time the store-owner is using the app? So I can try this from the server -> dashboard rather than dashboard -> server?

There is a method of using sessions with cookies but if someone clears their cookies I think the app would need to be reinstalled.

any help would be massively appreciated.

var url = (window.location != window.parent.location)
            ? document.referrer
            : document.location.href;
parent.document.location
parent.window.document.location
parent.window.location
parent.document.location.href
0 Likes
KarlOffenberger
Shopify Partner
1867 182 777

Hi,

I would definetely not recommend using frontend JavaScript for this. Generally, any kind of cross iframe communication not originating from the same source will end up in tears unless you're creating bookmarklet type apps though even those are fragile.

That's what the API's are for and with your app being installed by a merchant in their store, they grant you API access to query their store - among which is also store meta data such as the name.

Hope this helps!

Liked this post? You might also like our fantastic upsell apps Candy Rack and Candy Cart or offer free gifts with Gift Box. All made with ❤️  and care by Digismoothie
0 Likes
anitha
New Member
6 0 0

same kind i have tried out and this worked for me : 

console.log("window.location.hostname is ",window.parent.location.href); and am having one doubt any way u can use that session store value as shopOrgin by having that option only am not querying the shop name now. Any how this works well for you. Please have a try with this: window.parent.location.href
0 Likes