Add to cart ajax api

Shopify Partner
2 0 0

Hello, i'm trying to run the following code on my localhost from this page'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)

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.