Forum

Thread tagged as: Question, Problem, Shop

Is a truly "anonymous" one-time shopping cart possible?

I'm putting together a passwordless checkout for a client that sells an item usually sent as a gift to others.

During testing I've noticed that if I go back through the checkout and use the same email address as a previous order, then the stored address for that order is retrieved, and whatever details the customer has entered in the customer_create_passwordless.html are discarded.

Is there anyway to configure the checkout to be "anonymous" (for want of a better word) so that even if an existing email address is used it doesn't retrieve any address details from the database, but instead always uses the entered address?

Diagnostics

    Perch Runway: 3.0.14, PHP: 7.2.6, MySQL: mysqlnd 5.0.12-dev - 20150407 - $Id: 38fea24f2847fa7519001be390c98ae0acafe387 $, with PDO
    Server OS: Darwin, fpm-fcgi
    Installed apps: content (3.0.14), assets (3.0.14), categories (3.0.14), perch_blog (5.6.1), perch_forms (1.10), perch_shop_orders (1.2.5), perch_shop_products (1.2.5), perch_shop (1.2.5), perch_members (1.6.2)
    App runtimes: <?php $apps_list = [ 'perch_forms', 'perch_members', 'perch_shop', 'perch_blog', ];
    PERCH_LOGINPATH: /juniper
    PERCH_PATH: /Users/garrettc/sandbox/collagin/htdocs/juniper
    PERCH_CORE: /Users/garrettc/sandbox/collagin/htdocs/juniper/core
    PERCH_RESFILEPATH: /Users/garrettc/sandbox/collagin/htdocs/juniper/resources
    Image manipulation: GD
    PHP limits: Max upload 2M, Max POST 8M, Memory: 128M, Total max file upload: 2M
    F1: 3b606135b33e6a102526838f4152a807
    Resource folder writeable: Yes
    SCRIPT_NAME: /juniper/core/settings/diagnostics/index.php
    REQUEST_URI: /juniper/core/settings/diagnostics/
    DOCUMENT_ROOT: /Users/garrettc/sandbox/collagin/htdocs
    HTTP_HOST: collagin.local

checkout.php

<?php
    $page_title = perch_pages_title(true);
    PerchSystem::set_var('page_title', $page_title);

    perch_layout(
        'global.header', [
            'page_title' => $page_title,
            'body-class' => 'checkout',
    ]);

    perch_layout('global.main-start');

    // Show the cart with a non-interactive template
    perch_shop_cart([
        'template' => 'cart/cart_static.html'
    ]);

    perch_shop_registration_form([
        'template' => 'checkout/customer_create_passwordless.html'
    ]);

    perch_layout('global.main-end');

    perch_layout('global.footer');

customer_create_passwordless.html

<h1 class="title">
    <perch:content id="page_title" type="hidden" />
</h1>

<perch:form id="register" method="post" app="perch_shop" action="/shop/payment">
    <fieldset class="register-credentials">
        <h3>
            <legend>About you</legend>
        </h3>
        <div class="input required">
            <perch:label for="first_name">First name</perch:label>
            <perch:input type="text" id="first_name" required="true" label="First name" />
            <perch:error for="first_name" type="required"><p class="error">Please add your name</p></perch:error>
        </div>

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

        <div class="input required">
            <perch:label for="email">Email</perch:label>
            <perch:input type="email" id="email" required="true" placeholder="you@example.com" />
            <perch:error for="email" type="required"><p class="error">Please add your email address</p></perch:error>
            <perch:input type="hidden" id="password" value="__auto__" />
        </div>

    </fieldset>

    <fieldset class="register_billing">
        <h3>
            <legend>Address</legend>
        </h3>
        <div class="input">
            <perch:label for="company">Company</perch:label>
            <perch:input type="text" id="company" label="Company" />
        </div>

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

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

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

        <div class="input required">
            <perch:label for="postcode">Postal code</perch:label>
            <perch:input type="text" id="postcode" label="Postal code" />
            <perch:error for="postcode" type="required"><p class="error">Please add your post code</p></perch:error>
        </div>

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

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

    </fieldset>

    <div class="submit button-wrapper">
        <perch:input type="submit" value="Confirm" />
    </div>

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

</perch:form>

payment.php

    $page_title = perch_pages_title(true);
    PerchSystem::set_var('page_title', $page_title);

    // If we have the Stripe token we're in the payment flow
    if (perch_post('stripeToken')) {
        perch_shop_checkout('stripe', [
            'return_url' => '/shop/result',
            'cancel_url' => '/shop/cart',
            'token'      => perch_post('stripeToken'),
        ]);
    }

    perch_layout(
        'global.header', [
            'page_title' => $page_title,
            'body-class' => 'checkout',
    ]);

    perch_layout('global.main-start');

    // Show the cart with a non-interactive template
    perch_shop_cart([
        'template' => 'cart/cart_static.html'
    ]);

    perch_shop_order_addresses();

    // Payment button
    perch_shop_payment_form('stripe');

    perch_layout('global.main-end');

    perch_layout('global.footer');
Garrett Coakley

Garrett Coakley 0 points

  • 3 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

The entered details shouldn't be discarded. Is this in the same session, or are you logging the customer out at the end of the checkout process?

I’m not explicitly logging the test users out (is there a function for that?), but I’ve tested across multiple Private Browsing sessions in Chrome, and by manually deleting the session data in dev tools between tests.

I'm not sure what I was missing yesterday, but I ran through some more tests today using existing emails, and the details were all stored correctly. Going to mark this as solved.