【发布时间】:2016-09-15 20:30:14
【问题描述】:
我目前正在尝试在我的 shopify 商店中显示我所有产品的价格。我已经设法使用以下代码为我的第一个产品展示了这一点:
<div class="grid__item">
{% for collection in collections %}
{% for product in collection.products %}
{% for variant in product.variants %}
{% if forloop.index <=1 %}
<div id="temp_first" style="display:none;">
<div class="style14">Style</div>
<div class="style11">(No)</div>
<div class="front"><img src="//files/front.jpg?v=1473520767" title="1 Sided Full Color" /></div>
<div class="reverse"><img src="//1/1265/7581/files/reverse.jpg?v=1473520807" title="1 Sided Only" /></div>
<div class="price"><a href="/products/leaflets?variant={{ variant.id }}">{{ variant.price | money | remove: '.00'}}</a></div>
{% elsif forloop.index <7 %}
<div class="price"><a href="/products/leaflets?variant={{ variant.id }}">{{ variant.price | money | remove: '.00'}}</a></div>
{% elsif forloop.index <10 %}
<div class="price2"><a href="/products/leaflets?variant={{ variant.id }}">{{ variant.price | money | remove: '.00'}}</a></div>
{% elsif forloop.index <13 %}
<div class="price3"><a href="/products/leaflets?variant={{ variant.id }}">{{ variant.price | money | remove: '.00'}}</a></div>
{% elsif forloop.index ==13 %}
<div class="price3"><a href="/products/leaflets?variant={{ variant.id }}">{{ variant.price | money | remove: '.00'}}</a></div>
</div>
{% endif %}
{% endfor %}
{% endfor %}
{% endfor %}
现在效果很好。我现在遇到的问题是我想显示第二个产品的价格,我复制了上面的代码并更改了链接,以便将其链接到正确的产品页面和变体,这工作正常。问题是显示的价格是针对第一个产品的,我不知道我需要在代码中更改什么以针对第二个产品。无论是它的句柄名称还是什么,我只是不确定,因此需要一些帮助。
如果有人可以建议,我如何定位第二个产品,我将不胜感激。
提前致谢。
【问题讨论】: