【发布时间】:2021-11-23 07:58:14
【问题描述】:
我为我们的 Shopify 商店之一编写了代码,但它没有按我想要的方式工作。我请求您对此提供支持。
这是对我们收藏页面上每件商品的检查。我得到包含产品 base_sku 名称的标签,并在所有产品中查找带有此标签的产品。 然后我从具有相同 base_sku 的产品中提取包含颜色的标签,并将它们链接到主产品下。 我在这里使用分页,我知道我最多可以拉出 1000 个项目。我需要的是能够按我想要的每个产品多次循环分页,而不管页码是多少。 因为这样一来,它只检查集合第一页的前1000个产品,而当我切换到第二页时,它会检查剩余产品的数量。
在这里我必须继续处理标签,因为虽然这里的产品似乎是变体,但我展示的所有产品都是单独的产品。 https://gyazo.com/bc139013bdb7d9ad249ca907bf4b83a1
这是我一直在处理但无法解决的问题,如果您能支持我,我将非常高兴。
最好的问候, 伯克
<div id="prod-var" class="prod-variants">
{% for tag in product_card_product.tags %}
{% if tag contains "BASE SKU" %}
{% assign base_url = tag | split: "_" | last %}
{% endif %}
{% if tag contains "COLOUR" %}
{% assign first_colour = tag | split: "_" | last %}
{% endif %}
{% if tag contains "SIZE" %}
{% assign first_size = tag | split: "_" | last %}
{% endif %}
{% endfor %}
<div class="variant-all-div">
{% paginate collections.all.products by 1000 %}
{% for product in collections.all.products %}
{% for tag in product.tags %}
{% if tag contains base_url %}
{% for tag in product.tags %}
{% if tag contains "COLOUR" %}
{% assign colour = tag | split: "_" | last %}
{% endif %}
{% endfor %}
{% for tag in product.tags %}
{% if tag contains "SIZE" %}
{% assign size = tag | split: "_" | last %}
{% endif %}
{% endfor %}
{% if first_colour == colour and first_size == size%}{% continue %}{% endif %}
<div class="variant-div">
<a class="collec-variant" href="{{product.url}}"><img style="width: 30px; height: 30px;" src="{{ product.featured_media | img_url:'30x30' }}"></a>
<span class="tooltiptext">{{ colour }}</span>
</div>
{% endif %}
{% endfor %}
{% endfor %}
{% endpaginate %}
</div>
</div>
【问题讨论】:
标签: html shopify liquid shopify-template