Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Difference between mutations “cartLinesUpdate” and “cartLinesAdd”

Difference between mutations “cartLinesUpdate” and “cartLinesAdd”

AndreaGiachetto
Visitor
1 0 0

I have a question regarding Storefront API mutations.
What is the difference between the mutations “cartLinesUpdate” and “cartLinesAdd”?
I’ve noticed that both have the same effect, that is updating the quantity of the product I pass to the endpoint.
When should I use one or the other?
Thank you for any hint!

Reply 1 (1)

garyrgilbert
Shopify Partner
431 41 186

Hi Andrea,

 

For cartLinesUpdate you need the cart line_item_id to associate your update mutation with the correct line_item in the cart, but for cartLinesAdd you are adding a line_item to the cart so the id is not needed.

 

Cheers,

 

Gary

- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution