WordPress Plugin - LocalCurrency

Current version: 1.01 (24th February 2008) | Read The Changelog
Download (downloaded 576 times) | RSS feed icon Subscribe To LocalCurrency News

Shows currency values to readers in their local currency (in brackets after the original value). For example: If the site’s currency is Chinese yuan and the post contains 10 yuan, a user from Australia will see 10 yuan (AUD$1.53), while a user from US will see 10 yuan (USD$1.39).

Why Use It?

If you write about a place that uses a currency your readers may not be familiar with, LocalCurrency saves the need for you to explain how much currency values are worth.

I’ve seen many bloggers write something like: 10 yuan (about $1.50) - because many of their readers don’t know how much yuan (or whatever currency they are using) is worth.

LocalCurrency automatically does this for you and tells readers exactly how much it’s worth, in their own currency, wherever they are from.

Features

  • Determines the reader’s country via IP address (using IP2C)
  • Obtains current exchange rate from Yahoo! Finance
  • Uses ‘AJAX’ techniques so the call to Yahoo! Finance does not affect page load times
  • Does not do anything if there is no currency value in the post
  • Allows user to change their currency via a selection box

Requirements

WordPress 2.x

Installation

  • Download the localcurrency-1.01.zip file and unzip it.
  • Upload the localcurrency folder to the wp-content/plugins folder.
  • Activate the localcurrency plugin within WordPress.

Note: The plugin is large compared to most WordPress plugins, due the IP2C database used to recognise the reader’s country

Upgrade

  • Download the localcurrency-1.01.zip file and unzip it.
  • Upload the localcurrency folder to the wp-content/plugins folder, overwriting the existing files.

Options

There are two options which can be set on the LocalCurrency page in the WordPress Options page:

  1. Site Currency: The currency you use when writing your posts. The plugin will convert values from this currency to the reader’s currency. The default is set to USD.
  2. Show Link: By Default, a link to the plugin home page is included on pages where there are values to be converted. Deselect this parameter if you want to disable the link. Note1: It is not possible to turn off the link to Yahoo! Finance. Note2: These links do not appear on pages which have no currency value.

Usage

Enter any currency values you want converted within <--LCSTART--> and <--LCEND--> tags. This can be done through the Code view. Simply select the number to be converted and click the LocalCurrency Quicktag. This should enter the tags for you. For example:

<--LCSTART-->$10<--LCEND-->

WARNING:

The plugin strips non numeric characters (such as $) from between the tags, before converting the value. However, some currency symbols may include numeric characters. For example, 10元 may be stored as 10&amp#20803;. The 20803 will remain after the non numeric characters are stripped and will be considered as part of the value to convert, resulting in an incorrect value.

If you experience this problem, simply leave the currency sign outside the tags (ie: <--LCSTART-->10<--LCEND-->元).

Note: If you disable the plugin, the tags will remain in your post but will not be shown, because they are in a HTML comment.

See LocalCurrency In Action

The following sentence should contain the amount in your local currency:

I spent 20 yuan on dinner last night, then 30 yuan on the taxi home.

If you want to change the currency, use the selection box at the bottom of the post. Note: if you are in China, you will not see anything.

Support

This plugin is officially not supported (due to my time constraints), but if you leave a comment below or contact me, I should be able to help.

Acknowledgements

This plugin makes use of some code from the CurreX plugin. Thanks to miCRoSCoPiC^eaRthLinG for his great plugin.

It also uses IP2C and Yahoo! Finance.

The Future

I’m not expecting many people to use this plugin - it’s mainly for my own use.

There are many ways it could be improved (such as using cookies to remember a visitor’s currency across pages). If enough people are interested I may consider additional features.


Show currencies in
Powered byLocalCurrency. Rates from Yahoo! Finance
Subscribe To Site:
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Netvouz
  • MisterWong
  • Bumpzee
  • co.mments
  • PlugIM
  • Reddit
  • Sphinn
  • StumbleUpon
  • Technorati

19 Comments

  1. […] Visit […]

  2. […] Visit […]

  3. Nice work on the plugin, Stephen. Leave the plugin - the whole idea itself is brilliant and I’m sure this plugin will receive a wide audience the moment people realize it’s true potential.

    You may want to release the the code as a non-plugin version too, as the usefulness of this beauty far transcends that of a simple wordpress plugin. This one can find wide deployment across various financial / property sites…

    Cheers,
    m^e

  4. miCRoSCoPiC^eaRthLinG,

    Thanks! Good idea - when I get time, I’ll write up how to do this outside of WordPress. I’ll do that at my other site, More Than Scratch The Surface.

    Thanks again for the curreX plugin, without which, LocalCurrency wouldn’t have been possible (at least it would have been much harder!).

  5. I’ve now released a new version 1.01, fixing two problems:

    1. The plugin didn’t work if there was only one currency on the page. This was because of the way the JavaScript array was dynamically created by PHP (it didn’t cater for arrays with only one value, which need to be created differently). Now fixed.

    2. The plugin didn’t work properly on the home page (and other pages with more than one post). I’ve fixed it so it now works, but note: if you change the currency, it will only change currency values in the post you changed it from. It will not change other posts on the page. I may add this future, so changing one post will change all (I got this working, but it was not stable and needs further investigation, so I left it out for now).

    The new version can be download above.

  6. Howdy

    Great plugin, I’ve been looking for somehting like this. I have a whisky site where I add the cost of whisky bottles by Custom fields. I then add this info to the post but not wiithin the loop. Does this work outside the loop?

    1. Hi Jens,

      At the moment it won’t work with Custom fields as they aren’t actually part of the post body. It may be possible to modify it so that it filters the custom fields instead, but I’d need to find out more about how you use the custom fields (is there only one for each post, or are there several, what are their names, etc).

      If you could send me some more details in an email, I’ll have a look into it. If I can do a quick hack, I will - although if it’s a lot of work, I won’t have time now.

  7. Hi,

    Great plugin. See it in action on http://theshop.free-jazz.net which runs on WordPress_MU …

    A question: is there any development still going on? If so, are there plans for a widget as alternative to the current select box ?

    Anyway, thanks ! :)

    1. Hi RavanH,

      I’m open to further developing this plugin, although my time is pretty limited over the next few months.

      If you’re after a widget to enter a value and have it converted to the currency of your choice, try the CurreX plugin.

      If you’re after something else, give me some more details and I’ll see if I can do anything.

      1. Hi Stephen,

        Let me explain more: I am thinking of the Currency selection box that will appear at the bottom of the page/post. Would it not be nice to make it possible to place it anywhere in the sidebar through a widget?

        Again, already a SMART plugin !

        1. RavanH,

          Okay, I understand now. It would be possible to do, but there is one major problem for this: The selection box (and all the required JavaScript) only appears on posts which have a currency to convert.

          The widget would have to only appear when there was something to convert too. That’s possible - the only worry is not having a space show instead.

          I’ll put this on the list of things to look into further, but with my current workload, it may be a while before I get to it.

  8. Hi Stephen, great plugin, thanks for working on it.

    But I have a problem with it that might be a bug, for some reason, it’s not converting the values on my blog, it just displays “NaN” where the converted value should be. I can see it working on your post, but it’s not doing it for me.

    1. Hi Juan,

      I’ve been to your site and seen the problem. It’s a bit puzzling, because it works on my site, but not yours, so it seems to be something to do with the server.

      Anyway, I’ve been through the code, narrowing down where the problem may be. It seems almost certain that it’s related to the server side script that contacts Yahoo! Finance and gets the exchange rate.

      The NaN stands for Not A Number. I suspect that the server side script isn’t returning the exchange rate. To confirm this, I really need to see what is being returned by the script. The only way to do this, would be for me to send you a new plugin file, which has a JavaScript alert which pops up with the value.

      You obviously won’t want to leave this in place (users will keep getting pop up messages with the value!), but if you could put it in for a brief time, note what it says, then put the old plugin file back, that would give me some key information to look into it further.

      Let me know if you’re willing to try this and I’ll send you the modified plugin file as soon as I can. Thank you.

      1. I’m open to try that, if it helps you inprove your plugin, I would be happy to help.

        Besides I installed this plugin because of the excelent service it provides, so the proper thing to do is help it improve and make it work for me.

        1. Hi Juan,

          Thank you for having a great attitude - not everyone is so helpful! Plugin authors such as myself really appreciate it when some is willing to help sort out problems.

          I’ll email you a new localcurrency.php shortly. I’ve actually done it a little nicer than I said in my previous comment. I’ve added a debug mode option to the Options page, so you can turn the debug mode on and off as you need. Also, it should only affect users who are logged in (at level 9 or above), so your readers won’t notice a thing.

          Once you get the new file, simply ftp it up to the wp-content/plugins/localcurrency folder on your server (overwriting the previous file). There’s no need to put back the original afterwards, you can leave the new file there.

          Then go to the Options -> Local Currency page and turn on debug mode and Save the option. Go to a post where there are values to be converted and some messages should pop up. If you could make a note of them and email me back, it should help me work out where the problem lies. Then you can turn debug mode off.

          1. Juan J Calcaño Says:
             (Reply) (Comments won't nest below this level)

            Hello Stephen, please remember to send me the new plugin file, let’s see if it works now. :)

          2. Hi Juan,

            Whoops, some problem with email I guess… I emailed the file on March 13 to the email address you left with your comment. I’ll try sending it again. Please let me know if you don’t get.

            If you can let me know what numbers it pops up with it, I may be able to work out what the problem is. Thanks!

          3. Hi Stephen, let me know if you’ve got the email with the results of the test.
            Good luck.

  9. A new feature that I’d very much like to see is the ability to specify a variant source currency. I often have to write the prices of various bits of shareware into my blog so I have set US dollars as the “default” (even though I’m in Australia) - but some shareware is priced in euros. I would love to be able to vary the LC tags perhaps to something like this:
    &lt;!-- LCSTART CURR=EU--&gt;5&lt;!-- LCEND--&gt;
    Using the 2-letter country codes (or whatever Yahoo Finance uses? I only ever need 4-5 currencies so having to look up the code wouldn’t be a problem) to indicate to LC that the currency isn’t whatever the specified default is.

    My blog’s http://atmac.org/ - I’m working on upgrades so your plugin isn’t live where you can see it yet, but I have it worked into the upgrades and it’s very helpful. Thank you very much for providing it :).

    - Ricky

Leave a comment