Forums / Managing Customers and Orders / Problem with customer registration - State field

Problem with customer registration - State field

Started by onlyseadoo on 9 Mar 2012, 4:37 PM · Views: 2,437

Results 1 to 12 of 12
9 Mar 2012, 4:37 PM
#1
onlyseadoo avatar

onlyseadoo

New Zenner

Join Date:
Feb 2011
Posts:
43
Plugin Contributions:
0

Problem with customer registration - State field

I have a problem with customer registration so have been living with it so far but would like to fix. In "Customer Details" I have the State set to TRUE and "Always Display As Pulldown" also set to TRUE. By my thinking I should just have a pulldown with states but what it does is first makes you type in your state then when you submit, gives you an error and makes you use the pulldown that doesn't function the first time. Is that how it's supposed to function?

9 Mar 2012, 4:58 PM
#3
onlyseadoo avatar

onlyseadoo

New Zenner

Join Date:
Feb 2011
Posts:
43
Plugin Contributions:
0

Re: Problem with customer registration - State field

Thanks I put the following at the end of the stylesheet.css

.hiddenField {
display: none;
}
.visibleField {
display: inline;
}

That didn't do anything though. Note when you get to the reg page the first time I don't have a state drop down. If you click where it should be, it says "type a choice below". Once you type a choice and submit, it gives you the error and shows the pulldown. I think the pulldown should be showing the first time correct?

9 Mar 2012, 5:13 PM
#4
stevesh avatar

stevesh

Black Belt

Join Date:
Feb 2005
Location:
Lansing, Michigan USA
Posts:
19,793
Plugin Contributions:
2

Re: Problem with customer registration - State field

The dropdown should show all the time. Post a URL and we can take a look.

10 Mar 2012, 3:05 PM
#5
onlyseadoo avatar

onlyseadoo

New Zenner

Join Date:
Feb 2011
Posts:
43
Plugin Contributions:
0

Re: Problem with customer registration - State field

If you place an order on https://www.osdparts.com (pick anything) then go to the cart and try and register, you should be able to see what I mean.

10 Mar 2012, 6:32 PM
#6
ajeh avatar

ajeh

Oba-san

Join Date:
Sep 2003
Location:
Ohio
Posts:
62,757
Plugin Contributions:
1

Re: Problem with customer registration - State field

Pick United States and then it will go away ...

Prior to that, it does not know if it needs a manual or dropdown state ...

Linda McGrath
If you have to think ... you haven't been zenned ...

**Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!**

Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
Officially PayPal-Certified! Just click here

Try our Zen Cart Recommended Services - Hosting, Payment and more ...
Signup for our Announcements Forums to stay up to date on important changes and updates!

14 Jul 2012, 9:11 PM
#7
kbear avatar

kbear

New Zenner

Join Date:
Mar 2011
Location:
In a green and pleasant land
Posts:
46
Plugin Contributions:
0

Re: Problem with customer registration - State field

Hi Linda
I still have this problem
I am in the UK and it won't accept any typed counties
Every tine one of my customers sets up an account it allows them to type their county name (shouldn't be state if the country is United Kingdom - but that's just a xenophobic niggle). When they save their count it comes back with a drop down of countries
There is something not right
I'm using 1.39h

My website is https://www.equivivre-shop.co.uk

John

14 Jul 2012, 9:35 PM
#8
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Problem with customer registration - State field

We discovered this issue some time back...

If you start out with your store requiring users to TYPE IN their county/state, and a few customers sign up using this method... then you LATER switch to DROPDOWN... you will get a host of errors and difficulties with customers trying to register and login, and perhaps even check-out. This is particularly true for UK stores, because raw zencart does not do a default install of UK counties.

So what happens is that UK people install zencart, and let it operate for a while, and then see that it would be advantageous (for shipping for example) to have the COUNTIES added to the database.

Now... any customer that signed up BEFORE such counties were added to the dbase (and who TYPED IN their county), will not have the DBASE RELATIONAL ID applicable to their registration - and thus you get conflicts and errors.

We found the only way to fix this was to MANUALLY change each such customer's details in the admin area, and SELECT their county from the dropdown, then SAVE their record.


Additionally, the STATE dropdown will refer to the selected COUNTRY, and if you have states/counties set up for various countries, then it presents customers with some confusion when they FIRST have to select their STATE/COUNTY and then their COUNTRY and the system then asks them to select their county again...

So, what we did is REVERSE the position of the COUNTRY and STATE fields in the sign-up form.

When the signup form displays, people registering will FIRST select their COUNTRY... and THEN (because the system now knows the COUNTRY), it will present them with the dropdown for COUNTIES/STATES that are relevant to their COUNTRY. (if, of course, the STATES/COUNTIES are defined in the database - otherwise it invites users to type in their county.

tpl_modules_create_account.php

ORIGINAL VERSION

<fieldset>
<legend><?php echo TABLE_HEADING_ADDRESS_DETAILS; ?></legend>
<?php
  if (ACCOUNT_GENDER == 'true') {
?>
<?php echo zen_draw_radio_field('gender', 'm', '', 'id="gender-male"') . '<label class="radioButtonLabel" for="gender-male">' . MALE . '</label>' . zen_draw_radio_field('gender', 'f', '', 'id="gender-female"') . '<label class="radioButtonLabel" for="gender-female">' . FEMALE . '</label>' . (zen_not_null(ENTRY_GENDER_TEXT) ? '<span class="alert">' . ENTRY_GENDER_TEXT . '</span>': ''); ?>
<br class="clearBoth" />
<?php
  }
?>

<label class="inputLabel" for="firstname"><?php echo ENTRY_FIRST_NAME; ?></label>
<?php echo zen_draw_input_field('firstname', '', zen_set_field_length(TABLE_CUSTOMERS, 'customers_firstname', '40') . ' id="firstname"') . (zen_not_null(ENTRY_FIRST_NAME_TEXT) ? '<span class="alert">' . ENTRY_FIRST_NAME_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

<label class="inputLabel" for="lastname"><?php echo ENTRY_LAST_NAME; ?></label>
<?php echo zen_draw_input_field('lastname', '', zen_set_field_length(TABLE_CUSTOMERS, 'customers_lastname', '40') . ' id="lastname"') . (zen_not_null(ENTRY_LAST_NAME_TEXT) ? '<span class="alert">' . ENTRY_LAST_NAME_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

<label class="inputLabel" for="street-address"><?php echo ENTRY_STREET_ADDRESS; ?></label>
  <?php echo zen_draw_input_field('street_address', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_street_address', '40') . ' id="street-address"') . (zen_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="alert">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

<?php
  if (ACCOUNT_SUBURB == 'true') {
?>
<label class="inputLabel" for="suburb"><?php echo ENTRY_SUBURB; ?></label>
<?php echo zen_draw_input_field('suburb', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_suburb', '40') . ' id="suburb"') . (zen_not_null(ENTRY_SUBURB_TEXT) ? '<span class="alert">' . ENTRY_SUBURB_TEXT . '</span>': ''); ?>
<br class="clearBoth" />
<?php
  }
?>

<label class="inputLabel" for="city"><?php echo ENTRY_CITY; ?></label>
<?php echo zen_draw_input_field('city', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_city', '40') . ' id="city"') . (zen_not_null(ENTRY_CITY_TEXT) ? '<span class="alert">' . ENTRY_CITY_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

<?php
  if (ACCOUNT_STATE == 'true') {
    if ($flag_show_pulldown_states == true) {
?>
<label class="inputLabel" for="stateZone" id="zoneLabel"><?php echo ENTRY_STATE; ?></label>
<?php
      echo zen_draw_pull_down_menu('zone_id', zen_prepare_country_zones_pull_down($selected_country), $zone_id, 'id="stateZone"');
      if (zen_not_null(ENTRY_STATE_TEXT)) echo ' <span class="alert">' . ENTRY_STATE_TEXT . '</span>'; 
    }
?>

<?php if ($flag_show_pulldown_states == true) { ?>
<br class="clearBoth" id="stBreak" />
<?php } ?>
<label class="inputLabel" for="state" id="stateLabel"><?php echo $state_field_label; ?></label>
<?php
    echo zen_draw_input_field('state', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_state', '40') . ' id="state"');
    if (zen_not_null(ENTRY_STATE_TEXT)) echo ' <span class="alert" id="stText">' . ENTRY_STATE_TEXT . '</span>';
    if ($flag_show_pulldown_states == false) {
      echo zen_draw_hidden_field('zone_id', $zone_name, ' ');
    }
?>
<br class="clearBoth" />
<?php
  }
?>

<label class="inputLabel" for="postcode"><?php echo ENTRY_POST_CODE; ?></label>
<?php echo zen_draw_input_field('postcode', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_postcode', '40') . ' id="postcode"') . (zen_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="alert">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

<label class="inputLabel" for="country"><?php echo ENTRY_COUNTRY; ?></label>
<?php echo zen_get_country_list('zone_country_id', $selected_country, 'id="country" ' . ($flag_show_pulldown_states == true ? 'onchange="update_zone(this.form);"' : '')) . (zen_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="alert">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?>
<br class="clearBoth" />
</fieldset>

OUR VERSION

<fieldset>
<legend><?php echo TABLE_HEADING_ADDRESS_DETAILS; ?></legend>
<?php
  if (ACCOUNT_GENDER == 'true') {
?>
<?php echo zen_draw_radio_field('gender', 'm', '', 'id="gender-male"') . '<label class="radioButtonLabel" for="gender-male">' . MALE . '</label>' . zen_draw_radio_field('gender', 'f', '', 'id="gender-female"') . '<label class="radioButtonLabel" for="gender-female">' . FEMALE . '</label>' . (zen_not_null(ENTRY_GENDER_TEXT) ? '<span class="alert">' . ENTRY_GENDER_TEXT . '</span>': ''); ?>
<br class="clearBoth" />
<?php
  }
?>

<label class="inputLabel" for="firstname"><?php echo ENTRY_FIRST_NAME; ?></label>
<?php echo zen_draw_input_field('firstname', '', zen_set_field_length(TABLE_CUSTOMERS, 'customers_firstname', '40') . ' id="firstname"') . (zen_not_null(ENTRY_FIRST_NAME_TEXT) ? '<span class="alert">' . ENTRY_FIRST_NAME_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

<label class="inputLabel" for="lastname"><?php echo ENTRY_LAST_NAME; ?></label>
<?php echo zen_draw_input_field('lastname', '', zen_set_field_length(TABLE_CUSTOMERS, 'customers_lastname', '40') . ' id="lastname"') . (zen_not_null(ENTRY_LAST_NAME_TEXT) ? '<span class="alert">' . ENTRY_LAST_NAME_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

<label class="inputLabel" for="street-address"><?php echo ENTRY_STREET_ADDRESS; ?></label>
  <?php echo zen_draw_input_field('street_address', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_street_address', '40') . ' id="street-address"') . (zen_not_null(ENTRY_STREET_ADDRESS_TEXT) ? '<span class="alert">' . ENTRY_STREET_ADDRESS_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

<?php
  if (ACCOUNT_SUBURB == 'true') {
?>
<label class="inputLabel" for="suburb"><?php echo ENTRY_SUBURB; ?></label>
<?php echo zen_draw_input_field('suburb', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_suburb', '40') . ' id="suburb"') . (zen_not_null(ENTRY_SUBURB_TEXT) ? '<span class="alert">' . ENTRY_SUBURB_TEXT . '</span>': ''); ?>
<br class="clearBoth" />
<?php
  }
?>

<label class="inputLabel" for="city"><?php echo ENTRY_CITY; ?></label>
<?php echo zen_draw_input_field('city', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_city', '40') . ' id="city"') . (zen_not_null(ENTRY_CITY_TEXT) ? '<span class="alert">' . ENTRY_CITY_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

<label class="inputLabel" for="country"><?php echo ENTRY_COUNTRY; ?></label>
<?php echo zen_get_country_list('zone_country_id', $selected_country, 'id="country" ' . ($flag_show_pulldown_states == true ? 'onchange="update_zone(this.form);"' : '')) . (zen_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="alert">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

<?php
  if (ACCOUNT_STATE == 'true') {
    if ($flag_show_pulldown_states == true) {
?>
<label class="inputLabel" for="stateZone" id="zoneLabel"><?php echo ENTRY_STATE; ?></label>
<?php
      echo zen_draw_pull_down_menu('zone_id', zen_prepare_country_zones_pull_down($selected_country), $zone_id, 'id="stateZone"');
      if (zen_not_null(ENTRY_STATE_TEXT)) echo ' <span class="alert">' . ENTRY_STATE_TEXT . '</span>'; 
    }
?>

<?php if ($flag_show_pulldown_states == true) { ?>
<br class="clearBoth" id="stBreak" />
<?php } ?>
<label class="inputLabel" for="state" id="stateLabel"><?php echo $state_field_label; ?></label>
<?php
    echo zen_draw_input_field('state', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_state', '40') . ' id="state"');
    if (zen_not_null(ENTRY_STATE_TEXT)) echo ' <span class="alert" id="stText">' . ENTRY_STATE_TEXT . '</span>';
    if ($flag_show_pulldown_states == false) {
      echo zen_draw_hidden_field('zone_id', $zone_name, ' ');
    }
?>
<br class="clearBoth" />
<?php
  }
?>

<label class="inputLabel" for="postcode"><?php echo ENTRY_POST_CODE; ?></label>
<?php echo zen_draw_input_field('postcode', '', zen_set_field_length(TABLE_ADDRESS_BOOK, 'entry_postcode', '40') . ' id="postcode"') . (zen_not_null(ENTRY_POST_CODE_TEXT) ? '<span class="alert">' . ENTRY_POST_CODE_TEXT . '</span>': ''); ?>
<br class="clearBoth" />

</fieldset>

We ALSO make similar changes to tpl_account_edit_default.php (the file that registered users need to CHANGE their address later)

20 years a Zencart User

14 Jul 2012, 9:42 PM
#9
kbear avatar

kbear

New Zenner

Join Date:
Mar 2011
Location:
In a green and pleasant land
Posts:
46
Plugin Contributions:
0

Re: Problem with customer registration - State field

Schoolboy
Thanks so much for a most comprehensive and welcomed explanation.

I guess that sort of sets me up for the rest of the weekend...now where's that gazetteer?

Many thanks from the heart of Buckinghamshire (I think it will be about item 15 in the dropdown)

14 Jul 2012, 9:43 PM
#10
schoolboy avatar

schoolboy

Totally Zenned

Join Date:
Jun 2005
Location:
Cumbria, UK
Posts:
10,327
Plugin Contributions:
0

Re: Problem with customer registration - State field

My advice is to do the following:

When you INSTALL zc for the first time, BEFORE you go live, insert all the STATE/PROVINCE/COUNTY names relevant for your country. For UK users, this poses a bit of a problem, because there is no DEFINITIVE LIST of official UK counties! (Typical UK...).

We go by ISO rules, and I believe there is a plugin that will insert UK counties - but I don't know if these are the "official" ISO names...

Anyway... we have a list we use, and we populate the dbase with this list for the GB country ID.

Kevin Polley has a UK TEMPLATE that will configure a UK store, and if you install it at the SAME TIME and IN CONJUNCTION WITH a ZC install, it will give you a fully-compliant UK store. I haven't been in touch with Kevin for a few years now, so I don't know how compatible his template is with ver 1.5. We modified his 1.3.7 version to meet the requirements of 1.3.9.

We have a "manual work-around" when building a UK store on 1.5

You should LOAD the counties/provinces/states for your country (and all others you intend selling in) BEFORE you unleash your store on the general public.

Also, before you launch the site, configure the selector for county as DROP-DOWN, and set up your ZONE DEFINITIONS as well...

If you make changes later, you will have issues.

20 years a Zencart User

14 Jul 2012, 9:56 PM
#11
kbear avatar

kbear

New Zenner

Join Date:
Mar 2011
Location:
In a green and pleasant land
Posts:
46
Plugin Contributions:
0

Re: Problem with customer registration - State field

Thanks once again

Fortunately my 'proper' job is a database designer / data manager and so I actually hold all that information anyway, I was kidding about the gazetteer.

I'd done all the hard work of changing the spellings, date formats etc so all I have to do is change the code for the pages you described and import my data using PHP admin

Thanks so much for your help. Have a good weekend

3 Oct 2012, 8:33 AM
#12
thannaree avatar

thannaree

Zen Follower

Join Date:
Dec 2010
Location:
Thailand
Posts:
304
Plugin Contributions:
1

Re: Problem with customer registration - State field

schoolboy:

We ALSO make similar changes to tpl_account_edit_default.php (the file that registered users need to CHANGE their address later)

In version 1.5 it's in tpl_modules_address_book_details.php