这是一个Shopify网站。有没有办法只显示购物车中的某些订单项属性?我有几个,看起来很乱,所以只想显示选择的两个或三个。
我假设您已设置了类似于Shopify Wiki上建议的行项目属性(“行项目属性”)。
您在product.liquid中将有类似这样的内容:
<div>
<p><label for="property1">Property 1:</label></p>
<p><input type="text" id="property1" name="properties[Property1]" /></p>
</div>
然后将此代码放入购物车标题下方的cart.liquid:
{% for p in item.properties %}
{% if p.first == 'Property2' or p.first == 'Property5' %}
{% unless p.last == blank %}
{{ p.first }}:
{% if p.last contains '/uploads/' %}
<a class="lightbox" href="{{ p.last }}">{{ p.last | split: '/' | last }}</a>
{% else %}
{{ p.last }}
{% endif %}
<br />
{% endunless %}
{% endif %}
{% endfor %}
上面的代码直接来自Shopify Wiki上的“订单项属性”文章(第3.1节在购物车页面上显示订单项属性)。我刚刚在第二行添加了if语句,以仅显示我想要的属性:
{% for p in item.properties %}
{% if p.first == 'Property2' or p.first == 'Property5' %}
...
{% endif %}
{% endfor %}
或者,如果要在一行中显示多个属性(例如前三个属性),则可以这样做(不使用if语句):
{% for p in item.properties limit:3 %}
...
{% endfor %}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句