Hi, I have been creating a product page, and I need to implement download functionality for PDFs that each product might or might not have, its an optional field.
What I need to somehow figure out is how to display and make it possible for customers to download my uploaded PDFs?
I was able to display this:
[“gid://shopify/GenericFile/54152549746”,“gid://shopify/GenericFile/54152527282514”]
”metafield exists and not empty”
{% if product.metafields.custom.ke_stazeni %}
metafield exists and not empty
{% else %}No data in the metafield.
{% endif %}
{% assign ke_stazeni_files = product.metafields.custom.ke_stazeni %}
{{ product.metafields.custom.ke_stazeni }}
Which confused me even more.
Tried to access the file_url, did not work as well.
{% if product.metafields.custom.ke_stazeni.size > 0 %}
<div class="product-documents">
<h3>Ke stažení</h3>
<ul>
{% for file in product.metafields.custom.ke_stazeni %}
<li>
<a href="{{ file | file_url }}" download="{{ file.filename }}">
{{ file.filename }}
</a>
</li>
{% endfor %}
</ul>
</div>
{% else %}
<p>No documents available for download.</p>
{% endif %}
The slug is correct to the metafield.
I was wondering if anyone was facing similar issue? Thanks for any inputs.