Checkout Discounts

Checkout Discounts

Add Discount to Checkout

POST /checkouts/{checkoutId}/discounts

Request

Adds a discount to an existing checkout.

Use this endpoint to apply the following discounts:

  • Apply a manual discount to a cart. In this case, you can distribute the discount between each line item in the cart based on the item value.
  • Apply a manual discount against a specific line item.
  • Apply a manual discount at the item-level with a cart-level discount.

Notes:

  • When you call this API, you clear out all existing discounts applied to line items, including product and order-based discounts.
  • You cannot apply a manual discount to a specific line item if you have already applied a coupon or automatic promotion to it.

Required Fields:

  • discounted_amount at the cart-level or at the item-level

To prevent lost updates due to concurrent requests overriding changes made by others, it is recommended to enable optimistic concurrency control by including the version field in the request payload. If the provided version does not match the version on the server, a conflict error will be returned, which the client can handle accordingly.

Authentication

  • X-Auth-Token in header

Parameters

  • store_hash in path - string
  • checkoutId in path - string
    required
    ID of the checkout; the same as the cart ID.
  • Accept in header with default of application/json - string
    required
    The MIME type of the response body.
  • Content-Type in header with default of application/json - string
    required
    The MIME type of the request body.

Body

object | application/json
  • cart
    object

example

{
"cart": {
"discounts": [
{
"discounted_amount": 10,
"name": "manual-discount"
}
]
},
"version": 1
}

Response

Body

object | application/json
  • data
    object

  • meta
    object

    Response metadata.

example

{
"data": {
"id": "306d57d7-124e-4112-82cd-35e060c0d4d9",
"cart": {
"id": "306d57d7-124e-4112-82cd-35e060c0d4d9",
"customer_id": 11,
"channel_id": 1,
"email": "janedoe@example.com",
"currency": {
"code": "USD"
},
"tax_included": false,
"base_amount": 31.95,
"discount_amount": 0,
"manual_discount_amount": 10,
"cart_amount_inc_tax": 33.23,
"cart_amount_ex_tax": 31.95,
"coupons": [],
"discounts": [
{
"id": "8edef915-8e8e-4ebd-bece-31fbb1191a7e",
"discounted_amount": 13.6
}
],
"line_items": {
"physical_items": [
{
"id": "8edef915-8e8e-4ebd-bece-31fbb1191a7e",
Did you find what you were looking for?