Happening now | Office Hours: Customizing Your Theme With Moeed | Ask your questions now!

How can I redirect to a custom page after logging out?

How can I redirect to a custom page after logging out?

parmindersidhu
Shopify Partner
3 0 0

Hello Shopify Community!

I made the logout link in the headless side, and its link is account/login  When I click this link, I removed cookie data, and redirects to this link, then it is logged out of Shopify store.
Are there any solution for this? Like the redirect after login. We can redirect to custom page after Shopify login using the following link account/logout. I want this kind of solution for logout or any other solutions.
Thank you in advance.

Reply 1 (1)

parmindersidhu
Shopify Partner
3 0 0

you can use this in theme.liquid before end the body tag
<script>
$(document).ready( function() {
$('a[href^="/account/logout"]').on("click", function() {
$.ajax( $(this).attr('href') )
.done(function() {
window.location.href = "/cart";
});
return false;
});
});
</script>