FROM CACHE - en_header

Dynamic video on Order Status page - Is this scripting correct?

bjones21
Tourist
4 0 3

Our aim is to have a variety of videos load on our order status page based on a few cart items; ultimately so we can offer different deals discounts and special messaging. I put together this coding below and wanted to check if this should be applicable.
The idea being if they have item A then this video+discountA loads, if they have item B, then this video+discountB loads, for all other customers this video+discountX loads:

{% if first_time_accessed %}

<script>
{% for line in checkout.line_items %}
// DEBUG looking at {{ line.title }}
{% if line.title == 'XXXXX xXXX XXx' %}
Shopify.Checkout.OrderStatus.addContentBox(
'<video controls="controls" style="max-width: 100%; height: auto;">
<source src="your_url_goes_here" type="video/mp4" />
Your browser does not support our video.
</video>
<p>Download your product <a href="#">Here!</a></p>'
)
{% elseif line.title == 'YYYYY yy XXx' %}
Shopify.Checkout.OrderStatus.addContentBox(
'<video controls="controls" style="max-width: 100%; height: auto;">
<source src="your_url_goes_here" type="video/mp4" />
Your browser does not support our video.
</video>
<p>Download your product <a href="#">Here!</a></p>'
)
{% elseif line.title == 'ZZZZ' %}
Shopify.Checkout.OrderStatus.addContentBox(
'<video controls="controls" style="max-width: 100%; height: auto;">
<source src="your_url_goes_here" type="video/mp4" />
Your browser does not support our video.
</video>
<p>Download your product <a href="#">Here!</a></p>'
)
{% else %}
Shopify.Checkout.OrderStatus.addContentBox(
'<video controls="controls" style="max-width: 100%; height: auto;">
<source src="your_url_goes_here" type="video/mp4" />
Your browser does not support our video.
</video>
<p>Download your product <a href="#">Here!</a></p>'
)
{% endif %}
{% endfor %}
</script>

{% endif %}

Replies 0 (0)