← All changes
|
includes/booking-appointment/ajax/booking-appointment__resolve.php
+15
-0
11.7
→
11.9
View file →
| @@ -28,8 +28,23 @@ | ||
| 28 | 28 | if ( is_wp_error( $config ) ) { |
| 29 | 29 | wp_send_json_error( array( 'message' => $config->get_error_message(), 'code' => $config->get_error_code() ), 400 ); |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | + $is_preview_request = ! empty( $config['return_url'] ) && false !== strpos( (string) $config['return_url'], 'wpbc_bfb_preview=' ); | |
| 33 | + if ( $is_preview_request ) { | |
| 34 | + $preview_activated = class_exists( 'WPBC_BFB_Preview_Service' ) | |
| 35 | + && WPBC_BFB_Preview_Service::get_instance()->activate_appointment_preview_from_url( $config['return_url'] ); | |
| 36 | + if ( ! $preview_activated ) { | |
| 37 | + wp_send_json_error( | |
| 38 | + array( | |
| 39 | + 'message' => __( 'This booking form preview expired. Refresh the preview and try again.', 'booking' ), | |
| 40 | + 'code' => 'appointment_preview_expired', | |
| 41 | + ), | |
| 42 | + 403 | |
| 43 | + ); | |
| 44 | + } | |
| 45 | + } | |
| 46 | + | |
| 32 | 47 | $service_id = isset( $_POST['service_id'] ) && ! is_array( $_POST['service_id'] ) ? absint( wp_unslash( $_POST['service_id'] ) ) : 0; |
| 33 | 48 | $provider_id = isset( $_POST['provider_id'] ) && ! is_array( $_POST['provider_id'] ) ? absint( wp_unslash( $_POST['provider_id'] ) ) : 0; |
| 34 | 49 | $result = wpbc_booking_appointment_resolve_stage( $config, $service_id, $provider_id ); |
| 35 | 50 | if ( is_wp_error( $result ) ) { |