Exemple #1
0
 * Hotel loop room
 *
 * Created by ShineTheme
 *
 */
global $wp_query;
$post = STInput::request();
$post['room_parent'] = get_the_ID();
$hotel = new STHotel();
query_posts($hotel->search_room($post));
?>
    <ul class="booking-list loop-room">
        <?php 
if (have_posts()) {
    while (have_posts()) {
        the_post();
        echo st()->load_template('hotel/elements/loop-room-item');
    }
} else {
    echo st()->load_template('hotel/elements/loop-room-none');
}
?>

    </ul>
<div class="div_paged_room">
    <?php 
echo TravelHelper::paging_room();
?>
</div>
<?php 
wp_reset_query();
Exemple #2
0
 function ajax_search_room()
 {
     if (st_is_ajax() and STInput::post('room_search')) {
         if (!wp_verify_nonce(STInput::post('room_search'), 'room_search')) {
             $result = array('status' => 0, 'data' => "");
             echo json_encode($result);
             die;
         }
         $result = array('status' => 1, 'data' => "");
         $hotel_id = get_the_ID();
         $post = STInput::request();
         $post['room_parent'] = $hotel_id;
         //Check Date
         $today = date('m/d/Y');
         $check_in = TravelHelper::convertDateFormat($post['start']);
         $check_out = TravelHelper::convertDateFormat($post['end']);
         $date_diff = TravelHelper::dateDiff($check_in, $check_out);
         $booking_period = intval(get_post_meta($hotel_id, 'hotel_booking_period', TRUE));
         $period = TravelHelper::dateDiff($today, $check_in);
         if ($booking_period && $period < $booking_period) {
             $result = array('status' => 0, 'data' => st()->load_template('hotel/elements/loop-room-none'), 'message' => sprintf(__('This hotel allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period));
             echo json_encode($result);
             die;
         }
         if ($date_diff < 1) {
             $result = array('status' => 0, 'data' => "", 'message' => __('Make sure your check-out date is at least 1 day after check-in.', ST_TEXTDOMAIN), 'more-data' => $date_diff);
             echo json_encode($result);
             die;
         }
         add_filter('posts_where', array($this, '_alter_search_query_ajax'));
         $page = STInput::request('paged_room');
         if (!$page) {
             $page = get_query_var('paged_room');
         }
         $arg = array('post_type' => 'hotel_room', 'posts_per_page' => '10', 'paged' => $page, 'meta_query' => array(array('key' => 'room_parent', 'value' => $hotel_id, 'compare' => 'IN')));
         query_posts($arg);
         remove_filter('posts_where', array($this, '_alter_search_query_ajax'));
         global $wp_query;
         if (have_posts()) {
             while (have_posts()) {
                 the_post();
                 $result['data'] .= st()->load_template('hotel/elements/loop-room-item');
             }
         } else {
             $result['data'] .= st()->load_template('hotel/elements/loop-room-none');
         }
         $result['paging'] = TravelHelper::paging_room();
         wp_reset_query();
         echo json_encode($result);
         die;
     }
 }