How do I set shipping address to shopping cart quote using Magento SOAP API v2 method shoppingCartCustomerAddresses
in Android using ksoap2 Android library?
When I set the shipping address & billing address, billing address gets set but not shipping address. I get true as result when setting the addresses. Addresses are set properly using PHP as I get proper response when I call shoppingCartInfo
method. I think the following format is wrong, can anyone show me the correct format. Following is what I have tried:
SoapObject item = new SoapObject(NAMESPACE, "shoppingCartCustomerAddressEntity");
PropertyInfo pinfo = new PropertyInfo();
pinfo.setName("mode");
pinfo.setValue("shipping");
pinfo.setType(String.class);
item.addProperty(pinfo);
pinfo = new PropertyInfo();
pinfo.setName("firstname");
pinfo.setValue(firstName);
pinfo.setType(String.class);
item.addProperty(pinfo);
Log.i("FIRST NAME 1", firstName);
pinfo = new PropertyInfo();
pinfo.setName("lastname");
pinfo.setValue(lastName);
pinfo.setType(String.class);
item.addProperty(pinfo);
Log.i("LAST NAME 1", lastName);
pinfo = new PropertyInfo();
pinfo.setName("company");
pinfo.setValue(company1);
pinfo.setType(String.class);
item.addProperty(pinfo);
Log.i("COMPANY 1", company1);
pinfo = new PropertyInfo();
pinfo.setName("street");
pinfo.setValue(street1);
pinfo.setType(String.class);
item.addProperty(pinfo);
Log.i("STREET 1", street1);
pinfo = new PropertyInfo();
pinfo.setName("city");
pinfo.setValue(city1);
pinfo.setType(String.class);
item.addProperty(pinfo);
Log.i("CITY 1", city1);
pinfo = new PropertyInfo();
pinfo.setName("region");
pinfo.setValue(region1);
pinfo.setType(String.class);
item.addProperty(pinfo);
Log.i("REGION 1", region1);
pinfo = new PropertyInfo();
pinfo.setName("postcode");
pinfo.setValue(postcode1);
pinfo.setType(String.class);
item.addProperty(pinfo);
Log.i("POST CODE 1", postcode1);
pinfo = new PropertyInfo();
pinfo.setName("country_id");
pinfo.setValue(countryId1);
pinfo.setType(String.class);
item.addProperty(pinfo);
Log.i("COUNTRY ID 1", countryId1);
pinfo = new PropertyInfo();
pinfo.setName("telephone");
pinfo.setValue(telephone1);
pinfo.setType(String.class);
item.addProperty(pinfo);
Log.i("TELEPHONE 1", telephone1);
pinfo = new PropertyInfo();
pinfo.setName("fax");
pinfo.setValue(fax1);
pinfo.setType(String.class);
item.addProperty(pinfo);
Log.i("FAX 1", fax1);
pinfo = new PropertyInfo();
pinfo.setName("is_default_shipping");
pinfo.setValue(0);
pinfo.setType(Integer.class);
item.addProperty(pinfo);
pinfo = new PropertyInfo();
pinfo.setName("is_default_billing");
pinfo.setValue(1);
pinfo.setType(Integer.class);
item.addProperty(pinfo);
SoapObject entityArray = new SoapObject(NAMESPACE, "shoppingCartCustomerAddressEntityArray");
entityArray.addProperty("customer",item);
SoapObject item1 = new SoapObject(NAMESPACE, "shoppingCartCustomerAddressEntity");
pinfo.setName("mode");
pinfo.setValue("billing");
pinfo.setType(String.class);
item1.addProperty(pinfo);
pinfo = new PropertyInfo();
pinfo.setName("firstname");
pinfo.setValue(firstName);
pinfo.setType(String.class);
item1.addProperty(pinfo);
Log.i("FIRST NAME 2", firstName);
pinfo = new PropertyInfo();
pinfo.setName("lastname");
pinfo.setValue(lastName);
pinfo.setType(String.class);
item1.addProperty(pinfo);
Log.i("LAST NAME 2", lastName);
pinfo = new PropertyInfo();
pinfo.setName("company");
pinfo.setValue(company2);
pinfo.setType(String.class);
item1.addProperty(pinfo);
Log.i("COMPANY 2", company2);
pinfo = new PropertyInfo();
pinfo.setName("street");
pinfo.setValue(street2);
pinfo.setType(String.class);
item1.addProperty(pinfo);
Log.i("STREET 2", street2);
pinfo = new PropertyInfo();
pinfo.setName("city");
pinfo.setValue(city2);
pinfo.setType(String.class);
item1.addProperty(pinfo);
Log.i("CITY 2", city2);
pinfo = new PropertyInfo();
pinfo.setName("region");
pinfo.setValue(region2);
pinfo.setType(String.class);
item1.addProperty(pinfo);
Log.i("REGION 2", region2);
pinfo = new PropertyInfo();
pinfo.setName("postcode");
pinfo.setValue(postcode2);
pinfo.setType(String.class);
item1.addProperty(pinfo);
Log.i("POST CODE 2", postcode2);
pinfo = new PropertyInfo();
pinfo.setName("country_id");
pinfo.setValue(countryId2);
pinfo.setType(String.class);
item1.addProperty(pinfo);
Log.i("COUNTRY ID 2", countryId2);
pinfo = new PropertyInfo();
pinfo.setName("telephone");
pinfo.setValue(telephone2);
pinfo.setType(String.class);
item1.addProperty(pinfo);
Log.i("TELEPHONE 2", telephone2);
pinfo = new PropertyInfo();
pinfo.setName("fax");
pinfo.setValue(fax2);
pinfo.setType(String.class);
item1.addProperty(pinfo);
Log.i("FAX 2", fax2);
pinfo = new PropertyInfo();
pinfo.setName("is_default_billing");
pinfo.setValue(0);
pinfo.setType(Integer.class);
item1.addProperty(pinfo);
entityArray.addProperty("customer",item1);
SoapObject request = new SoapObject(NAMESPACE, "shoppingCartCustomerAddresses");
request.addProperty("sessionId", MainActivity.sessionId);
request.addProperty("quoteId", getCartId());
request.addProperty("customer",entityArray);
request.addProperty("storeId", storeId);
MainActivity.env.setOutputSoapObject(request);
MainActivity.androidHttpTransport.call("", MainActivity.env);
Boolean customerAddressAdded = (Boolean) MainActivity.env.getResponse();
NAMESPACE
value is "urn:Magento"
Following is the shoppingCartInfo method response (only relevant part):
shipping_address=shoppingCartAddressEntity{
created_at=2015-04-20 04:46:09;
updated_at=2015-04-20 04:46:38;
customer_id=93;
save_in_address_book=0;
address_type=shipping;
same_as_billing=1;
free_shipping=0;
weight=0;
};
billing_address=shoppingCartAddressEntity{
created_at=2015-04-20 04:46:09;
updated_at=2015-04-20 04:46:22;
customer_id=93;
save_in_address_book=0;
address_type=billing;
email=osama@example.com;
firstname=abc;
lastname=xyz;
company=testing;
street=testing;
city=Mumbai;
region=testing;
postcode=123456;
country_id=IN;
telephone=1234567890;
same_as_billing=0;
free_shipping=0;
weight=0;
};
Shipping to multiple addresses
is yes
& also Maximum Qty Allowed for Shipping to Multiple Addresses
is 100
in Magento System->Configuration->SALES->Shipping settings.
I don't know where am I wrong that shipping address is not getting set to shopping cart quote. Please help me out.
I got the answer. The trick was just to reverse the order of addresses.