osCommerce / oscommerce2

osCommerce Online Merchant v2.x
http://www.oscommerce.com
MIT License
281 stars 222 forks source link

Proposal: Auto select users default country in country pulldown of create_account.php #605

Open mgutt opened 6 years ago

mgutt commented 6 years ago

Search for:

        <td class="fieldValue"><?php echo tep_get_country_list('country') . '&nbsp;' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>

replace with:

<?php
  // try to get users default country
  $country = tep_db_fetch_array(tep_db_query("select countries_id from " . TABLE_COUNTRIES . " where countries_iso_code_2 = '" . tep_db_input(strtoupper(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2))) . "' OR countries_iso_code_3  = '" . tep_db_input(strtoupper(substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 3))) . "' LIMIT 1"));
?>
        <td class="fieldValue"><?php echo tep_get_country_list('country', $country['countries_id']) . '&nbsp;' . (tep_not_null(ENTRY_COUNTRY_TEXT) ? '<span class="inputRequirement">' . ENTRY_COUNTRY_TEXT . '</span>': ''); ?></td>