Currencies Displayed in Alphabetical Order
I have noticed that the currencies are displayed in alphabetical order in the admin. Yet they seem to be displayed in a random order (although the same random order each time) in the storefront. How could I make the currencies in the storefront display in alphabetical order in the sidebox "currencies" dropdown?
Re: Currencies Displayed in Alphabetical Order
The order that they are displayed isn't random, it's the order in which they appear in the database.
Ideally you would change this at the point at which they are pulled out of the database, but I wouldn't recommend hacking away at the core code that does this, and so I suggest the following change instead.
Create an over-ride file for your includes/modules/sideboxes/currencies.php file and then insert the two lines that I have added in the middle of this code sample.
PHP Code:
reset($currencies->currencies);
$currencies_array = array();
while (list($key, $value) = each($currencies->currencies)) {
$currencies_array[] = array('id' => $key, 'text' => $value['title']);
}
function text_cmp($a, $b) {return strcmp($a["text"], $b["text"]);}
usort($currencies_array, 'text_cmp');
$hidden_get_variables = '';
reset($_GET);
while (list($key, $value) = each($_GET)) {
if ( ($key != 'currency') && ($key != zen_session_name()) && ($key != 'x') && ($key != 'y') ) {
$hidden_get_variables .= zen_draw_hidden_field($key, $value);
}
}
Re: Currencies Displayed in Alphabetical Order
Worked a treat! Thank you kindly.
Re: Currencies Displayed in Alphabetical Order
Hi.
I have installed bunyip's most excellent currency header mod and it works fine. However, an ongoing issue I have is attempting to display a preferred sort order of the currencies.
I only have GBP, EUR and USD and this is the order I wish to achieve.
See: www.prestigeringcompany.com/index.php and you will note the order is USD, EUR, GBP
I have deleted and reset the currencies to try and change the order and I have tried kuroi's fix and changed the currency title to try and influence any alphabetic sort, etc... but I am having no luck and slowly going mad...
Would anybody know how I can achieve the preferred sort order of GBP EUR USD ...???
Thank you kindly in advance...
Steve
Re: Currencies Displayed in Alphabetical Order
Hi,
Can anyone (hopefully kuroi!) confirm whether or not this is compatible with 1.3.9h? I tested it out and it seems to work fine, but I just wanted to double check!
Thanks :smile:
Re: Currencies Displayed in Alphabetical Order
Yep. Nothing in there that's remotely version-related.
Re: Currencies Displayed in Alphabetical Order
Ok, thanks for the quick response kuroi :smile: