【问题标题】:Using Timber and Shopify, how can I add meta fields on the ajax mini cart of timber?使用 Timber 和 Shopify,如何在木材的 ajax 迷你购物车上添加元字段?
【发布时间】:2020-12-02 12:40:21
【问题描述】:

我在 Shopify 主题中使用 Timber

我希望在购物车上添加产品的元字段。 Cart screenshot here

元字段显示在产品上,我也想在 Ajax 迷你购物车上显示。 product page screenshot

js code here

如果可能,请告诉我。

【问题讨论】:

    标签: ajax shopify cart timber shopify-template


    【解决方案1】:

    这里有一个few examples,关于如何访问产品的元字段。

    但在购物车页面中,由于您无法直接访问产品对象,因此您应该首先通过[line_item][2] 对象访问产品对象才能访问metafields,例如:

    {% for item in cart.items %}
      {{ item.product.metafields.key }}
    {% endfor %}
    

    这应该可以解决问题!

    【讨论】:

      猜你喜欢
      • 2023-04-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-29
      • 2021-01-04
      • 2012-08-13
      • 1970-01-01
      相关资源
      最近更新 更多