Re: HTML in Metafield

How can I properly render HTML in a product metafield?

linpin
Tourist
4 0 1

I'm trying to add a list of text to a metafield for a product and when I add it as HTML, it doesn't render it properly on the front end. Other posts have solved this problem by using a single line text metafield rather than a multi line metafield. But i've created a new one, plugged in some HTML, and it still displays as straight html. 

See screenshot.

Any guidance would be appreciated.

 

screen 1.png

Replies 10 (10)

LitCommerce
Astronaut
2860 684 752

Hi @linpin,

Text won't support this, you can just change it to "Reference Page". https://i.imgur.com/ZN7kVQX.png

Then you create pages and select it in products. Finally, you just need to get it with the content of the page, it will work fine with HTML.

Code: {{ product.metafields.my_fields.namespace.value.content }}

Hope it helps!

LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool.
Effortlessly sell on biggest marketplaces like Amazon, Etsy, eBay, Facebook etc with bulk listing tool, real-time sync & smart order management. Use LitCommerce free for 1-year now!
linpin
Tourist
4 0 1

Hi @LitCommerce 

 

But does that solution mean that i need to create a page for every product given that the product details are different for every product? That seems cumbersome...I thought the point of the metafields was exactly for the purpose i'm describing. 

 

Thanks for your help.

 

Lindy

LitCommerce
Astronaut
2860 684 752

Hi @linpin,

Or you can create metafields as 'Multi-line text': https://i.imgur.com/18DLCjt.png

Then you just need to enter the html for it, everything will display fine: https://i.imgur.com/4NLVCzT.png

Hope it helps!

LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool.
Effortlessly sell on biggest marketplaces like Amazon, Etsy, eBay, Facebook etc with bulk listing tool, real-time sync & smart order management. Use LitCommerce free for 1-year now!
linpin
Tourist
4 0 1

Hi Litcommerce

 

I've tried both single and multi line metafields and it doesn't work for either. I've used an online html generator to make sure i've got the code correct and it's still displaying html.

My theme is 2.0.

Any other ideas?

 

Thanks so much for replyingUntitled.png

Lindy

LitCommerce
Astronaut
2860 684 752

Hi @linpin,

Can you send me the code of Metafield you enter or create a staff account.

I will check it. Because I checked 'Multi-line text' and it works fine.

 

LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool.
Effortlessly sell on biggest marketplaces like Amazon, Etsy, eBay, Facebook etc with bulk listing tool, real-time sync & smart order management. Use LitCommerce free for 1-year now!
LitCommerce
Astronaut
2860 684 752

Hi @linpin,

I checked and metafield when added by Customize it wont work well. So you need to add it directly to the code.

https://i.imgur.com/kgY3lu1.png , https://i.imgur.com/ow1wP51.png 

Hope it is clear to you.

If it helped you solve your issue, please mark it as a solution. Thank you and good luck.

LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool.
Effortlessly sell on biggest marketplaces like Amazon, Etsy, eBay, Facebook etc with bulk listing tool, real-time sync & smart order management. Use LitCommerce free for 1-year now!
tclapmarketing
Shopify Partner
14 0 7

Hi @LitCommerce,

 

How can I make this exact fix in the product liquid but for the theme "Dawn"?

 

Thank you,

Thomas

Thomas C.
Operations
blankcanvasbookstore.com
thomas@blankcanvasbookstore.com
LitCommerce
Astronaut
2860 684 752

Hi @tclapmarketing,

You can create a question on the community and send me the link. I will check it.
Because this will help build a better community.
Thank you.

LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool.
Effortlessly sell on biggest marketplaces like Amazon, Etsy, eBay, Facebook etc with bulk listing tool, real-time sync & smart order management. Use LitCommerce free for 1-year now!

meo_me
Excursionist
20 0 13

Hi @linpin did you find a solution for that?

MRamzan
Shopify Partner
392 3 36

You can display HTML using metafield.

 

Hire Me:

WhatsApp: +91-9145985880
Email: mohdramzaan112@gmail.com
Skype: mohdramzaan112