Jump to content

[SOLVED]Open and close store at set times each day


Recommended Posts

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

  • 2 months later...

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

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

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 by PascalVG
update command edited... (see edit history)
  • Like 1
Link to comment
Share on other sites

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

  • Like 1
Link to comment
Share on other sites

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

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 by sooroos (see edit history)
Link to comment
Share on other sites

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

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

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.

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

Attached Files

Cronjob help plz

 

those are my opening times

 

Monday 11:00 - 14:30 and from 17:00 clock - 23:00 clock
Tuesday 11:00 - 14:30 and from 17:00 clock - 23:00 clock
Wednesday 11:00 - 14:30 clock and from 17:00 - 23:00 clock
Thursday 11:00 - 14:30 and from 17:00 clock - 23:00 clock
Friday 11:00 - 14:30 and from 17:00 clock - 23:00 clock

Saturday 16:00 - 23:00 clock
Sunday 12:00 - 23:00 clock

 

Thx for help

 

lg Simon

Link to comment
Share on other sites

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 by sooroos (see edit history)
  • Like 1
Link to comment
Share on other sites

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

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

  • Like 2
Link to comment
Share on other sites

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

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

  • 8 months later...

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

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

  • 10 months later...

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

  • 1 month later...

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 by JazZ7 (see edit history)
Link to comment
Share on other sites

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

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

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 by JazZ7 (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...

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

  • 3 months later...

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.18
Content-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

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

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

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

  • 1 month later...

@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

  • 10 months later...

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 by NixxxoN (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...