Tuesday, February 26, 2019

PHP > 2012.2 Toolkit > Adding a customer with an address


Below is sample code on how to add a customer via web services with an address

require_once '../PHPToolkit/NetSuiteService.php';

$service = new NetSuiteService();

$customer = new Customer();
$customer->lastName = "Doe";
$customer->firstName = "John";
$customer->companyName = "ABC company 21";
$customer->phone = "123456789";

$addressbook = new CustomerAddressbook();
$addressbook = array(
'defaultShipping' => true,
'defaultBilling' => true,
'addr1' => "123 Test Php Customer Add",
'zip' => "90210",
'country' => '_unitedStates',
'state' => 'CA');

$addressBookList = new CustomerAddressbookList();
$addressBookList->addressbook = $addressbook;

$customer->addressbookList = $addressBookList;


$request = new AddRequest();
$request->record = $customer;

$addResponse = $service->add($request);

if (!$addResponse->writeResponse->status->isSuccess) {
echo "ADD ERROR";
} else {
echo "ADD SUCCESS, id " . $addResponse->writeResponse->baseRef->internalId;

No comments:

Post a Comment