Thread: Cron Job

Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1
    Join Date
    Sep 2010
    Location
    Finland
    Posts
    59
    Plugin Contributions
    0

    Default Cron Job

    I did not succeed cron job with store_status.php. Can any one help?

    command: php /home/xxxxx/public_html/xxxxxx/adminxxx/store_status.php

    store_status.php

    <?php
    /*
    ***********************************************************************
    $Id: store_status.php, v 1.0 2010/05/26

    ZenCart 1.3.x > 1.3.9c
    Copyright 2003-2010 Zen Cart Development Team
    Portions Copyright 2004 osCommerce
    http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

    Written By SkipWater <[email protected]> 05.08.10

    Use at your own risk.

    ***********************************************************************
    All we do is set the store status value based on the time of day.
    The admin of the zen cart should setup a cron to run this script a
    minute or two after the hour set to open and close the store.

    That is 2 (two) cron calls a day. One to open and one to close.

    This file must be run from the admin folder of the zen cart site.

    */

    require('includes/application_top.php');


    // Change to meet your opening and closing times
    // Time is based on 24 hour clock 12 = noon 24 = Midnight
    $store_open = ('21:53:00');// 12:00 noon
    $store_close = ('21:34:00'); // 10:00 pm

    // If you want an email sent to store owner, that notifies the Online Store Is Now OPEN
    // Set this to 1
    $notify = 1;

    /*
    0 = Normal Store
    1 = Showcase no prices
    2 = Showcase with prices
    */

    if ((date(H) >= $store_open) && (date(H) <= $store_close)) {
    $zen_store_stat = 0; // Store is Open Normal Zen Cart
    } else {
    $zen_store_stat = 1; // Store is Closed Showcase no Prices
    }

    // Should not need to edit below this line
    // ***********************************************************************

    $check_query = "SELECT * FROM " . DB_PREFIX . "configuration WHERE configuration_key = 'STORE_STATUS';";
    $check_result = $db->Execute($check_query);
    if ($check_result->RecordCount() > 0) {
    $insert_query = "UPDATE " . DB_PREFIX . "configuration SET configuration_value = '".$zen_store_stat."' WHERE `configuration_key` = 'STORE_STATUS'; ";
    $insert_result = $db->Execute($insert_query);
    // uncomment if not running cron
    // if ($insert_result) echo 'Store Status Set to '.$zen_store_stat.'<br />';
    if ($notify != 0) {
    zen_mail('',STORE_OWNER_EMAIL_ADDRESS, 'Store Status Changed to OPEN', 'OnLine Store OPENED '. date('M, d Y H:i'), '',STORE_OWNER_EMAIL_ADDRESS); // email admin if status change to OPEN
    }
    } else {
    // uncomment if not running cron
    // echo 'Error Setting Store Status <br />';
    zen_mail('',STORE_OWNER_EMAIL_ADDRESS, 'Error Failed Setting Store Status', 'ERROR Failed to OPEN OnLine Store'.date('M, d Y H:i'),'',STORE_OWNER_EMAIL_ADDRESS); // email admin if status change failed
    }
    ?>

    message:

    Status: 302 Moved Temporarily
    X-Powered-By: PHP/5.4.29
    Set-Cookie: zenAdminID=6a659ab870d8cdee1bc7ad50ee383170; domain=.xxxxxx; HttpOnly
    Expires: Thu, 19 Nov 1981 08:52:00 GMT
    Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
    Pragma: no-cache
    Content-Type: text/html; charset=utf-8
    Location: http://xxxxxx/login.php?camefrom=&/h...c7ad50ee383170

  2. #2
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,378
    Plugin Contributions
    9

    Default Re: Cron Job

    Try

    /usr/local/bin/php /home/xxxxx/public_html/xxxxxx/adminxxx/store_status.php

    note the space between php and /home

    This ofc depends on the exact location of your php directory on the server, you need to establish this first and may need to contact your host.

  3. #3
    Join Date
    Sep 2010
    Location
    Finland
    Posts
    59
    Plugin Contributions
    0

    Default Re: Cron Job

    Thanks for your answer.
    I try and it came error message.
    ERROR: admin/includes/configure.php file not found. Suggest running zc_install/index.php?

  4. #4
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,378
    Plugin Contributions
    9

    Default Re: Cron Job

    Quote Originally Posted by Cenkki View Post
    Thanks for your answer.
    I try and it came error message.
    ERROR: admin/includes/configure.php file not found. Suggest running zc_install/index.php?
    Just noticed that you are running ZC 1.5.1 but the header of the file you posted says

    ZenCart 1.3.x > 1.3.9c
    That add on may not be compatible with your version of ZC

  5. #5
    Join Date
    Sep 2010
    Location
    Finland
    Posts
    59
    Plugin Contributions
    0

    Default Re: Cron Job

    I just need basic script, open-closed shop auto whit cron job. I found store_status.php script from zen cart forum. And i can't update version.

    and i four this otter subject of zen cart forum...

    Dr Byte's solution works well for me but I thought I'd add a little caveat which might save somebody some time.

    If you run your php program directly as a cron job it won't have the right working directory and won't find /includes/config.php so it will fail with;
    ERROR: admin/includes/configure.php file not found. Suggest running zc_install/index.php?
    To avoid this you need to tell cron to change directory before invoking PHP to run the program, so your cron command should read
    Code:
    cd "public_html/admin"; /usr/local/bin/php my_program.php
    Remember to leave a space between your path to PHP and the program name, you are invoking PHP with the program name as a parameter.

    I hope this helps someone.

  6. #6
    Join Date
    Jun 2008
    Location
    Washington, DC
    Posts
    789
    Plugin Contributions
    7

    Default Re: Cron Job

    Quote Originally Posted by Cenkki View Post
    Thanks for your answer.
    I try and it came error message.
    ERROR: admin/includes/configure.php file not found. Suggest running zc_install/index.php?
    require('includes/application_top.php'); this file loads the paths needed for configure.php

    For testing uncomment the echo commands.

    Then call the script www.xxxxxx/adminxxx/store_status.php

    After you get the script to work then setup the cron up.

    Skip
    • 446F63746F722057686F •

  7. #7
    Join Date
    Sep 2010
    Location
    Finland
    Posts
    59
    Plugin Contributions
    0

    Default Re: Cron Job

    fortunately it works.
    wget -O - www.xxxxxx/xxxxx/adminxxx/store_status.php
    add... define('CRON_ADMIN_USER_ID', '1');

    but :)

    if store status 2= Showcase with prices, it change 1= Showcase no prices
    if store status 0= Normal Store, its change 1= Showcase no prices again
    if store status 1= Showcase no prices, its not changing

  8. #8
    Join Date
    Nov 2007
    Location
    Sunny Coast, Australia
    Posts
    3,378
    Plugin Contributions
    9

    Default Re: Cron Job

    Quote Originally Posted by Cenkki View Post
    fortunately it works.
    wget -O - www.xxxxxx/xxxxx/adminxxx/store_status.php
    add... define('CRON_ADMIN_USER_ID', '1');

    but :)

    if store status 2= Showcase with prices, it change 1= Showcase no prices
    if store status 0= Normal Store, its change 1= Showcase no prices again
    if store status 1= Showcase no prices, its not changing
    That indicates that the script is working as per configuration:

    PHP Code:
    if ((date(H) >= $store_open) && (date(H) <= $store_close)) {
    $zen_store_stat 0// Store is Open Normal Zen Cart
    } else {
    $zen_store_stat 1// Store is Closed Showcase no Prices

    If you wanted store status = 2 then you would need to set

    PHP Code:
    $zen_store_stat 2// Store is Closed Showcase with prices 

  9. #9
    Join Date
    Sep 2010
    Location
    Finland
    Posts
    59
    Plugin Contributions
    0

    Default Re: Cron Job

    It doesn't change store status open (0), with all combination.

  10. #10
    Join Date
    Sep 2010
    Location
    Finland
    Posts
    59
    Plugin Contributions
    0

    Default Re: Cron Job

    I forget add that code also...

    admin/init_includes/init_admin_auth.php

    if (!isset($_SESSION['admin_id']) && defined('CRON_ADMIN_USER_ID') && (int)CRON_ADMIN_USER_ID != 0) {
    $_SESSION['admin_id'] = CRON_ADMIN_USER_ID;
    }

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. v154 Cron job coding
    By droidmcse in forum All Other Contributions/Addons
    Replies: 1
    Last Post: 24 Apr 2015, 11:29 PM
  2. Cron Job to enable a EZ Page?
    By cs_jono in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 4 Jun 2010, 08:20 PM
  3. CRON job help
    By Jeff G in forum General Questions
    Replies: 10
    Last Post: 9 Oct 2008, 12:20 AM
  4. zen_mail as part of a cron job...
    By savage in forum General Questions
    Replies: 0
    Last Post: 30 Nov 2007, 06:25 PM

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