Jump to content

Edit History

Welele

Welele

this post would be perfect and it would be solved if the state field problem was solved.

Is anyone capable???

 

 

Thanks in advance

 

 

 

Welele

Welele

On 2/22/2022 at 3:19 PM, wegorz23 said:


Add code inside CustomerPersister.php is good solution.




But if you want add County field, add this code in file override/classes/form/CustomerFormatter.php :

        $countries = Country::getCountries((int)$this->language->id, true, false, false);
        if (count($countries) > 0) {
            $countryField = (new FormField)
                ->setName('id_country')
                ->setType('countrySelect')
                ->setLabel($this->translator->trans('Country', [], 'Shop.Forms.Labels'))
                ->setRequired(true);
            foreach ($countries as $country) {
                $countryField->addAvailableValue(
                    $country['id_country'],
                    $country['country']
                );
            }
            $format[$countryField->getName()] = $countryField;
        }



and this code in file override/classes/form/CustomerPersister.php:
 

//$address->id_country = (int) Tools::getCountry();
					
$address->id_country = (int)Tools::getValue('id_country') > 0 ? Tools::getValue('id_country') : (int) Tools::getCountry();



 

 

 

Can you show me your overrides? 

CustomerFormatted.php

CustomerPersister.php

image.thumb.png.ccb80570741a93fb519c4558b639b21a.png

I followed the thread and donest work for me...

 

Thanks in advance

 

 

 

Welele

Welele

On 2/22/2022 at 3:19 PM, wegorz23 said:


Add code inside CustomerPersister.php is good solution.




But if you want add County field, add this code in file override/classes/form/CustomerFormatter.php :

        $countries = Country::getCountries((int)$this->language->id, true, false, false);
        if (count($countries) > 0) {
            $countryField = (new FormField)
                ->setName('id_country')
                ->setType('countrySelect')
                ->setLabel($this->translator->trans('Country', [], 'Shop.Forms.Labels'))
                ->setRequired(true);
            foreach ($countries as $country) {
                $countryField->addAvailableValue(
                    $country['id_country'],
                    $country['country']
                );
            }
            $format[$countryField->getName()] = $countryField;
        }



and this code in file override/classes/form/CustomerPersister.php:
 

//$address->id_country = (int) Tools::getCountry();
					
$address->id_country = (int)Tools::getValue('id_country') > 0 ? Tools::getValue('id_country') : (int) Tools::getCountry();



 

 

 

Can you show me your overrides? 

CustomerFormatted.php

CustomerPersister.php

image.thumb.png.ccb80570741a93fb519c4558b639b21a.png

I followed the thread and donest work for me...

 

×
×
  • Create New...