Bookings Snippets: Tips and Tweaks

In this document, you will find many useful snippets for customizing the functionality of Bookings.

To use a snippet, you can copy the contained code into your child theme’s functions.php file.

Important: These snippets are customizations provided “as is”, with no guarantee. We do our best to offer advice and direct you to the appropriate resources, but we are unable to provide support for customizations under our Support Policy. If you are unfamiliar with code/templates and resolving potential conflicts, please contact a WooExpert.

Contents

  • Make calendar default to first available booking
  • Modify the date in a booking’s summary
  • Modify when In Cart bookings expire
  • Enable Big Selects to fix MAX_JOIN_SIZE errors
  • Automatically confirm bookings purchased via COD
  • Show Dependencies tab for Bookable products with WooCommerce Product Dependencies

Examples

 Make calendar default to first available booking

By default the current month will be shown on the Bookings calendar for performance reasons. This will default it to the month with the first available block:

Modify the date in a booking’s summary

A booking’s date in its summary is able to be modified with the wc_bookings_summary_list_date filter. This filter passes three arguments, the original date string, the timestamp for the start, and the timestamp for the end.

This example will modify the date so that only the start date is returned for the summary:


Modify when In Cart bookings expire

When bookings are added to the cart, they are immediately created. This allows for blocks to be properly reserved on the calendar. By default, these bookings expire after 60 minutes and are deleted by a WP Cron event.

The woocommerce_bookings_remove_inactive_cart_time filter allows you to increase or decrease this time. The example below reduces the time to 30 minutes:

Note: If this time is reduced to just a few minutes, then it is possible a booking may be removed from a customer’s cart before they complete checkout. The lowest recommended time is 15 minutes.

Enable Big Selects to fix MAX_JOIN_SIZE errors

Sometimes shared hosts have a low threshold for MAX_JOIN_SIZE, which causes problems with WooCommerce Bookings and WordPress in general. This example fixes that in most cases:

Automatically confirm bookings purchased via COD

When an order is placed for a booking via COD it remains in Unpaid status. Some store owners may want to have these bookings moved to Confirmed status, this example will do that:

Show Dependencies tab for Bookable products with WooCommerce Product Dependencies

WooCommerce Product Dependencies is a great little extension that allows you to require one product if another is purchased. In order to get the Dependencies tab to show for Bookable products, a filter needs to be used:

 

Leave a Reply

Your email address will not be published. Required fields are marked *