简体   繁体   中英

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?

Remove the internal braces:)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM