Create Netsuite Customer with Addresses

Figuring out how to do address arrays on a Netsuite Customer can be rather complicated so I thought I would share some sample code:

$CustomerAddressBooks = array();
foreach ($addresses as $address) {
        //populate the approprate varables i.i. $street, $City, etc from $address
	$addrArray = array(
            "defaultBilling" => $DefaultBilling,
            "defaultShipping" => $DefaultShipping,
            "addr1" => $Street,
            "addr2" => $Street2,
            "label" => $Street,
            "city" => $City,
            "phone" => $Phone,
            "country" => $NsCountryCode,
            "addressee" => $Addressee,
            "attention" => $attention,
            "zip" => $Zip
        );
	$CustomerAddressBook = new nsComplexObject('CustomerAddressbook');
        $CustomerAddressBook->setFields($addrArray);
        $CustomerAddressBooks[] = $CustomerAddressBook;
}
$CustomerAddressBookList = new nsComplexObject('CustomerAddressbookList');
$CustomerAddressBookList->setFields(array(
    "addressbook" => $CustomerAddressBooks
));

$customerInformationArray = array(
            "email" => $email,
            "phone" => $phone,
            "addressbookList" => $CustomerAddressBookList,
            "creditCardsList" => $CCCList
);
This entry was posted in Netsuite PHPToolkit and tagged , , , . Bookmark the permalink.

6 Responses to Create Netsuite Customer with Addresses

  1. Michael says:

    Hi Daniel, thanks for the sample code as always!

    I am having some trouble figuring out how to retrieve and display the address from netsuite. I can retrieve and display nearly all other fields (i.e. internalId, firstname, lastname, company, phone, fax and email but cannot for the life of me get the address.

    Any tip would be greatly appreciated, please send me your email address so I can send a little thank you via paypal.

    Michael

  2. Michael says:

    Daniel,

    Thank you, as always your code snippets are a great help!

  3. Parker says:

    Worked like a charm… thanks for posting

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>