Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Order countries in drop down menu


gecko

Recommended Posts

Im reposting this cause after an hour of 2 people searching we finaly found it..

 

a hack to list your favourites in the top of the drop down menu

credit to jalal

 

(in includes/functions/html_output.php):

 

CODE

 

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

$favored_countries = array(14,21,57,72,73,81,84,103,105,124,150,171,195,203,222);

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

$countries = tep_get_countries();

$n = sizeof($countries);

for ($i=0; $i<$n; $i++) {

if( in_array($countries[$i]['countries_id'], $favored_countries) ) {

$countries_array[] = array('id' => $countries[$i]['countries_id'],

'text' => $countries[$i]['countries_name']);

}

}

for ($i=0; $i<$n; $i++) {

if( !in_array($countries[$i]['countries_id'], $favored_countries) ) {

$countries_array[] = array('id' => $countries[$i]['countries_id'],

'text' => $countries[$i]['countries_name']);

}

}

 

return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters);

}

this time it'll go :-)

Link to comment
Share on other sites

  • 1 month later...
Im reposting this cause after an hour of 2 people  searching we finaly found it..

 

a hack to list your favourites in the top of the drop down menu

credit to jalal

 

(in includes/functions/html_output.php):

 

CODE

 

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

  $favored_countries = array(14,21,57,72,73,81,84,103,105,124,150,171,195,203,222);

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

  $countries = tep_get_countries();

  $n = sizeof($countries);

  for ($i=0; $i<$n; $i++) {

    if( in_array($countries[$i]['countries_id'], $favored_countries) ) {

        $countries_array[] = array('id' => $countries[$i]['countries_id'],

                              'text' => $countries[$i]['countries_name']);

    }

  }

  for ($i=0; $i<$n; $i++) {

    if( !in_array($countries[$i]['countries_id'], $favored_countries) ) {

        $countries_array[] = array('id' => $countries[$i]['countries_id'],

                              'text' => $countries[$i]['countries_name']);

    }

  }

 

  return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters);

}

I am assuming that this replaces what is there already? Or is it an addition?

Link to comment
Share on other sites

I am assuming that this replaces what is there already? Or is it an addition?

It's a replacement: Replace the existing 'tep_get_country_list' function with this one.

 

I have a question:

I wanted the countries that I wish to be promoted to the top of list to also REMAIN in there original alphabetical locations in the list.

 

In other words, I want the countries that I choose to promote to be DUPLICATES of the original ones, because I feel that there will be many people that will not spot that their country is at the top of the list, and will therefore scroll down the list to try and find it alphabetically.

 

Does anyone know the code to accomplish this?

Thanks, Marc.

Link to comment
Share on other sites

  • 2 months later...
Im reposting this cause after an hour of 2 people searching we finaly found it..

 

a hack to list your favourites in the top of the drop down menu

credit to jalal

 

(in includes/functions/html_output.php):

 

CODE

 

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

$favored_countries = array(14,21,57,72,73,81,84,103,105,124,150,171,195,203,222);

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

$countries = tep_get_countries();

$n = sizeof($countries);

for ($i=0; $i<$n; $i++) {

if( in_array($countries[$i]['countries_id'], $favored_countries) ) {

$countries_array[] = array('id' => $countries[$i]['countries_id'],

'text' => $countries[$i]['countries_name']);

}

}

for ($i=0; $i<$n; $i++) {

if( !in_array($countries[$i]['countries_id'], $favored_countries) ) {

$countries_array[] = array('id' => $countries[$i]['countries_id'],

'text' => $countries[$i]['countries_name']);

}

}

 

return tep_draw_pull_down_menu($name, $countries_array, $selected, $parameters);

}

 

 

Hi,

 

The person requested that the countries repeat themselves in alphabetical order, which we would need. Do you have a solution for that?

 

Thank You

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...