Adam Scot
Adam Scot

Reputation: 1409

Assign a liquid object to a variable in Shopify

In Shopify I am declaring a variable like this:

{% assign favourites = hello %}

Instead of the variable being `hello, I want to use a metafield from my product. I can get the metafield like this:

{{ product.metafields.global["other_options"] }}

I can't, however, merge the two together like this

 {% assign favourites = {{ product.metafields.global["other_options"] }} %}

I have tried wrapping the liquid object in single and double quotation marks but this doesn't work.

Is it possible to do this?

Upvotes: 0

Views: 1998

Answers (1)

Rick Davies
Rick Davies

Reputation: 733

Remove the internal braces :)

{% assign favourites = product.metafields.global["other_options"] %}

Upvotes: 4

Related Questions