Magento – Magento 2 how to add if or else statement to email template

email-templatesmagento2template-directivetransactional-mail

I want to add an if or else statement to the invoice email template to check if the order shipping method is courier delivery order or self pick up order. How can I do this?

Best Answer

The conditonal syntax in email templates is the same as Magento 1.

Thus in your email template you can do stuff like this for example:

{{if logo_width}}
    width="{{var logo_width}}"
{{else}}
    width="200"
{{/if}}

You can find more information in the official documentation: http://devdocs.magento.com/guides/v2.0/frontend-dev-guide/templates/template-email.html

Related Topic