<?php

get_header();
BYT_Theme_Utils::breadcrumbs();
get_sidebar('under-header');
global $post, $byt_theme_globals, $current_user, $car_rental_obj, $entity_obj, $default_car_rental_tabs, $score_out_of_10, $byt_car_rentals_post_type, $byt_theme_of_custom;
$enable_reviews = $byt_theme_globals->enable_reviews();
$enable_cruises = $byt_theme_globals->enable_cruises();
$car_rental_extra_fields = $byt_theme_globals->get_car_rental_extra_fields();
$tab_array = $byt_theme_globals->get_car_rental_tabs();
$price_decimal_places = $byt_theme_globals->get_price_decimal_places();
$default_currency_symbol = $byt_theme_globals->get_default_currency_symbol();
$show_currency_symbol_after = $byt_theme_globals->show_currency_symbol_after();
if (have_posts()) {
    the_post();
    $car_rental_obj = new byt_car_rental($post);
    $entity_obj = $car_rental_obj;
    $price_per_day = $car_rental_obj->get_custom_field('price_per_day');
    $car_rental_location = $car_rental_obj->get_location();
    $pick_up_location_title = '';
    if ($car_rental_location) {
        $pick_up_location_title = $car_rental_location->get_title();
    }
    ?>
	<script>
		window.postType = 'car_rental';
	</script>
<?php 
    get_template_part('includes/parts/inquiry', 'form');
    ?>
	<!--car rental three-fourth content-->
Beispiel #2
0
<?php

global $post, $car_rental_class, $display_mode, $byt_theme_globals, $byt_car_rentals_post_type;
$car_rental_id = $post->ID;
$car_rental_obj = new byt_car_rental($post);
$car_rental_image = $car_rental_obj->get_main_image();
if (empty($car_rental_image)) {
    $car_rental_image = BYT_Theme_Utils::get_file_uri('/images/uploads/img.jpg');
}
$price_decimal_places = $byt_theme_globals->get_price_decimal_places();
$default_currency_symbol = $byt_theme_globals->get_default_currency_symbol();
$show_currency_symbol_after = $byt_theme_globals->show_currency_symbol_after();
$price_per_day = $car_rental_obj->get_custom_field('price_per_day');
if (empty($display_mode) || $display_mode == 'card') {
    ?>
<!--car rental-->
<article class="car_rental_item <?php 
    echo $car_rental_class;
    ?>
">
	<div>
		<figure>
			<a href="<?php 
    echo esc_url($car_rental_obj->get_permalink());
    ?>
" title="<?php 
    echo esc_attr($car_rental_obj->get_title());
    ?>
">
				<img src="<?php 
    echo esc_url($car_rental_image);
 function book_car_rental_ajax_request()
 {
     global $byt_car_rentals_post_type, $byt_theme_globals, $byt_theme_woocommerce;
     $enc_key = $byt_theme_globals->get_enc_key();
     $add_captcha_to_forms = $byt_theme_globals->add_captcha_to_forms();
     if (isset($_REQUEST)) {
         $nonce = $_REQUEST['nonce'];
         if (wp_verify_nonce($nonce, 'byt-ajax-nonce')) {
             $first_name = isset($_REQUEST['first_name']) ? wp_kses($_REQUEST['first_name'], '') : '';
             $last_name = isset($_REQUEST['last_name']) ? wp_kses($_REQUEST['last_name'], '') : '';
             $email = isset($_REQUEST['email']) ? wp_kses($_REQUEST['email'], '') : '';
             $phone = isset($_REQUEST['phone']) ? wp_kses($_REQUEST['phone'], '') : '';
             $address = isset($_REQUEST['address']) ? wp_kses($_REQUEST['address'], '') : '';
             $town = isset($_REQUEST['town']) ? wp_kses($_REQUEST['town'], '') : '';
             $zip = isset($_REQUEST['zip']) ? wp_kses($_REQUEST['zip'], '') : '';
             $country = isset($_REQUEST['country']) ? wp_kses($_REQUEST['country'], '') : '';
             $special_requirements = isset($_REQUEST['requirements']) ? wp_kses($_REQUEST['requirements'], '') : '';
             $date_from = isset($_REQUEST['date_from']) ? wp_kses($_REQUEST['date_from'], '') : '';
             $date_from = date('Y-m-d', strtotime($date_from));
             $date_to = isset($_REQUEST['date_to']) ? wp_kses($_REQUEST['date_to'], '') : '';
             $date_to = date('Y-m-d', strtotime($date_to));
             $car_rental_id = isset($_REQUEST['car_rental_id']) ? intval(wp_kses($_REQUEST['car_rental_id'], '')) : 0;
             $drop_off = isset($_REQUEST['drop_off']) ? intval(wp_kses($_REQUEST['drop_off'], '')) : '';
             $c_val_s = isset($_REQUEST['c_val_s']) ? intval(wp_kses($_REQUEST['c_val_s'], '')) : 0;
             $c_val_1 = isset($_REQUEST['c_val_1']) ? intval(BYT_Theme_Utils::decrypt(wp_kses($_REQUEST['c_val_1'], ''), $enc_key)) : 0;
             $c_val_2 = isset($_REQUEST['c_val_2']) ? intval(BYT_Theme_Utils::decrypt(wp_kses($_REQUEST['c_val_2'], ''), $enc_key)) : 0;
             // nonce passed ok
             $car_rental_obj = new byt_car_rental($car_rental_id);
             if ($car_rental_obj != null) {
                 if ($add_captcha_to_forms && $c_val_s != $c_val_1 + $c_val_2) {
                     echo 'captcha_error';
                     die;
                 } else {
                     $drop_off_location_obj = new byt_location($drop_off);
                     $drop_off_location_title = $drop_off_location_obj->get_title();
                     $car_rental_location = $car_rental_obj->get_location();
                     $pick_up_location_title = '';
                     if ($car_rental_location) {
                         $pick_up_location_title = $car_rental_location->get_title();
                     }
                     $price_per_day = floatval($car_rental_obj->get_custom_field('price_per_day'));
                     $datediff = strtotime($date_to) - strtotime($date_from);
                     $days = floor($datediff / (60 * 60 * 24));
                     $total_price = $price_per_day * $days;
                     $current_user = wp_get_current_user();
                     $booking_id = $byt_car_rentals_post_type->create_car_rental_booking($first_name, $last_name, $email, $phone, $address, $town, $zip, $country, $special_requirements, $date_from, $date_to, $car_rental_id, $current_user->ID, $total_price, $drop_off);
                     $is_reservation_only = get_post_meta($car_rental_id, 'car_rental_is_reservation_only', true);
                     $use_woocommerce_for_checkout = $byt_theme_globals->use_woocommerce_for_checkout();
                     if (BYT_Theme_Utils::is_woocommerce_active() && !$is_reservation_only) {
                         if ($use_woocommerce_for_checkout) {
                             $product_id = $byt_theme_woocommerce->woocommerce_create_product($car_rental_obj->get_title(), '', 'ACC_' . $car_rental_id . '_', $booking_id, $total_price, BOOKYOURTRAVEL_WOO_PRODUCT_CAT_CAR_RENTALS);
                             echo $product_id;
                         }
                     } else {
                         echo $booking_id;
                     }
                     if (!$use_woocommerce_for_checkout || !BYT_Theme_Utils::is_woocommerce_active()) {
                         // only send email if we are not proceeding to WooCommerce checkout or if woocommerce is not active at all.
                         $admin_email = get_bloginfo('admin_email');
                         $admin_name = get_bloginfo('name');
                         $headers = "From: {$admin_name} <{$admin_email}>\n";
                         $subject = __('New car rental booking', 'bookyourtravel');
                         $message = __("New car rental booking: \n\nFirst name: %s \n\nLast name: %s \n\nEmail: %s \n\nPhone: %s \n\nAddress: %s \n\nTown: %s \n\nZip: %s \n\nCountry: %s \n\nSpecial requirements: %s \n\nDate from: %s \n\nDate to: %s \n\nPick up: %s \n\nDrop off: %s \n\nTotal price: %d \n\nCar: %s \n", 'bookyourtravel');
                         $message = sprintf($message, $first_name, $last_name, $email, $phone, $address, $town, $zip, $country, $special_requirements, $date_from, $date_to, $pick_up_location_title, $drop_off_location_title, $total_price, $car_rental_obj->get_title());
                         wp_mail($email, $subject, $message, $headers);
                         $contact_email = get_post_meta($car_rental_id, 'car_rental_contact_email', true);
                         $contact_emails = explode(';', $contact_email);
                         if (empty($contact_email)) {
                             $contact_emails = array($admin_email);
                         }
                         foreach ($contact_emails as $e) {
                             if (!empty($e)) {
                                 wp_mail($e, $subject, $message, $headers);
                             }
                         }
                     }
                 }
             }
         }
     }
     // Always die in functions echoing ajax content
     die;
 }