Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 36
  1. #11
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Scheduling a new release in the store

    Now i will need think what I am going to do with my free time, since you already coded this for me
    Quote Originally Posted by mc12345678 View Post
    New file:
    includes/init_includes/init_special_funcs_disabled_upcoming.php

    Code:
    <?php
    /**
     * @copyright 2018
     * @license http://www.zen-cart.com/License/2_0.txt GNU Public License V2.0
     * @author mc12345678
     **/
    
      if (!isset($_SESSION['today_is'])) {
        $_SESSION['today_is'] = date('Y-m-d');
      }
      if ($_SESSION['today_is'] != date('Y-m-d')) {
        $_SESSION['today_is'] = date('Y-m-d');
        $_SESSION['updateExpirations_upcoming'] = false;
      }
    
    
    if (!isset($_SESSION['updateExpirations_upcoming']) || $_SESSION['updateExpirations_upcoming'] !== true) {
      /**
       * require the disabled upcoming products functions, auto-enable disabled product.
       */
      require DIR_WS_FUNCTIONS . 'disabled_upcoming.php';
      zen_enable_disabled_upcoming();
    
    }
    new file:
    includes/functions/disabled_upcoming.php
    Code:
    <?php
    /**
     * disabled-upcoming products functions
     *
     * @copyright 2018
     * @license http://www.zen-cart.com/License/2_0.txt GNU Public License V2.0
     * @author mc12345678
     **/
    
      function zen_set_disabled_upcoming_status($products_id, $status) {
          $sql = "UPDATE " . TABLE_PRODUCTS . "
                SET products_status = " . (int)$status . ", products_date_available = '0001-01-01' WHERE products_id = " . (int)$products_id;
    
      return $GLOBALS['db']->Execute($sql);
      }
    
      function zen_enable_disabled_upcoming() {
    
      $date_range = time();
    
      $zc_disabled_upcoming_date = date('Ymd', $date_range);
    
      $disabled_upcoming_query = "SELECT products_id
                                               FROM " . TABLE_PRODUCTS . "
                                               WHERE products_status = 0
                                               AND ((products_date_available <= " . $zc_disabled_upcoming_date . "
                                               AND products_date_available != '0001-01-01'))
                                              ";
    
      $disabled_upcoming = $GLOBALS['db']->Execute($disabled_upcoming_query);
    
      if ($disabled_upcoming->RecordCount() > 0) {
        while (!disabled_upcoming->EOF) {
          zen_set_disabled_upcoming_status($disabled_upcoming->fields['products_id'], 1);
          $disabled_upcoming->MoveNext();
        }
      }
     }
    Then to initiate the above code (saved for last to tie it together), add the following new file:
    includes/auto_loaders/config.enable_disabled_upcoming.php

    Code:
    <?php
    /**
     * disabled-upcoming products auto_loader to execute the operations.
     *
     * @copyright 2018
     * @license http://www.zen-cart.com/License/2_0.txt GNU Public License V2.0
     * @author mc12345678
     **/
    /**
     *Load just before the other special functions that may include this product.
     */
    
    $autoLoadConfig[149][] = array(
                                          'autoType'=>'init_script',
                                          'loadFile'=>'init_special_funcs_disabled_upcoming.php',
                                         );
    Note, there is no "do this for this product, but not that product" type switch incorporated. Ie. any product that has a products_date_available that has passed will be so enabled and the products_date_available will be set/reset to 0001-01-01 as if it never had such a future date...

  2. #12
    Join Date
    Feb 2009
    Posts
    861
    Plugin Contributions
    0

    Default Re: Scheduling a new release in the store

    Quote Originally Posted by Design75 View Post
    Now i will need think what I am going to do with my free time, since you already coded this for me
    I sure have other ideas if you really need some! And they would not be tiny tasks either!

  3. #13
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Scheduling a new release in the store

    Quote Originally Posted by Design75 View Post
    Now i will need think what I am going to do with my free time, since you already coded this for me
    Well, I (thought I) had everything written except the end of the enable product sql statement and the config file last night. Figured I should just finish it off and await any feedback on it. :) Sorry, to have bit into your "keep busy free time". :) Fortunately, between computer uses and forum browsing I didn't lose the auto-saved content.

    I am wondering though about the use of the date session... Now that I think about it, it probably should be a little different in this added code than what is used in the special functions or at least not get in the way of it....

    Please consider the below revised includes/init_includes/init_special_funcs_disabled_upcoming.php file:

    Code:
    <?php
    /**
     * @copyright 2018
     * @license http://www.zen-cart.com/License/2_0.txt GNU Public License V2.0
     * @author mc12345678
     **/
    
    /* Do not want to affect the way that other code that follows uses $_SESSION['today_is']
      if (!isset($_SESSION['today_is'])) {
        $_SESSION['today_is'] = date('Y-m-d');
      }
      if ($_SESSION['today_is'] != date('Y-m-d')) {
        $_SESSION['today_is'] = date('Y-m-d');
        $_SESSION['updateExpirations_upcoming'] = false;
      }
    */
    
    
    if (!isset($_SESSION['today_is']) || $_SESSION['today_is'] != date('Y-m-d') || !isset($_SESSION['updateExpirations_upcoming']) || $_SESSION['updateExpirations_upcoming'] !== true) {
      /**
       * require the disabled upcoming products functions, auto-enable disabled product.
       */
      require DIR_WS_FUNCTIONS . 'disabled_upcoming.php';
      zen_enable_disabled_upcoming();
    
      // Need to set the session variable so that will not execute on every load.
      $_SESSION['updateExpirations_upcoming'] = true;
    }

    Quote Originally Posted by mc12345678 View Post
    New file:
    includes/init_includes/init_special_funcs_disabled_upcoming.php

    Code:
    <?php
    /**
     * @copyright 2018
     * @license http://www.zen-cart.com/License/2_0.txt GNU Public License V2.0
     * @author mc12345678
     **/
    
      if (!isset($_SESSION['today_is'])) {
        $_SESSION['today_is'] = date('Y-m-d');
      }
      if ($_SESSION['today_is'] != date('Y-m-d')) {
        $_SESSION['today_is'] = date('Y-m-d');
        $_SESSION['updateExpirations_upcoming'] = false;
      }
    
    
    if (!isset($_SESSION['updateExpirations_upcoming']) || $_SESSION['updateExpirations_upcoming'] !== true) {
      /**
       * require the disabled upcoming products functions, auto-enable disabled product.
       */
      require DIR_WS_FUNCTIONS . 'disabled_upcoming.php';
      zen_enable_disabled_upcoming();
    
    }
    new file:
    includes/functions/disabled_upcoming.php
    Code:
    <?php
    /**
     * disabled-upcoming products functions
     *
     * @copyright 2018
     * @license http://www.zen-cart.com/License/2_0.txt GNU Public License V2.0
     * @author mc12345678
     **/
    
      function zen_set_disabled_upcoming_status($products_id, $status) {
          $sql = "UPDATE " . TABLE_PRODUCTS . "
                SET products_status = " . (int)$status . ", products_date_available = '0001-01-01' WHERE products_id = " . (int)$products_id;
    
      return $GLOBALS['db']->Execute($sql);
      }
    
      function zen_enable_disabled_upcoming() {
    
      $date_range = time();
    
      $zc_disabled_upcoming_date = date('Ymd', $date_range);
    
      $disabled_upcoming_query = "SELECT products_id
                                               FROM " . TABLE_PRODUCTS . "
                                               WHERE products_status = 0
                                               AND ((products_date_available <= " . $zc_disabled_upcoming_date . "
                                               AND products_date_available != '0001-01-01'))
                                              ";
    
      $disabled_upcoming = $GLOBALS['db']->Execute($disabled_upcoming_query);
    
      if ($disabled_upcoming->RecordCount() > 0) {
        while (!disabled_upcoming->EOF) {
          zen_set_disabled_upcoming_status($disabled_upcoming->fields['products_id'], 1);
          $disabled_upcoming->MoveNext();
        }
      }
     }
    Then to initiate the above code (saved for last to tie it together), add the following new file:
    includes/auto_loaders/config.enable_disabled_upcoming.php

    Code:
    <?php
    /**
     * disabled-upcoming products auto_loader to execute the operations.
     *
     * @copyright 2018
     * @license http://www.zen-cart.com/License/2_0.txt GNU Public License V2.0
     * @author mc12345678
     **/
    /**
     *Load just before the other special functions that may include this product.
     */
    
    $autoLoadConfig[149][] = array(
                                          'autoType'=>'init_script',
                                          'loadFile'=>'init_special_funcs_disabled_upcoming.php',
                                         );
    Note, there is no "do this for this product, but not that product" type switch incorporated. Ie. any product that has a products_date_available that has passed will be so enabled and the products_date_available will be set/reset to 0001-01-01 as if it never had such a future date...
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  4. #14
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Scheduling a new release in the store

    You're always welcome to contact me, and we can discuss the possibilities.
    Quote Originally Posted by CaroleAs View Post
    I sure have other ideas if you really need some! And they would not be tiny tasks either!

  5. #15
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Scheduling a new release in the store

    Quote Originally Posted by CaroleAs View Post
    That would be great!

    I have a new product released every Friday night. My clients know, and sometimes, stalk the store, waiting for the release! Occasionally, I am ahead of the game and would love to schedule the release ahead (like Wednesday or Thursday), and not have to be at the computer on Friday night to release it, or schedule several weeks ahead. We can schedule emails, newsletters, Facebook posts. It is just time for our store to follow suit!
    How did last night's "automatic" release go?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  6. #16
    Join Date
    Feb 2009
    Posts
    861
    Plugin Contributions
    0

    Default Re: Scheduling a new release in the store

    Quote Originally Posted by mc12345678 View Post
    How did last night's "automatic" release go?
    I was not able to apply the code yesterday as something unexpected came up. I was lucky to be back at the computer in the evening to release the product manually, as usual. :)

  7. #17
    Join Date
    Jul 2012
    Posts
    16,733
    Plugin Contributions
    17

    Default Re: Scheduling a new release in the store

    Quote Originally Posted by CaroleAs View Post
    I was not able to apply the code yesterday as something unexpected came up. I was lucky to be back at the computer in the evening to release the product manually, as usual. :)
    I've noticed that you've mentioned "evening", note that the code provided makes the change at "midnight" by server time. Were you looking for it to happen at some other time?
    ZC Installation/Maintenance Support <- Site
    Contribution for contributions welcome...

  8. #18
    Join Date
    Feb 2009
    Posts
    861
    Plugin Contributions
    0

    Default Re: Scheduling a new release in the store

    Quote Originally Posted by mc12345678 View Post
    I've noticed that you've mentioned "evening", note that the code provided makes the change at "midnight" by server time. Were you looking for it to happen at some other time?
    Actually, that is a good point. Ideally, I would love to set the time too, but I won't be too picky at this point. I still plan on manually release the product, and use this only on occasions, in which case, I guess setting it to appear at midnight, on Friday night would not be the end of the world.

    However, when you think of it, everything else nowadays is schedule-able by day and time, so why not in Zencart too? :)

  9. #19
    Join Date
    Feb 2009
    Posts
    861
    Plugin Contributions
    0

    Default Re: Scheduling a new release in the store

    I was going to set this up today (as i am ahead of my release time) but once I added the files, the site because unavailable.
    When I removed this file: config.enable_disabled_upcoming.php the site would work.
    I am not sure if it is something I am doing wrong or if something is not compatible in the files.

    Can someone help me?

  10. #20
    Join Date
    Dec 2009
    Location
    Amersfoort, The Netherlands
    Posts
    2,846
    Plugin Contributions
    25

    Default Re: Scheduling a new release in the store

    Did it generate any debug files?
    Quote Originally Posted by CaroleAs View Post
    I was going to set this up today (as i am ahead of my release time) but once I added the files, the site because unavailable.
    When I removed this file: config.enable_disabled_upcoming.php the site would work.
    I am not sure if it is something I am doing wrong or if something is not compatible in the files.

    Can someone help me?

 

 
Page 2 of 4 FirstFirst 1234 LastLast

Similar Threads

  1. v151 Time release or calendar/scheduling of a product? Possible?
    By mickyhulse in forum General Questions
    Replies: 7
    Last Post: 16 Apr 2014, 01:28 AM
  2. 2008 Roadmap comments
    By DrByte in forum Development Road Map
    Replies: 2
    Last Post: 29 Aug 2008, 11:33 PM
  3. Adding Product Type -- New Release
    By rush_woman in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 31 Jan 2007, 08:22 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR