Zen Cart Logo
Forums / Managing Customers and Orders / add to cart only during physical store operating hours?

add to cart only during physical store operating hours?

Locked

Views: 6,420

Results 1 to 20 of 21
This thread is locked. New replies are disabled.
28 Aug 2008, 5:17 AM
#1
jeff_g avatar

jeff_g

Zen Follower

Join Date:
Oct 2007
Posts:
132
Plugin Contributions:
0

add to cart only during physical store operating hours?

Is there a way to allow the add-to-cart only during store hours?

This is for online ordering for a restaurant. Do not want people sending order if the store is closed.

Thanks,
Jeff

28 Aug 2008, 7:05 AM
#2
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: add to cart only during physical store operating hours?

You can certainly write/or hire someone to write a simple cronjob to do that. The job just have to change the store mode to view price only when it closes, and change back to normal when it opens. Or you can do it manually.

15 Sep 2008, 6:55 PM
#3
jeff_g avatar

jeff_g

Zen Follower

Join Date:
Oct 2007
Posts:
132
Plugin Contributions:
0

Re: add to cart only during physical store operating hours?

Thanks for the reply.

After reading about cron jobs, it seems they run at a set time.

Would it work if a code was added to index.php (I think that's where it is needed) that would do the date/time checks and set "STORE_STATUS" for the current session?

I think the answer to my question depends on whether STORE_STATUS is set once or if it is read from the database multiple times? If read once, my logic :unsure: says this will work. If read multiple times, the program would need to update the table. This leads to the question of if I am correct that index.php would always be executed upon entering the site preventing someone from getting an incorrect status?

Sorry I took so long to respond. I missed your reply somehow.

Jeff

15 Sep 2008, 7:15 PM
#4
gjh42 avatar

gjh42

Black Belt

Join Date:
Jul 2005
Location:
Upstate NY
Posts:
21,876
Plugin Contributions:
8

Re: add to cart only during physical store operating hours?

What if someone is online for an hour before your restaurant closes, and orders after that?
The check really needs to happen when an order is placed, and possibly also when the add to cart is clicked.

15 Sep 2008, 7:29 PM
#5
yellow1912 avatar

yellow1912

Totally Zenned

Join Date:
Oct 2006
Posts:
5,422
Plugin Contributions:
0

Re: add to cart only during physical store operating hours?

I dont understand why you dont like the idea of having cronjob running at certain time. It seems to help you with your requirement. Or is there any I'm missing?

15 Sep 2008, 10:06 PM
#6
jeff_g avatar

jeff_g

Zen Follower

Join Date:
Oct 2007
Posts:
132
Plugin Contributions:
0

Re: add to cart only during physical store operating hours?

yellow1912,

The site will potentially host hundreds of restaurants, each a separate ZC install on a single server. My thought process was that it might be easier to just have a single mod on each site that checked a store hours table (one table created for each store).

After giving more thought to your suggestion, I do like your idea. I'm sure the routine could run every half hour and check if any stores need to be updated. That makes sense.

gjh42,

Good question! I'm going to have to test this. I'll see what happens if I change the store status after beginning order entry.

Thanks to all. I really appreciate the help.

15 Sep 2008, 10:13 PM
#7
merlinpa1969 avatar

merlinpa1969

Totally Zenned

Join Date:
Mar 2004
Posts:
13,031
Plugin Contributions:
4

Re: add to cart only during physical store operating hours?

have the store flip on down for maintenance manually every night just like they were closing the store doors....

and you can easily change teh DFM page to read

Closed Store Hours are

2 Oct 2008, 8:11 PM
#8
neonexus avatar

neonexus

New Zenner

Join Date:
Oct 2008
Posts:
5
Plugin Contributions:
0

Re: add to cart only during physical store operating hours?

I am also looking to be able to do this.

The problem with pulling the site down for maintenance is that I want customers to be able to see the menu (Online food ordering) and browse while the physical store is closed. However, when they try to put something into the cart or try to check out it would redirect them to a page stating the opening hours.

So far I reckon the best way to do this is via the observer class
http://www.zen-cart.com/wiki/index.php/Developers_API_Tutorials
Once the customer adds something to the cart or tries to check out, it would run my code.

function storeStatus() {
    $_SESSION['cart']->attach($this, array('NOTIFIER_CART_ADD_CART_END', 'NOTIFY_CHECKOUT_PROCESS_BEGIN'));
  }

But heres my problem, how do I create a global variable ie ($STORE_STATUS) which can be set via a short php script, and how do I get it to redirect to my store openning hours page?

Any help of either of those issue please!!

2 Oct 2008, 11:13 PM
#9
skipwater avatar

skipwater

Totally Zenned

Join Date:
Jun 2008
Location:
Washington, DC
Posts:
775
Plugin Contributions:
1

Re: add to cart only during physical store operating hours?

my 2 cents
I have been watching this time setting option.

I agree that a cron approach is the best way to activate the change.

Write a small script that changes the STORE_STATUS value of the DB and insert into the configuration table.

open_shop cron insert 0= Normal Store
close_shop cron insert 2= Showcase with prices

With this approach it can be out side zen-cart code or write it into the admin as a mod.

Just a suggestion.

3 Oct 2008, 2:33 AM
#10
jeff_g avatar

jeff_g

Zen Follower

Join Date:
Oct 2007
Posts:
132
Plugin Contributions:
0

Re: add to cart only during physical store operating hours?

NeoNexus,

STORE_STATUS is available, but I'm not sure if it's changed anywhere once you enter the store. I have not gotten that far yet. (I would think it is never changed in core code.)

As my developement & testing continues, I see areas where the cron job would not help in every situation. In my earlier reply to Yellow1912, I knew in the back of my mind I would probably need more than the cron job, but it was too soon to know the full extent of what would be needed.

Using a cron job & changing store status to showroom after closing is a starting point. As NeoNexus said, maint is not desired because we also want people to browse after hours.

The problem comes with delivery hours vs. ordering hours vs. store hours. Store closes at 11:00, delivery till 10:00, accept pickup orders till 10:30.

The logic for this will likely be what's needed to deal with lunch specials. (Price/item only good till 3:00pm kind of thing.)

In the month since I first posted, I have gained a lot more insight into php and ZC and I think NeoNexus might be heading in the right direction. As most long time developers, I of course did not RTFM. :smile: I guess it's time now.

As I see now that others have an interest, I will post back when I find a solution.

Thanks for all the suggestions,
Jeff

3 Oct 2008, 8:19 AM
#11
neonexus avatar

neonexus

New Zenner

Join Date:
Oct 2008
Posts:
5
Plugin Contributions:
0

Re: add to cart only during physical store operating hours?

The reason I dont want to go the Cronjob route is that the hours are irregular. ie They open later at weekends and certain holidays. Also, the end user wont have access to this feature.

Basically, I need to have a button on the admin page, store open/closed, which toggles a value. The mod would then check this value every time the customer adds to the cart or attempts to check out. If condition is true the customer is redirected to a page telling them that the store is closed.

I think I can do this, but I need to setup a global variable to act as the toggle and also how to redirect the page if condition is true.

27 May 2010, 12:22 AM
#12
skipwater avatar

skipwater

Totally Zenned

Join Date:
Jun 2008
Location:
Washington, DC
Posts:
775
Plugin Contributions:
1

Re: add to cart only during physical store operating hours?

skipwater:

my 2 cents
I have been watching this time setting option.

I agree that a cron approach is the best way to activate the change.

Write a small script that changes the STORE_STATUS value of the DB and insert into the configuration table.

open_shop cron insert 0= Normal Store
close_shop cron insert 2= Showcase with prices

With this approach it can be out side zen-cart code or write it into the admin as a mod.

Just a suggestion.

I have had inquiries on how to create this script so I have created this small script store_status.php, that a cron can run.

There are some setting that you can change in the script. And how to use info in the header.

Skip

27 May 2010, 1:07 AM
#13
skipwater avatar

skipwater

Totally Zenned

Join Date:
Jun 2008
Location:
Washington, DC
Posts:
775
Plugin Contributions:
1

Re: add to cart only during physical store operating hours?

Of course I missed something here is a corrected zip.

Skip

3 Jun 2010, 4:46 PM
#14
cavatappo avatar

cavatappo

New Zenner

Join Date:
May 2010
Location:
New York, NY
Posts:
10
Plugin Contributions:
0

Re: add to cart only during physical store operating hours?

skipwater:

I have had inquiries on how to create this script so I have created this small script store_status.php, that a cron can run.

There are some setting that you can change in the script. And how to use info in the header.

Skip

I placed the store_status.php in the admin folder, then set up a cronjob within the server side cron manager to run 5 min after said time. But I'm now receiving an email error with the following:

/web/cgi-bin/php5: Symbol `client_errors' has different size in shared object, consider re-linking
Set-Cookie: zenAdminID=xxxxxxxxxxxxxx; path=/; domain=order.cavatappo.com
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

<br /> <b>Warning</b>: include(includes/languages/english/) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory in <b>/home/xxxx/x/x/x/xxxx/xxxx/admin/includes/init_includes/init_languages.php</b> on line <b>34</b><br /> <br /> <b>Warning</b>: include() [<a href='function.include'>function.include</a>]: Failed opening 'includes/languages/english/' for inclusion (include_path='.:/usr/local/php5/lib/php') in <b>/home/xxxx/x/x/x/xxxx/xxxx/admin/includes/init_includes/init_languages.php</b> on line <b>34</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at /home/xxxx/x/x/x/xxxx/xxxx/admin/includes/init_includes/init_languages.php:34) in <b>/home/xxxx/x/x/x/xxxx/xxxx/admin/includes/init_includes/init_templates.php</b> on line <b>36</b><br /> <br /> <b>Warning</b>: Cannot modify header information - headers already sent by (output started at /home/xxxx/x/x/x/xxxx/xxxx/admin/includes/init_includes/init_languages.php:34) in <b>/home/xxxx/x/x/x/xxxx/xxxx/admin/includes/functions/general.php</b> on line <b>21</b><br />

Any idea what I might be doing wrong? The store status had not chnaged.

3 Jun 2010, 5:54 PM
#15
skipwater avatar

skipwater

Totally Zenned

Join Date:
Jun 2008
Location:
Washington, DC
Posts:
775
Plugin Contributions:
1

Re: add to cart only during physical store operating hours?

Not knowing exactly how your cron manger works. I can not help you with that. And the errors you are getting are not related to store_status.
In my cron setup the call to the file would be.
your_admin/store_status.php

To test your settings you can log into ZC admin and set your store status to 2 and then run http://www.yoursite.com/your_admin/store_status.php
in you browser. store status should change the 2 to a 0 because the script sees that the store is within the opening times. 12:00 noon to 10:00PM

Skip

3 Jun 2010, 7:58 PM
#16
cavatappo avatar

cavatappo

New Zenner

Join Date:
May 2010
Location:
New York, NY
Posts:
10
Plugin Contributions:
0

Re: add to cart only during physical store operating hours?

Thank you so much for your help. We're using Godaddy as our host, *nix server, and they provide a Hosting Control Center panel where there is a Cron Manager.

When I set up the Cron Job and select the php file to be run at said time, Godaddy automates the command line to read ```
/web/cgi-bin/php5 "$HOME/html/admin/store_status.php"


This then provides me with before mentioned errors.
3 Jun 2010, 7:59 PM
#17
cavatappo avatar

cavatappo

New Zenner

Join Date:
May 2010
Location:
New York, NY
Posts:
10
Plugin Contributions:
0

Re: add to cart only during physical store operating hours?

We tested as you mentioned above, and it works perfectly. But when applied via Godaddy cron manager, it doesn't and output that error email.

3 Jun 2010, 9:00 PM
#18
skipwater avatar

skipwater

Totally Zenned

Join Date:
Jun 2008
Location:
Washington, DC
Posts:
775
Plugin Contributions:
1

Re: add to cart only during physical store operating hours?

Maybe some one can jump in here that has knowledge of Godaddy cron settings and setups. That might give you some help with that.

Skip

3 Jun 2010, 10:30 PM
#19
skipwater avatar

skipwater

Totally Zenned

Join Date:
Jun 2008
Location:
Washington, DC
Posts:
775
Plugin Contributions:
1

Re: add to cart only during physical store operating hours?

I checkout http://help.godaddy.com/topic/67/article/3547
If you read item 8.
NOTE: Our sample scripts use the variable $HOME in place of the actual server path, which you need to provide.

It looks like you need to edit that info with your server path.

Skip

4 Jun 2010, 4:28 PM
#20
cavatappo avatar

cavatappo

New Zenner

Join Date:
May 2010
Location:
New York, NY
Posts:
10
Plugin Contributions:
0

Re: add to cart only during physical store operating hours?

We moved the Store_Status.php file out of the Admin folder and into the root directory, followed Godaddy's steps, and it now works. It opened the store properly at the said time, but didn't close it last night.