Allow users to specify store opening times for each day

Hey guys,

I’m trying to build this functionality:

When businesses sign up to my website, they must specify their store opening times as a part of the onboarding process.

I want to have the following displayed:

Monday: Select opening time | Select closing time or closed
Tuesday: Select opening time | Select closing time or closed
Wednesday: Select opening time | Select closing time or closed

All the way through to Sunday. This then becomes their global store opening times.

I already have the ‘Business’ data type, but I’m not sure how to build the above.

Should I create another data type for opening times, or should I just create a bunch of data fields in my ‘Business’ data type? I guess they would have to be ‘Opening time - monday’, ‘closing time - monday’, but this doesn’t seem very elegant.

At another point in my applicaiton, I want to reference this opening/closing time, e.g. after closing time, the businesses’ page may say ‘Closed. Opening at 8:00’. I guess this means that it shouldn’t be a text field, but needs to be a date or number field?

Any help is appreciated!

I would have done the same.

And i would suggest you make each of them a date/time and not text. Will make life simple for you down the lane. When using the value you can extract just the time part and format it whatever way you want.

In addition you can have a yes/no field for monday-closed, tuesday-closed, etc.

Alternatively instead of having a monday-open, monday-close, you can just have monday-hours and make the field type to be date range where the range start will be the open time and the range end will be the close time.

Now i’m not sure if this will apply to your application but assuming the business is a restaurant where the closing time can overflow into next day, you will need to rethink about your database structure.
For example, it is very common to have a restaurant open say from Friday 2pm to 3am Saturday.
I have some ideas about this as i’ve done a similar thing for someone so if it applies to your case let me know and i can share some ideas with you.

2 Likes

If your “businesses” (brands?) have multiple locations, define a Location data type. Brands have a (hopefully huge) list of Locations. Locations have a bunch of data that defines them. The time those locations open is just detail.

Each location would have a range when they are open on each day. Organized by day of week maybe? Or perhaps DOW is sub to hours. Doesn’t really matter at that level (what, three or four levels down?).

Experimenting might be key. Don’t commit until you’re sure of the data model that fits your app and your brain.

2 Likes

@seanhoots Thanks, this gives me some sort of validation that I’m learning and doing something right! You’re right, there could be overflow (although this is not a very regular occurrence, maybe 1 in 30 businesses listed on our platform).


@keith Ah yes good thinking.

Maybe I’ll have an ‘Address’ Data type (which contains opening/closing times), then each ‘Business’ can have multiple addresses.

We’re allowing businesses to create offers, so when they add their ‘offer’, they can select an address from a dropdown of addresses they’ve created.

1 Like

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