How can I access product metafields in the cart page?

How can I access product metafields in the cart page?

Hamisco
New Member
5 0 0

Hello everyone, I had create a metafields for the products called "Reward Points" now I want to access this metafields in the cart page, the problem is the products in the cart page under "items" to through for all items in the cart, so how can i access this metafield from that item, or dose any one have another way?

 

I have tried this code : 

{{product.metafields.custom.reward_points}}

 also this one :

{{itme.metafields.cutom.reward_points}}

 but I didn't get any results...

Thank you for your support.

Replies 2 (2)

MetafieldsGuru
Shopify Partner
158 32 99

Hi @Hamisco ,

 

You need to use a slightly different Liquid code pattern. You may want to extract the line item object first, then extract the product object from that line item, and then access the product's metafields. As the result, you'll end up with the code like this:

{{ item.product.metafields.cutom.reward_points }}

If the "reward points" metafield is an Online Store 2.0 metafield, you'll need to add the ".value" part at the end of this code:

{{ item.product.metafields.cutom.reward_points.value }}
Check out Metafields Guru, the #1 ranked metafields app.

Bulk editor | Data import/export | Metafield sets | Browser extension
Hamisco
New Member
5 0 0

Thank you Mr. @MetafieldsGuru , this answer helped me...