Adding product variant metafield to product page

22 0 12

Hey all, 

I'm trying to add a variant product metafield to this page, below the price but above the Quantity.

I've tried adding this code to the right area, but it's not calling up the variant metafield, can anybody help me get it working? 

<p> Size: {{variant.metafields.my_fields.size}} </p>




Replies 2 (2)
22 0 12

Update, I have managed to make the variant metafield display correctly with the following code:

<div><p><strong> {{ current_variant.metafields.my_fields.size }} </strong></p></div>


However, if the metafield is empty (which it will be for some products) a "0" is being displayed on the product page. Can anyone help me to stop the "0" from being displayed?

Screenshot 2021-10-24 at 09.31.29.pngScreenshot 2021-10-24 at 09.35.02.png

New Member
2 0 0

I found a solution in an article written by Alan Ryan here: It works great!