UPDATE: As of 26th November, 2009, this plugin has been renamed “Deniro”. Many of the comments posted below refer to the original plugin name and syntax. Please refer to the official Deniro documentation for full usage instructions.
—-
Hello all,
The Deniro plugin (formerly SL Currency Converter) automatically converts an amount from currency A to currency B, using live exchange rate data from xurrency.com.
The use of live exchange rate data makes it handy for sites that sell products in a single currency, but want to provide guideline equivalent prices for international shoppers, or for any application that requires easy programmatic access to up-to-date currency exchange rate data.
I was wondering if you had any experience with both services that are referenced for conversion and which one was more accurate, etc.
I knocked this plugin together very quickly for a client site some time ago, in order to provide an “indication” of the likely cost in alternative currencies. 100% accuracy wasn’t a concern, and as such isn’t something I’ve looked into.
Put simply, xurrency.com provides free currency conversion through a nice simple API, and that was enough for the client (and me) at the time.
Sorry I can’t be of more assistance; Ben over at PYLO may be able to offer a bit more insight.
Is there a PHP way to get to the functions in this plugin? I’m using it OK in a template that parses PHP second, but I need to do it first, and have access to the conversion…
PHP second:
<?php // round up converted price, and add markup $price_rand = {exp:sl_currencyconverter:convert amount="{price_rand}" base="ZAR" target="GBP"}; $markup = {related_entries id="price_level"}{markup}{/related_entries};
The plugin is incredibly simple, so it’s probably a lot easier for you just to include something like the following in your PHP (note: I haven’t tested this code, but it should be about right).
$client = new SoapClient('http://xurrency.com/api.wsdl');
/** * Converts GBP100 to USD, and formats it for output. * You'll probably want to include some error checking. */
$converted_amount = $client->getValue(100, 'GBP', 'USD'); echo '£100.00 is worth approximately $' . round($converted_amount, 2) . '.';
Turns out I can’t use it that way because of the way I’m parsing php to do something else on the page - either way will cause me a problem. So, in replay to this thread, is there anyway to use/mod the plugin to use a tag pair and a variable, ala:
So, in replay to this thread, is there anyway to use/mod the plugin to use a tag pair and a variable
It’s possible, but not something I have time to work on right now. I’m not sure the example code you provided above would work anyway, with the related entries tag nested inside a plugin parameter.
It strikes me that the simplest solution would be the one I mentioned above; a small bit of custom PHP, probably in a separate template. Enable PHP in the sub-template, embed it in your main template, and pass in whatever variables are required (base amount, base currency, target currency, and markup, for example).
That way, you don’t have to worry about parsing order or anything; you can just do your PHP calculations with the variables provided.
Just tried out this plugin on a dev site and am very very happy with it.
Would it be possible to add an option to remove decimals i.e decimal=“no” and then the output would be limited to whole numbers? - I’m coverting to Korean won and the conversion spits out 35587.2 but decimal values are not used in Korean won.
on another note is there a way to force inclusion of commas where they occur in large numbers. The above price of 35587.2 is only us$30 so I expect to get some rather large numbers. Not sure if this can be done in this plugin or would need another plugin or php…
That all sounds perfectly doable, and not even particularly complex. I’m completely stacked with work at the moment, but will try to find a few minutes to make the necessary changes over the next week or so.
I’ve just realised that I haven’t even got round to adding this addon to GitHub, so I’ll sort that out too.