Skip to main content
replaced http://magento.stackexchange.com/ with https://magento.stackexchange.com/
Source Link

You cannot use logical expressions in depend (unfortunately neither in if as one comment suggested)

  • {{depend X}}...{{/depend}} output content in between only if variable X is true-ish (note that you cannot use logical expressions here, just variables or methods on variables.

From this answer, which covers more details of template directives: http://magento.stackexchange.com/a/121510/243https://magento.stackexchange.com/a/121510/243

So the only way I see to achieve what you are trying is to add three variables. For example:

in PHP code (probably best in an load_after observer):

$order->setData('delivery_time_1', $order->getDeliveryTime() == '1');
$order->setData('delivery_time_2', $order->getDeliveryTime() == '2');
$order->setData('delivery_time_3', $order->getDeliveryTime() == '3');

then in the email template:

{{depend order.delivery_time_1}}

Delivery Time: 10am To 2pm

{{/depend}}
{{depend order.delivery_time_2}}

Delivery Time: 2pm To 7pm

{{/depend}}
{{depend order.delivery_time_3}}

Delivery Time: 7pm To 10pm

{{/depend}}

You cannot use logical expressions in depend (unfortunately neither in if as one comment suggested)

  • {{depend X}}...{{/depend}} output content in between only if variable X is true-ish (note that you cannot use logical expressions here, just variables or methods on variables.

From this answer, which covers more details of template directives: http://magento.stackexchange.com/a/121510/243

So the only way I see to achieve what you are trying is to add three variables. For example:

in PHP code (probably best in an load_after observer):

$order->setData('delivery_time_1', $order->getDeliveryTime() == '1');
$order->setData('delivery_time_2', $order->getDeliveryTime() == '2');
$order->setData('delivery_time_3', $order->getDeliveryTime() == '3');

then in the email template:

{{depend order.delivery_time_1}}

Delivery Time: 10am To 2pm

{{/depend}}
{{depend order.delivery_time_2}}

Delivery Time: 2pm To 7pm

{{/depend}}
{{depend order.delivery_time_3}}

Delivery Time: 7pm To 10pm

{{/depend}}

You cannot use logical expressions in depend (unfortunately neither in if as one comment suggested)

  • {{depend X}}...{{/depend}} output content in between only if variable X is true-ish (note that you cannot use logical expressions here, just variables or methods on variables.

From this answer, which covers more details of template directives: https://magento.stackexchange.com/a/121510/243

So the only way I see to achieve what you are trying is to add three variables. For example:

in PHP code (probably best in an load_after observer):

$order->setData('delivery_time_1', $order->getDeliveryTime() == '1');
$order->setData('delivery_time_2', $order->getDeliveryTime() == '2');
$order->setData('delivery_time_3', $order->getDeliveryTime() == '3');

then in the email template:

{{depend order.delivery_time_1}}

Delivery Time: 10am To 2pm

{{/depend}}
{{depend order.delivery_time_2}}

Delivery Time: 2pm To 7pm

{{/depend}}
{{depend order.delivery_time_3}}

Delivery Time: 7pm To 10pm

{{/depend}}
Source Link
Fabian Schmengler
  • 66.1k
  • 25
  • 188
  • 422

You cannot use logical expressions in depend (unfortunately neither in if as one comment suggested)

  • {{depend X}}...{{/depend}} output content in between only if variable X is true-ish (note that you cannot use logical expressions here, just variables or methods on variables.

From this answer, which covers more details of template directives: http://magento.stackexchange.com/a/121510/243

So the only way I see to achieve what you are trying is to add three variables. For example:

in PHP code (probably best in an load_after observer):

$order->setData('delivery_time_1', $order->getDeliveryTime() == '1');
$order->setData('delivery_time_2', $order->getDeliveryTime() == '2');
$order->setData('delivery_time_3', $order->getDeliveryTime() == '3');

then in the email template:

{{depend order.delivery_time_1}}

Delivery Time: 10am To 2pm

{{/depend}}
{{depend order.delivery_time_2}}

Delivery Time: 2pm To 7pm

{{/depend}}
{{depend order.delivery_time_3}}

Delivery Time: 7pm To 10pm

{{/depend}}