Exemplo n.º 1
0
 function trav_tour_get_special_tours($type = 'latest', $count = 10, $exclude_ids = array(), $country = '', $city = '', $tour_type = array())
 {
     $args = array('post_type' => 'tour', 'suppress_filters' => 0, 'posts_per_page' => $count);
     if (!empty($country)) {
         if (is_numeric($country)) {
             $args['meta_query'][] = array('key' => 'trav_tour_country', 'value' => $country);
         } else {
             $term = get_term_by('name', $country, 'location');
             if ($term) {
                 $country = $term->term_id;
                 $args['meta_query'][] = array('key' => 'trav_tour_country', 'value' => $country);
             }
         }
     }
     if (!empty($city)) {
         if (is_numeric($city)) {
             $args['meta_query'][] = array('key' => 'trav_tour_city', 'value' => $city);
         } else {
             $term = get_term_by('name', $city, 'location');
             if ($term) {
                 $city = $term->term_id;
                 $args['meta_query'][] = array('key' => 'trav_tour_city', 'value' => $city);
             }
         }
     }
     if (!empty($exclude_ids)) {
         $args['post__not_in'] = $exclude_ids;
     }
     if (!empty($tour_type)) {
         $args['tax_query'] = array(array('taxonomy' => 'tour_type', 'field' => 'term_id', 'terms' => $tour_type));
     }
     if ($type == 'featured') {
         $args = array_merge($args, array('orderby' => 'rand', 'meta_key' => 'trav_tour_featured', 'meta_value' => '1'));
         return get_posts($args);
     } elseif ($type == 'latest') {
         $args = array_merge($args, array('orderby' => 'post_date', 'order' => 'DESC'));
         return get_posts($args);
     } elseif ($type == 'popular') {
         global $wpdb;
         $tbl_postmeta = esc_sql($wpdb->prefix . 'postmeta');
         $tbl_terms = esc_sql($wpdb->prefix . 'terms');
         $tbl_term_taxonomy = esc_sql($wpdb->prefix . 'term_taxonomy');
         $tbl_term_relationships = esc_sql($wpdb->prefix . 'term_relationships');
         $date = date('Y-m-d', strtotime('-30 days'));
         $sql = 'SELECT tour_id, COUNT(*) AS booking_count FROM ' . TRAV_TOUR_BOOKINGS_TABLE . ' AS booking';
         $where = ' WHERE (booking.status <> 0) AND (booking.created > %s)';
         if (!empty($country)) {
             $sql .= " INNER JOIN {$tbl_postmeta} AS meta_c1 ON (meta_c1.meta_key = 'trav_tour_country') AND (booking.tour_id = meta_c1.post_id)";
             $where .= " AND meta_c1.meta_value like '%%{$country}%%'";
         }
         if (!empty($city)) {
             $sql .= " INNER JOIN {$tbl_postmeta} AS meta_c1 ON (meta_c1.meta_key = 'trav_tour_city') AND (booking.tour_id = meta_c1.post_id)";
             $where .= " AND meta_c1.meta_value like '%%{$city}%%'";
         }
         if (!empty($tour_type)) {
             $sql .= " INNER JOIN {$tbl_term_relationships} AS tr ON tr.object_id = t1.tour_id \n\t\t\t\t\t\tINNER JOIN {$tbl_term_taxonomy} AS tt ON tt.term_taxonomy_id = tr.term_taxonomy_id";
             $where .= " AND tt.taxonomy = 'tour_type' AND tt.term_id IN (" . esc_sql(implode(',', $tour_type)) . ")";
         }
         $sql .= $where . ' GROUP BY booking.tour_id ORDER BY booking_count desc LIMIT %d';
         $popular_tours = $wpdb->get_results($wpdb->prepare($sql, $date, $count));
         $result = array();
         if (!empty($popular_tours)) {
             foreach ($popular_tours as $tour) {
                 $result[] = get_post(trav_tour_clang_id($tour->tour_id));
             }
         }
         // if booked room number in last month is smaller than count then add latest tours
         if (count($popular_tours) < $count) {
             foreach ($popular_tours as $tour) {
                 $exclude_ids[] = trav_tour_clang_id($tour->tour_id);
             }
             $result = array_merge($result, trav_tour_get_special_tours('latest', $count - count($popular_tours), $exclude_ids, $country, $city, $tour_type));
         }
         return $result;
     }
 }
<?php

/**
 * Tour Booking Confirmation Template
 */
global $trav_options, $wpdb, $logo_url;
global $booking_data, $tour_id, $st_id, $deposit_rate;
if (!isset($_REQUEST['booking_no']) || !isset($_REQUEST['pin_code'])) {
    do_action('trav_tour_conf_wrong_data');
    exit;
}
if (!($booking_data = trav_tour_get_booking_data($_REQUEST['booking_no'], $_REQUEST['pin_code']))) {
    do_action('trav_tour_conf_wrong_data');
    exit;
}
$tour_id = trav_tour_clang_id($booking_data['tour_id']);
$st_id = $booking_data['st_id'];
$deposit_rate = get_post_meta($tour_id, 'trav_tour_security_deposit', true);
$deposit_rate = empty($deposit_rate) ? 0 : $deposit_rate;
$tour_date = trav_tophptime($booking_data['tour_date']);
// if deposit is required and it is not paid process payment
if (!empty($deposit_rate) && empty($booking_data['deposit_paid'])) {
    // init payment variables
    $ItemName = '';
    if ($deposit_rate < 100) {
        $ItemName = sprintf(__('Deposit(%d%%) for ', 'trav'), $deposit_rate);
    } else {
        $ItemName = __('Deposit for ', 'trav');
    }
    $ItemName .= get_the_title($tour_id) . ' ' . trav_tour_get_schedule_type_title($tour_id, $st_id);
    $payment_data = array();
Exemplo n.º 3
0
    function trav_tour_get_tour_list_sigle($tour_id, $list_style, $before_article = '', $after_article = '', $show_badge = false, $animation = '')
    {
        echo wp_kses_post($before_article);
        $tour_id = trav_tour_clang_id($tour_id);
        $min_price = get_post_meta($tour_id, 'trav_tour_min_price', true);
        $brief = get_post_meta($tour_id, 'trav_tour_brief', true);
        if (empty($brief)) {
            $brief = apply_filters('the_content', get_post_field('post_content', $tour_id));
            $brief = wp_trim_words($brief, 20, '');
        }
        $discount_rate = get_post_meta($tour_id, 'trav_tour_discount_rate', true);
        $url = get_permalink($tour_id);
        $duration = trav_tour_get_tour_duration($tour_id);
        if ($list_style == "style1") {
            ?>

			<article class="box">
				<figure <?php 
            echo wp_kses_post($animation);
            ?>
>
					<a title="<?php 
            _e('View Photo Gallery', 'trav');
            ?>
" class="hover-effect popup-gallery" data-post_id="<?php 
            echo esc_attr($tour_id);
            ?>
" href="#"><?php 
            echo get_the_post_thumbnail($tour_id, 'biggallery-thumb');
            ?>
</a>
					<?php 
            if (!empty($discount_rate)) {
                ?>
						<span class="discount"><span class="discount-text"><?php 
                echo esc_html($discount_rate . '%' . ' ' . __('Discount', 'trav'));
                ?>
</span></span>
					<?php 
            }
            ?>
				</figure>
				<div class="details">
					<?php 
            if (!empty($min_price) && is_numeric($min_price)) {
                ?>
						<span class="price"><?php 
                echo esc_html(trav_get_price_field($min_price));
                ?>
</span>
					<?php 
            }
            ?>
					<h4 class="box-title"><a href="<?php 
            echo esc_url($url);
            ?>
"><?php 
            echo esc_html(get_the_title($tour_id));
            ?>
</a></h4>
					<hr>
					<div class="description"><?php 
            echo wp_kses_post($brief);
            ?>
</div>
					<hr>
					<div class="text-center">
						<div class="time">
							<i class="soap-icon-clock yellow-color"></i>
							<span><?php 
            echo esc_html($duration);
            ?>
</span>
						</div>
					<div class="action">
						<a title="<?php 
            _e('View Detail', 'trav');
            ?>
" class="button btn-small full-width" href="<?php 
            echo esc_url($url);
            ?>
"><?php 
            _e('BOOK NOW', 'trav');
            ?>
</a>
					</div>
				</div>
			</article>
		<?php 
        } elseif ($list_style == "style2") {
            ?>
			<article class="box">
				<?php 
            if (!empty($discount_rate)) {
                ?>
					<span class="discount"><span class="discount-text"><?php 
                echo esc_html($discount_rate . '%' . ' ' . __('Discount', 'trav'));
                ?>
</span></span>
				<?php 
            }
            ?>
				<figure <?php 
            echo wp_kses_post($animation);
            ?>
>
					<a href="<?php 
            echo esc_url($url);
            ?>
"><?php 
            echo get_the_post_thumbnail($tour_id, 'biggallery-thumb');
            ?>
</a>
					<figcaption>
						<?php 
            if (!empty($min_price) && is_numeric($min_price)) {
                ?>
							<span class="price"><?php 
                echo esc_html(trav_get_price_field($min_price));
                ?>
</span>
						<?php 
            }
            ?>
						<h2 class="caption-title"><?php 
            echo esc_html(get_the_title($tour_id));
            ?>
</h2>
					</figcaption>
				</figure>
			</article>
		<?php 
        } elseif ($list_style == "style3") {
            ?>

			<article class="box">
				<figure class="col-sm-5 col-md-4">
					<a title="<?php 
            _e('View Photo Gallery', 'trav');
            ?>
" class="hover-effect popup-gallery" data-post_id="<?php 
            echo esc_attr($tour_id);
            ?>
" href="#"><?php 
            echo get_the_post_thumbnail($tour_id, 'biggallery-thumb');
            ?>
</a>
					<?php 
            if ($show_badge && !empty($discount_rate)) {
                ?>
						<span class="discount"><span class="discount-text"><?php 
                echo esc_html($discount_rate . '%' . ' ' . __('Discount', 'trav'));
                ?>
</span></span>
					<?php 
            }
            ?>
				</figure>
				<div class="details col-sm-7 col-md-8">
					<div>
						<div>
							<h4 class="box-title"><a href="<?php 
            echo esc_url($url);
            ?>
"><?php 
            echo esc_html(get_the_title($tour_id));
            ?>
</a><small><i class="soap-icon-clock yellow-color"></i> <?php 
            echo esc_html($duration);
            ?>
</small></h4>
						</div>
						<div>
							<span class="price"><small><?php 
            _e('per person', 'trav');
            ?>
</small><?php 
            echo esc_html(trav_get_price_field($min_price));
            ?>
</span>
						</div>
					</div>
					<div>
						<?php 
            echo wp_kses_post($brief);
            ?>
						<div>
							<a title="<?php 
            _e('View Detail', 'trav');
            ?>
" class="button btn-small full-width text-center" href="<?php 
            echo esc_url($url);
            ?>
"><?php 
            _e('BOOK NOW', 'trav');
            ?>
</a>
						</div>
					</div>
				</div>
			</article>
		<?php 
        }
        echo wp_kses_post($after_article);
    }
Exemplo n.º 4
0
<?php

/*
 * Accommodation List
 */
global $tour_list, $current_view, $before_article, $after_article, $date_from, $date_to;
foreach ($tour_list as $tour) {
    $tour_id = is_numeric($tour) ? $tour : $tour->tour_id;
    $tour_id = trav_tour_clang_id($tour_id);
    /*$duration = date( 'd M Y', strtotime( $tour->min_date ) );
    	if ( $tour->min_date != $tour->max_date ) $duration .= ' - ' . date( 'd M Y', strtotime( $tour->max_date ) );*/
    $discount_rate = get_post_meta($tour_id, 'trav_tour_discount_rate', true);
    $duration = trav_tour_get_tour_duration($tour_id);
    $min_price = get_post_meta($tour_id, 'trav_tour_min_price', true);
    $brief = get_post_meta($tour_id, 'trav_tour_brief', true);
    if (empty($brief)) {
        $brief = apply_filters('the_content', get_post_field('post_content', $tour_id));
        $brief = wp_trim_words($brief, 20, '');
    }
    $query_args = array('date_from' => $date_from, 'date_to' => $date_to);
    $url = esc_url(add_query_arg($query_args, get_permalink($tour_id)));
    echo $before_article;
    if ($current_view == 'grid') {
        ?>

		<article class="box">
			<figure>
				<a title="<?php 
        _e('View Photo Gallery', 'trav');
        ?>
" class="hover-effect popup-gallery" data-post_id="<?php