Guest Posted December 18, 2006 Share Posted December 18, 2006 (edited) 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, Edited December 18, 2006 by nanorock4 Quote Link to comment Share on other sites More sharing options...
Guest Posted December 18, 2006 Share Posted December 18, 2006 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 Quote Link to comment Share on other sites More sharing options...
Guest Posted January 12, 2007 Share Posted January 12, 2007 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'); Quote Link to comment Share on other sites More sharing options...
ehong33234 Posted February 8, 2007 Share Posted February 8, 2007 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! Quote Link to comment Share on other sites More sharing options...
vizeislemleri Posted February 11, 2007 Share Posted February 11, 2007 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 Quote Link to comment Share on other sites More sharing options...
designgroop Posted March 24, 2007 Share Posted March 24, 2007 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)); Quote Link to comment Share on other sites More sharing options...
Jesse J Posted April 13, 2007 Share Posted April 13, 2007 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. Quote Link to comment Share on other sites More sharing options...
kimondo Posted May 1, 2007 Share Posted May 1, 2007 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. Quote Link to comment Share on other sites More sharing options...
Guest Posted May 1, 2007 Share Posted May 1, 2007 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 Quote Link to comment Share on other sites More sharing options...
dexters Posted October 21, 2007 Share Posted October 21, 2007 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 ... ... ... . Quote Link to comment Share on other sites More sharing options...
d_paulo Posted October 30, 2007 Share Posted October 30, 2007 (edited) 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 :) Edited October 30, 2007 by d_paulo Quote Link to comment Share on other sites More sharing options...
d_paulo Posted October 30, 2007 Share Posted October 30, 2007 (edited) here's the code from the checkout_shipping_address.php <?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 ? Edited October 30, 2007 by d_paulo Quote Link to comment Share on other sites More sharing options...
WS Evolution Posted November 21, 2007 Share Posted November 21, 2007 (edited) here's the code from the checkout_shipping_address.php <?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 $zones_array[] = array('id' => '', 'text' => PULL_DOWN_DEFAULT); Above $zones_array[] = array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']); and change to $zones_array[] .= array('id' => $zones_values['zone_name'], 'text' => $zones_values['zone_name']); NOTE the .= in create_account.php and any other pages that need it. Edited November 21, 2007 by WS Evolution Quote Link to comment Share on other sites More sharing options...
WS Evolution Posted November 21, 2007 Share Posted November 21, 2007 Sorry the code should be like this for it to work correctly: $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']); } Quote Link to comment Share on other sites More sharing options...
vtwebhost Posted November 25, 2007 Share Posted November 25, 2007 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. Quote Link to comment Share on other sites More sharing options...
sunrise99 Posted November 13, 2013 Share Posted November 13, 2013 I tried various ways to output a sorted countries list, changing the country I wanted at top to be ID 0 and whatnot, didnt work. Finally I relaized I was overlooking the obvious of using <option .... selected> Thankfully, the requisite functions have built-in "selected" handling, thus setting your default country is easy. Edit create_account.php and find CODE <tr> <td class="main"><?php echo ENTRY_COUNTRY; ?></td> <td class="main"><?php echo tep_get_country_list('country') . ' ' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td> </tr> you want to change this line CODE php echo tep_get_country_list('country') . to be CODE php echo tep_get_country_list('country','223') . 223 == the country ID for United States. YOu can set that to be any country by looking either in the database countries list for your countries ID, or even easier, look at the HTML of the create_account.php page and find where the country drop down list is, search for your country and grab the "value". Quote Link to comment Share on other sites More sharing options...
Supertex Posted February 11, 2015 Share Posted February 11, 2015 Here is an interesting fix for several of the requests in this thread, although it does require a modification to the "countries" table in your DB. Add a column named "countries_sort" that's type "int" and an appropriate length for a default within which you can fully enumerate the countries you want at the top of the list. So if you want 3 countries at the top, your default will be set at "4". Then go in and enumerate in order the countries you want at the top of the list, starting with 0 for the top, 1 for second, etc. Then just go into general.php and find (ctrl+f) the function "tep_get_countries." There's an if, followed by two 'else' statements, and a query for each. In the last query, add "countries_sort, " to the 'select' statement, and change the 'order by' to "order by countries_sort, countries_name" That will cause the countries drop down to retain the initial blank, but when the drop down button is pushed, the countries you chose to specify first will be at the top of the list. This way, it doesn't screw with the mechanics, it just changes the order of the array that holds all the countries. douglaswalker 1 Quote osC v2.3.1 MySQL v8.0.32 PHP v5.6.40 Installed addons: . Attribute Sets Plus .. Create Account & Manual Order Maker .. Customer Testimonials 2.3.4 .. Customer Blacklist .. Dynamic Info Pages .. FedEx Web Svcs v9 .. Filtered Sales Report .. Generic Box .. Google XML Sitemap SEO .. Maximum Order Value .. Modular Front Page .. Monthly Sales & Tax Report .. Multiple Products Manager .. Must Accept Terms & Conditions .. Order Editior .. PDF Customer Invoice .. Price in Cart Only .. Product Sort/Order .. Product Sort in Cart .. Quantity Discounts .. Restrict Delivery Methods .. SEO Header Tags - Reloaded .. Separate Pricing Per Customer .. Simpler Admin Session Length Control .. Sitemap SEO .. Show Free Ship + Modules .. Specials by Category for SPPC .. Store Mode (open|closed|maintenance) .. Store Pickup Shipping .. Theme Switcher .. Ultimate SEO URLs 5 Pro .. UPS XML Rates & Svcs 1.4 .. USPS methods 7.3.1 .. Who's Online Dashboard . Fixes: Add to cart -> 'product not found' : FIX Login issues with IE 11 : FIX Tools: Incredibly Handy: osC Xref Link to comment Share on other sites More sharing options...
Supertex Posted February 11, 2015 Share Posted February 11, 2015 And eh...since I'm resurrecting an ancient thread...I might toss this question in: How would a guy go about making the states drop-down populate 'onclick' of a country from its drop-down? Seems silly to have to submit an incomplete form just to get the right array of states. We could move the country up before the state selection and the whole thing would flow better. Quote osC v2.3.1 MySQL v8.0.32 PHP v5.6.40 Installed addons: . Attribute Sets Plus .. Create Account & Manual Order Maker .. Customer Testimonials 2.3.4 .. Customer Blacklist .. Dynamic Info Pages .. FedEx Web Svcs v9 .. Filtered Sales Report .. Generic Box .. Google XML Sitemap SEO .. Maximum Order Value .. Modular Front Page .. Monthly Sales & Tax Report .. Multiple Products Manager .. Must Accept Terms & Conditions .. Order Editior .. PDF Customer Invoice .. Price in Cart Only .. Product Sort/Order .. Product Sort in Cart .. Quantity Discounts .. Restrict Delivery Methods .. SEO Header Tags - Reloaded .. Separate Pricing Per Customer .. Simpler Admin Session Length Control .. Sitemap SEO .. Show Free Ship + Modules .. Specials by Category for SPPC .. Store Mode (open|closed|maintenance) .. Store Pickup Shipping .. Theme Switcher .. Ultimate SEO URLs 5 Pro .. UPS XML Rates & Svcs 1.4 .. USPS methods 7.3.1 .. Who's Online Dashboard . Fixes: Add to cart -> 'product not found' : FIX Login issues with IE 11 : FIX Tools: Incredibly Handy: osC Xref Link to comment Share on other sites More sharing options...
zocla Posted September 6, 2016 Share Posted September 6, 2016 (edited) An easy work around: I just added a blank space in front of the country name and voila, it appears first. and It is not very noticeable.I guess one could add two spaced and three spaces to have three countries appearing in a certain order. Edited September 6, 2016 by zocla Quote Link to comment Share on other sites More sharing options...
♥kymation Posted September 6, 2016 Share Posted September 6, 2016 @@zocla Did you test that in all modern browsers? The last time I checked, some browsers did not work with that trick. Regards Jim Quote See my profile for a list of my addons and ways to get support. Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.