Схема
protected mixed
validateForm (
)
Аргументы
| Аргумент |
Возможный тип |
Описание |
|
У метода нет аргументов
|
Описание
Метод пока еще не документирован.
Исходный код
if (!$this->user->hasPermission('modify', 'sale/order')) {
$this->error['warning'] = $this->language->get('error_permission');
}
if ((utf8_strlen($this->request->post['firstname']) < 1) || (utf8_strlen($this->request->post['firstname']) > 32)) {
$this->error['firstname'] = $this->language->get('error_firstname');
}
if ((utf8_strlen($this->request->post['lastname']) < 1) || (utf8_strlen($this->request->post['lastname']) > 32)) {
$this->error['lastname'] = $this->language->get('error_lastname');
}
if ((utf8_strlen($this->request->post['email']) > 96) || (!preg_match('/^[^\@]+@.*\.[a-z]{2,6}$/i', $this->request->post['email']))) {
$this->error['email'] = $this->language->get('error_email');
}
if ((utf8_strlen($this->request->post['telephone']) < 3) || (utf8_strlen($this->request->post['telephone']) > 32)) {
$this->error['telephone'] = $this->language->get('error_telephone');
}
if ((utf8_strlen($this->request->post['payment_firstname']) < 1) || (utf8_strlen($this->request->post['payment_firstname']) > 32)) {
$this->error['payment_firstname'] = $this->language->get('error_firstname');
}
if ((utf8_strlen($this->request->post['payment_lastname']) < 1) || (utf8_strlen($this->request->post['payment_lastname']) > 32)) {
$this->error['payment_lastname'] = $this->language->get('error_lastname');
}
if ((utf8_strlen($this->request->post['payment_address_1']) < 3) || (utf8_strlen($this->request->post['payment_address_1']) > 128)) {
$this->error['payment_address_1'] = $this->language->get('error_address_1');
}
if ((utf8_strlen($this->request->post['payment_city']) < 3) || (utf8_strlen($this->request->post['payment_city']) > 128)) {
$this->error['payment_city'] = $this->language->get('error_city');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->post['payment_country_id']);
if ($country_info) {
if ($country_info['postcode_required'] && (utf8_strlen($this->request->post['payment_postcode']) < 2) || (utf8_strlen($this->request->post['payment_postcode']) > 10)) {
$this->error['payment_postcode'] = $this->language->get('error_postcode');
}
// VAT Validation
$this->load->helper('vat');
if ($this->config->get('config_vat') && $this->request->post['payment_tax_id'] && (vat_validation($country_info['iso_code_2'], $this->request->post['payment_tax_id']) == 'invalid')) {
$this->error['payment_tax_id'] = $this->language->get('error_vat');
}
}
if ($this->request->post['payment_country_id'] == '') {
$this->error['payment_country'] = $this->language->get('error_country');
}
if (!isset($this->request->post['payment_zone_id']) || $this->request->post['payment_zone_id'] == '') {
$this->error['payment_zone'] = $this->language->get('error_zone');
}
if (!isset($this->request->post['payment_method']) || $this->request->post['payment_method'] == '') {
$this->error['payment_method'] = $this->language->get('error_payment');
}
// Check if any products require shipping
$shipping = false;
if (isset($this->request->post['order_product'])) {
$this->load->model('catalog/product');
foreach ($this->request->post['order_product'] as $order_product) {
$product_info = $this->model_catalog_product->getProduct($order_product['product_id']);
if ($product_info && $product_info['shipping']) {
$shipping = true;
}
}
}
if ($shipping) {
if ((utf8_strlen($this->request->post['shipping_firstname']) < 1) || (utf8_strlen($this->request->post['shipping_firstname']) > 32)) {
$this->error['shipping_firstname'] = $this->language->get('error_firstname');
}
if ((utf8_strlen($this->request->post['shipping_lastname']) < 1) || (utf8_strlen($this->request->post['shipping_lastname']) > 32)) {
$this->error['shipping_lastname'] = $this->language->get('error_lastname');
}
if ((utf8_strlen($this->request->post['shipping_address_1']) < 3) || (utf8_strlen($this->request->post['shipping_address_1']) > 128)) {
$this->error['shipping_address_1'] = $this->language->get('error_address_1');
}
if ((utf8_strlen($this->request->post['shipping_city']) < 3) || (utf8_strlen($this->request->post['shipping_city']) > 128)) {
$this->error['shipping_city'] = $this->language->get('error_city');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->post['shipping_country_id']);
if ($country_info && $country_info['postcode_required'] && (utf8_strlen($this->request->post['shipping_postcode']) < 2) || (utf8_strlen($this->request->post['shipping_postcode']) > 10)) {
$this->error['shipping_postcode'] = $this->language->get('error_postcode');
}
if ($this->request->post['shipping_country_id'] == '') {
$this->error['shipping_country'] = $this->language->get('error_country');
}
if (!isset($this->request->post['shipping_zone_id']) || $this->request->post['shipping_zone_id'] == '') {
$this->error['shipping_zone'] = $this->language->get('error_zone');
}
if (!$this->request->post['shipping_method']) {
$this->error['shipping_method'] = $this->language->get('error_shipping');
}
}
if ($this->error && !isset($this->error['warning'])) {
$this->error['warning'] = $this->language->get('error_warning');
}
if (!$this->error) {
return true;
} else {
return false;
}