How to remove an item from cart using magento api in android?

843 views Asked by At

I am using "shoppingCartProductRemove" api to remove an item from cart in magento. For that i am using the following code:

SoapObject item = new SoapObject(NAMESPACE,"shoppingCartProductEntity");
                PropertyInfo pinfo = new PropertyInfo();
                String productid = productId.get(deleteProductPosition);
                pinfo.setName("product_id");
                pinfo.setValue(productid);
                pinfo.setType(String.class);
                item.addProperty(pinfo);

                pinfo = new PropertyInfo();
                String productsku = productSku.get(deleteProductPosition);
                pinfo.setName("sku");
                pinfo.setValue(productsku);
                pinfo.setType(String.class);
                item.addProperty(pinfo);

                pinfo = new PropertyInfo();
                int productQty = Qty.get(deleteProductPosition);
                pinfo.setName("qty");
                pinfo.setValue(productQty);
                pinfo.setType(Double.class);
                item.addProperty(pinfo);

SoapObject EntityArray = new SoapObject(NAMESPACE,"shoppingCartProductEntity");
                EntityArray.addProperty("productsData", item);

            SoapObject request = new SoapObject(NAMESPACE, "shoppingCartProductRemove");
                request.addProperty("sessionId", sessionId);
                request.addProperty("quoteId", 118);
                request.addProperty("productsData", item);

                env.setOutputSoapObject(request);
                androidHttpTransport = new HttpTransportSE(URL);
                androidHttpTransport.call("", env);
                Object catrInfoObjs = env.getResponse();

but i am getting the xml pullparser exception. Is there any reference to remove an item from cart. Need help here!!

1

There are 1 answers

0
Amit Chandra On BEST ANSWER

I got it using the following code:

SoapObject item = new SoapObject(NAMESPACE, "shoppingCartProductEntity");
                PropertyInfo pinfo = new PropertyInfo();

                pinfo.setName("product_id");
                pinfo.setValue(productId.get(deleteProductPosition));
                pinfo.setType(String.class);
                item.addProperty(pinfo);

                pinfo = new PropertyInfo();
                pinfo.setName("sku");
                pinfo.setValue(productSku.get(deleteProductPosition));
                pinfo.setType(String.class);
                item.addProperty(pinfo);
                int productQty = Qty.get(deleteProductPosition);
                pinfo = new PropertyInfo();
                pinfo.setName("qty");
                pinfo.setValue(productQty);
                pinfo.setType(Double.class);
                item.addProperty(pinfo);

                pinfo = new PropertyInfo();
                pinfo.setName("options");
                pinfo.setValue(" ");
                pinfo.setType(String[].class);
                item.addProperty(pinfo);


                SoapObject EntityArray = new SoapObject(NAMESPACE, "shoppingCartProductEntityArray");
                EntityArray.addProperty("products",item);

                SoapObject request = new SoapObject(NAMESPACE, "shoppingCartProductRemove");
                request.addProperty("sessionId", sessionId);
                request.addProperty("quoteId", 74);
                request.addProperty("products",EntityArray);

                env.setOutputSoapObject(request);
                androidHttpTransport = new HttpTransportSE(URL);
                androidHttpTransport.call("", env);

                Object result = (Boolean) env.getResponse();