コード例 #1
0
 function ct_tour_check_availability($post_id, $date = '', $adults = 1, $kids = 0)
 {
     // validation
     if (empty($post_id) || 'tour' != get_post_type($post_id)) {
         return esc_html__('Invalide Tour ID.', 'citytours');
     }
     //invalid data
     $max_people = get_post_meta($post_id, '_tour_max_people', true);
     if (empty($max_people)) {
         return true;
     }
     // max people empty means no limit
     $is_repeated = get_post_meta($post_id, '_tour_repeated', true);
     $post_id = esc_sql(ct_tour_org_id($post_id));
     if (!empty($is_repeated) && !ct_strtotime($date)) {
         return esc_html__('Invalid date. Please check your booking date again.', 'citytours');
         //invalid data
     }
     global $wpdb;
     $where = "1=1";
     $where .= " AND tour_id=" . $post_id;
     if (!empty($is_repeated)) {
         $where .= " AND tour_date='" . esc_sql(date('Y-m-d', ct_strtotime($date))) . "'";
     }
     $sql = "SELECT COUNT(*) FROM " . CT_TOUR_BOOKINGS_TABLE . " WHERE {$where}";
     $booked_count = $wpdb->get_var($sql);
     if ($booked_count + $adults < $max_people) {
         return true;
     } elseif ($booked_count >= $max_people) {
         return esc_html__('Sold Out', 'citytours');
     } else {
         return sprintf(esc_html__('Exceed Persons. Only %d persons available', 'citytours'), $max_people - $booked_count);
     }
 }
コード例 #2
0
        function prepare_items()
        {
            global $wpdb;
            $per_page = 10;
            $columns = $this->get_columns();
            $hidden = array();
            $sortable = $this->get_sortable_columns();
            $this->_column_headers = array($columns, $hidden, $sortable);
            $this->process_bulk_action();
            $orderby = !empty($_REQUEST['orderby']) ? sanitize_sql_orderby($_REQUEST['orderby']) : 'id';
            //If no sort, default to title
            $order = !empty($_REQUEST['order']) ? sanitize_text_field($_REQUEST['order']) : 'desc';
            //If no order, default to desc
            $current_page = $this->get_pagenum();
            $post_table_name = esc_sql($wpdb->prefix . 'posts');
            $where = "1=1";
            $where .= " AND CT_Orders.post_type='tour'";
            if (!empty($_REQUEST['post_id'])) {
                $where .= " AND CT_Orders.post_id = '" . esc_sql(ct_tour_org_id($_REQUEST['post_id'])) . "'";
            }
            if (!empty($_REQUEST['date'])) {
                $where .= " AND CT_Orders.date_from = '" . esc_sql($_REQUEST['date']) . "'";
            }
            if (!empty($_REQUEST['booking_no'])) {
                $where .= " AND CT_Orders.booking_no = '" . esc_sql($_REQUEST['booking_no']) . "'";
            }
            if (isset($_REQUEST['status'])) {
                $where .= " AND CT_Orders.status = '" . esc_sql($_REQUEST['status']) . "'";
            }
            if (!current_user_can('manage_options')) {
                $where .= " AND tour.post_author = '" . get_current_user_id() . "' ";
            }
            $sql = $wpdb->prepare('SELECT CT_Orders.*, tour.ID as post_id, tour.post_title as tour_name FROM %1$s as CT_Orders
						INNER JOIN %2$s as tour ON CT_Orders.post_id=tour.ID
						WHERE ' . $where . ' ORDER BY %3$s %4$s
						LIMIT %5$s, %6$s', CT_ORDER_TABLE, $post_table_name, $orderby, $order, $per_page * ($current_page - 1), $per_page);
            $data = $wpdb->get_results($sql, ARRAY_A);
            $sql = sprintf('SELECT COUNT(*) FROM %1$s as CT_Orders INNER JOIN %2$s as tour ON CT_Orders.post_id=tour.ID WHERE %3$s', CT_ORDER_TABLE, $post_table_name, $where);
            $total_items = $wpdb->get_var($sql);
            $this->items = $data;
            $this->set_pagination_args(array('total_items' => $total_items, 'per_page' => $per_page, 'total_pages' => ceil($total_items / $per_page)));
        }
コード例 #3
0
            ?>
				</div>
			</div>

			<hr>
			<?php 
        }
        ?>

			<?php 
        global $ct_options;
        if (!empty($ct_options['tour_review'])) {
            $review_fields = !empty($ct_options['tour_review_fields']) ? explode(",", $ct_options['tour_review_fields']) : array("Position", "Comfort", "Price", "Quality");
            $review = get_post_meta(ct_tour_org_id($post_id), '_review', true);
            $review = round(!empty($review) ? (double) $review : 0, 1);
            $review_detail = get_post_meta(ct_tour_org_id($post_id), '_review_detail', true);
            if (!empty($review_detail)) {
                $review_detail = is_array($review_detail) ? $review_detail : unserialize($review_detail);
            } else {
                $review_detail = array_fill(0, count($review_fields), 0);
            }
            ?>
				<div class="row">
					<div class="col-md-3">
						<h3><?php 
            echo esc_html__('Reviews', 'citytours');
            ?>
</h3>
						<a href="#" class="btn_1 add_bottom_15" data-toggle="modal" data-target="#myReview"><?php 
            echo esc_html__('Leave a review', 'citytours');
            ?>
コード例 #4
0
			<div class="wishlist">
				<a class="tooltip_flip tooltip-effect-1 btn-add-wishlist" href="#" data-post-id="<?php 
    echo esc_attr($post_id);
    ?>
"<?php 
    echo in_array(ct_tour_org_id($post_id), $wishlist) ? ' style="display:none;"' : '';
    ?>
><span class="wishlist-sign">+</span><span class="tooltip-content-flip"><span class="tooltip-back"><?php 
    esc_html_e('Add to wishlist', 'citytours');
    ?>
</span></span></a>
				<a class="tooltip_flip tooltip-effect-1 btn-remove-wishlist" href="#" data-post-id="<?php 
    echo esc_attr($post_id);
    ?>
"<?php 
    echo !in_array(ct_tour_org_id($post_id), $wishlist) ? ' style="display:none;"' : '';
    ?>
><span class="wishlist-sign">-</span><span class="tooltip-content-flip"><span class="tooltip-back"><?php 
    esc_html_e('Remove from wishlist', 'citytours');
    ?>
</span></span></a>
			</div>
			<?php 
}
?>
			<div class="img_list">
				<a href="<?php 
echo esc_url(get_permalink($post_id));
?>
">
					<!-- <div class="ribbon popular" ></div> -->