I want the ordering to be available at specific hours only Opencart

Please LogIn to Reply!

Post By: guest | 01-18-2013 07:57 Reply


I'm working on an online ordering website for our takeaway restaurant. I have to prevent people from placing orders before 5pm and after 11.30 pm (server time). How can I set version that outside of these hours would display a message and would block the access of the site/service, please? Thanks in advance!


"block the access of the site/service" if you want to block access to website you can re-use maintenance page functionality to display corresponding message during the non-trading times.

Alternately you can write a custom module that taps into server time, once enabled this may be able to stop people ordering beyond specific times. Shop will be still open for business.

Hope that helps.

Thanks. Turning on and off the ordering manually by using the maintenance page could not be a long term solution.
Yes, a custom module would be perfect for it, but at this stage I don't know how to write modules for Opencart. I just started to learn php and I was wondering if the insertion of this code would work, and if yes, where I should insert it:

if (strtotime('5pm') <= time() && time() <= strtotime('11:30pm')) {
// we're in business
} else {
// we're not

Anybody knows which file to edit?

how about wrapping the if time code around the buy button
so if the time is whatever, show the buy button, otherwise show a "we are closed" message and hide the buy button
that way, they can still see what's available but can't buy
you could put the code into the .tpl. It's not nice to put code into the .tpl but if it works, it will do until we learn more.

or you could have a different .tpl for different times and in the controller file (product.php) add the time code to it
so the code would read if the time is whatever, use this template with no buy buttons, otherwise use the custom template with the buy buttons, otherwise use the default open cart template

Thank you, jty. I will try your suggestion. My problem is that everything is so hidden. I wanted to customize the maintenance.tpl, so I could have written something like: we are closed at the moment, bla, bla, bla, but I simply couldn't find where it gets that text that it displays from, what to edit. I'm too much accustomed to plain html where you can edit the texts in the code.

Reply Or Comment!
Please LogIn to Reply!