Ehsanai Posted June 25, 2021 Share Posted June 25, 2021 Hi, How to I can disable a module on specific day? actually the module is payment option Link to comment Share on other sites More sharing options...
Rhobur Posted June 25, 2021 Share Posted June 25, 2021 Install this https://github.com/nenes25/prestashop_console and do a cron job with the command to disable a module. 1 Link to comment Share on other sites More sharing options...
Ehsanai Posted June 25, 2021 Author Share Posted June 25, 2021 thank you, but I'm on shared web host and I've no access to do this. Link to comment Share on other sites More sharing options...
Rhobur Posted June 25, 2021 Share Posted June 25, 2021 Then unless you find a module that does this uninstalling thing which I doubt you will there is no other way other than doing it yourself manually. Link to comment Share on other sites More sharing options...
Crezzur.com Posted July 8, 2021 Share Posted July 8, 2021 (edited) You can achieve this by simple running a deactivate and activate SQL query. You can run this query automatic using a cronjob. Just use the cron service of your Server, if you do not have access to this feature you can write a small PHP script and use a service like https://cron-job.org/ to run your query every X time. Deactivate module // change id_module to the module id UPDATE ps_module SET active = 0 WHERE id_module = 12; Activate module // change id_module to the module id UPDATE ps_module SET active = 1 WHERE id_module = 12; For example a simple PHP script can be like: <?php // Check if _PS_ADMIN_DIR_ is defined, if not define. if (!defined('_PS_ADMIN_DIR_')) { define('_PS_ADMIN_DIR_', getcwd()); } // Setup connection with config.inc.php (required for database connection, ...) include(_PS_ADMIN_DIR_.'/../config/config.inc.php'); // Add a simple file protection method to prevent unwanted access. $crezzur_key = 'ed3fa1ce558e1c2528cfbaa3f99403'; // Check if correct crezzur_key is used when accessing page. // If the crezzur_key is not set our not equal the crezzur_key the page will stop running. // URL example: www.yourstore.com/yourbackoffice/yourpagename.php?crezzur_key=ed3fa1ce558e1c2528cfbaa3f99403 if(!Tools::getValue('crezzur_key') || Tools::getValue('crezzur_key') != $secure_key) { die('UNAUTHORIZED: We dont want you on this page!'); } $current_date = date('N'); // Display the current day in number format (0, 1, ..., 6) $module_id = 12; // Module id to disable/enable? $disable_days = array(5, 6); // 0 = Monday, 1 = Tuesday, 2 = Wednesday, 3 = Thursday, 4 = Friday, 5 = Saturday, 6 = Sunday if (in_array($current_date, $disable_days)) { echo 'INFO: Current day is '. $current_date .', module will be <b>disabled</b>'; Db::getInstance()->execute('UPDATE `'. _DB_PREFIX_ .'module` SET active = 0 WHERE id_module = '. (int)$moduleid); } else { echo 'INFO: Current day is '. $current_date .', module will be <b>enabled</b>'; Db::getInstance()->execute('UPDATE `'. _DB_PREFIX_ .'module` SET active = 1 WHERE id_module = '. (int)$moduleid); } Edited July 8, 2021 by Crezzur (see edit history) 1 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