function do_add_to_cart()
 {
     $pass_validate = true;
     $item_id = STInput::request('item_id', '');
     if ($item_id <= 0 || get_post_type($item_id) != 'st_holidays') {
         STTemplate::set_message(__('This holiday is not available..', ST_TEXTDOMAIN), 'danger');
         $pass_validate = false;
         return false;
     }
     $number = 1;
     $adult_number = intval(STInput::request('adult_number', 1));
     $child_number = intval(STInput::request('child_number', 0));
     $infant_number = intval(STInput::request('infant_number', 0));
     $data['adult_number'] = $adult_number;
     $data['child_number'] = $child_number;
     $data['infant_number'] = $infant_number;
     $max_number = intval(get_post_meta($item_id, 'max_people', true));
     $type_holiday = get_post_meta($item_id, 'type_holiday', true);
     $data['type_holiday'] = $type_holiday;
     $today = date('Y-m-d');
     $check_in = STInput::request('check_in', '');
     $check_out = STInput::request('check_out', '');
     if (!$check_in || !$check_out) {
         STTemplate::set_message(__('Select a holiday in the calendar above.', ST_TEXTDOMAIN), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $compare = TravelHelper::dateCompare($today, $check_in);
     if ($compare < 0) {
         STTemplate::set_message(__('This holiday has expired', ST_TEXTDOMAIN), 'danger');
         $pass_validate = false;
         return false;
     }
     $booking_period = intval(get_post_meta($item_id, 'holidays_booking_period', true));
     $period = TravelHelper::dateDiff($today, $check_in);
     if ($period < $booking_period) {
         STTemplate::set_message(sprintf(__('This holiday allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
         $pass_validate = false;
         return false;
     }
     if ($adult_number + $child_number + $infant_number > $max_number) {
         STTemplate::set_message(sprintf(__('Max of people for this holiday is %d people', ST_TEXTDOMAIN), $max_number), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $holiday_available = HolidayHelper::checkAvailableHoliday($item_id, strtotime($check_in), strtotime($check_out));
     if (!$holiday_available) {
         STTemplate::set_message(__('The check in, check out day is not invalid or this holiday not available.', ST_TEXTDOMAIN), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $free_people = intval(get_post_meta($item_id, 'max_people', true));
     $result = HolidayHelper::_get_free_peple($item_id, strtotime($check_in), strtotime($check_out));
     if (is_array($result) && count($result)) {
         $free_people = intval($result['free_people']);
     }
     if ($free_people < $adult_number + $child_number + $infant_number) {
         STTemplate::set_message(sprintf(__('This holiday only vacant %d people', ST_TEXTDOMAIN), $free_people), 'danger');
         $pass_validate = FALSE;
         return false;
     }
     $data_price = STPrice::getPriceByPeopleHoliday($item_id, strtotime($check_in), strtotime($check_out), $adult_number, $child_number, $infant_number);
     $total_price = $data_price['total_price'];
     $sale_price = STPrice::getSaleHolidaySalePrice($item_id, $total_price, $type_holiday, strtotime($check_in));
     $data['check_in'] = date('m/d/Y', strtotime($check_in));
     $data['check_out'] = date('m/d/Y', strtotime($check_out));
     $people_price = STPrice::getPeoplePrice($item_id, strtotime($check_in), strtotime($check_out));
     $data = wp_parse_args($data, $people_price);
     $data['ori_price'] = $sale_price;
     $data['currency'] = TravelHelper::get_current_currency('symbol');
     $data['currency_rate'] = TravelHelper::get_current_currency('rate');
     $data['currency_pos'] = TravelHelper::get_current_currency('booking_currency_pos');
     $data['commission'] = TravelHelper::get_commission();
     $data['data_price'] = $data_price;
     $data['discount_rate'] = STPrice::get_discount_rate($item_id, strtotime($check_in));
     if ($pass_validate) {
         $data['duration'] = $type_holiday == 'daily_holiday' ? floatval(get_post_meta($item_id, 'duration_day', true)) : '';
         if ($pass_validate) {
             STCart::add_cart($item_id, $number, $sale_price, $data);
         }
     }
     return $pass_validate;
 }
 function _check_validate()
 {
     $data = array();
     $order_item_id = STInput::request('order_item_id', '');
     $st_first_name = STInput::request('st_first_name', '');
     if (empty($st_first_name)) {
         STAdmin::set_message(__('The firstname field is not empty.', ST_TEXTDOMAIN), 'danger');
         return false;
     }
     $st_last_name = STInput::request('st_last_name', '');
     if (empty($st_last_name)) {
         STAdmin::set_message(__('The lastname field is not empty.', ST_TEXTDOMAIN), 'danger');
         return false;
     }
     $st_email = STInput::request('st_email', '');
     if (empty($st_email)) {
         STAdmin::set_message(__('The email field is not empty.', ST_TEXTDOMAIN), 'danger');
         return false;
     }
     $st_phone = STInput::request('st_phone', '');
     if (empty($st_phone)) {
         STAdmin::set_message(__('The phone field is not empty.', ST_TEXTDOMAIN), 'danger');
         return false;
     }
     if (STInput::request('section', '') != 'edit_order_item') {
         $item_id = intval(STInput::request('item_id', ''));
         if ($item_id <= 0 || get_post_type($item_id) != 'st_holidays') {
             STAdmin::set_message(__('The holiday field is not empty.', ST_TEXTDOMAIN), 'danger');
             return false;
         }
         $type_holiday = get_post_meta($item_id, 'type_holiday', true);
         $today = date('Y-m-d');
         $check_in = STInput::request('check_in', '');
         $check_out = STInput::request('check_out', '');
         if (!$check_in || !$check_out) {
             STAdmin::set_message(__('Select a holiday in the calendar above.', ST_TEXTDOMAIN), 'danger');
             $pass_validate = FALSE;
             return false;
         }
         $compare = TravelHelper::dateCompare($today, $check_in);
         if ($compare < 0) {
             STAdmin::set_message(__('This holiday has expired', ST_TEXTDOMAIN), 'danger');
             $pass_validate = false;
             return false;
         }
         $duration = ($type_holiday = 'daily_holiday') ? get_post_meta($item_id, 'duration_day', true) : '';
         $booking_period = intval(get_post_meta($item_id, 'holidays_booking_period', true));
         $period = TravelHelper::dateDiff($today, $check_in);
         if ($period < $booking_period) {
             STAdmin::set_message(sprintf(__('This holiday allow minimum booking is %d day(s)', ST_TEXTDOMAIN), $booking_period), 'danger');
             $pass_validate = false;
             return false;
         }
         $adult_number = intval(STInput::request('adult_number', 1));
         $child_number = intval(STInput::request('child_number', 0));
         $infant_number = intval(STInput::request('infant_number', 0));
         $max_number = intval(get_post_meta($item_id, 'max_people', true));
         if ($adult_number + $child_number + $infant_number > $max_number) {
             STAdmin::set_message(sprintf(__('Max of people for this holiday is %d people', ST_TEXTDOMAIN), $max_number), 'danger');
             return false;
         }
         $holiday_available = HolidayHelper::checkAvailableHoliday($item_id, strtotime($check_in), strtotime($check_out));
         if (!$holiday_available) {
             STAdmin::set_message(__('The check in, check out day is not invalid or this holiday not available.', ST_TEXTDOMAIN), 'danger');
             $pass_validate = FALSE;
             return false;
         }
         $free_people = intval(get_post_meta($item_id, 'max_people', true));
         $result = HolidayHelper::_get_free_peple($item_id, strtotime($check_in), strtotime($check_out), $order_item_id);
         if (is_array($result) && count($result)) {
             $free_people = intval($result['free_people']);
         }
         if ($free_people > $max_number) {
             STAdmin::set_message(sprintf(__('This holiday only vacant %d people', ST_TEXTDOMAIN), $free_people), 'danger');
             $pass_validate = FALSE;
             return false;
         }
         $data['order_item_id'] = $order_item_id;
         $data['item_id'] = $item_id;
         $data['check_in'] = date('m/d/Y', strtotime($check_in));
         $data['check_out'] = date('m/d/Y', strtotime($check_out));
         $data['adult_number'] = $adult_number;
         $data['child_number'] = $child_number;
         $data['infant_number'] = $infant_number;
         $data['type_holiday'] = $type_holiday;
         $data['duration'] = $duration;
         $people_price = STPrice::getPeoplePrice($item_id, strtotime($check_in), strtotime($check_out));
         $data = wp_parse_args($data, $people_price);
     }
     return $data;
 }