shopify - 如果在 shopify 中变体数量少于两个,则显示变体标题
问题描述
嗨,我在 Shopify 网站上工作。我想要实现的是从我的收藏页面中隐藏缺货产品的变体标题。“我已经完成了”所以现在我要尝试的是。显示数量超过 2 的产品的变体标题。“这是卡住的部分”这是我的代码
{%- assign empty_list = true -%}
{%- for variant in product.variants -%}
{%- comment -%}Skip the variant if it's not available{%- endcomment -%}
{%- unless variant.available -%}
{%- continue -%}
{%- endunless -%}
{%- comment -%}Print a comma unless our list is empty{%- endcomment -%}
{%- unless empty_list -%},{%- endunless -%}
{%- assign empty_list = false -%}
{%- comment -%}Now print our new entry{%- endcomment -%}
<span class="variant-name"> {{ variant.title }}</span>
{%- endfor -%}
解决方案
通过使用以下代码,您可以获得数量超过 2 的产品标题。
{% for variant in product.variants %}
{% if variant.inventory_quantity > 2 %}
{{- variant.title -}} <br>
{% endif %}
{% endfor %}
推荐阅读
- json - JQ新手在选择嵌套键时遇到问题
- sql - 帐户上的 SFDC 数据加载器 - 相同的 ID,不同的字段值
- javascript - 单击时单选按钮不执行 JavaScript 操作
- r - 为 r 中的多个水平创建置信区间图
- reactjs - Passing data from same level components React
- javascript - 如何从中获取选定的值
? - mysql - 使用 AND/OR 的 SQL 语句问题
- android - Android:CollapsingToolBar 不会将折叠后出现在工具栏底部的标题的图标设置在一级
- sql-server - 两个同名的 SQL Server 实例?
- php - symfony 2.8 谷歌驱动 api V2