In my Shopify theme I wish to display the value of a metafield. The key for this metafield is the string "prod_" joined with the product type.
Let's imagine that the product is a sofa. I can display the value of this metafield by simply using the metafield's name as a text string.
{{product.metafields.global["prod__sofa"]}}
I however wish to replace the "sofa" part of the string with the value of the field.
To do this I can create a variable called "type"
{% assign type = product.type %}
I am now however finding it difficult to use the variable "type" and the text string to look up the metafield.
My issue is in joining them together, I have used both a "+" and "&", but this does not work.
{{product.metafields.global["prod__" & type]}}
{{product.metafields.global["prod__" & type]}}
Am I joining the variable and string together incorrectly or is this simply not possible?