Using liquid variable in checkout script

Solved
Tourist
7 0 0

I am using a third party service for invoice generation. It generates a URL where Users can download the invoice. The URL is saved as a Liquid Variable: {{metafields.invoice.url}}

 

I am trying to add a content box to the order status page that allows the user to download the invoice from there.

 

What do I have to do in order to be able to include the liquid variable as the URL into a HTML link? See my poor, non-working effort below. I pasted that snippet to the "additional scripts" section in the checkout preferences. The box is displayed but the URL not included.

 

<script>
Shopify.Checkout.OrderStatus.addContentBox(
'<h2>Invoice</h2>',
'<p>You can download your invoice<a href="{{metafields.invoice.url}}">here.</a></p>'
)
</script>

 

0 Likes

Success.

Shopify Partner
1129 131 191

Assuming metafields should be part of the order, you might want to try this instead:

<script>
Shopify.Checkout.OrderStatus.addContentBox(
'<h2>Invoice</h2>',
'<p>You can download your invoice<a href="{{order.metafields.invoice.url}}">here.</a></p>'
)
</script>  

 

Sergiu Svinarciuc | CTO @ visely.io
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution!
- To learn more about the awesome stuff we do head over to visely.io or our blog
0 Likes
Tourist
7 0 0

Works like a charm! Many thanks

0 Likes