本文整理汇总了PHP中Country::getByIso方法的典型用法代码示例。如果您正苦于以下问题:PHP Country::getByIso方法的具体用法?PHP Country::getByIso怎么用?PHP Country::getByIso使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Country
的用法示例。
在下文中一共展示了Country::getByIso方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: install
public function install()
{
if (!parent::install() || !$this->installExternalCarrier($this->_config) || !Configuration::updateValue('EXTERNAL_CARRIER_OVERCOST', 5) || !$this->registerHook('updateCarrier') || !$this->registerHook('extraCarrier') || !$this->registerHook('newOrder') || !$this->registerHook('processCarrier') || !$this->registerHook('orderDetailDisplayed') || !$this->registerHook('updateOrderStatus') || !Configuration::updateValue('KIALASMALL_VERSION', $this->version) || !Configuration::updateValue('KIALASMALL_SECURITY_TOKEN', Tools::passwdGen(30)) || !Configuration::updateValue('KIALASMALL_WS_URL', $this->ws_url) || !Configuration::updateValue('KIALASMALL_SEARCH_BY', 'order')) {
return false;
}
// Install SQL
include dirname(__FILE__) . '/sql-install.php';
foreach ($sql as $s) {
if (!Db::getInstance()->Execute($s)) {
return false;
}
}
// Create country settings
foreach ($this->countries as $iso_code) {
$id_country = Country::getByIso($iso_code);
if ($id_country) {
$kiala_country = new SmKialaCountry();
$kiala_country->id_country = $id_country;
$kiala_country->preparation_delay = $this->default_preparation_delay;
$kiala_country->active = 0;
// Is this the merchant home country?
if ($id_country == Country::getByIso('ES')) {
$kiala_country->pickup_country = 1;
$kiala_country->dspid = '34600160';
}
$kiala_country->save();
}
}
return true;
}
示例2: postProcess
public function postProcess()
{
if (isset($_GET['delete' . $this->table]) || Tools::getValue('submitDel' . $this->table)) {
$this->_errors[] = Tools::displayError('You cannot delete a country. If you do not want it available for customers, please disable it.');
} elseif (Tools::getValue('submitAdd' . $this->table)) {
if (!Tools::getValue('id_' . $this->table)) {
if (Validate::isLanguageIsoCode(Tools::getValue('iso_code')) && Country::getByIso(Tools::getValue('iso_code'))) {
$this->_errors[] = Tools::displayError('This ISO code already exists, you cannot create two country with the same ISO code');
}
} else {
if (Validate::isLanguageIsoCode(Tools::getValue('iso_code'))) {
$id_country = Country::getByIso(Tools::getValue('iso_code'));
if (!is_null($id_country) && $id_country != Tools::getValue('id_' . $this->table)) {
$this->_errors[] = Tools::displayError('This ISO code already exists, you cannot create two country with the same ISO code');
}
}
}
if (Tools::isSubmit('standardization')) {
Configuration::updateValue('PS_TAASC', (bool) Tools::getValue('standardization', false));
}
if (isset($this->_errors) && count($this->_errors)) {
return false;
}
}
return parent::postProcess();
}
示例3: setCustomerAddress
/**
* Set customer address (when not logged in)
* Used to create user address with PayPal account information
*/
function setCustomerAddress($ppec, $customer, $id = null)
{
$address = new Address($id);
$address->id_country = Country::getByIso($ppec->result['COUNTRYCODE']);
$address->alias = 'Paypal_Address';
$address->lastname = $customer->lastname;
$address->firstname = $customer->firstname;
$address->address1 = $ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET'];
if (isset($ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET2'])) {
$address->address2 = $ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET2'];
}
$address->city = $ppec->result['PAYMENTREQUEST_0_SHIPTOCITY'];
$address->id_state = (int) State::getIdByIso($ppec->result['SHIPTOSTATE'], $address->id_country);
$address->postcode = $ppec->result['SHIPTOZIP'];
$address->id_customer = $customer->id;
return $address;
}
示例4: getByIdCountry
/**
* Get SmKialaCountry object by id_country
*
* @param int $id_country
* @return boolean|SmKialaCountry fetched object or false
*/
public static function getByIdCountry($id_country)
{
// Luxemburg is grouped with Belgium by Kiala
if (Country::getIsoById($id_country) == 'LU') {
$id_country = Country::getByIso('BE');
}
$result = Db::getInstance()->getRow('
SELECT `id_sm_kiala_country`, `id_country`, `dspid`, `sender_id`, `password`, `preparation_delay`, `active`
FROM `' . _DB_PREFIX_ . 'sm_kiala_country`
WHERE `id_country` = ' . (int) $id_country);
if (!$result) {
return false;
}
$kiala_country = new self();
$kiala_country->setData($result);
return $kiala_country;
}
示例5: preProcess
public function preProcess()
{
parent::preProcess();
if (self::$cookie->isLogged() and !Tools::isSubmit('ajax')) {
Tools::redirect('my-account.php');
}
if (Tools::getValue('create_account')) {
$create_account = 1;
self::$smarty->assign('email_create', 1);
}
if (Tools::isSubmit('SubmitCreate')) {
if (!Validate::isEmail($email = Tools::getValue('email_create')) or empty($email)) {
$this->errors[] = Tools::displayError('Invalid e-mail address');
} elseif (Customer::customerExists($email)) {
$this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
$_POST['email'] = $_POST['email_create'];
unset($_POST['email_create']);
} else {
$create_account = 1;
self::$smarty->assign('email_create', Tools::safeOutput($email));
$_POST['email'] = $email;
}
}
if (Tools::isSubmit('submitAccount') or Tools::isSubmit('submitGuestAccount')) {
$create_account = 1;
if (Tools::isSubmit('submitAccount')) {
self::$smarty->assign('email_create', 1);
}
/* New Guest customer */
if (!Tools::getValue('is_new_customer', 1) and !Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
$this->errors[] = Tools::displayError('You cannot create a guest account.');
}
if (!Tools::getValue('is_new_customer', 1)) {
$_POST['passwd'] = md5(time() . _COOKIE_KEY_);
}
if (isset($_POST['guest_email']) and $_POST['guest_email']) {
$_POST['email'] = $_POST['guest_email'];
}
/* Preparing customer */
$customer = new Customer();
$lastnameAddress = $_POST['lastname'];
$firstnameAddress = $_POST['firstname'];
$_POST['lastname'] = $_POST['customer_lastname'];
$_POST['firstname'] = $_POST['customer_firstname'];
if (!Tools::getValue('phone') and !Tools::getValue('phone_mobile')) {
$this->errors[] = Tools::displayError('You must register at least one phone number');
}
if (!@checkdate(Tools::getValue('months'), Tools::getValue('days'), Tools::getValue('years')) and !(Tools::getValue('months') == '' and Tools::getValue('days') == '' and Tools::getValue('years') == '')) {
$this->errors[] = Tools::displayError('Invalid date of birth');
}
$customer->birthday = empty($_POST['years']) ? '' : (int) $_POST['years'] . '-' . (int) $_POST['months'] . '-' . (int) $_POST['days'];
$this->errors = array_unique(array_merge($this->errors, $customer->validateControler()));
/* Preparing address */
$address = new Address();
$_POST['lastname'] = $lastnameAddress;
$_POST['firstname'] = $firstnameAddress;
$address->id_customer = 1;
$this->errors = array_unique(array_merge($this->errors, $address->validateControler()));
/* US customer: normalize the address */
if ($address->id_country == Country::getByIso('US')) {
include_once _PS_TAASC_PATH_ . 'AddressStandardizationSolution.php';
$normalize = new AddressStandardizationSolution();
$address->address1 = $normalize->AddressLineStandardization($address->address1);
$address->address2 = $normalize->AddressLineStandardization($address->address2);
}
$zip_code_format = Country::getZipCodeFormat((int) Tools::getValue('id_country'));
if (Country::getNeedZipCode((int) Tools::getValue('id_country'))) {
if ($postcode = Tools::getValue('postcode') and $zip_code_format) {
$zip_regexp = '/^' . $zip_code_format . '$/ui';
$zip_regexp = str_replace(' ', '( |)', $zip_regexp);
$zip_regexp = str_replace('-', '(-|)', $zip_regexp);
$zip_regexp = str_replace('N', '[0-9]', $zip_regexp);
$zip_regexp = str_replace('L', '[a-zA-Z]', $zip_regexp);
$zip_regexp = str_replace('C', Country::getIsoById((int) Tools::getValue('id_country')), $zip_regexp);
if (!preg_match($zip_regexp, $postcode)) {
$this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.') . '<br />' . Tools::displayError('Must be typed as follows:') . ' ' . str_replace('C', Country::getIsoById((int) Tools::getValue('id_country')), str_replace('N', '0', str_replace('L', 'A', $zip_code_format)));
}
} elseif ($zip_code_format) {
$this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is required.');
} elseif ($postcode and !preg_match('/^[0-9a-zA-Z -]{4,9}$/ui', $postcode)) {
$this->errors[] = '<strong>' . Tools::displayError('Zip/ Postal code') . '</strong> ' . Tools::displayError('is invalid.');
}
}
if (Country::isNeedDniByCountryId($address->id_country) and (!Tools::getValue('dni') or !Validate::isDniLite(Tools::getValue('dni')))) {
$this->errors[] = Tools::displayError('Identification number is incorrect or has already been used.');
} elseif (!Country::isNeedDniByCountryId($address->id_country)) {
$address->dni = NULL;
}
if (!sizeof($this->errors)) {
if (Customer::customerExists(Tools::getValue('email'))) {
$this->errors[] = Tools::displayError('An account is already registered with this e-mail, please fill in the password or request a new one.');
}
if (Tools::isSubmit('newsletter')) {
$customer->ip_registration_newsletter = pSQL(Tools::getRemoteAddr());
$customer->newsletter_date_add = pSQL(date('Y-m-d H:i:s'));
}
if (!sizeof($this->errors)) {
if (!($country = new Country($address->id_country, Configuration::get('PS_LANG_DEFAULT'))) or !Validate::isLoadedObject($country)) {
die(Tools::displayError());
}
//.........这里部分代码省略.........
示例6: getInstanceByKey
/**
* Get Instance for Ebay Country
* @param string $key Key of country
* @param boolean $dev If module work in debug
* @return EbayCountrySpec Ebay country
*/
public static function getInstanceByKey($key, $dev = false)
{
if (isset(self::$country_data[$key])) {
$iso_code = self::$country_data[$key]['iso_code'];
$id_country = Country::getByIso($iso_code);
} else {
$id_country = Configuration::get('PS_COUNTRY_DEFAULT');
}
$ebay_country = new EbayCountrySpec(new Country($id_country));
$ebay_country->setDev($dev);
$ebay_country->ebay_iso = is_numeric($key) ? self::getKeyForEbayCountry() : $key;
return $ebay_country;
}
示例7: getCountry
public static function getCountry($address = null)
{
if ($id_country = Tools::getValue('id_country')) {
} elseif (isset($address) && isset($address->id_country) && $address->id_country) {
$id_country = $address->id_country;
} elseif (Configuration::get('PS_DETECT_COUNTRY') && isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
preg_match('#(?<=-)\\w\\w|\\w\\w(?!-)#', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $array);
if (is_array($array) && isset($array[0]) && Validate::isLanguageIsoCode($array[0])) {
$id_country = Country::getByIso($array[0], true);
}
}
if (!isset($id_country) || !$id_country) {
$id_country = Configuration::get('PS_COUNTRY_DEFAULT');
}
return (int) $id_country;
}
示例8: postProcess
public function postProcess()
{
if (!Tools::getValue('id_' . $this->table)) {
if (Validate::isLanguageIsoCode(Tools::getValue('iso_code')) && Country::getByIso(Tools::getValue('iso_code'))) {
$this->errors[] = Tools::displayError('This ISO code already exists.You cannot create two countries with the same ISO code.');
}
} else {
if (Validate::isLanguageIsoCode(Tools::getValue('iso_code'))) {
$id_country = Country::getByIso(Tools::getValue('iso_code'));
if (!is_null($id_country) && $id_country != Tools::getValue('id_' . $this->table)) {
$this->errors[] = Tools::displayError('This ISO code already exists.You cannot create two countries with the same ISO code.');
}
}
}
return parent::postProcess();
}
开发者ID:AmineBENCHEIKHBRAHIM,项目名称:LnsTech-Prestashop-WebSite,代码行数:16,代码来源:AdminCountriesController.php
示例9: geolocationManagement
protected function geolocationManagement($default_country)
{
if (!in_array($_SERVER['SERVER_NAME'], array('localhost', '127.0.0.1'))) {
/* Check if Maxmind Database exists */
if (file_exists(_PS_GEOIP_DIR_ . 'GeoLiteCity.dat')) {
if (!isset($this->context->cookie->iso_code_country) || isset($this->context->cookie->iso_code_country) && !in_array(strtoupper($this->context->cookie->iso_code_country), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES')))) {
include_once _PS_GEOIP_DIR_ . 'geoipcity.inc';
$gi = geoip_open(realpath(_PS_GEOIP_DIR_ . 'GeoLiteCity.dat'), GEOIP_STANDARD);
$record = geoip_record_by_addr($gi, Tools::getRemoteAddr());
if (is_object($record)) {
if (!in_array(strtoupper($record->country_code), explode(';', Configuration::get('PS_ALLOWED_COUNTRIES'))) && !FrontController::isInWhitelistForGeolocation()) {
if (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_) {
$this->restrictedCountry = true;
} elseif (Configuration::get('PS_GEOLOCATION_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_) {
$this->context->smarty->assign(array('restricted_country_mode' => true, 'geolocation_country' => $record->country_name));
}
} else {
$has_been_set = !isset($this->context->cookie->iso_code_country);
$this->context->cookie->iso_code_country = strtoupper($record->country_code);
}
}
}
if (isset($this->context->cookie->iso_code_country) && $this->context->cookie->iso_code_country && !Validate::isLanguageIsoCode($this->context->cookie->iso_code_country)) {
$this->context->cookie->iso_code_country = Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT'));
}
if (isset($this->context->cookie->iso_code_country) && ($id_country = Country::getByIso(strtoupper($this->context->cookie->iso_code_country)))) {
/* Update defaultCountry */
if ($default_country->iso_code != $this->context->cookie->iso_code_country) {
$default_country = new Country($id_country);
}
if (isset($has_been_set) && $has_been_set) {
$this->context->cookie->id_currency = (int) Currency::getCurrencyInstance($default_country->id_currency ? (int) $default_country->id_currency : Configuration::get('PS_CURRENCY_DEFAULT'))->id;
}
return $default_country;
} elseif (Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_CATALOG_ && !FrontController::isInWhitelistForGeolocation()) {
$this->restrictedCountry = true;
} elseif (Configuration::get('PS_GEOLOCATION_NA_BEHAVIOR') == _PS_GEOLOCATION_NO_ORDER_ && !FrontController::isInWhitelistForGeolocation()) {
$this->context->smarty->assign(array('restricted_country_mode' => true, 'geolocation_country' => 'Undefined'));
}
} else {
Configuration::updateValue('PS_GEOLOCATION_ENABLED', 0);
}
}
return false;
}
示例10: foreach
if (!isset($ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET']) || !isset($ppec->result['PAYMENTREQUEST_0_SHIPTOCITY']) || !isset($ppec->result['SHIPTOZIP']) || !isset($ppec->result['COUNTRYCODE'])) {
$ppec->redirectToCheckout($customer, $ppec->type != 'payment_cart');
}
foreach ($customer->getAddresses($ppec->getContext()->language->id) as $address) {
if ($address['alias'] == 'Paypal_Address') {
$address = new Address($address['id_address']);
break;
}
}
// Create address
if (is_array($address) && isset($address['id_address'])) {
$address = new Address($address['id_address']);
}
if ((!$address || !$address->id) && $customer->id) {
$address = new Address();
$address->id_country = Country::getByIso($ppec->result['COUNTRYCODE']);
$address->alias = 'Paypal_Address';
$address->lastname = $customer->lastname;
$address->firstname = $customer->firstname;
$address->address1 = $ppec->result['PAYMENTREQUEST_0_SHIPTOSTREET'];
$address->city = $ppec->result['PAYMENTREQUEST_0_SHIPTOCITY'];
$address->postcode = $ppec->result['SHIPTOZIP'];
$address->id_customer = $customer->id;
$address->add();
}
if ($customer->id && !$address->id) {
$ppec->logs[] = $ppec->l('Cannot create Address');
}
// Create Order
if ($address->id && $customer->id) {
$ppec->getContext()->cart->id_customer = $customer->id;
示例11: intval
$years = Tools::dateYears();
if (isset($_POST['months']) and is_numeric($_POST['months'])) {
$selectedMonths = intval($_POST['months']);
}
$months = Tools::dateMonths();
if (isset($_POST['days']) and is_numeric($_POST['days'])) {
$selectedDays = intval($_POST['days']);
}
$days = Tools::dateDays();
/* Select the most appropriate country */
if (isset($_POST['id_country']) and is_numeric($_POST['id_country'])) {
$selectedCountry = intval($_POST['id_country']);
} elseif (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$array = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
if (Validate::isLanguageIsoCode($array[0])) {
$selectedCountry = Country::getByIso($array[0]);
if (!$selectedCountry) {
$selectedCountry = intval(Configuration::get('PS_COUNTRY_DEFAULT'));
}
}
}
if (!isset($selectedCountry)) {
$selectedCountry = intval(Configuration::get('PS_COUNTRY_DEFAULT'));
}
$countries = Country::getCountries(intval($cookie->id_lang), true);
$smarty->assign(array('years' => $years, 'sl_year' => isset($selectedYears) ? $selectedYears : 0, 'months' => $months, 'sl_month' => isset($selectedMonths) ? $selectedMonths : 0, 'days' => $days, 'sl_day' => isset($selectedDays) ? $selectedDays : 0, 'countries' => $countries, 'sl_country' => isset($selectedCountry) ? $selectedCountry : 0));
/* Call a hook to display more information on form */
$smarty->assign(array('HOOK_CREATE_ACCOUNT_FORM' => Module::hookExec('createAccountForm'), 'HOOK_CREATE_ACCOUNT_TOP' => Module::hookExec('createAccountTop')));
}
include dirname(__FILE__) . '/header.php';
$smarty->assign('errors', $errors);
示例12: getCountryByCode
/**
* Get Country object by code
* @param string $code Code
* @return Country Country object
*/
protected function getCountryByCode($code)
{
$idCountry = (int) Country::getByIso($code);
$country = new Country($idCountry, (int) $this->context->language->id);
return $country;
}
示例13: _expressCheckout
/**
* When the customer is back from PayPal after filling his/her credit card info or credentials, this function is preparing the order
* PayPal is providing us with the customer info (E-mail address, billing address) and we are trying to find a matching customer in the Shop database.
* If no customer is found, we create a new one and we simulate a logged customer session.
* Eventually it will redirect the customer to the "Shipping" step/page of the order process
*/
private function _expressCheckout()
{
/* We need to double-check that the token provided by PayPal is the one expected */
$result = $this->paypal_usa->postToPayPal('GetExpressCheckoutDetails', '&TOKEN=' . urlencode(Tools::getValue('token')));
if ((strtoupper($result['ACK']) == 'SUCCESS' || strtoupper($result['ACK']) == 'SUCCESSWITHWARNING') && $result['TOKEN'] == Tools::getValue('token') && $result['PAYERID'] == Tools::getValue('PayerID')) {
/* Checks if a customer already exists for this e-mail address */
if (Validate::isEmail($result['EMAIL'])) {
$customer = new Customer();
$customer->getByEmail($result['EMAIL']);
}
/* If the customer does not exist yet, create a new one */
if (!Validate::isLoadedObject($customer)) {
$customer = new Customer();
$customer->email = $result['EMAIL'];
$customer->firstname = $result['FIRSTNAME'];
$customer->lastname = $result['LASTNAME'];
$customer->passwd = Tools::encrypt(Tools::passwdGen());
$customer->add();
}
/* Look for an existing PayPal address for this customer */
$addresses = $customer->getAddresses((int) Configuration::get('PS_LANG_DEFAULT'));
foreach ($addresses as $address) {
if ($address['alias'] == 'PayPal') {
$id_address = (int) $address['id_address'];
break;
}
}
/* Create or update a PayPal address for this customer */
$address = new Address(isset($id_address) ? (int) $id_address : 0);
$address->id_customer = (int) $customer->id;
$address->id_country = (int) Country::getByIso($result['PAYMENTREQUEST_0_SHIPTOCOUNTRYCODE']);
$address->id_state = (int) State::getIdByIso($result['PAYMENTREQUEST_0_SHIPTOSTATE'], (int) $address->id_country);
$address->alias = 'PayPal';
$address->lastname = substr($result['PAYMENTREQUEST_0_SHIPTONAME'], 0, strpos($result['PAYMENTREQUEST_0_SHIPTONAME'], ' '));
$address->firstname = substr($result['PAYMENTREQUEST_0_SHIPTONAME'], strpos($result['PAYMENTREQUEST_0_SHIPTONAME'], ' '), strlen($result['PAYMENTREQUEST_0_SHIPTONAME']) - strlen($address->lastname));
$address->address1 = $result['PAYMENTREQUEST_0_SHIPTOSTREET'];
if ($result['PAYMENTREQUEST_0_SHIPTOSTREET2'] != '') {
$address->address2 = $result['PAYMENTREQUEST_0_SHIPTOSTREET2'];
}
$address->city = $result['PAYMENTREQUEST_0_SHIPTOCITY'];
$address->postcode = $result['PAYMENTREQUEST_0_SHIPTOZIP'];
$address->save();
/* Update the cart billing and delivery addresses */
$this->context->cart->id_address_delivery = (int) $address->id;
$this->context->cart->id_address_invoice = (int) $address->id;
$this->context->cart->update();
/* Update the customer cookie to simulate a logged-in session */
$this->context->cookie->id_customer = (int) $customer->id;
$this->context->cookie->customer_lastname = $customer->lastname;
$this->context->cookie->customer_firstname = $customer->firstname;
$this->context->cookie->passwd = $customer->passwd;
$this->context->cookie->email = $customer->email;
$this->context->cookie->is_guest = $customer->isGuest();
$this->context->cookie->logged = 1;
/* Save the Payer ID and Checkout token for later use (during the payment step/page) */
$this->context->cookie->paypal_express_checkout_token = $result['TOKEN'];
$this->context->cookie->paypal_express_checkout_payer_id = $result['PAYERID'];
if (_PS_VERSION_ < '1.5') {
Module::hookExec('authentication');
} else {
Hook::exec('authentication');
}
/* Redirect the use to the "Shipping" step/page of the order process */
Tools::redirectLink($this->context->link->getPageLink('order.php', false, null, array('step' => '3')));
exit;
} else {
foreach ($result as $key => $val) {
$result[$key] = urldecode($val);
}
$this->context->smarty->assign('paypal_usa_errors', $result);
$this->setTemplate('express-checkout-messages.tpl');
}
}
示例14: postProcess
public function postProcess()
{
if (!Tools::getValue('id_' . $this->table)) {
if (Validate::isLanguageIsoCode(Tools::getValue('iso_code')) && Country::getByIso(Tools::getValue('iso_code'))) {
$this->errors[] = Tools::displayError('This ISO code already exists.You cannot create two countries with the same ISO code.');
}
} else {
if (Validate::isLanguageIsoCode(Tools::getValue('iso_code'))) {
$id_country = Country::getByIso(Tools::getValue('iso_code'));
if (!is_null($id_country) && $id_country != Tools::getValue('id_' . $this->table)) {
$this->errors[] = Tools::displayError('This ISO code already exists.You cannot create two countries with the same ISO code.');
}
}
}
if (Tools::isSubmit('standardization')) {
Configuration::updateValue('PS_TAASC', (bool) Tools::getValue('standardization', false));
}
return parent::postProcess();
}
示例15: postProcess
public function postProcess()
{
if (!Tools::getValue('id_' . $this->table)) {
if (Validate::isLanguageIsoCode(Tools::getValue('iso_code')) && Country::getByIso(Tools::getValue('iso_code'))) {
$this->errors[] = Tools::displayError('This ISO code already exists, you cannot create two country with the same ISO code');
}
} else {
if (Validate::isLanguageIsoCode(Tools::getValue('iso_code'))) {
$id_country = Country::getByIso(Tools::getValue('iso_code'));
if (!is_null($id_country) && $id_country != Tools::getValue('id_' . $this->table)) {
$this->errors[] = Tools::displayError('This ISO code already exists, you cannot create two country with the same ISO code');
}
}
}
if (!count($this->errors)) {
$res = parent::postProcess();
} else {
return false;
}
if (Tools::getValue('submitAdd' . $this->table) && $res) {
$id_country = ($id_country = Tools::getValue('id_country')) ? $id_country : $res['id'];
$tmp_addr_format = new AddressFormat($id_country);
$save_status = false;
$is_new = is_null($tmp_addr_format->id_country);
if ($is_new) {
$tmp_addr_format = new AddressFormat();
$tmp_addr_format->id_country = $id_country;
}
$tmp_addr_format->format = Tools::getValue('address_layout');
if (strlen($tmp_addr_format->format) > 0) {
if ($tmp_addr_format->checkFormatFields()) {
$save_status = $is_new ? $tmp_addr_format->save() : $tmp_addr_format->update();
} else {
$error_list = $tmp_addr_format->getErrorList();
foreach ($error_list as $num_error => $error) {
$this->errors[] = $error;
}
}
if (!$save_status) {
$this->errors[] = Tools::displayError('Invalid address layout' . Db::getInstance()->getMsgError());
}
}
unset($tmp_addr_format);
}
return $res;
}