NateWr / restaurant-reservations

WordPress plugin to accept restaurant reservations online
68 stars 51 forks source link

How to use Opening hours from buisness profile plugin #131

Closed CharlesPoullain closed 6 years ago

CharlesPoullain commented 6 years ago

Hi, I am using this plugin with the other plugin Buisness Profile. I want to use opening hours from restaurants that I have created in the Locations panel (Buisness Profile). How can I do that ?

NateWr commented 6 years ago

Hi @CharlesPoullain,

The plugin doesn't yet support a different booking schedule for each location. It only accounts for the one schedule set under Bookings > Settings > Schedule. To use the opening hours from each business as the booking schedule, you'll need to do some custom coding.

CharlesPoullain commented 6 years ago

Thanks for your response @NateWr .

I will make my own code to make it works. Are there things I need to know about the current system and how I can do that ?

NateWr commented 6 years ago

Hi @CharlesPoullain,

You should be able to do it using the hooks in the plugin. You can see the opening hours are passed to the JavaScript here:

https://github.com/NateWr/restaurant-reservations/blob/master/includes/template-functions.php#L180

Just adjusting that depending on which location is being shown should be enough for most cases. The one trick bit will be if you show the booking form where the user can select the location. In that case, you'll need to update the opening hours dynamically based on that selection. You can see how the datepickers are initialized and passed a booking schedule in the JS here:

https://github.com/NateWr/restaurant-reservations/blob/master/assets/js/booking-form.js#L40-L166