Skip to main content Link Menu Expand (external link) Document Search Copy Copied

Module: Mage_Customer

Resource: customer_address

Method:

  • customer_address.create (SOAP V1)
  • customerAddressCreate (SOAP V2)

Create a new address for the customer

Arguments:

TypeNameDescription
stringsessionIdSession ID
intcustomerIdCustomer ID
arrayaddressdataArray of customerAddressEntityCreate

Returns:

TypeNameDescription
intresultID of the created customer address

The customerAddressEntityCreate content is as follows:

TypeNameDescription
stringcityName of the city
stringcompanyName of the company
stringcountry_idCountry ID
stringfaxFax
stringfirstnameCustomer first name
stringlastnameCustomer last name
stringmiddlenameCustomer middle name
stringpostcodePostcode
stringprefixCustomer prefix
intregion_idID of the region
stringregionName of the region
ArrayOfStringstreetArray of street addresses
stringsuffixCustomer suffix
stringtelephoneTelephone number
booleanis_default_billingTrue if the address is the default one for billing
booleanis_default_shippingTrue if the address is the default one for shipping

Note: If you want to leave any address fields empty, specify them as empty ones in the request body.

Examples

Request Example SOAP V1
$client = new SoapClient('http://magentohost/api/soap/?wsdl');

// If somestuff requires API authentication,
// then get a session token
$session = $client->login('apiUser', 'apiKey');

$result = $client->call(
$session,
'customer_address.create',
array('customerId' => 2, 'addressdata' => array('firstname' => 'John', 'lastname' => 'Doe', 'street' => array('Street line 1', 'Streer line 2'), 'city' => 'Weaverville', 'country_id' => 'US', 'region' => 'Texas', 'region_id' => 3, 'postcode' => '96093', 'telephone' => '530-623-2513', 'is_default_billing' => FALSE, 'is_default_shipping' => FALSE)));
var_dump ($result);
Request Example SOAP V2
$client = new SoapClient('http://magentohost/api/v2_soap/?wsdl');

// If some stuff requires API authentication,
// then get a session token
$session = $client->login('apiUser', 'apiKey');
$result = $client->customerAddressCreate($session, '2', array('firstname' => 'John', 'lastname' => 'Doe', 'street' => array('Street line 1', 'Streer line 2'), 'city' => 'Weaverville', 'country_id' => 'US', 'region' => 'Texas', 'region_id' => 3, 'postcode' => '96093', 'telephone' => '530-623-2513', 'is_default_billing' => FALSE, 'is_default_shipping' => FALSE));

var_dump ($result);
Request Example SOAP V2 (WS-I Compliance Mode)
$proxy = new SoapClient('http://magentohost/api/v2_soap/?wsdl'); 

$sessionId = $proxy->login((object)array('username' => 'apiUser', 'apiKey' => 'apiKey')); 
 
$result = $proxy->customerAddressCreate((object)array('sessionId' => $sessionId->result, 'customerId' => '2', 'addressData' => ((object)array(
'city' => 'Weaverville',
'country_id' => 'US',
'postcode' => '96093',
'region' => 'Texas',
'street' => array('Street line 1', 'Streer line 2'),
'telephone' => '847-431-7700',
'lastname' => 'Doe',
'firstname' => 'John',
'is_default_billing' => true
))));   
var_dump($result->result);

Table of contents