Does anyone know of an extension the turns a product availability off at a certain time of day, and then back on at another.
Not having much luck finding one.
You will probably need a script to be run by cron job on the time(s) that you wish enable or disable products.
The script is quite simple. Something like: status.php in your store root
Then you can run the script via cron, e.g. yourdomain.com/status.php?status=1 to enable or replace 1 with 0 to disable
Don’t forget to add as many $products[] as you wish with the appropriate product_id's
The script is quite simple. Something like: status.php in your store root
Code: Select all
<?php
if(isset($_GET['status']) && ($_GET['status'] === 1 || $_GET['status'] === 0)){
$status = (int)$_GET['status'];
set_time_limit(0);
require_once('config.php');
require_once(DIR_SYSTEM . 'startup.php');
// Registry
$registry = new Registry();
// Loader
$loader = new Loader($registry);
$registry->set('load', $loader);
// Config
$config = new Config();
$registry->set('config', $config);
// Database
$db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
$registry->set('db', $db);
// Create products array
$products = array();
// example -> $products[] = 1;
foreach ($products as $product){
$query = $db->query("UPDATE `" . DB_PREFIX . "product` SET `status` = $status WHERE `product_id` = '$product'");
}
}
Don’t forget to add as many $products[] as you wish with the appropriate product_id's
Required to be validated twice? Another way, however, would be by creating an event file since OC already allows it on more recent releases.if(isset($_GET['status']) && ($_GET['status'] === 1 || $_GET['status'] === 1)){
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
An event file won't help much as this is the 1.5x forum.
All products or just specific products?
Prevent adding to cart only or hide the product?
Can I ask why.....? Knowing why can help with an answer.
All products or just specific products?
Prevent adding to cart only or hide the product?
Can I ask why.....? Knowing why can help with an answer.
-
VIEW ALL EXTENSIONS * EXTENSION SUPPORT * WEBSITE * CUSTOM REQUESTS
Yes, which is why I mentioned 'on more recent releases' from my previous reply.An event file won't help much as this is the 1.5x forum.
Dedication and passion goes to those who are able to push and merge a project.
Regards,
Straightlight
Programmer / Opencart Tester
You could do this with Restrict Checkout. You'd set up 2 restrictions like this, to disable the checkout when Product A was being purchased before 8:00 am or after 5:00 pm:
------------------------------------------------------------------------------
RESTRICTION #1
Name: Disable checkout when Product A is purchased during closed hours
Message: This product must be purchased between 8:00 am and 5:00 pm
Rule: Product is Product A
Rule: Time is before 08:00
RESTRICTION #2
Name: Disable checkout when Product A is purchased during closed hours
Message: This product must be purchased between 8:00 am and 5:00 pm
Rule: Product is Product A
Rule: Time is after 17:00
------------------------------------------------------------------------------
Feel free to take a look at the screenshots and demo site, and if you're interested let me know at www.getclearthinking.com/contact if you have any further questions.
------------------------------------------------------------------------------
RESTRICTION #1
Name: Disable checkout when Product A is purchased during closed hours
Message: This product must be purchased between 8:00 am and 5:00 pm
Rule: Product is Product A
Rule: Time is before 08:00
RESTRICTION #2
Name: Disable checkout when Product A is purchased during closed hours
Message: This product must be purchased between 8:00 am and 5:00 pm
Rule: Product is Product A
Rule: Time is after 17:00
------------------------------------------------------------------------------
Feel free to take a look at the screenshots and demo site, and if you're interested let me know at www.getclearthinking.com/contact if you have any further questions.
Who is online
Users browsing this forum: No registered users and 149 guests