A quick post here as I had to reach out to Shopify Plus support to get this answer. Shopify docs and .dev Assistant both failed me :(
I was trying to reference a Shopify Market metafield in Liquid. Market metafields replace the previous handy SHOP owner_type metafields. They are different, but I dig them as they allow you to segment markets within the same store, changing pricing, products, merchandising etc.
However, the Shopify docs didn't work for me and it looks like I haven't been the first to look into this issue.
Here was my question:
How do I reference a Markets metafield via liquid, specifically for a Market?
Here's what the .dev Assistant responded with
{{ market.metafields['namespace']['key'] }}
However, try as I may, this wouldn't work for me.
I reached out to Shopify Plus Support and they seemed to struggle with it also. The solution finally came with:
{{ localization.market.metafields.namespace.key }}
Although the store I'm working on only has one published language, it may be due to the unpublished language that triggers the requirement for localization
.
Regardless, probably best to have additional languages of course, but I wish the shopify.dev docs reflected this.
Also, you'll notice that the Shopify reference uses "bracket" notation, while I use "dot" notation. This is because the Shopify Theme CLI automatically changes bracket notation to dot notation.
¯(ツ)/¯