Show content based on an order for a particular product
This page was printed on Mar 29, 2023. For the current version, visit https://help.shopify.com/en/manual/orders/status-tracking/customize-order-status/show-content-based-on-products.
Learn how to iterate through your checkout.line_items
to see if your special product is in the order.
For example, you want to sell a downloadable product and want to add a download link to the order status page. However, you only want to show the link if the digital product is in the order.
Steps:
- From your Shopify admin, go to Settings > Checkout.
- From the Shopify app, go to Store > Settings.
- Under Store settings, tap Checkout.
- From the Shopify app, go to Store > Settings.
- Under Store settings, tap Checkout.
Scroll down to the Additional scripts section.
Copy the following code to your clipboard (
command + c
on a Mac,ctrl + c
on a PC).
<script>
{% for line in checkout.line_items %}
// DEBUG looking at {{ line.title }}
{% if line.title == 'Downloadable product' %}
Shopify.Checkout.OrderStatus.addContentBox(
'<p>Download your product <a href="#">Here!</a></p>'
)
{% endif %}
{% endfor %}
</script>
Paste the code into the Additional scripts box. (press
ctrl
+V
on a PC orcommand
+V
on a Mac)Complete a test order to view your order status page.