close ad
Databridge V2 with MySQLi support IS Now Available!
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

Disable Add to Cart button based on time

Thread began 10/19/2009 2:32 pm by Rich Petersen | Last modified 10/26/2009 6:44 pm by Rich Petersen | 1335 views | 5 replies

Rich Petersen

Ok, this is just to post the solution in case someone searches on this topic.

Here is the code for where the button is placed:

if (Date('d M Y', $mon) < Date('d M Y'))
echo "Sorry no more orders for today";
elseif (Date('d M Y', $mon) > Date('d M Y'))
echo '<input type="image" src="WA_eCart/Images/Pacifica/Btn3_EN_addtocart.gif" border="0" value="Add to Cart" name="teacherslunchbox_21_ATC" >';

elseif (Date('d M Y', $mon) == Date('d M Y'))
if (Date("Hi") + 300 < "900")
echo '<input type="image" src="WA_eCart/Images/Pacifica/Btn3_EN_addtocart.gif" border="0" value="Add to Cart" name="teacherslunchbox_21_ATC" >';

echo "Sorry no more orders for today";

The page has two weeks worth of possible orders fed by a database.

$mon holds a date that could be in the future or the past. I get this date from script at the beginning of the page by using this script (repeating and tweaking it to get each day's date for the two week period so I have a $mon, $mon2, $tues, $tues2, etc)

$mon=strtotime('-'.$tod.' days');

So for example, if today is Wed, it could be Mon previous to today, or the Mon coming up. So first I see if Monday is before today (which means they can't order on a past date) so I echo "sorry, blah blah"

Then if that date is in the future, I place the button.

If the date happens to be TODAY, and it's before 9am, then place the button

If it's TODAY but past 9am, echo "sorry, blah blah" since it's too late to order and get it in time for lunch (it's a sandwich shop)

I'm a beginner PHP person, so if this is hokey, I'd appreciate any tweaks. However, it seems to work fine and I wanted to get it out there in the forum in case someone else can use it.

Thanks all,

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question





Ease of use


security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...