Creating function in your controller/module/class.
It's dummy way to create it rawly, better to use ForMbuilder of prestashop.
But anyway my code works:
public function createAddressCustom(){
if (((bool)Tools::isSubmit('create_address_custom')) == true){
$user_address_surname = Tools::getValue('adress_surname');
$user_address_name = Tools::getValue('adress_name');
$user_address_address = Tools::getValue('adress_adress');
$user_address_complement = Tools::getValue('adress_complement');
$user_address_postcode = Tools::getValue('adress_postcode');
$user_address_city = Tools::getValue('adress_city');
$user_address_country = Tools::getValue('adress_country');
/*creating address*/
$address = new Address(null, $this->context->language->id);
$address->lastname = trim(ucfirst($user_address_surname));
$address->firstname = trim(ucfirst($user_address_name));
$address->address1 = ucfirst($user_address_address);
$address->address2 = ucfirst($user_address_complement);
$address->postcode = trim($user_address_postcode);
$address->city = ($user_address_city);
$address->id_customer = (int) $this->context->customer->id;
$address->id_country = (int)19;
$address->id_state = 0;
$address->alias = 'Mon adresse';
//dump($address);
$address->save();
}
}
And .tpl file below
<form> <div class="form-group"> <label for="exampleInputEmail1">Nom</label> <input type="text" class="form-control text-capitalize" id="" name="user_surname" placeholder=""> </div> <div class="form-group"> <label for="exampleInputEmail1">Prenom</label> <input type="text" class="form-control text-capitalize" id="" name="user_name" placeholder=""> </div> <div class="form-group"> <label for="exampleInputEmail1">Email address</label> <input type="email" class="form-control" id="" name="user_email" namearia-describedby="emailHelp" placeholder="Votre email"> <small id="emailHelp" class="form-text text-muted">Nous ne partagerons jamais votre e-mail avec quelqu'un d'autre</small> </div> <div class="form-group"> <label for="exampleInputPassword1">Password</label> <input type="password" class="form-control" id="" name="user_password" placeholder="Password"> </div> <div class="form-group"> <label for="exampleInputPassword1">Numero de telephone</label> <input type="number" class="form-control" id="" name="user_phone" placeholder="Example:0041761234567"> <small id="emailHelp" class="form-text text-muted"></small> </div> <div class="form-group"> <label for="exampleInputPassword1">Date de naissance</label> <input type="date" class="form-control" id="" name="user_birthdate" placeholder="jj/mm/aa"> <small id="emailHelp" class="form-text text-muted">Date de votre naissance</small> </div> <button type="submit" class="btn btn-primary" name="create_user_custom" value="Save">Submit</button> </form>
Dont forget to add phone number to ps_customer table, because I link the phone not to adress but to customer.
Also dont forget to link your tpl to the controller/module:
return $this->display(__FILE__, 'views/templates/front/create_order.tpl');
//or path you desire
P.S. just remember, you need to adapt the code to your needs, it's something as cheatsheet I wrote you and code was written to my needs.