Liquid, JavaScript, themes, sales channels
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.
User | RANK |
---|---|
37 | |
26 | |
14 | |
13 | |
9 |
Make the shift from discounts to donations, and witness your business not only thrive fina...
By Holly Dec 4, 2023On our Shopify Expert Marketplace, you can find many trusted third party developers and fr...
By Arno Nov 27, 2023You've downloaded the Search & Discovery app from the Shopify App store, and as you're ...
By Skye Nov 8, 2023