Cart Discounts

Cart Discounts are used to change the prices of different elements within a Cart.

Cart Discounts are recalculated every time LineItems or CustomLineItems are added or removed from the Cart or an Order is created from the Cart.

The number of active CartDiscounts that do not require a Discount Code (isActive=true and requiresDiscountCode=false) is limited to 100. Learn more about this limit.

Representations

CartDiscount

id​
String​

Unique identifier of the CartDiscount.

version​
Int​

Current version of the CartDiscount.

key​
String​

User-defined unique identifier of the CartDiscount.

MinLength: 2​MaxLength: 256​Pattern: ^[A-Za-z0-9_-]+$​
name​

Name of the CartDiscount.

description​

Description of the CartDiscount.

Effect of the CartDiscount.

cartPredicate​
String​
target​

Sets a CartDiscountTarget. Empty if value has type giftLineItem.

sortOrder​
String​

Value between 0 and 1. All matching CartDiscounts are applied to a Cart in the order defined by this field. A Discount with a higher sortOrder is prioritized. The sort order is unambiguous among all CartDiscounts.

isActive​
Boolean​

Indicates if the CartDiscount is active and can be applied to the Cart.

validFrom​

Date and time (UTC) from which the Discount is effective.

validUntil​

Date and time (UTC) until which the Discount is effective.

requiresDiscountCode​
Boolean​

Indicates if the Discount can be used in connection with a DiscountCode.

references​
Array of Reference​

References of all resources that are addressed in the predicate. The API generates this array from the predicate.

stackingMode​

Indicates whether the application of the CartDiscount causes other discounts to be ignored.

Default: Stacking​
custom​

Custom Fields of the CartDiscount.

createdAt​

Date and time (UTC) for the CartDiscount was initially created.

createdBy​BETA

Present on resources created after 1 February 2019 except for events not tracked.

lastModifiedAt​

Date and time (UTC) for the CartDiscount was last updated.

lastModifiedBy​BETA

Present on resources updated after 1 February 2019 except for events not tracked.

CartDiscountDraft

key​
String​

User-defined unique identifier for the CartDiscount.

MinLength: 2​MaxLength: 256​Pattern: ^[A-Za-z0-9_-]+$​
name​

Name of the CartDiscount.

description​

Description of the CartDiscount.

Effect of the CartDiscount. For a target, relative or absolute discount values, or a fixed item price value can be specified. If no target is specified, a gift line item can be added to the cart.

cartPredicate​
String​
target​

Must not be set when the value has type giftLineItem, otherwise a CartDiscountTarget must be set.

sortOrder​
String​

Value between 0 and 1. A Discount with a higher sortOrder is prioritized. The sort order must be unambiguous among all CartDiscounts.

isActive​
Boolean​

Only active Discounts can be applied to the Cart.

Default: true​
validFrom​

Date and time (UTC) from which the Discount is effective.

validUntil​

Date and time (UTC) until which the Discount is effective.

requiresDiscountCode​
Boolean​

States whether the Discount can only be used in a connection with a DiscountCode.

Default: false​
stackingMode​

Specifies whether the application of this discount causes the following discounts to be ignored.

Default: Stacking​
custom​

Custom Fields of the CartDiscount.

CartDiscountPagedQueryResponse

PagedQueryResult with results containing an array of CartDiscount.

limit​
Int​
offset​
Int​

Number of elements skipped.

count​
Int​

Actual number of results returned.

total​
Int​

Total number of results matching the query. This number is an estimation that is not strongly consistent. This field is returned by default. For improved performance, calculating this field can be deactivated by using the query parameter withTotal=false. When the results are filtered with a Query Predicate, total is subject to a limit.

results​
Array of CartDiscount​

CartDiscounts matching the query.

CartDiscountReference

id​
String​

Unique identifier of the referenced CartDiscount.

typeId​
String​
"cart-discount"

References a CartDiscount.

obj​

Contains the representation of the expanded CartDiscount. Only present in responses to requests with Reference Expansion for CartDiscounts.

CartDiscountResourceIdentifier

id​
String​

Unique identifier of the referenced CartDiscount. Either id or key is required.

key​
String​

User-defined unique identifier of the referenced CartDiscount. Either id or key is required.

typeId​
String​
"cart-discount"

References a CartDiscount.

CartDiscountValue

Defines the effect the Discount will have. For a target, relative or absolute discount values, or a fixed item price value can be specified. If no target is specified, a gift Line Item can be added to the Cart.

CartDiscountValueRelative

Discounts the CartDiscountTarget relative to its price.

type​
String​
"relative"
permyriad​
Int​

Fraction (per ten thousand) the price is reduced by. For example, 1000 will result in a 10% price reduction.

With previous Discounts already applied, the target may already have a discounted price. The Discount is then calculated based on the already discounted price.

CartDiscountValueAbsolute

Discounts the CartDiscountTarget by an absolute amount (not allowed for MultiBuyLineItemsTarget and MultiBuyCustomLineItemsTarget).

type​
String​
"absolute"
money​
Array of CentPrecisionMoney​

Cent precision money values in different currencies.

CartDiscountValueFixed

Sets the DiscountedLineItemPrice of the CartDiscountLineItemsTarget or CartDiscountCustomLineItemsTarget to the value specified in the money field, if it is lower than the current Line Item price for the same currency. If the Line Item price is already discounted to a price equal to or lower than the respective price in the money field, this Discount is not applied.

type​
String​
"fixed"
money​
Array of CentPrecisionMoney​

Cent precision money values in different currencies.

CartDiscountValueGiftLineItem

Adds a free line item as a gift to the cart. The line item will have the LineItemMode GiftLineItem and a quantity of 1. Like all other line items, it has the price field set (it is therefore necessary that the variant has a price defined that can be selected for each cart the discount should be applied to). The totalPrice has a centAmount of 0. The discountedPricePerQuantity discounts the full price and links back to this cart discount.

If at creation time the discount can not be applied to any cart (for example because the product, the variant, or a channel does not exist), the creation fails.

The discount will not be applied to a cart if it either has become invalid since the creation (for example because the product, the variant, or a channel have been deleted) or because no price can be selected for the particular cart.

type​
String​
"giftLineItem"
product​

Reference to a Product.

variantId​
Int​

ProductVariant of the Product.

supplyChannel​

Channel must have the ChannelRoleEnum InventorySupply.

distributionChannel​

Channel must have the ChannelRoleEnum ProductDistribution.

Cannot be combined with MultiBuyLineItemsTarget.

CartDiscountValueDraft

Defines the effect the discount will have. For a target, relative or absolute discount values can be specified. If no target is specified, a gift line item can be added to the cart.

CartDiscountValueRelativeDraft

type​
String​
"relative"
permyriad​
Int​

Fraction (per ten thousand) the price is reduced by. For example, 1000 will result in a 10% price reduction.

CartDiscountValueAbsoluteDraft

type​
String​
"absolute"
money​
Array of Money​

Money values in different currencies. An absolute Cart Discount will only match a price if this array contains a value with the same currency. If it contains 10€ and 15$, the matching € price will be decreased by 10€ and the matching $ price will be decreased by 15$.

CartDiscountValueFixedDraft

Sets the DiscountedLineItemPrice of the CartDiscountLineItemsTarget or CartDiscountCustomLineItemsTarget to the value specified in the money field, if it is lower than the current Line Item price for the same currency. If the Line Item price is already discounted to a price equal to or lower than the respective price in the money field, this Discount is not applied.

type​
String​
"fixed"
money​
Array of Money​

Money values in different currencies. A fixed Cart Discount will only match a price if this array contains a value with the same currency. If it contains 10€ and 15$, the matching € price will be discounted by 10€ and the matching $ price will be discounted to 15$.

CartDiscountValueGiftLineItemDraft

type​
String​
"giftLineItem"

ResourceIdentifier of a Product.

variantId​
Int​

ProductVariant of the Product.

supplyChannel​

Channel must have the role InventorySupply.

distributionChannel​

Channel must have the role ProductDistribution.

CartDiscountTarget

Defines what part of the Cart will be discounted.
Discounts can be applied on LineItems, CustomLineItems, and ShippingInfo.
Additionally, MultiBuyLineItemsTarget discounts certain quantities of Line Items.

CartDiscountLineItemsTarget

Discount is applied to LineItems matching the predicate.

type​
String​
"lineItems"
predicate​
String​

CartDiscountCustomLineItemsTarget

Discount is applied to CustomLineItems matching the predicate.

type​
String​
"customLineItems"
predicate​
String​

CartDiscountShippingCostTarget

Discount is applied to the shipping costs of the Cart.

type​
String​
"shipping"

MultiBuyLineItemsTarget BETA

A multi-buy Discount is not applied on each Line Item as a whole (like with the LineItems Target), but on the individual items that are contained in all matching Line Items and subsumed under their quantity fields. A multi-buy Discount can occur multiple times in a Cart.

A single application of a multi-buy Discount is described by the following two numbers:

  • triggerQuantity - How many items need to match per occurrence?
  • discountedQuantity - How many of these items will be discounted per occurrence?

Multi-buy Discount represents a "Buy 4 items, get 2 of them at a discounted rate" type of discount. In this example, the triggerQuantity is 6, and the discountedQuantity is 2.

The triggerQuantity must be greater than 1.
The discountedQuantity must be greater than 0 and less than or equal to the triggerQuantity.

A multi-buy Discount can have more than one occurrence in a Cart. Yet, any item will only be considered once per multi-buy Discount. Sticking to the example above:

  • Given a cart with 6 items, the Discount can be applied only once. As a result, 2 items will be discounted and 4 items will be marked as participating in this Discount.

  • Given a cart with 8 items, the Discount can still be applied only once. As a result, 2 items will be discounted and 4 items will be marked as participating while the Remaining 2 items will be disregarded by this Discount.

  • Given a cart with 12 items, the Discount can be applied twice. As a result, 2*2 items will be discounted and 2*4 items will be marked as participating in this Discount.

A participation is represented by a DiscountedLineItemPortion with discountedAmount.centAmount = 0.

You can limit the number of occurrences ("applications") of a multi-buy Discount per Cart by defining the maxOccurrence parameter. A LineItemPredicate is applied to select the items relevant for the discount. The discount value to be applied is defined in the Discount's CartDiscountValue. Currently only Relative values are allowed.

To recap, the matching items of a discount application will be sliced into up to maxOccurence groups of size triggerQuantity. Remaining items (for example, the ninth of a "buy 8, get 2 for free" discount) do not participate in the discount. Of any such group only discountedQuantity items will actually be discounted (for example, the second of a "buy 8, get 2 for free" discount); the others are only participating, meaning they are part of this occurrence and thus, cannot participate in another group and the price remains unchanged. To determine which items of a group will actually be discounted, a SelectionMode needs to be set.

type​
String​
"multiBuyLineItems"
predicate​
String​

Valid LineItem target predicate. The Discount will be applied to Line Items that are matched by the predicate.

triggerQuantity​
Int​

Number of Line Items to be present in order to trigger an application of this Discount.

discountedQuantity​
Int​

Number of Line Items that are discounted per application of this Discount.

maxOccurrence​
Int​

Maximum number of times this Discount can be applied.

selectionMode​

Discounts particular Line Items only according to the SelectionMode.

MultiBuyCustomLineItemsTarget BETA

This Discount target is similar to MultiBuyLineItems, but is applied on Custom Line Items instead of Line Items.

type​
String​
"multiBuyCustomLineItems"
predicate​
String​

Valid CustomLineItems target predicate. The Discount will be applied to Custom Line Items that are matched by the predicate.

triggerQuantity​
Int​

Number of Custom Line Items to be present in order to trigger an application of this Discount.

discountedQuantity​
Int​

Number of Custom Line Items that are discounted per application of this Discount.

maxOccurrence​
Int​

Maximum number of times this Discount can be applied.

selectionMode​

Discounts particular Line Items only according to the SelectionMode.

SelectionMode

Defines which matching items are to be discounted.

Cheapest

Select the cheapest items.

MostExpensive

Select the most expensive items.

If the Discount occurs multiple times, it is guaranteed that, out of all matching items, the cheapest or most expensive ones will be discounted, depending on this setting.

Discount always refers to the current price including already applied discounts.

StackingMode

Describes how the Cart Discount interacts with other Discounts.

Stacking

Applies other matching Discounts after applying this one.

StopAfterThisDiscount

Doesn't apply any more matching Discounts after this one if it's successfully applied.

The stacking mode does not control free shipping as defined via freeAbove on a ShippingRate. To avoid unwanted scenarios, we highly recommend not using cart discounts on shipping target and freeAbove together.

Get CartDiscount

Get CartDiscount by ID

GET
https://api.{region}.commercetools.com/{projectKey}/cart-discounts/{id}
OAuth 2.0 Scopes:
view_orders:{projectKey}, view_cart_discounts:{projectKey}
Path parameters:
region
​
String
​

Region in which the Project is hosted.

projectKey
​
String
​

key of the Project.

id
​
String
​

id of the CartDiscount.

Query parameters:
expand
​​
The parameter can be passed multiple times.
Response:
Request Example:cURL
curl -X GET https://api.{region}.commercetools.com/{projectKey}/cart-discounts/{id} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'
200 Response Example: CartDiscountjson
{
"id" : "c2f93298-c967-44af-8c2a-d2220bf39eb2",
"version" : 1,
"createdAt" : "1970-01-01T00:00:00.001Z",
"lastModifiedAt" : "1970-01-01T00:00:00.001Z",
"name" : {
"en" : "Summer Sale"
},
"value" : {
"type" : "relative",
"permyriad" : 1000
},
"cartPredicate" : "1=1",
"target" : {
"type" : "lineItems",
"predicate" : "1=1"
},
"sortOrder" : "0.1",
"isActive" : true,
"requiresDiscountCode" : false,
"references" : [ ],
"stackingMode" : "Stacking"
}

Get CartDiscount by Key

GET
https://api.{region}.commercetools.com/{projectKey}/cart-discounts/key={key}
OAuth 2.0 Scopes:
view_orders:{projectKey}, view_cart_discounts:{projectKey}
Path parameters:
region
​
String
​

Region in which the Project is hosted.

projectKey
​
String
​

key of the Project.

key
​
String
​

key of the CartDiscount.

Query parameters:
expand
​​
The parameter can be passed multiple times.
Response:
Request Example:cURL
curl -X GET https://api.{region}.commercetools.com/{projectKey}/cart-discounts/key={key} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'
200 Response Example: CartDiscountjson
{
"id" : "c2f93298-c967-44af-8c2a-d2220bf39eb2",
"version" : 1,
"createdAt" : "1970-01-01T00:00:00.001Z",
"lastModifiedAt" : "1970-01-01T00:00:00.001Z",
"name" : {
"en" : "Summer Sale"
},
"value" : {
"type" : "relative",
"permyriad" : 1000
},
"cartPredicate" : "1=1",
"target" : {
"type" : "lineItems",
"predicate" : "1=1"
},
"sortOrder" : "0.1",
"isActive" : true,
"requiresDiscountCode" : false,
"references" : [ ],
"stackingMode" : "Stacking"
}

Query CartDiscounts

GET
https://api.{region}.commercetools.com/{projectKey}/cart-discounts
OAuth 2.0 Scopes:
view_orders:{projectKey}, view_cart_discounts:{projectKey}
Path parameters:
region
​
String
​

Region in which the Project is hosted.

projectKey
​
String
​

key of the Project.

Query parameters:
where
​​
The parameter can be passed multiple times.
/^var[.][a-zA-Z0-9]+$/
​
Any string parameter matching this regular expression
​

Predicate parameter values.

The parameter can be passed multiple times.
sort
​​
The parameter can be passed multiple times.
expand
​​
The parameter can be passed multiple times.
limit
​
Int
​
offset
​
Int
​

Number of elements skipped.

withTotal
​
Boolean
​

Controls the calculation of the total number of query results. Set to false to improve query performance when the total is not needed.

Request Example:cURL
curl -X GET https://api.{region}.commercetools.com/{projectKey}/cart-discounts -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'
200 Response Example: CartDiscountPagedQueryResponsejson
{
"limit" : 20,
"offset" : 0,
"count" : 1,
"total" : 1,
"results" : [ {
"id" : "c2f93298-c967-44af-8c2a-d2220bf39eb2",
"version" : 1,
"createdAt" : "1970-01-01T00:00:00.001Z",
"lastModifiedAt" : "1970-01-01T00:00:00.001Z",
"name" : {
"en" : "Summer Sale"
},
"value" : {
"type" : "relative",
"permyriad" : 1000
},
"cartPredicate" : "1=1",
"target" : {
"type" : "lineItems",
"predicate" : "1=1"
},
"sortOrder" : "0.1",
"isActive" : true,
"requiresDiscountCode" : false,
"references" : [ ],
"stackingMode" : "Stacking"
} ]
}

Create CartDiscount

POST
https://api.{region}.commercetools.com/{projectKey}/cart-discounts
OAuth 2.0 Scopes:
manage_orders:{projectKey}, manage_cart_discounts:{projectKey}
Path parameters:
region
​
String
​

Region in which the Project is hosted.

projectKey
​
String
​

key of the Project.

Query parameters:
expand
​​
The parameter can be passed multiple times.
Request Body:CartDiscountDraft
Response:
Request Example:cURL
curl -X POST https://api.{region}.commercetools.com/{projectKey}/cart-discounts -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}' \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"name" : {
"en" : "Summer Sale"
},
"value" : {
"type" : "relative",
"permyriad" : 1000
},
"cartPredicate" : "1=1",
"target" : {
"type" : "lineItems",
"predicate" : "1=1"
},
"sortOrder" : "0.1",
"isActive" : true,
"requiresDiscountCode" : false
}
DATA
201 Response Example: CartDiscountjson
{
"id" : "c2f93298-c967-44af-8c2a-d2220bf39eb2",
"version" : 1,
"createdAt" : "1970-01-01T00:00:00.001Z",
"lastModifiedAt" : "1970-01-01T00:00:00.001Z",
"name" : {
"en" : "Summer Sale"
},
"value" : {
"type" : "relative",
"permyriad" : 1000
},
"cartPredicate" : "1=1",
"target" : {
"type" : "lineItems",
"predicate" : "1=1"
},
"sortOrder" : "0.1",
"isActive" : true,
"requiresDiscountCode" : false,
"references" : [ ],
"stackingMode" : "Stacking"
}

Update CartDiscount

Update CartDiscount by ID

POST
https://api.{region}.commercetools.com/{projectKey}/cart-discounts/{id}
OAuth 2.0 Scopes:
manage_orders:{projectKey}, manage_cart_discounts:{projectKey}
Path parameters:
region
​
String
​

Region in which the Project is hosted.

projectKey
​
String
​

key of the Project.

id
​
String
​

id of the CartDiscount.

Query parameters:
expand
​​
The parameter can be passed multiple times.
Request Body:
version​
Int​

Expected version of the CartDiscount on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict will be returned.

actions​

Update actions to be performed on the CartDiscount.

Response:
Request Example:cURL
curl -X POST https://api.{region}.commercetools.com/{projectKey}/cart-discounts/{id} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}' \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"version" : 1,
"actions" : [ {
"action" : "changeValue",
"value" : {
"type" : "relative",
"permyriad" : 1000
}
} ]
}
DATA
200 Response Example: CartDiscountjson
{
"id" : "c2f93298-c967-44af-8c2a-d2220bf39eb2",
"version" : 1,
"createdAt" : "1970-01-01T00:00:00.001Z",
"lastModifiedAt" : "1970-01-01T00:00:00.001Z",
"name" : {
"en" : "Summer Sale"
},
"value" : {
"type" : "relative",
"permyriad" : 1000
},
"cartPredicate" : "1=1",
"target" : {
"type" : "lineItems",
"predicate" : "1=1"
},
"sortOrder" : "0.1",
"isActive" : true,
"requiresDiscountCode" : false,
"references" : [ ],
"stackingMode" : "Stacking"
}

Update CartDiscount by Key

POST
https://api.{region}.commercetools.com/{projectKey}/cart-discounts/key={key}
OAuth 2.0 Scopes:
manage_orders:{projectKey}, manage_cart_discounts:{projectKey}
Path parameters:
region
​
String
​

Region in which the Project is hosted.

projectKey
​
String
​

key of the Project.

key
​
String
​

key of the CartDiscount.

Query parameters:
expand
​​
The parameter can be passed multiple times.
Request Body:
version​
Int​

Expected version of the CartDiscount on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict will be returned.

actions​

Update actions to be performed on the CartDiscount.

Response:
Request Example:cURL
curl -X POST https://api.{region}.commercetools.com/{projectKey}/cart-discounts/key={key} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}' \
--header 'Content-Type: application/json' \
--data-binary @- << DATA
{
"version" : 1,
"actions" : [ {
"action" : "changeValue",
"value" : {
"type" : "relative",
"permyriad" : 1000
}
} ]
}
DATA
200 Response Example: CartDiscountjson
{
"id" : "c2f93298-c967-44af-8c2a-d2220bf39eb2",
"version" : 1,
"createdAt" : "1970-01-01T00:00:00.001Z",
"lastModifiedAt" : "1970-01-01T00:00:00.001Z",
"name" : {
"en" : "Summer Sale"
},
"value" : {
"type" : "relative",
"permyriad" : 1000
},
"cartPredicate" : "1=1",
"target" : {
"type" : "lineItems",
"predicate" : "1=1"
},
"sortOrder" : "0.1",
"isActive" : true,
"requiresDiscountCode" : false,
"references" : [ ],
"stackingMode" : "Stacking"
}

Update actions

Set Key

action​
String​
"setKey"
key​
String​

Value to set. If empty, any existing value will be removed.

MinLength: 2​MaxLength: 256​Pattern: ^[A-Za-z0-9_-]+$​

Change Value

action​
String​
"changeValue"

New value to set.

Example: json
{
"action" : "changeValue",
"value" : {
"type" : "absolute",
"money" : [ {
"currencyCode" : "EUR",
"centAmount" : 40099
} ]
}
}

Change Cart Predicate

action​
String​
"changeCartPredicate"
cartPredicate​
String​

New value to set.

Example: json
{
"action" : "changeCartPredicate",
"cartPredicate" : "cartPredicateString"
}

Change Target

action​
String​
"changeTarget"
target​

New value to set.

Example: json
{
"action" : "changeTarget",
"target" : {
"type" : "lineItems",
"predicate" : "sku = \"myOtherSKU\""
}
}

Change IsActive

action​
String​
"changeIsActive"
isActive​
Boolean​

New value to set. If set to true, the Discount will be applied to the Cart.

Example: json
{
"action" : "changeIsActive",
"isActive" : false
}

Change Name

action​
String​
"changeName"
name​

New value to set.

Example: json
{
"action" : "changeName",
"name" : {
"en" : "NewNameEN",
"de" : "NewNameDE"
}
}

Set Description

action​
String​
"setDescription"
description​

Value to set. If empty, any existing value will be removed.

Example: json
{
"action" : "setDescription",
"description" : {
"en" : "New Description EN",
"de" : "New Description DE"
}
}

Change Sort Order

action​
String​
"changeSortOrder"
sortOrder​
String​

New value to set (between 0 and 1). A Discount with a higher sortOrder is prioritized.

Example: json
{
"action" : "changeSortOrder",
"sortOrder" : "0.2"
}

Change Requires DiscountCode

action​
String​
"changeRequiresDiscountCode"
requiresDiscountCode​
Boolean​

New value to set. If set to true, the Discount can only be used in connection with a DiscountCode.

Example: json
{
"action" : "changeRequiresDiscountCode",
"requiresDiscountCode" : true
}

Set Valid From

action​
String​
"setValidFrom"
validFrom​

Value to set. If empty, any existing value will be removed.

Example: json
{
"action" : "setValidFrom",
"validFrom" : "2017-10-15T15:00:00.000Z"
}

Set Valid Until

action​
String​
"setValidUntil"
validUntil​

Value to set. If empty, any existing value will be removed.

Example: json
{
"action" : "setValidUntil",
"validUntil" : "2017-10-15T20:00:00.000Z"
}

Set Valid From and Until

action​
String​
"setValidFromAndUntil"
validFrom​

Value to set. If empty, any existing value will be removed.

validUntil​

Value to set. If empty, any existing value will be removed.

Example: json
{
"action" : "setValidFromAndUntil",
"validFrom" : "2017-10-15T15:00:00.000Z",
"validUntil" : "2017-10-15T15:05:00.000Z"
}

Change Stacking Mode

action​
String​
"changeStackingMode"
stackingMode​

New value to set.

Example: json
{
"action" : "changeStackingMode",
"stackingMode" : "Stacking"
}

Set Custom Type

action​
String​
"setCustomType"

Defines the Type that extends the CartDiscount with Custom Fields. If absent, any existing Type and Custom Fields are removed from the CartDiscount.

fields​

Sets the Custom Fields fields for the CartDiscount.

Example: json
{
"action" : "setCustomType",
"type" : {
"id" : "{{type-id}}",
"typeId" : "type"
},
"fields" : {
"examplaryStringTypeField" : "TextString"
}
}

Set CustomField

action​
String​
"setCustomField"
name​
String​

Name of the Custom Field.

value​

If value is absent or null, this field will be removed if it exists. Trying to remove a field that does not exist will fail with an InvalidOperation error. If value is provided, it is set for the field defined by name.

Example: json
{
"action" : "setCustomField",
"name" : "ExamplaryStringTypeField",
"value" : "TextString"
}

Delete CartDiscount

Delete CartDiscount by ID

DELETE
https://api.{region}.commercetools.com/{projectKey}/cart-discounts/{id}
OAuth 2.0 Scopes:
manage_orders:{projectKey}, manage_cart_discounts:{projectKey}
Path parameters:
region
​
String
​

Region in which the Project is hosted.

projectKey
​
String
​

key of the Project.

id
​
String
​

id of the CartDiscount.

Query parameters:
version
​
Int
​

Last seen version of the resource.

expand
​​
The parameter can be passed multiple times.
Response:
Request Example:cURL
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/cart-discounts/{id}?version={version} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'
200 Response Example: CartDiscountjson
{
"id" : "c2f93298-c967-44af-8c2a-d2220bf39eb2",
"version" : 1,
"createdAt" : "1970-01-01T00:00:00.001Z",
"lastModifiedAt" : "1970-01-01T00:00:00.001Z",
"name" : {
"en" : "Summer Sale"
},
"value" : {
"type" : "relative",
"permyriad" : 1000
},
"cartPredicate" : "1=1",
"target" : {
"type" : "lineItems",
"predicate" : "1=1"
},
"sortOrder" : "0.1",
"isActive" : true,
"requiresDiscountCode" : false,
"references" : [ ],
"stackingMode" : "Stacking"
}

Delete CartDiscount by Key

DELETE
https://api.{region}.commercetools.com/{projectKey}/cart-discounts/key={key}
OAuth 2.0 Scopes:
manage_orders:{projectKey}, manage_cart_discounts:{projectKey}
Path parameters:
region
​
String
​

Region in which the Project is hosted.

projectKey
​
String
​

key of the Project.

key
​
String
​

key of the CartDiscount.

Query parameters:
version
​
Int
​

Last seen version of the resource.

expand
​​
The parameter can be passed multiple times.
Response:
Request Example:cURL
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/cart-discounts/key={key}?version={version} -i \
--header 'Authorization: Bearer ${BEARER_TOKEN}'
200 Response Example: CartDiscountjson
{
"id" : "c2f93298-c967-44af-8c2a-d2220bf39eb2",
"version" : 1,
"createdAt" : "1970-01-01T00:00:00.001Z",
"lastModifiedAt" : "1970-01-01T00:00:00.001Z",
"name" : {
"en" : "Summer Sale"
},
"value" : {
"type" : "relative",
"permyriad" : 1000
},
"cartPredicate" : "1=1",
"target" : {
"type" : "lineItems",
"predicate" : "1=1"
},
"sortOrder" : "0.1",
"isActive" : true,
"requiresDiscountCode" : false,
"references" : [ ],
"stackingMode" : "Stacking"
}