Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Auto Update Currencies


Jack_mcs

Recommended Posts

  • 3 months later...

Hi, I am working on a new phoenix site, but have just realized that my auto update currency in  my live site, which is 2.3.4 is not working. Yet it has only been a few months that it has not worked for ...

At first I thought it was that my API key had lapsed, but I got that checked and put the link into a browser with my API key and it worked fine... so not sure why its not working... this is the error I am getting in the error log;

 

PHP Warning:  file(https://xurrency.com/api/gbp/aud/1?key=xxxx): failed to open stream: Connection refused in /home/creativ3/public_html/orders/admin/includes/functions/localization.php on line 19
PHP Warning:  implode(): Invalid arguments passed in /home/creativ3/public_html/orders/admin/includes/functions/localization.php on line 20
PHP Warning:  Invalid argument supplied for foreach() in /home/creativ3/public_html/orders/admin/includes/functions/localization.php on line 22
PHP Warning:  Invalid argument supplied for foreach() in /home/creativ3/public_html/orders/admin/includes/functions/localization.php on line 29

if I put the link into a browser this is the response I get:

{"status":"ok","code":0,"result":{"value":"1.7995","base":"gbp","target":"aud","updated_at":"2020-09-24T00:00:08Z"}}

So my API Key is working....

here is the appropriate code from localization.php;

function quote_xurrency_currency($base, $target = DEFAULT_CURRENCY) {
    if ($target == $base) return 1;	

$base = strtolower($base);
$target = strtolower($target);
  
    $page = file('https://xurrency.com/api/' . $base . '/' . $target . '/1?key=' . XURRENCY_KEY);
	$result = implode(",", $page);
	$result = json_decode($result,true);
	foreach ($result as $key => $value2) {
		if ($key == 'code') {
			if ($value2 != '0') {
				return false;
			}
		}
}
	foreach ($value2 as $key2 => $value3) {	
		if ($key2 == 'value') {
			$value = $value3;
		}
	}

    if (sizeof($value) > 0) {
      return $value;
    } else {
      return false;
    }
  }

It has been so long since I got this to work that I am having trouble working out what the problem could be - I'm obviously not the strongest coder - I can probably solve it with a couple of hours work, but if anyone with a keener eye than mine can see the problem I would really appreciate it.

Link to comment
Share on other sites

34 minutes ago, Portman said:

PHP Warning:  file(https://xurrency.com/api/gbp/aud/1?key=xxxx): failed to open stream: Connection refused in

Debugging a similar error:  https://stackoverflow.com/questions/15835274/php-file-get-contents-failed-to-open-stream-connection-refused

More results at https://www.google.com/search?q=PHP+Warning%3A++file()%3A+failed+to+open+stream%3A+Connection+refused+in

Always back up before making changes.

Link to comment
Share on other sites

@PortmanThis is the support thread for the Auto Update Currencies addon. If you are not using a version of it, then please post in the general forum. If you are, please let me know which version of the addon you are using.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

That's correct. The addon doesn't change the core function so if that code no longer works, it is due to something else. This thread may help. You could try upgrading this addon to v 1.3 since, as I recall, it contains the fix for the currency.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

  • 7 months later...

I Jack need your help, i'm using the OsCommerce v2.3.4.1 and I install the Auto Update currencies V1.4 but go to admin->Configuration->My Store to try set the Auto Update Currency setting to an hour but i don't see where???
Can you help?

Regards,

Nuno Amaral

Link to comment
Share on other sites

  • 4 months later...

Hi Jack,

What could be the problem if I can run the script directly from browser and get the rates updated, but can't run it from Cronjob. I did set it to 1 min, nothing change. This is the cron url im using : php /home/username/public_html/backend/auto_update_currencies.php

Any ideas where to look ?

Link to comment
Share on other sites

22 hours ago, Psytanium said:

php /home/username/public_html/backend/auto_update_currencies.php

If that is really what is being used then you need to change "username", assuming that is not the real username.

Support Links:

For Hire: Contact me for anything you need help with for your shop: upgrading, hosting, repairs, code written, etc.

Get the latest versions of my addons

Recommended SEO Addons

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...