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?

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.

Gives site owner the choice of using current or historic rates (ie at time of post)

Now works with mulitple source curriencies

Installation

Download the plugin 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

Alternatively, you can install the plugin automatically through the WordPress Admin interface by going to Plugins -> Add New and searching for LocalCurrency.

Upgrade

Please update this plugin through the WordPress Admin interface.

Usage

Enter any currency values you want converted using the localcurrency shortcode. For example:

[localcurrency]$65[/localcurrency]

This can be done manually through the Visual view in the post editor, or using the LocalCurrency Quicktag in the Code view (select the number to be converted and click the quicktag).

For a currency range, use a hyphen between values (without spaces), eg:

[localcurrency]$65-$75[/localcurrency]

There is a site-wide Site Currency setting which is used as the ‘from’ currency. To override this and convert from a different currency for a specific value, specify the ‘from’ currency (using a valid currency code):

[localcurrency from="GBP"]£65[/localcurrency]

The plugin will work with more than one currency per page, but will be much slower.

Note: This plugin used to use the following format: $10. This will still work but it is recommended to use the shortcode format shown above. Please do not use both formats on the one page.

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, please leave the currency sign outside the tags (ie: 元[localcurrency]10[/localcurrency]).

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.

Disclaimer

I do not accept any responsibility for any damages or losses, direct or indirect, that may arise from using the plugin or these instructions. This software is provided as is, with absolutely no warranty. Please refer to the full version of the GPL license for more information.

Acknowledgements

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

121 Responses

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…

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).

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?

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.

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.

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.

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.

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?

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:<!-- LCSTART CURR=EU-->5<!-- LCEND-->
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 :).

Hi
I’ve been looking for something like this for a long time. I’m just glad I’ve been brought to this page as I was looking for some WP plugins. Thank you so much for such excellent work. Will let you know how it works on my site. Best regards.
… just noticed this real-time preview display of this post. Wow, you’re great. Thanks so much.

Just a follow-up question. I noticed that the converted symbol used for Philippine Pesos is PHPPhp. It is redundant since we only use PhP (Ph for Philippines, and P for Peso). Is there any way we can adjust/configure this so that we only show PhP? Thanks again for such wonderful work.

This blog is running WordPress 2.8.4 and it’s working for me – see the “See LocalCurrency In Action” section above.

If the code isn’t being parsed, the most likely cause is another plugin filtering the content of the post / page before LocalCurrency get’s it. Can you give me some more details what other plugins you’re running?

Yatin

(9 Apr 2010):

hi there, no doubt a nice piece of work. Is it possible for user to select which currency they want to see all values? I see that on your website its working. are you adding it in next release?

As I’ve been writing a travelogue several years now, it would be helpful to lock in a currency price conversion for that specific post date, as opposed to using the today’s valuation when the post is read months or years down the road.

This site is being converted to WP and when it is, I’d like to show the price tables in the converted currency. But, as you see, space in the table is limited, so I don’t really want to cram 2 prices in each cell.

Also, the just-above comment about letting the user choose a currency would be Fab.

Just wondering if you had an opportunity to work on the plugin updates as per your last reply to me. We’re ready to launch the site next week and while the real-time conversion is not required, it would be nice to have soon.

I was just about to add this to the plugin, when I realised it’s not really feasible. I understand the need (I have some old post that are losing their meaning because of changes in exchange rates), but…

That would mean we’d have to store all 140-odd currencies for each post. ie If someone from France lands on your 5 year old post, you need to know the Euro rate from 5 years ago. If the next visitor is from Singapore, you need to know the Singapore dollar rate from 5 years ago (and so on).

Storing 140 currencies isn’t a big deal in it’s own right, but contacting Yahoo 140 times in a short space of time, could be. I’ll see what I can come up with, but it may this can’t be included.

Just a quick update – it probably won’t be finished until next week. I’ve rewritten a lot of it to make it more efficient and secure.

I’ll also be putting it in the official plugin directory, so when the update is made, you should receive a notification from the Plugins page in the WordPress and be able to automatically update as you can with other plugins.

1) If you use the options to hide the original price AND do not display historical rates (meaning you want the default current rates by UNchecking the box in the admin) ALL the base prices disappear from the page.

I see what you mean – I’ll look at this asap and try to have a new version up in the next day or two. At first guess, I must have missed something major in the logic. I’m really sorry about that.

I’ll also have a look at the WP-Table-Reloaded compatibility issue. I suspect that we need to change the order the plugins fire. LocalCurrency is running on the post content first (before the table is there so it can’t replace the shortcode), the WP-Table-Reloaded is adding the table.

I’ll let you know as soon as I get something up (although you should get a notiifcation of a new version from the Plugins page in the WordPress Admin area.

Okay, a new version should be appearing in your WordPress Admin panel shortly. It fixes the first problem you identified. Thanks for finding this and apologies!

I know how to fix the second problem, but I haven’t included it in the plugin because it may actually cause more problems than it fixes. Basically you need to go to line 41 of localcurrency.php, which is in the wp-content/plugins/localcurrency folder, and which will look like this:

add_filter('the_content', 'localcurrency');

Change this to:

add_filter('the_content', 'localcurrency',11);

This will mean that LocalCurrency will fire after WP-Table Reloaded so it can actually work. Note however that next time you update LocalCurrency, this change will be lost and will need to be added again. Also note that this may mean that the currency selection box will drop down below other things which add items the bottom of the post (such as the sharing plugin you are using).

Finally, for that post in particular, it still won’t work, because it checks for the <!–LCSTART–> tag and it won’t find it, even after that change. However, if you add the following somewhere in the post itself, it should be able to trick it into working:

<div style="display:none"><!--LCSTART--><!--LCEND--></div>

If you have any trouble with doing this, let me know and I’ll see if I can help further,

Bad news first — Second step didn’t work. Got the plugin to fire and the selector menu does appear at the bottom of the page. But the figures do not convert either onLoad on if the currency selection box is changed.

Good News? — Making the change you suggested didn’t break any pages. Menu loads where it always did, before the share plugin.

Barry

(29 Sep 2010):

Just to second Rick’s request from May 2008 for a per-post currency setting.

I travel quite a bit, so it’d be nice if it could handle my mentioning the local price of a beer in Singapore in one post, along with the price of a beer in Sydney in another post, and a beer in Seville in another…

If you’re not interested in implementing this, I may take a look at the code and see if I can add this myself if you don’t mind?

it’s open source so you’re welcome to change if you like. That said, I think I’ll probably add this. The question is, do you really want it on a per post basis, or on a per currency instance (which is what Rick suggested)?

Barry

(29 Sep 2010):

Er, per-instance basis is what I think I meant, as per Ricky’s example.

Assuming the Yahoo! API allows multiple calls, we could even have several currencies per article.

NOW, I do realize I’ve asked an awful lot of you and I told my partners I need to thank you with some cash for that. But I do have two more smaller questions, requests.

Neither are urgent.

1) Can I have a way to trim off the decimal places or round to the nearest whole unit?

2) I think the answer to this is no, as it comes from Yahoo!, but can the formatting of the currency figure be improved? Specifically, COMMAS to designate thousands ($1,000) and, second, a space between the current figure (GBP, THB, etc. and the number? Seeing THB4500000 is pretty hard on the eyes!

I’m willing to put up with #2 if I have to have the conversion. But it’d be nice.

Any progress on chopping off the decimals (or rounding) and fixing (if possible) the display to add spaces and commas?

Maria

(24 Nov 2010):

Hello, Stephen!

I’ve seen this plugin in action and I think it’s awsome!
But I have a problem: I’m currently working on my website locally (I mean it’s not hosted anywhere), and the tags don’t work. Why is this happening and will they work once I upload the website to a server?

Also, I would really like it if I could get this to convert the currencies in the shopping cart, too (I’m using the eShop plugin). Is it possible? Am I supposed to add the tags in the .php file responsible for the shopping cart?

Thanks in advance and I hope you will be able to help me with some answers soon.

Never got a reply to my earlier comment, so I’m guessing you’re quite busy. Ran into something I’m hoping you can remedy.

You recall your fix for the problem of loading LocalCurrency through another plugin and the need to change a setting to have it fire last. Has worked great.

HOWEVER, I just put another WP-TableReloaded table containing LocalCurrency shortcodes in a WIDDGET on my sidebar. It’s on the same page where LocalCurrency is already – successfully — being used in a WP-TableReloaded plugin table. However, in the widget, on the sidebar, LocalCurrency won’t work.

Basically, in one table at the bottom of the page loaded by plugin, LC works. In a second table, loaded in by the same plugin, inside a sidebar widget, it doesn’t work.

Any idea why? I’m thinking the shortcode doesn’t work in a widget. I used a text widget and put just the LC shortcodes and a figure in it (no plugin) and the page that rendered showed the shortcodes.

Perhaps I don’t need a fix from you, just a different plugin to enable shortcodes in widgets or sidebar?

Any help would be appreciated.

Salim Baduku

(6 Jan 2011):

ok really excellent plugin…

But i was working on a real estate website and was wondering how do I include into the PHP template…

All my prices are dynamically called – So i need your plugin to do its magic via the parsing of the PHP page. I tried wrapping this in PHP tahs templates , but nothing seems to work…

I’ll have a look at this in the next few days… It’s been a while I looked at that plugin and I’m not sure whether it can do it or what would be involved in it.

For all those other who have left requests, I’ll try to get to yours as well.

Toshirou Hagiwara

(30 Mar 2011):

Hi, Stephen.

Thank you for replying and I apologize for my late responding.
I thought if I put “force_lc” code in custom field as 1, currency selector will shows up like using “**”.
my ideal is the price in custom field could be changed with using currency selector in this page next to “本体価格（税込）”.

Thank you for a brilliant plugin. I really would like to use it but it’s not working for me, I hope you can help.

I am based in the UK and have installed LocalCurrency Converter on my site. I asked a friend in the US to check to see if the prices on the Tuition page of my site are in US dollars. Although we played around with it for quite awhile (with the currency symbol, without the currency symbol etc), whenever she checked, it was always in British pounds. Effectively, it doesn’t convert.

Do you have a suggestion why this might be.

Your plugin is perfect for my site and I would dearly love to get it working.

Stephen — thanks for the great plugin! I have a question: I’m using the plugin on a site where I’m making heavy use of custom fields. Specifically, I have a custom field “price” where I store the price of some farm equipment. The trouble is, the plugin doesn’t seem to recognize currency data outside the main post. Is there any way I could tweak the code to include the content of custom fields as well?

Jeremy

(14 Feb 2012):

Hello Stephen,

I have recently started using your plugin and I have to say I’m very impressed with its features. Great work!

Did you end up resolving the “NaN” error occurring in one of the previous comments? I am having the same issue with all currencies except USD. I have tried different numbers, different firing property from numbers 0-200, and using a combination of the different settings. When using the debug mode I get the following two messages (this is using the number 3598):

Value 0 : 3598
Converted 0 : NaN

I am using a quite clean wordpress install with only a few extra plugins. Usually I simply create a new page, type the number, highlight it and click on the “LocalCurrency” insert tags button.

Well done on getting the plugin to work. I’ve installed it but it’s not working and it doesn’t seem as though Stephen is supporting it anymore.

Would you mind explaining to me exactly what you did. Maybe if I follow your path I might get lucky.

I very much look forward to your reply,
Kind regards
Oretta

Jeremy

(14 Feb 2012):

Hi Oretta,

It isn’t working properly for me either which is why I posted here. I simply installed it through the WordPress plugins dialogue in the Dashboard, and then set the settings by clicking the settings link in the plugins page. Usually I simply create a new page, type the number, highlight it and click on the “LocalCurrency” insert tags button. But only the USD currency is working.

It’s looking like this plugin has gone obsolete since there isn’t any support here on the website anymore plus it clearly states at the top that it is only compatible with a very dated WordPress version. But see how you go.

Sorry I haven’t been able to support this (and answer emails if you sent me one).

At the moment I am flat out with my full time job and haven’t had time to support my free plugins. I’m hoping this will change soon – but then I’ve been hoping this for a while.

Jeremy – it’s been a long time since the NaN last reared it’s head (4 years ago!) and I can’t remember how that ended up. I will try to look at it soon for you.

Jeremy

(14 Feb 2012):

H Stephen,

Haha, yeah it has been a long time. I understand if you are busy. I am just quite surprised that WordPress has no other implementation of this sort of feature. At the moment I am considering using a currency drop down from one of the ecommerce plugins, but I haven’t found one yet that has such a widget which is easy to integrate. If you do find the time please keep us in the loop.

Can you please provide me a link to your site so I can have a look and see what’s happening? It’s working for me on WordPress 3.4.1 which is the latest version. Which version of WordPress are you using?

There are a couple of possible reasons that would prevent this from working:

1. A conflict with another plugin. It may be possible that another plugin is filtering the post content before (or after) Local Currency. Are you running any other plugins that change the post content?

2. A conflict with some other JavaScript that’s running on your site. If you give me a link to have a look at your site, I might be able to work out if this is the problem.

If you give me some further info, I’ll look into this.

Brooke

(23 Aug 2012):

Wow, thanks for your reply! Sorry I did not double-check my post after I sent it, it renders as (without spaces) as can be seen where I tried testing this plugin’s shortcode near the top of this page on the site I’m putting together here:

<--LCSTART-->$10<--LCEND-->
(that’s not showing, the < is actually & l t ; and the > is actually & g t 😉
It should have:

< --LCSTART-->$10< --LCEND-->
(but without the spaces, I’m not sure why they are appearing!)

Even though they look the same, they are actually different and the plugin will only work with the second syntax. I’ll look at making it more robust in future versions, but for now, could you please try editing the post / page in the HTML Editor and actually typeing in the < and the >?

Let me know if it still doesn’t work.

Cheers,
Stephen

Brooke

(23 Aug 2012):

Thanks for that Stephen, I have tried typing the code in by hand but it still doesn’t appear to be working.

Okay – I’ll have to think about what to try next. It’s working for me, but I’ll try to break it! The problem isn’t happening at the JavaScript level, it’s happening at the WordPress level before the page is created. Anyway, I’ll look into it (although I’m at work now so it will probably be tonight before I can even start looking at it).

I’ve had a look at your site and I can see that the Ajax request is being made from the page to your server to get the rate from Yahoo, but that 500 Internal Server Error is returned. So something is definitely going wrong at the server level.

If you go to the Settings -> LocalCurrency page, you’ll find that there is a Debug option. Could you please turn this on and Save, then load the PADI page again. It should popup a handful of messages. If you could email me what they say, that might help me look into it.

Note, once you have the numbers you should turn the Debug setting off, as you don’t want the popups to get in the way of real visitors.

This has been an answer to our prayers as people were asking what their currency price would be in relation to our UK prices. Installed and all works a treat apart from it doesn’t appear to recognise the decimal point so £2.99 is read as £299. Quite a difference in price 😉 Is there a work around please or does this plugin only recognise whole numbers?

Glad you’ve got 2.1 and it’s working for you (though I can’t see it on your site). I haven’t had any problems with 2.5, but I’d like to learn more about what went wrong, if you could describe it.

Thanks,
Stephen

Asia

(29 Sep 2013):

Great plugin. I’m having a small problem. I can’t get the converted amount to show up inside parentheses. What I’m seeing is something like this:

The price of a dozen ears of corn yesterday at the market was just £2 USD$3.65.

It should display like this:

The price of a dozen ears of corn yesterday at the market was just £2 (USD$3.65).

But it isn’t.

Also as a side note, USD$3.65 is incorrect. It should be either US $3.65 or USD3.65. To have both the D and $ is redundant, since the D and $ are both short versions of the word “Dollar” (D being part of the Acronym and $ being a symbolic representation). Would there be any easy way for me to modify the plugin code to remove the D? I’d also like to do the same for other currencies, so EUR€1.70 becomes €1.70 and AUD$3.00 becomes A$3.00 (which is the way it’s written in Australia when clarity is desired to differentiate it from other currencies that use the $ symbol – see here: http://en.wikipedia.org/wiki/Australian_dollar)

When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I
get several emails with the same comment. Is there any way you can remove
people from that service? Appreciate it!

diallo

(25 Jun 2014):

Hello,
very nice plugin! working great but the conversion is not very accurate. I tried converting the same
Amount on both (website and yahoo finance) and the results are a little different. Any explanation? Thanks

amit

(24 Jul 2014):

Why this plugin is not working with page-template ?
Please could you tell me how this will work ?

amit

(1 Aug 2014):

Hi, i posted the below comment regarding the plugin on 24th July 2014 but it is still unanswered from your side, Could you plz acknowledge this and update me.
Its a bit of urgent for me.

Why this plugin is not working with page-template ?
Please could you tell me how this will work ?

Joe Salmon

(30 Aug 2014):

Hi Stephen,

Just want to report a small bug. For the conversion to Chilean Pesos the official abbreviation is CLP. In the flie: localcurrency-activate.php, line 411 you have it listed as CLF. I think this error is also in the database someplace (maybe, “get_country_code” ?). Anyway, the result is that it returns a NaN error (CLFNaN)
for IP addresses located in Chile. It appears the fix might just by a single letter replacement, but I don’t know where to look in the DB. Thanks, Joe

Whilst I can get the tags [input] to wrap the calculated input field (which there are six … only one shows when the rules allow) your javascript is not appearing just the comment tags. I assume this is due to the javascript which is displaying the value once calculated and your code doesn’t see a value / or even trigger? Messed with plugin firing priority to no affect.

Any ideas?
Thanks
Ian

DebF

(7 Aug 2015):

Hi Stephen,

Conversions from IDR (Indonesian Rupiah) to USD, EUR, CAD, AUD and others are not correct.

For example this USD price displayed is wrong:

Price: from IDR 7890000 (USD$789.00) per person.

Correct (from Yahoo Finance) is :

Price: from IDR 7893566 (USD$583.95) per person.

I’m sure this is due to the rate returned from Yahoo for 1 IDR = .0001 USD , .0001 EUR .0001 AUD, .0001 CAD or….

The plugin won’t return correct values for base currencies with lots of zeros!

Any chance for this to be corrected?

Otherwise it’s a great, and VERY useful plugin. I can imagine you couldn’t support and make a little income off it. I’ve had plenty of clients who would use it.

Thanks,
DebF

DebF

(7 Aug 2015):

Correction to 7 Aug 2015 post:

For example this USD price displayed is wrong:

Price: from IDR 7890000 (USD$789.00) per person.

Correct (from Yahoo Finance) is :

Price: from IDR 7890000 (USD$583.95) per person.

Stephen Cronin

(22 Aug 2015):

Hi DebF,

Sorry for taking so long to notice this! I’ll try to look into this over the next day or two.

Cheers,
Stephen

Stephen Cronin

(22 Aug 2015):

Hi again DebF,

Just a quick note to say that I’ve replicated this and it is indeed because Yahoo is returning 0.0001 as the exchange rate. I’ll have to see whether I can get a more explicit rate from somewhere else, as there’s not much I can do with what they are returning… 🙁