Forums / Currencies & Sales Taxes, VAT, GST, etc. / Currencies Displayed in Alphabetical Order

Currencies Displayed in Alphabetical Order

Views: 3,870

Results 1 to 7 of 7
7 Oct 2007, 8:58 AM
#1
coolglobal avatar

coolglobal

New Zenner

Join Date:
Jul 2007
Posts:
64
Plugin Contributions:
0

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?

7 Oct 2007, 12:27 PM
#2
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

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
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);
    }
  }

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

8 Oct 2007, 7:53 AM
#3
coolglobal avatar

coolglobal

New Zenner

Join Date:
Jul 2007
Posts:
64
Plugin Contributions:
0

Re: Currencies Displayed in Alphabetical Order

Worked a treat! Thank you kindly.

31 Dec 2008, 5:00 PM
#4
121webconsultancy avatar

121webconsultancy

New Zenner

Join Date:
May 2007
Posts:
42
Plugin Contributions:
0

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

121webconsultancy - Professional Website Design & Internet Marketing

12 Jan 2011, 5:56 PM
#5
gaffettape avatar

gaffettape

Zen Follower

Join Date:
May 2009
Posts:
433
Plugin Contributions:
0

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:

12 Jan 2011, 5:59 PM
#6
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Currencies Displayed in Alphabetical Order

Yep. Nothing in there that's remotely version-related.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

12 Jan 2011, 6:01 PM
#7
gaffettape avatar

gaffettape

Zen Follower

Join Date:
May 2009
Posts:
433
Plugin Contributions:
0

Re: Currencies Displayed in Alphabetical Order

Ok, thanks for the quick response kuroi :smile: