Spirit-RC Posted January 13, 2004 Share Posted January 13, 2004 I wrote this patch as I found that neither OANDA, nor XE work for me. They both know nothing of Russian rouble (RUR or RUB). Here in Russia we usually use RosBusinessConsulting agency for currency exchange rate information, thus I decided to patch osCommerce to use that too. First of all, we add the following code to catalog/admin/includes/functions/localization.php: // A function to update exchange rates via RosBusinessConsulting Agency (www.rbc.ru) // using quotes from Centrobank of Russian Federation function quote_rbc_cb_currency($to, $from = DEFAULT_CURRENCY) { // RBC's Centrobank quotes don't understand RUR currency code and use BASE instead // the RUB code is mentioned here to add some robustness :) if ( $from == 'RUR' || $from == 'RUB' ) { $from='BASE'; } if ( $to == 'RUR' || $to == 'RUB' ) { $to='BASE'; } $page = file('http://conv.rbc.ru/convert.shtml?mode=calc&source=cb.0&tid_from='.$from.'&commission=1&tid_to='.$to.'&summa=1'); $match = array(); preg_match('/<TD height=32>.+:<\/TD>\s*<TD\><B>(\d+\.?\d*)<\/B>/', implode('',$page), $match); if (sizeof($match) > 0) { return $match[1]; } else { return false; } } Then we change catalog/admin/includes/application_top.php and replace define('CURRENCY_SERVER_PRIMARY', 'oanda'); with define('CURRENCY_SERVER_PRIMARY', 'rbc_cb'); That's it! The patch queries RBC for Centrobank quotes, but it can easily be updated to query for FOREX or MICEX (MMVB) data. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.