How to pass a variable to file_url

Solved
rpaulpen
Tourist
6 0 2

Hi folks,

I'm trying to pass the product.id to file_url so I get something like this:

<button class="specbutton specbutton-specs", onclick=window.open("{{'theDerivedProductIdHere.pdf' | file_url }}")>Spec Sheet</button>

I want the 'theDerivedProductIdHere.pdf' to be a concatenation of product.id of the current page plus '.pdf'.  I thought it might be something like 

onclick=window.open("{{product.id'.pdf' | file_url }}")>Spec Sheet</button>

 

 

 but that doesn't work.  

 

Any help would be appreciated.

RP

0 Likes
Michal_Morek
Shopify Partner
820 73 140

This is an accepted solution.

Hi @rpaulpen 

Hope you're having a great day!

I'm sorry for your inconvenience.

Try with append filter:

onclick=window.open("{{ product.id | append: '.pdf' | file_url }}")>Spec Sheet</button>

 If you found this comment useful, hit the 'Like' and 'Accepted solution' buttons.

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425
rpaulpen
Tourist
6 0 2

Hello,

Thanks for the reply.  Yes, I used the append filter but did it in 2 steps.  I will have to try in 1 line like you've done.

 

Thanks,

RP

0 Likes
Michal_Morek
Shopify Partner
820 73 140

Hi @rpaulpen 

You're welcome. Always happy to help.

Check it out and get back to me.

 If you found this comment useful, hit the 'Like' and 'Accepted solution' buttons.

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425
0 Likes
rpaulpen
Tourist
6 0 2

Thanks.  Worked.

0 Likes
Michal_Morek
Shopify Partner
820 73 140

Hi @rpaulpen 

Hope you're having a great day!

You're welcome. Always happy to help.

Good luck.

Founder of Shopify agency - Accomplishify.com
If you would like to hire us as Shopify experts, please reach out via:
  • Email michal.morek@accomplishify.com
  • WhatsApp +48 507 613 425
0 Likes