使用Timber和Shopify,如何在Ajax迷你木材手推车上添加元字段? [英] Using Timber and Shopify, how can I add meta fields on the ajax mini cart of timber?

查看:72
本文介绍了使用Timber和Shopify,如何在Ajax迷你木材手推车上添加元字段?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Shopify主题中使用木材.

我希望在购物车上添加产品的元字段.在此处购物车截图

产品上也显示了元字段,我也想在Ajax微型购物车上显示该字段.产品页面屏幕截图

此处的js代码

让我知道它是否可能.

解决方案

这是一个Timber in a Shopify theme.

I would look to add meta fields of the product on the cart. Cart screenshot here

The metafields are showing on product i would like to show that on Ajax mini cart too. product page screenshot

js code here

Let me know if its possible.

解决方案

Here are a few examples on how you may access a product's metafields.

In the cart page though, because you don't have a direct access to the product object, you should first get access to the product object via the [line_item][2] object to be able to access the metafields, example:

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

And that should do the trick!

这篇关于使用Timber和Shopify,如何在Ajax迷你木材手推车上添加元字段?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆