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
[FONT="Courier New"]/ramdisk/bin/php5 -c /home3/MY_USER_NAME/public_html/php.ini /home3/MY_USER_NAME/public_html/currency_update.php[/FONT] 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.
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:
Re: Currency Update (Automatic)
Quote:
Originally Posted by
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.
Quote:
Originally Posted by
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.
Quote:
Originally Posted by
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.
Re: Currency Update (Automatic)
Quote:
Originally Posted by
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
Code:
<?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.
Re: Currency Update (Automatic)
Quote:
Originally Posted by
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.
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
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!
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
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:
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