we are investigating some checks in our transactional emails or newsletters and looking at http://merch.docs.magento.com/ce/user_guide/store-operations/email-transactional.html

where we find the code below.

My question: can we use this DEPEND or IF to check the existence or emptiness of a variable? Something like

{{if customer.getFirstname()}} 
  {{var customer.firstname}} 
  {{var customer.name}} 

Example from link

Depend Condition

{{depend order.getIsNotVirtual()}}


{{depend salable}}


- If Condition

{{if order.getIsNotVirtual()}}



(else is optional)

This is exactly the purpose of {{depend}} and {{if}}. The only difference between them is that {{if}} supports an {{else}} statement.
{{depend}} is just as an {{if}} without an {{else}}.
To see how they work refer to Varien_Filter_Template::dependDirective() and Varien_Filter_Template::ifDirective().

  • 2
    and if I want to compare with a string like {{order.getStatus() == 'pending_payment'}} ? – Diego Queiroz Jul 24 '18 at 19:49
  • @DiegoQueiroz Did you find your answer? – snh_nl Jan 18 '19 at 15:40
  • @snh_nl Yes! I Found! – Diego Queiroz Jan 24 '19 at 16:00
  • 1
    Can you share the link? – snh_nl Jan 24 '19 at 17:38
  • 1
    To the people asking the link from Diego, it's not possible to use ==. Here you can find an alternative and more information -> magento.stackexchange.com/questions/161041/… – Sanne Apr 25 '19 at 12:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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