Country dropdown menu is a mess
Country dropdown menu is a mess
After more than 10 years of usage my country table has become a bit messy.
As a result the dropdown menu in create_account is no longer an alphabetical list.
It shows the countries in order of countries_id.
I would like to fix that and have the list sorted by countries_name.
Anyone has done that?
As a result the dropdown menu in create_account is no longer an alphabetical list.
It shows the countries in order of countries_id.
I would like to fix that and have the list sorted by countries_name.
Anyone has done that?
-
- Lead Developer
- Posts: 2423
- Joined: Tue Oct 29, 2019 9:37 am
- : Buy Me A Beverage
- Has thanked: 49 times
- Been thanked: 137 times
Re: Country dropdown menu is a mess
Which v Phoenix (or Frozen, Gold, etc) ?
Gamechanger Addon: Queued Emails, try before you buy.
-
- Lead Developer
- Posts: 2423
- Joined: Tue Oct 29, 2019 9:37 am
- : Buy Me A Beverage
- Has thanked: 49 times
- Been thanked: 137 times
Re: Country dropdown menu is a mess
The simplest solution would probably be to add an order by clause in the relevant module;
https://github.com/CE-PhoenixCart/Phoen ... y.php#L184
Should be enough to get you going?
https://github.com/CE-PhoenixCart/Phoen ... y.php#L184
Should be enough to get you going?
Gamechanger Addon: Queued Emails, try before you buy.
-
- Lead Developer
- Posts: 2637
- Joined: Tue Nov 05, 2019 6:02 pm
- Has thanked: 4 times
- Been thanked: 181 times
Re: Country dropdown menu is a mess
I would think it would be even simpler to just rebuild the table in the proper order.
I'm pretty sure that it sorts in insertion order, not by ID (it's just that the IDs are also in insertion order). So just export the table (including the IDs), reorder the insertion statements, drop the table, and import the table again.
That might be slightly more work upfront, but then you don't need to modify the code at all. And of course this doesn't limit you to ordering by country name. The order could be entirely arbitrary.
The advantage of not modifying the code is that you don't have to maintain the code going forward.
I'm pretty sure that it sorts in insertion order, not by ID (it's just that the IDs are also in insertion order). So just export the table (including the IDs), reorder the insertion statements, drop the table, and import the table again.
That might be slightly more work upfront, but then you don't need to modify the code at all. And of course this doesn't limit you to ordering by country name. The order could be entirely arbitrary.
The advantage of not modifying the code is that you don't have to maintain the code going forward.
Re: Country dropdown menu is a mess
I took Gary's advice and changed core. Not that changing core would be Gary's advice :-)
Changed:
To:
Changed:
Code: Select all
$countries_query = tep_db_query("SELECT countries_id, countries_name FROM countries");
Code: Select all
$countries_query = tep_db_query("SELECT countries_id, countries_name FROM countries ORDER BY countries_name ASC");
burt wrote: ↑Sat Jul 10, 2021 12:41 pm The simplest solution would probably be to add an order by clause in the relevant module;
https://github.com/CE-PhoenixCart/Phoen ... y.php#L184
Should be enough to get you going?
Re: Country dropdown menu is a mess
Another advantage is that you can place your country of business at the top of the list. For example, I'm in the United States, and most of my customers are. So, it would make sense (to me, at least) to have the USA at the top of the list.
Malcolm
-
- VIP Member
- Posts: 481
- Joined: Fri Oct 25, 2019 5:06 pm
- Has thanked: 48 times
- Been thanked: 27 times
Re: Country dropdown menu is a mess
You can check @zipurman add-on Favorite Countries app.php/addons/free_addon/favorite_countries/
Re: Country dropdown menu is a mess
I installed this one too, nice to have!
Omar_one wrote: ↑Tue Jul 20, 2021 6:38 pm You can check @zipurman add-on Favorite Countries app.php/addons/free_addon/favorite_countries/