如何在Android中使用Magento SOAP API v2方法shoppingCartCustomerAddresses将送货地址设置为购物车报价?

问题描述 投票:0回答:1

如何使用 ksoap2 Android 库在 Android 中使用 Magento SOAP API v2 方法

shoppingCartCustomerAddresses
将送货地址设置为购物车报价? 当我设置送货地址和帐单地址时,设置了帐单地址,但没有设置送货地址。设置地址时结果为真。地址是使用 PHP 正确设置的,因为当我调用
shoppingCartInfo
方法时我得到了正确的响应。我认为以下格式是错误的,谁能告诉我正确的格式。以下是我尝试过的:

                               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
值为
"urn:Magento"

以下是shoppingCartInfo方法响应(仅相关部分):

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 protected]; 
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
yes
而且
Maximum Qty Allowed for Shipping to Multiple Addresses
100
在 Magento 系统->配置->销售->运输设置中。

我不知道我哪里错了,送货地址没有设置为购物车报价。请帮帮我。

android magento ksoap2 magento-soap-api
1个回答
0
投票

我得到了答案。诀窍只是颠倒地址的顺序。

© www.soinside.com 2019 - 2024. All rights reserved.