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.
Full installation and usage instructions, and the plugin file, can be found on the official Deniro documentation page.
Cheers, Stephen
Hi Mr Dimsum,
This seems very useful! But I was wondering if there was any method of extracting this from custom fields? I have a value custom field, and a currency custom field - is there a way to input them into this plugin?
I’ve just tested the plugin with the following code, and it all works fine.
{exp:weblog:entries weblog="products" disable="categories|category_fields|member_data|pagination|trackbacks"}
<h2>{title}</h2>
{product-description}
Price: £{product-price} (${exp:sl_currencyconverter:convert amount="{product-price}" base="GBP" target="USD"}).
{/exp:weblog:entries}
Let me know if that’s not working for you, and I’ll try to find out what the problem is.
Cheers, Stephen
Stephen,
I love this plugin. I also noticed that PutYourLightsOn also has almost an identical plugin at: http://www.putyourlightson.net/projects/exchange_rates
I was wondering if you had any experience with both services that are referenced for conversion and which one was more accurate, etc.
Both modules seem to great great and function relatively to a cue with one another. Good job both of you. =)
Hi Danny,
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.
Cheers, Stephen
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};
$price_pounds = ceil($price_rand) + $markup;
echo $price_pounds; ?>
PHP first (assuming I’ve extracted the price to convert)?
<?php
// round up converted price, and add markup
$price_rand = sl_currencyconverter($price_rand, "ZAR", "GBP");
$markup = related_entries("price_level", "markup");
$price_pounds = ceil($price_rand) + $markup;
echo $price_pounds; ?>
Hi Luc,
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) . '.';
Hope that helps, Stephen
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:
{exp:sl_currencyconverter:convert amount="{price_rand}" base="ZAR" target="GBP" parse="inward"}
{exp:simple_math calculate="ceil({converted_currency_value}) + {related_entries id="price_level"}{markup}{/related_entries}"}
{/exp:sl_currencyconverter:convert}
Thanks,
Hi Luc,
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.
Hope that helps, Stephen
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…
once again thanks for a fantastic plugin.
Hi Sean,
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.
Cheers, Stephen
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.