Forum

Thread tagged as: Question, Members, Shop

Shop Trade Access - Members signup with country

Hi,

Sorry another Shop one!

I am using the Members app for people to sign up to gain access to Trade pricing on my shop. I am using a customised version of the members register form, and need to use the country select used in the customer_create in the Shop templates. This is so the shipping options, tax etc. are correct for the customer. I currently have this as my trade_register.html template:

<div class="container">

<perch:form id="register" method="post" app="perch_members" type="trade">

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

    </div>

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

    </div>

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

    <div>
            <perch:label for="company" class="required">Company Name</perch:label>
            <perch:error for="company" type="required"><span class="error">Please add your company name</span></perch:error>
            <perch:input type="text" id="company" required="true" label="Company Name" />

    </div>

    <div>
            <perch:label for="website">Company Website (if applicable)</perch:label>
            <perch:input type="text" id="website" label="Company Website" />
    </div>

    <div>
            <perch:label for="stores">How many stores do you have? Or is your business online only?</perch:label>
            <perch:input type="text" id="stores" label="How many stores do you have?" />
    </div>

    <div>
            <perch:label for="refer">Where did you hear about us?</perch:label>
            <perch:input type="text" id="refer" label="Where did you hear about us?" />
    </div>

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

    </div>

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

    <div>
            <perch:label for="city" class="required">Town or City</perch:label>
                <perch:error for="town" type="required"><span class="error">Please enter your Town</span></perch:error>
            <perch:input type="text" id="city" required="true" label="Town" />

    </div>

    <div>
            <perch:label for="county" class="required">County</perch:label>
                        <perch:error for="county" type="required"><span class="error">Please enter your County</span></perch:error>
            <perch:input type="text" id="county" required="true" label="County" />

    </div>

    <div>
            <perch:label for="country" class="required">Country</perch:label>
                        <perch:error for="country" type="required"><span class="error">Please enter your Country</span></perch:error>
            <perch:input type="text" id="country" required="true" label="Country" />

    </div>

    <div>
            <perch:label for="postcode" class="required">Postcode</perch:label>
                        <perch:error for="postcode" type="required"><span class="error">Please enter your Postcode</span></perch:error>
            <perch:input type="text" id="postcode" required="true" label="Postcode" />

    </div>

    <div>
            <perch:label for="phone">Phone Number</perch:label>
                <perch:error for="phone" type="format"><span class="error">Please check your phone number</span></perch:error>
            <perch:input type="tel" id="phone" label="Phone Number" />

    </div>

    <div>
        <perch:label for="password" class="required">Choose a Password</perch:label>
        <perch:error for="password" type="required"><span class="error">Please add a password</span></perch:error>
        <perch:error for="password" type="match"><span class="error">Passwords do not match</span></perch:error>
        <perch:input type="password" id="password" required="true" match-with="password2" />

    </div>

    <div>
        <perch:label for="password2" class="required">Repeat Password</perch:label>
        <perch:error for="password2" type="required"><span class="error">Please repeat your password</span></perch:error>
        <perch:input type="password" id="password2" required="true" />

    </div>


    <div>
        <perch:input type="submit" value="Request Access" />
    </div>

    <perch:success>
    <div class="approval">
        <p>Thanks for your application. We will be in touch shortly.</p>
        </div>
    </perch:success>

</perch:form>

</div>

Simply called on the page like this:

perch_member_form('trade_register.html');

Is this possible?

Mike Harrison

Mike Harrison 37 points

  • 5 years ago
Drew McLellan

Drew McLellan 2638 points
Perch Support

I think you should be able to use

PerchSystem::set_var('county_options', PerchShop_Countries::get_list_options());

Sorry no joy with that. My page now has:

PerchSystem::set_var('county_options', PerchShop_Countries::get_list_options());
perch_member_form('register.html');

My template has:

<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" />
Drew McLellan

Drew McLellan 2638 points
Perch Support

You're using county_options in one place and country_list in the other - they need to be the same.

Also the perch:shop tag needs to be perch:members in that context I think.

Oops typo. No still not working, tried this:

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

and

PerchSystem::set_var('country_list', PerchShop_Countries::get_list_options());
perch_member_form('register.html');

Tried perch:shop too but just getting a blank select

I could use perch_shop_registration_form but I need the confirmation from Members or anyone could get access.

Drew McLellan

Drew McLellan 2638 points
Perch Support

Does it show up in <perch:showall /> ?

On the <perch:showall /> for register.html, it does actually:

country_list    Afganistan|1,Åland Islands|2,Albania|3,Algeria|4,American{...}

That's encouraging I guess?

Drew McLellan

Drew McLellan 2638 points
Perch Support

At the bottom, which namespace does it say it's using?

perch:forms - if I switch it to that it works!

<perch:label for="country">Country</perch:label>
<perch:input type="select" options="<perch:forms id="country_list" />" value="236" id="country" label="Country" />
Drew McLellan

Drew McLellan 2638 points
Perch Support

It's handy, that!

Every day is a school day - cheers Drew