Forums / All Other Contributions/Addons / Currency Update (Automatic)

Currency Update (Automatic)

Views: 82,431

Results 221 to 240 of 298
12 Oct 2010, 11:48 AM
#221
nithinalex avatar

nithinalex

New Zenner

Join Date:
Oct 2010
Location:
India
Posts:
1
Plugin Contributions:
0

Currency Update (Automatic)

I was checking Automatic Currency Updater version 4.0 extension ...and found that currency conversion feed from European Central Bank's website do not contain Middle East Asian countries like UAE, Saudi Riyal, Kuwait Dinar etc Exchange rates...... :unsure: :shocking: So what to do for getting Currency Exchange rates from such Gulf countries??? .......

12 Oct 2010, 1:25 PM
#222
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Currency Update (Automatic)

nithinalex:

I was checking Automatic Currency Updater version 4.0 extension ...and found that currency conversion feed from European Central Bank's website do not contain Middle East Asian countries like UAE, Saudi Riyal, Kuwait Dinar etc Exchange rates...... :unsure: :shocking: So what to do for getting Currency Exchange rates from such Gulf countries??? .......Have you found somebody prepared to supply that data for free? If so, please advise and we can look at extending this mod to take their feed.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

5 Nov 2010, 10:14 AM
#223
leest35 avatar

leest35

Zen Follower

Join Date:
May 2010
Location:
London UK
Posts:
134
Plugin Contributions:
0

Re: Currency Update (Automatic)

HI,

I am trying to use the mod but i am running in to problems getting it working.

for the physical path of my installation i have added this:

define('/home/username/public_html/','');

But i keep getting the following messages:

Warning: require_once(PATH_TO_STORE_ROOTincludes/configure.php) [function.require-once]: failed to open stream: No such file or directory in /home/pestcont/public_html/currency_update.php on line 23

Fatal error: require_once() [function.require]: Failed opening required 'PATH_TO_STORE_ROOTincludes/configure.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/pestcont/public_html/currency_update.php on line 23

my currency update file is just located in the main catalogue

5 Nov 2010, 10:18 AM
#224
kuroi avatar

kuroi

Totally Zenned

Join Date:
Apr 2006
Location:
London, UK
Posts:
10,475
Plugin Contributions:
11

Re: Currency Update (Automatic)

Try

define('PATH_TO_STORE_ROOT','/home/pestcont/public_html/');

which should work, though this defeats the object of allowing you to place the file outside of the web root so that trolls won't be able to browse to and execute it.

Kuroi Web Design and Development | Twitter

(Questions answered in the forum only - so that any forum member can benefit - not by personal message)

5 Nov 2010, 10:39 AM
#225
leest35 avatar

leest35

Zen Follower

Join Date:
May 2010
Location:
London UK
Posts:
134
Plugin Contributions:
0

Re: Currency Update (Automatic)

thanks, i just want to try it first and then i will relocate it. outside of the website, thanks for your help.

Lee

5 Nov 2010, 10:42 AM
#226
leest35 avatar

leest35

Zen Follower

Join Date:
May 2010
Location:
London UK
Posts:
134
Plugin Contributions:
0

Re: Currency Update (Automatic)

OK, that worked perfect now thank you, i just have to work out the path once i have moved it, but that's great. Much appreciated.

Thank you

Lee

19 Dec 2010, 10:55 AM
#227
bioreactor avatar

bioreactor

New Zenner

Join Date:
Dec 2010
Posts:
2
Plugin Contributions:
0

Re: Currency Update (Automatic)

I am new to zencart. I have just installed v1.3.9h . I am trying to install Currency Update (Automatic) v4 . My host does not allow cronjob. If i place the file in the folder includes/auto_loaders will it run? (define('PATH_TO_STORE_ROOT','www/zen139-1/includes/auto_loaders/');) I tried this but nothing what am i doing wrong?:frusty::wacko:

thank you in advance

19 Dec 2010, 11:25 AM
#228
frank18 avatar

frank18

Deceased

Join Date:
Nov 2007
Location:
Sunny Coast, Australia
Posts:
3,427
Plugin Contributions:
2

Re: Currency Update (Automatic)

bioreactor:

I am new to zencart. I have just installed v1.3.9h . I am trying to install Currency Update (Automatic) v4 . My host does not allow cronjob. If i place the file in the folder includes/auto_loaders will it run? (define('PATH_TO_STORE_ROOT','www/zen139-1/includes/auto_loaders/');) I tried this but nothing what am i doing wrong?:frusty::wacko:

thank you in advance

As far as I know you will need a cron job to execute the file automatically at a given time of the day. Placing the file in the folder includes/auto_loaders will not do the trick.

You may want to talk to your host and see if they can set up a cron for you.

NOTE: We are sorry that Frank is no longer with us.
We are grateful for all his contributions to the Zen Cart community.

23 Dec 2010, 7:31 PM
#229
bioreactor avatar

bioreactor

New Zenner

Join Date:
Dec 2010
Posts:
2
Plugin Contributions:
0

Re: Currency Update (Automatic)

frank18:

As far as I know you will need a cron job to execute the file automatically at a given time of the day. Placing the file in the folder includes/auto_loaders will not do the trick.

You may want to talk to your host and see if they can set up a cron for you.

Thank you very much for you precious help:smile:

I justed hoped that ther was also another way except for cronjob :cry:

21 Jan 2011, 12:37 PM
#230
athens_collectibles avatar

athens_collectibles

Zen Follower

Join Date:
May 2010
Location:
Athens, Greece
Posts:
293
Plugin Contributions:
0

Re: Currency Update (Automatic)

A very old thread but a wonderful mod!

Having gone through almost every post, I was struggling to understand how it should be set up. I sent a support ticket to Bluehost but haven't received a reply yet. So, I decided to give it a try until a reply was received.

I have Zen Cart 1.3.9h installed in my root directory and wanted to install the Automatic Currency Updater version 4.0. Based on what I read in the posts above and Bluehost's help files on how to set up a cron job:

I placed the currency_update.php unmodified in my public_html folder. When entering http://athenscollectibles.info/currency_update.php in the browser, I got a blank page which, assuming from earlier posts, is what I should get. When I changed line 20 to define('PATH_TO_STORE_ROOT','/'); (i.e. with an added / between the single quotes), I got the following error:

Warning: require_once(/includes/configure.php) [function.require-once]: failed to open stream: No such file or directory in /home3/MY_USER_NAME/public_html/currency_update.php on line 23

Fatal error: require_once() [function.require]: Failed opening required '/includes/configure.php' (include_path='.:/usr/lib64/php:/usr/lib/php') in /home3/MY_USER_NAME/public_html/currency_update.php on line 23

I removed the / and everything went back to normal, so I left it like this.

Now, setting the cron job: as per Bluehost's help files, I entered the command:

/ramdisk/bin/php5 -c /home3/MY_USER_NAME/public_html/currency_update.php

and set it to run every minute (that's just to see what happens, I will change the frequency after making sure that everything works fine).

The rates were updated quickly and correctly (but see below about rounding). To test the system again, I updated the rates from the Admin > Localization > Currencies which brought up the oanda rates. These soon changed back to the ECB rates, proving that the mod and the cron job function correctly.

So far, so good. However, the auto email I get when the cron job runs, reads:

PHP: Error parsing /home3/MY_USER_NAME/public_html/currency_update.php on line 1
X-Powered-By: PHP/5.2.14
Content-type: text/html

Line 1 of the currency_update.php file reads:

#!/usr/bin/php

I don't know php but thought of changing the first line of the file to
#!/ramdisk/bin/php5 (in line with the cron job command as above) and see what happens. Unfortunately, I still got the same error in the email, so I restored the original line 1.

Although the exchange rates are published with 4 decimal places on the ECB web site, they are entered with 8 decimals in my currencies. I assume that the ECB file used to pull the rates has indeed 8 decimal places but they are displayed with 4 decimal places on the web site or is there another reason?

For example, with EUR as my base currency, rates are as follows:

USD 1.3472 1.34720004
GBP 0.8436 0.84359998
CAD 1.3463 1.34630001
AUD 1.3583 1.35829997

The first column shows the rates as published by ECB, the second as they are entered in my currencies. Is this something normal and not to be concerned about?

I wonder if someone can help in eliminating the above error message in emails and advising about the exchange rates decimals.

Any help will be greatly appreciated and my thanks are expressed in advance. Apologies for the very long post, which could possibly be of help to other Bluehost users.

21 Jan 2011, 4:23 PM
#231
athens_collectibles avatar

athens_collectibles

Zen Follower

Join Date:
May 2010
Location:
Athens, Greece
Posts:
293
Plugin Contributions:
0

Re: Currency Update (Automatic)

Update to the previous post

The above procedure was not correct (!)

It seems that the rates were updated when I run the file from my browser, not with the cron job. Finally, I found the solution.

The correct cron job command, as instructed by Bluehost, should have been

/ramdisk/bin/php5 -c /home3/MY_USER_NAME/public_html/php.ini /home3/MY_USER_NAME/public_html/currency_update.php and I had deliberately omitted the middle part as there was no php.ini file in my home directory. This was most probably responsible for the error message in the email and for the cron job not running.

I installed a master php.ini file in my home directory by selecting php Config from the Software/Services section of the cPanel and that seems to have done the job: the email now reads

X-Powered-By: PHP/5.2.14
Content-type: text/html

and the rates are updated normally. I tested it repeatedly by updating the rates from oanda, waiting for the cron job to run and seeing them changing within a minute (I still have the cron job to run every minute).

End of story for me. :D

Note: /home3/MY_USER_NAME is the name of my home directory. A user's home directory is displayed on the left side of cPanel in the Stats section.

21 Jan 2011, 10:13 PM
#232
athens_collectibles avatar

athens_collectibles

Zen Follower

Join Date:
May 2010
Location:
Athens, Greece
Posts:
293
Plugin Contributions:
0

Re: Currency Update (Automatic)

A last note to say that the mod works perfectly for the last few hours and to express my thanks to those who created and enhanced it. Great job and far better than the default Zen Cart manual update of exchange rates.

Thank you all. :bigups:

27 Jan 2011, 8:27 PM
#233
dayo avatar

dayo

Zen Follower

Join Date:
Dec 2006
Posts:
187
Plugin Contributions:
1

Re: Currency Update (Automatic)

kuroi:

Earlier versions of this mod used oanda and xe. However, they changed they terms of use to outlaw screen scrapping. So the mod was changed to the ECB feed to keep it legal.

kuroi:

The difference is that the admin script was written in 2006, before the terms of use were changed. Earlier versions of the mod were based on that code.

Troll:

Still don't understand the legal thingy though...I don't understand that including an old script to a new version makes it legal
This one has me scratching my head as well.

As far as I can see, the older versions of the mod were exactly the same as the script in the ZC admin adjusted so it could run outside the ZC environment. How can the code in the older versions of the mod be illegal and that in the ZC admin be legal?

I understand the ZC admin code was written in 2006 before the change of the TOS on the sites but that does not seem to be a reasonable explanation with respect to new releases.

So can one of the devs please clarify whether the currency update code in the ZC Admin is legal or not with regards to the TOS of the sites used for updates? If it is, I can't see how the code in the older versions of this mod could have been illegal.

Just trying to see whether to continue using the older (illegal?) version since it covers currencies not covered by the ECB.

Thanks.

27 Jan 2011, 9:01 PM
#234
dayo avatar

dayo

Zen Follower

Join Date:
Dec 2006
Posts:
187
Plugin Contributions:
1

Re: Currency Update (Automatic)

nithinalex:

I was checking Automatic Currency Updater version 4.0 extension ...and found that currency conversion feed from European Central Bank's website do not contain Middle East Asian countries like UAE, Saudi Riyal, Kuwait Dinar etc Exchange rates...... :unsure: :shocking: So what to do for getting Currency Exchange rates from such Gulf countries??? .......

I live in Bahrain and our currency is not covered either.

There is some confusion as to legalities but if the code in the Zencart admin is legal, then this is legal as it is taken directly from there

<?php
/**
 * @package admin
 * @copyright Copyright 2003-2009 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: currencies.php 15074 2009-12-10 03:04:31Z drbyte $
 */

/* Code below from admin/currencies.php in Zencart 1.3.9h */
  require('includes/application_top.php');
  require(DIR_WS_CLASSES . 'currencies.php');
  $currencies = new currencies();
      case 'update_currencies':
        $server_used = CURRENCY_SERVER_PRIMARY;
        zen_set_time_limit(600);
        $currency = $db->Execute("select currencies_id, code, title from " . TABLE_CURRENCIES);
        while (!$currency->EOF) {
          $quote_function = 'quote_' . CURRENCY_SERVER_PRIMARY . '_currency';
          $rate = $quote_function($currency->fields['code']);
  
          if (empty($rate) && (zen_not_null(CURRENCY_SERVER_BACKUP))) {
            // failed to get currency quote from primary server - attempting to use backup server instead
            $messageStack->add_session(sprintf(WARNING_PRIMARY_SERVER_FAILED, CURRENCY_SERVER_PRIMARY, $currency->fields['title'], $currency->fields['code']), 'warning');
            $quote_function = 'quote_' . CURRENCY_SERVER_BACKUP . '_currency';
            $rate = $quote_function($currency->fields['code']);
            $server_used = CURRENCY_SERVER_BACKUP;
          }
  
          /* Add currency uplift */
          if ($rate != 1 && defined('CURRENCY_UPLIFT_RATIO') && (int)CURRENCY_UPLIFT_RATIO != 0) {
            $rate = (string)((float)$rate * (float)CURRENCY_UPLIFT_RATIO);
          }

          // special handling for JPY, which always uses whole numbers, never decimals
          if ($code == 'JPY') {
            $rate = (int)$rate;
          }
  
          if (zen_not_null($rate) && $rate > 0) {
            $db->Execute("update " . TABLE_CURRENCIES . "
                          set value = '" . $rate . "', last_updated = now()
                          where currencies_id = '" . (int)$currency->fields['currencies_id'] . "'");
          }
          $currency->MoveNext();
        }
  /* relevant section from includes/application_bottom.php in Zencart 1.3.9h */
  session_write_close();
?>

Save it as a php file under your ZC folder (choose any name apart from currency_update so that wreckers do not keep firing it off) and set up the cron job as explained elsewhere in this thread. Covers every currency just like the ZC admin does.

28 Jan 2011, 5:44 AM
#235
dayo avatar

dayo

Zen Follower

Join Date:
Dec 2006
Posts:
187
Plugin Contributions:
1

Re: Currency Update (Automatic)

Dayo:

Save it as a php file under your ZC folder ... and set up the cron job as explained elsewhere in this thread.

Sorry. My code above will not work. Creating a spin off from this module based on the core Zencart code and functions in the Zencart admin which would similarly cover all currencies.

28 Jan 2011, 7:27 AM
#236
dayo avatar

dayo

Zen Follower

Join Date:
Dec 2006
Posts:
187
Plugin Contributions:
1

Re: Currency Update (Automatic)

Done the spin off version

PREAMBLE:
It is basically the same as the earlier versions of this module with minor updates but being given a new name since this module has developed to use ECB Reference Rates which only cover a limited set of currencies (Major Currencies Only) due to what appears to be concerns with the legality of the earlier versions.

The spin-off version returns to using the functions shipped with Zencart and is based on the assumption that if that code is legal, this must be as all it does is hook into the relevant Zencart functions as used by the core code.

USAGE:
Save the code into a php file and upload to your Zencart Admin folder. (No need to edit anything as it just hooks into ZC Functions)
Set up a cron job to call the file.

You can get the code here: http://www.zen-cart.com/forum/showthread.php?t=173176

30 Jan 2011, 12:16 PM
#237
joyjoy avatar

joyjoy

Totally Zenned

Join Date:
Sep 2010
Posts:
611
Plugin Contributions:
0

Re: Currency Update (Automatic)

HELP! HELP!

I'm losing my mind with this mod. I have managed to set up the cronjob, it runs and I get not errors in my email. However, the rates don't update? I've tried to change to root path over and over and followed many of the suggestions here but I just can't get it to work.

I have renamed catalog to shop. currency_update.php is in my shop file. It calls correctly and I do get the blank page if I run it in a browser. Any ideas?

Thank you!

23 Jun 2011, 7:11 PM
#238
spembleton avatar

spembleton

Zen Follower

Join Date:
Jun 2010
Location:
Holland, MI
Posts:
232
Plugin Contributions:
0

Re: Currency Update (Automatic)

Everything seemed to run smoothly. I got the following email. Does that mean it worked ok, or???:

Content-type: text/html

23 Jun 2011, 7:38 PM
#239
athens_collectibles avatar

athens_collectibles

Zen Follower

Join Date:
May 2010
Location:
Athens, Greece
Posts:
293
Plugin Contributions:
0

Re: Currency Update (Automatic)

Hi Steve,

The email shows that it runs smoothly!

I checked one of your items selling for $47.74 which converts to €35.27.

If the value in your Configuration > My Store > Currency Conversion Ratio has been left to the default 1.05 (to allow for bank commissions), then the conversion is perfect:

Today's EUR/USD rate is 1.4212. Therefore $47.74 / 1.4212 = 33.59 x 1.05 = €35.27 = correct.

This mod is something you set up once and then forget about it; it works by itself. Just check the email from time to time for any possible errors reported. If you get the "Content-type: text/html", there's nothing else you need to do.

Well done! :yes:

23 Jun 2011, 7:40 PM
#240
spembleton avatar

spembleton

Zen Follower

Join Date:
Jun 2010
Location:
Holland, MI
Posts:
232
Plugin Contributions:
0

Re: Currency Update (Automatic)

Thanks. I love the add-on. I keep forgetting to update the currencies, but luckily have so few foreign customers that it has not been an issue.

Thanks for the add-on and for your confirmation