Redirecting to external website after checkout

Redirecting to external website after checkout

Joni55
Visitor
1 0 0

I want to redirect users to an external website once they checkout successfully. Adding additional scripts on the   Post-purchase page didn't work
here is my script but it didn't work. Even a console log doesn't work.

<script>
document.addEventListener('DOMContentLoaded', function() {
if (window.location.href.indexOf('/thank_you') > -1) {
var orderId = Shopify.checkout.order_id;
var redirectUrl = 'http://example.com/?order_id=' + orderId;
window.location.href = redirectUrl;
}});

</script>

Replies 0 (0)