Using AJAX API to add item to cart in a React app

Using AJAX API to add item to cart in a React app

nmy1095
Shopify Partner
6 0 2

Hi all, I'm working on a React app that I'll embed into a merchant's product page via an iFrame. Inside the React app, I'd like to create an "Add to Cart" button that'll add products (using their variantIDs) into the cart. I've tried following the Cart API reference to no avail. I also tried hardcoding the request URL with my store (ex. https://storeurl.com/cart/add.js) and got a 404 CORS error.

 

Has anyone worked on such use-case and is the AJAX API possible with a 3rd-party React app? Any tips in the right direction would be greatly appreciated. Thank you!

Replies 0 (0)