Forum

Thread tagged as: Problem, Shop

Passwordless registration - email already in use

In my shop I'm using a passwordless customer create form. If I try to place a second order using an email address that already exists in the system I am unable to proceed with the order due to:

"That email address is already in use"

I want customers to be able to place multiple orders, using the same email address, without having to log in/have an account.

Please advise what I need to do or if you need more information.

Stephen Turvey

Stephen Turvey 0 points

  • 4 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you using the PerchMembers_Members::check_email helper on that form field?

Yes. I tested removing it but then on submitting the form I just got a "Thanks" message and the redirect didn't work:

if (perch_member_logged_in()) {
        PerchSystem::redirect('confirm.php');
}

The member was created successfully in the admin though.

Drew McLellan

Drew McLellan 2638 points
Perch Support

It's that helper than validates if the email address is in use.

Sorry as I marked this as solved but after more testing it isn't.

By removing the helper it allows the member to be created in the db but the redirect I have on my customer details page then doesn't work (doesn't forward the user to the checkout). It just reloads the details page and outputs the <perch:success> message from my Shop > Checkout > customer_create_passwordless.html. If I manually go to the checkout after that the members details aren't there so I can't complete the purchase (so it's not just a simple redirect issue). As mentioned, the member IS created and viewable in the admin though.

details.php

<?php 

    include($_SERVER['DOCUMENT_ROOT'].'/admin/runtime.php');

    if (perch_member_logged_in()) {
        PerchSystem::redirect('confirm');
    }

    perch_layout('header', array(
        'title' => "Your details",
    )); 

?>


<h1 class="mb-0">Your details</h1>


<div class="clear">

    <div class="wrap wrap--small">

        <?php perch_content('Intro text'); ?>

        <?php
            // New customer sign up form
            perch_shop_registration_form([
                'template' => 'checkout/customer_create_passwordless.html'
            ]);

        ?>

    </div>

</div>

<div class="clear">
    <div class="wrap wrap--small">
        <?php perch_content('Shop footer'); ?>
    </div>
</div>


<?php 

    perch_layout('footer', array(
        'hide-social' => true,
    )); 

?>

customer_create_passwordless.html

<div class="clear feature-block mb-0">

<perch:form id="register" method="post" app="perch_shop">

    <div class="blocks blocks--3-cols blocks--mobile-1-col">

        <div>
            <perch:label for="first_name" class="apply-form__label">First name</perch:label>
            <perch:input type="text" id="first_name" required="true" label="First name" class="apply-form__input" />
            <perch:error for="first_name" type="required">Please add your name</perch:error>
        </div>

        <div>
            <perch:label for="last_name" class="apply-form__label">Last name</perch:label>
            <perch:input type="text" id="last_name" required="true" label="Last name" class="apply-form__input" />
            <perch:error for="last_name" type="required">Please add your name</perch:error>
        </div>

        <div>
            <perch:label for="email" class="apply-form__label">Email</perch:label>
            <perch:input type="email" id="email" required="true" placeholder="you@company.com" class="apply-form__input" />
            <perch:error for="email" type="required"><span style="color:red;">Please add your email address</span></perch:error>
            <perch:input type="hidden" id="password" value="__auto__" />
        </div>

    </div>

    <h2>Billing address</h2>

    <div class="blocks blocks--3-cols blocks--mobile-1-col">

        <div>
            <perch:label for="address_1" class="apply-form__label">Address 1</perch:label>
            <perch:input type="text" id="address_1" required="true" label="Address 1" class="apply-form__input" />
            <perch:error for="address_1" type="required">Please add the first line of your address</perch:error>
        </div>

        <div>
            <perch:label for="address_2" class="apply-form__label">Address 2</perch:label>
            <perch:input type="text" id="address_2" label="Address 2" class="apply-form__input" />
        </div>

        <div>
            <perch:label for="postcode" class="apply-form__label">Postal code</perch:label>
            <perch:input type="text" id="postcode" label="Postal code" class="apply-form__input" />
        </div>

        <div>
            <perch:label for="city" class="apply-form__label">City</perch:label>
            <perch:input type="text" id="city" label="City" class="apply-form__input" />
        </div>

        <div>
            <perch:label for="county" class="apply-form__label">State or County</perch:label>
            <perch:input type="text" id="county" label="County" class="apply-form__input" />
        </div>

        <div>
            <perch:label for="country" class="apply-form__label">Country</perch:label>
            <perch:input type="select" options="<perch:shop id="country_list" />" value="236" id="country" label="Country" />
        </div>

    </div>      

    <div class="clear mb-0">
        <perch:input type="submit" value="Next" class="button button--primary" />
    </div>

    <perch:success>
        <p>Thanks!</p>
    </perch:success>

</perch:form>

</div>