Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Hi! I've added some custom scripts to my order status page (the Thank You page upon completed checkout), and i'm having issues (everything loads correctly, but only after a page refresh so i don't think it's an error in my code)
That being said, if i simply add something like:
Shopify.Checkout.OrderStatus.addContentBox('test');
it works fine on the initial page load.
But if i add what i need in there:
<script>
{% for line_item in order.line_items %}
{% if line_item.product.metafields.custom.sortcode == 2 or line_item.product.metafields.custom.sortcode == 4%}
{% assign sortType = true %}
Shopify.Checkout.OrderStatus.addContentBox('test');
{% endif %}
{% endfor %}
{% if sortType == true and order.customer.accepts_marketing %}
Shopify.Checkout.OrderStatus.addContentBox('reminders');
{% endif %}
</script>
It doesn't load the content boxes until i refresh the page (unless of course i access the page from orders>Order Status page)
So it works with this URL format: https://mysite.com/61052518618/orders/31ebba0e2fa2f7f9ae62d1d6b50ca88b
But not with the initial URL: https://mysite.com/checkouts/c/f5d7dac489b8003c4bd56a551dde732c/thank_you
Why doesn't it work on the /thank_you page? And is there a way to fix it? Thanks!!
Having exact same issue. It is surprising that the support did not post any comment on this. Its been more than 2 months I see.
Let me know if you found any solution for this.
Hey,
I just found a workaround for this. Sharing it here so anyone does not run after shopify support.
Just add this script with your script.
Bumping this. It seems scripts don't load on the Thank you page.
Also, refreshing the Thank you page does not redirect to Order Status page anymore.
Seems its works fine for me.
You're right! It wasn't working in my development store with test purchases, but when I tested it on my production store with real money it worked.
Thanks for the reply.
Discover how to increase customer engagement on your store with articles from Shopify A...
By Jacqui Apr 23, 2025Hey Community 👋 Did you know that March 15th is National Everything You Think Is W...
By JasonH Apr 1, 2025Discover how to increase the efficiency of commerce operations with Shopify Academy's l...
By Jacqui Mar 26, 2025