Jump to content
Jack_mcs

Auto Update Currencies

Recommended Posts

A new version has been uploaded. It adds a version for Phoenix. No file changes are required.

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
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.

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

hey @Jack_mcs,I

It is related to  Auto update currencies, I am using version 1 (as I mentioned in the post this is for my active 2.3.4 site which is going to be retired soon)

I thought because Auto Update currency  calls localization.php this was the place to post this, sorry if I am wrong.

 

Share this post


Link to post
Share on other sites

Does the currency update work if you click the update button in admin->Localization->Currencies?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Sorry but what settings should I make, you can help I'm really new to this and I would like to learn a lot, thanks for your time,

Share this post


Link to post
Share on other sites

Find this line

define('HOURS_BETWEEN_UPDATES' , '4')

and change the 4 to 1. You also need to run the cron job once an hour.

Share this post


Link to post
Share on other sites

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 ?

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×