Happening now | Office Hours: Customizing Your Theme With Moeed | Ask your questions now!

Can Metafields only show if there is data inside of them?

Can Metafields only show if there is data inside of them?

UPCRAFTED
Excursionist
17 0 4

I've created a few Product Metafields for my product page. For example: Specs; Features; Care Instructions. -- But not all products have this info. 

 

I'm surprised that this feature in Shopify doesn't have a checkbox where it says to not show if the field is empty. Since there is a problem when the shopper goes and tries to click on the Multi-field and it doesn't open because its empty. 

 

Is there a way to solve this? Much thanks in advanced!

Replies 2 (2)
UPCRAFTED
Excursionist
17 0 4

thank you for the reply. Would this be on the product liquid page? I've tried it in a few places but dont see anything changing. 

Small_Task_Help
Shopify Partner
1103 51 108

Hi,

Hope this will help

- At Product Page File and Add Liquid Code Where You Want the Metafield to Show

Example:

if you want to show "Care Instructions" metafield only if it has content:

{% if product.metafields.custom.care_instructions != blank %}

<div class="care-instructions"> <h3>Care Instructions</h3> <p>{{ product.metafields.custom.care_instructions }}</p> </div> {% endif %}

- Replace custom and care_instructions with your actual metafield namespace & key.

- Repeat this for each of your fields

To Get Shopify Experts Help, Click Here or E-mail - hi@ecommercesmalltask.com
About Us - We are Shopify Expert India
At Google My Business - Ecommerce Small Task - Hire Shopify Developers Ahmedabad