Forum

Thread tagged as: Question, Shop

Perch Shop Shipping Address Default

I understand that if you leave the shipping address form out of the customer_create_passwordless template then the shipping address will default to the billing address, but is it not possible to include the shipping form and for the customer to only complete it if the shipping address is different.

Toby Martin

Toby Martin 1 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

You'd use the billing address form and change the labelling.

But I'd be using the billing address form for the billing address?

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok, then yes, you can do that.

If I use the billing address and shipping address inputs in the customer_create_passwordless template and then test with perch_shop_addresses_set whilst leaving the shipping fields blank, the form doesnt submit.

Rachel Andrew

Rachel Andrew 394 points
Perch Support

Please post your template and Diagnostics Report if you are experiencing a problem.

Diagnostics:

Perch: 2.8.30
Production mode: Production (100)
Installed apps: content (2.8.30), assets (2.8.30), categories (2.8.30), perch_forms (1.8.3), perch_shop_orders (1.0.6), perch_shop_products (1.0.6), perch_shop (1.0.6), perch_members (1.5)
DB driver: PDO
DB tables: perch2_categories (86), perch2_category_counts (0), perch2_category_sets (1), perch2_content_index (848), perch2_content_items (8), perch2_content_regions (1), perch2_forms (0), perch2_forms_responses (0), perch2_members (10), perch2_members_forms (2), perch2_members_member_tags (0), perch2_members_sessions (0), perch2_members_tags (0), perch2_navigation (0), perch2_navigation_pages (0), perch2_page_templates (1), perch2_pages (1), perch2_resource_log (1164), perch2_resource_tags (0), perch2_resources (826), perch2_resources_to_tags (0), perch2_settings (34), perch2_shop_addresses (28), perch2_shop_admin_index (198), perch2_shop_brands (1), perch2_shop_cart (11), perch2_shop_cart_data (69), perch2_shop_cart_items (32), perch2_shop_countries (248), perch2_shop_currencies (152), perch2_shop_customers (10), perch2_shop_emails (1), perch2_shop_index (9030), perch2_shop_option_values (20), perch2_shop_options (5), perch2_shop_order_items (29), perch2_shop_order_promotions (0), perch2_shop_order_statuses (9), perch2_shop_orders (25), perch2_shop_orders_meta (1), perch2_shop_product_files (0), perch2_shop_product_option_values (19), perch2_shop_product_options (5), perch2_shop_product_tags (0), perch2_shop_products (223), perch2_shop_promotions (0), perch2_shop_search (219), perch2_shop_shipping_zone_countries (1), perch2_shop_shipping_zones (1), perch2_shop_shippings (6), perch2_shop_tax_exhibits (31), perch2_shop_tax_group_rates (1), perch2_shop_tax_groups (1), perch2_shop_tax_locations (1), perch2_shop_tax_rates (1), perch2_shop_variants (34), perch2_user_passwords (0), perch2_user_privileges (70), perch2_user_role_privileges (16), perch2_user_roles (2), perch2_users (1)
Users: 1
App runtimes:
<?php
    $apps_list = array(
        'content',
        'categories',
        'perch_forms',
        'perch_members',
        'perch_shop'
    );
Editor plug-ins: markitup
H1: efe77763824a956c38ef94e242ceb589
L1: b0a67eb80acfa57c890721a731a015f9
F1: 2edba60ed1f613d6dd804feb202456a2
headerColour: #ffffff
content_singlePageEdit: 1
helpURL:
siteURL: /
hideBranding: 1
content_collapseList: 1
lang: en-gb
update_2.8.13: done
latest_version: 2.8.15
on_sale_version: 2.8.30
headerScheme: light
perch_members_login_page: /members/login.php?r={returnURL}
perch_moltin_client_id: O9nzWOg4q2Dk5nXKS5c5q22kKUsLXx5hd1EcCnlJ
perch_moltin_client_secret: AbdIXbSPuMxdi02hyRgIjSTZ615e00kpcpvWiikO
perch_moltin_category_set: 1
perch_moltin_site_url: https://
dashboard: 0
hide_pwd_reset: 0
content_hideNonEditableRegions: 0
content_frontend_edit: 0
perch_moltin_update: 0.8
update_2.8.14: done
perch_shop_update: 1.0.6
perch_shop_price_tax_mode: exc
perch_shop_site_url: https://
perch_shop_default_currency: 47
perch_members_update: 1.4
update_2.8.21: done
update_2.8.23: done
perch_shop_product_url: /shop/products/{slug}
update_2.8.24: done
update_2.8.26: done
update_2.8.27: done
update_2.8.30: done
PERCH_DEVELOPMENT: 10
PERCH_STAGING: 50
PERCH_PRODUCTION: 100
PERCH_DB_USERNAME: root
PERCH_DB_DATABASE: perch_opt4
PERCH_DB_SERVER: localhost
PERCH_DB_PREFIX: perch2_
PERCH_TZ: UTC
PERCH_EMAIL_FROM: toby@pixelpen.co.uk
PERCH_EMAIL_FROM_NAME: Toby Martin
PERCH_LOGINPATH: /admin
PERCH_PATH: /Users/Toby/Sites/opt4mobility/admin
PERCH_CORE: /Users/Toby/Sites/opt4mobility/admin/core
PERCH_RESFILEPATH: /Users/Toby/Sites/opt4mobility/admin/resources
PERCH_RESPATH: /admin/resources
PERCH_HTML5: 1
PERCH_DEBUG: 1
PERCH_RUNWAY:
PERCH_ERROR_MODE: DIE
PERCH_DATE_LONG: %d %B %Y
PERCH_DATE_SHORT: %d %b %Y
PERCH_TIME_SHORT: %H:%M
PERCH_TIME_LONG: %H:%M:%S
PERCH_RUNWAY_ROUTED:
PERCH_STRONG_PASSWORDS:
PERCH_PREVIEW_ARG: preview
PERCH_TEMPLATE_PATH: /Users/Toby/Sites/opt4mobility/admin/templates
PERCH_DEFAULT_DOC: index.php
PERCH_DEFAULT_EXT: .php
PERCH_PRODUCTION_MODE: 100
PERCH_RWD:
PERCH_HTML_ENTITIES:
PERCH_SSL:
PERCH_STRIPSLASHES:
PERCH_PROGRESSIVE_FLUSH: 1
PERCH_PARANOID:
PERCH_FORCE_SECURE_COOKIES:
PERCH_PASSWORD_MIN_LENGTH: 6
PERCH_MAX_FAILED_LOGINS: 10
PERCH_AUTH_LOCKOUT_DURATION: 1 HOUR
PERCH_VERIFY_UPLOADS:
PERCH_AUTH_PLUGIN:
PERCH_DB_CHARSET: utf8
PERCH_DB_PORT:
PERCH_DB_SOCKET:
PERCH_SESSION_TIMEOUT_MINS: 20
PERCH_SHOP_VERSION: 1.0.6
PERCH_APPS_EDITOR_PLUGIN: markitup
PERCH_APPS_EDITOR_MARKUP_LANGUAGE: textile
HOSTING SETTINGS

PHP: 7.0.0
Zend: 3.0.0
OS: Darwin
SAPI: cgi-fcgi
Safe mode: not detected
MySQL client: mysqlnd 5.0.12-dev - 20150407 - $Id: 7e72f9690b1498a1bead7a637c33a831c0d2f655 $
MySQL server: 5.5.42
Free disk space: 63.06 GB
Extensions: Core, date, libxml, openssl, pcre, sqlite3, zlib, bcmath, bz2, calendar, ctype, curl, dom, hash, fileinfo, filter, ftp, gd, SPL, iconv, intl, json, ldap, mbstring, session, standard, mysqlnd, PDO, pdo_mysql, pdo_sqlite, Phar, posix, readline, Reflection, mysqli, SimpleXML, soap, sockets, exif, tokenizer, wddx, xml, xmlreader, xmlwriter, xsl, zip, cgi-fcgi, imap, mcrypt, pgsql, pdo_pgsql
GD: Yes
ImageMagick: No
PHP max upload size: 32M
PHP max form post size: 32M
PHP memory limit: 128M
Total max uploadable file size: 32M
Resource folder writeable: Yes
Session timeout: 24 minutes
Native JSON: Yes
Filter functions: Yes
Transliteration functions: Yes
PHP_FCGI_CHILDREN: 4
PWD: /Applications/MAMP/fcgi-bin
PHP_FCGI_MAX_REQUESTS: 200
__CF_USER_TEXT_ENCODING: 0x1F5:0x0:0x0
ORIG_SCRIPT_NAME: /fcgi-bin/php7.0.0.fcgi
ORIG_PATH_TRANSLATED: /Users/Toby/Sites/opt4mobility/admin/core/settings/diagnostics/index.php
ORIG_PATH_INFO: /admin/core/settings/diagnostics/index.php
ORIG_SCRIPT_FILENAME: /Applications/MAMP/fcgi-bin/php7.0.0.fcgi
SCRIPT_NAME: /admin/core/settings/diagnostics/index.php
REQUEST_URI: /admin/core/settings/diagnostics/?extended
QUERY_STRING: extended
REQUEST_METHOD: GET
SERVER_PROTOCOL: HTTP/1.1
GATEWAY_INTERFACE: CGI/1.1
REDIRECT_URL: /admin/core/settings/diagnostics/index.php
REDIRECT_QUERY_STRING: extended
REMOTE_PORT: 57595
SCRIPT_FILENAME: /Users/Toby/Sites/opt4mobility/admin/core/settings/diagnostics/index.php
SERVER_ADMIN: you@example.com
DOCUMENT_ROOT: /Users/Toby/Sites/opt4mobility
REMOTE_ADDR: ::1
SERVER_PORT: 8888
SERVER_ADDR: ::1
SERVER_NAME: loc.o
SERVER_SOFTWARE: Apache
PATH: /usr/bin:/bin:/usr/sbin:/sbin
HTTP_COOKIE: cmsa=1; p_m=; _ga=GA1.2.1696672089.1468244631; PHPSESSID=24686d298831fbe03bcb8065b826bb9b
HTTP_ACCEPT_LANGUAGE: en-US,en;q=0.8
HTTP_ACCEPT_ENCODING: gzip, deflate, sdch
HTTP_REFERER: https://loc.o:8888/admin/core/settings/diagnostics/
HTTP_ACCEPT: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
HTTP_USER_AGENT: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/54.0.2791.0 Safari/537.36
HTTP_UPGRADE_INSECURE_REQUESTS: 1
HTTP_CONNECTION: keep-alive
HTTP_HOST: loc.o:8888
REDIRECT_STATUS: 200
REDIRECT_HANDLER: php-fastcgi
REDIRECT_proto: http
FCGI_ROLE: RESPONDER
PHP_SELF: /admin/core/settings/diagnostics/index.php
REQUEST_TIME_FLOAT: 1468312953.11
REQUEST_TIME: 1468312953
argc: 1

Template:

<perch:form id="register" method="post" app="perch_shop">
    <div class="row">
        <div class="small-12 columns">
            <p>Please Enter your Billing and Shipping details below</p>
        </div>

        <div class="medium-6 columns">
            <fieldset>
                   <legend>Billing address</legend>

                <div>
                    <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">Please add your name</perch:error>
                </div>

                <div>
                    <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">Please add your name</perch:error>
                </div>

                <div>
                    <perch:label for="email">Email</perch:label>
                    <perch:input type="email" id="email" required="true" placeholder="you@company.com" helper="PerchMembers_Members::check_email" />
                    <perch:error for="email" type="required">Please add your email address</perch:error>
                    <perch:error for="email" type="helper">That email address is already in use</perch:error>
                    <perch:input type="hidden" id="password" value="__auto__" />
                </div>

            <div>
                    <perch:label for="company">Company</perch:label>
                    <perch:input type="text" id="company" required="true" label="Company" />
                </div>

                <div>
                    <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">Please add the first line of your address</perch:error>
                </div>

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

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

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

                <div>
                    <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>

        <div class="medium-6 columns">
            <fieldset class="shipping-details">
                <legend>Shipping Address</legend>

                <div>
                    <perch:label for="shipping_first_name">First name</perch:label>
                    <perch:input type="text" id="shipping_first_name" label="First name" />
                    <perch:error for="shipping_first_name" type="required">Please add your name</perch:error>
                </div>

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

                <div>
                    <perch:label for="company">Company</perch:label>
                    <perch:input type="text" id="shipping_company" label="Company" />
                </div>

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

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

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

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

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

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

            <div>
                <br>
                <perch:input type="submit" value="Continue to payment" class="btn btn-primary"/>
            </div>
        </div>
    </div>

    <perch:success>
        <p>Thanks!</p>
    </perch:success>
</perch:form>
Drew McLellan

Drew McLellan 2638 points
Perch Support

Are you leading the shipping address blank? I've no clear picture of what you're trying to do.

Yes, I want the user to leave the shipping address blank, unless it differs from the billing address.

Then if the shipping address is blank, for the Billing address to be used as the shipping address.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Ok. If that's not working, the solution might be to fill the shipping address with the same details as the billing address.

I'm using some js to duplicate the fields for now, but I think it's an added layer of friction that doesn't need to be there.

Or even a perch_shop_shipping_addresses_set() function would be useful here instead.

Drew McLellan

Drew McLellan 2638 points
Perch Support

So you having it working?

Yes, but not how we would like – it's only working by filling in the Shipping Address details.

Drew McLellan

Drew McLellan 2638 points
Perch Support

I think that's what we can do currently.