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

# Inventory

> Reference for WEBSALE inventory actions: renew product reservations and manage back-in-stock notifications for unavailable items in the frontend.

This section describes the available actions in the `Inventory` area. With these actions, product reservations can be renewed and back-in-stock notifications can be managed.

***

## Actions overview

| **Action**                    | **Description**                                             |
| ----------------------------- | ----------------------------------------------------------- |
| `InventoryReserve`            | Renews the reservation of a product in the basket.          |
| `BackInStockActivateNotify`   | Activates a notification when a product is available again. |
| `BackInStockDeactivateNotify` | Deactivates an existing back-in-stock notification.         |

***

## Actions

### InventoryReserve

This action renews the reservation of a product in the basket. It is only relevant if the reservation duration of an item has expired and the customer wants to extend the reservation.

**Usage example**\
Can be used on the basket page when the reservation time of an item has expired and the customer should be given the option to renew the reservation.

**Parameters**

| **Name**       | **Description**                                                 |
| -------------- | --------------------------------------------------------------- |
| `basketItemId` | The ID of the basket entry whose reservation should be renewed. |

**Error codes**

| **Error code**        | **Description**                                                                         |
| --------------------- | --------------------------------------------------------------------------------------- |
| `missingBasketItemId` | Parameter `basketItemId` is missing.                                                    |
| `invalidBasketItemId` | The basket entry does not exist or does not belong to this basket.                      |
| `reservationFailed`   | The reservation could not be renewed, e.g., because the product is no longer available. |

**Related modules, variables & methods**

* [\$wsInventory](/en/frontend/referenz/module/wsinventory)
* [\$wsInventory.load()](/en/frontend/referenz/module/wsinventory#\$wsinventory-load)
* [\$wsInventory.loadReservation()](/en/frontend/referenz/module/wsinventory#\$wsinventory-loadreservation)
* [\$wsBasket.items](/en/frontend/referenz/module/wsbasket#\$wsbasket-items)

**Example** showing how a customer with an expired reservation is given the option to renew it via a button.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ var $myReservation = $wsInventory.loadReservation($myProduct.id) }}
{{ if $myReservation and $myReservation.duration == 0 }}
    {{ var $myActionInventoryReserve = $wsActions.create("InventoryReserve", tag=$myProduct.id) }}
    <form method="post" action="{{= $wsViews.viewUrl('basket.htm') }}">
        <input type="hidden" name="wscsrf" value="{{= $myActionInventoryReserve.csrf }}">
        <input type="hidden" name="wsact" value="{{= $myActionInventoryReserve.id }}">
        <input type="hidden" name="wstarget" value="{{= $wsViews.viewUrl('basket.htm') }}">
        <input type="hidden" name="basketItemId" value="{{= $myProduct.id }}">
        <button type="submit">Renew reservation.</button>
    </form>
{{ /if }}
```

***

### BackInStockActivateNotify

This action activates a notification that informs the customer by email as soon as a sold-out product is available again.

**Usage example**\
Can be used on the product detail page when a product is sold out and the customer wants to be notified as soon as it can be ordered again.

**Parameters**

| **Name**    | **Description**                                                       |
| ----------- | --------------------------------------------------------------------- |
| `productId` | The ID of the product for which the notification should be activated. |
| `email`     | The email address to which the notification should be sent.           |

**Error codes**

| **Error code**     | **Description**                         |
| ------------------ | --------------------------------------- |
| `missingProductId` | Parameter `productId` is missing.       |
| `missingEmail`     | Parameter `email` is missing.           |
| `emailCheckFailed` | The specified email address is invalid. |

**Related modules, variables & methods**

* [\$wsInventory](/en/frontend/referenz/module/wsinventory)
* [\$wsAccount.backInStockList](/en/frontend/referenz/module/wsAccount#\$wsaccount-backinstocklist)

**Example** showing how a customer can activate a notification for a sold-out product.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ var $myActionBackInStockActivateNotify = $wsActions.create("BackInStockActivateNotify") }}
<form method="post" action="{{= $wsViews.current.url() }}">
    <input type="hidden" name="wscsrf" value="{{= $myActionBackInStockActivateNotify.csrf }}">
    <input type="hidden" name="wsact" value="{{= $myActionBackInStockActivateNotify.id }}">
    <input type="hidden" name="productId" value="{{= $myProduct.id }}">
    <input type="email" name="email">
    <button type="submit">Be notified when the product is back in stock.</button>
</form>
```

***

### BackInStockDeactivateNotify

This action deactivates an existing back-in-stock notification.

**Usage example**\
Can be used on the account overview page, where logged-in customers can view and remove their active notifications.

**Parameters**

| **Name**    | **Description**                                                         |
| ----------- | ----------------------------------------------------------------------- |
| `productId` | The ID of the product for which the notification should be deactivated. |
| `email`     | The email address for which the notification should be deactivated.     |

**Error codes**

| **Error code**     | **Description**                   |
| ------------------ | --------------------------------- |
| `missingProductId` | Parameter `productId` is missing. |
| `missingEmail`     | Parameter `email` is missing.     |

**Related modules, variables & methods**

* [\$wsInventory](/en/frontend/referenz/module/wsinventory)
* [\$wsAccount.backInStockList](/en/frontend/referenz/module/wsAccount#\$wsaccount-backinstocklist)

**Example** showing how an active notification is deactivated via a button.

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