Exemplo n.º 1
0
 static function ajax_submit_form()
 {
     //Add to cart then submit form
     $item_id = STInput::post('item_id');
     $sc = STInput::request('sc', '');
     if (!$item_id) {
         $name = '';
         if ($sc == 'add-hotel-booking') {
             $name = __('Hotel', ST_TEXTDOMAIN);
         } elseif ($sc == 'add-rental-booking') {
             $name = __('Rental', ST_TEXTDOMAIN);
         } elseif ($sc == 'add-car-booking') {
             $name = __('Car', ST_TEXTDOMAIN);
         } elseif ($sc == 'add-tour-booking') {
             $name = __('Tour', ST_TEXTDOMAIN);
         } elseif ($sc == 'add-holiday-booking') {
             $name = __('Holiday', ST_TEXTDOMAIN);
         } elseif ($sc == 'add-activity-booking') {
             $name = __('Activity', ST_TEXTDOMAIN);
         }
         $return = array('status' => false, 'message' => sprintf(__('Please choose a %s item ', ST_TEXTDOMAIN), $name));
     } else {
         $post_type = get_post_type($item_id);
         $number_room = STInput::post('number_room') ? STInput::post('number_room') : false;
         if (!$number_room) {
             $number_room = STInput::post('room_num_search') ? STInput::post('room_num_search') : 1;
         }
         self::destroy_cart();
         $validate = true;
         switch ($post_type) {
             case "st_hotel":
                 $hotel = new STHotel();
                 $validate = $hotel->do_add_to_cart();
                 break;
             case "st_cars":
                 $car = new STCars();
                 $validate = $car->do_add_to_cart();
                 break;
             case "st_activity":
                 $class = new STActivity();
                 $validate = $class->do_add_to_cart();
                 break;
             case "st_tours":
                 $class = new STTour();
                 $validate = $class->do_add_to_cart();
                 break;
             case "st_holidays":
                 $class = new STHoliday();
                 $validate = $class->do_add_to_cart();
                 break;
             case "st_rental":
                 $class = new STRental();
                 $validate = $class->do_add_to_cart();
                 break;
         }
         if ($validate) {
             $return = self::booking_form_submit($item_id);
         } else {
             $return = array('status' => false, 'message' => STTemplate::get_message_content());
             STTemplate::clear();
         }
     }
     echo json_encode($return);
     die;
 }
Exemplo n.º 2
0
 static function ajax_submit_form()
 {
     //Add to cart then submit form
     $item_id = STInput::post('item_id');
     if (!$item_id) {
         $return = array('status' => false, 'message' => __('Please choose an item', ST_TEXTDOMAIN));
     } else {
         $post_type = get_post_type($item_id);
         $number_room = STInput::post('number_room') ? STInput::post('number_room') : false;
         if (!$number_room) {
             $number_room = STInput::post('room_num_search') ? STInput::post('room_num_search') : 1;
         }
         self::destroy_cart();
         $validate = true;
         switch ($post_type) {
             case "st_hotel":
                 $hotel = new STHotel();
                 $validate = $hotel->do_add_to_cart(array('item_id' => STInput::post('item_id'), 'number_room' => $number_room, 'price' => STInput::post('price'), 'check_in' => STInput::post('check_in'), 'check_out' => STInput::post('check_out'), 'room_num_search' => STInput::post('room_num_search'), 'room_num_config' => STInput::post('room_num_config'), 'room_id' => STInput::post('room_id')));
                 break;
             case "st_cars":
                 $car = new STCars();
                 $validate = $car->do_add_to_cart();
                 break;
             case "st_activity":
                 $class = new STActivity();
                 $validate = $class->do_add_to_cart();
                 break;
             case "st_tours":
                 $class = new STTour();
                 $validate = $class->do_add_to_cart();
                 break;
             case "st_rental":
                 $class = new STRental();
                 $validate = $class->do_add_to_cart();
                 break;
         }
         if ($validate) {
             $return = self::booking_form_submit($item_id);
         } else {
             $return = array('status' => false, 'message' => STTemplate::get_message_content());
             STTemplate::clear();
         }
     }
     echo json_encode($return);
     die;
 }