Ok I'll post my setup to help people having problems. (Using justhost.com)
using standard cron through cpanel:
php -q /home/[username]/public_html/catalog/currency_update.php
php -q tells the cron to use the php intrepter or the cron will just try to run each line in the php file itself.
the php file has:
$location = '/home/[username]/public_html/catalog/'; // location of zen-cart intall
Although yours may not have the catalog folder. Make sure you include the '/' at the end and in this case I had to delete the '.' at the start.
The file persmission needs to be 644 although some cron jobs need 755? i think.
With this currency_update.php script I added an email function that tells you when the script has been run. I had concerns that a user can run the script to update currencies when rates suddenly drop in a certain currency and therefore purchasing the product for cheaper than you intended. Ok it's unlikely but never say never.
Anyway this addition emails you when its run and also the new rates. This also provides you with a backup of currency rates if you need to change them back.
add this:
Code:
require_once($location.'includes/configure.php');
require_once($location.'includes/database_tables.php');
// no need to edit below this line
// !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
$newrates=''; // add this here
now add the $newrates code to the orignal and also the email function so it looks like:
Code:
$newrates = $newrates."\n".$currency['code']." ".$rate;
if ($rate) {mysql_db_query(DB_DATABASE, "update " . TABLE_CURRENCIES . " set value = '" . $rate . "', last_updated = now() where currencies_id = '" . $currency['currencies_id']. "'", $link);}
}
}
mysql_close($link);
//end lookup
$to = "[email protected]";
$subject = "Currency Update";
$thedate = getdate();
$thedate = $thedate['hours'].":".$thedate['minutes'].".".$thedate['seconds']." ".$thedate['mday']."/".$thedate['mon']."/".$thedate['year'];
$body = "mywebsite.com\n\ncurrency_update.php script has been run on ".$thedate."\nRate: ".$newrates;
if (mail($to, $subject, $body)) {
echo("<p>Message successfully sent!</p>");
} else {
echo("<p>Message delivery failed...</p>");
}
dont forget to change the email address.
Not sure if that will help you or not but it's helped me.
Bookmarks