| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /** |
| 3 | 3 | * Front-End Render (Booking form, Calendar) |
| 4 | 4 | * |
| @@ -52,11 +52,12 @@ | ||
| 52 | 52 | 'start_month_calendar' => false, |
| 53 | 53 | 'shortcode_param__options' => '', |
| 54 | 54 | 'calendar_dates_start' => '', |
| 55 | 55 | 'calendar_dates_end' => '', |
| 56 | - 'booking_hash' => '', | |
| 57 | - 'form_status' => 'published', | |
| 58 | - 'calendar_request_overrides' => array(), | |
| 56 | + 'booking_hash' => '', | |
| 57 | + 'form_status' => 'published', | |
| 58 | + 'booking_workflow' => 'classic', | |
| 59 | + 'calendar_request_overrides' => array(), | |
| 59 | 60 | ); |
| 60 | 61 | $params_arr = wp_parse_args( $params_arr, $default_params ); |
| 61 | 62 | $is_echo = ( ! empty( $params_arr['is_echo'] ) ); |
| 62 | 63 | |
| @@ -85,16 +86,60 @@ | ||
| 85 | 86 | return self::echo_or_return( $resource_validation, $is_echo ); |
| 86 | 87 | } |
| 87 | 88 | |
| 88 | 89 | // --------------------------------------------------------------------- |
| 89 | - // == MU == | |
| 90 | - // --------------------------------------------------------------------- | |
| 91 | - make_bk_action( 'check_multiuser_params_for_client_side', $params_arr['resource_id'] ); | |
| 92 | - | |
| 93 | - // --------------------------------------------------------------------- | |
| 90 | + // == MU == | |
| 91 | + // --------------------------------------------------------------------- | |
| 92 | + make_bk_action( 'check_multiuser_params_for_client_side', $params_arr['resource_id'] ); | |
| 93 | + | |
| 94 | + // Render a focused cancellation confirmation instead of loading the complete booking form and calendar. | |
| 95 | + if ( WPBC_GET_Request::has_get( 'booking_cancel' ) && function_exists( 'wpbc_customer_access_render_cancellation_confirmation' ) ) { | |
| 96 | + $booking_hash = sanitize_text_field( wp_unslash( (string) $params_arr['booking_hash'] ) ); | |
| 97 | + if ( '' === $booking_hash ) { | |
| 98 | + $booking_hash = WPBC_GET_Request::get_sanitized( 'booking_hash' ); | |
| 99 | + } | |
| 100 | + | |
| 101 | + $cancellation_html = wpbc_customer_access_render_cancellation_confirmation( $booking_hash, $params_arr['resource_id'] ); | |
| 102 | + | |
| 103 | + /** | |
| 104 | + * Filters the complete visitor cancellation confirmation markup. | |
| 105 | + * | |
| 106 | + * @param string $cancellation_html Rendered confirmation markup. | |
| 107 | + * @param int $resource_id Resource ID used by the front-end form container. | |
| 108 | + * @param string $booking_hash Sanitized booking credential from the cancellation URL. | |
| 109 | + */ | |
| 110 | + $cancellation_html = apply_filters( | |
| 111 | + 'wpbc_customer_booking_cancellation_confirmation_html', | |
| 112 | + $cancellation_html, | |
| 113 | + absint( $params_arr['resource_id'] ), | |
| 114 | + $booking_hash | |
| 115 | + ); | |
| 116 | + | |
| 117 | + // phpcs:ignore WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedHooknameFound | |
| 118 | + $my_result = apply_filters( 'wpdev_booking_form', ' ' . $cancellation_html . ' ', $params_arr['resource_id'] ); | |
| 119 | + | |
| 120 | + make_bk_action( 'finish_check_multiuser_params_for_client_side', $params_arr['resource_id'] ); | |
| 121 | + | |
| 122 | + return self::echo_or_return( $my_result, $is_echo ); | |
| 123 | + } | |
| 124 | + | |
| 125 | + // --------------------------------------------------------------------- | |
| 94 | 126 | // Normalize calendar_dates_start/end. |
| 95 | 127 | // --------------------------------------------------------------------- |
| 96 | - $calendar_dates_range = WPBC_FE_Attr_Postprocessor::normalize_calendar_dates_range( $params_arr['calendar_dates_start'], $params_arr['calendar_dates_end'] ); | |
| 128 | + $calendar_dates_range = WPBC_FE_Attr_Postprocessor::normalize_calendar_dates_range( $params_arr['calendar_dates_start'], $params_arr['calendar_dates_end'] ); | |
| 129 | + $classic_booking_context_token = ''; | |
| 130 | + if ( function_exists( 'wpbc_classic_booking_context_encode' ) ) { | |
| 131 | + $classic_booking_context_token = wpbc_classic_booking_context_encode( | |
| 132 | + array( | |
| 133 | + 'booking_workflow' => $params_arr['booking_workflow'], | |
| 134 | + 'resource_id' => $params_arr['resource_id'], | |
| 135 | + 'calendar_dates_start' => $calendar_dates_range['start'], | |
| 136 | + 'calendar_dates_end' => $calendar_dates_range['end'], | |
| 137 | + 'custom_form' => $params_arr['custom_booking_form'], | |
| 138 | + 'aggregate_resource_ids' => $aggregate_resource_id_arr, | |
| 139 | + ) | |
| 140 | + ); | |
| 141 | + } | |
| 97 | 142 | |
| 98 | 143 | // --------------------------------------------------------------------- |
| 99 | 144 | // Calendar load params (keep identical keys). |
| 100 | 145 | // --------------------------------------------------------------------- |
| @@ -105,11 +150,12 @@ | ||
| 105 | 150 | 'calendar_number_of_months' => $params_arr['cal_count'], |
| 106 | 151 | 'start_month_calendar' => $params_arr['start_month_calendar'], |
| 107 | 152 | 'shortcode_options' => $params_arr['shortcode_param__options'], |
| 108 | 153 | 'custom_form' => $params_arr['custom_booking_form'], |
| 109 | - 'calendar_dates_start' => $calendar_dates_range['start'], | |
| 110 | - 'calendar_dates_end' => $calendar_dates_range['end'], | |
| 111 | - 'calendar_request_overrides' => $params_arr['calendar_request_overrides'], | |
| 154 | + 'calendar_dates_start' => $calendar_dates_range['start'], | |
| 155 | + 'calendar_dates_end' => $calendar_dates_range['end'], | |
| 156 | + 'classic_booking_context_token' => $classic_booking_context_token, | |
| 157 | + 'calendar_request_overrides' => $params_arr['calendar_request_overrides'], | |
| 112 | 158 | ); |
| 113 | 159 | |
| 114 | 160 | $start_script_code = wpbc__calendar__load( $calendar_load_params ); |
| 115 | 161 | |