Issue: Adding non‑Shopify items to cart via /cart/add.js returns “Required parameter missing or invalid: id.” The poster assumed variant_id could be null for a custom (non‑Shopify) product.
Key clarification: /cart/add.js requires a valid variant ID. “Custom line items” can’t be added unless the item (product/variant) is created in the Shopify store first. A reference thread was provided supporting this constraint.
Proposed approach: The poster asks if they can build their own client‑side cart, then, at checkout time, loop through that cart and add each non‑Shopify product as a line item to Shopify checkout via API.
Status/outcome:
Confirmed: You cannot add to cart without a variant ID; items must exist in Shopify.
Open question: Whether the hybrid approach (external cart, then API injection at checkout) is possible wasn’t answered in the thread. No final resolution or implementation steps provided.
Notes: Terms—variant ID (Shopify’s required identifier for a purchasable variant); /cart/add.js (Ajax endpoint to add variants to the cart); “custom line item” here refers to non‑catalog items, which Shopify does not support directly in cart without creating them in the catalog first.
I am adding non-shopify products to the cart using /cart/add.js. However, whenever I am doing this, it is giving me an error message indicating that I am not providing an Id. The error message is - description: “Required parameter missing or invalid: id”. I thought, variant_id can be null when adding a non-shopify product.
My question is, what is the best approach should I be doing? What I wanted to do is whenever I add a custom line item, it should show up in the shopify cart for checkout. Does /cart/add.js work for this?
Thank you for reaching out to the Shopify community.
While calling /add.js API there won’t be a way to add products to the cart without passing variant id. To pass a custom line item to the cart it has to be first created on the Shopify store.
Hello! Thank you for the information. How about creating my own cart system, collecting product data through JavaScript, and then integrating with Shopify only when the user is ready to check out. I will loop through custom cart data and add each non-Shopify product as a line item to the Shopify checkout using the API. Is this possible?