"return_to" After login with new Customer Accounts not working

I’m trying to redirect users to the same page that they clicked to login button. I used to achieve this with “return_to” parameter in the legacy system. But with the new Customer Accounts system it’s not working and redirecting all users to the profile page which causing 2-3 extra steps for customers to find the product page where they left.

Is there anyway to achieve this with the new Customer Accounts system?

Thank you,

1 Like

Hey @CMET i’d also cross post this to the https://community.shopify.dev forum.

The blackboxing of new customer accounts pages creates all types of domino effects and frictions, smh.

Found the solution!

I was dealing with this for the last few days and as soon as I started this thread my brain started to work :slightly_smiling_face:

For anyone who wants to redirect users to the same page that they clicked to the login button your login url needs to be this:

/customer_identity/login?return_to={{ request.path | url_encode }}

for example:

On my Refresh theme: sections>header.liquid

I modified the below code:

{%- if shop.customer_accounts_enabled -%}

to:

{%- if shop.customer_accounts_enabled -%}

2 Likes