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

# E-SUBS- (Subscription module)

> Design the four emails of the subscription module: announcement to the buyer, overview for the merchant, error message and notification about disabled subscriptions.

The subscription module sends four emails: two announcements before the next subscription order and two error messages to the merchant. The tags with the prefix `E-SUBS_` apply exclusively in the templates of these emails.

You enter all four in the shop configuration `shop.config` in the `Subscription` section, each in its own subsection.

| Subsection | Goes to | Occasion |
| - | - | - |
| `SubscriberNotificationMail` | the buyer | the next subscription order is due |
| `MerchantNotificationMail` | the merchant | overview of the upcoming subscription orders |
| `OrderErrorMail` | the merchant | a subscription order could not be created |
| `DisabledNotificationMail` | the merchant | the second attempt has failed as well |

Guide: Subscription module · Reference: Subscription section · Materials: Subscription module materials

> [!NOTE]
>
> Subscription management in the customer account is a different matter. It works with the tags of the prefix `SUBS-`, not with the `E-SUBS_` tags on this page.

> [!WARNING]
>
> The parameter `Days` in the two announcement emails determines how many days before the order the email is sent. With a short delivery interval, too long a lead time can cause the announcement to arrive before the previous delivery.

## The loop over the subscriptions

Two loops are available. Which one fits depends on who receives the email.

| Tag | Runs over |
| - | - |
| `E-SUBS_Data` | all affected subscriptions individually |
| `E-SUBS_DataByProduct` | the same subscriptions, grouped by product |

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{@E-SUBS_Data}
   <tr>
      <td>~E-SUBS_Data_PR_Name~</td>
      <td>~E-SUBS_Data_PR_Quantity~</td>
      <td>~E-SUBS_Data_PR_Price~ ~E-SUBS_Data_PR_CurrencyCode~</td>
      <td>~E-SUBS_Data_nextorder~</td>
   </tr>
{/@E-SUBS_Data}
```

> [!NOTE]
>
> Grouping by product is intended for the merchant announcement. The merchant wants to know how much of which item is going out soon, not which customer ordered what. The buyer, on the other hand, gets their own subscriptions listed individually.

> [!WARNING]
>
> The two loops cannot be nested inside each other. If `{@E-SUBS_DataByProduct}` is placed inside `{@E-SUBS_Data}`, the inner area stays empty. Choose one of the two for each email.

> [!NOTE]
>
> `E-SUBS_DataByProduct` can also be used as an area tag. The area applies if there are any grouped subscriptions at all, and keeps the table header and heading out of an otherwise empty email.

## The subscription details

All of the following tags are placed inside the loop and refer to the subscription currently being iterated.

| Tag | Returns |
| - | - |
| `E-SUBS_Data_Index` | the technical index of the subscription |
| `E-SUBS_DATA_UserIndex` | the technical index of the customer account |
| `E-SUBS_Data_PR_Index` | the product index |
| `E-SUBS_Data_PR_Number` | the product number |
| `E-SUBS_Data_PR_Name` | the product name |
| `E-SUBS_Data_PR_Price` | the price |
| `E-SUBS_Data_PR_CurrencyCode` | the currency code |
| `E-SUBS_Data_PR_Quantity` | the subscribed quantity |
| `E-SUBS_Data_PR_quantitydecimal` | the number of decimal places of the quantity |

> [!WARNING]
>
> These tags are **single tags only**. The old documentation also lists most of them as area tags and shows examples following the pattern `{E-SUBS_Data_PR_Name}…{/E-SUBS_Data_PR_Name}`. This bracketing does not work; the tag remains unresolved in the email. Do not check for empty values in the template; instead, rely on the details of an existing subscription being present.

> [!NOTE]
>
> Product name and price reflect the state of the last order or the last change to the subscription, not today's catalogue price. In the announcement to the buyer, this is the more honest information because it shows what was last charged. Point out in the text that the price may change before delivery.

> [!NOTE]
>
> `E-SUBS_Data_PR_quantitydecimal` is not in the old documentation. The tag outputs the number of decimal places with which the quantity is managed, which is necessary for items sold by weight or length.

## Points in time

| Tag | Returns |
| - | - |
| `E-SUBS_Data_Created` | the time at which the subscription was taken out |
| `E-SUBS_Data_LastChange` | the time of the last change |
| `E-SUBS_Data_lastorder` | the time of the last subscription order |
| `E-SUBS_Data_nextorder` | the time of the next subscription order |

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{@E-SUBS_Data}
   <p>
      Ihr Abo für ~E-SUBS_Data_PR_Name~ läuft seit ~E-SUBS_Data_Created~.
      Die nächste Lieferung ist für ~E-SUBS_Data_nextorder~ vorgesehen.
   </p>
{/@E-SUBS_Data}
```

> [!WARNING]
>
> With `E-SUBS_Data_nextorder`, only the date part is meaningful. The time in it results from the batch run and says nothing about the time of delivery. Therefore, only output the date to the buyer.

> [!NOTE]
>
> All four points in time come as timestamps. For readable output, format them in the template, for example with the date formatting tags.

## The state of a subscription

| Tag | Applies if the subscription |
| - | - |
| `E-SUBS_Data_state_isactive` | is active |
| `E-SUBS_Data_state_isnew` | is new on the list |
| `E-SUBS_Data_state_ispaused` | is paused |
| `E-SUBS_Data_state_istriggered` | is new and the order has already been triggered |
| `E-SUBS_Data_state_code` | (single tag) the state as a number |

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{@E-SUBS_Data}
   ~E-SUBS_Data_PR_Name~

   {E-SUBS_Data_state_ispaused}
      <span class="hinweis">pausiert, es wird nichts geliefert</span>
   {/E-SUBS_Data_state_ispaused}

   {E-SUBS_Data_state_isnew}
      <span class="hinweis">neu abgeschlossen</span>
   {/E-SUBS_Data_state_isnew}

   {E-SUBS_Data_state_isactive}
      nächste Lieferung am ~E-SUBS_Data_nextorder~
   {/E-SUBS_Data_state_isactive}
{/@E-SUBS_Data}
```

> [!WARNING]
>
> The four states are mutually exclusive. A subscription is either active, new, paused or triggered, never two at once. A chain of positive area tags therefore covers all cases; nesting is not necessary.

> [!WARNING]
>
> For `E-SUBS_Data_state_code`, the old documentation lists the values 0 for "not affected", 1 for "changed", 2 for "paused" and 3 for "resumed". This list does not belong to this tag but describes the change types of subscription management. The numeric value here corresponds to the four states listed above. Use the four `state_is…` area tags, which are unambiguous, and do not rely on the numeric value.

## Checking whether a product is subscribed

| Tag | Applies if |
| - | - |
| `E-SUBS_ProdIndexOnSubscription()` | a subscription exists for the product with this product index |
| `E-SUBS_ProdNumberOnSubscription()` | a subscription exists for the product with this product number |

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{E-SUBS_ProdNumberOnSubscription(12345)}
   <p>Für diesen Artikel haben wir ein Abo für Sie hinterlegt.</p>
{/E-SUBS_ProdNumberOnSubscription(12345)}
```

> [!NOTE]
>
> Both tags check the entire subscription list, not just the subscription currently being iterated. They are therefore placed outside the loop and are suitable for addressing a specific product in an email.

## The two error emails

| Tag | Returns |
| - | - |
| `E-SUBS_ErrorMsg` | the error message of the XML order generator |
| `E-SUBS_ErrorCode` | the associated error code |

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{E-SUBS_ErrorMsg}
   <p>Fehler: ~E-SUBS_ErrorMsg~ (Code ~E-SUBS_ErrorCode~)</p>
{/E-SUBS_ErrorMsg}

<table>
   {@E-SUBS_Data}
      <tr>
         <td>~E-SUBS_DATA_UserIndex~</td>
         <td>~E-SUBS_Data_PR_Number~</td>
         <td>~E-SUBS_Data_PR_Name~</td>
      </tr>
   {/@E-SUBS_Data}
</table>
```

> [!NOTE]
>
> `E-SUBS_ErrorCode` only applies in the template for `OrderErrorMail`. `E-SUBS_ErrorMsg` is available in all subscription templates.

> [!WARNING]
>
> Both error emails go to the merchant and name the customer account and product. Send them to an internal address and not to a mailbox that third parties can view.

> [!WARNING]
>
> The notification about permanently disabled subscriptions is only sent if a secret for deeplink emails is configured for the shop. If it is missing, nothing is sent and only an entry appears in the log. The same applies if the recipient address, sender address, subject or template is missing, or if the template is empty.

## The tags at a glance

| Tag | Single tag | Area tag | Negative area tag | Loop tag |
| - | - | - | - | - |
| `E-SUBS_Data` | – | – | – | yes |
| `E-SUBS_DataByProduct` | – | yes | yes | yes |
| `E-SUBS_Data_Index` | yes | – | – | – |
| `E-SUBS_DATA_UserIndex` | yes | – | – | – |
| `E-SUBS_Data_PR_Index` | yes | – | – | – |
| `E-SUBS_Data_PR_Number` | yes | – | – | – |
| `E-SUBS_Data_PR_Name` | yes | – | – | – |
| `E-SUBS_Data_PR_Price` | yes | – | – | – |
| `E-SUBS_Data_PR_CurrencyCode` | yes | – | – | – |
| `E-SUBS_Data_PR_Quantity` | yes | – | – | – |
| `E-SUBS_Data_PR_quantitydecimal` | yes | – | – | – |
| `E-SUBS_Data_Created` | yes | – | – | – |
| `E-SUBS_Data_LastChange` | yes | – | – | – |
| `E-SUBS_Data_lastorder` | yes | – | – | – |
| `E-SUBS_Data_nextorder` | yes | – | – | – |
| `E-SUBS_Data_state_code` | yes | – | – | – |
| `E-SUBS_Data_state_isactive` | – | yes | yes | – |
| `E-SUBS_Data_state_isnew` | – | yes | yes | – |
| `E-SUBS_Data_state_ispaused` | – | yes | yes | – |
| `E-SUBS_Data_state_istriggered` | – | yes | yes | – |
| `E-SUBS_ProdIndexOnSubscription()` | – | yes | yes | – |
| `E-SUBS_ProdNumberOnSubscription()` | – | yes | yes | – |
| `E-SUBS_ErrorMsg` | yes | yes | yes | – |
| `E-SUBS_ErrorCode` | yes | yes | yes | – |

All tags on this page are permitted in the four email templates of the subscription module. The `Data_` tags each within one of the two loops, `E-SUBS_ErrorCode` only in the template for `OrderErrorMail`.

## Related topics

* Guide: Subscription module
* Reference: Subscription section
* Reference: SUBS- (subscription management in the customer account)
* Materials: Subscription module materials


## Related topics

- [SUBS- (managing subscriptions)](https://dokumentation.websale.de/en/v8s/referenz/tags/subs/abos-verwalten.md)
- [SUBS- (taking out a subscription)](https://dokumentation.websale.de/en/v8s/referenz/tags/subs/abo-abschliessen.md)
- [Materials: subscription module](https://dokumentation.websale.de/en/v8s/materialien/materialien-abo-modul.md)
- [Special online services](https://dokumentation.websale.de/en/v8s/online-servicebereich/spezielle-online-dienste.md)
- [Shopping basket and order process](https://dokumentation.websale.de/en/v8s/referenz/konfigurationen/shopkonfiguration-shop-config/warenkorb-und-bestellprozess.md)


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