> ## 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.

# Intents

> Configure save, unsave, and cart behavior.

Intent options control how save, unsave, and cart actions interact with the customer. Pass them under `intents` in your `SwishOptions`.

> [!TIP]
>
> Looking to configure the layout of views like the drawer, home, or saves? See
> the [Views overview](https://swish.app/docs/guides/customize/views/overview.md).

## Save behavior

```js theme={null}
window.SwishOptions = {
  intents: {
    saveProduct: {
      promptVariantIfMissing: true,
      promptVariantIfPresent: false,
      showFeedback: true,
    },
  },
};
```

| Option | Type | Default | Description |
| - | - | - | - |
| `promptVariantIfMissing` | `boolean \| ((args: { product, variant }) => boolean)` | `true` | Show the variant selector when no variant is provided. Pass a function to decide per product. |
| `promptVariantIfPresent` | `boolean` | `false` | Show the variant selector even when a variant is already selected. |
| `saveBeforeVariantPrompt` | `boolean` | `true` | Save the item before showing the variant selector. |
| `showFeedback` | `boolean` | `true` | Show a toast notification after saving. |

Pass a function to `promptVariantIfMissing` when certain products should skip the variant selector. The function receives the product and variant (if selected) and returns `true` to show the selector or `false` to skip it. Product metafields are available when configured under `metafields`.

```js theme={null}
window.SwishOptions = {
  metafields: {
    product: ["custom.skip_variant_select"],
  },
  intents: {
    saveProduct: {
      promptVariantIfMissing: ({ product, variant }) =>
        product.metafields.custom?.skip_variant_select !== "true",
    },
  },
};
```

> [!TIP]
>
> `promptVariantIfPresent` is already `false` by default, so saves from a
> product page that has its own variant picker happen instantly. Set it to
> `true` only if you want customers to confirm the variant in Swish as well.

## Unsave behavior

```js theme={null}
window.SwishOptions = {
  intents: {
    unsaveProduct: {
      selectList: true,
      confirm: true,
      showFeedback: true,
    },
  },
};
```

| Option | Type | Default | Description |
| - | - | - | - |
| `selectList` | `boolean` | `true` | Let the customer choose which list to remove the item from. |
| `confirm` | `boolean` | `true` | Show a confirmation dialog before removing. |
| `showFeedback` | `boolean` | `true` | Show a toast notification after removing. |

> [!NOTE]
>
> `selectList` only applies to stores with more than one list. Running [a single
> list](https://swish.app/docs/guides/customize/views/overview.md#single-list-only) - or the classic
> wishlist page - skips the picker whatever this is set to, since there is
> nothing to choose between.

## Edit saved product

| Option | Type | Default | Description |
| - | - | - | - |
| `promptVariantChange` | `boolean` | `true` | Show the variant selector when editing a saved item. |
| `showFeedback` | `boolean` | `true` | Show a toast notification after updating. |

## Quick buy

Whether tapping the quick-buy button on a product card adds straight to cart or opens the quick buy dialog. To have customers confirm the variant and quantity in the dialog first:

```js theme={null}
window.SwishOptions = {
  intents: {
    initiateQuickBuy: {
      promptVariantIfPresent: true,
    },
  },
};
```

| Option | Type | Default | Description |
| - | - | - | - |
| `promptVariantIfPresent` | `boolean` | `false` | When the card already knows the variant, open the dialog to confirm it. |

By default, a card that already has a variant, such as an item saved with one, skips the dialog and adds that variant to the cart directly. It adds the amount on the card's quantity stepper when one shows, and 1 otherwise. The button invokes `create:cart-line` itself, so listeners on `initiate:quick-buy` won't fire for it. Cards without a variant always open the dialog.

## Cart behavior

Control what happens when items are added to or removed from the cart.

```js theme={null}
window.SwishOptions = {
  intents: {
    createCartLine: {
      afterComplete: (response) => {
        if (response.code === "ok") {
          window.location.href = "/cart";
        }
      },
    },
    removeCartLine: {
      saveCartLine: true,
    },
    saveCartLine: {
      confirm: false,
      showFeedback: true,
    },
  },
};
```

| Option | Path | Type | Default | Description |
| - | - | - | - | - |
| `afterComplete` | `createCartLine` | `(response) => void` | - | Callback invoked after adding to cart. |
| `saveCartLine` | `removeCartLine` | `boolean` | `true` | Prompt the customer to save items removed from the cart. |
| `confirm` | `saveCartLine` | `boolean \| "toast" \| "dialog"` | `false` | Ask before saving a removed cart item: `true` or `"toast"` in a toast, `"dialog"` in a modal dialog. |
| `showFeedback` | `saveCartLine` | `boolean` | `true` | Show a toast after saving a cart item. |
| `destination` | `saveCartLine` | `"saved-from-cart" \| "wishlist"` | `"saved-from-cart"` | Which list the saved cart line lands in. |
| `afterComplete` | `saveCartLine` | `(response) => void` | - | Callback invoked after saving a cart item. |

## Further reading

* [Intents reference](https://swish.app/docs/references/sdk/intents.md) for all intent parameters and response types
* [Full defaults reference](https://swish.app/docs/guides/customize/defaults.md) for all intent defaults


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