# 6. Price-Drop Notifications

The plugin can automatically send customers email notifications when products on their wishlists drop in price. Two things are required:

1. The feature is **globally enabled** in the plugin settings (active by default).
2. A **Flow Builder** flow is set up to send the email.

## How Price Tracking Works

When a customer adds a product to a wishlist, the plugin automatically saves the current gross unit price and currency ID. This stored price serves as the reference for future comparisons.

A **scheduled background task** periodically checks all wishlist items for price changes. When the current price drops below the stored reference price (minus the configured threshold), a Flow Builder event is dispatched.

> **Note:** The Scheduled Task Worker must be running. Without it, no checks are performed and no notifications are sent.

## Configuring the Threshold

In the [plugin settings](https://docs.momocode.de/en/shopware-6/advanced-wishlists/3.-configuration) under **Price Drop Notifications**, you can configure:

* **Threshold type** — `Percentage` or `Absolute value`
* **Minimum price drop threshold** — e.g. `5` for 5 % or €5

Only price drops that exceed the threshold trigger a notification. This filters out micro-fluctuations (e.g. from rounded currency conversions).

## Setting Up the Flow Builder

The plugin provides the **"Wishlist Price Drop"** event (technically: `momo_advanced_wishlists.price_drop`) for the Flow Builder.

### Step 1: Create a flow

1. Go to **Marketing → Flow Builder**.
2. Click **Create flow**.
3. Give the flow a descriptive name (e.g. "Price drop notification").

### Step 2: Select the trigger

1. Click **Add trigger**.
2. Search for **Wishlist Price Drop** or scroll to the Wishlist category.
3. Select the event.

### Step 3: Add an action

1. Click **Add action**.
2. Select **Send email**.
3. Choose a recipient — for customer notifications: **Customer (Wishlist)**.
4. Select an email template or create a new one. The plugin automatically creates the **"Wishlist Price Drop Notification"** template during installation — you can select and use it right away.

### Step 4: Design the email template

The following variables from the price-drop event are available in the email template:

| Variable                | Content                                          |
| ----------------------- | ------------------------------------------------ |
| `{{ customer }}`        | Customer object (firstName, lastName, email, id) |
| `{{ priceDropItems }}`  | Array of affected items (see below)              |
| `{{ currencyIsoCode }}` | Currency code (e.g. `EUR`)                       |

Each element in `priceDropItems` contains:

| Key                 | Content                              |
| ------------------- | ------------------------------------ |
| `productName`       | Product name                         |
| `productId`         | Product ID                           |
| `oldPrice`          | Original price (float)               |
| `newPrice`          | Current price (float)                |
| `savingsAmount`     | Savings amount (absolute, float)     |
| `savingsPercentage` | Savings percentage (float)           |
| `productUrl`        | URL to the product in the storefront |

**Example Twig for the email template:**

```twig
Hello {{ customer.firstName }},

the following products on your wishlists have dropped in price:

{% for item in priceDropItems %}
- {{ item.productName }}
  Was:  {{ item.oldPrice }} {{ currencyIsoCode }}
  Now:  {{ item.newPrice }} {{ currencyIsoCode }}
  You save: {{ item.savingsAmount }} {{ currencyIsoCode }} ({{ item.savingsPercentage }}%)
  View product: {{ item.productUrl }}
{% endfor %}

Best regards,
Your shop team
```

### Step 5: Activate the flow

Make sure the flow is set to **Active** before saving.

## Customer Opt-In

For a customer to receive notifications, they must **enable the feature per wishlist**:

1. Open the wishlist detail page in the storefront.
2. In the **Price-drop notifications** section, activate the toggle.

Customers can deactivate the toggle at any time. If the feature is globally disabled in the plugin settings, the toggle is hidden in the storefront.

## Frequently Asked Questions

**Are notifications sent for all price drops?** No. Only price drops that exceed the configured threshold trigger a notification.

**Is a notification sent each time the price drops further?** Yes — each check where the price is below the stored reference price dispatches an event. The reference price is not automatically updated.

**What happens if a product is removed from the catalogue?** Items for which no price can be resolved are skipped during the check. No notification and no error message is triggered.
