add other option in nationalities

This commit is contained in:
azhar bhat
2026-08-24 18:05:11 +05:30
parent e74a734a5a
commit 211e82380b
8 changed files with 24 additions and 10 deletions

View File

@@ -75,7 +75,7 @@
<div class="row">
<label class="control-label col-lg-3">{l s='Nationality'}</label>
<div class="col-lg-9">
<p class="form-control-static">{if $nationality}{$nationality}{else}{l s='Unknown'}{/if}</p>
<p class="form-control-static">{if $nationality}{$nationality}{else}--{/if}</p>
</div>
</div>
<div class="row">

View File

@@ -173,7 +173,7 @@ class CustomerCore extends ObjectModel
'passwd' => array('type' => self::TYPE_STRING, 'validate' => 'isPasswd', 'required' => true, 'size' => 60),
'last_passwd_gen' => array('type' => self::TYPE_STRING, 'copy_post' => false),
'id_gender' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId'),
'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'copy_post' => false),
'id_country' => array('type' => self::TYPE_INT, 'validate' => 'isInt', 'copy_post' => false),
'birthday' => array('type' => self::TYPE_DATE, 'validate' => 'isBirthDate'),
'newsletter' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
'newsletter_date_add' => array('type' => self::TYPE_DATE,'copy_post' => false),
@@ -838,6 +838,16 @@ class CustomerCore extends ObjectModel
return (int) Configuration::get('PS_COUNTRY_DEFAULT');
}
public static function getNationalities($id_lang)
{
$nationalities = Country::getCountries((int) $id_lang);
$nationalities[-1] = array(
'id_country' => -1,
'name' => Translate::getAdminTranslation('Other', 'AdminCustomersController'),
);
return $nationalities;
}
public function toggleStatus()
{

View File

@@ -88,6 +88,7 @@ class AdminCustomersControllerCore extends AdminController
foreach ($nationalities_result as $row) {
$selected_nationalities[$row['id_country']] = $row['name'];
}
$selected_nationalities[-1] = $this->l('Other');
$selected_countries = array();
$countries_result = Db::getInstance()->executeS('
@@ -337,7 +338,8 @@ class AdminCustomersControllerCore extends AdminController
ad.company as address_company, ad.vat_number,
ad.address1, ad.address2, ad.city, adstate.name as state,
ad.postcode, adcountry.name as country, ad.phone as address_phone,
ad.phone_mobile, ad.dni, natcountry.name as nationality';
ad.phone_mobile, ad.dni,
(CASE WHEN a.id_country = -1 THEN \''.pSQL($this->l('Other')).'\' ELSE natcountry.name END) as nationality';
// Check if we can add a customer
if (Shop::isFeatureActive() && (Shop::getContext() == Shop::CONTEXT_ALL || Shop::getContext() == Shop::CONTEXT_GROUP)) {
@@ -630,7 +632,7 @@ class AdminCustomersControllerCore extends AdminController
'required' => (bool)(Configuration::get('PS_CUSTOMER_NATIONALITY') && Configuration::get('PS_CUSTOMER_NATIONALITY_MANDATORY')),
'col' => '4',
'options' => array(
'query' => Country::getCountries($this->context->language->id),
'query' => Customer::getNationalities($this->context->language->id),
'id' => 'id_country',
'name' => 'name',
'default' => array(
@@ -997,7 +999,9 @@ class AdminCustomersControllerCore extends AdminController
$gender_image = $gender->getImage();
$nationality = '';
if ($customer->id_country) {
if ($customer->id_country == -1) {
$nationality = Translate::getAdminTranslation('Other', 'AdminCustomersController');
} elseif ($customer->id_country) {
$nationalityCountry = new Country($customer->id_country, $this->context->language->id);
if (Validate::isLoadedObject($nationalityCountry)) {
$nationality = $nationalityCountry->name;

View File

@@ -108,7 +108,7 @@ class AuthControllerCore extends FrontController
$this->context->smarty->assign('birthday', (bool) Configuration::get('PS_CUSTOMER_BIRTHDATE'));
$this->context->smarty->assign('nationality', (bool) Configuration::get('PS_CUSTOMER_NATIONALITY'));
$this->context->smarty->assign('nationality_mandatory', (bool) Configuration::get('PS_CUSTOMER_NATIONALITY_MANDATORY'));
$this->context->smarty->assign('nationality_countries', Country::getCountries($this->context->language->id));
$this->context->smarty->assign('nationality_countries', Customer::getNationalities($this->context->language->id));
$this->context->smarty->assign('newsletter', $newsletter);
$this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN'));

View File

@@ -175,7 +175,7 @@ class IdentityControllerCore extends FrontController
$this->context->smarty->assign('birthday', (bool) Configuration::get('PS_CUSTOMER_BIRTHDATE'));
$this->context->smarty->assign('nationality', (bool) Configuration::get('PS_CUSTOMER_NATIONALITY'));
$this->context->smarty->assign('nationality_mandatory', (bool) Configuration::get('PS_CUSTOMER_NATIONALITY_MANDATORY'));
$this->context->smarty->assign('nationality_countries', Country::getCountries($this->context->language->id));
$this->context->smarty->assign('nationality_countries', Customer::getNationalities($this->context->language->id));
$this->context->smarty->assign('newsletter', $newsletter);
$this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN'));

View File

@@ -562,7 +562,7 @@ class OrderOpcControllerCore extends ParentOrderController
$this->context->smarty->assign('birthday', (bool) Configuration::get('PS_CUSTOMER_BIRTHDATE'));
$this->context->smarty->assign('nationality', (bool) Configuration::get('PS_CUSTOMER_NATIONALITY'));
$this->context->smarty->assign('nationality_mandatory', (bool) Configuration::get('PS_CUSTOMER_NATIONALITY_MANDATORY'));
$this->context->smarty->assign('nationality_countries', Country::getCountries($this->context->language->id));
$this->context->smarty->assign('nationality_countries', Customer::getNationalities($this->context->language->id));
$this->context->smarty->assign('newsletter', $newsletter);
$this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN'));
$this->context->smarty->assign('field_required', $this->context->customer->validateFieldsRequiredDatabase());

View File

@@ -587,7 +587,7 @@ CREATE TABLE `PREFIX_customer` (
`id_gender` int(10) unsigned NOT NULL,
`id_default_group` int(10) unsigned NOT NULL DEFAULT '1',
`id_lang` int(10) unsigned NULL,
`id_country` int(10) unsigned NOT NULL DEFAULT '0',
`id_country` int(10) NOT NULL DEFAULT '0',
`id_risk` int(10) unsigned NOT NULL DEFAULT '1',
`company` varchar(64),
`siret` varchar(14),

View File

@@ -912,7 +912,7 @@
<value>1</value>
</configuration>
<configuration id="PS_CUSTOMER_NATIONALITY" name="PS_CUSTOMER_NATIONALITY">
<value>1</value>
<value>0</value>
</configuration>
<configuration id="PS_CUSTOMER_NATIONALITY_MANDATORY" name="PS_CUSTOMER_NATIONALITY_MANDATORY">
<value>0</value>