예제 #1
0
 function add_validate_fields($validate)
 {
     if ($this->check_is_car_booking()) {
         $validator = new STValidate();
         $validator->set_rules(array(array('field' => 'driver_name', 'label' => 'Driver\'s Name', 'rules' => 'required|trim|strip_tags'), array('field' => 'driver_age', 'label' => 'Driver\'s Age', 'rules' => 'required|trim|strip_tags')));
         if (!$validator->run()) {
             $validate = false;
             STTemplate::set_message($validator->error_string(), 'danger');
         }
     }
     return $validate;
 }
예제 #2
0
 function _add_cart_check_available($post_id = false, $data = array())
 {
     if (!$post_id or get_post_status($post_id) != 'publish') {
         STTemplate::set_message(__('Rental doese not exists', ST_TEXTDOMAIN), 'danger');
         return false;
     }
     $validator = new STValidate();
     $validator->set_rules('start', __('Check in', ST_TEXTDOMAIN), 'required');
     $validator->set_rules('end', __('Check out', ST_TEXTDOMAIN), 'required');
     if (!$validator->run()) {
         STTemplate::set_message($validator->error_string(), 'danger');
         return false;
     }
     $check_in = date('Y-m-d H:i:s', strtotime(STInput::post('start')));
     $check_out = date('Y-m-d H:i:s', strtotime(STInput::post('end')));
     if (!$this->_is_slot_available($post_id, $check_in, $check_out)) {
         STTemplate::set_message(__('Sorry! This rental is not available.', ST_TEXTDOMAIN), 'danger');
         return false;
     }
     return true;
 }
예제 #3
0
 /**
  *
  *
  * @return Bool
  *
  * */
 static function validate_checkout_fields()
 {
     $fields = self::get_checkout_fields();
     $result = true;
     $validator = new STValidate();
     if (is_array($fields) and !empty($fields)) {
         foreach ($fields as $key => $value) {
             $default = array('label' => '', 'placeholder' => '', 'class' => array('form-control'), 'type' => 'text', 'size' => 6, 'icon' => '', 'validate' => '');
             $value = wp_parse_args($value, $default);
             if ($value['validate']) {
                 $validator->set_rules($key, $value['label'], $value['validate']);
             }
         }
     }
     $result = $validator->run();
     if (!$result) {
         STTemplate::set_message($validator->error_string(), 'danger');
     }
     return $result;
 }