Child pages
  • Chapter 7 - Removal - Remove customer accounts from the database

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Here is the complete, detailed code you need in order to remove a customer:

Code Block

try {
	$webService = new PrestaShopWebservice('[http://mystore.com/|http://mystore.com/]' , 'ZR92FNY5UFRERNI3O9Z5QDHWKTP3YIIT' , false); // Create an instance
	$opt['resource'] = 'customers';            // Resource to use
	opt['id'] = 3;                             // ID to use
	$webService->delete($opt);                 // Delete
	echo 'Client '.3.' successfully deleted!'; // If we can see this message, that means we have not left the try block
}
catch (PrestaShopWebserviceException $ex) {
	$trace = $ex->getTrace();                // Retrieve all info on this error
	$errorCode = $trace[0]['args'][0]; // Retrieve error code 
	if ($errorCode == 401) 
		echo 'Bad auth key';   
	else 
		echo 'Other error: <br />'.$ex->getMessage(); 
	// Display error message{color}
}

...