A space to discuss online store customization, theme development, and Liquid templating.
I am adding a Metafield Type File to my Product Page. ( Uploading a User Manual PDF File that visitors can download. Condition: Display the link if there is a value / Don't display if there is no value. I want to have the field displayed when there is a file added to my Metafield field. I don't want to have the field displayed when there is not a file added to my Metafield.
I am currently using :
<a href="{{ product.metafields.my_fields.user_manual | file_url }}">Download</a>
I tried the following and doesn't work.
{%- assign file_usermanual = product.metafields.my_fields.user_manual | file_url -%}
{%- if file_usermanual != blank -%}
<div><a href="{{ product.metafields.my_fields.user_manual | file_url }}">Download</a></div>
{%- endif -%}
I think it's a normal feature to have : Download Link visible if there is a User Manual Saved / Not visible if no User Manual is present.
Please try adding like this
{%- assign file_usermanual = product.metafields.my_fields.user_manual -%}
{%- if file_usermanual != blank -%}
<div><a href="{{ file_usermanual | file_url }}">Download</a></div>
{%- endif -%}
If helpful then please Like and Accept Solution. Want to modify or custom changes on store Hire me. Feel free to contact me on shopify.dev.34@gmail.com | Shopify Design Changes | Custom Modifications In to Shopify Theme
Thanks , will try
Instead of
<a href="{{ product.metafields.my_fields.user_manual | file_url }}">Download</a>
try
{%- if product.metafields.my_fields.user_manual.value.url != blank -%}
<a href="{{product.metafields.my_fields.user_manual.value.url }}">Downlaod</a>
{%- endif -%}
Hi @buyifyyebay ,
If you're having trouble finding a way to upload your user manual PDF files to your products, I have a simple and effective solution for you! All you need to do is install the Free Ease Product Attachments App.
Once you've installed the app, you'll be able to easily upload your user manual PDF files and assign them to specific products or all products. Plus, you can create a block of your files in the Product Information section under the product description, giving your customers easy access to the information they need.
The best part is that it's incredibly simple to use, and you don't have to create any metafield.
I'm confident that this app will help you solve your problem once and for all 😊.
To give you a better idea of what this app can do, take a look at the example below:
Notes: The block title, file icon, and block position can be easily customized as you want 😄.