boxtel Posted June 21, 2005 Posted June 21, 2005 What I use to pre-select the country in create account and order info of pwa. This will prevent a page refresh in 80% of the cases because of a country change. the function which is in general.php. most users of the visitors stat contribution will recognize this as it is in there as well without the osc codes. Note that I only put in the osc country codes I support. function tep_get_country_by_language($country_code, $give_code = false) { $code1 = substr($country_code,0,2); $code2 = substr($country_code,3,2); $country_name = ''; $ctry_code = ''; if ($code1 == "af") {$country_name = 'Africa'; } elseif ($code1 == "ar") {$country_name = 'Arabic'; if ($code2 == "ae") {$country_name = 'UAE'; $ctry_code = 221;} if ($code2 == "bh") {$country_name = 'Bahrain';$ctry_code = 17;} if ($code2 == "eg") {$country_name = 'Egypt';$ctry_code = 63;} if ($code2 == "dz") {$country_name = 'Algeria';} if ($code2 == "iq") {$country_name = 'Iraq';} if ($code2 == "jo") {$country_name = 'Jordan';} if ($code2 == "kw") {$country_name = 'Kuwait';$ctry_code = 114;} if ($code2 == "lb") {$country_name = 'Lebanon';} if ($code2 == "ly") {$country_name = 'Libya';} if ($code2 == "ma") {$country_name = 'Morocco';} if ($code2 == "om") {$country_name = 'Oman';} if ($code2 == "qa") {$country_name = 'Qatar';} if ($code2 == "sa") {$country_name = 'Saudi Arabia';$ctry_code = 184;} if ($code2 == "sy") {$country_name = 'Syria';} if ($code2 == "tn") {$country_name = 'Tunisia';} if ($code2 == "ye") {$country_name = 'Yemen';} } elseif ($code1 == "be") {$country_name = 'Belarusian'; } elseif ($code1 == "bg") {$country_name = 'Bulgarian'; } elseif ($code1 == "ca") {$country_name = 'Catalan'; } elseif ($code1 == "cs") {$country_name = 'Czech Republic';$ctry_code = 56; } elseif ($code1 == "da") {$country_name = 'Denmark';$ctry_code = 57; } elseif ($code1 == "de") {$country_name = 'Germany';$ctry_code = 81; if ($code2 == "at") {$country_name = 'Austria';$ctry_code = 14;} if ($code2 == "ch") {$country_name = 'Switzerland';$ctry_code = 204;} if ($code2 == "li") {$country_name = 'Liechtenstein';$ctry_code = 122;} if ($code2 == "lu") {$country_name = 'Luxembourg';$ctry_code = 124;} } elseif ($code1 == "el") {$country_name = 'Greece';$ctry_code = 84; } elseif ($code1 == "en") {$country_name = 'Other English';$ctry_code = 223; if ($code2 == "us") {$country_name = 'USA';$ctry_code = 223;} if ($code2 == "au") {$country_name = 'Australia';$ctry_code = 13;} if ($code2 == "bz") {$country_name = 'Belize';} if ($code2 == "ca") {$country_name = 'Canada';$ctry_code = 38;} if ($code2 == "gb") {$country_name = 'UK';$ctry_code = 222;} if ($code2 == "ie") {$country_name = 'Ireland';$ctry_code = 103;} if ($code2 == "jm") {$country_name = 'Jamaica';} if ($code2 == "nz") {$country_name = 'New Zealand';$ctry_code = 153;} if ($code2 == "tt") {$country_name = 'Trinidad';} if ($code2 == "za") {$country_name = 'South Africa';$ctry_code = 193;} } elseif ($code1 == "es") {$country_name = 'Spain';$ctry_code = 195; if ($code2 == "ar") {$country_name = 'Argentina';$ctry_code = 10;} if ($code2 == "bo") {$country_name = 'Bolivia';} if ($code2 == "cl") {$country_name = 'Chile';} if ($code2 == "co") {$country_name = 'Colombia';} if ($code2 == "cr") {$country_name = 'Costa Rica';} if ($code2 == "do") {$country_name = 'Dominican';} if ($code2 == "ec") {$country_name = 'Ecuador';} if ($code2 == "gt") {$country_name = 'Guatemala';} if ($code2 == "hn") {$country_name = 'Honduras';} if ($code2 == "mx") {$country_name = 'Mexico';$ctry_code = 138;} if ($code2 == "ni") {$country_name = 'Nicaragua';} if ($code2 == "pa") {$country_name = 'Panama';} if ($code2 == "pe") {$country_name = 'Peru';} if ($code2 == "pr") {$country_name = 'Puerto Rico';} if ($code2 == "py") {$country_name = 'Paraguay';} if ($code2 == "sv") {$country_name = 'El Salvador';} if ($code2 == "uy") {$country_name = 'Uruguay';} if ($code2 == "ve") {$country_name = 'Venezuela';} } elseif ($code1 == "et") {$country_name = 'Estonian'; } elseif ($code1 == "eu") {$country_name = 'Basque'; } elseif ($code1 == "fa") {$country_name = 'Farsi'; } elseif ($code1 == "fi") {$country_name = 'Finland';$ctry_code = 72; } elseif ($code1 == "fo") {$country_name = 'Faeroes'; } elseif ($code1 == "fr") {$country_name = 'France';$ctry_code = 73; if ($code2 == "be") {$country_name = 'Belgium';$ctry_code = 21;} if ($code2 == "ca") {$country_name = 'Canada';$ctry_code = 38;} if ($code2 == "ch") {$country_name = 'Switzerland';$ctry_code = 204;} if ($code2 == "ca") {$country_name = 'Luxembourg';$ctry_code = 124;} } elseif ($code1 == "gd") {$country_name = 'Scotland';$ctry_code = 222; if ($code2 == "ie") {$country_name = 'Ireland';} } elseif ($code1 == "he") {$country_name = 'Hebrew'; } elseif ($code1 == "hi") {$country_name = 'Hindi'; } elseif ($code1 == "hr") {$country_name = 'Croatian'; } elseif ($code1 == "hu") {$country_name = 'Hungarian';$ctry_code = 97; } elseif ($code1 == "in") {$country_name = 'Indonesian';$ctry_code = 100; } elseif ($code1 == "is") {$country_name = 'Icelandic';$ctry_code = 98; } elseif ($code1 == "he") {$country_name = 'Hebrew';$ctry_code = 104; } elseif ($code1 == "it") {$country_name = 'Italy';$ctry_code = 105; if ($code2 == "ch") {$country_name = 'Switzerland';$ctry_code = 204;} } elseif ($code1 == "ja") {$country_name = 'Japan';$ctry_code = 107; } elseif ($code1 == "ji") {$country_name = 'Yiddish';$ctry_code = 104; } elseif ($code1 == "ko") {$country_name = 'Korea'; } elseif ($code1 == "lt") {$country_name = 'Lithuania'; } elseif ($code1 == "lv") {$country_name = 'Latvian'; } elseif ($code1 == "mk") {$country_name = 'Macedonia'; } elseif ($code1 == "ms") {$country_name = 'Malaysia';$ctry_code = 129; } elseif ($code1 == "mt") {$country_name = 'Malta';$ctry_code = 132; } elseif ($code1 == "nl") {$country_name = 'Netherlands';$ctry_code = 150; if ($code2 == "be") {$country_name = 'Belgium';$ctry_code = 21;} } elseif ($code1 == "no") {$country_name = 'Norway';$ctry_code = 160; } elseif ($code1 == "pl") {$country_name = 'Poland';$ctry_code = 170; } elseif ($code1 == "pt") {$country_name = 'Portugual';$ctry_code = 171; if ($code2 == "br") {$country_name = 'Brazil';$ctry_code = 30;} } elseif ($code1 == "rm") {$country_name = 'Romania'; } elseif ($code1 == "ro") {$country_name = 'Romania'; } elseif ($code1 == "ru") {$country_name = 'Russia'; } elseif ($code1 == "sb") {$country_name = 'Sorbian'; } elseif ($code1 == "sk") {$country_name = 'Slovak'; } elseif ($code1 == "sl") {$country_name = 'Slovenian'; } elseif ($code1 == "sq") {$country_name = 'Albania'; } elseif ($code1 == "sr") {$country_name = 'Serbia'; } elseif ($code1 == "sv") {$country_name = 'Sweden';$ctry_code = 203; if ($code2 == "fi") {$country_name = 'Finland';$ctry_code = 72;} } elseif ($code1 == "sx") {$country_name = 'Sutu'; } elseif ($code1 == "sz") {$country_name = 'Sami'; } elseif ($code1 == "tn") {$country_name = 'Tswana'; } elseif ($code1 == "tr") {$country_name = 'Turkey'; } elseif ($code1 == "ts") {$country_name = 'Tsonga'; } elseif ($code1 == "uk") {$country_name = 'Ukrainian'; } elseif ($code1 == "th") {$country_name = 'Thailand';$ctry_code = 209; } elseif ($code1 == "ur") {$country_name = 'Urdu'; } elseif ($code1 == "ve") {$country_name = 'Venda'; } elseif ($code1 == "vi") {$country_name = 'Vietnam'; } elseif ($code1 == "xh") {$country_name = 'Xhosa'; } elseif ($code1 == "zh") {$country_name = 'China';$ctry_code = 44; if ($code2 == "cn") {$country_name = 'China';$ctry_code = 44;} if ($code2 == "hk") {$country_name = 'Hong Kong';$ctry_code = 96;} if ($code2 == "sg") {$country_name = 'Singapore';$ctry_code = 188;} if ($code2 == "tw") {$country_name = 'Taiwan';$ctry_code = 206;} } elseif ($code1 == "zu") {$country_name = 'Zulu';} // if all fails just return a default value if ($country_name == '') {$country_name = 'Taiwan';} if ($ctry_code == '') {$ctry_code = '206';} if ($give_code) { return ($ctry_code); } else { return ($country_name); } } this function returns the country name or osc country code depending on the $give_code parameter based on the browser language parameter. in create account I use this function to determine the default country upon entry. if ($country == ''){ $country = tep_get_country_by_language(getenv('HTTP_ACCEPT_LANGUAGE'), true); // return the osc country code, not the name if ($country == ''){ $country = DEFAULT_COUNTRY; } } Treasurer MFC
sarah1980 Posted August 28, 2005 Posted August 28, 2005 Is there a way that you can pre-select the currency that products are to be displayed in, based on where the customer is located?
boxtel Posted August 28, 2005 Author Posted August 28, 2005 Is there a way that you can pre-select the currency that products are to be displayed in, based on where the customer is located? <{POST_SNAPBACK}> yes, in application_top.php : } elseif (getenv('HTTP_ACCEPT_LANGUAGE') != '') { $lng->get_browser_language(); $your_country = tep_get_country_by_language(getenv('HTTP_ACCEPT_LANGUAGE'), false); switch ($your_country) { case 'Taiwan' : $currency = 'TWD';break; case 'USA' : $currency = 'USD';break; case 'Japan' : $currency = 'JPY';break; case 'UK' : $currency = 'GBP';break; case 'China' : $currency = 'CNY';break; case 'Hong Kong' : $currency = 'HKD';break; case 'Netherlands' : $currency = 'EUR';break; case 'Italy' : $currency = 'EUR';break; case 'Spain' : $currency = 'EUR';break; case 'Belgium' : $currency = 'EUR';break; case 'Austria' : $currency = 'EUR';break; case 'Germany' : $currency = 'EUR';break; case 'Greece' : $currency = 'EUR';break; case 'Finland' : $currency = 'EUR';break; case 'Sweden' : $currency = 'EUR';break; case 'Norway' : $currency = 'EUR';break; case 'Denmark' : $currency = 'EUR';break; case 'France' : $currency = 'EUR';break; default : $currency = 'USD'; } if (!tep_session_is_registered('currency')) { tep_session_register('currency'); } Treasurer MFC
sarah1980 Posted September 4, 2005 Posted September 4, 2005 yes, in application_top.php : } elseif (getenv('HTTP_ACCEPT_LANGUAGE') != '') { $lng->get_browser_language(); $your_country = tep_get_country_by_language(getenv('HTTP_ACCEPT_LANGUAGE'), false); switch ($your_country) { case 'Taiwan' : $currency = 'TWD';break; case 'USA' : $currency = 'USD';break; case 'Japan' : $currency = 'JPY';break; case 'UK' : $currency = 'GBP';break; case 'China' : $currency = 'CNY';break; case 'Hong Kong' : $currency = 'HKD';break; case 'Netherlands' : $currency = 'EUR';break; case 'Italy' : $currency = 'EUR';break; case 'Spain' : $currency = 'EUR';break; case 'Belgium' : $currency = 'EUR';break; case 'Austria' : $currency = 'EUR';break; case 'Germany' : $currency = 'EUR';break; case 'Greece' : $currency = 'EUR';break; case 'Finland' : $currency = 'EUR';break; case 'Sweden' : $currency = 'EUR';break; case 'Norway' : $currency = 'EUR';break; case 'Denmark' : $currency = 'EUR';break; case 'France' : $currency = 'EUR';break; default : $currency = 'USD'; } if (!tep_session_is_registered('currency')) { tep_session_register('currency'); } <{POST_SNAPBACK}> May I ask where is the best place to put that code?
boxtel Posted September 6, 2005 Author Posted September 6, 2005 May I ask where is the best place to put that code? <{POST_SNAPBACK}> well, in application_top.php you already should have this part : } else { $lng->get_browser_language(); so you add this part : $your_country = tep_get_country_by_language(getenv('HTTP_ACCEPT_LANGUAGE'), false); switch ($your_country) { case 'Taiwan' : $currency = 'TWD';break; case 'USA' : $currency = 'USD';break; case 'Japan' : $currency = 'JPY';break; case 'UK' : $currency = 'GBP';break; case 'China' : $currency = 'CNY';break; case 'Hong Kong' : $currency = 'HKD';break; case 'Netherlands' : $currency = 'EUR';break; case 'Italy' : $currency = 'EUR';break; case 'Spain' : $currency = 'EUR';break; case 'Belgium' : $currency = 'EUR';break; case 'Austria' : $currency = 'EUR';break; case 'Germany' : $currency = 'EUR';break; case 'Greece' : $currency = 'EUR';break; case 'Finland' : $currency = 'EUR';break; case 'Sweden' : $currency = 'EUR';break; case 'Norway' : $currency = 'EUR';break; case 'Denmark' : $currency = 'EUR';break; case 'France' : $currency = 'EUR';break; default : $currency = 'USD'; } if (!tep_session_is_registered('currency')) { tep_session_register('currency'); } Treasurer MFC
sarah1980 Posted September 8, 2005 Posted September 8, 2005 Thanks Boxtel. I just put the code in application_top and get this error: Call to undefined function: tep_get_country_by_language() in /home/.sites/23/site156/web/catalog/includes/application_top.php on line 278
sarah1980 Posted September 8, 2005 Posted September 8, 2005 Hmm Now I took the code out and I get this message: Warning: main(includes/languages/.php): failed to open stream: No such file or directory in /home/.sites/23/site156/web/catalog/includes/application_top.php on line 285 Warning: main(includes/languages/.php): failed to open stream: No such file or directory in /home/.sites/23/site156/web/catalog/includes/application_top.php on line 285 Fatal error: main(): Failed opening required 'includes/languages/.php' (include_path='.:/usr/local/lib/php') in /home/.sites/23/site156/web/catalog/includes/application_top.php on line 285
sarah1980 Posted September 8, 2005 Posted September 8, 2005 Don't ask me how but I managed to fix the error by re-uploading the catalog/cincludes/languages/english.php file. However, it doesn't look as if the code is doing what I thought it would do. When I go to my catalog page the default currency is still selected. Is there a way that I can get the browser to automatically select the person's currency based upon the country that they are from?
boxtel Posted September 8, 2005 Author Posted September 8, 2005 Thanks Boxtel. I just put the code in application_top and get this error: Call to undefined function: tep_get_country_by_language() in /home/.sites/23/site156/web/catalog/includes/application_top.php on line 278 <{POST_SNAPBACK}> well, you should add the function tep_get_country_by_language() to general.php as stated some posts above. that function returns the country name or code based on the browser language setting. Treasurer MFC
scranmer Posted December 14, 2005 Posted December 14, 2005 Add the main browser function then edit includes\functions\html_output.php and amend the following bit to default ALL country LOVs to your shops country. HTH Si. //// // Creates a pull-down list of countries function tep_get_country_list($name, $selected = '', $parameters = '') { //**si** if ( strlen($selected)==0 ) $country = DEFAULT_COUNTRY; //**si** end $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT)); $countries = tep_get_countries(); for ($i=0, $n=sizeof($countries); $i<$n; $i++) { $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']); } return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters); }
Guest Posted January 12, 2006 Posted January 12, 2006 What I use to pre-select the country in create account and order info of pwa.This will prevent a page refresh in 80% of the cases because of a country change. the function which is in general.php. most users of the visitors stat contribution will recognize this as it is in there as well without the osc codes. Note that I only put in the osc country codes I support. function tep_get_country_by_language($country_code, $give_code = false) { $code1 = substr($country_code,0,2); $code2 = substr($country_code,3,2); $country_name = ''; $ctry_code = ''; if ($code1 == "af") {$country_name = 'Africa'; } elseif ($code1 == "ar") {$country_name = 'Arabic'; if ($code2 == "ae") {$country_name = 'UAE'; $ctry_code = 221;} if ($code2 == "bh") {$country_name = 'Bahrain';$ctry_code = 17;} if ($code2 == "eg") {$country_name = 'Egypt';$ctry_code = 63;} if ($code2 == "dz") {$country_name = 'Algeria';} if ($code2 == "iq") {$country_name = 'Iraq';} if ($code2 == "jo") {$country_name = 'Jordan';} if ($code2 == "kw") {$country_name = 'Kuwait';$ctry_code = 114;} if ($code2 == "lb") {$country_name = 'Lebanon';} if ($code2 == "ly") {$country_name = 'Libya';} if ($code2 == "ma") {$country_name = 'Morocco';} if ($code2 == "om") {$country_name = 'Oman';} if ($code2 == "qa") {$country_name = 'Qatar';} if ($code2 == "sa") {$country_name = 'Saudi Arabia';$ctry_code = 184;} if ($code2 == "sy") {$country_name = 'Syria';} if ($code2 == "tn") {$country_name = 'Tunisia';} if ($code2 == "ye") {$country_name = 'Yemen';} } elseif ($code1 == "be") {$country_name = 'Belarusian'; } elseif ($code1 == "bg") {$country_name = 'Bulgarian'; } elseif ($code1 == "ca") {$country_name = 'Catalan'; } elseif ($code1 == "cs") {$country_name = 'Czech Republic';$ctry_code = 56; } elseif ($code1 == "da") {$country_name = 'Denmark';$ctry_code = 57; } elseif ($code1 == "de") {$country_name = 'Germany';$ctry_code = 81; if ($code2 == "at") {$country_name = 'Austria';$ctry_code = 14;} if ($code2 == "ch") {$country_name = 'Switzerland';$ctry_code = 204;} if ($code2 == "li") {$country_name = 'Liechtenstein';$ctry_code = 122;} if ($code2 == "lu") {$country_name = 'Luxembourg';$ctry_code = 124;} } elseif ($code1 == "el") {$country_name = 'Greece';$ctry_code = 84; } elseif ($code1 == "en") {$country_name = 'Other English';$ctry_code = 223; if ($code2 == "us") {$country_name = 'USA';$ctry_code = 223;} if ($code2 == "au") {$country_name = 'Australia';$ctry_code = 13;} if ($code2 == "bz") {$country_name = 'Belize';} if ($code2 == "ca") {$country_name = 'Canada';$ctry_code = 38;} if ($code2 == "gb") {$country_name = 'UK';$ctry_code = 222;} if ($code2 == "ie") {$country_name = 'Ireland';$ctry_code = 103;} if ($code2 == "jm") {$country_name = 'Jamaica';} if ($code2 == "nz") {$country_name = 'New Zealand';$ctry_code = 153;} if ($code2 == "tt") {$country_name = 'Trinidad';} if ($code2 == "za") {$country_name = 'South Africa';$ctry_code = 193;} } elseif ($code1 == "es") {$country_name = 'Spain';$ctry_code = 195; if ($code2 == "ar") {$country_name = 'Argentina';$ctry_code = 10;} if ($code2 == "bo") {$country_name = 'Bolivia';} if ($code2 == "cl") {$country_name = 'Chile';} if ($code2 == "co") {$country_name = 'Colombia';} if ($code2 == "cr") {$country_name = 'Costa Rica';} if ($code2 == "do") {$country_name = 'Dominican';} if ($code2 == "ec") {$country_name = 'Ecuador';} if ($code2 == "gt") {$country_name = 'Guatemala';} if ($code2 == "hn") {$country_name = 'Honduras';} if ($code2 == "mx") {$country_name = 'Mexico';$ctry_code = 138;} if ($code2 == "ni") {$country_name = 'Nicaragua';} if ($code2 == "pa") {$country_name = 'Panama';} if ($code2 == "pe") {$country_name = 'Peru';} if ($code2 == "pr") {$country_name = 'Puerto Rico';} if ($code2 == "py") {$country_name = 'Paraguay';} if ($code2 == "sv") {$country_name = 'El Salvador';} if ($code2 == "uy") {$country_name = 'Uruguay';} if ($code2 == "ve") {$country_name = 'Venezuela';} } elseif ($code1 == "et") {$country_name = 'Estonian'; } elseif ($code1 == "eu") {$country_name = 'Basque'; } elseif ($code1 == "fa") {$country_name = 'Farsi'; } elseif ($code1 == "fi") {$country_name = 'Finland';$ctry_code = 72; } elseif ($code1 == "fo") {$country_name = 'Faeroes'; } elseif ($code1 == "fr") {$country_name = 'France';$ctry_code = 73; if ($code2 == "be") {$country_name = 'Belgium';$ctry_code = 21;} if ($code2 == "ca") {$country_name = 'Canada';$ctry_code = 38;} if ($code2 == "ch") {$country_name = 'Switzerland';$ctry_code = 204;} if ($code2 == "ca") {$country_name = 'Luxembourg';$ctry_code = 124;} } elseif ($code1 == "gd") {$country_name = 'Scotland';$ctry_code = 222; if ($code2 == "ie") {$country_name = 'Ireland';} } elseif ($code1 == "he") {$country_name = 'Hebrew'; } elseif ($code1 == "hi") {$country_name = 'Hindi'; } elseif ($code1 == "hr") {$country_name = 'Croatian'; } elseif ($code1 == "hu") {$country_name = 'Hungarian';$ctry_code = 97; } elseif ($code1 == "in") {$country_name = 'Indonesian';$ctry_code = 100; } elseif ($code1 == "is") {$country_name = 'Icelandic';$ctry_code = 98; } elseif ($code1 == "he") {$country_name = 'Hebrew';$ctry_code = 104; } elseif ($code1 == "it") {$country_name = 'Italy';$ctry_code = 105; if ($code2 == "ch") {$country_name = 'Switzerland';$ctry_code = 204;} } elseif ($code1 == "ja") {$country_name = 'Japan';$ctry_code = 107; } elseif ($code1 == "ji") {$country_name = 'Yiddish';$ctry_code = 104; } elseif ($code1 == "ko") {$country_name = 'Korea'; } elseif ($code1 == "lt") {$country_name = 'Lithuania'; } elseif ($code1 == "lv") {$country_name = 'Latvian'; } elseif ($code1 == "mk") {$country_name = 'Macedonia'; } elseif ($code1 == "ms") {$country_name = 'Malaysia';$ctry_code = 129; } elseif ($code1 == "mt") {$country_name = 'Malta';$ctry_code = 132; } elseif ($code1 == "nl") {$country_name = 'Netherlands';$ctry_code = 150; if ($code2 == "be") {$country_name = 'Belgium';$ctry_code = 21;} } elseif ($code1 == "no") {$country_name = 'Norway';$ctry_code = 160; } elseif ($code1 == "pl") {$country_name = 'Poland';$ctry_code = 170; } elseif ($code1 == "pt") {$country_name = 'Portugual';$ctry_code = 171; if ($code2 == "br") {$country_name = 'Brazil';$ctry_code = 30;} } elseif ($code1 == "rm") {$country_name = 'Romania'; } elseif ($code1 == "ro") {$country_name = 'Romania'; } elseif ($code1 == "ru") {$country_name = 'Russia'; } elseif ($code1 == "sb") {$country_name = 'Sorbian'; } elseif ($code1 == "sk") {$country_name = 'Slovak'; } elseif ($code1 == "sl") {$country_name = 'Slovenian'; } elseif ($code1 == "sq") {$country_name = 'Albania'; } elseif ($code1 == "sr") {$country_name = 'Serbia'; } elseif ($code1 == "sv") {$country_name = 'Sweden';$ctry_code = 203; if ($code2 == "fi") {$country_name = 'Finland';$ctry_code = 72;} } elseif ($code1 == "sx") {$country_name = 'Sutu'; } elseif ($code1 == "sz") {$country_name = 'Sami'; } elseif ($code1 == "tn") {$country_name = 'Tswana'; } elseif ($code1 == "tr") {$country_name = 'Turkey'; } elseif ($code1 == "ts") {$country_name = 'Tsonga'; } elseif ($code1 == "uk") {$country_name = 'Ukrainian'; } elseif ($code1 == "th") {$country_name = 'Thailand';$ctry_code = 209; } elseif ($code1 == "ur") {$country_name = 'Urdu'; } elseif ($code1 == "ve") {$country_name = 'Venda'; } elseif ($code1 == "vi") {$country_name = 'Vietnam'; } elseif ($code1 == "xh") {$country_name = 'Xhosa'; } elseif ($code1 == "zh") {$country_name = 'China';$ctry_code = 44; if ($code2 == "cn") {$country_name = 'China';$ctry_code = 44;} if ($code2 == "hk") {$country_name = 'Hong Kong';$ctry_code = 96;} if ($code2 == "sg") {$country_name = 'Singapore';$ctry_code = 188;} if ($code2 == "tw") {$country_name = 'Taiwan';$ctry_code = 206;} } elseif ($code1 == "zu") {$country_name = 'Zulu';} // if all fails just return a default value if ($country_name == '') {$country_name = 'Taiwan';} if ($ctry_code == '') {$ctry_code = '206';} if ($give_code) { return ($ctry_code); } else { return ($country_name); } } this function returns the country name or osc country code depending on the $give_code parameter based on the browser language parameter. in create account I use this function to determine the default country upon entry. if ($country == ''){ $country = tep_get_country_by_language(getenv('HTTP_ACCEPT_LANGUAGE'), true); // return the osc country code, not the name if ($country == ''){ $country = DEFAULT_COUNTRY; } } Howdy! I am very interested in the location of the second snippet of code in the create_account.php file. I would LOVE to have my install default out to the US but want to be sure I am placing the code in the correct location...thanks!!! Awesome stuff!!! Cheers, Travis
Guest Posted January 12, 2006 Posted January 12, 2006 Add the main browser function then edit includes\functions\html_output.php and amend the following bit to default ALL country LOVs to your shops country. HTH Si. //// // Creates a pull-down list of countries function tep_get_country_list($name, $selected = '', $parameters = '') { //**si** if ( strlen($selected)==0 ) $country = DEFAULT_COUNTRY; //**si** end $countries_array = array(array('id' => '', 'text' => PULL_DOWN_DEFAULT)); $countries = tep_get_countries(); for ($i=0, $n=sizeof($countries); $i<$n; $i++) { $countries_array[] = array('id' => $countries[$i]['countries_id'], 'text' => $countries[$i]['countries_name']); } return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters); } Simon, when you say add the main browser function what are you referring to? Sorry, I am trying to get this to function and I am not clear what the browser main function is??? Thanks!!! Cheers, Travis
kitchenniche Posted February 5, 2006 Posted February 5, 2006 this function returns the country name or osc country code depending on the $give_code parameter based on the browser language parameter.in create account I use this function to determine the default country upon entry. if ($country == ''){ $country = tep_get_country_by_language(getenv('HTTP_ACCEPT_LANGUAGE'), true); // return the osc country code, not the name if ($country == ''){ $country = DEFAULT_COUNTRY; } } Hi, This looks like a very useful addon. Do you know where i need to place the above code in the create account file??? I'm getting this error when I add it : Parse error: parse error, unexpected ',' in /home/kitchenn/public_html/create_account.php on line 200 even though I did not add the code on line 200 thanks Sandra HIM - Dark Light - Out on 26/09/05
kitchenniche Posted February 5, 2006 Posted February 5, 2006 Disregard the above comment. I had another error with my create account file. HIM - Dark Light - Out on 26/09/05
kitchenniche Posted February 5, 2006 Posted February 5, 2006 Both pre-select country and pre-select currency work now, thanks a lot! HIM - Dark Light - Out on 26/09/05
Qihun Posted February 8, 2006 Posted February 8, 2006 I use IP number for pre-selecting country. But may be this way slow down the page load. I have Geoip file in /includes and i call name from DB.
boxtel Posted February 9, 2006 Author Posted February 9, 2006 I use IP number for pre-selecting country. But may be this way slow down the page load. I have Geoip file in /includes and i call name from DB. yes, that would be a very stupid strategy (performance-wise). Treasurer MFC
Qihun Posted February 9, 2006 Posted February 9, 2006 why it is Very stupid startegy and not just stupid ?
sinryder Posted February 20, 2006 Posted February 20, 2006 hey buddy, could you please help me out i tried this code but nothing happend. in /public_html/includes/functions/general.php enter the code you said before the last ?> and in public_html/create_account.php entered this code if ($country == ''){ $country = tep_get_country_by_language(getenv('HTTP_ACCEPT_LANGUAGE'), true); // return the osc country code, not the name if ($country == ''){ $country = DEFAULT_COUNTRY; } } before the country state selector contribution that i have installed. did work so then entered it at top after applicatino top code and nothing happend any help is very much appreciated thankyou What I use to pre-select the country in create account and order info of pwa.This will prevent a page refresh in 80% of the cases because of a country change. the function which is in general.php. most users of the visitors stat contribution will recognize this as it is in there as well without the osc codes. Note that I only put in the osc country codes I support. function tep_get_country_by_language($country_code, $give_code = false) { $code1 = substr($country_code,0,2); $code2 = substr($country_code,3,2); $country_name = ''; $ctry_code = ''; if ($code1 == "af") {$country_name = 'Africa'; } elseif ($code1 == "ar") {$country_name = 'Arabic'; if ($code2 == "ae") {$country_name = 'UAE'; $ctry_code = 221;} if ($code2 == "bh") {$country_name = 'Bahrain';$ctry_code = 17;} if ($code2 == "eg") {$country_name = 'Egypt';$ctry_code = 63;} if ($code2 == "dz") {$country_name = 'Algeria';} if ($code2 == "iq") {$country_name = 'Iraq';} if ($code2 == "jo") {$country_name = 'Jordan';} if ($code2 == "kw") {$country_name = 'Kuwait';$ctry_code = 114;} if ($code2 == "lb") {$country_name = 'Lebanon';} if ($code2 == "ly") {$country_name = 'Libya';} if ($code2 == "ma") {$country_name = 'Morocco';} if ($code2 == "om") {$country_name = 'Oman';} if ($code2 == "qa") {$country_name = 'Qatar';} if ($code2 == "sa") {$country_name = 'Saudi Arabia';$ctry_code = 184;} if ($code2 == "sy") {$country_name = 'Syria';} if ($code2 == "tn") {$country_name = 'Tunisia';} if ($code2 == "ye") {$country_name = 'Yemen';} } elseif ($code1 == "be") {$country_name = 'Belarusian'; } elseif ($code1 == "bg") {$country_name = 'Bulgarian'; } elseif ($code1 == "ca") {$country_name = 'Catalan'; } elseif ($code1 == "cs") {$country_name = 'Czech Republic';$ctry_code = 56; } elseif ($code1 == "da") {$country_name = 'Denmark';$ctry_code = 57; } elseif ($code1 == "de") {$country_name = 'Germany';$ctry_code = 81; if ($code2 == "at") {$country_name = 'Austria';$ctry_code = 14;} if ($code2 == "ch") {$country_name = 'Switzerland';$ctry_code = 204;} if ($code2 == "li") {$country_name = 'Liechtenstein';$ctry_code = 122;} if ($code2 == "lu") {$country_name = 'Luxembourg';$ctry_code = 124;} } elseif ($code1 == "el") {$country_name = 'Greece';$ctry_code = 84; } elseif ($code1 == "en") {$country_name = 'Other English';$ctry_code = 223; if ($code2 == "us") {$country_name = 'USA';$ctry_code = 223;} if ($code2 == "au") {$country_name = 'Australia';$ctry_code = 13;} if ($code2 == "bz") {$country_name = 'Belize';} if ($code2 == "ca") {$country_name = 'Canada';$ctry_code = 38;} if ($code2 == "gb") {$country_name = 'UK';$ctry_code = 222;} if ($code2 == "ie") {$country_name = 'Ireland';$ctry_code = 103;} if ($code2 == "jm") {$country_name = 'Jamaica';} if ($code2 == "nz") {$country_name = 'New Zealand';$ctry_code = 153;} if ($code2 == "tt") {$country_name = 'Trinidad';} if ($code2 == "za") {$country_name = 'South Africa';$ctry_code = 193;} } elseif ($code1 == "es") {$country_name = 'Spain';$ctry_code = 195; if ($code2 == "ar") {$country_name = 'Argentina';$ctry_code = 10;} if ($code2 == "bo") {$country_name = 'Bolivia';} if ($code2 == "cl") {$country_name = 'Chile';} if ($code2 == "co") {$country_name = 'Colombia';} if ($code2 == "cr") {$country_name = 'Costa Rica';} if ($code2 == "do") {$country_name = 'Dominican';} if ($code2 == "ec") {$country_name = 'Ecuador';} if ($code2 == "gt") {$country_name = 'Guatemala';} if ($code2 == "hn") {$country_name = 'Honduras';} if ($code2 == "mx") {$country_name = 'Mexico';$ctry_code = 138;} if ($code2 == "ni") {$country_name = 'Nicaragua';} if ($code2 == "pa") {$country_name = 'Panama';} if ($code2 == "pe") {$country_name = 'Peru';} if ($code2 == "pr") {$country_name = 'Puerto Rico';} if ($code2 == "py") {$country_name = 'Paraguay';} if ($code2 == "sv") {$country_name = 'El Salvador';} if ($code2 == "uy") {$country_name = 'Uruguay';} if ($code2 == "ve") {$country_name = 'Venezuela';} } elseif ($code1 == "et") {$country_name = 'Estonian'; } elseif ($code1 == "eu") {$country_name = 'Basque'; } elseif ($code1 == "fa") {$country_name = 'Farsi'; } elseif ($code1 == "fi") {$country_name = 'Finland';$ctry_code = 72; } elseif ($code1 == "fo") {$country_name = 'Faeroes'; } elseif ($code1 == "fr") {$country_name = 'France';$ctry_code = 73; if ($code2 == "be") {$country_name = 'Belgium';$ctry_code = 21;} if ($code2 == "ca") {$country_name = 'Canada';$ctry_code = 38;} if ($code2 == "ch") {$country_name = 'Switzerland';$ctry_code = 204;} if ($code2 == "ca") {$country_name = 'Luxembourg';$ctry_code = 124;} } elseif ($code1 == "gd") {$country_name = 'Scotland';$ctry_code = 222; if ($code2 == "ie") {$country_name = 'Ireland';} } elseif ($code1 == "he") {$country_name = 'Hebrew'; } elseif ($code1 == "hi") {$country_name = 'Hindi'; } elseif ($code1 == "hr") {$country_name = 'Croatian'; } elseif ($code1 == "hu") {$country_name = 'Hungarian';$ctry_code = 97; } elseif ($code1 == "in") {$country_name = 'Indonesian';$ctry_code = 100; } elseif ($code1 == "is") {$country_name = 'Icelandic';$ctry_code = 98; } elseif ($code1 == "he") {$country_name = 'Hebrew';$ctry_code = 104; } elseif ($code1 == "it") {$country_name = 'Italy';$ctry_code = 105; if ($code2 == "ch") {$country_name = 'Switzerland';$ctry_code = 204;} } elseif ($code1 == "ja") {$country_name = 'Japan';$ctry_code = 107; } elseif ($code1 == "ji") {$country_name = 'Yiddish';$ctry_code = 104; } elseif ($code1 == "ko") {$country_name = 'Korea'; } elseif ($code1 == "lt") {$country_name = 'Lithuania'; } elseif ($code1 == "lv") {$country_name = 'Latvian'; } elseif ($code1 == "mk") {$country_name = 'Macedonia'; } elseif ($code1 == "ms") {$country_name = 'Malaysia';$ctry_code = 129; } elseif ($code1 == "mt") {$country_name = 'Malta';$ctry_code = 132; } elseif ($code1 == "nl") {$country_name = 'Netherlands';$ctry_code = 150; if ($code2 == "be") {$country_name = 'Belgium';$ctry_code = 21;} } elseif ($code1 == "no") {$country_name = 'Norway';$ctry_code = 160; } elseif ($code1 == "pl") {$country_name = 'Poland';$ctry_code = 170; } elseif ($code1 == "pt") {$country_name = 'Portugual';$ctry_code = 171; if ($code2 == "br") {$country_name = 'Brazil';$ctry_code = 30;} } elseif ($code1 == "rm") {$country_name = 'Romania'; } elseif ($code1 == "ro") {$country_name = 'Romania'; } elseif ($code1 == "ru") {$country_name = 'Russia'; } elseif ($code1 == "sb") {$country_name = 'Sorbian'; } elseif ($code1 == "sk") {$country_name = 'Slovak'; } elseif ($code1 == "sl") {$country_name = 'Slovenian'; } elseif ($code1 == "sq") {$country_name = 'Albania'; } elseif ($code1 == "sr") {$country_name = 'Serbia'; } elseif ($code1 == "sv") {$country_name = 'Sweden';$ctry_code = 203; if ($code2 == "fi") {$country_name = 'Finland';$ctry_code = 72;} } elseif ($code1 == "sx") {$country_name = 'Sutu'; } elseif ($code1 == "sz") {$country_name = 'Sami'; } elseif ($code1 == "tn") {$country_name = 'Tswana'; } elseif ($code1 == "tr") {$country_name = 'Turkey'; } elseif ($code1 == "ts") {$country_name = 'Tsonga'; } elseif ($code1 == "uk") {$country_name = 'Ukrainian'; } elseif ($code1 == "th") {$country_name = 'Thailand';$ctry_code = 209; } elseif ($code1 == "ur") {$country_name = 'Urdu'; } elseif ($code1 == "ve") {$country_name = 'Venda'; } elseif ($code1 == "vi") {$country_name = 'Vietnam'; } elseif ($code1 == "xh") {$country_name = 'Xhosa'; } elseif ($code1 == "zh") {$country_name = 'China';$ctry_code = 44; if ($code2 == "cn") {$country_name = 'China';$ctry_code = 44;} if ($code2 == "hk") {$country_name = 'Hong Kong';$ctry_code = 96;} if ($code2 == "sg") {$country_name = 'Singapore';$ctry_code = 188;} if ($code2 == "tw") {$country_name = 'Taiwan';$ctry_code = 206;} } elseif ($code1 == "zu") {$country_name = 'Zulu';} // if all fails just return a default value if ($country_name == '') {$country_name = 'Taiwan';} if ($ctry_code == '') {$ctry_code = '206';} if ($give_code) { return ($ctry_code); } else { return ($country_name); } } this function returns the country name or osc country code depending on the $give_code parameter based on the browser language parameter. in create account I use this function to determine the default country upon entry. if ($country == ''){ $country = tep_get_country_by_language(getenv('HTTP_ACCEPT_LANGUAGE'), true); // return the osc country code, not the name if ($country == ''){ $country = DEFAULT_COUNTRY; } }
boxtel Posted February 21, 2006 Author Posted February 21, 2006 hey buddy, could you please help me outi tried this code but nothing happend. in /public_html/includes/functions/general.php enter the code you said before the last ?> and in public_html/create_account.php entered this code if ($country == ''){ $country = tep_get_country_by_language(getenv('HTTP_ACCEPT_LANGUAGE'), true); // return the osc country code, not the name if ($country == ''){ $country = DEFAULT_COUNTRY; } } before the country state selector contribution that i have installed. did work so then entered it at top after applicatino top code and nothing happend any help is very much appreciated thankyou hey buddy? well, what does your "country state selector contribution" do? With "nothing happened" you mean? Treasurer MFC
sinryder Posted February 21, 2006 Posted February 21, 2006 hey buddy? well, what does your "country state selector contribution" do? With "nothing happened" you mean? well right now you have to select the country first and then the page refreshes and then you can select the state. default country is set to USA then after entering your code, nothing changed. i still get the default country when i go to create account page "USA" .I am in Canada so i guess it should change to canada itself right?
sinryder Posted February 21, 2006 Posted February 21, 2006 well right now you have to select the country first and then the page refreshes and then you can select the state. default country is set to USA then after entering your code, nothing changed. i still get the default country when i go to create account page "USA" .I am in Canada so i guess it should change to canada itself right? i think , the reason why your code didnt work for me was because i didnt put the code in the right place in create account I use this function to determine the default country upon entry. if ($country == ''){ $country = tep_get_country_by_language(getenv('HTTP_ACCEPT_LANGUAGE'), true); // return the osc country code, not the name if ($country == ''){ $country = DEFAULT_COUNTRY; } } could you please tell me where in create_account.php file i should put that code in. Like at the very end or something ??
boxtel Posted February 22, 2006 Author Posted February 22, 2006 i think , the reason why your code didnt work for me was because i didnt put the code in the right place in create account I use this function to determine the default country upon entry. if ($country == ''){ $country = tep_get_country_by_language(getenv('HTTP_ACCEPT_LANGUAGE'), true); // return the osc country code, not the name if ($country == ''){ $country = DEFAULT_COUNTRY; } } could you please tell me where in create_account.php file i should put that code in. Like at the very end or something ?? just before the state dropdown box is determined if you have state before country dropdown. so before : <?php if (ACCOUNT_STATE == 'true') { ?> Treasurer MFC
vjren Posted April 4, 2008 Posted April 4, 2008 hey buddy? well, what does your "country state selector contribution" do? With "nothing happened" you mean? If you want a preselected country in a countrylist with your favorites at the top, look here, it combines this solution and the other.. here
Recommended Posts
Archived
This topic is now archived and is closed to further replies.