Page 1 of 2 12 LastLast
Results 1 to 10 of 12
  1. #1
    Join Date
    Mar 2007
    Posts
    28
    Plugin Contributions
    0

    Default 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

  2. #2
    Join Date
    Mar 2007
    Posts
    28
    Plugin Contributions
    0

    Default 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.

  3. #3
    Join Date
    Mar 2007
    Posts
    28
    Plugin Contributions
    0

    Default 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

    Code:
    //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

    Code:
    //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';
      }
    includes/templates/YOUR_TEMPLATE/templates/tpl_modules_create_account.php

    make update happen if country list is changed
    Code:
    <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
    Code:
    <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.

  4. #4
    Join Date
    Mar 2007
    Posts
    28
    Plugin Contributions
    0

    Default Re: Changing required fields on account form for Irish customers

    Had to make the following change in includes/templates/YOUR_TEMPLATE/create_account.php
    Code:
    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.

    Code:
    <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??

  5. #5
    Join Date
    Mar 2007
    Posts
    28
    Plugin Contributions
    0

    Default 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.
    Code:
     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.

    Code:
    <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.

    Code:
    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:
    Code:
     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?

  6. #6
    Join Date
    Mar 2007
    Posts
    28
    Plugin Contributions
    0

    Default Re: Changing required fields on account form for Irish customers


    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.


  7. #7
    Join Date
    Oct 2006
    Posts
    5,477
    Plugin Contributions
    11

    Default 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.
    I no longer provide installation support on forum for all my modules. However, if there are real bugs with the modules please feel free to contact me

  8. #8
    Join Date
    Mar 2007
    Posts
    28
    Plugin Contributions
    0

    Default 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.

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. New account setup for required fields?
    By shiningfaery in forum Customization from the Admin
    Replies: 2
    Last Post: 13 Oct 2010, 08:56 PM
  2. Changing Required Fields for New Customer Sign-Up
    By jackibar in forum Templates, Stylesheets, Page Layout
    Replies: 1
    Last Post: 12 Aug 2009, 09:43 PM
  3. Required Fields For Account Creation
    By kwarner in forum Customization from the Admin
    Replies: 2
    Last Post: 4 Dec 2008, 06:45 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR