// Refactor AdminController::_errors to errors
This commit is contained in:
@@ -297,7 +297,7 @@ class AdminAddressesControllerCore extends AdminController
|
||||
if (Validate::isLoadedObject($customer))
|
||||
$_POST['id_customer'] = $customer->id;
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('This e-mail address is not registered.');
|
||||
$this->errors[] = Tools::displayError('This e-mail address is not registered.');
|
||||
}
|
||||
else if ($id_customer = Tools::getValue('id_customer'))
|
||||
{
|
||||
@@ -305,23 +305,23 @@ class AdminAddressesControllerCore extends AdminController
|
||||
if (Validate::isLoadedObject($customer))
|
||||
$_POST['id_customer'] = $customer->id;
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('Unknown customer');
|
||||
$this->errors[] = Tools::displayError('Unknown customer');
|
||||
}
|
||||
else
|
||||
$this->_errors[] = Tools::displayError('Unknown customer');
|
||||
$this->errors[] = Tools::displayError('Unknown customer');
|
||||
if (Country::isNeedDniByCountryId(Tools::getValue('id_country')) && !Tools::getValue('dni'))
|
||||
$this->_errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
|
||||
$this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
|
||||
|
||||
/* If the selected country does not contain states */
|
||||
$id_state = (int)Tools::getValue('id_state');
|
||||
$id_country = (int)Tools::getValue('id_country');
|
||||
$country = new Country((int)$id_country);
|
||||
if ($country && !(int)$country->contains_states && $id_state)
|
||||
$this->_errors[] = Tools::displayError('You have selected a state for a country that does not contain states.');
|
||||
$this->errors[] = Tools::displayError('You have selected a state for a country that does not contain states.');
|
||||
|
||||
/* If the selected country contains states, then a state have to be selected */
|
||||
if ((int)$country->contains_states && !$id_state)
|
||||
$this->_errors[] = Tools::displayError('An address located in a country containing states must have a state selected.');
|
||||
$this->errors[] = Tools::displayError('An address located in a country containing states must have a state selected.');
|
||||
|
||||
/* Check zip code */
|
||||
if ($country->need_zip_code)
|
||||
@@ -336,14 +336,14 @@ class AdminAddressesControllerCore extends AdminController
|
||||
$zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);
|
||||
$zip_regexp = str_replace('C', $country->iso_code, $zip_regexp);
|
||||
if (!preg_match($zip_regexp, $postcode))
|
||||
$this->_errors[] = Tools::displayError('Your zip/postal code is incorrect.').'<br />'.
|
||||
$this->errors[] = Tools::displayError('Your zip/postal code is incorrect.').'<br />'.
|
||||
Tools::displayError('Must be typed as follows:').' '.
|
||||
str_replace('C', $country->iso_code, str_replace('N', '0', str_replace('L', 'A', $zip_code_format)));
|
||||
}
|
||||
else if ($zip_code_format)
|
||||
$this->_errors[] = Tools::displayError('Postcode required.');
|
||||
$this->errors[] = Tools::displayError('Postcode required.');
|
||||
else if ($postcode && !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode))
|
||||
$this->_errors[] = Tools::displayError('Your zip/postal code is incorrect.');
|
||||
$this->errors[] = Tools::displayError('Your zip/postal code is incorrect.');
|
||||
}
|
||||
|
||||
/* If this address come from order's edition and is the same as the other one (invoice or delivery one)
|
||||
@@ -355,15 +355,15 @@ class AdminAddressesControllerCore extends AdminController
|
||||
$_POST['id_address'] = '';
|
||||
}
|
||||
|
||||
if (empty($this->_errors))
|
||||
if (empty($this->errors))
|
||||
parent::processSave($token);
|
||||
|
||||
/* Reassignation of the order's new (invoice or delivery) address */
|
||||
$address_type = ((int)Tools::getValue('address_type') == 2 ? 'invoice' : ((int)Tools::getValue('address_type') == 1 ? 'delivery' : ''));
|
||||
if ($this->action == 'save' && ($id_order = (int)Tools::getValue('id_order')) && !count($this->_errors) && !empty($address_type))
|
||||
if ($this->action == 'save' && ($id_order = (int)Tools::getValue('id_order')) && !count($this->errors) && !empty($address_type))
|
||||
{
|
||||
if (!Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'orders SET `id_address_'.$address_type.'` = '.Db::getInstance()->Insert_ID().' WHERE `id_order` = '.$id_order))
|
||||
$this->_errors[] = Tools::displayError('An error occurred while linking this address to its order.');
|
||||
$this->errors[] = Tools::displayError('An error occurred while linking this address to its order.');
|
||||
else
|
||||
Tools::redirectAdmin(Tools::getValue('back').'&conf=4');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user