function trav_ajax_acc_check_room_availability() { if (!isset($_POST['_wpnonce']) || !isset($_POST['booking_no']) || !wp_verify_nonce($_POST['_wpnonce'], 'booking-' . $_POST['booking_no'])) { $result_json['success'] = 0; $result_json['result'] = __('Sorry, your nonce did not verify.', 'trav'); wp_send_json($result_json); } if (!isset($_POST['date_from']) || !isset($_POST['date_to']) || trav_strtotime($_POST['date_from']) >= trav_strtotime($_POST['date_to'])) { $result_json['success'] = 0; $result_json['result'] = __('Wrong Date Interval. Please check your dates.', 'trav'); wp_send_json($result_json); } global $wpdb; $booking_no = sanitize_text_field($_POST['booking_no']); $pin_code = sanitize_text_field($_POST['pin_code']); if (!($booking_data = trav_acc_get_booking_data($booking_no, $pin_code))) { $result_json['success'] = 0; $result_json['result'] = __('Wrong booking number and pin code.', 'trav'); wp_send_json($result_json); } $booking_data['date_from'] = trav_sanitize_date($_POST['date_from']); $booking_data['date_to'] = trav_sanitize_date($_POST['date_to']); $booking_data['rooms'] = sanitize_text_field($_POST['rooms']); $booking_data['adults'] = sanitize_text_field($_POST['adults']); $booking_data['kids'] = sanitize_text_field($_POST['kids']); $booking_data['child_ages'] = $_POST['child_ages']; $room_price_data = trav_acc_get_room_price_data($booking_data['accommodation_id'], $booking_data['room_type_id'], $booking_data['date_from'], $booking_data['date_to'], $booking_data['rooms'], $booking_data['adults'], $booking_data['kids'], $booking_data['child_ages'], $booking_no, $pin_code); if (!$room_price_data || !is_array($room_price_data)) { $result_json['success'] = 0; $result_json['result'] = __('The room is not available for the selected date, rooms and person. Please have another look at booking fields.', 'trav'); wp_send_json($result_json); } else { $tax_rate = get_post_meta($booking_data['accommodation_id'], 'trav_accommodation_tax_rate', true); $tax = 0; if (!empty($tax_rate)) { $tax = $tax_rate * $room_price_data['total_price'] / 100; } $total_price = $room_price_data['total_price'] + $tax; $return_html = '<dl class="other-details">'; $return_html .= '<dt class="feature">' . esc_html(trav_get_day_interval($booking_data['date_from'], $booking_data['date_to'])) . ' ' . __('night Stay', 'trav') . ':</dt><dd class="value">' . esc_html(trav_get_price_field($room_price_data['total_price'])) . '</dd>'; if (!empty($tax_rate)) { $return_html .= '<dt class="feature">' . __('taxes and fees', 'trav') . ':</dt><dd class="value">' . esc_html(trav_get_price_field($tax)) . '</dd>'; } $return_html .= '<dt class="feature">' . __('Total Price', 'trav') . '</dt><dd>' . esc_html(trav_get_price_field($total_price)) . '</dd>'; $return_html .= '</dl>'; $result_json['success'] = 1; $result_json['result'] = $return_html; wp_send_json($result_json); } }
</article> <h4><?php _e('Other Details', 'trav'); ?> </h4> <dl class="other-details"> <dt class="feature"><?php _e('Room Type', 'trav'); ?> :</dt><dd class="value"><?php echo esc_html(get_the_title($booking_data['room_type_id'])); ?> </dd> <dt class="feature"><?php echo esc_html(trav_get_day_interval($booking_data['date_from'], $booking_data['date_to']) . ' ' . __('night Stay', 'trav')); ?> :</dt><dd class="value"><?php echo esc_html(trav_get_price_field($room_price_data['total_price'])); ?> </dd> <?php if (!empty($tax_rate)) { ?> <dt class="feature"><?php echo __('taxes and fees', 'trav'); ?> :</dt><dd class="value"><?php echo esc_html(trav_get_price_field($tax)); ?> </dd>