当前位置: 首页>>代码示例>>PHP>>正文


PHP BYT_Theme_Utils::get_dates_from_range方法代码示例

本文整理汇总了PHP中BYT_Theme_Utils::get_dates_from_range方法的典型用法代码示例。如果您正苦于以下问题:PHP BYT_Theme_Utils::get_dates_from_range方法的具体用法?PHP BYT_Theme_Utils::get_dates_from_range怎么用?PHP BYT_Theme_Utils::get_dates_from_range使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BYT_Theme_Utils的用法示例。


在下文中一共展示了BYT_Theme_Utils::get_dates_from_range方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: update_car_rental_booking

 function update_car_rental_booking($booking_id, $first_name, $last_name, $email, $phone, $address, $town, $zip, $country, $special_requirements, $date_from, $date_to, $car_rental_id, $user_id, $total_price, $drop_off_location_id)
 {
     global $wpdb;
     // We are actually (in terms of db data) looking for date 1 day before the to date.
     // E.g. when you look to book a room from 19.12. to 20.12 you will be staying 1 night, not 2.
     // The same goes for cars.
     $date_to = date('Y-m-d', strtotime($date_to . ' -1 day'));
     // delete previous days from table
     $sql = "DELETE FROM " . BOOKYOURTRAVEL_CAR_RENTAL_BOOKING_DAYS_TABLE . "\r\n\t\t\t\tWHERE car_rental_booking_id = %d ";
     $wpdb->query($wpdb->prepare($sql, $booking_id));
     $sql = "UPDATE " . BOOKYOURTRAVEL_CAR_RENTAL_BOOKINGS_TABLE . "\r\n\t\t\t\tSET first_name = %s,\r\n\t\t\t\tlast_name = %s,\r\n\t\t\t\temail = %s, \r\n\t\t\t\tphone = %s, \r\n\t\t\t\taddress = %s, \r\n\t\t\t\ttown = %s, \r\n\t\t\t\tzip = %s, \r\n\t\t\t\tcountry = %s, \r\n\t\t\t\tspecial_requirements = %s,\r\n\t\t\t\tcar_rental_id = %d, \r\n\t\t\t\tuser_id = %d, \r\n\t\t\t\ttotal_price = %f, \r\n\t\t\t\tdrop_off = %d\r\n\t\t\t\tWHERE Id=%d";
     $wpdb->query($wpdb->prepare($sql, $first_name, $last_name, $email, $phone, $address, $town, $zip, $country, $special_requirements, $car_rental_id, $user_id, $total_price, $drop_off_location_id, $booking_id));
     $dates = BYT_Theme_Utils::get_dates_from_range($date_from, $date_to);
     foreach ($dates as $date) {
         $sql = "INSERT INTO " . BOOKYOURTRAVEL_CAR_RENTAL_BOOKING_DAYS_TABLE . "\r\n\t\t\t\t\t(car_rental_booking_id, booking_date)\r\n\t\t\t\t\tVALUES\r\n\t\t\t\t\t(%d, %s);";
         $wpdb->query($wpdb->prepare($sql, $booking_id, $date));
     }
     return $booking_id;
 }
开发者ID:alikris,项目名称:OTA,代码行数:19,代码来源:car_rentals.php

示例2: calculate_total_price

 function calculate_total_price($accommodation_id, $room_type_id, $date_from, $date_to, $room_count, $adults, $children)
 {
     global $wpdb;
     $accommodation_id = BYT_Theme_Utils::get_default_language_post_id($accommodation_id, 'accommodation');
     if ($room_type_id > 0) {
         $room_type_id = BYT_Theme_Utils::get_default_language_post_id($room_type_id, 'room_type');
     }
     $accommodation_is_price_per_person = get_post_meta($accommodation_id, 'accommodation_is_price_per_person', true);
     $accommodation_count_children_stay_free = get_post_meta($accommodation_id, 'accommodation_count_children_stay_free', true);
     $accommodation_count_children_stay_free = isset($accommodation_count_children_stay_free) ? intval($accommodation_count_children_stay_free) : 0;
     $children = $children - $accommodation_count_children_stay_free;
     $children = $children > 0 ? $children : 0;
     // we are actually (in terms of db data) looking for date 1 day before the to date
     // e.g. when you look to book a room from 19.12. to 20.12 you will be staying 1 night, not 2
     $date_to = date('Y-m-d', strtotime($date_to . ' -1 day'));
     $dates = BYT_Theme_Utils::get_dates_from_range($date_from, $date_to);
     $total_price = 0;
     foreach ($dates as $date) {
         $date = date('Y-m-d', strtotime($date));
         $price_per_day = $this->get_accommodation_price($date, $accommodation_id, $room_type_id, false);
         $child_price_per_day = $this->get_accommodation_price($date, $accommodation_id, $room_type_id, true);
         if ($accommodation_is_price_per_person) {
             $total_price += ($adults * $price_per_day + $children * $child_price_per_day) * $room_count;
         } else {
             $total_price += $price_per_day * $room_count;
         }
     }
     $total_price = $total_price * $room_count;
     return $total_price;
 }
开发者ID:alikris,项目名称:OTA,代码行数:30,代码来源:accommodations.php


注:本文中的BYT_Theme_Utils::get_dates_from_range方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。