v1

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

Apply coupon code

The API allows a logged-in user to apply a coupon before proceeding to checkout. It performs the following tasks:

  1. Verification of eligibility: The API checks if the user is eligible to apply the coupon based on certain criteria, such as the total amount in the user's shopping cart.
  2. Calculation of discounted cart value: If the user is eligible, the API calculates the updated cart value by applying the discount offered by the coupon. This involves reducing the total cart amount by an amount based on the coupon details.
  3. Return of updated cart: Finally, the API returns the updated cart to the user, reflecting the applied discount. The user can then proceed to checkout with the discounted cart value.

In summary, this API provides a mechanism for users to apply coupons, verifies their eligibility, calculates the discounted cart value, and returns the updated cart for a seamless checkout experience.

post/ecommerce/coupons/c/apply

Request body

couponCodestring

Example request

{
  "couponCode": "must be unique like 'CORRUPTI845'"
}

Response

Apply coupon code

messagestring
statusCodenumber
successboolean

Example response

{
  "data": {
    "_id": "649e7bfbdbf96264731f54c1",
    "cartTotal": 3400,
    "coupon": {
      "_id": "649e7bfcdbf96264731f5786",
      "couponCode": "CORRUPTI845",
      "createdAt": "2023-06-30T06:53:48.738Z",
      "discountValue": 845,
      "expiryDate": "2025-09-22T17:20:16.758Z",
      "isActive": true,
      "minimumCartValue": 1145,
      "name": "temporibus",
      "owner": "649e7bfbdbf96264731f5419",
      "startDate": "2023-06-07T11:55:17.122Z",
      "type": "FLAT",
      "updatedAt": "2023-06-30T06:53:48.738Z"
    },
    "discountedTotal": 2555,
    "items": [
      {
        "_id": "649e7bfbdbf96264731f54c1",
        "coupon": "649e7bfcdbf96264731f5786",
        "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": "649e7bfcdbf96264731f5786",
        "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": "Coupon applied successfully",
  "statusCode": 200,
  "success": true
}