If you are still having issues then replace your file YOUR_ADMIN/auto_store_open_close.php with this code:
PHP Code:
<?php
/*
***********************************************************************
$Id: auto_store_open_close.php, v 1.2 2016/02/15
ZenCart 1.5.4
Copyright 2003-2010 Zen Cart Development Team
Portions Copyright 2004 osCommerce
http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
Originally written By SkipWater <skip@ccssinc.net> 05.08.10
Modified by Frank Riegel (frank18) isonetwork.net.au - Mon 15 Feb 2016 14:23:02 +1000 $
Use at your own risk.
***********************************************************************
All we do is set the store status value based on the time of day.
The admin of the zen cart should setup a cron to run this script a
minute or two after the hour set to open and close the store.
That is 2 (two) cron calls a day. One to open and one to close.
This file must be run from the admin folder of the zen cart site.
*/
define('CRON_ADMIN_USER_ID', '1'); // as suggested by DrByte --- DO NOT EDIT THIS LINE OR YOUR CRON TAB WILL NOT WORK!!!
require('includes/application_top.php');
$now_time = date('H:i:s'); // --- DO NOT EDIT THIS LINE OR YOUR CRON TAB WILL NOT WORK!!!
// Change to meet your opening and closing times - you need to set below times to 5 mins earlier than your advertised opening/closing times
// and then set your cron tab times to the exact advertised opening/closing times of your physical store
// Time is based on 24 hour clock 12 = noon, 00 = Midnight
$store_open = ("10:55:00");// 10:55 am
$store_close = ("21:55:00"); // 09:55 pm
// If you want an email sent to store owner, that notifies that the status of the Online Store has actually changed
// Set this to 1
$notify = 1;
/*
0 = Normal Store
1 = Showcase no prices
2 = Showcase with prices
*/
if ((strtotime($now_time) >= strtotime($store_open)) && (strtotime($now_time) <= strtotime($store_close))) {
$zen_store_stat = 0; // Store is Open Normal Zen Cart
} else {
// comment / uncomment ONE of the next 2 lines to fit your requirements
// $zen_store_stat = 1; // Store is Closed - Showcase no Prices
$zen_store_stat = 2; // Store is Closed - Showcase with Prices >> RECOMMENDED
}
// Should not need to edit below this line
// ***********************************************************************
$check_query = "SELECT * FROM " . TABLE_CONFIGURATION . " WHERE configuration_key = 'STORE_STATUS';";
$check_result = $db->Execute($check_query);
if ($check_result->RecordCount() > 0) {
$insert_query = "UPDATE " . TABLE_CONFIGURATION . " SET configuration_value='" . $zen_store_stat . "' WHERE `configuration_key` = 'STORE_STATUS'; ";
$insert_result = $db->Execute($insert_query);
// uncomment if not running cron
// if ($insert_result) echo 'Store Status Set to '.$zen_store_stat.'<br />';
}
// by now the Store Status should be updated as specified above
// now let's notify the store owner by email
if ($notify != 0) {
$email_updated_status = false;
zen_mail();
switch (true) {
case ($zen_store_stat == 0):
$email_updated_status = true;
zen_mail('',STORE_OWNER_EMAIL_ADDRESS, 'Store Status Changed to OPEN', 'Online Store OPEN - updated: '. date('Y M d H:i:s'), '',STORE_OWNER_EMAIL_ADDRESS); // email admin if status change to OPEN
break;
case ($zen_store_stat == 1):
$email_updated_status = true;
zen_mail('',STORE_OWNER_EMAIL_ADDRESS, 'Store Status Changed to CLOSED (Showcase no prices)', 'Online Store CLOSED (Showcase no prices) - updated: '. date('Y M d H:i:s'), '',STORE_OWNER_EMAIL_ADDRESS); // email admin if status change to CLOSED
break;
case ($zen_store_stat == 2):
$email_updated_status = true;
zen_mail('',STORE_OWNER_EMAIL_ADDRESS, 'Store Status Changed to CLOSED (Showcase with prices)', 'Online Store CLOSED (Showcase with prices) - updated: '. date('Y M d H:i:s'), '',STORE_OWNER_EMAIL_ADDRESS); // email admin if status change to CLOSED
break;
default:
// uncomment if not running cron
// echo 'Error Setting Store Status <br />';
zen_mail('',STORE_OWNER_EMAIL_ADDRESS, 'Error Failed Setting Store Status!!', 'ERROR - No Store Status set on OnLine Store! '.date('Y M d H:i:s'),'',STORE_OWNER_EMAIL_ADDRESS); // email admin if status change failed
break;
}
}
?>
I tested this on a 1.5.4 server with PHP 5.5.9 and had no issues.
Please let me know how it works for you.
Bookmarks