Thread: CRON job help

Page 1 of 2 12 LastLast
Results 1 to 10 of 11
  1. #1
    Join Date
    Oct 2007
    Posts
    132
    Plugin Contributions
    0

    Default CRON job help

    Hi,

    I need to write a CRON job to turn categories on and off each day (Daily Specials).

    I think I can figure out how to set the cron on the server, but I need some direction on how to write/where to put the php script.

    The logic is pretty simple, (in english)

    select categories with categories_id = '1','2','3','4','5','6','7'
    set categories_status = "0" (turn off all specials)
    select categories with categories-id = day_of_the_week
    set categories_status = "1"

    I could probably figure out the correct syntax/logic for the sql, but I don't know what other initilize stuff is needed to open/access the tables.

    I also have no idea where this file should be put.

    If someone can provide a sample file, or point me to an existing ZC file I can hack through, it would be a big help.

    Thanks,
    Jeff

  2. #2
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: CRON job help

    Are you wanting to turn off the categories as in categories_status = 0 for every day except the current day of the week ...

    Are you wanting to take, for example, today is wednesday, if the cron was to run today, at Wednesday, Midnight, do you just want the categories_status for Tuesday Category to be set to 0 for hide or don't show ... and then do you "also" need all Specials, as in Specials in the specials table deleted or set the status to 0 or what on the Products that were in the Category for Tuesday ...

    I am assuming that you are using Linked Products on the Day of the Week Categories ...

    Should the Products then be "removed" from the products_to_categories table that related them to the Tuesday Category ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  3. #3
    Join Date
    Oct 2007
    Posts
    132
    Plugin Contributions
    0

    Default Re: CRON job help

    Are you wanting to turn off the categories as in categories_status = 0 for every day except the current day of the week ...
    That's all I want to do. My specials are just categories, not as in ZC specials.

    It might be clearer to know this is for a restaurant site. The products in "Monday Specials" categories are only in that category, not linked. No need to do anything other than set categories_status = 0 for Monday. The same items are "special" every Monday.

    My idea to turn off all 7 days then turn on only today is from a failsafe design thought. If the job should not run on a particular day, the following day will self correct. Job will run daily at around 1:AM. It's not terrible if a person should see Monday Specials on Tuesday.

    ALSO, if CRON is not the right way to do this, I would still like to figure out how to do cron jobs in ZC for other possible mods.

    Thanks,
    Jeff

  4. #4
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: CRON job help

    Well that is what I am trying to figure out ... the idea of do you really need a CRON job or do you just need to add something to manage the categories_status for 7 categories_id and not worry about anything other than:

    It is Tuesday, and Cinderella is at the ball ... er ... sorry, I lost track there ... the clock is about to strike Midnight ...

    1 The Clock hits Midnight - set the categories_status = 0 for categories_id = Tuesday

    2 Set the categories_status = 1 for categories_id = Wednesday ...

    You see there is a nifty little feature I added one day for knowning the Date that a customer comes to your shop ...

    This means that on hit 1, run the update on Specials and Featured Products, but do not run it again ...

    However, if they pass through the Midnight hour, it will re-run the 1 time per session events such as activate and deactivate Specials and Featured products for the new day ...

    Using this handy dandy gizmo, you would have a way of knowing when it is the "new day" in your shop and could use php to manage this nifty little event without breaking things or forgetting about what happens if the customer is hanging around at 11:55pm and then still there at 12:03am when the specials of the day aren't so special any more ...
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  5. #5
    Join Date
    Oct 2007
    Posts
    132
    Plugin Contributions
    0

    Default Re: CRON job help

    Well that is what I am trying to figure out
    Does this refer to cron jobs?
    there is a nifty little feature
    This sounds like it would accomplish the same thing and could be the way to go. Are you referring to init_system?

    You say it activates when someone first comes to the site. Does that mean each time a new customer arrives it will activate again? If so, is that a bad thing?

    This could also be useful for other things like turning off the lunch menu at a certain time of day. On these items, I would prefer to just disable the "add to cart" button. We want people to see the whole menu even after lunch is over.

    As I re-read what I just wrote, I guess I could just use an observer class item to disable the order button and display a "Only Available until..." message for all sorts of things.

    Could you offer an opinion of which method would be best?

    Jeff

  6. #6
    Join Date
    Sep 2003
    Location
    Ohio
    Posts
    69,402
    Plugin Contributions
    6

    Default Re: CRON job help

    Now ... you are adding more information, which is good, but are forgetting I don't know what you are talking about, so you have to type slower ...

    You have the "Daily Specials" which I am guessing is the:

    Monday
    Ham on Rye

    Tuesday
    Spagetti and Meatballs

    Wednesday
    Meatloaf

    Thursday
    Peanut Butter and Jelly

    Friday
    Tuna Sandwich

    Saturday
    Moon Burger

    Sunday
    Turkey with Gravy


    So, you want to see this where the Daily Special for the Meatloaf is "shown" All Day in the Wednesday Category or that it is "available" All Day in the Wednesday Category ...

    If not "available" All Day in the Wednesday Category, does this mean that there is a Day of the Week and Time Period that these Products "show" are "available"?

    You need to spell this out really specific as in, I walk into the store to buy the Wednesday Special ...

    1 When is the Wednesday Special available?

    2 What makes it so Special?

    3 What happens to the Wednesday Special after it is "NOT" available ... does that mean too bad so sad no Meatloaf for me on Thursday or after the "available" Special is over? Or ... can I still get the Meatloaf and what makes it "plain" meatloaf vs the Wednesday "Daily Special" Meatloaf?
    Linda McGrath
    If you have to think ... you haven't been zenned ...

    Did YOU buy the Zen Cart Team a cup of coffee and a donut today? Just click here to support the Zen Cart Team!!

    Are you using the latest? Perhaps you've a problem that's fixed in the latest version: [Upgrade today!]
    Officially PayPal-Certified! Just click here

    Try our Zen Cart Recommended Services - Hosting, Payment and more ...
    Signup for our Announcements Forums to stay up to date on important changes and updates!

  7. #7
    Join Date
    Oct 2007
    Posts
    132
    Plugin Contributions
    0

    Default Re: CRON job help


    Sorry, I tend to give too much information and tried to simplify it.

    Cat Tree would probably be:

    Pizza
    Beverages
    Veal
    Chicken
    Daily Specials
    -> Monday
    -> Tuesday
    -> Wednesday

    Monday Category has... (all day)
    Mama's Meatloaf 4.50 (only avail on Mon)
    Sandwich, Fries and a soda combo for 4.95
    Soup & Salad combo for 5.25
    Wrap & Soda combo for 4.95
    etc, etc.

    Items might be available on regular menu priced higher/separately.
    So... ONLY on Monday, you can order these items or combos at this special price. Ideally, you can see these on other days, but not place an order.

    Time of day option is the same but different.
    Menu has:
    Veal Cutlet Parm - Lunch Portion 6.95 (until 3:00pm only)
    Veal Cutlet Parm - Dinner 8.95 (available any time)

    Thanks again and I hope this makes sense to someone besides me.

    Jeff

    BTW: The goal is to host dozens or even hundreds of restaurants, so the final method needs to be something that is fairly easy to mod for each site. I am a long time software designer, so changing the business logic is a no brainer. My real issue at this time is knowing best way to implement in ZC and some php help.
    Last edited by Jeff G; 8 Oct 2008 at 09:15 PM.

  8. #8
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: CRON job help

    Keep in mind that simply disabling a category doesn't necessarily disable all the products in that category ... meaning, if someone were to do a search for the product, they could still find and even purchase the item if the product itself wasn't also disabled.

    For the larger-scale implementation you're referring to, I'd be inclined to contemplate a "rolling specials" concept, whereby each "special" (using the specials infrastructure) would only be enabled based on the day of the week (and in some cases as you mentioned in your last post, the time of day).

    I suppose there's benefit in the product-number of the daily specials being used for certain orders, but the existing specials infrastructure might be adaptable more efficiently than enabling/disabling products, esp since Google will see things come and go repeatedly, and may or may not frown on that.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  9. #9
    Join Date
    Oct 2007
    Posts
    132
    Plugin Contributions
    0

    Default Re: CRON job help

    DrByte,

    Keep in mind that simply disabling a category doesn't necessarily disable all the products in that category ... meaning, if someone were to do a search for the product, they could still find and even purchase the item if the product itself wasn't also disabled.
    All very good points, but especially this one.

    Maybe I'm oversimplifying it, but what if I write an observer class that is called when the product info page is viewed using "NOTIFY_HEADER_START_PRODUCT_INFO". This is the only place to order from. I could put all my day and time logic in there.

    This approach does not require disabling anything, lets customers see specials they may want to come back for, and should allow all kinds of logic, probably using hidden tags embedded in the item description.

    I wrote (hacked someone elses) one oberserver to deal with minimum orders so I have a little understanding of their workings. (FWIW: Min order mod to prevent delivery orders under a set amount, but no min for takeout.)

    I have been trying this approach for the last hour, but I can not figure out how to get the product information in my function. Any help there would be appreciated.

    Is there anything inherently wrong with this design?

    Jeff

  10. #10
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: CRON job help

    Quote Originally Posted by Jeff G View Post
    ... is called when the product info page is viewed using "NOTIFY_HEADER_START_PRODUCT_INFO". This is the only place to order from ...
    You mean, people can't order from the product-listing page too?
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 
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. v151 Cron Job
    By Cenkki in forum General Questions
    Replies: 19
    Last Post: 8 Sep 2014, 02:54 PM
  3. 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
  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