Skip to content
Advertisement

Add a select field with time intervals based on opening, closing and breaks times in WooCommerce checkout

I am building pizza delivery website with WooCommerce. In fact when customer is checking out, he can select when he want to have food delivered.

The select box should contain 15 minute intervals ranging from the current time and clearing all past hours. The first option I want is to be “As soon as possible”, and then the next option is an hour later (rounded to nearest 15mins), and then 15 mins each time.

Our delivery hours are as below:

  • Monday: Closed
  • Tuesday – Friday 11:30 – 14:00 & 17:00 – 22:00
  • Sat & Sun : 13:00 – 22:00

I succesfully WooCommerce action/hook, but I can’t disable all time slots before the current time.

JavaScript

Advertisement

Answer

For your question about the select field you can use the following

Via the $store_times array you can set the opening and closing hours as well as the hours of the break.

If the store is closed all day, leave all settings for that day empty (see monday)

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement