Solved

Shopify.Checkout.OrderStatus.addContentBox only once rather than for each product

Liam123
Visitor
3 0 0

Hey all,

So we have a bit of code in our checkout "additional scripts" box that essentially looks like this

{% for line in checkout.line_items %}
    {% if line.vendor contains 'xyz' %}
      Shopify.Checkout.OrderStatus.addContentBox(
        '**CONTENT BOX CONTENT***'
      )
    {% endif %}
  {% endfor %}

 

So it checks the vendor of the items in the order and if any of them is 'xyz' then it creates the content box. The issue is that if the customer buys more than one product from this vendor then it creates the box multiple times which isn't ideal. How would I modify this so that it checks that if any of them match this condition, it only posts the box once?

I'm not really great with code but could we use some sort of while loop that gets to i=1 and stops? or maybe declare a variable initially as false and set it to true when it detects the vendor match, then do a separate if statement below that says if variable==true then create content box?

Any ideas would be much appreciated here, thanks!

Accepted Solution (1)

LitCommerce
Astronaut
2860 684 735

This is an accepted solution.

Hi @Liam123,

Please change code:

{% for line in checkout.line_items %}
    {% if line.vendor contains 'xyz' %}
      Shopify.Checkout.OrderStatus.addContentBox(
        '**CONTENT BOX CONTENT***'
      )
     {% break %}
    {% endif %}
  {% endfor %}

Hope it helps!

LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool.
Effortlessly sell on biggest marketplaces like Amazon, Etsy, eBay, Facebook etc with bulk listing tool, real-time sync & smart order management. Use LitCommerce free for 1-year now!

View solution in original post

Replies 3 (3)

LitCommerce
Astronaut
2860 684 735

This is an accepted solution.

Hi @Liam123,

Please change code:

{% for line in checkout.line_items %}
    {% if line.vendor contains 'xyz' %}
      Shopify.Checkout.OrderStatus.addContentBox(
        '**CONTENT BOX CONTENT***'
      )
     {% break %}
    {% endif %}
  {% endfor %}

Hope it helps!

LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool.
Effortlessly sell on biggest marketplaces like Amazon, Etsy, eBay, Facebook etc with bulk listing tool, real-time sync & smart order management. Use LitCommerce free for 1-year now!
Liam123
Visitor
3 0 0

You legend! Thanks very much!

LitCommerce
Astronaut
2860 684 735

Hi @Liam123.

Thank you. If you have any difficulty, you can contact me.

Happy to help you.

LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool.
Effortlessly sell on biggest marketplaces like Amazon, Etsy, eBay, Facebook etc with bulk listing tool, real-time sync & smart order management. Use LitCommerce free for 1-year now!