我希望能够在shopify商店的特色产品部分展示两个不同的系列。我想这样做是为了避免显示与正在查看的产品相同的特色产品。我看到在自定义主题页面上可以选择要显示的集合,但此集合无法更改。我认为最好的方法是使用产品标签,然后根据标签更改特色集合。但是我没有成功。非常感谢任何帮助。
<!-- snippets/featured-products.liquid -->
{% if section_number > 1 and number_of_index_sections > 1 %}
<hr class="hr--medium hr--clear">
{% endif %}
<div class="section-header text-center">
<h1>{{ 'home_page.sections.featured_products' | t }}</h1>
<hr class="hr--small">
</div>
<div class="{% if settings.collection_products_grid == 'collage' %}grid grid-collage{% else %}grid-uniform{% endif %}">
{% comment %}
Loop through products in your Frontpage collection.
This collection is created by default, but you must add products to it.
See the snippet 'snippets/product-grid-collage.liquid'.
`is_reverse_row_product`, `three_row_index_product`, `collection_product_count_product`, and `divisible_by_three_product` are
all used by 'snippets/product-grid-collage.liquid'
{% endcomment %}
<div class="grid-uniform__aligner">
{% if settings.home_featured_products == blank or collections[settings.home_featured_products].empty? or collections[settings.home_featured_products].products_count == 0 %}
{% comment %}
For onboarding new users to your theme, we add some default products and onboarding tutorials to help populate their store
{% endcomment %}
{% unless emptyState %}
{{ 'theme-onboarding.css' | global_asset_url | stylesheet_tag }}
{% assign emptyState = true %}
{% endunless %}
{% include 'onboarding-featured-products' %}
{% else %}
{% if settings.collection_products_grid == 'collage' %}
{% assign is_reverse_row__product = false %}
{% assign three_row_index__product = 0 %}
{% if collections[settings.home_featured_products].products_count > 50 %}
{% assign collection_product_count__product = 50 %}
{% else %}
{% assign collection_product_count__product = collections[settings.home_featured_products].products_count %}
{% endif %}
{% assign divisible_by_three__product = collection_product_count__product | modulo:3 %}
{% for product in collections[settings.home_featured_products].products %}
{% include 'product-grid-collage' %}
{% endfor %}
{% else %}
{% assign grid_item_width = 'medium--one-half large--one-third' %}
{% for product in collections[settings.home_featured_products].products %}
{% include 'product-grid-item' %}
{% endfor %}
{% endif %}
{% endif %}
</div>
</div>
产品页面上还包含一个“featured-products.liquid”文件,用于控制特色产品部分的布局。可以创建其中两个显示两个不同集合的文件,然后根据标记显示不同的文件。但是我不确定如何控制在此文件中显示哪个集合。
proxy_set_header Host $host
答案 0 :(得分:1)
如果您只想在集合中显示当前产品,则可以执行以下操作:
{% assign handle = product.handle %}
{% for product in collection[featured_products].products %}
{% unless product.handle == handle %}
Your product goes here.
{% endunless %}
{% endfor %}
您可以替换“您的产品到此处”。使用指定的任何产品对象here