Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Add blank to top of the state list in create_account.php


Supertex

Recommended Posts

I've noticed the account creation page initially allows a text box for the state, and then if there was an error on submission, switches to a drop down.  

 

I've seen several customers that for whatever reason, end up creating another account...and apparently try to use the same email address.  When the page refreshes, telling them that email is already in use, it has already taken the country designation into account, and populated the 'State' drop-down.  

 

The problem is, the customer doesn't realize this - and of course the state selection is defaulted to whatever is atop the list, so they proceed on without making the proper selection.  Next thing you know we have a ton of accounts with Alabama (for the US case) incorrectly defined at their state...shipping modules cant match the ZIP to the state...and then the emails begin.

 

Seems to me a good way to remedy this would be for the default selection to be blank, as it would require action from the user before the form could be submitted.

 

I know there are mods that default the state field to a drop down, and/or 'remember' the field's contents upon a page refresh.  Those may well remedy the issue, but how difficult would it be to add the blank to the top of the drop down state list?  And would that cause any issues anywhere else?

Link to comment
Share on other sites

How about code to prompt "Select your state"? I understand that there is an HTML5 attribute to put a prompt message in such a place. You could also force a "state" with that text at the top of the list, and reject it if the customer doesn't make a selection. That could be done not only on the server, but also in Javascript. Anyway, a prompt would be far better than a blank (or a default state).

 

Maybe it would be more fruitful to attack why some customers are trying to create a second account. Perhaps they forgot they had an account already, or forgot the password? Something in the error message about the email address being duplicated might advise them how to deal with forgotten accounts/passwords.

Link to comment
Share on other sites

@@burt

 

That's where I was headed, but I was looking at the html_output file.  Changing the create_account.php did the trick: 

    if ($process == true) {
      if ($entry_state_has_zones == true) {
        $zones_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
        $zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . (int)$country . "' order by zone_name");
        while ($zones_values = tep_db_fetch_array($zones_query)) {
          $zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);
        }
        echo tep_draw_pull_down_menu('state', $zones_array, $zones_array[$zone_id]['id']);
      } else {
        echo tep_draw_input_field('state');
      }
    } else {
      echo tep_draw_input_field('state');
    }

@@MrPhil

 

 

 

...You could also force a "state" with that text at the top of the list, and reject it if the customer doesn't make a selection....

 

That's exactly what I was after.  The state field is subject to minimum values (2), so it cannot be left blank. Having the blank at the top of the drop down by default enforces that requirement.  If they DO enter a state correctly, then this line will make it persistent, even after a page refresh converts the text field to the drop down:

 

echo tep_draw_pull_down_menu('state', $zones_array, $zones_array[$zone_id]['id'])

 

I found that in another post, but had to make one small change in order for it to work with the 'blank', else it would give TN when TX had been entered.  Originally it was:

 

echo tep_draw_pull_down_menu('state', $zones_array, $zones_array[$zone_id - 1]['id']) 

 

Problem solved, as far as I can tell.  

 

Thank you both, very much.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...