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

# SP- (reset password)

> Build the email for resetting the password: loop over all accounts for an address, make them distinguishable for the recipient and offer a separate link for each account.

If a buyer has forgotten their password, the shop sends them an email with a link they can use to set a new one. There is one special feature: several customer accounts can belong to a single email address. The recipient must then be able to tell which account is meant and receive a separate link for each one.

This is exactly what the `SP-` tags are for. They loop over all accounts for this address, describe each one and generate the matching link for each account.

Guide: Forgot password

> [!NOTE]
>
> All tags on this page apply exclusively in the HTML mail template of the "Forgot password" function. Which template is used is defined in the `SetPasswordMail` section of the shop configuration.

## How many accounts belong to the address

Three tags answer this question before getting into the details.

| Tag | Returns |
| - | - |
| `SP-Data` | as a single tag, the number of accounts; as a loop, the iteration over them |
| `SP-SingleData` | bracketing: there is exactly one account |
| `SP-SingleDataFromMultipleAccount` | bracketing: it concerns a single multiple account |

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{SP-SingleData}
   <p>Sie haben ein neues Passwort angefordert.</p>
{/SP-SingleData}

{!SP-SingleData}
   <p>Zu Ihrer E-Mail-Adresse gehören ~SP-Data~ Kundenkonten. Bitte wählen Sie das gewünschte aus.</p>
{/!SP-SingleData}
```

> [!NOTE]
>
> `SP-SingleData` applies if exactly one account is in the list. This is also the case when the buyer wants to reset the password for a single account from the overview of their multiple accounts. `SP-SingleDataFromMultipleAccount` distinguishes which of the two cases applies.

> [!NOTE]
>
> The previous documentation requires placing `SP-SingleDataFromMultipleAccount` within `SP-SingleData`. The shop system does not require this; the tag works anywhere in the mail template. Nesting still makes sense, though, because outside the single-account case it does not answer a meaningful question.

## The loop over the accounts

All details about a single account are within the `SP-Data` loop.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{@SP-Data}
   <p>
      {SP-Company}~SP-Company~<br>{/SP-Company}
      ~SP-FirstName~ ~SP-LastName~<br>
      {SP-CustomerID}Kundennummer ~SP-CustomerID~<br>{/SP-CustomerID}
      {SP-LastLogin}Letzte Anmeldung: ~SP-LastLogin~{/SP-LastLogin}
   </p>
   <p><a href="~SP-SetPasswordLink~">Für dieses Konto ein neues Passwort setzen</a></p>
{/@SP-Data}
```

> [!WARNING]
>
> The loop is required even in the single-account case. `SP-SetPasswordLink` and all account details are invalid tags outside the `SP-Data` loop, even within `SP-SingleData`. Therefore, write the account details once in the loop and control the surrounding text via `SP-SingleData`.

> [!NOTE]
>
> `SP-Data` exists only as a single tag and as a loop, not as a bracketing. For the case distinction, use `SP-SingleData`.

## The account details

| Tag | Returns |
| - | - |
| `SP-CustomerID` | the customer number |
| `SP-Company` | the company from the billing address |
| `SP-FirstName` | the first name from the billing address |
| `SP-LastName` | the last name from the billing address |
| `SP-LastLogin` | the time of the last login |
| `SP-SubAccountID` | the identifier of the sub-account |
| `SP-SetPasswordLink` | the link for resetting the password for this account |

> [!NOTE]
>
> All details except the link also work as a bracketing, namely when the value is filled. This is useful because company, customer number and last login are not available for every account.

> [!NOTE]
>
> `SP-SubAccountID` exists in the shop system but is not described in the previous documentation. With multiple accounts, this identifier is often the only feature by which the recipient can tell the accounts apart if name and company are the same.

> [!WARNING]
>
> The email goes to an address that may be used by several people. Therefore, only output as many details as are needed to tell the accounts apart. Customer number and sub-account identifier are usually sufficient; the last login is already information about the account holder's behaviour.

> [!NOTE]
>
> `SP-SetPasswordLink` is exclusively a single tag. Each iteration of the loop generates its own link that belongs to exactly this account.

Reference: MA- (multiple accounts)

## Distinguishing by subshop

In a shop network, a multiple account is not necessarily allowed to log in to every subshop. `SP-SubShopPermission()` checks this for each account.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{@SP-Data}
   {SP-SubShopPermission(fachhandel)}
      <p><a href="~SP-SetPasswordLink~">Konto ~SP-CustomerID~ im Fachhandelsbereich</a></p>
   {/SP-SubShopPermission(fachhandel)}
{/@SP-Data}
```

> [!WARNING]
>
> The tag requires exactly one parameter, namely a single subshop. An asterisk as a wildcard is rejected, as is an empty parameter or multiple values. In all three cases, the tag is invalid. The previous documentation does not state this.

> [!NOTE]
>
> `SP-SubShopPermission()` exists only as a bracketing and only within the `SP-Data` loop.

## Tags at a glance

| Tag | Single tag | Area tag | Negative area tag | Loop tag |
| - | - | - | - | - |
| `SP-Data` | yes | – | – | yes |
| `SP-SingleData` | – | yes | yes | – |
| `SP-SingleDataFromMultipleAccount` | – | yes | yes | – |
| `SP-SetPasswordLink` | yes | – | – | – |
| `SP-SubAccountID` | yes | yes | yes | – |
| `SP-CustomerID` | yes | yes | yes | – |
| `SP-Company` | yes | yes | yes | – |
| `SP-FirstName` | yes | yes | yes | – |
| `SP-LastName` | yes | yes | yes | – |
| `SP-LastLogin` | yes | yes | yes | – |
| `SP-SubShopPermission()` | – | yes | yes | – |

All tags apply exclusively in the mail template of the "Forgot password" function. `SP-Data`, `SP-SingleData` and `SP-SingleDataFromMultipleAccount` stand freely there, all others within the `SP-Data` loop. If there is no password reset process, all tags output nothing.

## Related topics

* Guide: Forgot password
* Guide: Login and registration
* Reference: MA- (multiple accounts)
* Reference: `SetPasswordMail` section in the shop configuration


## Related topics

- [actions - Sign-in & registration](https://dokumentation.websale.de/en/konfiguration/actions-fehlertexte-e-mails/actions-anmeldung-registrierung.md)
- [Account](https://dokumentation.websale.de/en/frontend/referenz/aktionen/account.md)
- [Storefront API Customer Account](https://dokumentation.websale.de/en/schnittstellen/storefront-api/storefront-api-kundenkonto.md)
- [API reference customer data](https://dokumentation.websale.de/en/schnittstellen/admin-interface-api/api-referenz-kundendaten.md)
- [$wsConfig - Configuration](https://dokumentation.websale.de/en/frontend/referenz/module/wsconfig.md)


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