Searching the forums I couldn't find any post dealing with this contribution: http://addons.oscommerce.com/info/5685%20" target="_blank"> http://addons.oscommerce.com/info/5685
This contrib seems ideal to get rid of complicated scripts to auto update currencies. It seems to work well but, I think has Pound as a base rate.
I need to use Euro as the standard currency, but would like to be able to show customers from England or the US prices in Dollar or Pound.
Any hint or even step-by-step explanation how to define what's getting updated would be highly appreciated
Datse
Here is the code:
**********************************
// Update Currency Rate
# Read currency exchanges rates
# Cache file if appropriate ...
if (time()-filemtime("eurofxref-daily.xml") > 36000) {
$stuff = file("http://www.ecb.int/stats/eurofxref/eurofxref-daily.xml");
$fh = fopen("eurofxref-daily.xml","w");
foreach ($stuff as $line) { fputs($fh,$line); }
fclose ($fh);
$xld = "loaded afresh (and not cached)";
} else {
# .. or read from cache
$stuff = file("eurofxref-daily.xml");
$xld = "cached (and not loaded afresh)";
}
# $xld may be used in your output to inform you user or admin
# Extract exchange rates
$exchrate[EUR] = 1.00;
foreach ($stuff as $line) {
ereg("currency='([[:alpha:]]+)'",$line,$gota);
if (ereg("rate='([[:graph:]]+)'",$line,$gotb)) {
$exchrate[$gota[1]] = $gotb[1];
}
}
$GBP_EUR = round(1 / $exchrate[GBP], 8);
$GBP_USD = round($GBP_EUR * $exchrate[USD], 8);
tep_db_query("update currencies set value = ". $GBP_EUR ." where code = 'EUR'");
tep_db_query("update currencies set value = ". $GBP_USD ." where code = 'USD'");
**********************************