well, to anyone that might find this usefull
I've override the file init_special_func and added this to the IF :
if (!isset($_SESSION['updateExpirations']) || $_SESSION['updateExpirations'] !== true) {
PHP Code:
require(DIR_WS_FUNCTIONS . 'upcoming_expire.php');
zen_expire_upcoming();
Then created a new function file upcoming_expire.php with
PHP Code:
function zen_update_upcoming_status($upcoming_id) {
global $db;
$sql = "update " . TABLE_PRODUCTS . "
set products_quantity = '100'
where products_id = '" . (int)$upcoming_id . "'";
return $db->Execute($sql);
}
function zen_expire_upcoming() {
global $db;
$today = $_SESSION['today_is'];
$upcoming_query = "select p.products_id
from " . TABLE_PRODUCTS . " p
LEFT JOIN ".TABLE_PRODUCT_BOOKX_EXTRA." be on p.products_id = be.products_id
where p.products_status = '1' AND p.products_quantity = '0'
and ((" . $today . " <= be.publishing_date and be.publishing_date != '0000-00-00 00:00:00')
or (" . $today. " <= p.products_date_available and p.products_date_available != null))";
$upcoming = $db->Execute($upcoming_query);
if ($upcoming->RecordCount() > 0) {
while (!$upcoming->EOF) {
zen_update_upcoming_status($upcoming->fields['products_id']);
$upcoming->MoveNext();
}
}
}
In this case I'm using a bookx module. For a normal product, I guess this is enough
PHP Code:
function zen_expire_upcoming() {
global $db;
$today = $_SESSION['today_is'];
$upcoming_query = "select p.products_id
from " . TABLE_PRODUCTS . " p
where p.products_status = '1' AND p.products_quantity = '0'
and (" . $today. " <= p.products_date_available and p.products_date_available != null))";
$upcoming = $db->Execute($upcoming_query);
if ($upcoming->RecordCount() > 0) {
while (!$upcoming->EOF) {
zen_update_upcoming_status($upcoming->fields['products_id']);
$upcoming->MoveNext();
}
}
}
And I'm also hardcoding the 100 for a stock.