Con
Yet another WordPress dev

How to setup time slots with different durations in WooCommerce Bookings

Fixed blocks of

Timelots with varying durations in the same WooCommerce Bookings product, you say? Not possible. Yes, possible with a little math.

Here is the scenario.

The required times:
• 8.15am
• 9:30am
• 12.00pm
• 2.30pm
• 5.30pm

In many bookings scenario the duration of the bookable slot is not a deciding factor. Just like in this one, only the start time counts. Since WooCommerce Bookings only allows one duration for the bookable slot you need to do a little math to make it work.

All you need is to find the highest common denominator (hcd) and then knock out the times in-between that you do not want to be available. I hope I used the correct term. English is not my first language and my math vocabulary is limited, ahem ;).

Let me illustrate:

Finding the hcd

These are the required times and their time gap in-between:

• 8.15am – 75 minutes.
• 9:30am – 150 minutes.
• 12.00pm – 150 Minutes
• 2.30pm – 180 minutes
• 5.30pm

Now for the math. Find the highest number that can be used to divide each time gap.

The answer here is 15.

75 / 15 = 5
150 / 15 = 10
180 / 15 = 12

You then set 15 as your bookable slot:

Eliminate non-required timeslots

Upon saving this will produce many, many, many bookable time slots. Now starts the elimination. As a first step set the “First Block starts at…” to your earliest required time: 08:15. This will eliminate night times.

Much better.

As you can see now, your required times are among them. Now all you need to do is to knock out the times you don’t want while preserving the duration of your bookable slot, that is 15 minutes. Like so:

Each availability rule has 15 minutes of a gap, so that your desired time slots “survive”. The last availability rule takes care of all time slots after 05:30pm until midnight.

This gives you your required times:

That is it

Hope this helps the next time you need to setup varying bookable slots for your WooCommerce Bookings product

PS: Tested with WooCommerce Bookings 1.9.15

keep reading?

7 comments

  • Thanks, I found this very helpful — in my case the bookings are of the same duration, but I have two resources with different times, so this showed me to just use the starting time slot and to block out the others

    • A
      Con Schneider

      Hi Frank,

      Thanks for your comment.
      Glad this was helpful. 👍

  • thank you for taking the time to explain this! really helps!

  • Hi Con,

    This is a fantastic article and seems very topical.

    If you had this scenario:
    – A tour that ran on a Monday for two hours, 2pm to 4pm
    – A tour that ran on a Tuesday for five hours, 11am to 4pm

    How would you do this?

    It seems like it would be great to be able to be able to set a custom duration for each bookable range!

    Cheers,

    Ben

    • A
      Con Schneider

      Hi Ben,

      Thanks for the feedback!

      For your scenario I would set the hcd to: one hour.

      As for setting custom duration for each bookable range, you can submit that request to the WooCommerce Bookings ideas board.

      Take care!

      • Thanks Con.

        Actually, it was listed back on the Ideas Board and has ’85 Votes’. It was listed in 2014, with interest since.

        http://ideas.woocommerce.com/forums/133476-woocommerce/suggestions/5949342-update-the-bookings-plugin-for-more-flexibility-at

        Do you have any idea when it might be applied? Basically it is the difference between us using this plugin and using another one. We’d prefer to use yours!

        Cheers,

        Ben

        • A
          Con Schneider

          Thanks for pointing out the link to ideas board, I was not aware of that ;). I left a link to this post, hopefully some people can benefit of it.

          I cannot tell you an ETA for features such as this. WooCommerce Bookings is hugely complex and I am not in the position to know what features get added to the roadmap.

          I assume that a feature must ramp up three digit votes, before it gets considered, but that is just me.

          Cheers,
          Con

Leave your comment