wordpress - is there any woocommerce API for add To cart -


is there woocommerce api add cart can add product cart via mobile app.

please me.

did not found "add cart" functionality in woocommerce api.

what had been done "add cart" button save product id , quantity(and other properties) shared preferences object.

firstly getting products json object shared preferences object , find out to-be-added product present on shared preferences object.if present execution returns.otherwise advance add product property shared preferences object.

                sharedpreferences pref = getsharedpreferences("cartpref", 0);                 string strjson = pref.getstring("productcartjson","[]");                 jsonarray productssavedetailjsonarray = new jsonarray(strjson);                  //checking if product-to-be-added present in shared preferences object                 for(int i=0;i<productssavedetailjsonarray.length();i++){                     if(productssavedetailjsonarray.getjsonobject(i).getstring("product_id").contentequals(productidfordetailspage)){                         strjson = pref.getstring("productcartjson","0");                         log.d("strjson",""+strjson);                         //if present returns.                         return;                     }                 }                 jsonobject productsavedetailjsonobject = new jsonobject();                 productsavedetailjsonobject.put("product_id",""+productidfordetailspage);                 productsavedetailjsonobject.put("quantity","1");                  productssavedetailjsonarray.put(productsavedetailjsonobject);                 sharedpreferences.editor editor = pref.edit();                 editor.putstring("productcartjson", ""+productssavedetailjsonarray);                 editor.apply();                 strjson = pref.getstring("productcartjson","0");                 log.d("strjson",""+strjson); 

if doubt please comment.

this works me.hope works well.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -