New addon "Currencies updates" is available for testing

can you help me ? with parsing code ? ithink easy but i cehcked another provider i cant do that:(

Try installing this code in your addons/my_changes directory and then invoking it as it says in the comments.



It should get all currencies configured in your store and update them to what's current from the www.webservicex.net currency conversion service. I can NOT vouge for how current the conversion data is, but it seems to be pretty accurate. You should only need to run this once a day after the US market's close. It is possible they have a block on foreign IP addresses, I don't know.


```php

/**
** Usage: Use the root of your store as the working directory for CRON
** Use this command line: php ./addons/my_changes/update_currencies.php --pw=
** where is the password used for password reminders in Administration/Settings/Security Settings
**/
define('AREA', 'A');
define('AREA_NAME', 'admin');
if( !file_exists('./prepare.php') )
chdir('../..');
require_once("./prepare.php");
require_once("./init.php");

define("RUN_FROM_CRON", empty($_REQUEST['i']) ? true : false);
define("UPDATE_DB", true);

if( RUN_FROM_CRON ) {
$cron_password = Registry::get('settings.Security.cron_password');
if( !$cron_password )
die('Bad pass');

if ((!isset($_REQUEST['pw']) || $cron_password != $_REQUEST['pw']) ) {
die(fn_get_lang_var('access_denied'));
}
}

define('cur_host', 'www.webservicex.net');
define('cur_url', cur_host."/CurrencyConvertor.asmx/ConversionRate");
define('cur_from', 'FromCurrency=');
define('cur_to', 'ToCurrency=');

function cur_get_rate($cur) {
// $request = cur_url."?".cur_from.$cur."&".cur_to.CART_PRIMARY_CURRENCY;
$request = cur_url."?".cur_to.$cur."&".cur_from.CART_PRIMARY_CURRENCY;
list($header, $response) = fn_http_request('GET', $request);
$v = preg_replace('/.*>([0-9]\.[^<]*).*/is', '$1', $response);
if( is_numeric($v) )
return $v;
return Registry::get('currencies.'.$cur."coefficient");
}

$currencies = Registry::get('currencies');

echo "
";
foreach($currencies as $currency => $data) {
if( $currency == CART_PRIMARY_CURRENCY )
continue;
$old = $data['coefficient'];
$data['coefficient'] = cur_get_rate($currency);
if( UPDATE_DB )
db_query("UPDATE ?:currencies set coefficient=?d WHERE currency_code=?s", $data['coefficient'], $currency);
echo "$currency updated from $old to $data[coefficient]\n";
}
echo "
";
exit;

?>

```

[quote name='Mike-D' timestamp='1327228470' post='129738']



[color=#888888][font=arial, sans-serif][size=3][color=#333333][size=4]If someone is needed to synchronize the currency exchange rates with the PayPal server, there is also an add-on:[/size][/color]



[color=#333333][size=4]http://cs-cart-devel…ronization.html[/size][/color][/size][/font][/color]



[/quote]



Hi Mike,

I use Paypal for my merchant account and accept Paypal payments as well.

This add-on is $51. Does it accurately update the exchange rate data so my customers will see accurate prices in their preferred currency while shopping?

I want to avoid a cookie-based solution, or a process that updates the exchange rate for every visitor. I prefer a process that updates the rates once per day.

Is that what this add-on does? The description for the add-on is terrible and lacking the most basic information.

Thanks,

Donnie

I would be interested in getting a good / solid working currency add-on. I currently use PayPal Pro/Express and would like to accept payments in other currencies.



I agree with you Donnie, this mod description is terrible and leaves out information. I did send them a message so hopefully they can give me a little more information before spending $51 and it not working like I would want it to.



-Tim

And the free one I provided you above is lacking in…?

Just implemented your script tbirnseth, it works.

But your script doesn't divide 1 by the webservicex.net convertion rate (1 / coefficient) before writing to the db.

I had to change the core/fn.cart.php script, line 2744, so the rate is multiplied by the coeffient value, instead of divided by it in order to use these values.

Hmm… Back when I did this, there was an issue where it was reversed… But why would you change the core file instead of the script? The original post could have been the incorrect version.

I changed the core file instead of the script because I'm not a programmer. I could easily see the change to make in the core file, but adding the logic needed (1 / coefficient for each value in the array) to your script was beyond me.

Your posts have helped me many times in the past. Thanks for the great contributions you make to CS-Cart community.

i need this add on urgently,but why there is no updation from cs cart?