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

# BackInStockMail (OrderNow service)

> How to notify buyers by email in WEBSALE V8s as soon as an unavailable product is back in stock.

With "BackInStockMail", a buyer leaves their contact details for a product that is currently not available. If the availability status improves, the shop automatically sends a personalized email with a deep link directly to the product. If the product has dependent variants, the link leads directly to the desired variant.

![Backinstockmail](https://mintcdn.com/websaleag-44ee7ea6/Dgb_SNFMeC9HkKBV/images/backinstockmail.png?fit=max\&auto=format\&n=Dgb_SNFMeC9HkKBV\&q=85\&s=98758ae24a64fbea51b016ede3a5f96e)

> [!NOTE]
>
> The feature was formerly called "OrderNow service". The old name still appears in the technical identifiers, for example in the configuration section `<OrderNowMail>`.

## When an email is sent

The email is not triggered by a schedule but by the improvement of the availability status compared to the moment of registration.

| Registration was made at status | Email is sent when the status changes to |
| - | - |
| red | yellow or green |
| yellow | green |

> [!NOTE]
>
> No distinction is made between "red not orderable" (red-hard) and "red orderable" (red-soft). No email is therefore sent when switching from red-hard to red-soft.

The service is most useful when you cannot give a foreseeable date for the return to availability. In this case, the product should have the status "red not orderable" (red-hard) at red stock levels. Instead of the shopping cart button, you then show the button for the BackInStockMail.

## Requirement

Dynamic stock management must be activated. Without it, the shop does not know an availability status whose change it could react to.

Guide: Displaying stock levels&#x20;

## Overview of the building blocks

The function consists of three templates, one email, and two configuration sections. Get this overview first, then the integration steps fall into place on their own.

| Building block | Purpose | Assignment |
| - | - | - |
| Product detail view `ws_product.htm` | carries the registration button | already present |
| Registration template | asks for the contact details | `<Templates>`, parameter `InventoryRegister` |
| Confirmation template | confirms the registration | `<Templates>`, parameter `InventoryRegisterConfirm` |
| Email template | the notification itself | `<OrderNowMail>`, parameter `Template` |
| Overview template (optional) | lists the registered products | none, loaded via a link |

How the registration form appears is then up to your design. Possible options are a redirect to a dedicated shop page, a pop-up or layer, or a Bootstrap modal. The technical integration is the same in all three cases.

## Step 1: Activate the service

In the shop configuration `shop.config`, set the `Allow` parameter to `yes` in the `<OrderNowMail>` section. If the section is missing, create it. It will later also contain the settings for the notification email.

```ini theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<OrderNowMail>
   Allow             = yes
   ...
</OrderNowMail>
```

Reference: Section OrderNowMail&#x20;

## Step 2: Set a minimum stock level (optional)

Without this specification, the shop sends the notification as soon as a single unit is available. With multiple registered buyers, the product is then immediately out of stock again. With a minimum stock level, you delay sending until enough goods are available.

To do this, add the `OrderableMailStockLimit-Value` parameter to the `<Inventory>` section in the `shop.config`.

```ini theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<Inventory>
   OrderableMailStockLimit-Value      = 10
   ...
</Inventory>
```

Reference: Section Inventory&#x20;

## Step 3: Configure the email

Subject, sender, and the template to be used are also in the `<OrderNowMail>` section.

```ini theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<OrderNowMail>
   ....
   Subject-Txt       = Ihr Produkt ist wieder verfügbar.
   SenderAddress     = email@ihr-shop.de
   SenderName        = Ihr Shop
   Template          = mail_backinstock.htm
   ...
</OrderNowMail>
```

> [!WARNING]
>
> `SenderAddress` and `Subject-Txt` are mandatory. If either is missing or empty, the shop aborts sending and writes an error to the log. The buyer then does not receive an email, without this being visible in the shop.

Reference: Section OrderNowMail&#x20;

## Step 4: Create the email template

Create a template under exactly the name that appears after `Template` in the `<OrderNowMail>` section, and save it in the template directory of the respective sub-shop, for example under `benutzer/templates/<Subshop>/`.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<body>
   ...
   {A-CompleteSalutation}
   ~A-CompleteSalutation~,
   {/A-CompleteSalutation}

   {!A-CompleteSalutation}
   Sehr geehrte Damen und Herren,
   {/!A-CompleteSalutation}
   das Produkt "~PR-Name~" (Produktnummer: ~PR-Number~) steht wieder zur Verfügung und kann bestellt werden.
   Bitte klicken Sie <a href="~PR-DeepLink~">hier</a>
   ...
</body>
```

The mail is always sent as an HTML mail. You do not need to add anything for this, the shop marks the content accordingly itself.

### Which tags are allowed

The content of automatically generated emails depends on which feature they originate from. The BackInStockMail comes from the OrderNow module, so exactly the data that this module supplies when sending is available. Other tags remain unreplaced in the text.

| Tag | Content |
| - | - |
| `A-CompleteSalutation` | full salutation, for example "Sehr geehrte Frau Musterfrau" |
| `A-Salutation` | only the salutation, for example "Frau" |
| `A-FirstName` | first name |
| `A-LastName` | last name |
| `A-Email`, `A-E-Mail` | email address, both spellings are equivalent |
| `PR-Name` | product name |
| `PR-Number` | product number |
| `PR-DeepLink` | link directly to the product, in the case of dependent variants to the specific combination |
| `URL-Template` | base URL of the template directory, for image and CSS paths in the mail |

> [!NOTE]
>
> The same tags are also replaced in the subject. `Subject-Txt = ~PR-Name~ ist wieder verfügbar` is therefore possible.

### Adding your own parameters to the deep link

If you want to append your own parameters to `~PR-DeepLink~`, first add the optional parameters `Referer` and `SubReferer` in the `<OrderNowMail>` section.

```ini theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<OrderNowMail>
   ...
   Referer           = backinstock
   SubReferer        = mail
   ...
</OrderNowMail>
```

From these, the shop appends `ref=` and `subref=` to the link. This guarantees that the link ends on a parameter, and you can attach further ones in the form `&parameter=value`.

> [!NOTE]
>
> `SubReferer` only takes effect if `Referer` is also filled. If `Referer` is empty, the link remains unchanged.

Materials: URL parameters&#x20;

## Step 5: Add the button to the product detail view

Using the `PR-InventoryState()` bracket, you control at which availability status the registration is offered. In the following example, the registration link appears at "red not orderable" (red-hard), and the regular shopping cart button in all other cases.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{PR-Inventory}

   {!PR-InventoryState(red-hard)}
      <input type="text" name="~PR-Quantity_input~" value="~PR-Quantity~">
      <input type="submit" value="In den Warenkorb" onclick="return ws_AJAXaddToBasket('productform', '~BT-ProductAddToBasket_Ajax~', '~WS-Charset~')">
   {/!PR-InventoryState(red-hard)}

   {PR-InventoryState(red-hard)}
      Sie haben Interesse an diesem Produkt? Wir informieren Sie gerne unverbindlich via E-Mail, sobald es wieder verfügbar ist.
      Wenn Sie diesen Service nutzen möchten, <a href="~PR-InventoryRegisterLink~">bitte hier klicken.</a>
   {/PR-InventoryState(red-hard)}

{/PR-Inventory}
```

`~PR-InventoryRegisterLink~` leads to the registration template from Step 7 and passes along the product.

## Step 6: Assign the templates in the shop configuration

Two templates are assigned in the `<Templates>` section of the `shop.config`: one for the collection of the contact data, one for the confirmation.

```ini theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<Templates>
   ...
   InventoryRegister                = ws_inventory_register.htm
   InventoryRegisterConfirm         = ws_inventory_register_confirm.htm
   ...
</Templates>
```

Reference: Section Templates&#x20;

## Step 7: Collect the contact data

Create the template under the name that appears after `InventoryRegister`.

The only mandatory field is the email address, because only it is needed for sending. All other fields are optional in accordance with the EU General Data Protection Regulation.

If the buyer is logged in and has thereby consented to the use of their data, the other fields are already pre-filled. If they subsequently register for another product, all fields are filled and they do not have to enter anything again.

You can additionally include product information. In the following example, product name and price appear above the form.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<form action="~FORM-InventoryRegister~" method="post">

   ~MSG-InventoryRegister_Notify~

   {PR-Data}
      Produktname: ~PR-Name~
      Preis: ~PR-Price~ ~WS-CurrencySymbol~
   {/PR-Data}

   Anrede :   ~IR-SalutationList~
   Vorname :   <input type="text" size="30" maxlength="128" name="~IR-FirstName_input~" value="~IR-FirstName~">
   Nachname :   <input type="text" size="30" maxlength="128" name="~IR-LastName_input~" value="~IR-LastName~">
   E-Mail *:   <input type="text" size="30" maxlength="128" name="~IR-Email_input~" value="~IR-Email~">

   <input type="submit" value="absenden">

</form>
```

`~MSG-InventoryRegister_Notify~` outputs the shop's messages, for example when the email address is missing or invalid. Without this tag, a rejected registration remains inexplicable to the buyer.

The `IR-` tags come in pairs: `~IR-Fieldname_input~` provides the field name for the form, `~IR-Fieldname~` the value already entered.

## Step 8: Confirm the registration

Create the template under the name that appears after `InventoryRegisterConfirm`. No special tags are needed here, a confirming text is enough.

```text theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
Vielen Dank für Ihr Interesse an unserem Produkt.
Wir haben Ihre Anmeldung erhalten und werden Sie sofort per E-Mail informieren,
wenn Ihr gewünschtes Produkt wieder in unserem Onlineshop verfügbar ist.
```

## Step 9: Test the notification email

The test runs in two stages, because the display and the tag replacement are checked separately.

### Check the display

Open the email template in the browser to see whether the CSS rules take effect. To do this, append the `tpl` parameter with the template name to a sample product.

```text theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
https://www.<ihre-domain>.de/<Beispielprodukt>?tpl=mail_backinstock.htm
```

> [!NOTE]
>
> This call only shows the view. The tags are not replaced, and the link to the product cannot be clicked.

### Check the function

Create a test product with the stock level for which you have integrated the service. Call it up, fill in the form, and then set the stock level to "green". You will then receive the notification at the specified address, with replaced tags and an active product link.

## Show registered products in the shop

Optionally, you show the buyer a list of the products for which they have registered, along with the option to unsubscribe from individual notifications.

### Create the overview template

Create a template with any name, for example `ws_inventory_register_overview.htm`. An assignment in the `shop.config` is not necessary, the template is loaded via a link.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
<h1>Benachrichtigung für ausverkaufte Produkte</h1>
<p>Hier finden Sie eine Übersicht der ausverkauften Produkte, bei denen Sie sich für eine Benachrichtigung angemeldet haben,
   wenn sie wieder verfügbar sind.</p>
<p>Möchten Sie diese Information für ein Produkt nicht mehr erhalten, dann können Sie die Benachrichtigung hier deaktivieren.</p>

{CAT-AdvData($InventoryRegister,999)}
   ~DC-FPAdvData_set(ProductsAvailable)~
   {@PR-Data}
      ~PR-Name~
      ...
      {PR-SetParent}
         {CAT-AdvData($SetProducts,999)}
            {@PR-Data}
               ~PR-Name~<br>
               ...
            {/@PR-Data}
         {/CAT-AdvData($SetProducts,999)}
      {/PR-SetParent}
      <a href="~PR-DeleteIRListEntry(ws_inventory_register_overview.htm)~">Produkt löschen</a><br>
      <hr>
   {/@PR-Data}
{/CAT-AdvData($InventoryRegister,999)}

{!DC-FPAdvData(ProductsAvailable)}
   Derzeit haben Sie keine Benachrichtigungen für ausverkaufte Produkte aktiviert.
{/!DC-FPAdvData(ProductsAvailable)}
```

Three places in the example deserve an explanation:

* `{CAT-AdvData($InventoryRegister,999)}` returns the registrations as a product list, here up to 999 entries. The `{@PR-Data}` loop iterates through them.
* The free parameter `DC-FPAdvData` remembers that the list had entries. Only in this way can a text be output below the list when it was empty, since the bracket itself is already closed at this point.
* `~PR-DeleteIRListEntry(...)~` generates the unsubscribe link. As a parameter you specify the template to which the shop returns after deletion, in this case the overview itself.

The `{PR-SetParent}` block is only needed for set products. It lists the contained sub-products.

### Add a link to the overview

The obvious choice is the customer account `ws_user_account.htm`. Since a buyer does not have to be logged in to register, however, you can place the link anywhere.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
...
{CAT-AdvData($InventoryRegister,999)}
   <a href="~WS-LoadTpl(ws_inventory_register_overview.htm)~">Benachrichtigungen für ausverkaufte Produkte</a>
{/CAT-AdvData($InventoryRegister,999)}
...
```

The bracket ensures that the link only appears when registrations actually exist.

Finally, check both: the sending of the BackInStockMail and the display of the registered products.

## Related topics

* Guide: Displaying stock levels
* Guide: Displaying dependent variants


## Related topics

- [Email notifications: overview](https://dokumentation.websale.de/en/v8s/e-mails/e-mail-benachrichtigungen-ueberblick.md)
- [IR- (BackInStockMail)](https://dokumentation.websale.de/en/v8s/referenz/tags/ir-backinstockmail.md)
- [Emails](https://dokumentation.websale.de/en/v8s/referenz/konfigurationen/shopkonfiguration-shop-config/e-mails.md)
- [Products, catalog, and search](https://dokumentation.websale.de/en/v8s/referenz/konfigurationen/shopkonfiguration-shop-config/produkte-katalog-und-suche.md)
- [Use cases](https://dokumentation.websale.de/en/v8s/anwendungsbeispiele/anwendungsbeispiele.md)


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