Problem implementing a metafield to a collapsible row

orhl1234
Shopify Partner
47 0 0

I created a metafield with a file as a content type. I want to put it in a collapsible row, and as I know it's impossible, I added a liquid section to the collapsible row(see the image below).
But for some reason, the code doesn't work and I can't see the file.

{% if product.metafields.custom.assemble_instruction_guide.value != blank %}
{{product.metafields.custom.assemble_instruction_guide | file_url }}
{% endif %}

P.S. This code worked for someone I saw on the internet.

 

orhl1234_0-1712135113237.png

i added the option to add liquid to metafild by myself from the internt.

Myaby the way it was done is the problem.

here's how I did that:

orhl1234_1-1712135577731.png

 

 

Replies 2 (2)

Xipirons
Shopify Partner
136 24 29

Hi @orhl1234 

 

Here are a few things to check and try:

 

1. Make sure the metafield is properly defined and has a value assigned for the specific product. Double check that the namespace is "custom" and the key is "assemble_instruction_guide" for the metafield.

2. Instead of using `product.metafields.custom.assemble_instruction_guide.value`, try accessing the metafield directly like this:

 

{% if product.metafields.custom.assemble_instruction_guide != blank %}
{{ product.metafields.custom.assemble_instruction_guide | file_url }}
{% endif %}

 

3. If the above doesn't work, try using the `file_url` filter directly on the metafield without checking for blank[10][16]:

 

{{ product.metafields.custom.assemble_instruction_guide | file_url }}

4. Make sure the `file_url` filter is being used correctly. It should be applied directly to the metafield to generate the CDN URL for the file.

5. Verify that the collapsible row is set up correctly to display the custom liquid content. The `{{ block.settings.custom_liquid }}` should be placed inside the `<div class="accordion__content">` section of the collapsible row.

6. If none of the above works, try using the `file_img_url` filter instead, which allows you to specify dimensions for the file:

 

{{ product.metafields.custom.assemble_instruction_guide | file_img_url: '800x800' }}

 

If you've checked all these points and the file still doesn't display, there might be an issue with how the collapsible row or section is implemented in your theme. I recommend double-checking the theme code and settings.

Was this helpful? Like or Accept solution - Buy me a coffee
- Contact me: Xipirons | WhatsApp
- Shopify Developer based in France, helping online merchants succeed

orhl1234
Shopify Partner
47 0 0

could you maybe help me with that? 

it didn't work what you tried helping me. and above is the way I added the liquid to the metafild

orhl1234_0-1712219170838.png