Re: Displaying Metafield Data in Custom HTML block

Solved

Displaying Metafield Data in Custom HTML block

CGS-PDigital
Shopify Partner
7 1 1

I am using the Shopify Empire theme for my store, https://cozyglowstoves.com.  I'm currently working on adding a multi-line text metafield section into a HTML custom block on my product page for a certain template. I've done this before without issue. I've created the metafield, but when I go to enter it into the HTML block using {{ product.metafields.custom.3d_animations }} I get the error, "Setting 'custom_html' can't include Liquid syntax ('{{', '}}', '{%' or '%}') without valid dynamic sources." There is data in the metafield for the products tied to this product template. I've even tried modifying per ChatGBT's suggestion using {{ product.metafields.custom.3d_animations | raw }} and it still returns the same error.

 

As a test, I took a similar coding that is currently working on another block, {{
product.metafields.custom.product_videos.value }}, pasted it into the new block, and it's returning an error as well.

 

I then tried even entering in {{ product.description }}, and once again still getting the "Setting 'custom_html' can't include Liquid syntax ('{{', '}}', '{%' or '%}') without valid dynamic sources." error.  

 

Again, there is data in the metafield... so I can't understand what's going on. Especially since I have similar code working on the same product template already.

 

Can anyone shed some light on this issue???

 
 
Accepted Solution (1)
CGS-PDigital
Shopify Partner
7 1 1

This is an accepted solution.

I figured it out. I had two issues.

 

One: Apparently Shopify does not like numeric values when you're naming metafields. When I was trying to enter {{ product.metafields.custom.3d_animations }} it didn't like it because of the value "3". When I renamed it to artificial reality coding I finally got it to work.

 

Two: Apparently you cannot use {{ in custom HTML blocks. When I changed the block type to a custom liquid block I was finally able to get it to display.

 

Thank you for the help though!

View solution in original post

Replies 4 (4)

PaulNewton
Shopify Partner
7722 678 1627

Hi @CGS-PDigital 👋 Is the "HTML custom" block setting type set to liquid?

 

Try the code in a custom section that accepts liquid to validate the logic.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org


CGS-PDigital
Shopify Partner
7 1 1

When I insert a new "custom liquid" block using {{ product.description }} and {{ product.metafields.custom.product_videos.value }}, it works.

 

But still no luck using, {{ product.metafields.custom.3d_animations }}, {{ product.metafields.custom.3d_animations.value }}, or even {{ product.metafields.custom.3d_animations | raw }}.

 

It's boggling my mind:

 

CGSPDigital_0-1734055214465.png

 

CGS-PDigital
Shopify Partner
7 1 1

This is an accepted solution.

I figured it out. I had two issues.

 

One: Apparently Shopify does not like numeric values when you're naming metafields. When I was trying to enter {{ product.metafields.custom.3d_animations }} it didn't like it because of the value "3". When I renamed it to artificial reality coding I finally got it to work.

 

Two: Apparently you cannot use {{ in custom HTML blocks. When I changed the block type to a custom liquid block I was finally able to get it to display.

 

Thank you for the help though!

PaulNewton
Shopify Partner
7722 678 1627

File a feature request either with a support advisor or through the partner support or on the community.shopify.dev, or all three 😏.

There's probably a blurb somewhere about starting mf names|keys with numbers but the error messages created a misleading rabbit hole for you to stumble through.

Contact paull.newton+shopifyforum@gmail.com for the solutions you need


Save time & money ,Ask Questions The Smart Way


Problem Solved? ✔Accept and Like solutions to help future merchants

Answers powered by coffee Thank Paul with a Coffee for more answers or donate to eff.org