Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
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 %}
<p>Some related products here.</p>
{% else %}
<p>It is empty.</p>
{% endif %}
Where {% product.metafields.products.related.type %} is list.product_reference.
Solved! Go to the solution
This is an accepted solution.
Hi @henglw0621,
Sorry for the confusion, you can use the following code:
{% if product.metafields.products.related.value != blank %}
<p>Some related products here.</p>
{% else %}
<p>It is empty.</p>
{% endif %}
Hope it helps!
Hi @henglw0621
Can you let us know where you want to display the metafields and the theme which you are using?
Hi @Tinytasks, thank you for reply.
I am using the following theme and display the metafields on the product page.
Hi @henglw0621,
You can refer: https://shopify.dev/api/liquid/objects#paginate
Hope it helps!
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.
This is an accepted solution.
Hi @henglw0621,
Sorry for the confusion, you can use the following code:
{% if product.metafields.products.related.value != blank %}
<p>Some related products here.</p>
{% else %}
<p>It is empty.</p>
{% endif %}
Hope it helps!
Although this has been solved, here is a simpler solution:
Size of Metafield list = {{ product.metafields.products.related.value | size }}
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024