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
    733
    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

      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

        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

          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

            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

              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
              • K
                kumar_sk last edited by

                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

                  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
                  • First post
                    Last post