Android Magento:将产品转移到客户的购物车
我正在使用android ksoap2和magento soap api V2制作购物车。我无法使用api shoppingCartProductMoveToCustomerQuote将购物车产品移动到客户的购物车。我收到错误,因为“客户的报价不存在”。我使用了 我已使用以下代码:Android Magento:将产品转移到客户的购物车,android,magento,ksoap2,android-ksoap2,ksoap,Android,Magento,Ksoap2,Android Ksoap2,Ksoap,我正在使用android ksoap2和magento soap api V2制作购物车。我无法使用api shoppingCartProductMoveToCustomerQuote将购物车产品移动到客户的购物车。我收到错误,因为“客户的报价不存在”。我使用了 我已使用以下代码: private String response,id; String[][] Products = new String[][] {{"20","20","1"}}; protec
private String response,id;
String[][] Products = new String[][] {{"20","20","1"}};
protected String doInBackground(String... params)
{
try
{
//SoapEnvelop.VER11 is SOAP Version 1.1 constant
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.xsd = SoapSerializationEnvelope.XSD;
envelope.enc = SoapSerializationEnvelope.ENC;
SoapObject request = new SoapObject(NAMESPACE,"login");
request.addProperty("username", "***");
request.addProperty("apiKey", "*********");
//envelope.bodyOut = request;
envelope.setOutputSoapObject(request);
HttpTransportSE transport = new HttpTransportSE(URL);
try
{
transport.debug=true;
transport.call(NAMESPACE + SOAP_ACTION_PREFIX + "shoppingCartProductAdd", envelope);
// transport.call(NAMESPACE + SOAP_ACTION_PREFIX + "catalogProductList", envelope);
response=(String) envelope.getResponse();
String sessionId = response.toString();
Log.d("The session Id is:",sessionId);
SoapObject SingleProduct = new SoapObject(NAMESPACE, "shoppingCartProductEntity");
PropertyInfo pi = new PropertyInfo();
pi.setName("product_id");
pi.setValue(Integer.parseInt(Products[0][0]));
pi.setType(Integer.class);
SingleProduct.addProperty(pi);
pi = new PropertyInfo();
pi.setName("sku");
pi.setValue(Products[0][1]);
pi.setType(String.class);
SingleProduct.addProperty(pi);
pi = new PropertyInfo();
pi.setName("qty");
pi.setValue(Products[0][2]);
pi.setType(Double.class);
SingleProduct.addProperty(pi);
SoapObject EntityArray = new SoapObject(NAMESPACE, "shoppingCartProductEntityArray");
EntityArray.addProperty("products",SingleProduct);
request = new SoapObject(NAMESPACE,METHOD_NAME);
//adding the propery such as sessionId and Customerdata for request
request.addProperty("sessionId",sessionId );
request.addProperty("quoteId",100);
request.addProperty("products",EntityArray);
request.addProperty("options",null);
request.addProperty("bundle_option",null);
request.addProperty("bundle_option_qty",null);
request.addProperty("links",null);
//request.addProperty("store_id", 1);
envelope.setOutputSoapObject(request);
transport.call(NAMESPACE + SOAP_ACTION_PREFIX + METHOD_NAME, envelope);
//getting the response which is the customerId
Log.d("Test", "request: " + transport.requestDump);
Log.d("Test", "response: " + transport.responseDump);
}
catch (IOException e)
{
e.printStackTrace();
}
catch (XmlPullParserException e)
{
e.printStackTrace();
}
shoppingCartProductAdd方法只有4个参数
会话ID,
引用,
产品\产品数据,
storeId可选
,但您发送的内容超出了此范围,因此请删除
request.addProperty("options",null);
request.addProperty("bundle_option",null);
request.addProperty("bundle_option_qty",null);
request.addProperty("links",null);
从您的代码,然后尝试
如果需要,可以将这些属性添加到shoppingCartProductEntity方法中。
欲知详情