How to pass Dynamic key value for Update Cart (to update product count) API request for android.
-
My Url is http://techinstance.tk/shop/bagisto/public/api/checkout/cart/update
My Request Data is {"qty":{"item_id":"quantity"}} i.e. {"qty":{"4":"3"}}Please provide the way to pass dynamic key value for cart update API in android
-
Hi @wearecoders
Please go through with following article - https://devdocs.bagisto.com/api_cart.html
Thanks
-
I am already following this document but my query is that how can I pass dynamic key value in Android for cart quantity update API ?
-
Hi @wearecoders
First of all , you need to get cart item then you can call cart API like -
this.$http.put('/api/checkout/cart/update', { 'qty': this.quantities }) .then(function(response) { }) .catch(function (error) {});
Thanks
-
Thanks you so much. It would be a great help. Thanks you so much once again. Great plateform for help
-
cannot do this in flutter
my code below// item_id = 33 // quantity = 7 // both are dynamic params /*{ "qty": { "33": "7" } } */ var cartVal = CartUpdateModel(cartItemId: itemId, quantity: newQuantity); // print(cartVal); final Map<String, dynamic> cartbodyMap = new Map<String, dynamic>(); cartbodyMap['qty'] = cartVal; final bodyParams = jsonEncode(cartbodyMap); print("bodyParams: "); print(bodyParams); response = await put( cartUpdateUrl, headers: { 'Authorization': 'Bearer $token', 'Content-Type': 'application/json', }, body: bodyParams ); // CartUpdateModel class class CartUpdateModel{ String cartItemId; String quantity; CartUpdateModel({this.cartItemId, this.quantity}); Map<String, String> toJson(){ return{ '$cartItemId' : '$quantity' }; } }
-
Hello,
you need to read out about flutter *how to send request in flutter with parameter after that you can achieve the goal.
thanks