是否可以在 shopify 商店上动态设置 "featured" 系列?
Is it possible to dynamically set the "featured" collection on a shopify store?
我希望能够在 shopify 商店的特色产品部分显示两个不同的系列。我想这样做是为了避免显示与正在查看的产品相同的特色产品。我看到在自定义主题页面上可以选择要显示的集合,但是这个集合不能改变。我认为最好的方法是使用产品标签,然后根据标签更改精选系列。但是我没有成功。非常感谢此处的任何帮助。
{% for tag in product.tags %}
{% if tag contains 'top' %}
{% assign settings.home_featured_products == 'Home' %}
{% elsif tag contains 'bottom' %}
{% assign settings.home_featured_products == 'Frontpage' %}
{% endif %}
{% endfor %}
产品页面上还包含一个 "featured-products.liquid" 文件,用于控制特色产品部分的布局。可以创建其中两个文件来显示两个不同的集合,然后根据标签显示不同的文件。但是我不确定如何控制在这个文件中显示哪个集合。
<!-- 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>
如果您只想显示集合中的当前产品,您可以这样做:
{% assign handle = product.handle %}
{% for product in collection[featured_products].products %}
{% unless product.handle == handle %}
Your product goes here.
{% endunless %}
{% endfor %}
您可以将 'Your product goes here.' 替换为指定的任何产品对象 here
我希望能够在 shopify 商店的特色产品部分显示两个不同的系列。我想这样做是为了避免显示与正在查看的产品相同的特色产品。我看到在自定义主题页面上可以选择要显示的集合,但是这个集合不能改变。我认为最好的方法是使用产品标签,然后根据标签更改精选系列。但是我没有成功。非常感谢此处的任何帮助。
{% for tag in product.tags %}
{% if tag contains 'top' %}
{% assign settings.home_featured_products == 'Home' %}
{% elsif tag contains 'bottom' %}
{% assign settings.home_featured_products == 'Frontpage' %}
{% endif %}
{% endfor %}
产品页面上还包含一个 "featured-products.liquid" 文件,用于控制特色产品部分的布局。可以创建其中两个文件来显示两个不同的集合,然后根据标签显示不同的文件。但是我不确定如何控制在这个文件中显示哪个集合。
<!-- 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>
如果您只想显示集合中的当前产品,您可以这样做:
{% assign handle = product.handle %}
{% for product in collection[featured_products].products %}
{% unless product.handle == handle %}
Your product goes here.
{% endunless %}
{% endfor %}
您可以将 'Your product goes here.' 替换为指定的任何产品对象 here