Re: Metafield Type File

Metafield Type File

buyifyyebay
Tourist
10 1 5

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. 

Replies 3 (3)

Savior
Shopify Partner
537 108 161

@buyifyyebay 

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

banned

Scott-WebWizard
Shopify Partner
8 0 6

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 -%}

 

 

EaseApps
Shopify Partner
1 0 1

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:

 

add pdf files to shopify.png

 

Notes: The block title, file icon, and block position can be easily customized as you want 😄.

Let us know if this solution was helpful by giving it a like or marking it as a solution!
Ease Product Attachments - The free Shopify app that makes adding PDF files (or any other file format) to your product page effortless!