IF语句,根据购物车金额显示不同的文本



我需要在购物车上创建一个IF语句脚本,它根据购物篮中的金额显示不同的文本。目前我只有两个选择。IF/ELSE。我如何使几个IF语句在一个特定的金额变化?

到目前为止,我做了这个,它只适用于低于/超过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%}

最新更新