Forums / Customization from the Admin / Time setting for ENABLE_DISABLED_UPCOMING_PRODUCT

Time setting for ENABLE_DISABLED_UPCOMING_PRODUCT

Views: 3,048

Results 1 to 8 of 8
16 Feb 2023, 1:05 AM
#1
wcbutler avatar

wcbutler

New Zenner

Join Date:
Sep 2017
Location:
Raleigh, NC, United States
Posts:
81
Plugin Contributions:
0

Time setting for ENABLE_DISABLED_UPCOMING_PRODUCT

I've been manually doing preorders and came across the ENABLE_DISABLED_UPCOMING_PRODUCT setting in Configuration - Stock. That probably makes an item go online at midnight. Is there a way to use this to go online at noon my timezone? That would be super handy because preorders sometimes slow down my store and setting enabled manually is a pain.

16 Feb 2023, 3:01 PM
#2
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,973
Plugin Contributions:
8

Re: Time setting for ENABLE_DISABLED_UPCOMING_PRODUCT

wcbutler:

I've been manually doing preorders and came across the ENABLE_DISABLED_UPCOMING_PRODUCT setting in Configuration - Stock. That probably makes an item go online at midnight. Is there a way to use this to go online at noon my timezone? That would be super handy because preorders sometimes slow down my store and setting enabled manually is a pain.

there is no way to do it without modifying the zc core code.

it looks like one could set up a cron job to handle it, ignoring that setting.

if you do not know how to set up a cron job to do this task, perhaps someone else can help; else you could hire one of the developers on this board to set it up for you.

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

16 Feb 2023, 6:07 PM
#3
wcbutler avatar

wcbutler

New Zenner

Join Date:
Sep 2017
Location:
Raleigh, NC, United States
Posts:
81
Plugin Contributions:
0

Re: Time setting for ENABLE_DISABLED_UPCOMING_PRODUCT

carlwhat:

there is no way to do it without modifying the zc core code.

it looks like one could set up a cron job to handle it, ignoring that setting.

if you do not know how to set up a cron job to do this task, perhaps someone else can help; else you could hire one of the developers on this board to set it up for you.

best.

I'm a sys admin by day so I'm familiar with cron jobs in general, I'll research how to set this up and see if that will help, I appreciate you pointing me in the right direction.

16 Feb 2023, 6:36 PM
#4
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: Time setting for ENABLE_DISABLED_UPCOMING_PRODUCT

There is no timer associated with ENABLE_DISABLED_UPCOMING_PRODUCT. It fires once per session in includes/init_includes/init_special_funcs.php. Anytime someone starts using your cart, this logic fires, and as long as it's after 00:00 on the day the product is scheduled to go enabled, it goes enabled.

The date check is done in includes/functions/functions_products.php and you could add a time check if you wanted to. Are you sure it's worth the added complexity? Guess it depends on your business.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

16 Feb 2023, 7:51 PM
#5
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,973
Plugin Contributions:
8

Re: Time setting for ENABLE_DISABLED_UPCOMING_PRODUCT

swguy:

There is no timer associated with ENABLE_DISABLED_UPCOMING_PRODUCT. It fires once per session in includes/init_includes/init_special_funcs.php. Anytime someone starts using your cart, this logic fires, and as long as it's after 00:00 on the day the product is scheduled to go enabled, it goes enabled.

The date check is done in includes/functions/functions_products.php and you could add a time check if you wanted to. Are you sure it's worth the added complexity? Guess it depends on your business.

really?

the whole point of a cronjob is to be able to run it at the specific time one wants.

this thing is not that complex.

here you go, free code:

turn ENABLE_DISABLED_UPCOMING_PRODUCT to manual.

create a file in your store root called something like cronUpcomingProducts.php

add a cron job at your specified time. something like:

/usr/local/bin/php /var/www/myStoreRoot/cronUpcomingProducts.php > /home/myUser/UpcomingProducts.log

(you can figure out the times and days).

use the following code in your new file:

#!/usr/bin/php
<?php

    $is_browser = (isset($_SERVER['HTTP_HOST']) || PHP_SAPI !== 'cli');
    if ($is_browser && isset($_SERVER["REMOTE_ADDR"]) && $_SERVER["REMOTE_ADDR"] !== $_SERVER["SERVER_ADDR"]) {
        echo ' ERROR: Permission denied.';
        exit(1);
    };

    $baseDir = dirname(__FILE__);

    $_SERVER['REQUEST_URI'] = 'cronUpcomingProducts';
    $_SERVER['REMOTE_ADDR'] = 'localhost';
    $_SERVER['HTTP_HOST'] = 'localhost';

    chdir($baseDir);

    require $baseDir . '/includes/application_top.php';

    zen_enable_disabled_upcoming();

done.

hope that helps. not too complex. no changing of zc core code.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

16 Feb 2023, 10:02 PM
#6
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: Time setting for ENABLE_DISABLED_UPCOMING_PRODUCT

You still have to edit includes/init_includes/init_special_funcs.php to remove the call to zen_enable_disabled_upcoming() or any visitor who happens along before noon will enable the disabled products which are set to the current day.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.

16 Feb 2023, 10:57 PM
#7
carlwhat avatar

carlwhat

zennedOut

Join Date:
Nov 2005
Location:
los angeles
Posts:
2,973
Plugin Contributions:
8

Re: Time setting for ENABLE_DISABLED_UPCOMING_PRODUCT

swguy:

You still have to edit includes/init_includes/init_special_funcs.php to remove the call to zen_enable_disabled_upcoming() or any visitor who happens along before noon will enable the disabled products which are set to the current day.

i do not believe that is correct. the call of that function is controlled by a config value. as previously stated above:

carlwhat:

turn ENABLE_DISABLED_UPCOMING_PRODUCT to manual.

from: includes/init_includes/init_special_funcs.php

    if (defined('ENABLE_DISABLED_UPCOMING_PRODUCT') && ENABLE_DISABLED_UPCOMING_PRODUCT == 'Automatic') {
        zen_enable_disabled_upcoming();
    }

best.

author of square Webpay, now with Apple Pay and Google Pay.
mXworks
donations: venmo or paypal accepted.
premium consistent excellent support. available for hire.

17 Feb 2023, 12:59 AM
#8
swguy avatar

swguy

Administrator

Join Date:
Feb 2006
Location:
Tampa Bay, Florida
Posts:
10,729
Plugin Contributions:
56

Re: Time setting for ENABLE_DISABLED_UPCOMING_PRODUCT

I see your point - I had overlooked this:

turn ENABLE_DISABLED_UPCOMING_PRODUCT to manual.

That Software Guy. My Store: Zen Cart Support
Available for hire - See my ad in Services
Plugin Moderator, Documentation Curator, Chief Cook and Bottle-Washer.
Do you benefit from Zen Cart? Then please support the project.