Hello all,
We are migrating specifications for hundreds of products, and am trying to display the following metafield
product.metafields.productDetails.brightness
within HTML in a multitext field (I’ve tried single-text and rich-text too):
| Maximum Brightness | {{product.metafields.productDetails.brightness}} |
| - | - |
And in my code, I have
{{ product.metafields.productDetails.specifications.value}}
However, I can’t get the metafield to display its value; it just displays product.metafields.productDetails.brightness. Is there a way to display it within a multitext/rich text/single text metafield?
Thanks in advance!
I think you might need to save “specifications” as a JSON type metafield: https://shopify.dev/docs/apps/custom-data/metafields/types
Then you can access it as follows:
{% assign specifications = product.metafields.productDetails.specifications %}
{% assign parsed_specifications = specifications | json_parse %}
And use the following to access “value” in specifications
{{ parsed_specifications.value }}
Please check; I haven’t tested it
tim_1
March 19, 2024, 2:41pm
3
This depends on whether your metafields are legacy or new ones.
Legacy metafields do not have value property.
https://shopify.dev/docs/api/liquid/objects/metafield#metafield-deprecated-metafields
You should be able to migrate legacy metafields to modern by adding metafield definitions in Settings → Custom data