zak92
zak92

Reputation: 77

Get users information when creating a customer

I'm trying to create a Prestashop Module which when a user is created, I can get all his information automatically using ActionCustomerAccountAdd, this event return ($params), but I don't know the structure of the object params for getting the data needed

I tried to create hookActionCustomerAccountAdd which get params, I was able to get just the email of the customer $params['newCustomer']->email, but I can't get the first name and last name and the password

// Will be executed each times actionCustomerAccountAdd is triggered
public function hookActionCustomerAccountAdd($params)
{
  // $params is an array set by PrestaShop which contains the 
  // hook data (here, the customer details

  $this->CustomerAdd($params['newCustomer']->email);

  /*   $json_output = json_decode($params,true); 
        var_dump($json_output) ;
        echo "Works";
  */
}

public function CustomerAdd($mail){
   $myObj->userx->UserID = 0;
   $myObj->userx->Username = "NameUser";
   $myObj->userx->Password ="Password";
   $myObj->userx->Fname ="Fname";
   $myObj->userx->Lname= "Lname";
   $myObj->userx->Mail= $mail;
   $myObj->username= "evdokimosk";
   $myObj->password="123425";
}

I expect to get all data I need like first name, last name but I don't know what is inside the $params

Upvotes: 1

Views: 298

Answers (1)

ethercreation
ethercreation

Reputation: 1273

$params['newCustomer'] is the object of the client, so you can retrieve customer information: :

$firstname = $params['newCustomer']->firstname;
$lastname = $params['newCustomer']->lastname;
....

Regards

Upvotes: 2

Related Questions