Hi @HunkyBill
I am trying to update a form with user selection of particular products and during form submission, save those products as metafields under that particular customer and those products should to added to the cart.
I went through this https://shopify.dev/docs/themes/ajax-api/reference/cart#post-cart-add-js document, but this is an ajax call.
I am using nodejs and so, while form submission, I have retrieved the selected products and saved in the metafields and in continuation to that I want to addToCart from the app itself. I don’t see any document related to shopify API in adding to cart.
Can you please provide your suggestions on how to proceed.
The only way you could deal with Metafield and Product resources from a store is by using an App installed in the shop. So I assume you used NodeJS for that, and you have your connection between the store and App secured with the App Proxy pattern.
Simply put you are making an XHR call to your App via the Proxy, manipulating Metafield resources and returning a 200 OK status to the store. You can return JSON, or HTML/Liquid as you know.
Upon the return from that call, use the simplistic front-end Ajax to add the products to the cart. There is no need to add to cart from your App itself as it has no concept of the user’s cart.
If instead, you chose to present products to customers without a Shopify storefront, then you should be comfortable using the Storefront API, as it provides checkout options for your marked-up products.
1 Like
Thanks you @HunkyBill
Upon the return from that call, use the simplistic front-end Ajax to add the products to the cart - This solution worked.