OSCOMMERCE SUPPORT CALL 702-453-3332

 

Help - Search - Members - Calendar
Full Version: Change default country dropdown list
osCommerce Community Support Forums > osCommerce Online Merchant v2.x > Contributions / Add-Ons > Languages and Zones
nanorock4
Does anyone know how to change the country dropdown lists to default to a specific country. As you know they default to aphabetical order. I want to be able to have United States to be listed out of order at the top of the list with the others in the normal order. Is this a php edit or a SQL edit and where and how would it be done?

Thanks,
nanorock4
QUOTE (nanorock4 @ Dec 18 2006, 09:54 AM) *
Does anyone know how to change the country dropdown lists to default to a specific country. As you know they default to aphabetical order. I want to be able to have United States to be listed out of order at the top of the list with the others in the normal order. Is this a php edit or a SQL edit and where and how would it be done?

Thanks,



Ok I found it after digging through the custimization info.

You can also make any country appear by default while still having the pull down list available.

In includes/functions/html_output.php at about line 299 find:

$countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));

Replace (for the United States) with...

// $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
$countries_array = array(array('id' => '223', 'text' => 'United States'));

I just commented out the original line to keep it as a reference.
You can change the country id and the text in this line to make any country appear by default.


Thanks anyway
bentsteal
Hi actually you want to change the includes/languages/english.php

at about line 140

// pull down default text
define('PULL_DOWN_DEFAULT', 'United States');
ehong33234
QUOTE (nanorock4 @ Dec 18 2006, 10:19 AM) *
Ok I found it after digging through the custimization info.

You can also make any country appear by default while still having the pull down list available.

In includes/functions/html_output.php at about line 299 find:

$countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));

Replace (for the United States) with...

// $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
$countries_array = array(array('id' => '223', 'text' => 'United States'));

I just commented out the original line to keep it as a reference.
You can change the country id and the text in this line to make any country appear by default.
Thanks anyway


Your method worked perfectly, thanks!
vizeislemleri
QUOTE (nanorock4 @ Dec 18 2006, 06:19 PM) *
Ok I found it after digging through the custimization info.

You can also make any country appear by default while still having the pull down list available.

In includes/functions/html_output.php at about line 299 find:

$countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));

Replace (for the United States) with...

// $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));
$countries_array = array(array('id' => '223', 'text' => 'United States'));

I just commented out the original line to keep it as a reference.
You can change the country id and the text in this line to make any country appear by default.
Thanks anyway



thnks a lot
bluewebco
A cleaner way to do this, whilst preserving the OSCommerce languages system is:

in catalogue/includes/languages/english.php (& for all languages in use):

Change:
define('PULL_DOWN_DEFAULT', 'Please Select');
to
define('PULL_DOWN_DEFAULT', '**Default Country Here**');

Then below that, add:
define('PULL_DOWN_DEFAULT_VALUE', '**your country id here**');


In catalogue/includes/functions/html_output.php

Change:
$countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));

To:
$countries_array = array(array('id' => PULL_DOWN_DEFAULT_VALUE, 'text' => PULL_DOWN_DEFAULT));
Jesse J
QUOTE (bluewebco @ Mar 24 2007, 10:30 AM) *
A cleaner way to do this, whilst preserving the OSCommerce languages system is:

in catalogue/includes/languages/english.php (& for all languages in use):

Change:
define('PULL_DOWN_DEFAULT', 'Please Select');
to
define('PULL_DOWN_DEFAULT', '**Default Country Here**');

Then below that, add:
define('PULL_DOWN_DEFAULT_VALUE', '**your country id here**');
In catalogue/includes/functions/html_output.php

Change:
$countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT));

To:
$countries_array = array(array('id' => PULL_DOWN_DEFAULT_VALUE, 'text' => PULL_DOWN_DEFAULT));


FYI I did the above and it made the default for my Manufactures list United States. So this is not a working solution.
kimondo
QUOTE (Jesse J @ Apr 13 2007, 07:28 PM) *
FYI I did the above and it made the default for my Manufactures list United States. So this is not a working solution.


Just had the same problem i'd select United Kingdom and it would show up as United States - turned out that the array 'id' => '223' was causing it to switch to United States - even if you change the text after. So to change it for other countries you need the number. In my case the UK was 222 so the resulting code is:

$countries_array = array(array('id' => '222', 'text' => 'United Kingdom'));

so the id and the text have now been changed. To find the others I think you can use view source on the resulting page, or just guess.
enigma1
QUOTE (nanorock4 @ Dec 18 2006, 09:54 AM) *
Does anyone know how to change the country dropdown lists to default to a specific country. As you know they default to aphabetical order. I want to be able to have United States to be listed out of order at the top of the list with the others in the normal order. Is this a php edit or a SQL edit and where and how would it be done?

Thanks,

you can use the active countries
http://www.oscommerce.com/community/contributions,3607
dexters
is there a way to bring my 3 neighborhood countrys on top and the others down?

please choose:
germany
austria
swiss
---------
rest of the world
spain
usa
...
...
...
.
d_paulo
Hi guys,

here's the problem: I just modified the all files and everything seems to be ok except 2 files that I realy don't know how to figured out

files: 1. check_out_shipping.php (when you want to add a new shipping address)
2. checkout_payment_address.php (When you want to add a new Billing address)


does anyone know how to change the state filed to have pre-selected the state that I want (not country, that one I have fix it)

any help will be nice smile.gif
d_paulo
here's the code from the checkout_shipping_address.php


CODE
<?php
      $radio_buttons = 0;

      $addresses_query = tep_db_query("select address_book_id, entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "'");
      while ($addresses = tep_db_fetch_array($addresses_query)) {
        $format_id = tep_get_address_format_id($addresses['country_id']);
?>


Where can set the default state/provincie id ?
WS Evolution
QUOTE (d_paulo @ Oct 30 2007, 10:28 PM) *
here's the code from the checkout_shipping_address.php
CODE
<?php
      $radio_buttons = 0;

      $addresses_query = tep_db_query("select address_book_id, entry_firstname as firstname, entry_lastname as lastname, entry_company as company, entry_street_address as street_address, entry_suburb as suburb, entry_city as city, entry_postcode as postcode, entry_state as state, entry_zone_id as zone_id, entry_country_id as country_id from " . TABLE_ADDRESS_BOOK . " where customers_id = '" . (int)$customer_id . "'");
      while ($addresses = tep_db_fetch_array($addresses_query)) {
        $format_id = tep_get_address_format_id($addresses['country_id']);
?>


Where can set the default state/provincie id ?



Add

CODE
$zones_array[] = array('id' => '', 'text' => PULL_DOWN_DEFAULT);


Above

CODE
$zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);


and change to

CODE
$zones_array[] .= array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);


NOTE the
QUOTE
.=


in create_account.php and any other pages that need it.
WS Evolution
Sorry the code should be like this for it to work correctly:



CODE
    $zones_array[] = array('id' => '', 'text' => PULL_DOWN_DEFAULT);
        while ($zones_values = tep_db_fetch_array($zones_query)) {

          $zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']);

        }
vtwebhost
I have found the simplest way to set a default country is to make the following change to includes/functions/html_output.php on or around line 303..

Look for: function tep_get_country_list($name, $selected = '', $parameters = '') {

Change $selected = '' to $selected = '223' so it looks like this...

function tep_get_country_list($name, $selected = '223', $parameters = '') {

That would make USA the default country. For those in other countries just substitute 223 with your country.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.