processing an array of address objects
Posted: Tue Jul 14, 2009 6:22 am
I'm really stuck with this problem and I could badly do with some help with it. I have a method which calls a soap call called Address_info_select which returns an array of customer_address
The attributes for each address are
<UL>
<LI>sequence of the address - the sequence 1 is always the contact address
<LI>company name
<LI>address1, address2 and address3
<LI>city
<LI>state - the method tries to retrieve the state from the cache data using the state code returned by
<LI>zip code
<LI>country - the method tries to retrieve the country from the cache data using the state code returned by
<LI>telephone, fax and mobile numbers
<LI>email address
Basically I need to loop over the address objects and then populate a template according to whether its a contact address or billing address the contact address is always sequence 1
Here is what I am trying to do:
so on and so fourth, I need to populate the contact address which has a sequence value of 1 and then populate the billing address template which is anything after 1.
I will attach the soap request value returned from the soap server so you will understand as I am new to php I really need help with this.
The attributes for each address are
<UL>
<LI>sequence of the address - the sequence 1 is always the contact address
<LI>company name
<LI>address1, address2 and address3
<LI>city
<LI>state - the method tries to retrieve the state from the cache data using the state code returned by
<LI>zip code
<LI>country - the method tries to retrieve the country from the cache data using the state code returned by
<LI>telephone, fax and mobile numbers
<LI>email address
Basically I need to loop over the address objects and then populate a template according to whether its a contact address or billing address the contact address is always sequence 1
Here is what I am trying to do:
Code: Select all
$ThinkSoap = new ThinkWS('Customized25.wsdl',array());
$address_info_select_request = new address_info_select_request();
$address_info_select_request->user_login_data = $user_login_data;
$address_info_select_request->customer_identifier = $customer_identifier;
$address_info_select_response = new address_info_select_response();
$address_info_select_response = $ThinkSoap->AddressInfoSelect($address_info_select_request);
$customer_addresses = new customer_address();
$customer_addresses = $address_info_select_response->[b]customer_address[/b]; // this customer_address is an array
foreach ($customer_addresses as $address => $value){
$addressSequence = $customer_addresses->customer_address_seq;
if ($customer_addresses->address1 != null){
$address1 = $customer_address->address1;
}
if ($customer_addresses->address2 != null){
$address2 = $customer_addresses->address2;
}
if ($customer_addresses->address3 != null){
$address3 = $customer_addresses->address3;
}
if ($customer_addresses->city != null){
$city = $customer_addresses->city;
}
if ($customer_addresses->state != null){
$state = $customer_addresses->state;
}
I will attach the soap request value returned from the soap server so you will understand as I am new to php I really need help with this.