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

# $wsNewsletter - Newsletter

> Reference for $wsNewsletter: build subscription forms, load target groups and add newsletter management to the WEBSALE customer account area.

With the `$wsNewsletter` module, you can access newsletter functions. Typical use cases are subscription forms with target group selection, newsletter management in the customer account, or unsubscribe links in emails. In this section, you will learn how to load target groups and create newsletter forms.

***

## Module overview

**Example / excerpt of** `$wsNewsletter`

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

**JSON output**

```json theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{
  "getTargetGroups": "ƒ()"
}
```

Note: `ƒ()` denotes a function.

**Methods overview**

| **Method**          | **Return type** | **Description**                               |
| ------------------- | --------------- | --------------------------------------------- |
| `getTargetGroups()` | array           | Loads the available newsletter target groups. |

***

## Templates

Newsletter forms are typically used in the following places:

* Footer: compact subscription form with email field.
* Custom page: detailed form with target group selection and additional fields.
* Customer account: management of newsletter subscriptions.

***

## Variables

No variables are available for `$wsNewsletter`.

***

## Methods

### \$wsNewsletter.getTargetGroups()

Loads the available newsletter target groups.

**Signature**\
`$wsNewsletter.getTargetGroups()`

**Return value**\
`array` - List of available target groups.

**Example** that loads all target groups.

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ var $myTargetGroups = $wsNewsletter.getTargetGroups() }}
{{ foreach $targetGroup in $myTargetGroups }}
    {{= $targetGroup.name }} - {{= $targetGroup.id }}
{{ /foreach }}
```

***

## Actions

No actions are available for `$wsNewsletter`.

***

## Examples

### Subscription form with target group selection

```html theme={"theme":{"light":"github-light","dark":"github-dark"},"languages":{"custom":["/languages/websale.json"]}}
{{ var $targetGroups = $wsNewsletter.getTargetGroups() }}

{{ if $targetGroups }}
  <p>Select newsletter:</p>
  {{ foreach $group in $targetGroups }}
    <label>
      <input type="checkbox" name="targetGroupId" value="{{= $group.id }}">
      {{= $group.name }}
    </label>
  {{ /foreach }}
{{ /if }}
```

***

## Related links

* [newsletter - Newsletter](/en/konfiguration/newsletter-newsletter)
* [actions - Newsletter](/en/konfiguration/actions-fehlertexte-e-mails/actions-newsletter)
