PluginProbe
Booking Calendar / 11.9
Booking Calendar v11.9
11.9 11.8.4 11.8.3 11.8.2 11.8.1 11.8 11.7 11.6.1 11.6 11.5 11.4.3 11.4.2 11.4.1 11.4 11.3 11.2.1 11.2 11.1 11.0 10.15.7 10.15.6 10.1.3 10.10 10.10.1 10.10.2 All 205 releases
← All changes | includes/booking-appointment/ajax/booking-appointment__validate-time.php +15 -3 11.8 → 11.9 View file →
@@ -93,12 +93,13 @@
93 93 * @param string[] $dates Selected SQL dates.
94 94 * @param string $start_time Strict browser time value.
95 95 * @param int $maximum_duration Maximum allowed duration in minutes.
96 96 * @param array<int,array<string,int>> $existing_intervals Existing Provider intervals.
97 + * @param int $provider_id Provider resource ID.
97 98 *
98 99 * @return array<string,mixed> Public, non-sensitive validation result.
99 100 */
100 -function wpbc_booking_appointment_validate_one_start_time( $service, $dates, $start_time, $maximum_duration, $existing_intervals ) {
101 +function wpbc_booking_appointment_validate_one_start_time( $service, $dates, $start_time, $maximum_duration, $existing_intervals, $provider_id = 0 ) {
101 102 $start_seconds = wpbc_booking_appointment_get_preflight_start_seconds( $start_time );
102 103 if ( is_wp_error( $start_seconds ) ) {
103 104 return array( 'valid' => false, 'message' => $start_seconds->get_error_message(), 'code' => $start_seconds->get_error_code() );
104 105 }
@@ -107,8 +108,19 @@
107 108 if ( is_wp_error( $end_seconds ) ) {
108 109 return array( 'valid' => false, 'message' => $end_seconds->get_error_message(), 'code' => $end_seconds->get_error_code() );
109 110 }
110 111
112 + $working_time_check = wpbc_appointment_services_check_working_time( $service, $provider_id, $dates, array( $start_seconds, $end_seconds ) );
113 + if ( is_wp_error( $working_time_check ) ) {
114 + return array(
115 + 'valid' => false,
116 + 'message' => $working_time_check->get_error_message(),
117 + 'code' => $working_time_check->get_error_code(),
118 + 'start_time' => sanitize_text_field( $start_time ),
119 + 'end_time' => wpbc_transform__seconds__in__24_hours_his( $end_seconds ),
120 + );
121 + }
122 +
111 123 $buffer_check = wpbc_appointment_services_check_buffer_conflicts_in_intervals( $service, $dates, array( $start_seconds, $end_seconds ), $existing_intervals );
112 124 if ( is_wp_error( $buffer_check ) ) {
113 125 return array(
114 126 'valid' => false,
@@ -170,9 +182,9 @@
170 182 }
171 183
172 184 $slots = array();
173 185 foreach ( $start_times as $start_time ) {
174 - $slots[ $start_time ] = wpbc_booking_appointment_validate_one_start_time( $service, $dates, $start_time, $maximum_duration, $existing_intervals );
186 + $slots[ $start_time ] = wpbc_booking_appointment_validate_one_start_time( $service, $dates, $start_time, $maximum_duration, $existing_intervals, $provider_id );
175 187 }
176 188 wp_send_json_success(
177 189 array(
178 190 'valid' => true,
@@ -184,9 +196,9 @@
184 196 );
185 197 }
186 198
187 199 $start_time = isset( $_POST['start_time'] ) && ! is_array( $_POST['start_time'] ) ? sanitize_text_field( wp_unslash( $_POST['start_time'] ) ) : '';
188 - $result = wpbc_booking_appointment_validate_one_start_time( $service, $dates, $start_time, $maximum_duration, $existing_intervals );
200 + $result = wpbc_booking_appointment_validate_one_start_time( $service, $dates, $start_time, $maximum_duration, $existing_intervals, $provider_id );
189 201 if ( empty( $result['valid'] ) ) {
190 202 wp_send_json_success( $result );
191 203 }
192 204