All things Shopify and commerce
Hi All,
Im hoping I've posted this in the correct place. I'm trying to get metafield data to show the title and data only idf the data is present, at the moment im having to setup multiple templates for our products.
Example.
Im using a Shopify app S-Bulk Excel like product editor to create all my meta fields associated with to the products that all have a unique meta filed value. For instance Height, Length and Width per product.
Ive added html code to my template to show the label and then add the relevant data.
Im try to get it to only show the label and relevant data only if the is data present, so if there is no data no label will show. please see example of the html I used below.
<p><b><label>Height: </label></b><span productmf='spec/height'></span></p>
<p><b><label>Length: </label></b><span productmf='spec/length'></span></p>
<p><b><label>Width: </label></b><span productmf='spec/width'></span></p>
Please let know know if this is possible, much appreciated.
Solved! Go to the solution
This is an accepted solution.
Use this code
{% for field in product.metafields.spec %}
{% if field.last %}
<p>
<b><label>{{ field.first }}: </label></b>
<span>{{ field.last }}</span>
</p>
{% endif %}
{% endfor %}
This is an accepted solution.
Use this code
{% for field in product.metafields.spec %}
{% if field.last %}
<p>
<b><label>{{ field.first }}: </label></b>
<span>{{ field.last }}</span>
</p>
{% endif %}
{% endfor %}
Thanks for this, it works great. Appreciate the help.
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025