【问题标题】:Show title and image of all Shopify products within drop down menu在下拉菜单中显示所有 Shopify 产品的标题和图片
【发布时间】:2015-11-24 02:47:47
【问题描述】:

我正在为我的商店开发“捆绑”功能,并希望在自定义表单字段中显示我的所有产品。

我希望有一个下拉菜单,显示每个产品的标题和主图像。

我认为代码应该是这样的:

<p class="line-item-property__field">
  <label>bundled item</label><br>
  <select required class="required" id="bundled-item" name="properties[bundled item]">
    {% for product in collections.products %}
      <option value="{{ product.title }}">{{ product.title }}{{ product.featured_image }}</option>

    {% endfor %}
  </select>
</p>

但这并没有完全做到这一点。任何人都可以展示在下拉列表中嵌入产品的正确方法吗?

【问题讨论】:

标签: html shopify liquid


【解决方案1】:

试试这个

    {% for product in collections['all'].products %}
      <option value="{{ product.title }}">{{ product.title }}{{ product.featured_image }}</option>
  {% endfor %}

但请记住,一个循环最多只能调用 1000 个项目;默认为 50。

【讨论】:

  • 什么是我有两个下拉列表,当我在一个下拉列表中选择一个产品时,该产品将在第二个下拉列表中被禁用。
  • @AnupamMistry 你需要在那里应用 JavaScript 逻辑。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-04-07
  • 1970-01-01
  • 2019-09-27
相关资源
最近更新 更多