-
Working hours...
Hi Folks,
I would like to restrict my store. Orderings need to possible only in working hours. I am just testing the latest Zen Cart version, before use it in real environment, but it is very important aspect for me. Could anybody suggest method, links etc.
Thanks in advanced,
Gyurci
-
Re: Working hours...
Hi and Welcome to the Forum. :smile:
Till you find something different the easiest way is to manually put the Store in Maintenance mode, then enable Store when open again.
Admin > Configuration > Website Maintenance
-
Re: Working hours...
I would create two php files. One contains an sql statement to put the store in showcase mode. The other contains an sql statement to put the store in normal mode. Then create two cron jobs to call the files at the appropriate times.
-
Re: Working hours...
Website Rob and Steven300,
thanks for your quick help. Theoretically I totally understand Steven300's solution and it is very creative, but I am a graphic designer and I have no programming knowledge at all. :(
So with PhpMyadmin I can find in configuration table the Store Status value but I can not write a PHP code to change it.
Could you give me some cue words what should I search in PHP help or forums. I definitely like to solve this problem so if I have to learn, I will do that. Please correct me if I wrong, I should connect to the local database, make a value change in a table and close the connection. Can I make it only with the built in PHP functions?
The two php files should be in public_html folder or not?
Thanks and have a nice day!
Gyurci
-
Re: Working hours...
I think it would go something like this..
PHP Code:
<?php
require('includes/application_top.php');
$sql="UPDATE configuration SET configuration_value = 2 where configuration_id = 23;";
$result=$db->Execute($sql);
?>
Including application_top.php will automatically connect you to the database. The example above puts the store in showcase mode (with prices). To put it in normal mode, you would change configuration_value from 2 to 0. This example assumes the file is in your root directory. I think you could put it elsewhere providing you update the path to application_top.php. Hope this helps.
-
Re: Working hours...
Or if you wanted to avoid cron jobs for whatever reason, you could take a different approach whereby you create a php file containing the following code and include it so it loads on each page visit to your site. It gets the current time and checks to see whether the store should be in normal mode or showcase mode and sets it accordingly. I'm not sure whether it would affect the speed of your site doing this on each page visit, but I think it should be okay.
PHP Code:
<?php
require('includes/application_top.php');
//Define opening time
$opening_time = "09:00:00";
$closing_time = "17:00:00";
//Remove characters
$opening_time = str_replace(':', '', $opening_time);
$closing_time = str_replace(':', '', $closing_time);
//Get current time
$t = time();
$now = date('His', $t);
//Check if it's opening time
if ( ($now > $opening_time ) && ( $now < $closing_time ) ) {
//opening time, put store in normal mode
$sql_opening="UPDATE configuration SET configuration_value = 0 where configuration_id = 23;";
$result_opening=$db->Execute($sql_opening);
} else {
//closing time, put store in showcase mode
$sql_closing="UPDATE configuration SET configuration_value = 2 where configuration_id = 23;";
$result_closing=$db->Execute($sql_closing);
}
?>
-
Re: Working hours...
I am in late because of test Your first method. At first sight it not worked for me because I put a pre (zen) tag to my all table at installation and I forgot about it. But now everything works fine.
Absolutelly You are the king. :yes:
I will try Your second method in a minute. Thanks for Your help.
Best regards,
Gyurci
-
Re: Working hours...
It's an another brilliant solution!
" create a php file containing the following code"
for example changemod.php
"and include it "
to where? You mean I should place this row "require('changemod.php');"to every visible php file on my webpage?! Tell the truth, this is my first try with Zen Cart, so I can not know the stucture pretty much.
Just a quick tip in theoretically:
May be I should only include this file to the index.php, so the first visitor will turn off the store shopping cart in the closed time, and vica versa. Is it true, that Your function works only when someone calls in my case the index.php from a web browser?
Bye,
Gyurci
-
Re: Working hours...
To be honest I'm still learning about the Zen Cart structure as well, especially when it comes to auto-loading. My (minimal) understanding of index.php is that it is like the "engine" for Zen Cart and is used to "put together" every page. So you might find that including it from index.php will load it on every page visit, not just the first. Hopefully someone more experienced in this area can jump in.
-
Re: Working hours...
Thanks once more, You solved my problem in a minute.
The cron version absolute perfect for me.
Good luck!
Gyurci