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

# WatchList

> Reference for WEBSALE watchlist actions used to add products to a customer's wish list and remove them again from saved selections.

This section describes the available actions in the watchlist area. With these actions, products can be added to or removed from the watchlist.

***

## Actions overview

| **Action**            | **Description**                             |
| --------------------- | ------------------------------------------- |
| `WatchListItemAdd`    | Adds one or more products to the watchlist. |
| `WatchListItemDelete` | Removes a product from the watchlist.       |
| `AddWatchList`        | Creates a new watchlist.                    |
| `DeleteWatchList`     | Deletes an existing watchlist.              |
| `RenameWatchList`     | Renames an existing watchlist.              |

***

## Actions

### WatchListItemAdd

This action adds a product to the user's watchlist. Both individual products and multiple products can be passed simultaneously.

**Usage example**\
Can be used on product or category pages where customers can add items to their watchlist to find or buy them later.

**Parameters**

| **Name**                               | **Description**                                                                       |
| -------------------------------------- | ------------------------------------------------------------------------------------- |
| `productId`                            | The ID of the product to be added to the watchlist.                                   |
| `freeFields.<identifier>`              | Optional free fields that can be assigned to the watchlist entry.                     |
| `multiProducts.<productId>.<quantity>` | Allows multiple products to be added simultaneously with their respective quantities. |

**Error codes**

| **Error code**     | **Description**                                                    |
| ------------------ | ------------------------------------------------------------------ |
| `missingProductId` | Parameter `productId` is missing or empty.                         |
| `invalidProductId` | The product with the specified `productId` does not exist.         |
| `invalidVariantId` | The specified variant of the product is invalid or does not exist. |

**Related modules, variables & methods**

* [\$wsWatchList](/en/frontend/referenz/module/wswatchlist)
* [\$wsWatchList.watchLists](/en/frontend/referenz/module/wswatchlist#\$wswatchlist-watchlists)
* [\$wsWatchList.loadWatchList()](/en/frontend/referenz/module/wswatchlist#\$wswatchlist-loadwatchlist)
* [\$wsWatchList.isProductOnWatchList()](/en/frontend/referenz/module/wswatchlist#\$wswatchlist-isproductonwatchlist)
* [\$wsWatchList.countWatchListsWithProduct()](/en/frontend/referenz/module/wswatchlist#\$wswatchlist-countwatchlistswithproduct)

**Example** showing how a product is added to the default watchlist.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ var $myActionWatchListItemAdd = $wsActions.create("WatchListItemAdd") }}
<form method="post" action="{{= $wsViews.current.url() }}">
    <input type="hidden" name="wsact" value="{{= $myActionWatchListItemAdd.id }}">
    <input type="hidden" name="wscsrf" value="{{= $myActionWatchListItemAdd.csrf }}">
    <input type="hidden" name="productId" value="{{= $myProduct.id }}">
    <input type="hidden" name="watchListIds.default" value="default">
    <button type="submit">Add to watchlist</button>
</form>
```

***

### WatchListItemDelete

This action removes an entry from the user's watchlist.

**Usage example**\
Can be used on the watchlist page where customers can delete individual products from their watchlist.

**Parameters**

| **Name**          | **Description**                              |
| ----------------- | -------------------------------------------- |
| `watchListItemId` | The ID of the watchlist entry to be deleted. |

**Error codes**

| **Error code**           | **Description**                                  |
| ------------------------ | ------------------------------------------------ |
| `missingWatchListItemId` | Parameter `watchListItemId` is missing or empty. |

**Related modules, variables & methods**

* [\$wsWatchList](/en/frontend/referenz/module/wswatchlist)
* [\$wsWatchList.watchLists](/en/frontend/referenz/module/wswatchlist#\$wswatchlist-watchlists)
* [\$wsWatchList.loadWatchList()](/en/frontend/referenz/module/wswatchlist#\$wswatchlist-loadwatchlist)
* [\$wsWatchList.loadWatchListItemId()](/en/frontend/referenz/module/wswatchlist#\$wswatchlist-loadwatchlistitemid)

**Example** showing how a product is removed from the default watchlist by its watchlist entry ID.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ var $myActionWatchListItemDelete = $wsActions.create("WatchListItemDelete") }}
{{ var $myWatchListItemId = $wsWatchList.loadWatchListItemId("default", $myProduct.id) }}
<form method="post" action="{{= $wsViews.current.url() }}">
    <input type="hidden" name="wsact" value="{{= $myActionWatchListItemDelete.id }}">
    <input type="hidden" name="wscsrf" value="{{= $myActionWatchListItemDelete.csrf }}">
    <input type="hidden" name="productId" value="{{= $myProduct.id }}">
    <input type="hidden" name="watchListItemId" value="{{= $myWatchListItemId }}">
    <button type="submit">Remove from watchlist</button>
</form>
```

***

### AddWatchList

This action creates a new watchlist for the logged-in user.

**Usage example**\
Can be used on the watchlist management page where customers can create additional watchlists, e.g., for various occasions or categories.

**Parameters**

| **Name**        | **Description**                |
| --------------- | ------------------------------ |
| `watchListName` | The name of the new watchlist. |

**Error codes**

| **Error code**         | **Description**                       |
| ---------------------- | ------------------------------------- |
| `notLoggedIn`          | The user is not logged in.            |
| `missingWatchListName` | Parameter `watchListName` is missing. |

**Related modules, variables & methods**

* [\$wsWatchList](/en/frontend/referenz/module/wswatchlist)
* [\$wsWatchList.watchLists](/en/frontend/referenz/module/wswatchlist#\$wswatchlist-watchlists)

**Example** showing how a new watchlist is created via an input field.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ var $myActionAddWatchList = $wsActions.create("AddWatchList") }}
<form method="post" action="{{= $wsViews.current.url() }}">
    <input type="hidden" name="wsact" value="{{= $myActionAddWatchList.id }}">
    <input type="hidden" name="wscsrf" value="{{= $myActionAddWatchList.csrf }}">
    <input type="text" name="watchListName">
    <button type="submit">Create new watchlist.</button>
</form>
```

***

### DeleteWatchList

This action deletes an existing watchlist of the logged-in user.

**Usage example**\
Can be used on the watchlist management page where customers can remove watchlists they no longer need.

**Parameters**

| **Name**      | **Description**                        |
| ------------- | -------------------------------------- |
| `watchListId` | The ID of the watchlist to be deleted. |

**Error codes**

| **Error code**       | **Description**                                                                 |
| -------------------- | ------------------------------------------------------------------------------- |
| `notLoggedIn`        | The user is not logged in.                                                      |
| `missingWatchListId` | Parameter `watchListId` is missing.                                             |
| `invalidWatchListId` | The specified watchlist does not exist or does not belong to this user account. |

**Related modules, variables & methods**

* [\$wsWatchList](/en/frontend/referenz/module/wswatchlist)
* [\$wsWatchList.watchLists](/en/frontend/referenz/module/wswatchlist#\$wswatchlist-watchlists)

**Example** showing how a watchlist is deleted via a button.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ var $myActionDeleteWatchList = $wsActions.create("DeleteWatchList") }}
<form method="post" action="{{= $wsViews.current.url() }}">
    <input type="hidden" name="wsact" value="{{= $myActionDeleteWatchList.id }}">
    <input type="hidden" name="wscsrf" value="{{= $myActionDeleteWatchList.csrf }}">
    <input type="hidden" name="watchListId" value="{{= $myWatchList.watchListId }}">
    <button type="submit">Delete watchlist.</button>
</form>
```

***

### RenameWatchList

This action renames an existing watchlist of the logged-in user.

**Usage example**\
Can be used on the watchlist management page where customers can adjust the name of an existing watchlist.

**Parameters**

| **Name**        | **Description**                        |
| --------------- | -------------------------------------- |
| `watchListId`   | The ID of the watchlist to be renamed. |
| `watchListName` | The new name of the watchlist.         |

**Error codes**

| **Error code**         | **Description**                                                                 |
| ---------------------- | ------------------------------------------------------------------------------- |
| `notLoggedIn`          | The user is not logged in.                                                      |
| `missingWatchListId`   | Parameter `watchListId` is missing.                                             |
| `missingWatchListName` | Parameter `watchListName` is missing.                                           |
| `invalidWatchListId`   | The specified watchlist does not exist or does not belong to this user account. |

**Related modules, variables & methods**

* [\$wsWatchList](/en/frontend/referenz/module/wswatchlist)
* [\$wsWatchList.watchLists](/en/frontend/referenz/module/wswatchlist#\$wswatchlist-watchlists)

**Example** showing how a watchlist is renamed via an input field.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ var $myActionRenameWatchList = $wsActions.create("RenameWatchList") }}
<form method="post" action="{{= $wsViews.current.url() }}">
    <input type="hidden" name="wsact" value="{{= $myActionRenameWatchList.id }}">
    <input type="hidden" name="wscsrf" value="{{= $myActionRenameWatchList.csrf }}">
    <input type="hidden" name="watchListId" value="{{= $myWatchList.watchListId }}">
    <input type="text" name="watchListName" value="{{= $myWatchList.watchListName }}">
    <button type="submit">Rename watchlist.</button>
</form>
```
