【问题标题】:Shopify Limit Tagged ProductsShopify 限制标记产品
【发布时间】:2016-06-02 00:47:34
【问题描述】:

我目前正在开发 Shopify 主题,我有一个所有产品的列表,我已将它们过滤为仅显示带有以下标签“Neoprene”的任何内容 - 我如何不将标记的产品限制为仅显示 4 ?

任何帮助将不胜感激!

<main class="wrapper">
  <div class="grid">
    <div class="grid__item">
      <div class="large--one-whole">
      {% for product in collections.all.products limit: 9999 %}
        {% if product.tags contains 'Neoprene' %}
        <div class="landing-product grid__item large--one-quarter medium--one-quarter small--one-half">
          <a href="{{ product.url }}" class="img">
            {% for image in product.images %}
              <span class="grid-link__image-centered">
                <img src="{{ product.featured_image.src | img_url: 'grande' }}" alt="{{ product.featured_image.alt | escape }}">
              </span>
            {% endfor %}
          </a>
          <a href="{{ product.url }}" class="title">
            {{ product.title }}
          </a>
          <a href="{{ product.url }}" class="price">
            {{ product.price | money }}
          </a>
        </div>
        {% endif %}
      {% endfor %}
      </div>
    </div>
  </div>
</main>

【问题讨论】:

    标签: shopify


    【解决方案1】:
    <main class="wrapper">
      <div class="grid">
        <div class="grid__item">
          <div class="large--one-whole">
          {% assign a = 0 %}
          {% for product in collections.all.products limit: 9999 %}
            {% if a == 4 %}
                {% break %}
            {% else %}        
              {% if product.tags contains 'Neoprene' %}
              {% assign a = a | plus : 1 %}
              <div class="landing-product grid__item large--one-quarter medium--one-quarter small--one-half">
                <a href="{{ product.url }}" class="img">
                  {% for image in product.images %}
                    <span class="grid-link__image-centered">
                      <img src="{{ product.featured_image.src | img_url: 'grande' }}" alt="{{ product.featured_image.alt | escape }}">
                    </span>
                  {% endfor %}
                </a>
                <a href="{{ product.url }}" class="title">
                  {{ product.title }}
                </a>
                <a href="{{ product.url }}" class="price">
                  {{ product.price | money }}
                </a>
              </div>
              {% endif %}
            {% endif %}
          {% endfor %}
          </div>
        </div>
      </div>
    </main>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-11-29
      • 2014-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多