Jump to content

Edit History

agarmur

agarmur


résolution pb

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 !

agarmur

agarmur

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 !

agarmur

agarmur

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 !

×
×
  • Create New...