Ad

Assign A Liquid Object To A Variable In Shopify

- 1 answer

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?

Ad

Answer

Remove the internal braces :)

{% assign favourites = product.metafields.global["other_options"] %}
Ad
source: stackoverflow.com
Ad