【发布时间】:2017-03-16 02:49:24
【问题描述】:
目标是在 Shopify 的产品系列页面上仅显示其他颜色变体。 使用供应主题。我在集合中显示所有变体图像,但如果存在变体,我只想显示颜色变体。有些物品没有变体,有些物品有尺寸变体。有的有颜色,有的有大小和颜色。我不想在集合页面上显示颜色的所有尺寸变体。 收集.液体
{% for product in collection.products %}
{% for variant in product.variants %}
{% if has_sidebar %}
{% assign grid_item_width = 'large--one-quarter medium--one-third small--one-half' %}
{% else %}
{% assign grid_item_width = 'large--one-fifth medium--one-third small--one-half' %}
{% endif %}
{% include 'product-grid-item' %}
{% else %}
<div class="grid-item">
<p>{{ 'collections.general.no_matches' | t }}</p>
</div>
{% endfor %}
{% endfor %}
</div>
product-grid-item.liquid
<div class="grid-item {{ grid_item_width }}{% if sold_out %} sold-out{% endif %}{% if on_sale %} on-sale{% endif %}">
{% 如果售罄 %} {{ 'products.product.sold_out' | }} {% 万一 %} 我想我需要从 if 语句开始检查变体,然后为颜色添加一个 forloop。 {% for option in product.options %} {% if option == 'Color' %}
任何帮助将不胜感激。
【问题讨论】: