Magento 1.9 – How to Get Customer Billing Address ID Using SOAP API

apicustomermagento-1.9soap-api-v2

I want to get customer all information using soap api.
Code I am using

<?php
require_once "includes/config.php";
$session_id = $_SESSION['session_id'];
//call customer.list method
$result = $cli->customerCustomerList($session_id);

//echo "<pre>";
//var_dump($result);
//echo "</pre>";

foreach($result as $customer){
    $customerInfo = $cli->customerCustomerInfo($session_id, '135');
    //$address = $cli->customerAddressInfo($session_id, $customer->customer_id);
    //echo $customer->customer_id;
    echo "<pre>";
    print_r($customerInfo);
    //print_r($address);
    echo "</pre>";
    break;
}

And this is my response

object(stdClass)#2 (11) {
  ["customer_id"]=>
  int(135)
  ["created_at"]=>
  string(25) "2013-05-16T02:46:11-07:00"
  ["updated_at"]=>
  string(19) "2013-06-24 19:50:46"
  ["store_id"]=>
  int(0)
  ["website_id"]=>
  int(1)
  ["created_in"]=>
  string(5) "Admin"
  ["email"]=>
  string(19) "johndoe@example.com"
  ["firstname"]=>
  string(4) "John"
  ["lastname"]=>
  string(3) "Doe"
  ["group_id"]=>
  int(1)
  ["password_hash"]=>
  string(97) "60d0b6777081273c90d9dcf6342b18d511d539f5f119b56a364b2b0ff6dd29f1:O9hr8Lafe1STOCnJkp2ZHjFMrfM9plGn"
}

I can not see the customer address id on response. So how can I get address of the customer?? Can anyone help me??

Best Answer

The API provides you a method to retrieve the list of addresses associated to a customer.

To use it you can do the following in your loop:

$addresses = $cli->customerAddressList($session_id, $customer->customer_id);

Then if you want to get the full details for one address, you can do it by using the address id and the following code:

$address = $cli->customerAddressInfo($session_id, $addressId);
Related Topic