Redirection to the cart page after customer authentification

Hello all,

I have adjusted my shopify website that customers need to authentificate with their login to buy any products (crucial for our operations, cannot be changed).

we have a problem in case of the following senario:

1/ Customer add products in its cart before authentifying itself

2/ From its cart Customer clicks on the button “Check out”

3/ The website directs the customer to authentification page, customer authentificate itself

4/ PROBLEM → Customer is directed toward the final payment page (capture 4)

We need that after its authentification the customer get directed to its cart, and then he has to click (again) on the button “check out” and get to the final payment page.

I need to do a page redirection as important information (up-to-dates discount codes related to the customer tag of the customer that authentificated) appear on the cart page only after customer authentification, and in the scenario described above the customer eligible to the discount codes won’t see them.

How to do that?

Website: www.champagne-legrand.com

password to navigate: Password99

Many thanks for your help,

Val

Hi @Legval ,

This redirection isn’t supported natively in Shopify, but it can be done with custom code using JavaScript and Liquid. However, it’s a bit complex and time-consuming to implement properly.

An easier option is using an app that supports login flow control. Here are a few you can check out:

  • Helium Customer Fields

  • B2B Login/Lock Access

  • EasyLockdown ‑ Access Control

These can help with redirection or restricting access before login.

Hope this helps!

Val, Lesle this side from Dollarlabs.

I checked out the website and noticed that the checkout button was taking the user to the Shopify login page but with a redirect after login set to the destination as “/checkout” since that’s the original destination of the user in this case when pressing the button.

I tried placing a collab request to help, but it seems that it’s locked with a code. Feel free to DM or share relevant info so I can help further.

Happy to assist further,

Hi @Abel_Lesle ,

Thank you for helping. THe code for the collab request is 7945.

I remain available,

Regards

Val

Val, I’ve placed a request from my side.

Best,

I just accepted

@Legval and possibly others who may stumble across this thread later down the line. Here’s how we fixed the issue mentioned and achieved the user behavior requested.

  1. Check if the customer is logged in, If yes - show the theme’s default checkout button as is.
  2. If customer is not logged in, show a custom button with a redirect to the “/cart” after the user completes the login.

Here’s the before code

{%- when 'buttons' -%}
            
              

              
            

            {%- if additional_checkout_buttons and block.settings.show_dynamic_checkout -%}
              
                {{ content_for_additional_checkout_buttons }}
              

            {%- endif -%}

Here’s the after code

{%- when 'buttons' -%}
            
              
              {% if customer %}
              
                {% else %}
                 
                {{ 'sections.cart.checkout' | t }}
                
                {% endif %}
          
            

            {%- if additional_checkout_buttons and block.settings.show_dynamic_checkout -%}
              
                {{ content_for_additional_checkout_buttons }}
              

            {%- endif -%}

You can check out the Shopify docs that detail how the redirection works for new customer accounts.

https://shopify.dev/docs/storefronts/themes/login#direct-customers-back-to-another-page-on-the-online-store

Best,