Skip to content Skip to sidebar

Open

Reported for: WooCommerce Multilingual & Multicurrency 5.5.1

Topic Tags: Bug, Compatibility, WCML

Overview of the issue

When you have a booking with persons and there is more than 1 person for the booking, the availability will not be adjusted properly resulting in wrong available slots to be displayed for the available timeslot.

Workaround

Our developers are working on fixing this. For the time being you can revert to WCML 5.5.0 or you can patch the code by going to /wp-content/plugins/woocommerce-multilingual/compatibility/WcBookings/class-wcml-bookings.php
Adjust the code from:

			$booking_order_ids = [];
			array_walk( $existing_bookings, function ( WC_Booking $booking ) use ( &$booking_order_ids ) {
				/* @phpstan-ignore-next-line */
				$booking_order_ids[] = $booking->get_order_id();
			} );
			$unique_ids = array_unique( $booking_order_ids ); // when blocked, we don't want each N-language variation to occupy one slot

			return count( $unique_ids );

to:

			$booking_person_counts_by_order = [];

			foreach ( $existing_bookings as $booking ) {
				/** @var WC_Booking $booking */
				$order_id = $booking->get_order_id();

				// Skip if already counted this order ID (to avoid double-counting translations)
				if ( isset( $booking_person_counts_by_order[ $order_id ] ) ) {
					continue;
				}

				// Get total persons (sum of all person types for this booking)
				$person_counts = array_sum( $booking->get_person_counts() );

				// Store count by order ID
				$booking_person_counts_by_order[ $order_id ] = $person_counts;
			}

// Return total number of persons across unique orders
			return array_sum( $booking_person_counts_by_order );

2 Responses to “WooCommerce Bookings availability wrong when more than one person is booked”

Leave a Reply

Please stay on topic and be respectful to others. If you need help with issues not related to this post, use our Support Forum to start a chat or submit a ticket.

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>