Jump to content

[Résolu]Ajouter une adresse à un client


agarmur

Recommended Posts

Bonjour j'essaye d'ajouter une adresse à mon client, le client est bien créer mais il n'arrive pas à créer l'adresse 

Voici mon code :

$crypto = new Hashing();
$xml = simplexml_load_file('php://input');
$client = new Customer($xml->id);
$client->id_gender = 1; //1 monsieur 2 mademoiselle
$client->firstname = (string)$xml->prenom;
$client->lastname = (string)$xml->nom;
$client->email = (string)$xml->email;
$client->passwd = $crypto->hash($xml->motDePasse);
$client->birthday = (string)$xml->dateAnniversaire; //aaaa-mm-jj
$client->active = (bool)$xml->active; //true ou false
$client->newsletter = (bool)$xml->newsletter; //true ou false
$client->optin = (bool)$xml->offrePartenaire; //true ou false
$client->id_default_group = 3;
$client->add();

$address = new Address();
$address->firstname = $client->firstname;
$address->lastname = $client->lastname;
$address->id_customer = $client->id;
$address->alias = "alias";
$address->company = "entreprise";
$address->address1 = "adresse1";
$address->address2 = "adresse2";
$address->postcode = "75000";
$address->city = "Paris";
$address->country = (int)Context::getContext()->country->id;
$address->phone = "0000000000";
$address->phone_mobile = "0000000000";
$address->add();

$this->output .= $client->id;

Merci !

Edited by agarmur
résolution pb (see edit history)
Link to comment
Share on other sites

  • agarmur changed the title to [Résolu]Ajouter une adresse à un client

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...