-1
我的產品頁面上有一個「相關產品」部分,基於'Vatage'主題。現在它顯示了一個由「收集」相關的產品。是否有可能顯示相關產品的相同標籤? 我試着用其他代碼,但我失敗了.. 請有人幫助我。如何通過標籤顯示相關產品 - shopify
這是我的related-products.liquid代碼。
謝謝。
{% capture number_of_related_products_to_fetch %}{{ number_of_related_products_to_show | plus: 1 }}{% endcapture %}
{% if collection == null or collection.handle == 'frontpage' or collection.handle == 'all' %}
{% assign found_a_collection = false %}
{% for c in product.collections %}
{% if found_a_collection == false and c.handle != 'frontpage' and c.handle != 'all' and c.all_products_count > 1 %}
{% assign found_a_collection = true %}
{% assign collection = c %}
{% endif %}
{% endfor %}
{% endif %}
<div class="desktop-12 mobile-3">
<h4 class="section-title">{{ 'products.product.related_products' | t }}</h4>
<div id="product-loop">
{% assign current_product_found = false %}
{% for prod in collection.products limit: 7 %}
{% if prod.title == product.title %}
{% assign current_product_found = true %}
{% else %}
{% unless current_product_found == false and forloop.last %}
<div class="product-index desktop-2 tablet-2 mobile-half" id="prod-{{ product.id }}" data-alpha="{{ prod.title }}" data-price="{{ prod.price }}">
<a href="{{ prod.url | within: collection }}" title="{{ prod.title | escape }}">
<img src="{{ prod.featured_image | product_img_url: 'large' }}" alt="{{ product.title | escape }}" />
</a>
<div class="product-info">
<div class="product-info-inner">
<a href="{{ prod.url | within: collection }}">
<h3>{{ prod.title }}</h3>
</a>
<div class="price">
{% if product.price < prod.compare_at_price %}
<div class="onsale">{{ prod.price | money }}</div>
<div class="was">{{ prod.compare_at_price | money }}</div>
{% else %}
<div class="prod-price">{% if prod.price_varies %} {{ 'products.general.from' | t }} {{ prod.price_min | money }} - {{ prod.price_max | money }} {% else %}{{ prod.price | money }}{% endif %}</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endunless %}
{% endif %}
{% endfor %}
</div>
</div>
[如何通過Shopify中的標記顯示相關產品](https://stackoverflow.com/questions/45407485/how-to-show-related-products-by-tag-in-shopify) – drip