Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Add to cart ajax api

Add to cart ajax api

dimamakefor
Shopify Partner
2 0 0

Hello, i'm trying to run the following code on my localhost from this page https://shopify.dev/api/ajax/reference/cart(I've replaced the ID with the existing product)

 

Screenshot 2022-07-25 at 12.23.47 PM.png

And I'm getting this:

Screenshot 2022-07-25 at 12.25.01 PM.png

 What's the issue here? As far as I know there shouldn't be such file, as this is an endpoint for API.

Reply 1 (1)

SabirHussain
New Member
6 0 0

Yes, I had the same problem, we can't test add to cart locally, but it should work after deployment.
If window.Shopify.routes.root doesn't work for you try replacing it with window.origin.
In my case its working.
Do let me me know in case you still got some error, may be I would be able to help.

Sabir