• Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Register
  • Login
Bagisto Forum

Bagisto

  • Register
  • Login
  • Search
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups

How to pass Dynamic key value for Update Cart (to update product count) API request for android.

Knowledge Base
4
7
734
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W
    wearecoders last edited by 7 Dec 2019, 10:24

    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

    1 Reply Last reply Reply Quote 0
    • R
      rahul last edited by 10 Dec 2019, 04:46

      Hi @wearecoders

      Please go through with following article - https://devdocs.bagisto.com/api_cart.html

      Thanks

      1 Reply Last reply Reply Quote 0
      • W
        wearecoders last edited by 10 Dec 2019, 04:52

        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 ?

        1 Reply Last reply Reply Quote 0
        • R
          rahul last edited by 10 Dec 2019, 05:21

          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

          1 Reply Last reply Reply Quote 0
          • W
            wearecoders last edited by 10 Dec 2019, 05:27

            Thanks you so much. It would be a great help. Thanks you so much once again. Great plateform for help

            1 Reply Last reply Reply Quote 0
            • 7 months later
            • K
              kumar_sk last edited by 25 Jun 2020, 17:57

              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'
                  };
                }
              
              }
              
              1 Reply Last reply Reply Quote 0
              • S
                shivam-webkul last edited by 2 Jul 2020, 04:22

                Hello,

                you need to read out about flutter *how to send request in flutter with parameter after that you can achieve the goal.

                thanks

                1 Reply Last reply Reply Quote 0
                3 out of 7
                • First post
                  3/7
                  Last post