# updateCheckoutPlusLines: Update the Checkout+ product (CartConnector)

> STEP 3-2

```ts
updateCheckoutPlusLines(change: CheckoutPlusLineChange): Promise<'applied' | 'rejected'>
```

A `CartConnector` function that the SDK user implements. Removes and adds Checkout+ product lines exactly as specified in the change the SDK decided on (`change`). An implementation example is in [Step 2: Implement `CartConnector`](./shopify-headless-cart-connector.html).

## Which cart to update

`change` does not specify a cart. Update the same single cart that `getCart` returns. This also applies when one page handles more than one cart.

## What to return

| Return | When |
| --- | --- |
| `'applied'` | Only when all removals and additions succeeded and the addition returned no stock `warnings` |
| `'rejected'` | When you're sure nothing was changed (Storefront API `userErrors`, etc.) |
| Exception | When only part of the change succeeded (for example, only the removal succeeded), or when the result is unknown (for example, a timeout, or the updated cart is not returned) |

- If there are both removals and an addition, remove first, then add.
- When the addition returns stock `warnings` (`MERCHANDISE_OUT_OF_STOCK`, `MERCHANDISE_NOT_ENOUGH_STOCK`), you can't tell what happened to the added line (not added, or added with quantity 0). Whichever line the warning is about, throw an exception as an unknown result.

## When it returns `'rejected'`

| When the SDK called it | What was rejected | How the SDK handles it |
| --- | --- | --- |
| Inside `prepareCheckout()` | The addition (`change.remove` is empty) | It does not retry. It completes with `{ attached: false }` and reports `add-failed` through `onError` |
| Inside `prepareCheckout()` | The removal (`change.remove` has lines) | It fetches the cart again, decides again from the cart at that moment, and retries once. If it completes without confirming that the Checkout+ product was removed, it reports `remove-failed` through `onError` |
| On the first `mount()` or `refresh()`, or when [the previous screen is shown as is](./overview.html#glossary) | The removal | It does not retry, and does not report through `onError`. The next `prepareCheckout()` decides again from the cart at that moment |

- In every case, checkout is not blocked.
- The retry happens within the 10-second limit of `prepareCheckout()`. After 10 seconds, the SDK does not retry.

## When it throws

- How the SDK handles it: It treats the result as unknown, fetches the cart again, and decides based on the actual cart.
- Because the SDK refetches the cart after an update to verify it, mistakes in `CartConnector` won't block purchases. With most mistakes, the shopper proceeds to checkout without Checkout+ being added.

## Value passed in (CheckoutPlusLineChange)

| Field | Type | Description |
| --- | --- | --- |
| `remove` | `string[]` | IDs of the lines to remove (Checkout+ product lines only) |
| `add` | Object or `null` | The Checkout+ product to add (`variantId`, `quantity` (always 1), `attributes`). Use `attributes` as the line attributes as is. If `null`, nothing is added |
