How can I conceal an empty metafield in a product.json file?

This code is from my product.json file

“79b2a2e0-eb20-483d-8386-8743710bfd15”: {
“type”: “text”,
“settings”: {
“text”: “

Country of origin </strong>: {{ product.metafields.custom.country.value }}</p>”
}

How can I get this field to hide if it is blank?

Please share the code of the liquid file that is using this code.

Here you go

{
“sections”: {
“breadcrumbs”: {
“type”: “product__breadcrumb”,
“settings”: {
“width”: “standard”,
“padding_top”: 0,
“padding_bottom”: 0,
“css_class”: “”,
“custom_css”: “”
}
},
“main”: {
“type”: “product__main”,
“blocks”: {
“title”: {
“type”: “title”,
“settings”: {
}
},
“price”: {
“type”: “price”,
“settings”: {
“display_savings”: true
}
},
“a2465fbd-ed30-43ec-b8a1-4116d9023fe9”: {
“type”: “text”,
“settings”: {
“text”: “

Dimensions</strong>: {{ product.metafields.custom.dimensions.value }}</p>”
}
},
“f5972076-fa2b-48c5-84b1-33d8f656e5e9”: {
“type”: “text”,
“settings”: {
“text”: “

Spin speed</strong> : {{ product.metafields.custom.spin_speed.value }}</p>”
}
},
“f9002e6e-17a5-428c-8ea9-5c96049cf5c8”: {
“type”: “text”,
“settings”: {
“text”: “

Quick wash time</strong> : {{ product.metafields.custom.quick_wash_time.value }}</p>”
}
},
“f08492a8-30e7-447b-bfaa-bb40fabb4b1a”: {
“type”: “text”,
“settings”: {
“text”: “

Energy Rating : </strong>{{ product.metafields.custom.energy_rating_.value }}</p>”
}
},
“900d7c5e-a975-4991-99d5-830857a2cb23”: {
“type”: “text”,
“settings”: {
“text”: “

Capacity : </strong>{{ product.metafields.custom.capacity.value }} </p>”
}
},
“e47daabd-1c96-4fd2-9f89-a334e6f2c0ad”: {
“type”: “text”,
“settings”: {
“text”: “

Colour : </strong>{{ product.metafields.custom.colour.value }}</p>”
}
},
“79b2a2e0-eb20-483d-8386-8743710bfd15”: {
“type”: “text”,
“settings”: {
“text”: “

Country of origin </strong>: {{ product.metafields.custom.country.value }}</p>”
}
},
“58b7a3b2-71bb-4c43-8bc3-f5ff307536d9”: {
“type”: “text”,
“settings”: {
“text”: “

Unique selling point </strong>: {{ product.metafields.custom.unique_selling_point | metafield_tag }}</p>”
}
},
“2310be34-d5a2-4662-8604-3636a3371c97”: {
“type”: “text”,
“settings”: {
“text”: “

{{ product.metafields.custom.fs_or_int.value }}</strong></p>”
}
},
“68ec8ca1-cb20-4694-8657-3b047477b595”: {
“type”: “text”,
“settings”: {
“text”: “

Door colour</strong> : {{ product.metafields.custom.door_colour.value }}</p>”
}
},
“5129445e-7f0e-4e42-b124-c1af79a4aada”: {
“type”: “text”,
“settings”: {
“text”: “

Side panel colour </strong>: {{ product.metafields.custom.side_panel_colour.value }}</p>”
}
},
“f49ffd97-f0e7-406e-8642-34438d075591”: {
“type”: “text”,
“settings”: {
“text”: “

Quick programme</strong> : {{ product.metafields.custom.quick_programme.value }}</p>”
}
},
“bf19fe4b-fc8e-42a0-9674-6c25c15cfc67”: {
“type”: “text”,
“settings”: {
“text”: “

Delay timer </strong>: {{ product.metafields.custom.delay_timer.value }}</p>”
}
},
“bea9b861-294a-48a0-8e4b-9a49718eb145”: {
“type”: “text”,
“settings”: {
“text”: “

Technology </strong>: {{ product.metafields.custom.technology.value }}</p>”
}
},
“7356753e-d8d1-494a-867b-f551eb2b11ed”: {
“type”: “text”,
“settings”: {
“text”: “

Wifi </strong>: {{ product.metafields.custom.wi_fi.value }}</p>”
}
},
“3db1f9b9-3325-46db-9203-b8e75f79ad00”: {
“type”: “text”,
“settings”: {
“text”: “

Controls</strong> : {{ product.metafields.custom.controls.value }}</p>”
}
},
“648c4ad9-8019-4daa-a0d7-0011ab1c5a27”: {
“type”: “text”,
“settings”: {
“text”: “

Noise level</strong> : {{ product.metafields.custom.noise_level_db_.value }}</p>”
}
},
“e53c08d6-ef43-41d4-9867-54560b2d5884”: {
“type”: “text”,
“settings”: {
“text”: “

Hinge</strong> : {{ product.metafields.custom.hinge.value }}</p>”
}
},
“611d1a67-3a37-4a6c-bb5b-ac4a5ec02644”: {
“type”: “text”,
“settings”: {
“text”: “

Parts Guarantee</strong> : {{ product.metafields.custom.parts_guarantee.value }}</p>”
}
},
“524849d7-c10c-465d-b01d-62df4bcd1b73”: {
“type”: “text”,
“settings”: {
“text”: “

Labour guarantee </strong>: {{ product.metafields.custom.labour_guarantee.value }}</p>”
}
},
“84347658-d008-46b4-882d-1a1b4780c459”: {
“type”: “text”,
“settings”: {
“text”: “

Description</strong> : {{ product.metafields.custom.description.value }}</p>”
}
},
“4d5e6e0f-9a99-4905-84ed-6ce50ee83f17”: {
“type”: “text”,
“settings”: {
“text”: “

Fridge capacity</strong> : {{ product.metafields.custom.fridge_capacity.value }}</p>”
}
},
“c7294a0f-8f04-4217-bf41-ded55a0708ea”: {
“type”: “text”,
“settings”: {
“text”: “

Fridge shelves</strong> : {{ product.metafields.custom.fridge_shelves.value }}</p>”
}
},
“74e77802-f301-4d0b-88e6-6944e1ca4451”: {
“type”: “text”,
“settings”: {
“text”: “

Fridge drawers</strong> : {{ product.metafields.custom.fridge_drawers.value }}</p>”
}
},
“47b2ac3d-86f5-4a0c-be3c-79e9854b97a9”: {
“type”: “text”,
“settings”: {
“text”: “

Freezer capacity</strong> : {{ product.metafields.custom.freezer_capacity.value }}</p>”
}
},
“b186ddda-cbd4-481a-8a16-33bc9a55676f”: {
“type”: “text”,
“settings”: {
“text”: “

Freezer draws</strong> : {{ product.metafields.custom.freezer_draws.value }}</p>”
}
},
“form”: {
“type”: “form”,
“settings”: {
“show_payment_button”: true
}
}
},
“block_order”: [
“title”,
“price”,
“a2465fbd-ed30-43ec-b8a1-4116d9023fe9”,
“f5972076-fa2b-48c5-84b1-33d8f656e5e9”,
“f9002e6e-17a5-428c-8ea9-5c96049cf5c8”,
“f08492a8-30e7-447b-bfaa-bb40fabb4b1a”,
“900d7c5e-a975-4991-99d5-830857a2cb23”,
“e47daabd-1c96-4fd2-9f89-a334e6f2c0ad”,
“79b2a2e0-eb20-483d-8386-8743710bfd15”,
“58b7a3b2-71bb-4c43-8bc3-f5ff307536d9”,
“2310be34-d5a2-4662-8604-3636a3371c97”,
“68ec8ca1-cb20-4694-8657-3b047477b595”,
“5129445e-7f0e-4e42-b124-c1af79a4aada”,
“f49ffd97-f0e7-406e-8642-34438d075591”,
“bf19fe4b-fc8e-42a0-9674-6c25c15cfc67”,
“bea9b861-294a-48a0-8e4b-9a49718eb145”,
“7356753e-d8d1-494a-867b-f551eb2b11ed”,
“3db1f9b9-3325-46db-9203-b8e75f79ad00”,
“648c4ad9-8019-4daa-a0d7-0011ab1c5a27”,
“e53c08d6-ef43-41d4-9867-54560b2d5884”,
“611d1a67-3a37-4a6c-bb5b-ac4a5ec02644”,
“524849d7-c10c-465d-b01d-62df4bcd1b73”,
“84347658-d008-46b4-882d-1a1b4780c459”,
“4d5e6e0f-9a99-4905-84ed-6ce50ee83f17”,
“c7294a0f-8f04-4217-bf41-ded55a0708ea”,
“74e77802-f301-4d0b-88e6-6944e1ca4451”,
“47b2ac3d-86f5-4a0c-be3c-79e9854b97a9”,
“b186ddda-cbd4-481a-8a16-33bc9a55676f”,
“form”
],
“settings”: {
“product_images_position”: “left”,
“set_product_height”: true,
“product_height”: 500,
“video_looping”: false,
“gallery_arrows”: false,
“enable_zoom”: false,
“enable_product_lightbox”: true,
“slideshow_speed”: 0,
“slideshow_transition”: “slide”,
“display_thumbnails”: true,
“thumbnail_position”: “left-thumbnails”,
“enable_thumbnail_slider”: true,
“width”: “wide”,
“padding_top”: 20,
“padding_bottom”: 20,
“animation”: “none”,
“css_class”: “”,
“custom_css”: “”
}
},
“16376307254819e784”: {
“type”: “index__faq”,
“blocks”: {
“163763072583826343-1”: {
“type”: “content”,
“settings”: {
“title”: “Are your products considered weight-loss/diet supplements?”,
“answer”: “

Our products are not dietary supplements, however, because of all the balanced nutrients and plant-protein, they may help improve your overall diet! Every BODY is different, and everyone requires a different amount of food and nutrients, so please consult with a professional for more information on diet/weight-loss programs. </p>”
}
},
“163763072583826343-2”: {
“type”: “content”,
“settings”: {
“title”: “How long do your products last?”,
“answer”: “

Our products have a long shelf life, but they do all each include expiry dates. Please make sure to read what the expiry date is on each package, and enjoy before that! </p>”
}
},
“163763072583826343-3”: {
“type”: “content”,
“settings”: {
“title”: “Can I recycle the product packaging?”,
“answer”: “

All of our packaging is 100% recyclable. The mailers/shipping packaging is also 100% compostable – being environmentally friendly and sustainable is a top priority for us. </p>”
}
},
“163763072583826343-5”: {
“type”: “content”,
“settings”: {
“title”: “Are your products safe to consume while pregnant or bodyfeeding?”,
“answer”: “

Absolutely! There are no ingredients that would be harmful to either. However, if you are concerned, you may want to consult with your health care professional. </p>”
}
}
},
“block_order”: [
“163763072583826343-1”,
“163763072583826343-2”,
“163763072583826343-3”,
“163763072583826343-5”
],
“settings”: {
“title”: “Product information”,
“width”: “standard”,
“padding_top”: 25,
“padding_bottom”: 25,
“animation”: “none”,
“css_class”: “”,
“custom_css”: “”
}
},
“1663933474e82cbafd”: {
“type”: “index__faq”,
“blocks”: {
“16639334742ea32211-0”: {
“type”: “heading”,
“disabled”: true,
“settings”: {
“title”: “Section heading”
}
},
“16639334742ea32211-1”: {
“type”: “content”,
“settings”: {
“title”: “What is your question?”,
“answer”: “

Provide the answer to the question here.</p>”
}
},
“16639334742ea32211-2”: {
“type”: “content”,
“settings”: {
“title”: “What is your question?”,
“answer”: “

Provide the answer to the question here.</p>”
}
},
“16639334742ea32211-3”: {
“type”: “content”,
“settings”: {
“title”: “What is your question?”,
“answer”: “

Provide the answer to the question here.</p>”
}
},
“16639334742ea32211-4”: {
“type”: “heading”,
“settings”: {
“title”: “Section heading”
}
},
“16639334742ea32211-5”: {
“type”: “content”,
“settings”: {
“title”: “What is your question?”,
“answer”: “

Provide the answer to the question here.</p>”
}
},
“16639334742ea32211-6”: {
“type”: “content”,
“settings”: {
“title”: “What is your question?”,
“answer”: “

Provide the answer to the question here.</p>”
}
},
“16639334742ea32211-7”: {
“type”: “content”,
“settings”: {
“title”: “What is your question?”,
“answer”: “

Provide the answer to the question here.</p>”
}
},
“16639334742ea32211-8”: {
“type”: “image”,
“disabled”: true,
“settings”: {
}
}
},
“block_order”: [
“16639334742ea32211-0”,
“16639334742ea32211-1”,
“16639334742ea32211-2”,
“16639334742ea32211-3”,
“16639334742ea32211-4”,
“16639334742ea32211-5”,
“16639334742ea32211-6”,
“16639334742ea32211-7”,
“16639334742ea32211-8”
],
“settings”: {
“title”: “Specifications”,
“width”: “standard”,
“padding_top”: 25,
“padding_bottom”: 25,
“animation”: “none”,
“css_class”: “”,
“custom_css”: “”
}
},
“recommendations”: {
“type”: “product__recommendations”,
“settings”: {
“show_product_recommendations”: true,
“product_recommendations_style”: “slider”,
“product_recommendations_heading”: “You may also like”,
“products_per”: 3,
“recommended_products_limit”: 6,
“align_height”: false,
“collection_height”: 200,
“width”: “standard”,
“padding_top”: 20,
“padding_bottom”: 50,
“animation”: “fadeIn”,
“css_class”: “”,
“custom_css”: “”
}
}
},
“order”: [
“breadcrumbs”,
“main”,
“16376307254819e784”,
“1663933474e82cbafd”,
“recommendations”
]
}

Hi @RobMoore007 please share the product__main.liquid file code, not the JSON file.

here you go..

{% comment %}
** Product - main content area **

  • Product template
    {% endcomment %}

{% assign id = section.id %}
{% comment %} Layout {% endcomment %}
{% assign width = section.settings.width %}
{% assign padding_top = section.settings.padding_top %}
{% assign padding_bottom = section.settings.padding_bottom %}
{% assign animation = section.settings.animation | default: ‘none’ %}
{% comment %} Advanced {% endcomment %}
{% assign css_class = section.settings.css_class %}
{% assign custom_css = section.settings.custom_css %}

{% comment %} Section specific CSS {% endcomment %}
{% style %}
#shopify-section-{{ id }} {
padding-top: {{ padding_top }}px;
padding-bottom: {{ padding_bottom }}px;
{% if width == ‘wide’ %}
width: 100%;
{% endif %}
}

.section–has-sidebar-option.has-sidebar-enabled {
max-width: 900px;
{% if width == ‘wide’ -%}
width: 100%;
max-width: 95%;
{%- endif %}
}

.section–has-sidebar-option.has-sidebar-disabled {
width: 100%;
max-width: none;
}

{% render ‘css-loop’,
css: section.settings.custom_css,
id: section.id
%}
{% endstyle %}

{% liquid
assign selected_variant = product.selected_variant

if product.variants.size == 1 or settings.select_first_available_variant
assign selected_variant = product.selected_or_first_available_variant
endif
%}

{% render 'product', product: product, sold_out_options: settings.sold_out_options, selected_variant: selected_variant, width: width, css_class: css_class, display_thumbnails: section.settings.display_thumbnails, enable_product_lightbox: section.settings.enable_product_lightbox, enable_shopify_product_badges: section.settings.enable_shopify_product_badges, enable_thumbnail_slider: section.settings.enable_thumbnail_slider, enable_zoom: section.settings.enable_zoom, gallery_arrows: section.settings.gallery_arrows, product_height: section.settings.product_height, product_images_position: section.settings.product_images_position, set_product_height: section.settings.set_product_height, slideshow_transition: section.settings.slideshow_transition, stickers_enabled: settings.stickers_enabled, tag_style: settings.tag_style, thumbnail_position: section.settings.thumbnail_position, video_looping: section.settings.video_looping, %}

{%- for block in section.blocks -%}
{%- if block.type == ‘price’ -%}
{%- assign display_savings = block.settings.display_savings | json -%}
{%- endif -%}
{%- endfor -%}

{% comment %} JavaScript {% endcomment %}

{% comment %} Shopify-XR {% endcomment %}
{% if product.media %}

{% endif %}

{% schema %}

{
“name”: “Product information”,
“class”: “product-template product-main has-sidebar-option jsProduct section–has-sidebar-option”,
“settings”: [
{
“type”: “header”,
“content”: “Media”,
“info”: “Learn more about media types
},
{
“type”: “radio”,
“id”: “product_images_position”,
“label”: “Media position”,
“options”: [
{
“value”: “left”,
“label”: “Left”
},
{
“value”: “right”,
“label”: “Right”
}
],
“default”: “left”
},
{
“type”: “checkbox”,
“id”: “set_product_height”,
“label”: “Set height of product media”,
“default”: false
},
{
“type”: “range”,
“id”: “product_height”,
“label”: “Product media height”,
“min”: 200,
“max”: 800,
“step”: 10,
“default”: 500,
“unit”: “px”
},
{
“type”: “checkbox”,
“id”: “video_looping”,
“label”: “Enable video looping”,
“default”: false
},
{
“type”: “header”,
“content”: “Product gallery”
},
{
“type”: “checkbox”,
“id”: “gallery_arrows”,
“label”: “Show arrows”,
“info”: “Only applies to desktop”,
“default”: true
},
{
“type”: “checkbox”,
“id”: “enable_zoom”,
“label”: “Magnify on hover”,
“default”: true
},
{
“type”: “checkbox”,
“id”: “enable_product_lightbox”,
“label”: “Enable lightbox”,
“default”: true
},
{
“type”: “range”,
“id”: “slideshow_speed”,
“label”: “Gallery speed”,
“min”: 0,
“max”: 6,
“unit”: “sec”,
“default”: 0,
“info”: “Set to 0 to disable autoplay.”
},
{
“type”: “select”,
“id”: “slideshow_transition”,
“label”: “Gallery transition”,
“options”: [
{
“value”: “slide”,
“label”: “Slide”
},
{
“value”: “fade”,
“label”: “Fade”
}
],
“default”: “slide”
},
{
“type”: “checkbox”,
“id”: “display_thumbnails”,
“label”: “Show thumbnails”,
“default”: true
},
{
“type”: “select”,
“id”: “thumbnail_position”,
“label”: “Thumbnails position”,
“options”: [
{
“value”: “left-thumbnails”,
“label”: “Left of main image”
},
{
“value”: “right-thumbnails”,
“label”: “Right of main image”
},
{
“value”: “bottom-thumbnails”,
“label”: “Below main image”
}
],
“default”: “bottom-thumbnails”
},
{
“type”: “checkbox”,
“id”: “enable_thumbnail_slider”,
“label”: “Enable thumbnail slider”,
“default”: true
},
{
“type”: “header”,
“content”: “Layout”
},
{
“type”: “select”,
“id”: “width”,
“label”: “Width”,
“options”: [
{
“value”: “standard”,
“label”: “Standard”
},
{
“value”: “wide”,
“label”: “Wide”
}
],
“default”: “standard”
},
{
“type”: “range”,
“id”: “padding_top”,
“label”: “Top spacing”,
“min”: 0,
“max”: 80,
“default”: 20,
“unit”: “px”
},
{
“type”: “range”,
“id”: “padding_bottom”,
“label”: “Bottom spacing”,
“min”: 0,
“max”: 80,
“default”: 20,
“unit”: “px”
},
{
“type”: “select”,
“id”: “animation”,
“label”: “Animation”,
“default”: “none”,
“options”: [
{
“value”: “none”,
“label”: “None”
},
{
“value”: “fadeIn”,
“label”: “Fade in”
},
{
“value”: “fadeInDown”,
“label”: “Fade in down”
},
{
“value”: “fadeInLeft”,
“label”: “Fade in left”
},
{
“value”: “fadeInRight”,
“label”: “Fade in right”
},
{
“value”: “slideInLeft”,
“label”: “Slide in left”
},
{
“value”: “slideInRight”,
“label”: “Slide in right”
}
]
},
{
“type”: “header”,
“content”: “Advanced”,
“info”: “Learn more
},
{
“type”: “text”,
“id”: “css_class”,
“label”: “CSS Class”
},
{
“type”: “textarea”,
“id”: “custom_css”,
“label”: “Custom CSS”
}
],
“blocks”: [
{
“type”: “@app
},
{
“type”: “title”,
“name”: “Title”,
“limit”: 1
},
{
“type”: “vendor”,
“name”: “Vendor”,
“limit”: 1
},
{
“type”: “price”,
“name”: “Price”,
“limit”: 1,
“settings”: [
{
“type”: “checkbox”,
“id”: “display_savings”,
“label”: “Show price savings”,
“default”: true
}
]
},
{
“type”: “rating”,
“name”: “Product rating”,
“limit”: 1,
“settings”: [
{
“type”: “paragraph”,
“content”: “To display a rating, add a product rating app. Learn more
}
]
},
{
“type”: “sku”,
“name”: “SKU”,
“limit”: 1
},
{
“type”: “text”,
“name”: “Text”,
“settings”: [
{
“type”: “richtext”,
“id”: “text”,
“label”: “Text”,
“default”: “

Text block


}
]
},
{
“type”: “description”,
“name”: “Description”,
“limit”: 1
},

{
“type”: “form”,
“name”: “Form”,
“limit”: 1,
“settings”: [
{
“type”: “header”,
“content”: “Dynamic Checkout Button”
},
{
“type”: “checkbox”,
“id”: “show_payment_button”,
“label”: “Show dynamic checkout button”,
“info”: “Each customer will see their preferred payment method from those available on your store, such as PayPal or Apple Pay. Learn more”,
“default”: true
},
{
“type”: “paragraph”,
“content”: “Customize additional form features for the product in Theme settings > Product form.”
}
]
},
{
“type”: “product-links”,
“name”: “Product links”,
“limit”: 1,
“settings”: [
{
“type”: “checkbox”,
“id”: “show_collections”,
“label”: “Show collections”,
“default”: true
},
{
“type”: “checkbox”,
“id”: “show_types”,
“label”: “Show types”,
“default”: true
},
{
“type”: “checkbox”,
“id”: “show_tags”,
“label”: “Show tags”,
“default”: true
}
]
},
{
“type”: “share”,
“name”: “Share”,
“limit”: 1
},
{
“type”: “size-chart”,
“name”: “Size chart”,
“limit”: 1,
“settings”: [
{
“type”: “text”,
“id”: “title”,
“label”: “Label”,
“default”: “Size chart”
},
{
“type”: “page”,
“id”: “size_chart”,
“label”: “Size chart”,
“info”: “Learn more
}
]
}
],
“default”: {
“settings”: {

}
}
}

{% endschema %}

where you are showing the metafield?

On the default product page template

please share page link

Here you go

https://mygroovyplace.myshopify.com/collections/washing-machines/products/washing-machine-test-2?variant=42602137452703

passwd: ohtrow

how did you add these meta fields to the product page? did you add them direct in JSON file?

No I used the add dynamic source..

Please share the code of product.liquid file and the screenshot of meta fields settings page from admin dashboard

Here is the best way I used to solve this problem:

Step 1: Add “Custom liquid/Custom HTML” block instead of Text block.

Step 2: Go to Dashboard → Settings → Custom data → Products

Step 3: See all the keys generated to access your metafields example: “product.metafields.custom.gemstone_size”

Step 4: Go to Dashboard → Customize

Step 5: Go to product or any other page where you are displaying metafields (in my case I need on product page)

Step 6: For individual metafields to display, just add “Custom liquid” block and put the conditions like this:

{%- if product.metafields.custom.gemstone_size != blank -%}
Gemstone size (cm): {{ product.metafields.custom.gemstone_size }}
{%- endif -%}

In your case the keys for displaying metafields will be different. For each metafield to display you need as many “Custom liquid” blocks and need to put conditions accordingly.

Hope! I answered the question.

Thanks