Liquid, JavaScript, themes, sales channels
Recently Shopify released the ability to create Metafield Definitions for a List of Values. The content of these metafields is an iterable and accessed via the value property.
This works for most of the new content types. However some of the content types return either null or throw an internal error.
I've put together an exhaustive table of all the metafield list types and whether they work property or are broken. The code below the table can be used to recreate the issue. (with appropriately created metafield definitions)
list.weight (bug: meta.value throws internal error) list.volume (bug: meta.value throws internal error) list.dimension (bug: meta.value throws internal error) list.page_reference (bug: meta.value is null) list.rating (bug: meta.value throws internal error) list.date (works) list.date_time (works) list.number_integer (works) list.number_decimal (works) list.product_reference (works) list.single_line_text_field (works) list.color (works) list.file_reference (works) list.url (works)
<!-- # WORKING EXAMPLES - where metafield.value returns a list of values list.single_line_text_field: json: {{ product.metafields.specs.textsingle_list.value | json }} el: {{ product.metafields.specs.textsingle_list.value[0] | json }} str: {{ product.metafields.specs.textsingle_list | prepend: "" }} # FAILING EXAMPLES - where metafield.value returns either null or throws an error list.page_reference: json: {{ product.metafields.specs.pageref_list.value | json }} el: {{ product.metafields.specs.pageref_list.value[0] | json }} str: {{ product.metafields.specs.pageref_list | prepend: "" }} list.rating_list: json: {{ product.metafields.specs.rating_list.value | json }} el: {{ product.metafields.specs.rating_list.value[0] | json }} str: {{ product.metafields.specs.rating_list | prepend: "" }} -->
<!-- # WORKING EXAMPLES - where metafield.value returns a list of values list.single_line_text_field: json: ["cat","dog"] el: "cat" str: ["cat","dog"] # FAILING EXAMPLES - where metafield.value returns either null or throws an error list.page_reference: json: "" el: null str: ["gid://shopify/OnlineStorePage/88645664920","gid://shopify/OnlineStorePage/91070595224"] list.rating_list: json: Liquid error: internal el: Liquid error: internal str: [{"scale_min":"0.0","scale_max":"5.0","value":"1.0"},{"scale_min":"0.0","scale_max":"5.0","value":"3.0"}] -->
Converting the entire metafield to a String via prepend "" was done to show that the metafield is in fact not empty. Unfortunately this is not useful when actually trying to iterate over the metafield contents.
User | RANK |
---|---|
33 | |
27 | |
18 | |
9 | |
9 |
We're excited to announce improvements to the threaded messaging experience in our communi...
By TyW May 31, 2023Thank you to everyone who participated in our AMA with Klaviyo. It was great to see so man...
By Jacqui May 30, 2023Photo by Marco Verch Sales channels on Shopify are various platforms where you can sell...
By Ollie May 25, 2023