Forum Academy Marketplace Showcase Pricing Features

Handling multiple store opening hours per day

Hi Community :blush:

I have been searching through to find the best way to handle store opening and closing times. I can find a lot of information about handling times when it is just one time per day but I can’t figure out how to handle multiple opening times.

For example:

A store may open on Monday 9am to 11am and then 3pm to 9pm.

How is this handled both in the database and also how do you allow a user to “add” extra availability for a day in the front end?

Thanks for any help.

Create a data type called ‘Opening hours’. It has three standard fields

  • store
  • open time
  • close time

Then if you want to add extra open times, you just add another row to the table.

This is a bit tricky. So you need to take open time and closing time from the user. Then count the minutes and store them in DB like
Open time count = Open time:Extract hoursX60+Open time:Extract minutes
Closing time count = Closing time:Extra hoursX60+Closing time:Extra minutes

Now you know at exactly what minute the store opens and at exactly what minute the store closes, on a 24 hour clock. While displaying list of “Open stores”, you need to count the minutes of current time of the day like
Current date/time:Extract hoursX60+Current date/time:Extract minutes
Now you need to compare this current time count with open time count and closing time count to check whether a store is open or closed.
To add extra availability from front end of user dashboard, there should be a button to mark them “Currently open” manually and there should be “Yes/no” field in the database. If they click on “Currently open” beyond their timings, you need to change that “Yes/no” field to “Yes”. In the page where you are displaying stores, you can for this “Yes/no” field’s value, if it’s “Yes”, that store should be displayed as open regardless of their timings.
They need to click on “Close store” button manually to close it, which turns “Yes/no” field to “No”.

1 Like

This topic was automatically closed after 70 days. New replies are no longer allowed.