Jump to content
Latest News: (loading..)

Recommended Posts

The function tep_draw_pull_down_menu should be fixed as well:

find:

if (tep_not_null($parameters)) $field .= ' ' . $parameters;

replace with:

    if (tep_not_null($parameters)) {
        if (strpos($parameters, 'required') !== false) {
            $parameters .= ' oninvalid="this.setCustomValidity(\'' . FORM_INPUT_VALUE_MISSING. '!\')" onchange="this.setCustomValidity(\'\')"';

        }
        $field .= ' ' . $parameters;
    }

 

Share this post


Link to post
Share on other sites

Hi,

If a country does not have zones, we do not need the
state input entry.

This is what I did:

in
includes/modules/checkout_new_address.php
includes/modules/checkout_new_address.php
account_pwa.php (I haven't tested this yet)

replace the block:

<?php
  if (ACCOUNT_STATE == 'true') {
?>
  ...
  <?php
  }
?>

with the following lines:

<?php
  if (ACCOUNT_STATE == 'true') {
?>
      <div id="results" class="form-group has-feedback">
          <?php
                  $zone_id = 0;
                  $check_query = tep_db_query("select count(*) as total from " . TABLE_ZONES . " where zone_country_id = '" . $country . "'");
                  $check = tep_db_fetch_array($check_query);
                  $entry_state_has_zones = ($check['total'] > 0);
                if ($entry_state_has_zones == true) {
                    $zones_array = array();
                    $zones_array[0] = array('id' => '', 'text' => PULL_DOWN_DEFAULT);                        
                    $zones_query = tep_db_query("select zone_name from " . TABLE_ZONES . " where zone_country_id = '" . $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 '<label for="inputState" class="control-label col-sm-3">' . ENTRY_STATE .'</label>';
                    echo '<div class="col-sm-9">';                    
                    echo tep_draw_pull_down_menu('state', $zones_array, (isset($entry['entry_country_id']) ? tep_get_zone_name($entry['entry_country_id'], $entry['entry_zone_id'], $entry['entry_state']) : ''), 'required aria-required="true" id="inputState"');
                    echo FORM_REQUIRED_INPUT;
                    echo '</div>';
                    if (tep_not_null(ENTRY_STATE_TEXT)) echo '<span class="help-block">' . ENTRY_STATE_TEXT . '</span>';
                }
              ?>
      </div>
<?php
  }
?>


in get_states.php

find:
     if ($entry_state_has_zones == true) {
          $zones_array = array();
       $zones_array[0] = array('id' => '', 'text' => PULL_DOWN_DEFAULT);                        
       $zones_query = tep_db_query("select zone_name from zones where zone_country_id = '" . (int)$state . "' 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, '', 'required aria-required="true" id="inputState"');
       echo FORM_REQUIRED_INPUT;
     } else {
          echo tep_draw_input_field('state', NULL, 'id="inputState" class="form-control" required aria-required="true" placeholder="' . ENTRY_STATE    . '"');
          echo FORM_REQUIRED_INPUT;
     }
    
replace with:

     if ($entry_state_has_zones == true) {
          $zones_array = array();
       $zones_array[0] = array('id' => '', 'text' => PULL_DOWN_DEFAULT);                        
       $zones_query = tep_db_query("select zone_name from zones where zone_country_id = '" . (int)$state . "' 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 '<label for="inputState" class="control-label col-sm-3">' . ENTRY_STATE .'</label>';
       echo '<div class="col-sm-9">';
       echo tep_draw_pull_down_menu('state', $zones_array, '', 'required aria-required="true" id="inputState"');
       echo FORM_REQUIRED_INPUT;
       echo '</div>';
     }

 

Share this post


Link to post
Share on other sites

If a country does not have zones in the oscommerce zones table, it doesn't mean that zones are not used. That's why the input field is still available for manual customer input like in the standard forms.

If your modification is good for your store ok, but it is not a generic modification which should be added to the add-on package (in my opinion).

Share this post


Link to post
Share on other sites

Most of our customers are from Finland, i.e. no zones. I just do not love unnecessary input fields.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×