Metafields showing when no input

rebelcopenhagen
Tourist
13 0 0

Hi.

 

I have created metafields for origin of production and for the material of the product.

In the theme I have create a text section where I have written Produced in: [Metafield attribute] and it is all good when I write the country in the products metafield, but for some products I don't have the origin and leave the field empty but then it just says "Produced in:" on the product.

Is there any way for the text box not to show if the input field is empty in the backend?

 

Right now I am writing the entire sentence and I CAN do that, but I'm so lazy that I don't want to 🙂

 

The theme is Kalles

The link is https://www.rebelcopenhagen.dk/products/8434685482288?variant=49359751545158 (code is copenhagenrebel)

 

metafields.JPGmetafields2.JPG

Replies 4 (4)

Liqiud_xPert_SJ
Shopify Partner
723 92 112

@rebelcopenhagen 

 

are these metafields are custom coded? or you are getting them using dynamic source.

 

thanks

- Please don't forget to Like and Mark Solution to the post that helped you. Thanks!
- Your Shopify Solution Specialist For further discussion contact: Email ID- Liqud_3xPert_SJ OR Whatsapp
- Buy a Coffee for me to get more frequently help 🙂
- Hire Me to unlock the full potential of your e-commerce store Now 🙂
rebelcopenhagen
Tourist
13 0 0

Hi.

It is dynamic sourced (meaning I pressed the Add dynamic source in the text field)

LuffyOnePiece
Shopify Partner
311 55 54

Hi @rebelcopenhagen ,

 

To fix this issue, we need to add the condition to check the if the metafield is empty or not.

 

For example: 

 

{%- if product.metafields.custom.country.value != blank -%}
 {{ product.metafields.custom.country.value }}
{% endif %}

 

If you require further help to optimize or customize your store, please don’t hesitate to reach out. If you find this information useful, a Like would be greatly appreciated. And if this solves the problem, please Mark it as Solution!

 

Best Regards,
LuffyOnePiece

 

Sandeep Pangeni
Need help with your store? sandeeppangeni17@gmail.com
For quick response, Contact In WhatsApp +9779867521184
rebelcopenhagen
Tourist
13 0 0

Hi.

Thank you, but in what file do I put this code?