metafield string to object

Donfetto
Tourist
5 0 1

Hi there,
I am retreiving a metafield like so:

{% assign foo = order.metafields.bar.service %}

If I output the metafield like this: <p>{{foo}}</p
 
the following is displayed:
{"service_code":"A2P","pickup_id":"90325863","address_1":"32 some street","zip":"234","city":"Berlin","country_code":"DE"}
 
My question is: How can I access the keys directly. Like {{foo.service_code}} ?
Is there a way to turn this string into some kind of Liquid Object? What is the best way to do it?
 
I could do this via Javascript but as I also have to display the metafield information in Email notifications, so I am looking for a pure Liquid version to do this.
 
Thank you for your help!
 

 

Replies 2 (2)
24by7themes
Navigator
389 61 73

See below issue, may it useful.

https://github.com/Shopify/liquid/issues/432

Shopify Plus Expert, Quality Service Provider, CONTACT ME for any kind of solutions.
Please like and accept solution. SKYPE -> live:gp21111990
LitExtension
Shopify Partner
1965 328 402

Hi @Donfetto ,

You can try with code:

{% assign foo = order.metafields.bar.service %}
{{ foo['service_code'] }}


Hope it helps!

LitExtension - #1 Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!