3

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?

2 Answers 2

7

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

1
  • 3
    How to check if logo_width > 250? Commented Nov 15, 2018 at 13:59
2

This is the same concept as magento 1,

Example:

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

{{if logo_height}}
    height="{{var logo_height}}"
{{else}}
    height="100"
{{/if}}

Above example just demo purpose Check the width and height attributes of the img tag to reflect the area in which you want your logo to display (for example, 200 × 100).

2
  • 3
    How to check if width> 250 ? Commented Nov 15, 2018 at 13:58
  • @jafarpinjar I don't think you can use if/else condition to check values. However, you can call a custom Block inside your email template and put your logic in the custom Block as suggested by: magento.stackexchange.com/questions/161041/… Commented Aug 19, 2019 at 6:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.