Custom Data PDF file upload link

Hi all. I’m using a Custom Data field to allow my client to upload a PDF file each product on their Shopify store. The file is going to be downloadable from each product page.

I’ve managed to get it all working from the product admin page. However, I am stuck in how to create a link to this file on each Product page.

I need help in determining what the URL will be for each PDF. I can then assign this to a button to allow their customers to click to download the PDF.

Thanks in advance for any help given.

Nigel

1 Like
{{ 'size-chart.pdf' | file_url }}

This is what would create a link.

File name, of course, would be different.

Link itself would look like this:

 DOWNLOAD PDF 

Thanks for getting back to me on this one. The issue I have is that I’m trying to dynamically add a button link to the theme template so it automatically adds the right PDF file link for each product once it is uploaded via the Custom Data field. I can’t work out how to determine what the actual URL will be for each PDF that is uploaded.

If you know that file will be assigned for each product AND there is a logic in how files are named, then it saves you a whole lot of work.

Say, file names are product SKUs, then first you need to create a variable with the product SKU and add .pdf to it.

{% assign our_product_sku == variant.SKU %}
{% assign our_file_name = our_product_sku | append: .pdf %}

So now we have variable that consists of the file name corresponding to the product. Now the link to the file will look like this:

 DOWNLOAD PDF 

All this works in case if files are uploaded into Files / Content.

How does that work if the file name is going to be different for every PDF uploaded on each product page though? The PDF titles are going to unique every time one is uploaded.

In your themes files you dont have a separate templates for each product, right? It`s just a template. So when we assign a variable with the product SKU, this variable will… vary, depending on which product page you are looking at right now. So this code is universal and will adapt to every product and file.

You’re correct, I only have the one Product Template page on the theme they are using.

I still cannot get my head around how the liquid code used will know what the file name is for each unique PDF that is uploaded on each product page.

I’ve recorded this short video to show you what I am doing as I’m not sure if you understand the issue I think I have: https://share.vidyard.com/watch/YTMLizkHKdFTQ93mUgkiwc?

It works same way as it takes colour or book type from your metafields.

Have you tried it yet?

Another solution might be to use this line instead of what you have:

Download

Tried that but the URL for the file doesn’t appear to be correct…

Alright, we are getting somewhere. Try adding your website first then:

Download

Like this.

I would still recommend to try the first variant, tho.

Neither seem to work. It’s just not pulling in the right URL for the PDF in the Files section of the store.

There is not much information regarding metafields and on how to call them, yet I would try another variant:

Download

If this wont work, them I am sorry, cant help you otherwise.

Thanks for you help. That didn’t work either.

I appreciate you trying to help me with this one. I’ll get on to Shopify Support to see if they can shed any light on this.

Hi @Nigel_Burke ,

Based on my understanding of your request, I believe that the free Ease Product Attachments app is a great solution for your needs.

With this app, you can easily upload multiple PDF files (or other file formats) and assign them to specific products, collections, or all items.

Additionally, you can create a section or block on the product page to display the downloadable files, (by adding the file section/ block to the current product page template).

As a result, when customers visit a product page, they will be able to conveniently access the related downloadable file that has been already assigned to that particular product.

To give you a better idea of how this works, please refer to the attached screenshot below:

The best part about the Ease Product Attachments app is that it is completely free and user-friendly, making it a great option for individuals who may not have extensive technical expertise.

Hope that this information is helpful to you :blush: !