Shopify themes, liquid, logos, and UX
I want to add a collapsible row to my product template, then fill that with a link to download a pdf that is assigned to the product via metafields. I also want to hide any empty collapsible rows that are empty.
I added a liquid field to the collapsible row, and then added code in there to add the download link via the metafield. The problem is the metafield is empty and the liquid field is not, so the collapsible row is never empty. It just has a link that doesn't go anywhere if the metafield is empty.
What would be the easiest way to have the link go to the file in the metafield but hide it if there is no file in the metafield?
This is an example of a product that has a growing guide. https://8c4caf-34.myshopify.com/products/lettuce-bibb
This product does not have a growing guide. https://8c4caf-34.myshopify.com/products/vegetables-romanesco-puntoverde
{% if product.metafields.my_fields.download_pdf != blank %}
////your html code start like any div tag <div>
{{ if product.metafields.my_fields.download_pdf }}
////your html code end like any div tag close </div>
{% endif %}
you need to add a check for your metafield. If the metafield empty then you html or collapse content will be not visible like below example code.
Do let me know if you want me to help you in this step by step.
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025