Country dropdown menu is a mess
- ReneH4
- Contributor
- Posts: 145
- Joined: Mon Oct 26, 2020 12:00 pm
- Phoenix Version:
- Has thanked: 13 times
- Been thanked: 17 times
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?
- burt
- Core Team
- Posts: 4551
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 412 times
Re: Country dropdown menu is a mess
Which v Phoenix (or Frozen, Gold, etc) ?
I am not here to build for you.
I am here to build with you. Let's help each other.
I am here to build with you. Let's help each other.
- ReneH4
- Contributor
- Posts: 145
- Joined: Mon Oct 26, 2020 12:00 pm
- Phoenix Version:
- Has thanked: 13 times
- Been thanked: 17 times
Re: Country dropdown menu is a mess
Sure, forgot to mention: 1079 Phoenix
Good to see you back Gary!
Good to see you back Gary!
- burt
- Core Team
- Posts: 4551
- Joined: Tue Oct 29, 2019 9:37 am
- Phoenix Version: v1.1.0.8
- : Buy Me A Beverage
- Has thanked: 252 times
- Been thanked: 412 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?
I am not here to build for you.
I am here to build with you. Let's help each other.
I am here to build with you. Let's help each other.
-
ecartz
- Core Team
- Posts: 3084
- Joined: Tue Nov 05, 2019 6:02 pm
- Phoenix Version:
- Has thanked: 4 times
- Been thanked: 208 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.
- ReneH4
- Contributor
- Posts: 145
- Joined: Mon Oct 26, 2020 12:00 pm
- Phoenix Version:
- Has thanked: 13 times
- Been thanked: 17 times
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?
-
ArtcoInc
- Contributor
- Posts: 119
- Joined: Fri Oct 25, 2019 4:19 pm
- Phoenix Version: v1.0.3.0
- Has thanked: 86 times
- Been thanked: 17 times
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
-
Omar_one
- Senior Contributor
- Posts: 677
- Joined: Fri Oct 25, 2019 5:06 pm
- Phoenix Version: v1.0.8.16
- Has thanked: 100 times
- Been thanked: 56 times
Re: Country dropdown menu is a mess
You can check @zipurman add-on Favorite Countries app.php/addons/free_addon/favorite_countries/
- ReneH4
- Contributor
- Posts: 145
- Joined: Mon Oct 26, 2020 12:00 pm
- Phoenix Version:
- Has thanked: 13 times
- Been thanked: 17 times
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/