Shopify Customer Login Redirect

By default Shopify points to the /accounts page when Customers login. This function will redirect them to a page of your choice.

Place in theme.liquid before </body>

   (function() { 
     var REDIRECT_PATH = '/checkout'; // change to desired page
     var selector = '#form_ID, form[action$="/account"][method="post"]', // change #form_ID to the login form ID, and update /account to match your form
         $form = document.querySelectorAll(selector)[0]; 
     if ($form) { 
       $redirect = document.createElement('input'); 
       $redirect.setAttribute('name', 'return_to'); 
       $redirect.setAttribute('type', 'hidden'); 
       $redirect.value = REDIRECT_PATH; 

Source (with video and more details).

Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.