> ## Documentation Index
> Fetch the complete documentation index at: https://swish.app/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Save from cart

> Automatically save items for customers when they remove products from the cart.

Save from cart lets customers keep items they remove from the cart instead of losing them. When enabled, Swish intercepts cart line removals and saves the product to the customer's list so they can purchase it later.

## How it works

1. A customer removes an item from their cart.
2. Swish saves the item to their list with `source: "cart"`.
3. A feedback toast confirms the save and offers an **Undo** action that removes the item again if pressed (optional).

If `confirm` is set, Swish asks before saving so the customer can choose whether to keep the item. Set it to `"toast"` (or `true`) to ask in a toast, or to `"dialog"` to ask in a modal dialog the customer can't miss. In the customiser this is **Global → Preferences → Cart → Ask before saving a cart line**. The undo action is only shown when `confirm` is off, since prompting and offering undo would be redundant.

In the drawer, each "Saved from cart" card has a heart that moves the item to the customer's wishlist with its quantity, taking it out of "Saved from cart", and a trash button that removes the item from "Saved from cart" after a confirmation. The wishlist item the heart saves carries the `saved-from-cart` tag. To remove one in code, call `swish.api.smartLists.removeItem("saved-from-cart", itemId)`.

## Enabling and disabling

Save from cart is **enabled by default**. Two settings control the feature:

* **`intents.removeCartLine.saveCartLine`** -- triggers the save when a cart line is removed. Enabled by default.
* The `saved-from-cart` section in the [home view](https://swish.app/docs/guides/customize/views/home.md) shows the "Saved from cart" smart list in the drawer. Included by default.

To disable save from cart:

```js theme={null}
window.SwishOptions = {
  intents: {
    removeCartLine: {
      saveCartLine: false,
    },
  },
};
```

## Configuration

Fine-tune the save behavior under `intents.saveCartLine`:

```js theme={null}
window.SwishOptions = {
  intents: {
    removeCartLine: {
      saveCartLine: true,
    },
    saveCartLine: {
      confirm: "dialog",
      showFeedback: true,
      afterComplete: (response) => {
        console.log("Saved from cart", response);
      },
    },
  },
};
```

| Option | Type | Default | Description |
| - | - | - | - |
| `confirm` | `boolean \| "toast" \| "dialog"` | `false` | Ask before saving the removed cart item. `true` or `"toast"` asks in a toast, `"dialog"` in a modal dialog. |
| `showFeedback` | `boolean` | `true` | Show a feedback toast after saving. When `confirm` is `false`, the toast also offers an undo action. |
| `destination` | `"saved-from-cart" \| "wishlist"` | `"saved-from-cart"` | Which list the saved cart line lands in. |
| `afterComplete` | `(response) => void` | `undefined` | Callback invoked after the item is saved. |

### Saving to the wishlist instead

Set `destination` to `"wishlist"` for a "move to wishlist" behaviour: removed cart lines are saved as ordinary wishlist items rather than into the "Saved from cart" smart list. Each one carries the `saved-from-cart` tag. The `saved-from-cart` section in the [home view](https://swish.app/docs/guides/customize/views/home.md) then has nothing to show, and the "For you" `lists-section` in the [saves view](https://swish.app/docs/guides/customize/views/saves.md) is hidden along with it. That section renders smart lists only, so hiding it also removes "Recently viewed" — there is currently no way to keep one without the other. Switching the destination in the customiser applies both changes for you; configuring `destination` in code does not, so hide the sections yourself.

```js theme={null}
window.SwishOptions = {
  intents: {
    saveCartLine: {
      destination: "wishlist",
    },
  },
};
```

> [!TIP]
>
> Set `confirm` if you want customers to explicitly opt in to saving removed
> cart items rather than saving automatically. `"dialog"` is the hardest to miss
> on a wide screen; rename its text with the `saveForLaterAlert` keys in
> [translations](https://swish.app/docs/guides/customize/translations.md#save-for-later-alert).

## Further reading

* [Intents](https://swish.app/docs/guides/customize/intents.md#cart-behavior) for all cart-related intent options
* [Configuration reference](https://swish.app/docs/references/sdk/configuration.md#removecartline) for the complete options list


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.