customer address add , update in magento programatically SOAP


<pre><?php
$proxy = new SoapClient('http://your.com/api/soap/?wsdl');
$sessionId = $proxy->login('pk_admin', 'pk1234567');

echo "<br />sessionId : ".$sessionId;
$store_id = 2;
$website_id = 2;
$load_customer = 222;// your customer must be exists and your customer address also be there atleast two addresses

echo "<h1>Customer Address List</h1>";
$cust = $proxy->call($sessionId, 'customer_address.list', $load_customer);
echo '<pre>';
print_r($cust);
echo '</pre>';

for($i=0;$i<count($cust);$i++)
{
if($cust[$i]['is_default_billing'] == "1")
{
   $default_billing_id = $cust[$i]['customer_address_id'];
}
else if($cust[$i]['is_default_shipping'] == "1")
{
   $default_shipping_id = $cust[$i]['customer_address_id'];
}
}
echo "<br />default_billing_id : ".$default_billing_id;
echo "<br />default_shipping_id : ".$default_shipping_id;


$newCustomerAddress = array(
    'firstname'  => 'First1',
    'lastname'   => 'Last2',
    'country_id' => 'USA',
    'region_id'  => '43',
    'region'     => 'New York',
    'city'       => 'New York',
    'street'     => array('Bla bla pragnesh','bla bla karia'),
    'telephone'  => '5555-555-786',
    'postcode'   => 10021786,
    'is_default_billing'  => false,
    'is_default_shipping' => false
);
$newAddressId = $proxy->call($sessionId, 'customer_address.create', array($load_customer, $newCustomerAddress));
echo "New Address ID Created for Customer ".$load_customer." is ".$newAddressId;

//Update customer address
$proxy->call($sessionId, 'customer_address.update', array($newAddressId, $newCustomerAddress));

echo "<br />DONE";
?></pre>

 

thanks to :

Change Customer Address Updated SOAP
http://www.magentocommerce.com/wiki/doc/webservices-api/api/customer_address#customer_address.update

Share on Facebook




About Pragnesh Karia

Pragnesh Karia, Open Source Enthusiast, Software Professional, Software Developer, Technical Lead ,Magento, Joomla ,Joomla LMS , Moodel LMS ,PHP ,Mysql, Ajax, Javascript, Jquery, Linux, Fan of Open Sources , Annet Technologies , SEO Analyst , Mootools