问题
I’m using 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.
回答1:
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!
来源:https://stackoverflow.com/questions/65108306/using-timber-and-shopify-how-can-i-add-meta-fields-on-the-ajax-mini-cart-of-tim