Hi everyone,
With the deprecation of the Checkout API, I’m transitioning to Shopify’s Cart API. In the Checkout API, we had a simple way to replace the entire cart by passing new line items, but I don’t see a direct equivalent in the Cart API.
From my research, the Cart API provides mutations like:
- cartLinesAdd (to add new items)
- cartLinesRemove (to remove specific items)
- cartLinesUpdate (to update existing items)
However, there doesn’t seem to be a cartLinesReplace or cartReplace mutation. This means that if I want to completely replace the cart with a new set of line items, I need to:
- Fetch the current cart items (cart(id: $cartId)).
- Remove all existing line items (cartLinesRemove).
- Add the new line items (cartLinesAdd).
Is there an efficient way to replace the entire cart in a single API call?