Shopify themes, liquid, logos, and UX
I have a featured products section on my product pages for complete the look. I have set up a product metafield so you can select which items pair with a product. Which works however I want the section to be hidden if the meta field is blank. I have tried this code on a custom liquid section in customiser but it only hides the section for all products (including the ones where the metafield has been filled in)
{% if product.metafield.custom.complete_the_look_products == blank %}
<style>
#shopify-section-template--23961742377309__featured_products_8BPVfh {
display: none;
}
Store url: https://really-wild-clothing-company.myshopify.com/products/isabella-cropped-wool-blend-boucle-jacke...
this doesn't work either:
{% if product.metafield.custom.complete_the_look_products != blank %}
<style>
#shopify-section-template--23961742377309__featured_products_8BPVfh {
display: block; /* Ensure it displays if products are present */
}
</style>
{% else %}
<style>
#shopify-section-template--23961742377309__featured_products_8BPVfh {
display: none; /* Hide if no products are present */
}
</style>
{% endif %}
Since it's a list, i guess you can't really compare it to a blank -- this is for strings, you should check size.
But at least you can do this:
.section-featured-products {
display: none;
}
.section-featured-products:has(product-card) {
display: block;
}
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025