Hi, I have tried the following approach, but it doesn’t work. I wonder how I can get the size of the metafields list.
{% if product.metafields.products.related.value.size > 0 %}
Some related products here.
{% else %}
It is empty.
{% endif %}
Where {% product.metafields.products.related.type %} is list.product_reference.
Hi @henglw0621
Can you let us know where you want to display the metafields and the theme which you are using?
1 Like
Hi @Tinytasks , thank you for reply.
I am using the following theme and display the metafields on the product page.
https://themes.shopify.com/themes/empire/styles/supply
Hi @LitExtension , thank you for reply.
I have checked the pagination reference you provided, but I don’t know how I can apply it to my code. I would appreciate if you could give me some example code on how to apply pagination with the metafield list.
Hi @henglw0621 ,
Sorry for the confusion, you can use the following code:
{% if product.metafields.products.related.value != blank %}
Some related products here.
{% else %}
It is empty.
{% endif %}
Hope it helps!
1 Like
@LitExtension Thank you so much! You saved my day.
1 Like
Although this has been solved, here is a simpler solution:
Size of Metafield list = {{ product.metafields.products.related.value | size }}
{% liquid
assign related_products = product.metafields.products.related | split: ‘,’
echo related_products | size
%}