Results 1 to 5 of 5
  1. #1
    Join Date
    Jun 2005
    Location
    Hertfordshire, UK
    Posts
    9,955
    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
    Our latest project is Pet Tags.

  2. #2
    Join Date
    Nov 2006
    Location
    Dartmouth, NS Canada
    Posts
    2,369
    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
    Breakfast: the most important donut of the day.

  3. #3
    Join Date
    Jun 2005
    Location
    Hertfordshire, UK
    Posts
    9,955
    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.
    Our latest project is Pet Tags.

  4. #4
    Join Date
    Nov 2006
    Location
    Dartmouth, NS Canada
    Posts
    2,369
    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
    Breakfast: the most important donut of the day.

  5. #5
    Join Date
    Feb 2010
    Posts
    19
    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. Help making Template
    By Shiftypow in forum Basic Configuration
    Replies: 8
    Last Post: 4 Jun 2007, 07:20 AM
  2. [Done v1.3.6] Country Dropdown Bug
    By zytroop in forum Bug Reports
    Replies: 60
    Last Post: 20 Jan 2007, 12:37 PM
  3. country dropdown not working
    By ftrTechy in forum Upgrading from 1.3.x to 1.3.9
    Replies: 22
    Last Post: 17 Sep 2006, 02:03 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
  •