如何通过客户标签将产品供应商从搜索结果中排除

时间:2020-07-14 19:55:26

标签: shopify liquid

我正在尝试根据每个客户标签的供应商类型排除产品。例如,如果客户登录并标记为“设计者”,则他们只能从搜索结果中的供应商类型“设计者”中获取产品。

我将代码放在{%如果search.performed%}的下面,但没有成功。预先感谢。

    {% assign isWholesaler = false %}
          {% if customer %}
            {% if customer.tags contains 'wholesale' %}
              {% assign isWholesaler = true %}
            {% endif %}
          {% endif %}
          
          {% if isWholesaler %}
            {% for result in search.results %}
                {% if item.product.vendor == 'CompanyName Wholesale' %}
                {% include 'search-result' %}
                {% else %}
                {% endif %}
            {% endfor %}
          {% endif %}

    {% assign isDesigner = false %}
          {% if customer %}
            {% if customer.tags contains 'designer' %}
              {% assign isDesigner = true %}
            {% endif %}
          {% endif %}

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

    {% assign isConsumer = false %}
          {% if customer %}
            {% if customer.tags contains 'consumer' %}
              {% assign isConsumer = true %}
            {% endif %}
          {% endif %}

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

0 个答案:

没有答案