On 3/2/2020 at 9:18 PM, Marc Bastarache said:CURRENT SOLUTION
It seems like the initContent() function is NOT being executed when submitting the registration form in Prestashop 1.7.6.3... (perhaps above solutions worked in earlier 1.7.x versions?)
Therefore, I was NOT able to apply the above address save logic within the AuthController.php file...
HOWEVER - instead of adding to AuthController.php --- I'm able to update the ps_address file by updating override/classes/form/CustomerPersister.php
(Clear cache after updating below code)1) Within CustomerPersister.php -- find the 2nd occurrence of
$ok = $customer->save();
2) Directly below -- Add your Address Saving Code (slight variation of above solutions to allow same code to work within this logical position)..
//address saving
$address = new Address(
null,
$this->context->language->id
);$address->id_country = (int) Tools::getCountry();
$address->address1 = Tools::getValue('address1');
$address->postcode = Tools::getValue('postcode');
$address->city = Tools::getValue('city');
$address->phone = Tools::getValue('phone');
$address->vat_number = Tools::getValue('vat_number');
$address->firstname = $customer->firstname;
$address->lastname = $customer->lastname;
$address->id_customer = (int) $customer->id;
$address->id_state = 0;
$address->alias = 'My Address';
if($address->save()){
$should_redirect = true;
} else {
$customer->delete();
$this->errors[] = $this->trans('Could not update your information, please check your data.', array(), 'Shop.Notifications.Error');
$this->redirectWithNotifications($this->getCurrentURL());
}
how can i apply this solution to saving new address on identity page? When, for example, client updating his phone and name in my account, in identity section, not in address section
Or perhaps how not to create new address, but update already existing address for same user