How can I display a message for specific product combinations on the order status page?

Hi everyone.

I’m trying to amend my customers’ order status page with an additional message.

I’ve followed the Shopify guide “Show content based on an order for a particular product” which works fine, but I only want a message to appear if a particular combination of products has been ordered.

So only if the customer’s order contains ‘product A’ AND ‘product B’, then display the message.

I know the code below is wrong (obviously) but does anyone know the correct code to make this work?

<script>
{% for line in checkout.line_items %}
// DEBUG looking at {{ line.title }}
{% if line.title contains 'Hat' %}
and
{% if line.title contains 'Gloves' %}
Shopify.Checkout.OrderStatus.addContentBox(
'<p>Great combination etc etc</p>'
)
{% endif %}
{% endfor %}
</script>

Hello,

I hope this helps :slightly_smiling_face:

{% assign productA = false %}
{% assign productB = false %}

{% for line_item in Shopify.checkout.line_items %}

{% if line_item.product_id == ‘product-A-id’ %}
{% assign productA = true %}
{% elsif line_item.product_id == ‘product-B-id’ %}
{% assign productB = true %}
{% endif %}

{% endfor %}

{% if productA == true and productB == true %}
Shopify.Checkout.OrderStatus.addContentBox(‘

Your Message

’);
{% endif %}

1 Like

Thank you very much. That seems to be working fine.

1 Like