Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

How to disable Check-in / Check-out on selected weekdays for multiple day bookings with WooCommerce

Disable weekdays for multiple day bookings with WooCommerce - WooCommerce Booking and Appointment Plugin

In the WooCommerce Booking & Appointment plugin, we have multiple day booking since version 1.1 of the plugin (July 26 2013). But until some time back, the plugin was not allowing to disable weekdays for check-in and check-out calendar of the bookable product. For example, some customers want that Saturdays and Sundays should not be enabled in the check-in calendar. Or some customers may want that a particular weekday should be disabled on check-out calendar.

To provide a solution for this, we have introduced a filter named as bkap_block_weekdays in the plugin from version 2.4.3 ( November 27 2015 ). This filter opens the door for the store owner to disable certain weekdays in the check-in and check-out calendars of their bookable products.

How to use this filter on your store?

You have to add the function to be executed on the filter in your active theme’s “functions.php” file or in any other file / plugin. You can add it as given in below example:

add_filter( ‘bkap_block_weekdays’, ‘block_weekdays’, 10, 1 );

function block_weekdays( $block_weekdays ) {

// Disable the Sunday for check-in and check-out calendar.
$block_weekdays[‘checkin’][] = ‘sunday’;
$block_weekdays[‘checkout’][] = ‘sunday’;

return $block_weekdays;
}

Once you add the above code in your file, it will disable Sundays from the check-in and check-out calendars of the bookable products. This filter returns a multi-dimensional array with the calendar name as key & the sub-array of the weekdays which need to be disabled.

Once the above filter is implemented, your calendar will appear as shown below:
Disable weekdays for multiple day bookings with WooCommerce - Sundays disabled

Please note that the calendar name in the array key has to be ‘checkin’ for the check-in calendar & ‘checkout’ for the check-out calendar without any leading or trailing spaces.

Is it possible to disable the weekdays for any 1 calendar only (either check-in or check-out, but not both)?

Yes, it is possible to disable check-in or check-out calendar weekdays individually. By referring to the above example, you have to mention the calendar name and its respective weekdays which need to be disabled for it. You can remove the array assignment for the calendar where you don’t need to disable any weekdays.

You can also disable weekdays for both the calendars, as mentioned in above example.

Conclusion:

That’s it. Using the above solution, you can disable the weekdays for multiple days booking method with the WooCommerce Booking & Appointment plugin.

We have a lot more hooks and filters which can be helpful for various such needs. You can view the full list here.

Browse more in: Documentation, How Tos, Tutorials, WooCommerce, WooCommerce Booking & Appointment

Share It:

Subscribe
Notify of
0 Comments
Newest
Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x