Conversations about creating, managing, and using metafields to store and retrieve custom data for apps and themes.
Hello,
I have a metafield with a "/" character in key name. Everything is ok accessing it via REST but how to access it via liquid?
Hi Ios14,
It's not possible to access a metafield via liquid if it contains a "/" character in the key name. This is due to the fact that the "/" character is treated as a path separator in Liquid and is not valid in variable names. It's recommended to avoid using special characters like "/" in metafield keys to ensure compatibility with all parts of Shopify's system, including Liquid.
You may need to rename your metafield key to something without the "/" character to be able to access it via Liquid. For example, you might change "A/C" to "AC" or "A_C". Then you would access it via Liquid, eg:
product.metafields.global.AC
product.metafields.global.A_C
Please note that renaming the metafield key will require updating any existing data or code that references the old key name.
Hope this helps!
Liam | Developer Advocate @ Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit Shopify.dev or the Shopify Web Design and Development Blog