E-Mail Templates

Ausgabe von Bestellinformationen

Im Standard-Mailtemplate von Shopware werden bereits alle Bestellinformationen ausgegeben. Diese können nach belieben angepasst werden, sodass mehr oder weniger Informationen übermittelt werden.

Ausgabe von bestimmten Feld-Werten im Template

{% set breite = nestedItem.payload.options|filter(option => option.group == "Breite") %}
Ihre gewählte Breite: {{ breite.option|raw }}

Ausgabe von HTML-Code in Labels

Falls HTML-Code in Feld-Labels oder Werten genutzt wird, muss das Standard-Template angepasst werden:

Suchen nach:

{% for option in nestedItem.payload.options %}
   {{ option.group }}: {{ option.option }}
   {% if nestedItem.payload.options|last != option %}
     {{ " | " }}
   {% endif %}
{% endfor %}

Ersetzen durch:

{% for option in nestedItem.payload.options %}
   {{ option.group|raw }}: {{ option.option|raw }}
   {% if nestedItem.payload.options|last != option %}
     {{ " | " }}
   {% endif %}
{% endfor %}

Durch |raw wird der HTML-Code umgewandelt.

Um Links aus Dateiuploads direkt in Mailtemplates auszugeben ist folgender Code notwendig:

Suchen nach:

{% for option in nestedItem.payload.options %}
   {{ option.group }}: {{ option.option }}
   {% if nestedItem.payload.options|last != option %}
     {{ " | " }}
   {% endif %}
{% endfor %}

Ersetzen durch:

{% for option in nestedItem.payload.options %}
  {{ option.group }}: 
  {% if option.configurator is defined and option.configurator.field_type == 'upload' %}
   <a href='{{ option.configurator.user_value.fileUrl}}'
            target="_blank">{{ option.configurator.user_value.fileName }}</a>
  {% else %}
      {{ option.option }}
  {% endif %}
  {% if nestedItem.payload.options|last != option %}
    {{ " | " }}
  {% endif %}
{% endfor %}

Bis Version 1.10.0

Folgenden Code kannst du in deine Mail-Templates kopieren, um dort die Bestellinformationen auszugeben:

Diese Anpassung wird ab der Konfigurator-Version 1.11.0 nicht mehr benötigt, da der Konfigurator die Informationen in die von Shopware vorgesehenen Felder schreibt. Dennoch können zusätzliche Angaben mit diesen Template-Anpassungen ausgegeben werden. Siehe hier auch Wie wird die Konfiguration in einer Bestellung gespeichert?

Templates

HTML

{% if nestedItem.payload.neon_configurator is defined %}
    {% for userConfiguration in nestedItem.payload.neon_configurator.user_configuration %}
       <span>{{ userConfiguration.field_label }} ({{ userConfiguration.field_key }}):</span>
       <span>{{ userConfiguration.user_value_formatted }}</span>
       {% if nestedItem.payload.neon_configurator.user_configuration|last != userConfiguration %}
       {{ " | " }}
       {% endif %}
    {% endfor %}
{% endif %}

Plaintext-Mails

{% if lineItem.payload.neon_configurator is defined %}{% for userConfiguration in lineItem.payload.neon_configurator.user_configuration %}{{ userConfiguration.field_label }}: {{ userConfiguration.user_value_formatted }}{% if lineItem.payload.neon_configurator.user_configuration|last != userConfiguration %}{{ " | " }}{% endif %}{% endfor %}{% endif %}

Wo füge ich den Code ein?

Im Bestellbestätigungs-Template beispielsweise direkt nach dem Name der Bestellposition. Einfach nach folgendem Text suchen und den obigen Code danach einsetzen.

{{ nestedItem.label|u.wordwrap(80) }}<br>

So würde das Endergebnis bei der HTML-Mail aussehen:

...
{{ nestedItem.label|u.wordwrap(80) }}<br>
{% if nestedItem.payload.neon_configurator is defined %}
    <br>
    {% for userConfiguration in nestedItem.payload.neon_configurator.user_configuration %}
       <span>{{ userConfiguration.field_label }}:</span>
       <span>{{ userConfiguration.user_value_formatted }}</span>
       {% if nestedItem.payload.neon_configurator.user_configuration|last != userConfiguration %}
       {{ " | " }}
       {% endif %}
    {% endfor %}
{% endif %}
...

Last updated