【问题标题】:How to hide products in Shopify search results based on a vendor name如何根据供应商名称在 Shopify 搜索结果中隐藏产品
【发布时间】:2015-07-02 03:05:47
【问题描述】:

由于外部 POS,我无法在控制面板中隐藏某些供应商的产品。对于 search.liquid 中的测试,我使用了如下所示的 search.terms。此代码有效,但不是每个人都会以完全相同的方式键入 thevendor,并且如果他们不键入 thevendor,就会看到产品。

{% for item in search.results %}
{% if search.terms == 'thevendor' %}
{% else %}
{% include 'search-result' %}
{% endif %}
{% endfor %}

我试图弄清楚如何编写代码以更好地隐藏这些产品。我尝试了下面的 product.vendor ,但是当我单独搜索这些产品时,它们并没有被隐藏。代码:

{% for item in search.results %}
{% if product.vendor == 'thevendor' %}
{% else %}
{% include 'search-result' %}
{% endif %}
{% endfor %}

有人可以告诉我我在这里缺少什么吗?似乎它不知道 product.vendor 是什么,但是当我打印出供应商是谁时,它会显示供应商。我不明白为什么它不隐藏与该供应商相关的产品。

【问题讨论】:

    标签: shopify liquid


    【解决方案1】:
    {% for item in search.results %}
    {% if item.product.vendor == 'thevendor' %}
    {% else %}
    {% include 'search-result' %}
    {% endif %}
    {% endfor %}
    

    这应该可行。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-12-19
      • 2020-10-28
      • 1970-01-01
      • 2018-08-10
      • 1970-01-01
      • 2021-01-06
      • 2017-01-19
      相关资源
      最近更新 更多