static function get_info_price($post_id = null, $date_start = false, $date_end = false) { if (!$post_id) { $post_id = get_the_ID(); } $price_origin = get_post_meta($post_id, 'cars_price', true); $list_price = array(); $price = $price_origin; $is_custom_price = get_post_meta($post_id, 'is_custom_price', true); if (empty($is_custom_price)) { $is_custom_price = 'price_by_number'; } /////////////////////////////////////// /////////// Price By Date ///////////// /////////////////////////////////////// if ($is_custom_price == 'price_by_number') { if (!empty($date_start) and !empty($date_end)) { $price = self::get_rental_price_by_number_of_day_or_hour($post_id, $price_origin, $date_start, $date_end); } else { $price = $price_origin; } } /////////////////////////////////////// /////////// Price By Date ///////////// /////////////////////////////////////// if ($is_custom_price == 'price_by_date') { if (!empty($date_start) and !empty($date_end)) { $unit = st()->get_option('cars_price_unit', 'day'); if ($unit == 'day') { $one_day = 60 * 60 * 24; } elseif ($unit == 'hour') { $one_day = 60 * 60; } $total = 0; $str_start_date = $date_start; $str_end_date = $date_end; $number_days = STCars::get_date_diff($str_start_date, $str_end_date); for ($i = 1; $i <= $number_days; $i++) { $data_date = date("Y-m-d", $str_start_date + $one_day * $i - $one_day); $tmp_date = date("Y-m-d H:i:s", $str_start_date + $one_day * $i - $one_day); $price_tmp = TravelerObject::st_get_custom_price_by_date($post_id, $data_date); if (empty($price_tmp)) { $price_tmp = $price; } $is_sale = STPrice::_check_car_sale_schedule_by_date($post_id, $data_date); if (!empty($is_sale)) { $price_tmp = $price_tmp - $price_tmp * ($is_sale / 100); } $list_price[$data_date] = array('start' => $tmp_date, 'end' => $tmp_date, 'price' => apply_filters('st_apply_tax_amount', $price_tmp)); $total += $price_tmp; } } else { $price = TravelerObject::st_get_custom_price_by_date($post_id); if (empty($price)) { $price = $price_origin; } } } $discount = get_post_meta($post_id, 'discount', true); $is_sale_schedule = get_post_meta($post_id, 'is_sale_schedule', true); if ($is_sale_schedule == 'on') { $sale_from = get_post_meta($post_id, 'sale_price_from', true); $sale_to = get_post_meta($post_id, 'sale_price_to', true); if ($sale_from and $sale_from) { $today = date('Y-m-d'); $sale_from = date('Y-m-d', strtotime($sale_from)); $sale_to = date('Y-m-d', strtotime($sale_to)); if ($today >= $sale_from && $today <= $sale_to) { } else { $discount = 0; } } else { $discount = 0; } } if ($discount) { if ($discount > 100) { $discount = 100; } $new_price = $price - $price / 100 * $discount; } else { $new_price = $price; } $data = array('price' => apply_filters('st_apply_tax_amount', $new_price), 'price_origin' => apply_filters('st_apply_tax_amount', $price_origin), 'discount' => $discount, 'is_custom_price' => $is_custom_price, 'list_price' => $list_price); return apply_filters('st_car_info_price', $data, $post_id); }