How To Update Product Quantity in Cart By Using GraphQL in Magento 2.x / Adobe Commerce 2.x

The following below steps need to follow to update product Quantity in Cart by using GraphQL in Magento 2.x / Adobe Commerce 2.x

Use the updateCartItems mutation to update shopping cart items and removeItemFromCart to remove a product from the shopping cart.

Step [1] – Recommendation to use below syntax to update product Quantity in Cart

Here Using Postman

Syntax –

Step [2] – Put below Request

mutation {

  updateCartItems(

    input: {

      cart_id: "s6Wgi4j0H2ULX0YHfD3mhOMHuAL10qLL"

      cart_items: [{ cart_item_id: 140, quantity: 21 }]

    }

  ) {

    cart {

      items {

        id

        quantity

        product {

          id

          sku

          name

        }

        prices {

          row_total {

            value

            currency

          }

        }

      }

    }

  }

}

Step [3] – Put below Output Response

{
    "data": {
        "updateCartItems": {
            "cart": {
                "items": [
                    {
                        "id": "140",
                        "quantity": 21,
                        "product": {
                            "id": 7,
                            "sku": "24-UB02",
                            "name": "Impulse Duffle"
                        },
                        "prices": {
                            "row_total": {
                                "value": 1554,
                                "currency": "INR"
                            }
                        }
                    }
                ]
            }
        }
    }
}

Leave a Reply

Your email address will not be published. Required fields are marked *