22

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}} 
{{else} 
  {{var customer.name}} 
{{/if}}

Example from link

Depend Condition

{{depend order.getIsNotVirtual()}}

{{/depend}}

{{depend salable}}

{{/depend}}

- If Condition

{{if order.getIsNotVirtual()}}

{{else}}

{{/if}}

(else is optional)
42

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 at 15:40
  • @snh_nl Yes! I Found! – Diego Queiroz Jan 24 at 16:00
  • 1
    Can you share the link? – snh_nl Jan 24 at 17:38
  • @DiegoQueiroz please share a link if you still have it.. I really need solution of this problem.. – Mansi Raja Apr 10 at 7:36

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.