Як оновити глобальну змінну зсередини оператора IF / ELSE або циклу FOR
Приклад сценарію (не працює):
{% set hasDiscount = FALSE %}
{% if userAttribute.vouchers %}
{% set hasDiscount = TRUE %}
{% endif %}
{{hasDiscount}} <---- still prints FALSE Вирішення проблеми:
{% set hasDiscount = [] %}
{% if userAttribute.vouchers %}
{% set temp = hasDiscount.append(TRUE) %}
{% endif %}
Printing all items from the hasDiscount list:
{% for item in hasDiscount %}
{{item}}
{% endfor %}
Or just printing the first item:
{{hasDiscount[0]}}Last updated