Dispaly the contets of json metafield in main-order.liquid

4 0 0

Hi Guys
I have a json metafield added to orders by an app and it's easy to display it's contents in the checkout scripts for example so I know it works. But in main-order.liquid I can see it's contents as string but it does not parse as json and I'm not able to show it in the same way. Any idea?

Here is the code:


{% if order.metafields.xchange.licenses %}  
<table BORDER=”1″ >
		<tr style="background-color:#f0f0f0">
			<th style="text-align:left; padding-left: 5px;">Product</th>
			<th style="text-align:left">Serial</th>
			<th style="text-align:left">Download</th>
		{% for license in order.metafields.xchange.licenses %}
				<td style="text-align:left; padding-left: 5px;">{{license.product}}</td>
				<td style="text-align:left">{{license.serial}}</td>
				<td style="text-align:left"><a href="{{license.download}}">{{license.download}}</a></td>
		{% endfor %}
{% else %}
<strong>Please wait while we generate your license key </strong><br>
You may need to refresh the browser page (F5)
{% endif %}

Here is how it looks like when it working:


Product Serial Download

Test ProductDUMMY_LICENSE_638270898649923327https://koolsoftware.com/activate/®


Now in main-order.liquid if I dispaly it like this:





{{ order.metafields.xchange.licenses }}





It looks:

[{"product":"Test Product","serial":"DUMMY_LICENSE_638270898649923327","download":"https://koolsoftware.com/activate/®"}]


But the same code above does not print the table and never goes into the 'for' loop. I'm guessing it turned into a 'string' but it makes no sense to me. 

Any advice?

Replies 0 (0)