Applying And Removing Discounts

There are two options for applying a discount code:

  1. During initial cart creation

  2. To a cart that already exists

Apply Discount Code at Cart Creation

During cart creation by providing a list of codes and merchant_ids

Add discounts to cart creation request:

{
  "base_currency": "USD",
  "wallet_based_checkout": false,
  "skus": [
    {
      "sku_id": 99638,
      "quantity": 1
    }
  ],
  "discounts": [
    {
      "code": "20p_off",
      "merchant_id": 22
    }
  ]
}

Apply Discount Code to Existing Cart

Add discount to existing cart by providing a single code and merchant_id in the dedicated endpoint

{
  "code": "20p_off",
  "merchant_id": 22
}

Both endpoints will return the entire cart with the discounts applied to correct bags. See the "discounts" sections below:

{
  "id": 10632,
  "token": "b1e4032238424888b6a360b6686cc070",
  "user_id": 10002,
  "app_id": 10001,
  "developer_id": 10001,
  "bags": [
    {
      "id": 10643,
      "order_id": 10632,
      "merchant_id": 22,
      "app_id": 10001,
      "status": "IN_PROGRESS",
      "fulfillment_status": "PROCESSING",
      "financial_status": "UNPAID",
      "skus": [
        {
          "id": 10927,
          "merchant_id": 22,
          "app_id": 10001,
          "product_id": "525a1e59bebd48e7a2d431d666367b5f",
          "sku_id": 99638,
          "external_id": "MS-Champ-XL",
          "name": "Champ Tee Extra Large",
          "quantity": 1,
          "price": 2500,
          "weight": 0.5,
          "available": true,
          "status": "IN_PROGRESS",
          "product_type": "PHYSICAL",
          "line_price": 2500
        }
      ],
      "taxes": [],
      "sub_total": 2500,
      "taxes_included": false,
      "transactions": [],
      "external_checkout": true,
      "commission_rate": 0.0,
      "date_created": "2023-05-23T20:37:33+0000",
      "remorse_period_ends": "2023-06-22T20:37:33+0000",
      "currency": "USD",
      "external_currency": "USD",
      "channel": "APP",
      "platform": "MAGENTO",
      "fulfillments": [],
      "discounts": [
        {
          "id": 10367,
          "bag_id": 10643,
          "status": "APPLIED",
          "type": "CODE",
          "code": "20p_off",
          "date_created": "2023-05-23T20:37:33+0000",
          "date_last_modified": "2023-05-23T20:37:36+0000"
        }
      ],
      "wallet_based_checkout": false,
      "bag_id": 10643,
      "bag_status": "IN_PROGRESS",
      "merchant_name": "Magento Shared's Store"
    }
  ],
  "sub_total": 2500,
  "status": "IN_PROGRESS",
  "is_guest": true,
  "date_created": "2023-05-23T20:37:33+0000",
  "date_last_modified": "2023-05-23T20:37:33+0000",
  "priced": false,
  "wallet_based_checkout": false,
  "currency": "USD",
  "errors": [],
  "channel": "APP",
  "currency_symbol": "$",
  "stripe_key": "pk_test_UHg8oLvg4rrDCbvtqfwTE8qd",
  "guest": true,
  "intent_based_checkout": false,
  "order_id": 10632,
  "order_status": "IN_PROGRESS"
}

Once the cart is priced all available discount information is filled and returned. See "discounts" section below:

{
  "id": 10632,
  "token": "b1e4032238424888b6a360b6686cc070",
  "user_id": 10002,
  "app_id": 10001,
  "developer_id": 10001,
  "customer": {
    "user_id": 10002,
    "first_name": "Evandro",
    "last_name": "Gomes",
    "email": "[email protected]",
    "name": "Evandro Gomes"
  },
  "bags": [
    {
      "id": 10643,
      "order_id": 10632,
      "merchant_id": 22,
      "app_id": 10001,
      "status": "IN_PROGRESS",
      "fulfillment_status": "PROCESSING",
      "financial_status": "UNPAID",
      "skus": [
        {
          "id": 10927,
          "merchant_id": 22,
          "app_id": 10001,
          "product_id": "525a1e59bebd48e7a2d431d666367b5f",
          "sku_id": 99638,
          "external_id": "MS-Champ-XL",
          "name": "Champ Tee Extra Large",
          "quantity": 1,
          "price": 2500,
          "weight": 0.5,
          "available": true,
          "status": "IN_PROGRESS",
          "product_type": "PHYSICAL",
          "line_price": 2500
        }
      ],
      "shipping_method": {
        "type": "FLAT_RATE_PRICE",
        "carrier": "OTHER",
        "label": "Flat Rate",
        "price": 500,
        "id": 10644,
        "shipping_method_id": "flatrate_flatrate",
        "bag_id": 10643,
        "merchant_id": 22
      },
      "taxes": [],
      "sub_total": 2500,
      "shipping_total": 500,
      "tax_total": 0,
      "discount_total": 500,
      "total": 2500,
      "taxes_included": false,
      "transactions": [],
      "external_checkout": true,
      "commission_rate": 0.0,
      "date_created": "2023-05-23T20:37:33+0000",
      "remorse_period_ends": "2023-06-22T20:37:33+0000",
      "currency": "USD",
      "external_currency": "USD",
      "channel": "APP",
      "platform": "MAGENTO",
      "fulfillments": [],
      "discounts": [
        {
          "id": 10367,
          "bag_id": 10643,
          "status": "APPLIED",
          "type": "CODE",
          "value_type": "PERCENTAGE",
          "code": "20p_off",
          "amount_total": 500,
          "date_created": "2023-05-23T20:37:33+0000",
          "date_last_modified": "2023-05-23T20:38:34+0000"
        }
      ],
      "wallet_based_checkout": false,
      "bag_id": 10643,
      "bag_status": "IN_PROGRESS",
      "merchant_name": "Magento Shared's Store"
    }
  ],
  "shipping_address": {
    "name": "Evandro Gomes",
    "city": "Seattle",
    "state": "WA",
    "country": "US",
    "postal_code": "98101",
    "type": "SHIPPING",
    "first_name": "Evandro",
    "last_name": "Gomes",
    "address_1": "123 Main St NEWS"
  },
  "billing_address": {
    "name": "Evandro Gomes",
    "city": "Seattle",
    "state": "WA",
    "country": "US",
    "postal_code": "98101",
    "type": "BILLING",
    "first_name": "Evandro",
    "last_name": "Gomes",
    "address_1": "123 Main St NEWS"
  },
  "sub_total": 2500,
  "shipping_total": 500,
  "tax_total": 0,
  "discount_total": 500,
  "total": 2500,
  "status": "IN_PROGRESS",
  "is_guest": true,
  "date_created": "2023-05-23T20:37:33+0000",
  "date_last_modified": "2023-05-23T20:40:32+0000",
  "priced": true,
  "wallet_based_checkout": false,
  "currency": "USD",
  "errors": [],
  "channel": "APP",
  "currency_symbol": "$",
  "stripe_key": "pk_test_UHg8oLvg4rrDCbvtqfwTE8qd",
  "guest": true,
  "intent_based_checkout": false,
  "order_id": 10632,
  "order_status": "IN_PROGRESS"
}

Removing Discounts

Removing discounts is simple. Discounts can be removed from bags through the [DELETE] /checkout/cart/:cart_id/discounts/:discount_id endpoint. The cart will be returned with current status without the previously applied discount.

Last updated

Was this helpful?