Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,262
    Plugin Contributions
    3

    Default Force State/Province dropdown to show relevant options for selected COUNTRY

    If you use the State/Province DROPDOWN for your customer address-capture forms, you will notice that, as the input field for STATE/PROVINCE appears ABOVE the input field for COUNTRY, the options for STATE/PROVINCE will be those of the default COUNTRY.

    This can be annoying for non-default country customers, who will try to see their STATE/PROVINCE in the dropdown, and won't!

    It will appear only AFTER they choose their country (if, of course these zones are configured.)

    If you put the input field for COUNTRY, above the input field for STATE/PROVINCE, then they select their COUNTRY first.

    This will then populate the STATE/PROVINCE dropdown with appropriate names - or indicate a manual input...

    There are TWO files to change:

    tpl_modules_address_book_details.php
    and
    tpl_modules_create_account.php

    Find these two bits of code:

    This one for STATE/PROVINCE
    PHP Code:
    <?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 '&nbsp;<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 '&nbsp;<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
      
    }
    ?>

    This one for COUNTRY
    PHP 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);"' '')) . (zen_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="alert">' ENTRY_COUNTRY_TEXT '</span>'''); ?>
    <br class="clearBoth" />

    Then make sure you move the COUNTRY section to above the STATE/PROVINCE section... like this:

    PHP 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);"' '')) . (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 '&nbsp;<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 '&nbsp;<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
      
    }
    ?>
    SAVE RESULTANT PHP FILES IN YOUR CUSTOM OR OVER-RIDES FOLDER
    19 years a Zencart User

  2. #2
    Join Date
    Nov 2006
    Location
    Dartmouth, NS Canada
    Posts
    2,378
    Plugin Contributions
    0

    Default Re: Force State/Province dropdown to show relevant options for selected COUNTRY

    Hi schoolboy,

    You've misbehaved! Go stand in the corner.

    On my 1.3.7 test system, this modification drops the State/Province drop-down and field as well as the Post/Zip Code fields down below (outside of) the Address Details box (on the create account page page, at least).

    I don't understand PHP well enough to fiddle it to get them back into the box. I'll bet you can though.

    Rob

  3. #3
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,262
    Plugin Contributions
    3

    Default Re: Force State/Province dropdown to show relevant options for selected COUNTRY

    OOps...

    Perhaps the final
    PHP Code:
    <?php 
      

    ?>
    shouldn't be included...

    The edit works for me...

    www.commotionstore.co.uk (go to login)

    -----------------------------------------------------------

    I'll have a look at the code in my actual files... then re-post.
    19 years a Zencart User

  4. #4
    Join Date
    Nov 2006
    Location
    Dartmouth, NS Canada
    Posts
    2,378
    Plugin Contributions
    0

    Default Re: Force State/Province dropdown to show relevant options for selected COUNTRY

    Hi,

    I'm sure it's something like that, but despite literally a decade of programming in scripting languages, PHP remains Greek to me -- and I ain't Greek! I wish I had time to study it, but not right now.

    By the way, that's a great site. I see we share a desire to simplify, simplify! And great products too.

    Rob

  5. #5
    Join Date
    Feb 2010
    Posts
    58
    Plugin Contributions
    0

    Default Re: Force State/Province dropdown to show relevant options for selected COUNTRY

    i can show stateZone in admin/invoice.php ?

 

 

Similar Threads

  1. Replies: 4
    Last Post: 9 Apr 2016, 07:53 PM
  2. Modify State/Province dropdown list
    By kdipaolo in forum General Questions
    Replies: 1
    Last Post: 9 Jan 2012, 07:15 PM
  3. Replies: 2
    Last Post: 29 Nov 2009, 05:35 PM
  4. Replies: 6
    Last Post: 31 Mar 2009, 04:59 AM
  5. Replies: 6
    Last Post: 19 Sep 2007, 09:48 AM

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