Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

problem with currencies...


varvunt

Recommended Posts

Did you created a new default currency?

In the edit did you put 1.0000000 as the value and then click on update currencies button ?

and in the catalog/includes/languages/english.php around line 36

 

// if USE_DEFAULT_LANGUAGE_CURRENCY is true, use the following currency, instead of the applications default currency (used w$

 

define('LANGUAGE_CURRENCY', 'USD');

Change it to whatever you need

 

HTH

The_Bear

Link to comment
Share on other sites

i checked the currencyvalue and after clicking the update im getting error:

how cam i solve it?

 

 

Warning: file(): URL file-access is disabled in the server configuration in /data/members/free/tripod/uk/d/u/d/dudubenami/htdocs/admin/includes/functions/localization.php on line 14

 

Warning: file(http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=dol&format=CSV&dest=Get+Table&sel_list=nis): failed to open stream: no suitable wrapper could be found in /data/members/free/tripod/uk/d/u/d/dudubenami/htdocs/admin/includes/functions/localization.php on line 14

 

Warning: implode(): Bad arguments. in /data/members/free/tripod/uk/d/u/d/dudubenami/htdocs/admin/includes/functions/localization.php on line 18

 

Warning: file(): URL file-access is disabled in the server configuration in /data/members/free/tripod/uk/d/u/d/dudubenami/htdocs/admin/includes/functions/localization.php on line 28

 

Warning: file(http://www.xe.net/ucc/convert.cgi?Amount=1&From=nis&To=dol): failed to open stream: no suitable wrapper could be found in /data/members/free/tripod/uk/d/u/d/dudubenami/htdocs/admin/includes/functions/localization.php on line 28

 

Warning: implode(): Bad arguments. in /data/members/free/tripod/uk/d/u/d/dudubenami/htdocs/admin/includes/functions/localization.php on line 32

 

Warning: file(): URL file-access is disabled in the server configuration in /data/members/free/tripod/uk/d/u/d/dudubenami/htdocs/admin/includes/functions/localization.php on line 14

 

Warning: file(http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=nis&format=CSV&dest=Get+Table&sel_list=nis): failed to open stream: no suitable wrapper could be found in /data/members/free/tripod/uk/d/u/d/dudubenami/htdocs/admin/includes/functions/localization.php on line 14

 

Warning: implode(): Bad arguments. in /data/members/free/tripod/uk/d/u/d/dudubenami/htdocs/admin/includes/functions/localization.php on line 18

 

Warning: file(): URL file-access is disabled in the server configuration in /data/members/free/tripod/uk/d/u/d/dudubenami/htdocs/admin/includes/functions/localization.php on line 28

 

Warning: file(http://www.xe.net/ucc/convert.cgi?Amount=1&From=nis&To=nis): failed to open stream: no suitable wrapper could be found in /data/members/free/tripod/uk/d/u/d/dudubenami/htdocs/admin/includes/functions/localization.php on line 28

 

Warning: implode(): Bad arguments. in /data/members/free/tripod/uk/d/u/d/dudubenami/htdocs/admin/includes/functions/localization.php on line 32

 

Warning: Cannot modify header information - headers already sent by (output started at /data/members/free/tripod/uk/d/u/d/dudubenami/htdocs/admin/includes/functions/localization.php:14) in /data/members/free/tripod/uk/d/u/d/dudubenami/htdocs/admin/includes/functions/general.php on line 18

Link to comment
Share on other sites

  • 3 months later...

re: file(): URL file-access is disabled in the server configuration

 

I had the same problem, and following a posting by

volrathxp on

http://forums.invisionpower.com/lofiversio...hp/t121520.html

 

I added the line

ini_set("allow_url_fopen","1");

 

into

catalog\admin\includes\functions\localization.php

 

as follows:

function quote_oanda_currency($code, $base = DEFAULT_CURRENCY) {

ini_set("allow_url_fopen","1");

$page = file('http://www.oanda.com/convert/fxdaily?value=1&redirected=1

 

and it seems to have sorted the problem with updating currencies.

Link to comment
Share on other sites

the issue is as posted and is to do whith a setting in php.ini to which the above post gives a resolve where you do not have access to php.ini

No longer giving free advice. Please place deposit in meter slot provided.  Individual: [=] SME: [==] Corporation: [===]
If deposit does not fit one of the slots provided then you are asking too much! :P

Is your Osc dated try Phoenix  raising oscommerce from the ashes.

Link to comment
Share on other sites

  • 1 month later...

:thumbsup:

 

I added the line

ini_set("allow_url_fopen","1");

 

into

catalog\admin\includes\functions\localization.php

 

This solution solved my same problem. Thanks

 

Ciz

Link to comment
Share on other sites

  • 2 years later...

this not solved my problem... isn´t there any restriction configured by my host admim at php.ini that could make "allow_url_fopen" not to be turned on by a function (the init_set())?

 

is there any workaround for this? safe_mode IS enabled at my server config.

 

I do not have access to php.ini

 

(is there any solution using fsockopen? or would it break into the same problem?)

 

THANKS!

Link to comment
Share on other sites

  • 6 months later...
  • 9 months later...

Try replacing localization.php with this:

 

NB. Web server must have PHP cURL extensions loaded (present in most).

 

 

<?php
/*
 $Id: localization.php,v 1.12 2003/06/25 20:36:48 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

 Copyright © 2003 osCommerce

 Released under the GNU General Public License
*/

 function quote_oanda_currency($code, $base = DEFAULT_CURRENCY) {

//FIX
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=' . $code .  '&format=CSV&dest=Get+Table&sel_list=' . $base);
curl_setopt($ch, CURLOPT_HEADER,0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TRANSFERTEXT, 1);
$page= curl_exec($ch); 
curl_close($ch);
//END FIX

//insecure line    $page = file('http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=' . $code .  '&format=CSV&dest=Get+Table&sel_list=' . $base);

   $match = array();

   preg_match('/(.+),(\w{3}),([0-9.]+),([0-9.]+)/i', $page, $match);

   if (sizeof($match) > 0) {
     return $match[3];
   } else {
     return false;
   }
 }



 function quote_xe_currency($to, $from = DEFAULT_CURRENCY) {

//FIX
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.xe.com/ucc/convert.cgi?Amount=1&From=' . $from . '&To=' . $to);
curl_setopt($ch, CURLOPT_HEADER,0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TRANSFERTEXT, 1);
$page= curl_exec($ch); 
curl_close($ch);
//END FIX


//insecure    $page = file('http://www.xe.net/ucc/convert.cgi?Amount=1&From=' . $from . '&To=' . $to);

   $match = array();

   preg_match('/[0-9.]+\s*' . $from . '\s*=\s*([0-9.]+)\s*' . $to . '/', $page, $match);

   if (sizeof($match) > 0) {
     return $match[1];
   } else {
     return false;
   }
 }



?>

 

 

No more really bad .htaccess or php.ini directives like allow_url_fopen or allow_url_include required. More recent versions of PHP prohibit local enabling of these functions if the host php.ini has disabled them.

 

Two things here differ from similar code around using cURL in place of file() or similar.

 

#1 cURL returns the page as a string, not an array - so the implode command which is tripping up the preg_match function line is no longer required.

 

#2 the second URL now contains www.xe.com - not www.xe.net as in previous file. My file is based on OSC ME2.2, so this may have been corrected in the later RC version.

Link to comment
Share on other sites

  • 1 month later...
  • 4 weeks later...

Hello,

 

I still get the error below,

 

Ive checked php.ini and turned on curl ext and allow_url_fopen, it did no do the job. Ive explicitly added ini_set("allow_url_fopen", "On") in localization.php, even tried changing "On" to "1". No avail!

 

please help!

 

 

Error: The exchange rate for Canadian Dollar (CAD) was not updated via xe. Is it a valid currency code?

Warning Warning: The primary exchange rate server (oanda) failed for Pound Sterling (GBP) - trying the secondary exchange rate server.

Error Error: The exchange rate for Pound Sterling (GBP) was not updated via xe. Is it a valid currency code?

Warning Warning: The primary exchange rate server (oanda) failed for US Dollar (USD) - trying the secondary exchange rate server.

Error Error: The exchange rate for US Dollar (USD) was not updated via xe. Is it a valid currency code?

Warning Warning: The primary exchange rate server (oanda) failed for Euro (EUR) - trying the secondary exchange rate server.

Error Error: The exchange rate for Euro (EUR) was not updated via xe. Is it a valid currency code?

Link to comment
Share on other sites

Hello,

 

I still get the error below,

 

Ive checked php.ini and turned on curl ext and allow_url_fopen, it did no do the job. Ive explicitly added ini_set("allow_url_fopen", "On") in localization.php, even tried changing "On" to "1". No avail!

 

please help!

 

 

Error: The exchange rate for Canadian Dollar (CAD) was not updated via xe. Is it a valid currency code?

Warning Warning: The primary exchange rate server (oanda) failed for Pound Sterling (GBP) - trying the secondary exchange rate server.

Error Error: The exchange rate for Pound Sterling (GBP) was not updated via xe. Is it a valid currency code?

Warning Warning: The primary exchange rate server (oanda) failed for US Dollar (USD) - trying the secondary exchange rate server.

Error Error: The exchange rate for US Dollar (USD) was not updated via xe. Is it a valid currency code?

Warning Warning: The primary exchange rate server (oanda) failed for Euro (EUR) - trying the secondary exchange rate server.

Error Error: The exchange rate for Euro (EUR) was not updated via xe. Is it a valid currency code?

 

 

Hi All,

 

Me too,I got the same problem when I updated the currency rate today. The thing interesting is that I have the same code working perfectly on my warm localhost with the same version of PHP 446 and Apache 2052,and I have not done any change with my code(it worked fine before yesterday) on my remote server.

 

Here is my error message,can anybody help?

 

Warning: The primary exchange rate server (oanda) failed for USD (USD) - trying the secondary exchange rate server.

Error: The exchange rate for USD (USD) was not updated via xe. Is it a valid currency code?

Warning: The primary exchange rate server (oanda) failed for CAD (CAD) - trying the secondary exchange rate server.

Error: The exchange rate for CAD (CAD) was not updated via xe. Is it a valid currency code?

 

Thanks!

 

Kanata

Link to comment
Share on other sites

  • 1 month later...

Kanata, I'm having exactly same issue with you and the fix above didn't make a different.

Codes never been changed and now it's getting this weird problem.

Link to comment
Share on other sites

  • 2 months later...

This worked for me, currencies update just fine in several osc shops.

Host does not allow fopen for obvious reasons.

 

Just replce the code in your localisation file with this;

 

<?php
 function quote_oanda_currency($code, $base = DEFAULT_CURRENCY) {

  $alte_url = "http://www.oanda.com/convert/fxdaily";
  $alte_params = 'value=1&redirected=1&exch=' . $code .  '&format=CSV&dest=Get+Table&sel_list=' . $base;
  $alte_user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";

  $alte_ch = curl_init();
  curl_setopt($alte_ch, CURLOPT_POST,1);
  curl_setopt($alte_ch, CURLOPT_POSTFIELDS,$alte_params);
  curl_setopt($alte_ch, CURLOPT_URL,$alte_url);
  curl_setopt($alte_ch, CURLOPT_SSL_VERIFYHOST, 2);
  curl_setopt($alte_ch, CURLOPT_USERAGENT, $alte_user_agent);
  curl_setopt($alte_ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($alte_ch, CURLOPT_SSL_VERIFYPEER, FALSE);

  $alte_page=curl_exec ($alte_ch);
  curl_close ($alte_ch);

  $page = explode("\n",$alte_page);

$match = array();

preg_match('/(.+),(\w{3}),([0-9.]+),([0-9.]+)/i', implode('', $page), $match);

if (sizeof($match) > 0) {
  return $match[3];
} else {
  return false;
}
 }

 function quote_xe_currency($to, $from = DEFAULT_CURRENCY) {

  $alte_url = "http://www.xe.net/ucc/convert.cgi";
  $alte_params = 'Amount=1&From=' . $from . '&To=' . $to;
  $alte_user_agent = "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)";

  $alte_ch = curl_init();
  curl_setopt($alte_ch, CURLOPT_POST,1);
  curl_setopt($alte_ch, CURLOPT_POSTFIELDS,$alte_params);
  curl_setopt($alte_ch, CURLOPT_URL,$alte_url);
  curl_setopt($alte_ch, CURLOPT_SSL_VERIFYHOST, 2);
  curl_setopt($alte_ch, CURLOPT_USERAGENT, $alte_user_agent);
  curl_setopt($alte_ch, CURLOPT_RETURNTRANSFER,1);
  curl_setopt($alte_ch, CURLOPT_SSL_VERIFYPEER, FALSE);

  $alte_page=curl_exec ($alte_ch);
  curl_close ($alte_ch);

  $page = explode("\n",$alte_page);

$match = array();

preg_match('/[0-9.]+\s*' . $from . '\s*=\s*([0-9.]+)\s*' . $to . '/', implode('', $page), $match);

if (sizeof($match) > 0) {
  return $match[1];
} else {
  return false;
}
 }
?>

Link to comment
Share on other sites

  • 3 weeks later...

Hi,

 

I have added the above code is the localization file and the exchange rate does now update successfully for GBR (which is what I want). I have set GBR as my default currency but when I go to my site it is still all in US Dollars, Im I missing something?

 

Alex

Link to comment
Share on other sites

  • 3 months later...
Try replacing localization.php with this:

 

NB. Web server must have PHP cURL extensions loaded (present in most).

 

 

<?php
/*
 $Id: localization.php,v 1.12 2003/06/25 20:36:48 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

 Copyright © 2003 osCommerce

 Released under the GNU General Public License
*/

 function quote_oanda_currency($code, $base = DEFAULT_CURRENCY) {

//FIX
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=' . $code .  '&format=CSV&dest=Get+Table&sel_list=' . $base);
curl_setopt($ch, CURLOPT_HEADER,0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TRANSFERTEXT, 1);
$page= curl_exec($ch); 
curl_close($ch);
//END FIX

//insecure line    $page = file('http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=' . $code .  '&format=CSV&dest=Get+Table&sel_list=' . $base);

   $match = array();

   preg_match('/(.+),(\w{3}),([0-9.]+),([0-9.]+)/i', $page, $match);

   if (sizeof($match) > 0) {
     return $match[3];
   } else {
     return false;
   }
 }



 function quote_xe_currency($to, $from = DEFAULT_CURRENCY) {

//FIX
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.xe.com/ucc/convert.cgi?Amount=1&From=' . $from . '&To=' . $to);
curl_setopt($ch, CURLOPT_HEADER,0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TRANSFERTEXT, 1);
$page= curl_exec($ch); 
curl_close($ch);
//END FIX


//insecure    $page = file('http://www.xe.net/ucc/convert.cgi?Amount=1&From=' . $from . '&To=' . $to);

   $match = array();

   preg_match('/[0-9.]+\s*' . $from . '\s*=\s*([0-9.]+)\s*' . $to . '/', $page, $match);

   if (sizeof($match) > 0) {
     return $match[1];
   } else {
     return false;
   }
 }



?>

 

 

No more really bad .htaccess or php.ini directives like allow_url_fopen or allow_url_include required. More recent versions of PHP prohibit local enabling of these functions if the host php.ini has disabled them.

 

Two things here differ from similar code around using cURL in place of file() or similar.

 

#1 cURL returns the page as a string, not an array - so the implode command which is tripping up the preg_match function line is no longer required.

 

#2 the second URL now contains www.xe.com - not www.xe.net as in previous file. My file is based on OSC ME2.2, so this may have been corrected in the later RC version.

 

 

Mate! I owe you a pint as well! Thanks a lot.

Link to comment
Share on other sites

  • 5 weeks later...

This worked for me too.

Tks a lot! :)

 

Try replacing localization.php with this:

 

NB. Web server must have PHP cURL extensions loaded (present in most).

 

 

<?php
/*
 $Id: localization.php,v 1.12 2003/06/25 20:36:48 hpdl Exp $

 osCommerce, Open Source E-Commerce Solutions
 [url="http://www.oscommerce.com"]http://www.oscommerce.com[/url]

 Copyright © 2003 osCommerce

 Released under the GNU General Public License
*/

 function quote_oanda_currency($code, $base = DEFAULT_CURRENCY) {

//FIX
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=' . $code .  '&format=CSV&dest=Get+Table&sel_list=' . $base);
curl_setopt($ch, CURLOPT_HEADER,0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TRANSFERTEXT, 1);
$page= curl_exec($ch); 
curl_close($ch);
//END FIX

//insecure line    $page = file('http://www.oanda.com/convert/fxdaily?value=1&redirected=1&exch=' . $code .  '&format=CSV&dest=Get+Table&sel_list=' . $base);

   $match = array();

   preg_match('/(.+),(\w{3}),([0-9.]+),([0-9.]+)/i', $page, $match);

   if (sizeof($match) > 0) {
     return $match[3];
   } else {
     return false;
   }
 }



 function quote_xe_currency($to, $from = DEFAULT_CURRENCY) {

//FIX
$ch=curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.xe.com/ucc/convert.cgi?Amount=1&From=' . $from . '&To=' . $to);
curl_setopt($ch, CURLOPT_HEADER,0); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_TRANSFERTEXT, 1);
$page= curl_exec($ch); 
curl_close($ch);
//END FIX


//insecure    $page = file('http://www.xe.net/ucc/convert.cgi?Amount=1&From=' . $from . '&To=' . $to);

   $match = array();

   preg_match('/[0-9.]+\s*' . $from . '\s*=\s*([0-9.]+)\s*' . $to . '/', $page, $match);

   if (sizeof($match) > 0) {
     return $match[1];
   } else {
     return false;
   }
 }



?>

 

 

No more really bad .htaccess or php.ini directives like allow_url_fopen or allow_url_include required. More recent versions of PHP prohibit local enabling of these functions if the host php.ini has disabled them.

 

Two things here differ from similar code around using cURL in place of file() or similar.

 

#1 cURL returns the page as a string, not an array - so the implode command which is tripping up the preg_match function line is no longer required.

 

#2 the second URL now contains www.xe.com - not www.xe.net as in previous file. My file is based on OSC ME2.2, so this may have been corrected in the later RC version.

Patty

Link to comment
Share on other sites

  • 4 months later...
re: file(): URL file-access is disabled in the server configuration

 

I had the same problem, and following a posting by

volrathxp on

http://forums.invisionpower.com/lofiversio...hp/t121520.html

 

I added the line

ini_set("allow_url_fopen","1");

 

into

catalog\admin\includes\functions\localization.php

 

as follows:

function quote_oanda_currency($code, $base = DEFAULT_CURRENCY) {

ini_set("allow_url_fopen","1");

$page = file('http://www.oanda.com/convert/fxdaily?value=1&redirected=1

 

and it seems to have sorted the problem with updating currencies.

 

This worked with OC 3.0a5 version as well. Note you probably need to add the line twice, once for Oanda, and once for Xe...

Thanks, John :-#)#

Link to comment
Share on other sites

  • 1 month later...

This solution worked for me too. Thanks a lot amcho!

 

 

re: file(): URL file-access is disabled in the server configuration

 

I had the same problem, and following a posting by

volrathxp on

http://forums.invisionpower.com/lofiversio...hp/t121520.html

 

I added the line

ini_set("allow_url_fopen","1");

 

into

catalog\admin\includes\functions\localization.php

 

as follows:

function quote_oanda_currency($code, $base = DEFAULT_CURRENCY) {

ini_set("allow_url_fopen","1");

$page = file('http://www.oanda.com/convert/fxdaily?value=1&redirected=1

 

and it seems to have sorted the problem with updating currencies.

Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks later...

i have the same problem, but all those solutions did not worked for me.

 

I have 2 currencies: EUR and RON (Romania)

 

I replaced the localization.php but i still have this errors:

 

Error Error: The exchange rate for Ron (RON) was not updated via xe. Is it a valid currency code?

Warning Warning: The primary exchange rate server (oanda) failed for Euro (EUR) - trying the secondary exchange rate server.

Error Error: The exchange rate for Euro (EUR) was not updated via xe. Is it a valid currency code?

 

Can anybody help me?

 

Thanks!

Link to comment
Share on other sites

  • 2 months later...

This solution worked for me too. Thanks a lot amcho!

Was about to delete / re-add my currencies. Found this and replaced the original code with the code mentioned a few posts up and it worked

 

Thanks

 

Ian

Link to comment
Share on other sites

  • 2 weeks later...

Hi, I am getting the same problem of no price displayed in listing or in cart once item has been added, error codes are:

 

Warning: The primary exchange rate server (oanda) failed for GBR () - trying the secondary exchange rate server.

Error Error: The exchange rate for GBR () was not updated via xe. Is it a valid currency code?

 

I have tried replacing the codes to the above ones by copy & pasting then pressing update on the currencies but it is not making any difference.

 

I am in UK so currency is pound, GBP OR GBR I have tried all but still comes up not a valid currency.

 

All help very much appreciated. Ray.

Link to comment
Share on other sites

  • 7 months later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...