Log in Sign up
Discussion Shopify

How do I access Metafields in a .js file for my custom section?

Tom Security
Tom Security
0 reputation
2 weeks ago 103 views 3 replies
Been struggling with this for a bit. Any suggestions?

Question: How do I access Metafields in a .js file for my custom section?

2 Replies

Jake Project
Jake Project · 2 weeks ago
Assign the metafield to a JavaScript variable inside a `<script>` tag in your liquid section file: `const metaValue = {{ product.metafields.custom.data | json }};`.
Robert Hosting
Robert Hosting · 2 weeks ago
You can't access Liquid objects directly in a .js asset file.

You must be logged in to reply.

Log In to Reply