我已经在StackOverflow上看到了其他示例,但两者都不适用于我,我的代码在NetSuite中创建了一个地址行,但addr1,city,state和zip为空,默认结算和运输显示为false或者如果我将其设置为true它显示true,以便部分正在更新..响应不显示任何错误。有什么想法吗?
这是我的代码:
$customer = new Customer();
$customer->internalId = 16;
$customer->firstName = 'Joe';
$customer->middleName = 'A';
$customer->lastName = 'Smith';
$customer->email = 'joe@email.com';
$address = new CustomerAddressBook();
$address->defaultShipping = false;
$address->defaultBilling = false;
$address->isResidential = true;
$address->addr1 = '123 Street';
$address->city = 'New York';
$address->zip = '12345';
$address->state = 'NY';
$addressBook = new CustomerAddressbookList();
$addressBook->addressbook = array($address);
$addressBook->replaceAll = false;
// add address to cutomer
$customer->addressbookList = $addressBook;
$request = new UpdateRequest();
$request->record = $customer;
$netsuiteService = new NetSuiteService();
$response = $netsuiteService->update($request);
答案 0 :(得分:4)
$address = new Address();
$address->addr1 = '123 Street';
$address->city = 'New York';
$address->zip = '12345';
$address->state = 'NY';
$address_book = new CustomerAddressBook();
$address_book->defaultShipping = false;
$address_book->defaultBilling = false;
$address_book->isResidential = true;
$address_book->addressbookAddress = $address;
$address_book_list = new CustomerAddressbookList();
$address_book_list->addressbook = $address_book;
$address_book_list->replaceAll = false;
$customer = new Customer();
$customer->internalId = 16;
$customer->firstName = 'Joe';
$customer->middleName = 'A';
$customer->lastName = 'Smith';
$customer->email = 'joe@email.com';
$customer->addressbookList = $address_book_list;
$request = new UpdateRequest();
$request->record = $customer;
$netsuiteService = new NetSuiteService();
$response = $netsuiteService->update($request);
if (!$response->writeResponse->status->isSuccess) {
echo "UPDATE ERROR";
} else {
echo "UPDATE SUCCESS, id " . $response->writeResponse->baseRef->internalId;
}