根据购物车金额显示不同文字的IF语句
IF statement that shows a different text according to the shopping cart amount
我需要在我的购物车上制作一个 IF 语句脚本,它会根据购物篮中的数量显示不同的文本。目前我只有两个选择。 IF/ELSE。如何制作多个 IF 语句,这些语句会根据特定数量发生变化?
到目前为止我已经做了这个,它只适用于 below/beyond 1000:
{% assign totalCart = 0 %}
{% for item in cart.items %}
{% assign totalCart = totalCart | plus:item.totalCart_raw %}
{% endfor %}
{% comment %}
If the amount
{% endcomment %}
{% if totalCart >= 1000 %}
Volume Discount 20%
{%else%}
Volume Discount available 30%
{%endif%}
使用 if
+ elsif
的示例(基于问题中的代码)
{% assign totalCart = 0 %}
{% for item in cart.items %}
{% assign totalCart = totalCart | plus:item.totalCart_raw %}
{% endfor %}
{% comment %}
If the amount
{% endcomment %}
{% if totalCart < 1000 %}
Volume Discount 20% use this code
{% elsif totalCart < 2000 %}
Volume Discount available 30% use this code
{% elsif totalCart < 3000 %}
Volume Discount available 40% use this code
{% elsif totalCart < 4000 %}
Volume Discount available 50% use this code
{% elsif totalCart > 4000 %}
Volume Discount available 60% use this code
{% endif%}
我需要在我的购物车上制作一个 IF 语句脚本,它会根据购物篮中的数量显示不同的文本。目前我只有两个选择。 IF/ELSE。如何制作多个 IF 语句,这些语句会根据特定数量发生变化?
到目前为止我已经做了这个,它只适用于 below/beyond 1000:
{% assign totalCart = 0 %}
{% for item in cart.items %}
{% assign totalCart = totalCart | plus:item.totalCart_raw %}
{% endfor %}
{% comment %}
If the amount
{% endcomment %}
{% if totalCart >= 1000 %}
Volume Discount 20%
{%else%}
Volume Discount available 30%
{%endif%}
使用 if
+ elsif
的示例(基于问题中的代码)
{% assign totalCart = 0 %}
{% for item in cart.items %}
{% assign totalCart = totalCart | plus:item.totalCart_raw %}
{% endfor %}
{% comment %}
If the amount
{% endcomment %}
{% if totalCart < 1000 %}
Volume Discount 20% use this code
{% elsif totalCart < 2000 %}
Volume Discount available 30% use this code
{% elsif totalCart < 3000 %}
Volume Discount available 40% use this code
{% elsif totalCart < 4000 %}
Volume Discount available 50% use this code
{% elsif totalCart > 4000 %}
Volume Discount available 60% use this code
{% endif%}