How to customize email templates per channel?

Let’s assume you have two channels in your Sylius store: TOY_STORE and FASHION_WEB. You want to personalize email content depending on which channel the customer used to place an order. This guide shows how to achieve this in a maintainable and scalable way.

To verify and manage channels in your system, open the Channels grid in the Sylius admin panel. You’ll find each channel’s code, name, and hostname.

These codes are what you will use to differentiate content in your Twig templates.


1. Identify the Email Template to Override

Original template:

@SyliusCoreBundle/Email/orderConfirmation.html.twig

To override it, copy it to:

templates/bundles/SyliusCoreBundle/Email/orderConfirmation.html.twig

Twig paths like @SyliusCoreBundle/... point to the original bundle templates. To override them, create files under templates/bundles/..., following Symfony’s bundle override system.


2. Choose a Strategy

Depending on the number of channels and degree of customization, choose one of two strategies:

For 1–2 Channels with Small Differences

Use inline if conditions:

{# templates/bundles/SyliusCoreBundle/Email/orderConfirmation.html.twig #}

{% extends '@SyliusCore/Email/layout.html.twig' %}

{% block subject %}
    {% include '@SyliusCore/Email/Blocks/OrderConfirmation/_subject.html.twig' %}
{% endblock %}

{% block content %}
    {% if sylius.channel.code == 'TOY_STORE' %}
        Thanks for buying one of our toys!
    {% elseif sylius.channel.code == 'FASHION_WEB' %}
        Your new style is on the way!
    {% else %}
        Thanks for your purchase!
    {% endif %}

    Your order no. {{ order.number }} has been successfully placed.
{% endblock %}

For 3+ Channels or Maintainability

Use per-channel Twig includes with fallback:

Parent Template:

{# templates/bundles/SyliusCoreBundle/Email/orderConfirmation.html.twig #}

{% extends '@SyliusCore/Email/layout.html.twig' %}

{% block subject %}
    {% include '@SyliusCore/Email/Blocks/OrderConfirmation/_subject.html.twig' %}
{% endblock %}

{% block content %}
    {% include [
        'Email/OrderConfirmation/' ~ sylius.channel.code ~ '.html.twig',
        'Email/OrderConfirmation/_default.html.twig'
    ] %}
{% endblock %}

Example File Structure

templates/
β”œβ”€β”€ bundles/
β”‚   └── SyliusShopBundle/
β”‚       └── Email/
β”‚           └── orderConfirmation.html.twig
└── Email/
    └── OrderConfirmation/
        β”œβ”€β”€ TOY_STORE.html.twig
        β”œβ”€β”€ FASHION_WEB.html.twig
        └── _default.html.twig

Sample Channel Files

_default.html.twig

{# templates/Email/OrderConfirmation/_default.html.twig #}

Your order no. {{ order.number }} has been successfully placed.

TOY_STORE.html.twig

{# templates/Email/OrderConfirmation/TOY_STORE.html.twig #}

Thanks for buying one of our toys!

Your order with number {{ order.number }} is currently being processed.

FASHION_WEB.html.twig

{# templates/Email/OrderConfirmation/FASHION_WEB.html.twig #}

Your new style is on the way!

We’ve received your order no. {{ order.number }}.

3. Understand the Default Layout

By default, the core Sylius orderConfirmation.html.twig email looks like this:

{# SyliusCoreBundle/Resources/views/Email/orderConfirmation.html.twig #}

{% extends '@SyliusCore/Email/layout.html.twig' %}

{% block subject %}
    {% include '@SyliusCore/Email/Blocks/OrderConfirmation/_subject.html.twig' %}
{% endblock %}

{% block content %}
    {% include '@SyliusCore/Email/Blocks/OrderConfirmation/_content.html.twig' %}
{% endblock %}
  • _subject.html.twig: contains the translated subject line

  • _content.html.twig: includes layout, order number, and optional link


βœ… Result

Each email adapts to the right channel automatically. Developers can manage templates independently, and fallback logic ensures robustness.

You’ve now implemented clean, scalable multi-channel email templates in Sylius!

FASHION_WEB channel
TOY_STORE channel

Last updated

Was this helpful?