Zen Cart Logo
Forums / General Questions / Changing required fields on account form for Irish customers

Changing required fields on account form for Irish customers

Locked

Views: 5,032

Results 1 to 8 of 8
This thread is locked. New replies are disabled.
24 Nov 2007, 5:43 PM
#1
tomzo avatar

tomzo

New Zenner

Join Date:
Mar 2007
Posts:
28
Plugin Contributions:
0

Changing required fields on account form for Irish customers

Hello,

most of the customers visiting my site are from Ireland.  We're so wee we don't have post codes (well we do but there not used by postal system).  I've looked at the \templates\my_template\templates\tpl_modules_create_account.php as I figured this is where I'd need to make some changes.  Basically I would like it to function so that if the selected country is Ireland a postcode is not required, so validation will be skipped and the red * won't appear for postcode.  I'm not sure how to achieve this or if it can be done using the override system.   Could anyone give me some pointers?

Thanks
T

1 Dec 2007, 10:58 AM
#2
tomzo avatar

tomzo

New Zenner

Join Date:
Mar 2007
Posts:
28
Plugin Contributions:
0

Re: Changing required fields on account form for Irish customers

I saw a thread that recommended just adding a note to the post code saying if ireland is country chosen set postcode to "none".

I do need the postcode to be required for non-irish visitors, so what I ideally would like to do is to change the post code to be not required when ireland is selected in the country drop down list.  I know it can be done, but have never had to do it, so just wondered if anyone had already done this.
1 Dec 2007, 7:22 PM
#3
tomzo avatar

tomzo

New Zenner

Join Date:
Mar 2007
Posts:
28
Plugin Contributions:
0

Re: Changing required fields on account form for Irish customers

ok, I've think I've found the solution. Can anyone tell me if I'm missing something before I put it into production, please?

skip post code check for given country code
includes/modules/pages/login/jscript_form_check.php

//103 is code for Ireland, therefore skip postcode check for ireland.  Codes can be seen 
//by viewing source of page with country drop down list.
 if (document.getElementById('country').value != 103)  {
    check_input("postcode", 4, "Your Post/ZIP Code must contain a minimum of 4 characters.");
  }
```hide post code if given country is selected
**includes/modules/pages/login/jscript_addr_pulldowns.php**

//placed at top of function update_zone
if (document.getElementById('country').value == 103){
document.getElementById('hide_postcode').style.visibility='hidden';
} else {
document.getElementById('hide_postcode').style.visibility='visible';
}


**make update happen if country list is changed

<label class="inputLabel" for="country"><?php echo ENTRY_COUNTRY; ?></label>

<?php echo zen_get_country_list('zone_country_id', $selected_country, 'id="country" '. 'onchange="update_zone(this.form);"') . (zen_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="alert">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?> <br class="clearBoth" /> </fieldset> ```add div to contain elements that will be hidden ``` <div id="hide_postcode"> <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" /> </div> ```This works. The top two edits should be added to **includes/modules/pages/create_account/jscript_form_check.php **and **includes/modules/pages/create_account/jscript_addr_pulldowns.php **The files in login and create_account have the same data.

Hope this helps someone with the same problem and is a valid solution to the problem. If any zen pros see issues please let me know ASAP.

2 Dec 2007, 1:57 AM
#4
tomzo avatar

tomzo

New Zenner

Join Date:
Mar 2007
Posts:
28
Plugin Contributions:
0

Re: Changing required fields on account form for Irish customers

Had to make the following change in includes/templates/YOUR_TEMPLATE/create_account.php

if (strlen($postcode) < ENTRY_POSTCODE_MIN_LENGTH && $country != 103) {
   $error = true;
   $messageStack->add('create_account', ENTRY_POST_CODE_ERROR);
 }

as I was getting a postcode error message when form was submitted.

Now I have one last error message that comes up, it says "Please select a state from the drop down list" (or words to that effect). I was somewhat hasty, me thinks, in editing the **includes/templates/YOUR_TEMPLATE/templates/tpl_modules_create_account.php **file.

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

<br class="clearBoth" />
</fieldset>

I think this edit is causing the state drop down list to be required though it is not shown. Users can still sign up but after the first form submit they have to go back and choose a state from the drop down list before they can continue. Anyone suggest how to fix this problem??

2 Dec 2007, 1:25 PM
#5
tomzo avatar

tomzo

New Zenner

Join Date:
Mar 2007
Posts:
28
Plugin Contributions:
0

Re: Changing required fields on account form for Irish customers

I resolved the last error by adding the following to includes/modules/YOUR_TEMPLATE/create_account.php.

 if ($found_exact_iso_match) {
        $zone_id = $zone->fields['zone_id'];
        $zone_name = $zone->fields['zone_name'];
      } else {
          if ($country != 103) {
            $error = true;
            $error_state_input = true;
            $messageStack->add('create_account', ENTRY_STATE_ERROR_SELECT);
          }
      }
```and changed includes/templates/YOUR_TEMPLATE/templates/tpl_modules_create_account.php
 to the more sensible format.

<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);"' : 'onchange="update_country();"')) . (zen_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="alert">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?> <br class="clearBoth" /> </fieldset> ```This means adding an update_country function to the jscript_addr_pulldowns file.
function update_country() {
     if (document.getElementById('country').value == 103){
                document.getElementById('hide_postcode').style.visibility='hidden';
     else {
                document.getElementById('hide_postcode').style.visibility='visible';
       }
}

```  Note you  need to add this line to top of update_zone to call update_country on load: ```
 update_country(); 

So all is well for Irish customers. The states pull down menu does not show up for US customers though until after the form is submitted, then an error message is displayed telling them to select a state from the pull down list, is this a bug?

2 Dec 2007, 5:39 PM
#6
tomzo avatar

tomzo

New Zenner

Join Date:
Mar 2007
Posts:
28
Plugin Contributions:
0

Re: Changing required fields on account form for Irish customers

:oops:
The states pull down menu did not show up because it hadn't been enabled in the admin section ;( I've enabled it and taken out the update_country function and the call to update_country and all is well at last. Phew.

The results can be seen here, http://www.healingharvest.ie. Ireland is the default country, notice the lack of post code section. If a user selects a different country the postcode field is inserted.

:clap:

2 Dec 2007, 7:17 PM
#7
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: Changing required fields on account form for Irish customers

Just a quick note: I see the link "Log out" on your site when I have not even logged in yet. Can be confusing.
And leaving My Account and Log In/Out links at the bottom of the site may not be the best choice.

8 Dec 2007, 6:14 PM
#8
tomzo avatar

tomzo

New Zenner

Join Date:
Mar 2007
Posts:
28
Plugin Contributions:
0

Re: Changing required fields on account form for Irish customers

I hear ya, changed the login / logout problem, with the help of this thread http://www.zen-cart.com/forum/showthread.php?t=79156. I'll have to get around to adding a sidebox for logins and take it out of the footer. Thanks T.