> For the complete documentation index, see [llms.txt](https://docs.yaycommerce.com/yaymail/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.yaycommerce.com/yaymail/visibility-control/conditional-template-variants.md).

# Conditional Template Variants

YayMail now lets you apply **conditional logic to entire email templates**, not just individual elements.

This makes it possible to create multiple designs for the same type of email and automatically send the right version based on specific conditions.

### From Conditional Elements to Conditional Templates

Previously, conditional logic could be used to show or hide individual elements within an email. For example, you could display a special message only when a customer had a certain role or when an order met a specific condition.

Now, you can take this further by applying conditions **at the template level**.

Instead of changing individual elements inside one design, you can create completely different email templates and let YayMail decide which one to send.

### Create Template Variants

With **Template Variants**, you can create alternative designs for the same email and assign different conditions to each one.

<figure><img src="https://157604815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJfBhHG_1ipE5lMX4qT%2Fuploads%2FyYtYqNScg2ZzkG6hN2xL%2Fimage.png?alt=media&amp;token=a8aee076-3f15-4531-b0bf-3dd1cbeab60a" alt=""><figcaption></figcaption></figure>

For example, you could create:

* **Standard Order Confirmation** for regular customers
* **VIP Order Confirmation** for customers with a VIP role
* **Wholesale Order Confirmation** for B2B customers
* **Special Order Confirmation** for orders above a certain value

When an email is triggered, YayMail evaluates the conditions and automatically sends the template variant that matches.

#### Example

Imagine you want different order confirmation emails for different customer types:

**Template A — Retail Customers**\
Condition: Customer role is `Customer`

<figure><img src="https://157604815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJfBhHG_1ipE5lMX4qT%2Fuploads%2FBJKiHZ6J6ym8SjcmWqQr%2Fimage.png?alt=media&amp;token=3174d4a3-6a99-483a-8bf3-70fbe00bdc70" alt=""><figcaption></figcaption></figure>

**Template B — Wholesale Customers**\
Condition: Customer role is `Wholesale Customer`

<figure><img src="https://157604815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJfBhHG_1ipE5lMX4qT%2Fuploads%2FEEgb1ZIiX3ZS4Rog3szO%2Fimage.png?alt=media&amp;token=b602701f-5a9b-4730-89ef-0ea3641d5f6e" alt=""><figcaption></figcaption></figure>

**Template C — VIP Customers**\
Condition: Customer role is `VIP`

<figure><img src="https://157604815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJfBhHG_1ipE5lMX4qT%2Fuploads%2FQRvogwOfVzShf3WTU1lT%2Fimage.png?alt=media&amp;token=28f45436-7d4b-4636-82d9-89e1249878f3" alt=""><figcaption></figcaption></figure>

When a customer places an order, YayMail checks the conditions and selects the appropriate template automatically.

Additionally, you can set each template variant to **Published** or **Draft**. This is especially useful for seasonal campaigns or limited-time promotions, once a campaign ends, you can simply switch the variant to Draft instead of deleting it, keeping it ready to reuse or update for future campaigns.

<figure><img src="https://157604815-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MJfBhHG_1ipE5lMX4qT%2Fuploads%2FZL9VGOSqXE2mblG1ea8Z%2Fimage.png?alt=media&amp;token=34299e8f-bea5-41aa-a4f6-b81e1c9370d3" alt=""><figcaption></figcaption></figure>

Happy customizing! 🪄
