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;
}
Hey Community! As the holiday season unfolds, we want to extend heartfelt thanks to a...
By JasonH Dec 6, 2024Dropshipping, a high-growth, $226 billion-dollar industry, remains a highly dynamic bus...
By JasonH Nov 27, 2024Hey Community! It’s time to share some appreciation and celebrate what we have accomplis...
By JasonH Nov 14, 2024