问题概述
当您的预订包含人员且预订人数超过 1 人时,可用性将无法正确调整,导致可用时间段显示错误的可用名额。
临时解决方法
此问题已在 WooCommerce Multilingual & Multicurrency 5.5.2 中修复。 更新即可在您的站点上解决此问题,因此只有在您还无法更新时,才需要此临时解决方法。
我们的开发人员正在努力修复此问题。目前,您可以回退到 WCML 5.5.0,或者前往 /wp-content/plugins/woocommerce-multilingual/compatibility/WcBookings/class-wcml-bookings.php 修补代码。
将代码从:
PHP
$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 );
PHP
$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 );