Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can’t get Shopify cart via jsonp crossdomain anymore #8

Open
oscarni opened this issue Jul 17, 2020 · 3 comments
Open

Can’t get Shopify cart via jsonp crossdomain anymore #8

oscarni opened this issue Jul 17, 2020 · 3 comments

Comments

@oscarni
Copy link

oscarni commented Jul 17, 2020

I’m using “Get Shopify cart data with JSONP“. Since a couple of days ago the request returns empty carts. Anyone else experiencing the same?

I make sure the Shopify store has items in the cart, but when getting the cart via Jsonp from another domain the cart response is without any cart items. Did Shopify change it’s api in some way?

@freakdesign
Copy link
Owner

Interesting. It's possible that JSONP is no longer accepted but would have to look into it.
Do you have some replication steps/code used so I can give it a test using the same process?

@oscarni
Copy link
Author

oscarni commented Jul 24, 2020

To test I'm running your script in the console. I get the response from shopify, it's just without any items which I can see are in the cart when I visit the shop.

This could be far fetched, but I think I've figured it out. It looks like it works when I have https setup and only when i'm running the script from the same main domain. So it works when I run it on a subdomain of the main shopify store. But cross-domain with a totally different domain doesn't look like it works anymore. Could be related to chrome setting same-site: lax as default on cookies or some other cookie restriction shopify has limiting the session to only be available on the main domain.

Edit: I can confirm that it get the correct cart when request is made from a subdomain of the same main Shopify domain and over ssl. To test locally i suggest running your local server over https (adding certificates was a pain) and adding a testing subdomain.maindomain to your hosts file.

@NotARobit
Copy link

Looks like @oscarni is correct about the cookies. My shop is on a subdomain, so I'm able to set my own cookie that is usable by both domains.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants