glennlawre Posted May 20, 2013 Share Posted May 20, 2013 I am looking for a way to auto enable/disable my store. I cannot see any settings in the BO that allows for closing/opening the store at set times. Can anyone advise on how I can maybe do this? Is there a way to maybe schedule the store to go into/out of "Maintenance" mode? If so I could just configure the maintenance page to say we are closed. The reason for closing the store is because it is a food delivery website and we only deliver at certain times of the day & night. I am on PS v1.4.9.0 and using Windows (Helm) hosting. Any help would be great... Link to comment Share on other sites More sharing options...
benjamin utterback Posted May 20, 2013 Share Posted May 20, 2013 Hi glennlawre, I actually do not know of a module that can do that. However it does not seem that it will be very difficult. You may need to have it custom coded. Link to comment Share on other sites More sharing options...
glennlawre Posted May 21, 2013 Author Share Posted May 21, 2013 So is there a command that can be run from somewhere on a schedule that can put the store into maintenance mode? Link to comment Share on other sites More sharing options...
bellini13 Posted May 21, 2013 Share Posted May 21, 2013 As Benjamin already stated, you likely need create something custom to do this. Perhaps a cronjob (or windows equivalent) that executes at these pre-defined intervals that disables or enables the store Link to comment Share on other sites More sharing options...
glennlawre Posted May 21, 2013 Author Share Posted May 21, 2013 Thanks for the replies, You don't happen to know the command that needs to go into the cronjob to put the store into maintenance mode do you? Thanks in advance... Link to comment Share on other sites More sharing options...
bellini13 Posted May 22, 2013 Share Posted May 22, 2013 there is not an existing command, you would have to develop it. Link to comment Share on other sites More sharing options...
sooroos Posted August 19, 2013 Share Posted August 19, 2013 hi, i am looking for something like that also. In my case i would need the shop (online pizza) to function normally between specific times and for the rest, the shop needs to enter automatically in catalog mode (ordering would be disabled) specified by a popup with countdown time until opening Link to comment Share on other sites More sharing options...
bellini13 Posted August 19, 2013 Share Posted August 19, 2013 As stated a few times, a cronjob would need to be created that executes at these predefined times that enable/disable the shop. If you send me a PM with your specific time requirements, I can review them and provide you with an estimate to implement such a feature. Link to comment Share on other sites More sharing options...
PascalVG Posted August 25, 2013 Share Posted August 25, 2013 (edited) If you're allowed to create EVENTS on your database, that might work as well. Not sure if you are on a shared host, then normally they don't allow you to turn on the scheduler, though.. :-( But if you can run them, you could think about something like: CREATE EVENT IF NOT EXISTS SHOP_CLOSED ON SCHEDULE EVERY 1 DAY STARTS '2013-08-26 19:00:00' ENABLE DO UPDATE `ps_configuration` SET `value` = 0 where `name` = 'PS_SHOP_ENABLE'; To turn it off at 7 PM and: CREATE EVENT IF NOT EXISTS SHOP_OPEN ON SCHEDULE EVERY 1 DAY STARTS '2013-08-27 09:00:00' ENABLE DO UPDATE `ps_configuration` SET `value` = 1 where `name` = 'PS_SHOP_ENABLE'; to open the shop at 9 AM Just a thought... pascal (EDIT: Edited sql commands a little. needed to change 'value' not the 'name'...) Edited August 26, 2013 by PascalVG update command edited... (see edit history) 1 Link to comment Share on other sites More sharing options...
PascalVG Posted August 26, 2013 Share Posted August 26, 2013 Ok, two cron jobs and scripts: Create a file 'CloseShop.php' in /<root of shop>/config/ folder. Edit file and copy this in there: <?php // cron job php script to set shop into maintenance mode // by Pascal van Geest @ ModulesModules.com // Setup connection variables, such as database username // and password // host name, database user, password and database name // can be found in: // config/settings.inc.php $hostname="localhost"; $username="your user name of the database used"; $password="the password of that user"; $dbname="database name"; //Connect to the database $connection = mysql_connect($hostname, $username, $password); mysql_select_db($dbname, $connection); //Setup our query $query = "UPDATE `ps_configuration` SET `value` = 0 where `name` = 'PS_SHOP_ENABLE';"; //Run the Query $result = mysql_query($query); ?> Add info of hostname, database, user, password (see config/settings.inc.php for details) and save the file. Then go to your cPanel and go to Cron Jobs application. Add a new cron job: Select MINUTE = 0 (to close straight on the hour) HOUR = 19 (example, to close at 7 PM) select DAY = * (if you want to close the shop every day) select MONTH = * select WEEKDAY = * ( if you work all days) add command: /usr/bin/php full/path/to/your/new/file/CloseShop.php and save. Same to OPEN the shop again: Create new file OpenShop.php in the /<root of shop>/config/ folder. edit and copy this: <?php // cron job php script to get shop out of maintenance mode // by Pascal van Geest @ ModulesModules.com // Setup connection variables, such as database username // and password // host name, database user, password and database name // can be found in: // config/settings.inc.php $hostname="localhost"; $username="your user name of the database used"; $password="the password of that user"; $dbname="database name"; //Connect to the database $connection = mysql_connect($hostname, $username, $password); mysql_select_db($dbname, $connection); //Setup our query $query = "UPDATE `ps_configuration` SET `value` = 1 where `name` = 'PS_SHOP_ENABLE';"; //Run the Query $result = mysql_query($query); ?> Add info of hostname, database, user, password (see config//settings.inc.php for details) and save file make another cron job, to open the shop again: Select MINUTE = 30 (example, to close at half past...) HOUR = 8 (example, to open at 8:30 am) select DAY = * (if you want to close the shop every day) select MONTH = * select WEEKDAY = * ( if you work all days) add command: /usr/bin/php full/path/to/your/new/file/OpenShop.php and save. To see if it works, change the MINUTE AND HOUR temporarily to * (One job only, first cronjob of CloseShop.php. if that does the job (Check by waiting 1 minute and then reload the front of your shop) , change this job back to real closing time and then change the OpenShop cron job to *. If it reopens again (check again by waiting 1 minute then go to the shop page), change to the real opening times again. Hope this helps, pascal N.B. Be careful with the script files, as the password is unencrypted in there. (This is also the case for config/settings.inc.php) so set the permissions correctly 1 Link to comment Share on other sites More sharing options...
sooroos Posted August 26, 2013 Share Posted August 26, 2013 hi Pascal, thanks for your reply. i am trying something similar but i would like the shop to get automatically in catalog mode at specific times, not in maintenance. So i am using this crontab: 30 16 * * * /usr/bin/wget http://www.myshop.com/catalog.php and in catalog.php i have: <?php include(dirname(__FILE__).'/config/config.inc.php'); include(dirname(__FILE__).'/init.php'); if (!Configuration::get('PS_CATALOG_MODE')) { Configuration::updateValue('PS_CATALOG_MODE', true); } else { Configuration::updateValue('PS_CATALOG_MODE', false); } ?> and it is not working i have used "mailto" to receive the error and here it is: HTTP request sent, awaiting response... 503 temporarily overloaded 2013-08-26 03:10:02 ERROR 503: temporarily overloaded. Link to comment Share on other sites More sharing options...
El Patron Posted August 26, 2013 Share Posted August 26, 2013 you could just add code to the FrontController, (no crontab) that checks the time at runtime, you could then turn catalog mode on or off depending on the time. Link to comment Share on other sites More sharing options...
sooroos Posted August 26, 2013 Share Posted August 26, 2013 thanks for fast reply, but can you please be more specific? How to do that step by step Link to comment Share on other sites More sharing options...
El Patron Posted August 26, 2013 Share Posted August 26, 2013 here is a good post on time comparison. basically when anyone visits your domain, the code could check for open/closed times and set catalog mode accordingly. http://stackoverflow.com/questions/3403858/how-to-compare-two-time-in-php Link to comment Share on other sites More sharing options...
sooroos Posted August 26, 2013 Share Posted August 26, 2013 (edited) thanks, i see now what you mean, still i don't have knowledge of php the problem is not the crontab, as it is working fine, but the php script is, since i am a newbie pascal's solution seems just fine and seems that all ineed to do is change this line: $query = "UPDATE `ps_configuration` SET `value` = 1 where `name` = 'PS_SHOP_ENABLE';"; to this: $query = "UPDATE `ps_configuration` SET `value` = 1 where `name` = 'PS_CATALOG_MODE';"; Edited August 26, 2013 by sooroos (see edit history) Link to comment Share on other sites More sharing options...
PascalVG Posted August 26, 2013 Share Posted August 26, 2013 If you do want to use cronjobs, here they are: Furthermore just do the same as above. My 2 cents, pascal ToCatalogModeShop.php OutOfCatalogModeShop.php 2 Link to comment Share on other sites More sharing options...
sooroos Posted August 26, 2013 Share Posted August 26, 2013 i can confirm it is working. Thank you 1 Link to comment Share on other sites More sharing options...
PascalVG Posted August 26, 2013 Share Posted August 26, 2013 El Patron, I was curious: is the FrontController ALWAYS called, on every page? I ask, as I am curious what happens if someone already is in checkout or so, and the time expires, does in the checkout the frontController gets called? On the example page you linked to, I think they have some problems to 'update' the timestamp, as they use the timestring, but don't really have a mechanism to update the date in it. Looking at the discussion there, it's not fully straightforward to me how it works. Would love to see the code how this would look like! pascal Link to comment Share on other sites More sharing options...
PascalVG Posted August 26, 2013 Share Posted August 26, 2013 sooroos, thanks for the feedback! I'll mark the topic as solved. pascal Link to comment Share on other sites More sharing options...
sooroos Posted August 26, 2013 Share Posted August 26, 2013 thank you again, here are is my crontab in case someone needs to inspire and it is to lazy to browse the web, my shop opens at 16.30 and closes at 23.45, the 2 php files are provided by pascal above [email protected] 30 16 * * * /usr/bin/wget http://www.myshop.com/open.php -O /dev/null 45 23 * * * /usr/bin/wget http://www.myshop.com/close.php -O /dev/null Link to comment Share on other sites More sharing options...
El Patron Posted August 26, 2013 Share Posted August 26, 2013 El Patron, I was curious: is the FrontController ALWAYS called, on every page? I ask, as I am curious what happens if someone already is in checkout or so, and the time expires, does in the checkout the frontController gets called? On the example page you linked to, I think they have some problems to 'update' the timestamp, as they use the timestring, but don't really have a mechanism to update the date in it. Looking at the discussion there, it's not fully straightforward to me how it works. Would love to see the code how this would look like! pascal re: FrontController, yes I do believe that is is 'always' called. I think though due to the over use of class override on FrontController I would extend the Configuration class. As for the 'other' code checking dates etc...without crontab...I did not look at it very closely. I tend to stay away from anything cron related as not all hosting account supply an easy interface for cron, worse case scenario we have customers need ssh... then cron itself can be rather complex so that is why I suggested just checking at session time if the store should be open or closed. I've kicked around building a little module that would allow one to enter jobs to kick off in the back office and then use timers and session establishment to run them. If you think about it you could set up a time initiated ping to your website that did nothing but the module would at least be activated to run any jobs scheduled. You can run 1.4 and 1.5 ps catalog mode by session. But that requires the Configuration extension (not FrontController), and/or hack to use the Configuration::set (don't update file). But in answer to your question about what if someone is shopping and the store closes...you could check 1) logged in and 2) cart not empty...again in Configuration use the set to turn off catalog mode if on....but that seems like a lot of work for very little wool. 1 Link to comment Share on other sites More sharing options...
ssiimmoonn Posted December 14, 2013 Share Posted December 14, 2013 Attached Files OutOfCatalogModeShop.php 701bytes 4 downloads ToCatalogModeShop.php 697bytes 4 Downloads Cronjob help plz those are my opening times Monday 11:00 - 14:30 and from 17:00 clock - 23:00 clockTuesday 11:00 - 14:30 and from 17:00 clock - 23:00 clockWednesday 11:00 - 14:30 clock and from 17:00 - 23:00 clockThursday 11:00 - 14:30 and from 17:00 clock - 23:00 clockFriday 11:00 - 14:30 and from 17:00 clock - 23:00 clock Saturday 16:00 - 23:00 clockSunday 12:00 - 23:00 clock Thx for help lg Simon Link to comment Share on other sites More sharing options...
sooroos Posted December 14, 2013 Share Posted December 14, 2013 (edited) hi simon. here are the cronjobs for you, i dont know if it can be simplier written... 0 11 * * 1 /usr/bin/wget http://www.myshop.com/OutOfCatalogModeShop.php .php -O /dev/null 30 14 * * 1 /usr/bin/wget http://www.myshop.com/ToCatalogModeShop.php .php -O /dev/null 0 17 * * 1 /usr/bin/wget http://www.myshop.com/OutOfCatalogModeShop.php .php -O /dev/null 0 23 * * 1 /usr/bin/wget http://www.myshop.com/ToCatalogModeShop.php .php -O /dev/null 0 11 * * 2 /usr/bin/wget http://www.myshop.com/OutOfCatalogModeShop.php .php -O /dev/null 30 14 * * 2 /usr/bin/wget http://www.myshop.com/ToCatalogModeShop.php .php -O /dev/null 0 17 * * 2 /usr/bin/wget http://www.myshop.com/OutOfCatalogModeShop.php .php -O /dev/null 0 23 * * 2 /usr/bin/wget http://www.myshop.com/ToCatalogModeShop.php .php -O /dev/null 0 11 * * 3 /usr/bin/wget http://www.myshop.com/OutOfCatalogModeShop.php .php -O /dev/null 30 14 * * 3 /usr/bin/wget http://www.myshop.com/ToCatalogModeShop.php .php -O /dev/null 0 17 * * 3 /usr/bin/wget http://www.myshop.com/OutOfCatalogModeShop.php .php -O /dev/null 0 23 * * 3 /usr/bin/wget http://www.myshop.com/ToCatalogModeShop.php .php -O /dev/null 0 11 * * 4 /usr/bin/wget http://www.myshop.com/OutOfCatalogModeShop.php .php -O /dev/null 30 14 * * 4 /usr/bin/wget http://www.myshop.com/ToCatalogModeShop.php .php -O /dev/null 0 17 * * 4 /usr/bin/wget http://www.myshop.com/OutOfCatalogModeShop.php .php -O /dev/null 0 23 * * 4 /usr/bin/wget http://www.myshop.com/ToCatalogModeShop.php .php -O /dev/null 0 11 * * 5 /usr/bin/wget http://www.myshop.com/OutOfCatalogModeShop.php .php -O /dev/null 30 14 * * 5 /usr/bin/wget http://www.myshop.com/ToCatalogModeShop.php .php -O /dev/null 0 17 * * 5 /usr/bin/wget http://www.myshop.com/OutOfCatalogModeShop.php .php -O /dev/null 0 23 * * 5 /usr/bin/wget http://www.myshop.com/ToCatalogModeShop.php .php -O /dev/null 0 16 * * 6 /usr/bin/wget http://www.myshop.com/OutOfCatalogModeShop.php .php -O /dev/null 0 23 * * 6 /usr/bin/wget http://www.myshop.com/ToCatalogModeShop.php .php -O /dev/null 0 12 * * 0 /usr/bin/wget http://www.myshop.com/OutOfCatalogModeShop.php .php -O /dev/null 0 23 * * 0 /usr/bin/wget http://www.myshop.com/ToCatalogModeShop.php .php -O /dev/null Edited December 14, 2013 by sooroos (see edit history) 1 Link to comment Share on other sites More sharing options...
ssiimmoonn Posted December 15, 2013 Share Posted December 15, 2013 my data are root/config/OutOfCatalogModeShop.php and root/config/ToCatalogModeShop.php is that ok? thx for help lg Simon Link to comment Share on other sites More sharing options...
sooroos Posted December 15, 2013 Share Posted December 15, 2013 you can place those 2 files directly into root but you need to replace "//www.myshop.com" with your shop link and also you need to edit those 2 files with your data $hostname="localhost"; $username="your user name of the database used"; $password="the password of that user"; $dbname="database name"; Link to comment Share on other sites More sharing options...
eleazar Posted December 15, 2013 Share Posted December 15, 2013 As you already said, sooroos, it may in fact be simplier written. The cron tab syntax excepts ranges and comma separated value like e.g. 1-5 (for Monday till Friday) or Monday, Wednesday,Friday as day of the week parameter. Which means, it is possible to reduce the first 20 cron jobs to 4: 0 11 * * 1-5 /usr/bin/wget http://www.myshop.com/OutOfCatalogModeShop.php .php -O /dev/null 30 14 * * 1-5 /usr/bin/wget http://www.myshop.com/ToCatalogModeShop.php .php -O /dev/null 0 17 * * 1-5 /usr/bin/wget http://www.myshop.com/OutOfCatalogModeShop.php .php -O /dev/null 0 23 * * 1-5 /usr/bin/wget http://www.myshop.com/ToCatalogModeShop.php .php -O /dev/null 2 Link to comment Share on other sites More sharing options...
sooroos Posted December 15, 2013 Share Posted December 15, 2013 thx, good to know Link to comment Share on other sites More sharing options...
Lockesoft Posted December 15, 2013 Share Posted December 15, 2013 in Case of ssiimmoonn's Openingtimes the Closingtime are every day at the same time. So you can shorten it to an total of 6 Cronjobs. 0 11 * * 1-5 /usr/bin/wget http://www.MeinShop.de/OutOfCatalogModeShop.php .php -O /dev/null 30 14 * * 1-5 /usr/bin/wget http://www.MeinShop.de/ToCatalogModeShop.php .php -O /dev/null 0 17 * * 1-5 /usr/bin/wget http://www.MeinShop.de/OutOfCatalogModeShop.php .php -O /dev/null 0 12 * * 6 /usr/bin/wget http://www.MeinShop.de/OutOfCatalogModeShop.php .php -O /dev/null 0 16 * * 0 /usr/bin/wget http://www.MeinShop.de/OutOfCatalogModeShop.php .php -O /dev/null 0 23 * * * /usr/bin/wget http://www.MeinShop.de/ToCatalogModeShop.php .php -O /dev/null Link to comment Share on other sites More sharing options...
PascalVG Posted December 16, 2013 Share Posted December 16, 2013 my data are root/config/OutOfCatalogModeShop.php and root/config/ToCatalogModeShop.php is that ok? thx for help lg Simon Best is to put them in config subdir, as here already is another file with the database password in it. If (by accident?) your root dir is 'too openly available', at least the password is (hopefully) not easily available yet in the subdir. best to keep both files concentrated in one folder... My 2 cents, pascal Link to comment Share on other sites More sharing options...
san_ozcar Posted August 27, 2014 Share Posted August 27, 2014 Hello, I know this is marked as solved but im still hoping someone can help me. We are using Presta 1.6 and 2 days ago the shop started to turn maintenance mode on by itself, it will work fine for a few hrs and then suddenly switch to maintenance mode then manually i have to go to the BO to put it back on live mode. We have no idea why its doing this and i was wondering if anyone could give me some direction on how to resolve this? Regards. Link to comment Share on other sites More sharing options...
sooroos Posted August 27, 2014 Share Posted August 27, 2014 (edited) have you set some cronjob? or someone is messing with you Edited August 27, 2014 by sooroos (see edit history) Link to comment Share on other sites More sharing options...
san_ozcar Posted August 27, 2014 Share Posted August 27, 2014 have you set some cronjob? or someone is messing with you No, we have not set any cronjobs or anything. You could be right. We have to delete the maintenance.tpl file from the CSS to stop it..its working so far but dont know what else to do.. Link to comment Share on other sites More sharing options...
kiran.jawa Posted July 3, 2015 Share Posted July 3, 2015 Hi, Want to set store hours timing and display it on homepage BUt I want to set time from admin panel. Link to comment Share on other sites More sharing options...
PascalVG Posted July 5, 2015 Share Posted July 5, 2015 Hi Kiran, Not fully sure if I understand your question well. Do you mean you just want some text on the front page where you mention the opening and closing time? Or do you really want to close your webshop during these times as well?) To really close the shop you can follow the steps outlined above. To just add some opening closing time text on our front page, you can for example add the 'Home text editor' (I believe sometimes called 'Home Editorial' or so). See the user guide on installing modules etc. Hope this helps, pascal. Link to comment Share on other sites More sharing options...
JazZ7 Posted August 16, 2015 Share Posted August 16, 2015 (edited) Hello,It is my first message here... Nice to meet you! \o/ I'm working on a dashboard module to automatically open and close store. This module has already been created but needs a CRON job in order to run automatically. My question is: Do you know any other ways to automatically update PS_CATALOG_MODE base on a timer without CRON? (I'd like that when someone install the module, there is no CRON job to set) If someone is interested with the module: http://cyrilchalamon.fr/produit/everswitch-module-de-mise-en-mode-catalogue-automatique-sur-horaires/ What dashEverswitch does for now: - turn on/off the catalog mode from the dashboard with a switch radio, - show the opening hours on the dashboard - configure the opening hours from the dashboard - show the opening hours of the store on product's pages when PS_CATALOG_MODE = 1 - If CRON job is set there will be automatic opening and closing of store Targets: - enable the setting of more than one opening and closing hour - Automatic opening and closing store without CRON Kindly please help. Thank you. Edited August 16, 2015 by JazZ7 (see edit history) Link to comment Share on other sites More sharing options...
bellini13 Posted August 17, 2015 Share Posted August 17, 2015 Do you know any other ways to automatically update PS_CATALOG_MODE base on a timer without CRON? (I'd like that when someone install the module, there is no CRON job to set) Find a hook that is executed every time a person visits the front office, but before page rendering is started. Have your module register this hook, and then you can check the configured time and enable/disable catalog mode as required Link to comment Share on other sites More sharing options...
JazZ7 Posted August 17, 2015 Share Posted August 17, 2015 Find a hook that is executed every time a person visits the front office, but before page rendering is started. Thanks for your answer bellini13. Sorry, but i don't know where to find this hook. I had look in prestashop docs and hook's list but didn't find anything sounds like that. Do you know where I cant find or where I have to look for this hook? Thank you. Link to comment Share on other sites More sharing options...
bellini13 Posted August 17, 2015 Share Posted August 17, 2015 I would probably start with the Controller or FrontController class and see what hooks are fired. I doubt you are going to find any documentation on this, you will just need to dig into the code Link to comment Share on other sites More sharing options...
JazZ7 Posted August 18, 2015 Share Posted August 18, 2015 (edited) Thanks again Bellini13 but I didn't find. The solution I used is the Pascal reply: MySQL EVENT Here is the code: if (isset($_GET['aut'])) { $aut = (bool)$_GET['aut']; Configuration::updateValue('AUTO_MODE', $aut); // Db::getInstance()->execute('SET GLOBAL event_scheduler = ON'); Db::getInstance()->execute('DROP EVENT IF EXISTS auto_open'); Db::getInstance()->execute('DROP EVENT IF EXISTS auto_close'); $open_hour = date(Configuration::get('DASHEVERSWITCH_OPEN_HOURS')); $close_hour = date(Configuration::get('DASHEVERSWITCH_CLOSE_HOURS')); if ($aut) { Db::getInstance()->execute( 'CREATE EVENT IF NOT EXISTS auto_open ON SCHEDULE EVERY 1 DAY STARTS "'.date('Y-m-d').' '.$open_hour.'" ENABLE DO UPDATE `'._DB_PREFIX_.'configuration` SET `value` = 0 WHERE `name` = "PS_CATALOG_MODE"' ); Db::getInstance()->execute( 'CREATE EVENT IF NOT EXISTS auto_close ON SCHEDULE EVERY 1 DAY STARTS "'.date('Y-m-d').' '.$close_hour.'" ENABLE DO UPDATE `'._DB_PREFIX_.'configuration` SET `value` = 1 WHERE `name` = "PS_CATALOG_MODE"' ); } echo '<div class="alert alert-success"> <p>Automatic Opening Mode Updated !</p> </div>'; } Hope this help! EDIT: This would be the perfect solution if MySQL event_scheduler does not need SUPER PRIVILEGES to be enable... So, the script works fine in localhost but online, impossible to turn the event_scheduler on for security... Back to the start point... EDIT 2: I think i found the hook: /** * Called before compiling common page sections (header, footer, columns). * Good place to modify smarty variables. * * @see FrontController::initContent() */ public function process() { } Edited August 18, 2015 by JazZ7 (see edit history) Link to comment Share on other sites More sharing options...
[email protected] Posted August 28, 2015 Share Posted August 28, 2015 Hi, I am looking for solution to call a pop-up on site pages with notice "We are closed now. But you can make pre-order" when the shop is closed. I also have food delivery site and I think it is better way to communicate with customer. Regards Link to comment Share on other sites More sharing options...
skullxcrusher Posted January 6, 2016 Share Posted January 6, 2016 Hi, I am looking for solution to call a pop-up on site pages with notice "We are closed now. But you can make pre-order" when the shop is closed. I also have food delivery site and I think it is better way to communicate with customer. Regards anyone has made module similiar to this? Link to comment Share on other sites More sharing options...
wackyracer8 Posted April 19, 2016 Share Posted April 19, 2016 I'm trying to get this working but I'm struggling. I have created the CloseShop.php file with the database credentials and set up a cron job to run but it doesn't work. The cron job command I am using is /usr/bin/php /home/useraccount/public_html/config/CloseShop.php the email just returns X-Powered-By: PHP/5.6.18Content-type: text/html; charset=UTF-8 Is the email supposed to return this from the cron job? What am I doing wrong? Link to comment Share on other sites More sharing options...
JazZ7 Posted April 19, 2016 Share Posted April 19, 2016 Hello wackyracer8 Please see that link at last comment for the solution : http://stackoverflow.com/questions/36362937/prestashop-set-catalog-mode-on-off-if-user-unlogged-logged You will just have to set a new condition based on the open/close time of your shop. <?php // placed in /override/classes/Configuration.php class Configuration extends ConfigurationCore { public static function get($key, $id_lang = null, $id_shop_group = null, $id_shop = null) { if (defined('_PS_DO_NOT_LOAD_CONFIGURATION_') && _PS_DO_NOT_LOAD_CONFIGURATION_) { return false; } // If conf if not initialized, try manual query if (!isset(self::$_cache[self::$definition['table']])) { Configuration::loadConfiguration(); if (!self::$_cache[self::$definition['table']]) { return Db::getInstance()->getValue('SELECT `value` FROM `'._DB_PREFIX_.bqSQL(self::$definition['table']).'` WHERE `name` = "'.pSQL($key).'"'); } } $id_lang = (int)$id_lang; if ($id_shop === null || !Shop::isFeatureActive()) { $id_shop = Shop::getContextShopID(true); } if ($id_shop_group === null || !Shop::isFeatureActive()) { $id_shop_group = Shop::getContextShopGroupID(true); } if (!isset(self::$_cache[self::$definition['table']][$id_lang])) { $id_lang = 0; } if ($id_shop && Configuration::hasKey($key, $id_lang, null, $id_shop)) { if($key == 'PS_CATALOG_MODE') // Add your time condition { return !Context::getContext()->customer->isLogged() || self::$_cache[self::$definition['table']][$id_lang]['shop'][$id_shop][$key]; } else { return self::$_cache[self::$definition['table']][$id_lang]['shop'][$id_shop][$key]; } } elseif ($id_shop_group && Configuration::hasKey($key, $id_lang, $id_shop_group)) { if($key == 'PS_CATALOG_MODE') // Add your time condition { return !Context::getContext()->customer->isLogged() || self::$_cache[self::$definition['table']][$id_lang]['group'][$id_shop_group][$key]; } else { return self::$_cache[self::$definition['table']][$id_lang]['group'][$id_shop_group][$key]; } } elseif (Configuration::hasKey($key, $id_lang)) { if($key == 'PS_CATALOG_MODE') // Add your time condition { return !Context::getContext()->customer->isLogged() || self::$_cache[self::$definition['table']][$id_lang]['global'][$key]; } else { return self::$_cache[self::$definition['table']][$id_lang]['global'][$key]; } } return false; } } Hope it helps 1 Link to comment Share on other sites More sharing options...
EvrenE Posted May 3, 2016 Share Posted May 3, 2016 Ok, two cron jobs and scripts: Create a file 'CloseShop.php' in /<root of shop>/config/ folder. Edit file and copy this in there: <?php // cron job php script to set shop into maintenance mode // by Pascal van Geest @ ModulesModules.com // Setup connection variables, such as database username // and password // host name, database user, password and database name // can be found in: // config/settings.inc.php $hostname="localhost"; $username="your user name of the database used"; $password="the password of that user"; $dbname="database name"; //Connect to the database $connection = mysql_connect($hostname, $username, $password); mysql_select_db($dbname, $connection); //Setup our query $query = "UPDATE `ps_configuration` SET `value` = 0 where `name` = 'PS_SHOP_ENABLE';"; //Run the Query $result = mysql_query($query); ?> Add info of hostname, database, user, password (see config/settings.inc.php for details)and save the file. Then go to your cPanel and go to Cron Jobs application. Add a new cron job: Select MINUTE = 0 (to close straight on the hour) HOUR = 19 (example, to close at 7 PM) select DAY = * (if you want to close the shop every day) select MONTH = * select WEEKDAY = * ( if you work all days) add command: /usr/bin/php full/path/to/your/new/file/CloseShop.php and save. Same to OPEN the shop again: Create new file OpenShop.php in the /<root of shop>/config/ folder. edit and copy this: <?php // cron job php script to get shop out of maintenance mode // by Pascal van Geest @ ModulesModules.com // Setup connection variables, such as database username // and password // host name, database user, password and database name // can be found in: // config/settings.inc.php $hostname="localhost"; $username="your user name of the database used"; $password="the password of that user"; $dbname="database name"; //Connect to the database $connection = mysql_connect($hostname, $username, $password); mysql_select_db($dbname, $connection); //Setup our query $query = "UPDATE `ps_configuration` SET `value` = 1 where `name` = 'PS_SHOP_ENABLE';"; //Run the Query $result = mysql_query($query); ?> Add info of hostname, database, user, password (see config//settings.inc.php for details)and save file make another cron job, to open the shop again: Select MINUTE = 30 (example, to close at half past...) HOUR = 8 (example, to open at 8:30 am) select DAY = * (if you want to close the shop every day) select MONTH = * select WEEKDAY = * ( if you work all days) add command: /usr/bin/php full/path/to/your/new/file/OpenShop.php and save. To see if it works, change the MINUTE AND HOUR temporarily to * (One job only, first cronjob of CloseShop.php. if that does the job (Check by waiting 1 minute and then reload the front of your shop) , change this job back to real closing time and then change the OpenShop cron job to *. If it reopens again (check again by waiting 1 minute then go to the shop page), change to the real opening times again. Hope this helps, pascal N.B. Be careful with the script files, as the password is unencrypted in there. (This is also the case for config/settings.inc.php) so set the permissions correctly Hello, Is this independent solution from this post : https://www.prestashop.com/forums/topic/248621-solvedopen-and-close-store-at-set-times-each-day/?do=findComment&comment=1351568 or should I apply both of them together? Thanks for your helps. Link to comment Share on other sites More sharing options...
EvrenE Posted June 6, 2016 Share Posted June 6, 2016 @PascalVG Hello, I couldn't understand that, "If you're allowed to create EVENTS on your database, that might work as well." and cron jobs... Are they work together or are these solutions independent of each other? Also, may I handle this cron job via prestashop cron module? Thanks. Link to comment Share on other sites More sharing options...
NixxxoN Posted May 2, 2017 Share Posted May 2, 2017 (edited) If you do want to use cronjobs, here they are: Furthermore just do the same as above. My 2 cents, pascal Hi there! I know this is an old thread but... Would this work on Prestashop 1.6.1.4 and 1.6.1.5??? Its just what I need, to enable/disable shop using catalog mode on/off at specific hours of the day. Please reply... Edited May 2, 2017 by NixxxoN (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now