static function get_avg_price_hotel($hotel_id) { global $wpdb; $rooms = self::_getAllRoomHotelID($hotel_id); $avg_price = 0; $check_in = STInput::request('start', ''); $check_out = STInput::request('end', ''); if (empty($check_in)) { $check_in = date('m/d/Y'); } else { $check_in = TravelHelper::convertDateFormat($check_in); } if (empty($check_out)) { $check_out = date('m/d/Y', strtotime("+1 day")); } else { $check_out = TravelHelper::convertDateFormat($check_out); } $room_num_search = STInput::request('room_num_search', 1); if (intval($room_num_search) <= 0) { $room_num_search = 1; } $room_full_ordered = HotelHelper::_get_room_cant_book_by_id($hotel_id, date('Y-m-d', strtotime($check_in)), date('Y-m-d', strtotime($check_out)), $room_num_search); if (is_array($rooms) && count($rooms)) { $i = 0; foreach ($rooms as $room) { if (!in_array($room, $room_full_ordered)) { $price = STPrice::getRoomPriceOnlyCustomPrice($room, strtotime($check_in), strtotime($check_out), $room_num_search); if ($price > 0) { $avg_price += $price; } } $i++; } $avg_price /= $i; } return $avg_price; }
" type="text" class="form-control" name="coupon_code"> </div> <button class="btn btn-primary" type="submit"><?php _e('Apply Coupon', ST_TEXTDOMAIN); ?> </button> </form> </div> <div class="booking-item-payment-total text-right"> <?php $price = floatval(get_post_meta($room_id, 'price', true)); $number_room = intval($item['number']); $numberday = TravelHelper::dateDiff($check_in, $check_out); $origin_price = STPrice::getRoomPriceOnlyCustomPrice($room_id, strtotime($check_in), strtotime($check_out), $number_room); $sale_price = STPrice::getRoomPrice($room_id, strtotime($check_in), strtotime($check_out), $number_room); $extra_price = isset($item['data']['extra_price']) ? floatval($item['data']['extra_price']) : 0; $price_with_tax = STPrice::getPriceWithTax($sale_price + $extra_price); ?> <table border="0" class="table_checkout"> <tr> <td class="text-left title"> <?php echo __('Origin Price', ST_TEXTDOMAIN); ?> <?php $include_tax = STPrice::checkIncludeTax(); if ($include_tax) { echo '(' . __('tax included', ST_TEXTDOMAIN) . ')'; }
</div> <div class="col-md-3"> <?php $start = TravelHelper::convertDateFormat(STInput::request('start')); $end = TravelHelper::convertDateFormat(STInput::request('end')); $numberday = TravelHelper::dateDiff($start, $end); $is_search_room = STInput::request('is_search_room'); ?> <?php if ($start and $end and $is_search_room) { ?> <?php $room_id = get_the_ID(); $room_num_search = intval(STInput::request('room_num_search', 1)); $sale_price = STPrice::getRoomPrice($room_id, strtotime($start), strtotime($end), $room_num_search); $total_price = STPrice::getRoomPriceOnlyCustomPrice($room_id, strtotime($start), strtotime($end), $room_num_search); ?> <?php if ($sale_price < $total_price) { ?> <span class="text-lg onsale mr20"> <?php echo TravelHelper::format_money($total_price); ?> </span> <br /> <?php } ?> <span class="booking-item-price"> <?php
function _add_booking() { if (!check_admin_referer('shb_action', 'shb_field')) { die; } $data = $this->_check_validate(); if (is_array($data) && count($data)) { extract($data); $order = array('post_title' => __('Order', ST_TEXTDOMAIN) . ' - ' . date(get_option('date_format')) . ' @ ' . date(get_option('time_format')), 'post_type' => 'st_order', 'post_status' => 'publish'); $order_id = wp_insert_post($order); if ($order_id) { $check_out_field = STCart::get_checkout_fields(); if (!empty($check_out_field)) { foreach ($check_out_field as $field_name => $field_desc) { update_post_meta($order_id, $field_name, STInput::post($field_name)); } } $id_user = get_current_user_id(); update_post_meta($order_id, 'id_user', $id_user); update_post_meta($order_id, 'payment_method', 'st_submit_form'); $item_price = floatval(get_post_meta($room_id, 'price', true)); $origin_price = STPrice::getRoomPriceOnlyCustomPrice($room_id, strtotime($check_in), strtotime($check_out), $room_num_search); //Extra price $extras = STInput::request('extra_price', array()); $numberday = TravelHelper::dateDiff($check_in, $check_out); $extra_price = STPrice::getExtraPrice($extras, $room_num_search, $numberday); $sale_price = STPrice::getRoomPrice($room_id, strtotime($check_in), strtotime($check_out), $room_num_search); $price_with_tax = STPrice::getPriceWithTax($sale_price + $extra_price); $deposit_money['data'] = array(); $deposit_money = STPrice::getDepositData($room_id, $deposit_money); if (!empty($deposit_money['data']['deposit_money'])) { $data_deposit_money = $deposit_money['data']['deposit_money']; } else { $data_deposit_money = ""; } $deposit_price = STPrice::getDepositPrice($data_deposit_money, $price_with_tax, 0); if (isset($deposit_money['data']['deposit_money'])) { $total_price = $deposit_price; } else { $total_price = $price_with_tax; } $data_prices = array('origin_price' => $origin_price, 'sale_price' => $sale_price, 'coupon_price' => 0, 'price_with_tax' => $price_with_tax, 'total_price' => $total_price, 'deposit_price' => $deposit_price); $item_data = array('item_number' => $room_num_search, 'item_id' => $item_id, 'item_price' => $item_price, 'check_in' => date('Y-m-d', strtotime($check_in)), 'check_out' => date('Y-m-d', strtotime($check_out)), 'adult_number' => $adult_number, 'child_number' => $child_number, 'room_id' => $room_id, 'total_price' => $total_price, 'deposit_money' => $data_deposit_money, 'booking_by' => 'admin', 'st_tax' => STPrice::getTax(), 'st_tax_percent' => STPrice::getTax(), 'status' => $_POST['status'], 'data_prices' => $data_prices, 'extras' => $extras, 'extra_price' => $extra_price, 'currency' => TravelHelper::get_current_currency('symbol'), 'currency_rate' => TravelHelper::get_current_currency('rate'), 'commission' => TravelHelper::get_commission()); foreach ($item_data as $val => $value) { update_post_meta($order_id, $val, $value); } do_action('st_booking_success', $order_id); //Check email $user_name = STInput::post('st_email'); $user_id = email_exists($user_name); if (!$user_id and email_exists($user_name) == false or $user_id == false) { $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false); $userdata = array('user_login' => $user_name, 'user_pass' => $random_password, 'user_email' => $user_name, 'first_name' => STInput::post('st_first_name'), 'last_name' => STInput::post('st_last_name')); $user_id = wp_insert_user($userdata); //Create User Success, send the nofitication wp_new_user_notification($user_id); } if (TravelHelper::checkTableDuplicate('st_hotel')) { global $wpdb; $table = $wpdb->prefix . 'st_order_item_meta'; $g_post = get_post($item_id); $partner_id = $g_post ? $g_post->post_author : ''; global $sitepress; if ($sitepress) { $post_type = get_post_type($st_booking_id); if ($post_type == 'st_hotel') { $post_type = 'hotel_room'; $id = $room_id; } else { $id = $st_booking_id; } $lang_code = $sitepress->get_default_language(); $origin_id = icl_object_id($id, $post_type, true, $lang_code); } else { $origin_id = $st_booking_id; } $data = array('order_item_id' => $order_id, 'type' => 'normal_booking', 'check_in' => $check_in, 'check_out' => $check_out, 'st_booking_post_type' => 'st_hotel', 'st_booking_id' => $item_id, 'room_id' => $room_id, 'adult_number' => $adult_number, 'child_number' => $child_number, 'room_num_search' => $room_num_search, 'check_in_timestamp' => strtotime($check_in), 'check_out_timestamp' => strtotime($check_out), 'user_id' => $id_user, 'status' => $_POST['status'], 'wc_order_id' => $order_id, 'partner_id' => $partner_id, 'created' => get_the_date('Y-m-d', $order_id), 'total_order' => $total_price, 'commission' => TravelHelper::get_commission(), 'origin_id' => $origin_id); $wpdb->insert($table, $data); } STCart::send_mail_after_booking($order_id, true); STCart::send_email_confirm($order_id); wp_safe_redirect(self::$booking_page); } } else { return false; } }
if (!isset($_REQUEST['check_in'])) { $check_in = date('m/d/Y', strtotime("now")); } else { $check_in = TravelHelper::convertDateFormat(STInput::request('check_in')); } if (!isset($_REQUEST['check_out'])) { $check_out = date('m/d/Y', strtotime("+1 day")); } else { $check_out = TravelHelper::convertDateFormat(STInput::request('check_out')); } $room_num_search = STInput::request('room_num_search'); if (!isset($room_num_search) || intval($room_num_search) <= 0) { $room_num_search = 1; } $room_id = get_the_ID(); $total_price = STPrice::getRoomPriceOnlyCustomPrice($room_id, strtotime($check_in), strtotime($check_out), $room_num_search); $default = array('align' => 'right'); if (isset($attr)) { extract(wp_parse_args($attr, $default)); } else { extract($default); } $room_id = get_the_ID(); $item_id = get_post_meta(get_the_ID(), 'room_parent', true); $booking_period = intval(get_post_meta($item_id, 'hotel_booking_period', TRUE)); $numberday = TravelHelper::dateDiff($check_in, $check_out); $extra_price = get_post_meta(get_the_ID(), 'extra_price', true); $external = STRoom::get_external_url(); ?> <div class="hotel-room-form"> <!-- <div class="overlay-form"><i class="fa fa-refresh text-color"></i></div> -->