Forward Customer to Cart/Checkout AFTER registration

Nicholas_Rose
New Member
23 0 0

Hi all, new to the Shopify experience here I am trying to set up my store so that when a customer registers and clicks the CREATE button at "/account/register" if they have something in their cart they are forwarded to the cart rather than their account page.

Is this simple to achieve? Note I am using the Minimal theme.

Thanks for any feedback.

Nick

 

 

0 Likes
Caroline_Schnap
Shopify Staff
Shopify Staff
5704 1 341

Hi Nick,

Try adding this to your registration form:

{% if cart.item_count > 0 %}
<input type="hidden" name="return_to" value="/cart" />
{% endif %}

I tested this in my sandbox and it works.

0 Likes
Caroline_Schnap
Shopify Staff
Shopify Staff
5704 1 341

To forward to the checkout page instead of the cart page, use this:

{% if cart.item_count > 0 %}
<input type="hidden" name="return_to" value="/checkout" />
{% endif %}

 

Nicholas_Rose
New Member
23 0 0

Thankyou Caroline, you are a god send :-)

0 Likes
Caroline_Schnap
Shopify Staff
Shopify Staff
5704 1 341

You're welcome, Nicholas!

0 Likes
froystore
New Member
3 0 0

Hi Caroline,

We inserted the code that you provided and the registration form successfully creates the account and redirects users to checkout. However, the form now no longer checks for errors or displays error messages.

Users can click on the sign up button without entering any information and gets redirected back to the previous page (in our case, the login/register page). Could you check if we're doing somethings wrong?

 

      <!-- Create Customer -->
      <div id="create-customer">

        {% form 'create_customer' %}
          {{ form.errors | default_errors }}

          <div id="first_name" class="clearfix large_form">
            <label for="first_name" class="login">First Name</label>
            <input type="text" value="" name="customer[first_name]" id="first_name" class="large" size="30" />
          </div>

          <div id="last_name" class="clearfix large_form">
            <label for="last_name" class="login">Last Name</label>
            <input type="text" value="" name="customer[last_name]" id="last_name" class="large" size="30" />
          </div>

          <div id="email" class="clearfix large_form">
            <label for="email" class="login">Email Address</label>
            <input type="email" value="" name="customer[email]" id="email" class="large" size="30" />
          </div>

          <div id="password" class="clearfix large_form">
            <label for="password" class="login">Password</label>
            <input type="password" value="" name="customer[password]" id="password" class="large password" size="30" />
          </div>

          <div class="action_bottom">
            {% if cart.item_count > 0 %}
            <input type="hidden" name="return_to" value="checkout" />
            <input class="action_button" type="submit" value="Continue to Next Step" />
            {% else %}
            <input class="action_button" type="submit" value="Sign Up" />
            {% endif %}
          </div>
        {% endform %}
      </div><!-- /#create-customer -->

 

0 Likes
meganathan
New Member
2 0 0
return_to is not working in latest version. So, please send me the new variable if you have an idea
Thanks
0 Likes
michael-helium
Shopify Expert
183 1 107

Here's a quick guide on Helium's blog how we handle this. Our app, Customer Fields, also supports redirecting customers to checkout... you can even add specific items to the cart based on user input. Basically, you can turn your registration form into a custom order form. 😄 

Merchants are able to customize their registration form and add specific product variants to the cart based on form options (ie: camper’s gender and/or tshirt size). Then a customer account is created containing all of the unique information, in this case the parent is creating an account and all of the camper’s data is being saved.

For example, a camp registration form.

Michael | Business Development @ Helium
Helium builds apps that merchants depend on:
- Customer Fields
- Meteor Mega Menu
0 Likes
aaroncb
New Member
1 0 0

Anyone find a fix for this?

Helium's code:

<script>
  (function() {
    var REDIRECT_PATH = '/checkout';

    var selector = '#create_customer, form[action$="/account"][method="post"]',
        $form = document.querySelectorAll(selector)[0];

    if ($form) {
      $redirect = document.createElement('input');
      $redirect.setAttribute('name', 'return_to');
      $redirect.setAttribute('type', 'hidden');
      $redirect.value = REDIRECT_PATH;
      $form.appendChild($redirect);
    }
  })();
</script>

 

didn't work for me (and the app seems a bit convoluted, so not interested in the app). 

I have a custom checkout, so I can't use Helium's code with a REDIRECT_PATH to '/checkout', it takes user to Shopify's checkout.

I tried to redirect to '/apps/checkout' (where my custom checkout is), and that just takes user to a blank page.

I tried to use '/cart' and I get the same issues as using

{% if cart.item_count > 0 %}
<input type="hidden" name="return_to" value="/cart" />
{% endif %}

 

Errors aren't triggering in registration page, just an infinite loop when trying to register with an existing user email. 

So I'm at a loss. Any help is appreciated!

0 Likes
michael-helium
Shopify Expert
183 1 107

Hi @aaroncb 

Are you willing to elaborate on how the seems app convoluted to you? We welcome honest/critical feedback.

The primary purpose of the Customer Fields app is to save data to a customer account, but it also makes custom redirects easy after registration as well. 

It sounds like the best course of action would be to consider hiring a Shopify Expert to write this script for you, seeing as you have a custom checkout.

I hope you're able to find a solution that works well for you!

Michael | Business Development @ Helium
Helium builds apps that merchants depend on:
- Customer Fields
- Meteor Mega Menu
0 Likes