本文整理汇总了PHP中vat_validation函数的典型用法代码示例。如果您正苦于以下问题:PHP vat_validation函数的具体用法?PHP vat_validation怎么用?PHP vat_validation使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vat_validation函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validate_main_tax_id
public function validate_main_tax_id($value, $fields)
{
$this->load->helper('vat');
$this->load->model('localisation/country');
$this->language->load('account/register');
$country_id = $fields['main_country_id']['value'];
$country = $this->model_localisation_country->getCountry($country_id);
if ($country && !empty($country['iso_code_2']) && vat_validation($country['iso_code_2'], $value) == 'invalid') {
return $this->language->get('error_vat');
}
return '';
}
示例2: validateForm
protected function 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 ($this->request->post['payment_method'] == '') {
$this->error['payment_zone'] = $this->language->get('error_zone');
}
if (!$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;
}
//.........这里部分代码省略.........
示例3: validate
//.........这里部分代码省略.........
if ($this->request->post['payment_address'] == 'existing') {
$this->load->model('account/address');
if (empty($this->request->post['address_id'])) {
$json['error']['warning'] = $this->language->get('error_address');
} elseif (!in_array($this->request->post['address_id'], array_keys($this->model_account_address->getAddresses()))) {
$json['error']['warning'] = $this->language->get('error_address');
} else {
// Default Payment Address
$this->load->model('account/address');
$address_info = $this->model_account_address->getAddress($this->request->post['address_id']);
if ($address_info) {
$this->load->model('account/customer_group');
$customer_group_info = $this->model_account_customer_group->getCustomerGroup($this->customer->getCustomerGroupId());
// Company ID
if ($customer_group_info['company_id_display'] && $customer_group_info['company_id_required'] && !$address_info['company_id']) {
$json['error']['warning'] = $this->language->get('error_company_id');
}
// Tax ID
if ($customer_group_info['tax_id_display'] && $customer_group_info['tax_id_required'] && !$address_info['tax_id']) {
$json['error']['warning'] = $this->language->get('error_tax_id');
}
}
}
if (!$json) {
$this->session->data['payment_address_id'] = $this->request->post['address_id'];
if ($address_info) {
$this->session->data['payment_country_id'] = $address_info['country_id'];
$this->session->data['payment_zone_id'] = $address_info['zone_id'];
} else {
unset($this->session->data['payment_country_id']);
unset($this->session->data['payment_zone_id']);
}
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
}
}
$this->request->post['firstname'] = $this->model_checkout_checkout_tools->getFirstName($this->request->post['firstname']);
$this->request->post['lastname'] = $this->model_checkout_checkout_tools->getLastName($this->request->post['firstname']);
$this->request->post['address_2'] = '';
if (!isset($this->request->post['company_id'])) {
$this->request->post['company_id'] = '';
}
if (!isset($this->request->post['tax_id'])) {
$this->request->post['tax_id'] = '';
}
if ($this->request->post['payment_address'] == 'new') {
if (utf8_strlen($this->request->post['firstname']) < 1 || utf8_strlen($this->request->post['firstname']) > 32) {
$json['error']['firstname'] = $this->language->get('error_firstname');
}
// Customer Group
$this->load->model('account/customer_group');
$customer_group_info = $this->model_account_customer_group->getCustomerGroup($this->customer->getCustomerGroupId());
if ($customer_group_info) {
// Company ID
if ($customer_group_info['company_id_display'] && $customer_group_info['company_id_required'] && empty($this->request->post['company_id'])) {
$json['error']['company_id'] = $this->language->get('error_company_id');
}
// Tax ID
if ($customer_group_info['tax_id_display'] && $customer_group_info['tax_id_required'] && empty($this->request->post['tax_id'])) {
$json['error']['tax_id'] = $this->language->get('error_tax_id');
}
}
if (utf8_strlen($this->request->post['address_1']) < 3 || utf8_strlen($this->request->post['address_1']) > 128) {
$json['error']['address_1'] = $this->language->get('error_address_1');
}
if (utf8_strlen($this->request->post['city']) < 2 || utf8_strlen($this->request->post['city']) > 32) {
$json['error']['city'] = $this->language->get('error_city');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);
if ($country_info) {
if ($country_info['postcode_required'] && utf8_strlen($this->request->post['postcode']) < 2 || utf8_strlen($this->request->post['postcode']) > 10) {
$json['error']['postcode'] = $this->language->get('error_postcode');
}
// VAT Validation
$this->load->helper('vat');
if ($this->config->get('config_vat') && isset($this->request->post['tax_id']) && $this->request->post['tax_id'] != '' && vat_validation($country_info['iso_code_2'], $this->request->post['tax_id']) == 'invalid') {
$json['error']['tax_id'] = $this->language->get('error_vat');
}
}
if ($this->request->post['country_id'] == '') {
$json['error']['country'] = $this->language->get('error_country');
}
if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '') {
$json['error']['zone'] = $this->language->get('error_zone');
}
if (!$json) {
// Default Payment Address
$this->load->model('account/address');
$this->session->data['payment_address_id'] = $this->model_account_address->addAddress($this->request->post);
$this->session->data['payment_country_id'] = $this->request->post['country_id'];
$this->session->data['payment_zone_id'] = $this->request->post['zone_id'];
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
}
}
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
示例4: validate
protected function validate()
{
$this->load->model('account/customer_group');
$this->load->model('catalog/information');
$this->load->model('localisation/country');
if (utf8_strlen($this->request->post['firstname']) < 1 || utf8_strlen($this->request->post['firstname']) > 32) {
$this->error['firstname'] = Language::getVar('SUMO_NOUN_FIRSTNAME');
}
if (utf8_strlen($this->request->post['lastname']) < 1 || utf8_strlen($this->request->post['lastname']) > 32) {
$this->error['lastname'] = Language::getVar('SUMO_NOUN_ERROR_LASTNAME');
}
if (empty($this->request->post['gender'])) {
$this->error['gender'] = Language::getVar('SUMO_NOUN_ERROR_GENDER');
}
if (empty($this->request->post['birthdate']) || utf8_strlen($this->request->post['birthdate']) != 10) {
$this->error['birthdate'] = Language::getVar('SUMO_NOUN_ERROR_BIRTHDATE');
}
if (!filter_var($this->request->post['email'], \FILTER_VALIDATE_EMAIL)) {
$this->error['email'] = Language::getVar('SUMO_NOUN_ERROR_EMAIL');
}
if ($this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
$this->error['warning'] = Language::getVar('SUMO_NOUN_ERROR_EMAIL_IN_USE', $this->url->link('account/login', '', 'SSL'));
}
$this->request->post['telephone'] = preg_replace('/([^\\d]+)/', '', str_replace('+', '00', $this->request->post['telephone']));
$this->request->post['mobile'] = preg_replace('/([^\\d]+)/', '', str_replace('+', '00', $this->request->post['mobile']));
if (utf8_strlen($this->request->post['telephone']) < 8 || utf8_strlen($this->request->post['telephone']) > 15) {
$this->error['telephone'] = Language::getVar('SUMO_NOUN_ERROR_TELEPHONE');
}
if (!empty($this->request->post['mobile'])) {
if (utf8_strlen($this->request->post['mobile']) < 8 || utf8_strlen($this->request->post['mobile']) > 15) {
$this->error['mobile'] = Language::getVar('SUMO_NOUN_ERROR_TELEPHONE');
}
}
// Customer Group
if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('customer_group_display'))) {
$customer_group_id = $this->request->post['customer_group_id'];
} else {
$customer_group_id = $this->config->get('customer_group_id');
}
$customer_group = $this->model_account_customer_group->getCustomerGroup($customer_group_id);
if ($customer_group) {
// Company ID
if ($customer_group['company_id_display'] && $customer_group['company_id_required'] && empty($this->request->post['company_id'])) {
$this->error['company_id'] = Language::getVar('SUMO_NOUN_ERROR_COMPANY');
}
// Tax ID
if ($customer_group['tax_id_display'] && $customer_group['tax_id_required'] && empty($this->request->post['tax_id'])) {
$this->error['tax_id'] = Language::getVar('SUMO_NOUN_ERROR_TAX');
}
}
if (utf8_strlen($this->request->post['address_1']) < 3 || utf8_strlen($this->request->post['address_1']) > 128) {
$this->error['address_1'] = Language::getVar('SUMO_NOUN_ERROR_ADDRESS');
}
if (utf8_strlen($this->request->post['city']) < 2 || utf8_strlen($this->request->post['city']) > 128) {
$this->error['city'] = Language::getVar('SUMO_NOUN_ERROR_CITY');
}
$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);
if ($country_info) {
if ($country_info['postcode_required'] && utf8_strlen($this->request->post['postcode']) < 2 || utf8_strlen($this->request->post['postcode']) > 6) {
$this->error['postcode'] = Language::getVar('SUMO_NOUN_ERROR_POSTAL_CODE');
}
// VAT Validation
$this->load->helper('vat');
if ($this->request->post['tax_id'] && vat_validation($country_info['iso_code_2'], $this->request->post['tax_id']) == 'invalid') {
$this->error['tax_id'] = Language::getVar('SUMO_NOUN_ERROR_VAT');
}
}
if ($this->request->post['country_id'] == '') {
$this->error['country'] = Language::getVar('SUMO_NOUN_ERROR_COUNTRY');
}
if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '') {
$this->error['zone'] = Language::getVar('SUMO_NOUN_ERROR_ZONE');
}
$password = $this->request->post['password'];
if (empty($password) || utf8_strlen($this->request->post['password']) < 4) {
$this->error['password'] = Language::getVar('SUMO_NOUN_ERROR_PASSWORD_UNSAFE');
}
if ($this->request->post['confirm'] != $this->request->post['password']) {
$this->error['confirm'] = Language::getVar('SUMO_NOUN_ERROR_PASSWORD_CONFIRM');
}
if ($this->config->get('customer_policy_id')) {
$information_info = $this->model_catalog_information->getInformation($this->config->get('customer_policy_id'));
if ($information_info && !isset($this->request->post['agree'])) {
$this->error['warning'] = Language::getVar('SUMO_NOUN_ACCOUNT_AGREE_PAGE', array($this->url->link('information/information/info', 'information_id=' . $information_info['information_id']), $information_info['title']));
}
}
if (!$this->error) {
return true;
}
return false;
}
示例5: validateForm
protected function validateForm()
{
if (!$this->user->hasPermission('modify', 'sale/customer')) {
$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,15}$/i', $this->request->post['email'])) {
$this->error['email'] = $this->language->get('error_email');
}
$customer_info = $this->model_sale_customer->getCustomerByEmail($this->request->post['email']);
if (!isset($this->request->get['customer_id'])) {
if ($customer_info) {
$this->error['warning'] = $this->language->get('error_exists');
}
} else {
if ($customer_info && $this->request->get['customer_id'] != $customer_info['customer_id']) {
$this->error['warning'] = $this->language->get('error_exists');
}
}
if (utf8_strlen($this->request->post['telephone']) < 3 || utf8_strlen($this->request->post['telephone']) > 32) {
$this->error['telephone'] = $this->language->get('error_telephone');
}
if (isset($this->request->post['date_of_birth']) && utf8_strlen($this->request->post['date_of_birth']) == 10) {
if ($this->request->post['date_of_birth'] != date('Y-m-d', strtotime($this->request->post['date_of_birth']))) {
$this->error['date_of_birth'] = $this->language->get('error_date_of_birth');
}
} else {
$this->error['date_of_birth'] = $this->language->get('error_date_of_birth');
}
if ($this->request->post['password'] || !isset($this->request->get['customer_id'])) {
if (utf8_strlen($this->request->post['password']) < 4 || utf8_strlen($this->request->post['password']) > 20) {
$this->error['password'] = $this->language->get('error_password');
}
if ($this->request->post['password'] != $this->request->post['confirm']) {
$this->error['confirm'] = $this->language->get('error_confirm');
}
}
if (isset($this->request->post['address'])) {
foreach ($this->request->post['address'] as $key => $value) {
if (utf8_strlen($value['firstname']) < 1 || utf8_strlen($value['firstname']) > 32) {
$this->error['address_firstname'][$key] = $this->language->get('error_firstname');
}
if (utf8_strlen($value['lastname']) < 1 || utf8_strlen($value['lastname']) > 32) {
$this->error['address_lastname'][$key] = $this->language->get('error_lastname');
}
if (utf8_strlen($value['address_1']) < 3 || utf8_strlen($value['address_1']) > 128) {
$this->error['address_address_1'][$key] = $this->language->get('error_address_1');
}
if (utf8_strlen($value['city']) < 2 || utf8_strlen($value['city']) > 128) {
$this->error['address_city'][$key] = $this->language->get('error_city');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($value['country_id']);
if ($country_info) {
if ($country_info['postcode_required'] && utf8_strlen($value['postcode']) < 2 || utf8_strlen($value['postcode']) > 10) {
$this->error['address_postcode'][$key] = $this->language->get('error_postcode');
}
// VAT Validation
$this->load->model('sale/customer_group');
if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) {
$customer_group_id = $this->request->post['customer_group_id'];
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$customer_group = $this->model_sale_customer_group->getCustomerGroup($customer_group_id);
if ($customer_group && $customer_group['tax_id_display']) {
$this->load->helper('vat');
if ($this->config->get('config_vat') && $value['tax_id'] != '' && vat_validation($country_info['iso_code_2'], $value['tax_id']) == 'invalid') {
$this->error['address_tax_id'][$key] = $this->language->get('error_vat');
}
}
}
if ($value['country_id'] == '') {
$this->error['address_country'][$key] = $this->language->get('error_country');
}
if (!isset($value['zone_id']) || $value['zone_id'] == '') {
$this->error['address_zone'][$key] = $this->language->get('error_zone');
}
}
}
if ($this->error && !isset($this->error['warning'])) {
$this->error['warning'] = $this->language->get('error_warning');
}
if (!$this->error) {
return true;
} else {
return false;
}
}
示例6: validateForm
private function validateForm()
{
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['address_1']) < 3 || utf8_strlen($this->request->post['address_1']) > 128) {
$this->error['address_1'] = $this->language->get('error_address_1');
}
if (utf8_strlen($this->request->post['city']) < 2 || utf8_strlen($this->request->post['city']) > 128) {
$this->error['city'] = $this->language->get('error_city');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);
if ($country_info) {
if ($country_info['postcode_required'] && utf8_strlen($this->request->post['postcode']) < 2 || utf8_strlen($this->request->post['postcode']) > 10) {
$this->error['postcode'] = $this->language->get('error_postcode');
}
// VAT Validation
$this->load->helper('vat');
if ($this->config->get('config_vat') && !empty($this->request->post['tax_id']) && vat_validation($country_info['iso_code_2'], $this->request->post['tax_id']) == 'invalid') {
$this->error['tax_id'] = $this->language->get('error_vat');
}
}
if ($this->request->post['country_id'] == '') {
$this->error['country'] = $this->language->get('error_country');
}
if ($this->request->post['zone_id'] == '') {
$this->error['zone'] = $this->language->get('error_zone');
}
/*Verify Postal*/
$this->load->model('ocean/urlredirect');
$verifyPostal = $this->model_ocean_urlredirect->verifyPostal($this->request->post['postcode'], $this->request->post['city'], $this->request->post['zone_id'], $this->request->post['country_id']);
if (empty($verifyPostal)) {
$this->error['postcode'] = ERROR_POSTAL_VERIFICATION;
}
/*End Verify Postal*/
/*Verify City*/
$verifyCity = $this->model_ocean_urlredirect->verifyCity($this->request->post['city'], $this->request->post['zone_id'], $this->request->post['country_id']);
if (empty($verifyCity)) {
$this->error['city'] = ERROR_CITY_VERIFICATION;
}
/*End Verify City*/
if (!$this->error) {
return true;
} else {
return false;
}
}
示例7: validate
protected function validate()
{
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 ($this->model_account_customer->getTotalCustomersByEmail($this->request->post['email'])) {
$this->error['warning'] = $this->language->get('error_exists');
}
if (utf8_strlen($this->request->post['telephone']) < 3 || utf8_strlen($this->request->post['telephone']) > 32 || !is_numeric($this->request->post['telephone'])) {
$this->error['telephone'] = $this->language->get('error_telephone');
}
// Customer Group
$this->load->model('account/customer_group');
if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) {
$customer_group_id = $this->request->post['customer_group_id'];
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$customer_group = $this->model_account_customer_group->getCustomerGroup($customer_group_id);
if ($customer_group) {
// Company ID
if ($customer_group['company_id_display'] && $customer_group['company_id_required'] && empty($this->request->post['company_id'])) {
$this->error['company_id'] = $this->language->get('error_company_id');
}
// Tax ID
// if ($customer_group['tax_id_display'] && $customer_group['tax_id_required'] && empty($this->request->post['tax_id'])) {
// $this->error['tax_id'] = $this->language->get('error_tax_id');
// }
}
if (utf8_strlen($this->request->post['address_1']) < 3 || utf8_strlen($this->request->post['address_1']) > 128) {
$this->error['address_1'] = $this->language->get('error_address_1');
}
if (utf8_strlen($this->request->post['city']) < 2 || utf8_strlen($this->request->post['city']) > 128) {
$this->error['city'] = $this->language->get('error_city');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);
if ($country_info) {
if ($country_info['postcode_required'] && utf8_strlen($this->request->post['postcode']) < 6 || utf8_strlen($this->request->post['postcode']) > 6 || !is_numeric($this->request->post['postcode'])) {
$this->error['postcode'] = $this->language->get('error_postcode');
}
// VAT Validation
$this->load->helper('vat');
if ($this->config->get('config_vat') && $this->request->post['tax_id'] && vat_validation($country_info['iso_code_2'], $this->request->post['tax_id']) == 'invalid') {
$this->error['tax_id'] = $this->language->get('error_vat');
}
}
if ($this->request->post['country_id'] == '') {
$this->error['country'] = $this->language->get('error_country');
}
if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '') {
$this->error['zone'] = $this->language->get('error_zone');
}
if (utf8_strlen($this->request->post['password']) < 4 || utf8_strlen($this->request->post['password']) > 20) {
$this->error['password'] = $this->language->get('error_password');
}
if ($this->request->post['confirm'] != $this->request->post['password']) {
$this->error['confirm'] = $this->language->get('error_confirm');
}
if ($this->config->get('config_account_id')) {
$this->load->model('catalog/information');
$information_info = $this->model_catalog_information->getInformation($this->config->get('config_account_id'));
if ($information_info && !isset($this->request->post['agree'])) {
$this->error['warning'] = sprintf($this->language->get('error_agree'), $information_info['title']);
}
}
if (!$this->error) {
return true;
} else {
return false;
}
}
示例8: validateForm
protected function validateForm()
{
if (!$this->user->hasPermission('modify', 'sale/customer')) {
$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 || !$this->ocstore->validate($this->request->post['email'])) {
$this->error['email'] = $this->language->get('error_email');
}
$customer_info = $this->model_sale_customer->getCustomerByEmail($this->request->post['email']);
if (!isset($this->request->get['customer_id'])) {
if ($customer_info) {
$this->error['warning'] = $this->language->get('error_exists');
}
} else {
if ($customer_info && $this->request->get['customer_id'] != $customer_info['customer_id']) {
$this->error['warning'] = $this->language->get('error_exists');
}
}
if (utf8_strlen($this->request->post['telephone']) < 3 || utf8_strlen($this->request->post['telephone']) > 32) {
$this->error['telephone'] = $this->language->get('error_telephone');
}
if ($this->request->post['password'] || !isset($this->request->get['customer_id'])) {
if (utf8_strlen($this->request->post['password']) < 4 || utf8_strlen($this->request->post['password']) > 20) {
$this->error['password'] = $this->language->get('error_password');
}
if ($this->request->post['password'] != $this->request->post['confirm']) {
$this->error['confirm'] = $this->language->get('error_confirm');
}
}
if (isset($this->request->post['address'])) {
foreach ($this->request->post['address'] as $key => $value) {
if (utf8_strlen($value['firstname']) < 1 || utf8_strlen($value['firstname']) > 32) {
$this->error['address_firstname'][$key] = $this->language->get('error_firstname');
}
if (utf8_strlen($value['lastname']) < 1 || utf8_strlen($value['lastname']) > 32) {
$this->error['address_lastname'][$key] = $this->language->get('error_lastname');
}
if (utf8_strlen($value['address_1']) < 3 || utf8_strlen($value['address_1']) > 128) {
$this->error['address_address_1'][$key] = $this->language->get('error_address_1');
}
if (utf8_strlen($value['city']) < 2 || utf8_strlen($value['city']) > 128) {
$this->error['address_city'][$key] = $this->language->get('error_city');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($value['country_id']);
if ($country_info) {
if ($country_info['postcode_required'] && utf8_strlen($value['postcode']) < 2 || utf8_strlen($value['postcode']) > 10) {
$this->error['address_postcode'][$key] = $this->language->get('error_postcode');
}
// VAT Validation
$this->load->helper('vat');
if ($this->config->get('config_vat') && $value['tax_id'] && vat_validation($country_info['iso_code_2'], $value['tax_id']) == 'invalid') {
$this->error['address_tax_id'][$key] = $this->language->get('error_vat');
}
}
if ($value['country_id'] == '') {
$this->error['address_country'][$key] = $this->language->get('error_country');
}
if (!isset($value['zone_id']) || $value['zone_id'] == '') {
$this->error['address_zone'][$key] = $this->language->get('error_zone');
}
}
}
if ($this->error && !isset($this->error['warning'])) {
$this->error['warning'] = $this->language->get('error_warning');
}
if (!$this->error) {
return true;
} else {
return false;
}
}
示例9: invalid
public function invalid($value, $data = array())
{
$result = false;
if (isset($data['not_empty'])) {
$result = empty($value) ? true : false;
}
if (isset($data['min_length']) && !$result) {
$result = utf8_strlen($value) < $data['min_length'] ? true : false;
}
if (isset($data['max_length']) && !$result) {
$result = utf8_strlen($value) > $data['max_length'] ? true : false;
}
if (isset($data['vat_address']) && !$result) {
$result = vat_validation($this->checkout[$data['vat_address']]['iso_code_2'], $value) == 'invalid' ? true : false;
}
if (isset($data['compare_to']) && !$result) {
$field = explode("[", $data['compare_to']);
$field[1] = str_replace("]", "", $field[1]);
$data['compare_to'] = isset($this->checkout[$field[0]][$field[1]]) ? $this->checkout[$field[0]][$field[1]] : '';
$result = $value != $data['compare_to'] ? true : false;
}
if (isset($data['regex']) && !$result) {
$result = !preg_match($data['regex'], $value) ? true : false;
}
if (isset($data['email_exists']) && !$result) {
$result = $this->model_account_customer->getTotalCustomersByEmail($value) ? true : false;
}
if (isset($data['checked']) && !$result) {
$result = !$value;
}
return $result;
}
示例10: payment_address_validate
//.........这里部分代码省略.........
}
}
}
} else {
if (!$json) {
if (isset($this->request->post['payment_address']) && $this->request->post['payment_address'] == 'existing') {
$this->load->model('account/address');
if (empty($this->request->post['payment_address_id'])) {
$json['error']['warning'] = $this->language->get('error_address');
} elseif (!in_array($this->request->post['payment_address_id'], array_keys($this->model_account_address->getAddresses()))) {
$json['error']['warning'] = $this->language->get('error_address');
} else {
// Default Payment Address
$this->load->model('account/address');
$address_info = $this->model_account_address->getAddress($this->request->post['payment_address_id']);
if ($address_info) {
$this->load->model('account/customer_group');
$customer_group_info = $this->model_account_customer_group->getCustomerGroup($this->customer->getCustomerGroupId());
// Company ID
if ($customer_group_info['company_id_display'] && $customer_group_info['company_id_required'] && !$address_info['company_id']) {
$json['error']['warning'] = $this->language->get('error_company_id');
}
// Tax ID
if ($customer_group_info['tax_id_display'] && $customer_group_info['tax_id_required'] && !$address_info['tax_id']) {
$json['error']['warning'] = $this->language->get('error_tax_id');
}
}
}
if (!$json) {
$this->session->data['payment_address_id'] = $this->request->post['payment_address_id'];
if ($address_info) {
$this->session->data['payment_country_id'] = $address_info['country_id'];
$this->session->data['payment_zone_id'] = $address_info['zone_id'];
} else {
unset($this->session->data['payment_country_id']);
unset($this->session->data['payment_zone_id']);
}
//unset($this->session->data['payment_method']);
//unset($this->session->data['payment_methods']);
}
} else {
if (!isset($this->request->post['firstname']) || (utf8_strlen(trim($this->request->post['firstname'])) < 1 || utf8_strlen(trim($this->request->post['firstname'])) > 32)) {
$json['error']['firstname'] = $this->language->get('error_firstname');
}
if (!isset($this->request->post['lastname']) || (utf8_strlen(trim($this->request->post['lastname'])) < 1 || utf8_strlen(trim($this->request->post['lastname'])) > 32)) {
$json['error']['lastname'] = $this->language->get('error_lastname');
}
if (!isset($this->request->post['address_1']) || (utf8_strlen(trim($this->request->post['address_1'])) < 3 || utf8_strlen(trim($this->request->post['address_1'])) > 128)) {
$json['error']['address_1'] = $this->language->get('error_address_1');
}
if (!isset($this->request->post['city']) || (utf8_strlen($this->request->post['city']) < 2 || utf8_strlen($this->request->post['city']) > 32)) {
$json['error']['city'] = $this->language->get('error_city');
}
// Customer Group
$this->load->model('account/customer_group');
$customer_group_info = $this->model_account_customer_group->getCustomerGroup($this->customer->getCustomerGroupId());
if ($customer_group_info) {
// Company ID
if ($customer_group_info['company_id_display'] && $customer_group_info['company_id_required'] && empty($this->request->post['company_id'])) {
$json['error']['company_id'] = $this->language->get('error_company_id');
}
// Tax ID
if ($customer_group_info['tax_id_display'] && $customer_group_info['tax_id_required'] && empty($this->request->post['tax_id'])) {
$json['error']['tax_id'] = $this->language->get('error_tax_id');
}
}
$this->load->model('localisation/country');
if (isset($this->request->post['country_id'])) {
$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);
}
if (isset($country_info)) {
if ($country_info['postcode_required'] && utf8_strlen($this->request->post['postcode']) < 2 || utf8_strlen($this->request->post['postcode']) > 10) {
$json['error']['postcode'] = $this->language->get('error_postcode');
}
// VAT Validation
$this->load->helper('vat');
if ($this->config->get('config_vat') && !empty($this->request->post['tax_id']) && vat_validation($country_info['iso_code_2'], $this->request->post['tax_id']) == 'invalid') {
$json['error']['tax_id'] = $this->language->get('error_vat');
}
}
if (!isset($this->request->post['country_id']) || $this->request->post['country_id'] == '') {
$json['error']['country_id'] = $this->language->get('error_country');
}
if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '') {
$json['error']['zone_id'] = $this->language->get('error_zone');
}
if (!$json) {
// Default Payment Address
$this->load->model('account/address');
$this->session->data['payment_address_id'] = $this->model_account_address->addAddress($this->request->post);
$this->session->data['payment_country_id'] = $this->request->post['country_id'];
$this->session->data['payment_zone_id'] = $this->request->post['zone_id'];
//unset($this->session->data['payment_method']);
//unset($this->session->data['payment_methods']);
}
}
}
}
return $json;
}
示例11: validate
public function validate()
{
$this->language->load('onepage/checkout');
$json = array();
// Validate if customer is logged in.
if (!$this->customer->isLogged()) {
$json['redirect'] = $this->url->link('onepage/checkout', '', 'SSL');
}
// Validate cart has products and has stock.
if (!$this->cart->hasProducts() && empty($this->session->data['vouchers']) || !$this->cart->hasStock() && !$this->config->get('config_stock_checkout')) {
$json['redirect'] = $this->url->link('onepage/cart');
}
// Validate minimum quantity requirments.
$products = $this->cart->getProducts();
foreach ($products as $product) {
$product_total = 0;
foreach ($products as $product_2) {
if ($product_2['product_id'] == $product['product_id']) {
$product_total += $product_2['quantity'];
}
}
if ($product['minimum'] > $product_total) {
$json['redirect'] = $this->url->link('onepage/cart');
break;
}
}
if (!$json) {
if (isset($this->request->post['payment_address']) && $this->request->post['payment_address'] == 'existing') {
$this->load->model('account/address');
if (empty($this->request->post['address_id'])) {
$json['error']['warning'] = $this->language->get('error_address');
} elseif (!in_array($this->request->post['address_id'], array_keys($this->model_account_address->getAddresses()))) {
$json['error']['warning'] = $this->language->get('error_address');
} else {
// Default Payment Address
$this->load->model('account/address');
$address_info = $this->model_account_address->getAddress($this->request->post['address_id']);
if ($address_info) {
$this->load->model('account/customer_group');
$customer_group_info = $this->model_account_customer_group->getCustomerGroup($this->customer->getCustomerGroupId());
// Company ID
if ($customer_group_info['company_id_display'] && $customer_group_info['company_id_required'] && !$address_info['company_id']) {
$json['error']['warning'] = $this->language->get('error_company_id');
}
// Tax ID
if ($customer_group_info['tax_id_display'] && $customer_group_info['tax_id_required'] && !$address_info['tax_id']) {
$json['error']['warning'] = $this->language->get('error_tax_id');
}
}
}
if (!$json) {
$this->session->data['payment_address_id'] = $this->request->post['address_id'];
if ($address_info) {
$this->session->data['payment_country_id'] = $address_info['country_id'];
$this->session->data['payment_zone_id'] = $address_info['zone_id'];
} else {
unset($this->session->data['payment_country_id']);
unset($this->session->data['payment_zone_id']);
}
unset($this->session->data['payment_method']);
unset($this->session->data['payment_methods']);
}
} else {
if (utf8_strlen($this->request->post['firstname']) < 1 || utf8_strlen($this->request->post['firstname']) > 32) {
$json['error']['firstname'] = $this->language->get('error_firstname');
}
if (utf8_strlen($this->request->post['lastname']) < 1 || utf8_strlen($this->request->post['lastname']) > 32) {
$json['error']['lastname'] = $this->language->get('error_lastname');
}
// Customer Group
$this->load->model('account/customer_group');
$customer_group_info = $this->model_account_customer_group->getCustomerGroup($this->customer->getCustomerGroupId());
if ($customer_group_info) {
// Company ID
if ($customer_group_info['company_id_display'] && $customer_group_info['company_id_required'] && empty($this->request->post['company_id'])) {
$json['error']['company_id'] = $this->language->get('error_company_id');
}
// Tax ID
if ($customer_group_info['tax_id_display'] && $customer_group_info['tax_id_required'] && empty($this->request->post['tax_id'])) {
$json['error']['tax_id'] = $this->language->get('error_tax_id');
}
}
if (utf8_strlen($this->request->post['address_1']) < 3 || utf8_strlen($this->request->post['address_1']) > 128) {
$json['error']['address_1'] = $this->language->get('error_address_1');
}
if (utf8_strlen($this->request->post['city']) < 2 || utf8_strlen($this->request->post['city']) > 32) {
$json['error']['city'] = $this->language->get('error_city');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);
if ($country_info) {
if ($country_info['postcode_required'] && utf8_strlen($this->request->post['postcode']) < 2 || utf8_strlen($this->request->post['postcode']) > 10) {
$json['error']['postcode'] = $this->language->get('error_postcode');
}
// VAT Validation
$this->load->helper('vat');
if ($this->config->get('config_vat') && !empty($this->request->post['tax_id']) && vat_validation($country_info['iso_code_2'], $this->request->post['tax_id']) == 'invalid') {
$json['error']['tax_id'] = $this->language->get('error_vat');
}
}
//.........这里部分代码省略.........
示例12: index
public function index()
{
$this->language->load('onecheckout/checkout');
$this->load->model('onecheckout/checkout');
$version_int = $this->model_onecheckout_checkout->versiontoint();
$json = array();
if ($this->customer->isLogged()) {
$json['redirect'] = $this->url->link('onecheckout/checkout', '', 'SSL');
}
if (!$this->cart->hasProducts() && (!isset($this->session->data['vouchers']) || !$this->session->data['vouchers']) || !$this->cart->hasStock() && !$this->config->get('config_stock_checkout')) {
$json['redirect'] = $this->url->link('checkout/cart');
}
if (!$this->config->get('config_guest_checkout') || $this->cart->hasDownload()) {
$json['redirect'] = $this->url->link('onecheckout/checkout', '', 'SSL');
}
if ($this->request->server['REQUEST_METHOD'] == 'POST') {
if (!$json) {
if (strlen(utf8_decode($this->request->post['firstname'])) < 1 || strlen(utf8_decode($this->request->post['firstname'])) > 32) {
$json['error']['firstname'] = $this->language->get('error_firstname');
}
if (strlen(utf8_decode($this->request->post['lastname'])) < 1 || strlen(utf8_decode($this->request->post['lastname'])) > 32) {
$json['error']['lastname'] = $this->language->get('error_lastname');
}
if ($this->request->post['birthday_day'] == '' || $this->request->post['birthday_month'] == '' || $this->request->post['birthday_year'] == '') {
$json['error']['birthday'] = $this->language->get('error_birthday');
}
if (strlen(utf8_decode($this->request->post['email'])) > 96 || !preg_match('/^[^\\@]+@.*\\.[a-z]{2,6}$/i', $this->request->post['email'])) {
$json['error']['email'] = $this->language->get('error_email');
}
if (strlen(utf8_decode($this->request->post['telephone'])) < 3 || strlen(utf8_decode($this->request->post['telephone'])) > 32) {
$json['error']['telephone'] = $this->language->get('error_telephone');
}
//version
if ($version_int >= 1530) {
// Customer Group
$this->load->model('account/customer_group');
if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) {
$customer_group_id = $this->request->post['customer_group_id'];
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$customer_group = $this->model_account_customer_group->getCustomerGroup($customer_group_id);
if ($customer_group) {
// Company ID
if ($customer_group['company_id_display'] && $customer_group['company_id_required'] && empty($this->request->post['company_id'])) {
$json['error']['company_id'] = $this->language->get('error_company_id');
}
// Tax ID
if ($customer_group['tax_id_display'] && $customer_group['tax_id_required'] && empty($this->request->post['tax_id'])) {
$json['error']['tax_id'] = $this->language->get('error_tax_id');
}
}
}
if (strlen(utf8_decode($this->request->post['address_1'])) < 3 || strlen(utf8_decode($this->request->post['address_1'])) > 128) {
$json['error']['address_1'] = $this->language->get('error_address_1');
}
$country_info = $this->model_onecheckout_checkout->getCountry($this->request->post['country_id']);
if ($country_info) {
if ($country_info['postcode_required'] && strlen(utf8_decode($this->request->post['postcode'])) < 2 || strlen(utf8_decode($this->request->post['postcode'])) > 10) {
$json['error']['postcode'] = $this->language->get('error_postcode');
}
if ($version_int >= 1530) {
// VAT Validation
$this->load->helper('vat');
if ($this->config->get('config_vat') && $this->request->post['tax_id'] && vat_validation($country_info['iso_code_2'], $this->request->post['tax_id']) == 'invalid') {
$json['error']['tax_id'] = $this->language->get('error_vat');
}
}
}
if ($this->request->post['country_id'] == '') {
$json['error']['country'] = $this->language->get('error_country');
}
if ($this->request->post['zone_id'] == '') {
$json['error']['zone'] = $this->language->get('error_zone');
}
}
if (!$json) {
$this->session->data['guest']['customer_group_id'] = isset($customer_group_id) ? $customer_group_id : $this->config->get('config_customer_group_id');
$this->session->data['guest']['firstname'] = $this->request->post['firstname'];
$this->session->data['guest']['lastname'] = $this->request->post['lastname'];
$this->session->data['guest']['email'] = $this->request->post['email'];
$this->session->data['guest']['telephone'] = $this->request->post['telephone'];
$this->session->data['guest']['fax'] = $this->request->post['fax'];
$this->session->data['guest']['payment']['firstname'] = $this->request->post['firstname'];
$this->session->data['guest']['payment']['lastname'] = $this->request->post['lastname'];
$this->session->data['guest']['payment']['company'] = $this->request->post['company'];
$this->session->data['guest']['payment']['company_id'] = isset($this->request->post['company_id']) ? $this->request->post['company_id'] : '';
$this->session->data['guest']['payment']['tax_id'] = isset($this->request->post['tax_id']) ? $this->request->post['tax_id'] : '';
$this->session->data['guest']['payment']['address_1'] = $this->request->post['address_1'];
$this->session->data['guest']['payment']['address_2'] = $this->request->post['address_2'];
$this->session->data['guest']['payment']['postcode'] = $this->request->post['postcode'];
$this->session->data['guest']['payment']['city'] = $this->request->post['city'];
$this->session->data['guest']['payment']['country_id'] = $this->request->post['country_id'];
$this->session->data['guest']['payment']['zone_id'] = $this->request->post['zone_id'];
$country_info = $this->model_onecheckout_checkout->getCountry($this->request->post['country_id']);
if ($country_info) {
$this->session->data['guest']['payment']['country'] = $country_info['name'];
$this->session->data['guest']['payment']['iso_code_2'] = $country_info['iso_code_2'];
$this->session->data['guest']['payment']['iso_code_3'] = $country_info['iso_code_3'];
$this->session->data['guest']['payment']['address_format'] = $country_info['address_format'];
//.........这里部分代码省略.........
示例13: payment
public function payment()
{
$this->language->load('onecheckout/checkout');
$this->load->model('onecheckout/checkout');
$this->load->model('account/customer');
$version_int = $this->model_onecheckout_checkout->versiontoint();
$this->data['version_int'] = $version_int;
$json = array();
if (!$this->customer->isLogged()) {
$json['redirect'] = $this->url->link('onecheckout/checkout', '', 'SSL');
}
if (!$this->model_onecheckout_checkout->getAddresses()) {
$json['alert'] = $this->language->get('text_noaddress');
$json['redirect'] = $this->url->link('account/address/insert', '', 'SSL');
}
if (!$this->cart->hasProducts() && (!isset($this->session->data['vouchers']) || !$this->session->data['vouchers']) || !$this->cart->hasStock() && !$this->config->get('config_stock_checkout')) {
$json['redirect'] = $this->url->link('checkout/cart');
}
if ($this->request->server['REQUEST_METHOD'] == 'POST') {
if (!$json) {
if ($this->request->post['payment_address'] == 'existing') {
if (!isset($this->request->post['address_id'])) {
$json['error']['warning'] = $this->language->get('error_address');
}
if (!$json && $version_int >= 1530) {
$this->load->model('account/address');
$existaddress = $this->model_account_address->getAddress($this->request->post['address_id']);
if ($existaddress) {
$this->load->model('account/customer_group');
$customer_group_info = $this->model_account_customer_group->getCustomerGroup($this->customer->getCustomerGroupId());
// Company ID
if ($customer_group_info['company_id_display'] && $customer_group_info['company_id_required'] && !$existaddress['company_id']) {
$json['error']['warning'] = $this->language->get('error_company_id');
}
// Tax ID
if ($customer_group_info['tax_id_display'] && $customer_group_info['tax_id_required'] && !$existaddress['tax_id']) {
$json['error']['warning'] = $this->language->get('error_tax_id');
}
}
}
if (!$json) {
$this->session->data['payment_address_id'] = $this->request->post['address_id'];
// Default Payment Address
$address_info = $this->model_onecheckout_checkout->getAddress($this->request->post['address_id']);
if ($address_info && $this->config->get('config_tax_customer') == 'payment') {
$this->session->data['payment_country_id'] = $address_info['country_id'];
$this->session->data['payment_zone_id'] = $address_info['zone_id'];
} else {
unset($this->session->data['payment_country_id']);
unset($this->session->data['payment_zone_id']);
}
unset($this->session->data['payment_methods']);
unset($this->session->data['payment_method']);
}
}
if ($this->request->post['payment_address'] == 'new') {
if (strlen(utf8_decode($this->request->post['firstname'])) < 1 || strlen(utf8_decode($this->request->post['firstname'])) > 32) {
$json['error']['firstname'] = $this->language->get('error_firstname');
}
if (strlen(utf8_decode($this->request->post['lastname'])) < 1 || strlen(utf8_decode($this->request->post['lastname'])) > 32) {
$json['error']['lastname'] = $this->language->get('error_lastname');
}
//version
if ($version_int >= 1530) {
// Customer Group
$this->load->model('account/customer_group');
/*if (isset($this->request->post['customer_group_id']) && is_array($this->config->get('config_customer_group_display')) && in_array($this->request->post['customer_group_id'], $this->config->get('config_customer_group_display'))) {
$customer_group_id = $this->request->post['customer_group_id'];
} else*/
if ($this->customer->isLogged()) {
$customer_group_id = $this->customer->getCustomerGroupId();
} else {
$customer_group_id = $this->config->get('config_customer_group_id');
}
$customer_group = $this->model_account_customer_group->getCustomerGroup($customer_group_id);
if ($customer_group) {
// Company ID
if ($customer_group['company_id_display'] && $customer_group['company_id_required'] && empty($this->request->post['company_id'])) {
$json['error']['company_id'] = $this->language->get('error_company_id');
}
// Tax ID
if ($customer_group['tax_id_display'] && $customer_group['tax_id_required'] && empty($this->request->post['tax_id'])) {
$json['error']['tax_id'] = $this->language->get('error_tax_id');
}
}
}
if (strlen(utf8_decode($this->request->post['address_1'])) < 3 || strlen(utf8_decode($this->request->post['address_1'])) > 64) {
$json['error']['address_1'] = $this->language->get('error_address_1');
}
$country_info = $this->model_onecheckout_checkout->getCountry($this->request->post['country_id']);
if ($country_info) {
if ($country_info['postcode_required'] && strlen(utf8_decode($this->request->post['postcode'])) < 2 || strlen(utf8_decode($this->request->post['postcode'])) > 10) {
$json['error']['postcode'] = $this->language->get('error_postcode');
}
if ($version_int >= 1530) {
// VAT Validation
$this->load->helper('vat');
if ($this->config->get('config_vat') && $this->request->post['tax_id'] && vat_validation($country_info['iso_code_2'], $this->request->post['tax_id']) == 'invalid') {
$json['error']['tax_id'] = $this->language->get('error_vat');
}
//.........这里部分代码省略.........
示例14: validateForm
protected function validateForm()
{
if (!$this->user->hasPermission('modify', 'sale/customer')) {
$this->error[] = Language::getVar('SUMO_ERROR_NO_PERMISSION');
return;
}
if (utf8_strlen($this->request->post['firstname']) < 1 || utf8_strlen($this->request->post['firstname']) > 32) {
$this->error[] = Language::getVar('SUMO_ERROR_FIRSTNAME');
}
if (utf8_strlen($this->request->post['lastname']) < 1 || utf8_strlen($this->request->post['lastname']) > 32) {
$this->error[] = Language::getVar('SUMO_ERROR_LASTNAME');
}
if (utf8_strlen($this->request->post['email']) > 96 || !preg_match('/^[^\\@]+@.*\\.[a-z]{2,6}$/i', $this->request->post['email'])) {
$this->error[] = Language::getVar('SUMO_ERROR_EMAIL');
}
$customer_info = $this->model_sale_customer->getCustomerByEmail($this->request->post['email']);
if (!isset($this->request->get['customer_id'])) {
if ($customer_info) {
$this->error[] = Language::getVar('SUMO_ERROR_EMAIL_EXISTS');
}
} else {
if ($customer_info && $this->request->get['customer_id'] != $customer_info['customer_id']) {
$this->error[] = Language::getVar('SUMO_ERROR_EMAIL_EXISTS');
}
}
if (empty($this->request->post['gender'])) {
$this->error[] = Language::getVar('SUMO_ERROR_GENDER');
}
if (utf8_strlen($this->request->post['telephone']) < 3 || utf8_strlen($this->request->post['telephone']) > 32) {
$this->error[] = Language::getVar('SUMO_ERROR_PHONE');
}
if (!empty($this->request->post['mobile'])) {
if (utf8_strlen($this->request->post['mobile']) < 3 || utf8_strlen($this->request->post['mobile']) > 32) {
$this->error[] = Language::getVar('SUMO_ERROR_MOBILE');
}
}
if ($this->request->post['password'] || !isset($this->request->get['customer_id'])) {
if (utf8_strlen($this->request->post['password']) < 4 || utf8_strlen($this->request->post['password']) > 20) {
$this->error[] = Language::getVar('SUMO_ERROR_PASSWORD');
}
if ($this->request->post['password'] != $this->request->post['confirm']) {
$this->error[] = Language::getVar('SUMO_ERROR_PASSWORD_CONFIRM');
}
}
if (isset($this->request->post['address'])) {
foreach ($this->request->post['address'] as $key => $value) {
// All fields empty? Continue with next item, we're not using this address
if (implode('', $value) == '') {
unset($this->request->post['address'][$key]);
continue;
}
if (utf8_strlen($value['firstname']) < 1 || utf8_strlen($value['firstname']) > 32) {
$this->error['address_firstname'] = Language::getVar('SUMO_ERROR_FIRSTNAME');
}
if (utf8_strlen($value['lastname']) < 1 || utf8_strlen($value['lastname']) > 32) {
$this->error['address_lastname'] = Language::getVar('SUMO_ERROR_LASTNAME');
}
if (utf8_strlen($value['address_1']) < 3 || utf8_strlen($value['address_1']) > 128) {
$this->error['address_address_1'] = Language::getVar('SUMO_ERROR_ADDRESS_1');
}
if (strlen($value['number']) < 1 || strlen($value['number']) > 9) {
$this->error['address_number'] = Language::getVar('SUMO_ERROR_ADDRESS_NUMBER');
}
if (utf8_strlen($value['city']) < 2 || utf8_strlen($value['city']) > 128) {
$this->error['address_city'] = Language::getVar('SUMO_ERROR_CITY');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($value['country_id']);
if ($country_info) {
if ($country_info['postcode_required'] && utf8_strlen($value['postcode']) < 2 || utf8_strlen($value['postcode']) > 10) {
$this->error['address_postcode'] = Language::getVar('SUMO_ERROR_POSTCODE');
}
// VAT Validation
$this->load->helper('vat');
if ($this->config->get('vat') && $value['tax_id'] && vat_validation($country_info['iso_code_2'], $value['tax_id']) == 'invalid') {
$this->error['address_tax_id'] = Language::getVar('SUMO_ERROR_TAX');
}
}
if ($value['country_id'] < 1) {
$this->error['address_country'] = Language::getVar('SUMO_ERROR_COUNTRY');
}
if (!isset($value['zone_id']) || $value['zone_id'] == '') {
$this->error['address_zone'] = Language::getVar('SUMO_ERROR_ZONE');
}
}
}
// Do we at least have on address?
if (!sizeof($this->request->post['address'])) {
$this->error['address'] = Language::getVar('SUMO_ERROR_NO_ADDRESS');
}
if (!$this->error) {
return true;
}
return false;
}
示例15: validateForm
protected function validateForm()
{
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['address_1']) < 3 || utf8_strlen($this->request->post['address_1']) > 128) {
$this->error['address_1'] = $this->language->get('error_address_1');
}
if (utf8_strlen($this->request->post['city']) < 2 || utf8_strlen($this->request->post['city']) > 128) {
$this->error['city'] = $this->language->get('error_city');
}
$this->load->model('localisation/country');
$country_info = $this->model_localisation_country->getCountry($this->request->post['country_id']);
if ($country_info) {
if ($country_info['postcode_required'] && utf8_strlen($this->request->post['postcode']) < 2 || utf8_strlen($this->request->post['postcode']) > 10) {
$this->error['postcode'] = $this->language->get('error_postcode');
}
// VAT Validation
$this->load->helper('vat');
if ($this->config->get('config_vat') && !empty($this->request->post['tax_id']) && vat_validation($country_info['iso_code_2'], $this->request->post['tax_id']) == 'invalid') {
$this->error['tax_id'] = $this->language->get('error_vat');
}
}
if ($this->request->post['country_id'] == '') {
$this->error['country'] = $this->language->get('error_country');
}
if (!isset($this->request->post['zone_id']) || $this->request->post['zone_id'] == '') {
$this->error['zone'] = $this->language->get('error_zone');
}
if (!$this->error) {
return true;
} else {
return false;
}
}