Skip Navigation

[Résolu] Opening hours and closed/open status

This support ticket is created Il y a 7 années et 10 mois. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 réponses, has 2 voix.

Last updated by Luo Yang Il y a 7 années et 10 mois.

Assisted by: Luo Yang.

Auteur
Publications
#409388

SD

Hi there,

We are offering web design services to restaurants and our clients repeatedly request some features for the sites so we decided to develop those as plugins using Toolset if possible.

For the moment the first plugin we want to create using toolset is "Opening Hours".

So we have a lot of customers/restaurants that break their opening times in two time slots and others that are just one.
For example Monday's opening hours for Restaurant A are 19:00 - 23:00 but for Restaurant B Monday's opening hours could be 13:00 - 15:00 & 19:00 - 23:00. And we also need to be able to set CLOSED for specific days(maybe using a check box.

And the we want to output the opening hours in the front-end in two ways
1) As a time-table, for example something like this:
Monday 1:00PM - 3:00PM & 5:00PM – 10:00PM (an example day with 2 time slots)
Tuesday 1:00PM - 3:00PM & 5:00PM – 10:00PM
Wednesday 1:00PM - 3:00PM & 5:00PM – 10:00PM
Thursday 1:00PM - 3:00PM & 5:00PM – 10:00PM
Friday 1:00PM - 3:00PM & 5:00PM – 10:00PM
Saturday 5:00PM – 10:00PM (an example day with 1 time slot)
Sunday CLOSE (an example day with CLOSE checked)

2) And the second way we want to output that in the front-end is showing the current status for the current day and the day's hours. OPEN/CLOSE along with the next opening time or the next closing time, for example:
OPEN NOW(until 3:00PM, reopening at 5:00PM) (an example day with status open and with 2 time slot)
OPEN NOW(until 10:00PM) (same day as above but during the second time slot)
CLOSED NOW(opening at 5:00PM) (an example with closed status and the next opening time)

What is the best possible way to achieve this using toolset? I assume we'll have to use types to create the days and use custom fields opening hours and closed.

And the use Views for the output.

Is this possible? Please advice, how to we make views display the current day with the status and the opening hours.
I know how to do the time table view, i only need help and to know how to do the view where it says the current status the closing time and the opening time.

Thanks in advance
Stelios

#409413

SD

To make it easier, we can ditch the "until" part
so it will display a time next to the status only when it's closed.

So the status can be:

OPEN NOW
&
CLOSE NOW(Reopening 3:00pm) (the status + the next opening time)

thanks

#409574

Dear Stelios,

There isn't such a feature within Toolset, I assume there is a custom post type "restaurants" in your website, here is my suggestion:
1) Create a child post type "Opening hours", with below custom fields:
https://toolset.com/documentation/user-guides/creating-post-type-relationships/
a) select field "Day of the week", with options:
Monday, Tuesday ... Sunday
b) select field "Start hour", with options 1:00 AM, 0:00 AM 1:00 AM ... 11PM
c) select field "End hour", with options 1:00 AM, 0:00 AM 1:00 AM ... 11PM
d) checkbox "Open/Close",
e) date field "special day",
https://toolset.com/documentation/user-guides/using-custom-fields/
Then when you edit a "restaurant" post, you will be able to setup the child "Opening hours" posts

Create a custom shortcode, to calculate if current time is in the range of child "Opening hours", then output waht you want:
OPEN NOW(until 10:00PM) (same day as above but during the second time slot)
CLOSED NOW(opening at 5:00PM) (an example with closed status and the next opening time)
http://codex.wordpress.org/Function_Reference/add_shortcode

#409600

SD

Hi Luo,

You might not was clear of what i meant.
I know there is not such a feature within toolset. And i'm not talking about a restaurants cpt either....what i meant is that we are creating a website for a restaurant. But we will be reusing the same website for other clients/restaurants as well.
So we need to create a plugin using toolset(we will export types and views) that will accommodate both kind of restaurants(restaurants with one time slot like 1:00pm - 5:00pm and restaurants with 2 time slots like 1:00pm - 5:00pm , 5:00pm - 11:00pm)
Saying that, "Opening Hours" don't need to be a child post type...it will be just a custom post type.

So, I assume we will need to create some custom fields for "opening hours" cpt.
a) Select field "Opening Hour"
b) Select field "Closing Hour"
Now how should we go about the restaurants that have 2 times slots(2 opening hours and 2 closing hours) ? Should we make the two above select fields repeating as a group ? or should we just create 2 different ones that will be available for such restaurants and tell the single time slot restaurants to leave those blank. or maybe use conditional logic to let the user selct how many time slots he has?
c) Checkbox "Open/Close"
And for the day(monday,tue,etc) we will be using the default title filed of the post so we don;t need a custom field for that.

You had another field called "Special day" but i assume this was due to a misunderstanding as i cannot see why is needed.

Now for the output part....is there anyway we can do what we want using Views instead of a schortcode?

Thanks

#409972

Q1) Now how should we go about the restaurants that have 2 times slots(2 opening hours and 2 closing hours) ? Should we make the two above select fields repeating as a group ?
There isn't built-in repeating field group feature within Types, but we can use child post type to act same result, see our document:
https://toolset.com/documentation/user-guides/creating-groups-of-repeating-fields-using-fields-tables/

In your case, if the website is for only one restaurant, then you just need one post type "Opening hours", with the custom fields as I mentioned above:
https://toolset.com/forums/topic/opening-hours-and-closedopen-status/#post-409574
But it is only my suggestion.

Q2) About the another field called "Special day", there might be some holidays, the restaurant will open or close in those holidays.

Q3) output part, since it is not standard date fields, so it is not possible with Views plugin, It needs custom codes, I suggest you check out our certified partners for it:
https://toolset.com/consultant/

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.