Retrieving and Displaying Netsuite Address Information

Adam Haeder requested to see some sample code for accessing address information via the Netsuite Webservices API. So here it is:

<?php
//$customer is nsComplexObject retrieved from a search or a get.
if (isset($customer->nsComplexObject_fields['addressbookList'])) {
    $CustomerAddressbookList = $customer->getField('addressbookList');
    $addresses = $CustomerAddressbookList->getField('addressbook');
    foreach ($addresses as $CustomerAddressbook) {
        $city = $CustomerAddressbook->getField('city');
        $state = $CustomerAddressbook->getField('state');
        $nsCountry = $CustomerAddressbook->getField('country');
        $zip = $CustomerAddressbook->getField('zip');
        $street = $CustomerAddressbook->getField('addr1');
        $street2 = "";//filled in later
        $attention = $CustomerAddressbook->getField('attention');
        $phone = $CustomerAddressbook->getField('phone');
        if ($phone === null) {
            $phone = $customer->getField('phone');//if the address didn't have a phone, use the customer one
        }
        $nsID = (int) $CustomerAddressbook->getField('internalId');
        $defaultShipping = (bool) $CustomerAddressbook->getField('defaultShipping');
        $defaultBilling = (bool) $CustomerAddressbook->getField('defaultBilling');
        if (isset($CustomerAddressbook->nsComplexObject_fields['addr2'])) {
            $street2 = $CustomerAddressbook->getField('addr2');
        }
        $addressee = $CustomerAddressbook->getField('addressee');
    }
}
?>
This entry was posted in Netsuite PHPToolkit, PHP and tagged , , , , , , . Bookmark the permalink.

One Response to Retrieving and Displaying Netsuite Address Information

  1. Pingback: Joe Motacek » Blog Archive » Joomla 2.5 Extension Development – Working with the NetSuite Webservice

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>