Join us for an upcoming Shopify Partner webinar on February 27, 2024. Discover the latest Checkout Extensibility features, and deep dive on improvements to Shopify Functions and Web Pixels. Register now for either the 10am EST or 2pm EST sessions.

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