在Shopify中,我很难找到全局变量的数据类型。我的问题可能是范围问题,但他们应该不难告诉我数据类型。他们的技术支持说主题作者应该回答它,主题作者说Shopify应该回答它。国际水文学组织,他们中的任何一个都应该能够回答这个问题。所以我非常感谢你能提供的任何智慧。
我的客户是批发商,不做低于50.00美元的订单。在变量中运行用于总顺序的比较应该是相当容易的,但是我的代码完全失败了。代码还应允许零售商更改其订单并再次运行比较。我在变量和片段中添加了所有可能的括号组合,以防语法错误。
<div class="six columns cart-buttons">
{% if cart.total_price | money_with_currency < 50 %}
<div style="font-weight: bold; color: #900; margin-bottom: 15px;">Your order must be at least $50.00</div>
{% endif %}
{% if cart.total_price | money_with_currency > 50 %}
<input class="button nice" type="submit" value="{{settings.checkout_text}}" name="checkout" />
{% if additional_checkout_buttons %}
<em>or</em>
{{ content_for_additional_checkout_buttons }}
{% endif %}
{% endif %}
</div> <!-- end cart buttons div -->发布于 2014-12-05 06:31:07
请参阅货币过滤器上的Shopify文档。money_with_currency过滤器可以输出类似于“1.45CAD”的东西。也许可以试试money_without_currency,它将价格格式化为十进制。
编辑:
看来money_without_currency不工作了。下面的代码会导致Liquid error: comparison of String with 50 failed
{% assign total_price = cart.total_price | money_without_currency %}
{% if total_price < 50 %} ... {% endif %} 所以,你有两个选择。首先,可以将money_without_currency的输出转换为如下数字:
{% assign total_price = cart.total_price | money_without_currency | times: 1 %}或者,与没有过滤器的cart.total_price进行比较(添加2个零,因为cart.total_price没有小数位,所以如果没有货币过滤器的格式,$50.00就是5000 ):
{% if cart.total_price < 5000 %} ... {% endif %} https://stackoverflow.com/questions/27309120
复制相似问题