Using liquid variable in checkout script

Solved
i_am_niklas
Tourist
8 0 1

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>

 

Accepted Solution (1)
Visely-Team
Shopify Partner
1843 210 480

This is an accepted solution.

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

View solution in original post

Replies 3 (3)
Visely-Team
Shopify Partner
1843 210 480

This is an accepted solution.

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
i_am_niklas
Tourist
8 0 1

Works like a charm! Many thanks

GobBluth
Shopify Partner
7 0 0

Curious- What's the 3rd party invoice service you mentioned?