I want to update lineitem in the checkout, but I need to include lineitem id in the checkoutLineItemsUpdate mutation.
So I want to get lineitem id after adding a product to checkout so that I can use it when I update the lineitem. But I don’t know how to get lineitem id in the return of checkoutLineItemsAdd mutation.
@Luke_K thank you for your kind reply. This should work.
Only my concern is that I don’t have the storefront access token with the access to get line items. I tried to get the new one from the private app, but the new token didn’t work. It still doesn’t have access. Which access scopes do I need to select?
Could you please let me know your thoughts? Am I missing anything?
For that call I made above to checkoutLineItemsAdd, my X-Shopify-Storefront-Access-Token specified in my private app when I make the call has the following scopes below enabled; you’d need those to be able to call checkoutLineItemsAdd, it wouldn’t work without them. Let me know if that helps!
I’m thinking if the X-Shopify-Storefront-Access-Token is correct, it has to be something passed in the settings const or the headers.
So one thing I noticed in your settings const, the Content-Type header is application.json.
I would try changing that to ‘application/graphql’. I figured you were just omitting the url in the settings const too, but ensure it’s going to the Storefront API endpoint and not the admin endpoint (that catches people out sometimes).
Alas, Liquid is technically out of scope for my team, but to the best of my knowledge I don’t believe this approach is possible via Liquid at this time. You may want to check in the Liquid forums though. Thanks!
The line items returned by the Storefront Checkout and Cart API do not seem to be sorted in any predictable fashion, meaning that your query will not return the line item which was last added to cart but merely any one of the line items.