v1

latestOpenAPI 3.0.3raw.githubusercontent.com2024-10-2916802.4 MB
🛒 Ecommerce

Add item or update item quantity

The API allows users to add a product to their cart or update the quantity of an already added product.

The frontend can send a request to this API, passing the productId as a path variable and the desired quantity as a number in the request body.

This API handles both adding new products to the cart and updating the quantity of existing products, providing a convenient way for users to manage their shopping cart. E.g. If user has 4 products already in cart and if user click on add more button frontend should send quantity as 5 in the same api.

NOTES:

Quanity that is passed in the request body will be assigned directly and will be treated as a new quantity for the respective product.

Minimum quantity should be 1. Once user decrements it from 1, instead of sending 0 call remove item from cart api.

post/ecommerce/cart/item/{productId}

Request body

quantitystring

Response

Add item or update item quantity

messagestring
statusCodenumber
successboolean

Example response

{
  "data": {
    "_id": "649e7bfbdbf96264731f54c1",
    "cartTotal": 3400,
    "discountedTotal": 3400,
    "items": [
      {
        "_id": "649e7bfbdbf96264731f54c1",
        "coupon": null,
        "product": {
          "__v": 0,
          "_id": "649e7bfcdbf96264731f57c8",
          "category": "649e7bfcdbf96264731f56e1",
          "createdAt": "2023-06-30T06:53:48.766Z",
          "description": "Carbonite web goalkeeper gloves are ergonomically designed to give easy fit",
          "mainImage": {
            "_id": "649e7bfcdbf96264731f57c9",
            "localPath": "",
            "url": "https://loremflickr.com/640/480/product?lock=7464317817454592"
          },
          "name": "Recycled Granite Bacon",
          "owner": "649e7bfbdbf96264731f543d",
          "price": 426,
          "stock": 47,
          "subImages": [
            {
              "_id": "649e7bfcdbf96264731f57ca",
              "localPath": "",
              "url": "https://loremflickr.com/640/480/product?lock=3434367487574016"
            },
            {
              "_id": "649e7bfcdbf96264731f57cb",
              "localPath": "",
              "url": "https://loremflickr.com/640/480/product?lock=5167427790831616"
            },
            {
              "_id": "649e7bfcdbf96264731f57cc",
              "localPath": "",
              "url": "https://loremflickr.com/640/480/product?lock=3368131338698752"
            },
            {
              "_id": "649e7bfcdbf96264731f57cd",
              "localPath": "",
              "url": "https://loremflickr.com/640/480/product?lock=8845803512659968"
            }
          ],
          "updatedAt": "2023-06-30T06:53:48.766Z"
        },
        "quantity": 6
      },
      {
        "_id": "649e7bfbdbf96264731f54c1",
        "coupon": null,
        "product": {
          "__v": 0,
          "_id": "649e7bfcdbf96264731f57e0",
          "category": "649e7bfcdbf96264731f56df",
          "createdAt": "2023-06-30T06:53:48.767Z",
          "description": "New ABC 13 9370, 13.3, 5th Gen CoreA5-8250U, 8GB RAM, 256GB SSD, power UHD Graphics, OS 10 Home, OS Office A & J 2016",
          "mainImage": {
            "_id": "649e7bfcdbf96264731f57e1",
            "localPath": "",
            "url": "https://loremflickr.com/640/480/product?lock=8288021558329344"
          },
          "name": "Oriental Plastic Tuna",
          "owner": "649e7bfbdbf96264731f5467",
          "price": 211,
          "stock": 57,
          "subImages": [
            {
              "_id": "649e7bfcdbf96264731f57e2",
              "localPath": "",
              "url": "https://loremflickr.com/640/480/product?lock=2878816741490688"
            },
            {
              "_id": "649e7bfcdbf96264731f57e3",
              "localPath": "",
              "url": "https://loremflickr.com/640/480/product?lock=1697180433776640"
            },
            {
              "_id": "649e7bfcdbf96264731f57e4",
              "localPath": "",
              "url": "https://loremflickr.com/640/480/product?lock=4602145108131840"
            },
            {
              "_id": "649e7bfcdbf96264731f57e5",
              "localPath": "",
              "url": "https://loremflickr.com/640/480/product?lock=1624351178752000"
            }
          ],
          "updatedAt": "2023-06-30T06:53:48.767Z"
        },
        "quantity": 4
      }
    ]
  },
  "message": "Item added successfully",
  "statusCode": 200,
  "success": true
}