Cart Discounts

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

The number of active CartDiscounts that do not require a Discount Code (isActive=true and requiresDiscountCode=false) is limited to 100. Cart Discounts can be defined globally for the Project or specific to one or more (up to 500) Stores. Learn more about this limit.

For an introduction to Cart Discounts and to understand how they work in Composable Commerce, see the Cart Discounts overview.

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: 2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$
name

Name of the CartDiscount.

description

Description of the CartDiscount.

Effect of the CartDiscount on the target.

cartPredicate
String
target

Segment of the Cart that is discounted.

Empty, if the value is 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.

stores
Array of StoreKeyReference
  • If a value exists, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
  • If empty, the Cart Discount applies on all Carts, irrespective of a Store.
MaxItems: 500
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 is used in connection with a DiscountCode.

Default: false
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) the CartDiscount was initially created.

createdByBETA

IDs and references that created the CartDiscount.

lastModifiedAt

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

lastModifiedByBETA

IDs and references that last modified the CartDiscount.

CartDiscountDraft

key
String

User-defined unique identifier for the CartDiscount.

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

Name of the CartDiscount.

description

Description of the CartDiscount.

Effect of the CartDiscount on the target.

cartPredicate
String
target

Segment of the Cart that will be discounted.

Must not be set if the value is giftLineItem.

sortOrder
String

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

stores
  • If defined, the Cart Discount applies on Carts having a Store matching any Store defined for this field.
  • If not defined, the Cart Discount applies on all Carts, irrespective of a Store.

If the referenced Stores exceed the limit, a MaxStoreReferencesReached error is returned.

If the referenced Stores exceed the limit for Cart Discounts that do not require a Discount Code, a StoreCartDiscountsLimitReached error is returned.

MaxItems: 500
isActive
Boolean

Only active Discounts can be applied to the Cart. If the limit for active Cart Discounts is reached, a MaxCartDiscountsReached error is returned.

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
"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

ResourceIdentifier to a CartDiscount. Either id or key is required. If both are set, an InvalidJsonInput error is returned.

id
String

Unique identifier of the referenced CartDiscount. Required if key is absent.

key
String

User-defined unique identifier of the referenced CartDiscount. Required if id is absent.

typeId
"cart-discount"

References a CartDiscount.

CartDiscountValue

The effect of the Discount on the specified target. The discount can be a relative or absolute Price value, a fixed item Price, or a Gift Line Item added to a 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.

applicationMode

Determines how the discount is applied on CartDiscountLineItemTarget and CartDiscountCustomLineItemTarget.

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. If the quantity of the Line Item eligible for the Discount is greater than 1, the fixed price discount is only applied to the Line Item portion for which the money value is lesser than their current price.

type
String
"fixed"
money
Array of TypedMoney

Money values in cent precision or high precision of different currencies.

applicationMode

Indicates how the discount is applied on CartDiscountLineItemTarget or CartDiscountCustomLineItemTarget.

For CartDiscountPatternTarget, the mode can also be ProportionateDistribution or EvenDistribution.

Default: IndividualApplication

CartDiscountValueGiftLineItem

A Gift Line Item is automatically added to the Cart when a Discount Predicate evaluates as true.

The Gift Line Item has the following characteristics:

  • LineItemMode GiftLineItem and a quantity of 1.
  • Like all other Line Items, it has the price field set (it is, therefore, necessary that the Product 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 shows a discountedPrice with a centAmount of 0 and includedDiscounts references the Cart Discount that was evaluated to add the Gift Line Item.

If the gift Line Item becomes invalid (for example when the referenced Product, Product Variant, or Channel has been deleted) since creation, or if a Price cannot be selected for a Cart, the Discount does not apply to the Cart.

type
String
"giftLineItem"
product

Reference to a Product.

A Gift Line Item can be present on a Cart even if the referenced Product is unpublished.

variantId
Int

ProductVariant of the Product.

supplyChannel

Channel must have the ChannelRoleEnum InventorySupply.

distributionChannel

Channel must have the ChannelRoleEnum ProductDistribution.

Gift Line Items are ignored by MultiBuyLineItemsTarget and CartDiscountPatternTarget discounts.

CartDiscountValueDraft

Defines the effect the Discount will have on the specified target. You can define a relative or absolute Discount value, a fixed item Price value, or a Gift Line Item.

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 match a price only if the array contains a value with the same currency. For example, if it contains 10€ and 15$, the matching € price will be decreased by 10€ and the matching $ price will be decreased by 15$. If the array has multiple values of the same currency, the API returns an InvalidOperation error.

If the array is empty, the discount does not apply.

applicationMode

Determines how the discount applies on CartDiscountLineItemTarget and CartDiscountCustomLineItemTarget.

If not set, the default behavior is ProportionateDistribution.

For example, when an absolute Discount of €16 applies to all Line Items in a Cart:

  • If discounted proportionately, the discount is calculated (for a Line Item) by dividing the price of the Line Item by the total price of the Cart and multiplying (the rounded) value by the discount amount; in this case, for Line Item A, (14/54)*16 = 4.16.
  • If discounted evenly, the discount amount is divided by the number of Line Items—in this case, 16/3—and that value is deducted from each Line Item with rounding.
  • If applied individually, the discount amount is deducted on every eligible Line item; negative values are rounded to zero, as seen for Line Item A.
CartQuantityPriceTotal price (tax-inclusive)Proportionate distributionEven distributionIndividual application
Line Item A1€14,00€14,00€9,84€8,67€0,00
Line Item B2€20,00€40,00€28.16€29,33€8,00
-------------------------------------------------------------------------
Total3€54,00€38,00€38,00€8,00
Discounted total€0,00€16,00€16,00€46,00

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 TypedMoneyDraft

Money values provided either in cent precision or high precision for different currencies. A fixed Cart Discount will match a price only if the array contains a value with the same currency. For example, if it contains 10€ and 15$, the matching € price will be discounted by 10€ and the matching $ price will be discounted to 15$. If the array has multiple values of the same currency, the API returns an InvalidOperation error.

If the array is empty, the discount does not apply.

applicationMode

Determines how the discount applies on CartDiscountLineItemTarget or CartDiscountCustomLineItemTarget.

For CartDiscountPatternTarget, you can also set the mode to ProportionateDistribution or EvenDistribution.

Default: IndividualApplication

CartDiscountValueGiftLineItemDraft

Adds one free Line Item to the Cart as a gift.

When the best deal (between Cart and Product Discounts) applies to a Cart, the gift item is added only after the best deal is calculated. The sort order and stacking mode are effective only among other Cart Discounts with the same discount target.

Can only be used in a CartDiscountDraft with no target specified. Hence, this type can not be used in the Change Value update action.

type
String
"giftLineItem"

ResourceIdentifier of a Product.

A Gift Line Item is added to a Cart even if the referenced Product is unpublished.

variantId
Int

ProductVariant of the Product.

supplyChannel

Channel must have the role InventorySupply.

distributionChannel

Channel must have the role ProductDistribution.

CartDiscountTarget

Defines what segment of the Cart will be discounted.
Discounts can be applied on LineItems, CustomLineItems, ShippingInfo, or Cart totalPrice.

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"

When the best deal (between Cart and Product Discounts) applies to a Cart, the discount (to the shipping cost) applies only after the best deal is calculated. The sort order and stacking mode are effective only among other Cart Discounts with the same discount target.

CartDiscountTotalPriceTarget

Discount is applied to the total price of the Cart.

type
String
"totalPrice"

When other Cart Discounts with different targets apply on a Cart, the Cart Total Price discount applies last, regardless of its sort order and ignoring the StopAfterThisDiscount StackingMode of the other Cart Discounts, if any. The sort order for a Cart Total Price discount only determines its ranking among other Cart Discounts targeting the Total Price. As a result, the stackingMode = StopAfterThisDiscount takes effect for a Cart Total Price discount only when there are other Cart Discounts targeting the Total Price with a lower sort order.

MultiBuyLineItemsTarget BETA

Multi-buy Discounts represent a "Buy X items, get Y of them at a discounted rate" type of discount. Multi-buy Line Items can only be discounted relatively.

To select the items relevant for the Discount, a LineItem Predicate is applied. Unlike LineItems Target, a multi-buy Discount is not applied on each LineItem as a whole, but on individual items that are contained in all matching Line Items and subsumed under their quantity fields.

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.

Minimum: 2
discountedQuantity
Int

Number of Line Items that are discounted per application of this Discount. It must be less than or equal to the triggerQuantity.

Minimum: 1
maxOccurrence
Int

Maximum number of times this Discount can be applied. Do not set if the Discount should be applied an unlimited number of times.

selectionMode

Discounts particular Line Items only according to the SelectionMode.

A multi-buy Discount can occur multiple times in a Cart, but any item will only be considered once per multi-buy Discount. A single application of a multi-buy Discount is defined by the triggerQuantity and discountedQuantity. For example, if the triggerQuantity is 6, and the discountedQuantity is 2, then the following cases apply:

  • On a Cart with 6 items, 2 items are discounted and 4 items are undiscounted while participating in the Discount. As a result, the Discount is applied only once.

  • On a Cart with 8 items, 2 items are discounted, 4 items are undiscounted while participating in the Discount, and the 2 remaining items are disregarded by the Discount. As a result, the Discount is still applied only once.

  • On a Cart with 12 items, 2*2 items are discounted and 2*4 are undiscounted while participating in the Discount. As a result, the Discount is applied twice.

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

To recap, the matching items of a Discount application are sliced into maxOccurence groups of size triggerQuantity. The remaining items (for example, the ninth item in a "buy 8, get 2 free" discount) do not participate in the Discount. In any such group, only discountedQuantity items are actually discounted (for example, the second item of a "buy 8, get 2 free" discount); the other items are part of this occurrence and thus, cannot participate in another group and the Price remains unchanged.

MultiBuyCustomLineItemsTarget BETA

Multi-buy Custom Line Items can only be discounted relatively.

To select the items relevant for the Discount, a CustomLineItem Predicate is applied. Unlike CustomLineItems Target, a multi-buy Discount is not applied on each CustomLineItem as a whole, but on individual items that are contained in all matching Custom Line Items and subsumed under their quantity fields.

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.

Minimum: 2
discountedQuantity
Int

Number of Custom Line Items that are discounted per application of this Discount. It must be less than or equal to the triggerQuantity.

Minimum: 1
maxOccurrence
Int

Maximum number of times this Discount can be applied. Do not set if the Discount should be applied an unlimited number of times.

selectionMode

Discounts particular Line Items only according to the SelectionMode.

CartDiscountPatternTarget BETA

Pattern targets can be used to model Buy and Get discounts.

Unlike CartDiscountLineItemsTarget and CartDiscountCustomLineItemsTarget, it does not apply to a (Custom) Line Item as a whole, but to individual units of a (Custom) Line Item. The discounts can apply multiple times on the same cart, but each unit can be discounted only once.

type
String
"pattern"
triggerPattern
Array of PatternComponent

Units of a (Custom) Line Item that trigger a discount application.

Based on the availability of matching units, the triggerPattern can match multiple times, effecting the number of times the discount will be applied. To further limit the discount application, set the maxOccurrence.

If empty or not set, the Discount will apply indefinitely.

targetPattern
Array of PatternComponent

Units of (Custom) Line Items on which the Discount is applied.

Based on the availability of matching units and the limits from the triggerPattern or maxOccurence, the targetPattern can match multiple times.

maxOccurrence
Int

Maximum number of times the Discount can apply on a Cart.

If empty or not set, the Discount will apply indefinitely.

selectionMode

Determines which of the matching units of (Custom) Line Items are discounted.

This discount is based on the concept of pattern matching. A pattern matches when all the components (in triggerPattern and targetPattern) match. Each (pattern) component defines a set of units participating in the Discount; the set can include units coming from different (Custom) Line Items.

Components are matched in the order listed in the array. A unit matched in a component will not be available for further matching. The resulting set of units is a combination of the resulting sets of all components.

Let's see a few examples:

  • Example 1: Buy a bundle of 2 jeans and 1 shirt; get the bundle with a US$100 discount distributed evenly. The discount can be applied up to 3 times and the cheapest items are selected for the discount.

    To obtain this behavior, only define the targetPattern to select the units that will be discounted. The pattern component (targetPattern) is matched by the union of the units matching each single component.

    {
    "targetPattern": [
    {
    "type":"CountOnLineItemUnits",
    "predicate": "categories.key=\"Jeans\"",
    "minCount": 2,
    "maxCount": 2
    },
    {
    "type":"CountOnLineItemUnits",
    "predicate": "categories.key=\"Shirt\"",
    "minCount": 1,
    "maxCount": 1
    }
    ],
    "maxOccurrence": 3,
    "selectionMode": "Cheapest",
    ...
    "value": {
    "type": "absolute",
    "applicationMode": "EvenDistribution",
    "money": [
    {
    "type": "centPrecision",
    "currencyCode": "USD",
    "centAmount": 10000,
    "fractionDigits": 2
    }
    ]
    }
    }

    If a cart contains:

    • 1 jean and 4 shirts, no unit will be selected for the discount as the first target component is not satisfied.
    • 4 jeans, no unit will be selected for the discount as the second target component is not satisfied.
    • 3 jeans and 2 shirts, 1 bundle (of 2 jeans and 1 shirt) will be selected for the discount and priced at US$100.
    • 6 jeans and 5 shirts, 3 bundles will be selected for the discount and each bundle will be priced at US$100. Each time the target pattern is matched, the cheapest bundle will be selected.
    • 12 jeans and 2 shirts, only 3 bundles will be selected for the discount as the maximum allowed limit for the discount application is 3.
  • Example 2: Buy 2 jeans and get up to 3 shirts at 20% off. The discount can be applied up to 4 times and the most expensive items are selected for the discount.

    In this scenario, a set of units is required to apply the discount on another set of units. To obtain this behavior, you must define the triggerPattern and targetPattern.

    {
    "triggerPattern": [
    {
    "type":"CountOnLineItemUnits",
    "predicate": "categories.key=\"Jeans\"",
    "minCount": 2,
    "maxCount": 2
    }
    ],
    "targetPattern": [
    {
    "type":"CountOnLineItemUnits",
    "predicate": "categories.key=\"Shirt\"",
    "minCount": 1,
    "maxCount": 3
    }
    ],
    "maxOccurrence": 4,
    "selectionMode": "MostExpensive",
    ...
    "value": {
    "type": "relative",
    "permyriad": "200",
    }
    }

    If a cart contains:

    • 2 jeans and 8 shirts, 3 shirts are discounted as the trigger is matched only once.
    • 4 jeans and 3 shirts, 3 shirts are discounted as the target is matched only once although the trigger is matched twice.
    • 4 jeans and 5 shirts, 5 shirts are discounted as the trigger and target is matched twice.
    • 6 jeans and 6 shirts, 6 shirts are discounted.
    • 20 jeans and 20 shirts, 12 shirts are discounted shirts as the discount is applied a maximum of 4 times.
  • Example 3: Buy 3 tees and get up to 2 tees at US$20 each. The discount can be applied up any number of times and the cheapest items are selected for the discount.

    In this scenario, the units that trigger the discount and the units that are targeted by the discount are the same. To obtain this behavior, define targetPattern.excludeCount.

{
"targetPattern": [
{
"type":"CountOnLineItemUnits",
"predicate": "categories.key=\"Tee\"",
"minCount": 1,
"maxCount": 2,
"excludeCount": 3
}
],
"selectionMode": "Cheapest",
...
"value": {
"type": "fixed",
"applicationMode": "IndividualApplication"
"money": [
{
"type": "centPrecision",
"currencyCode": "USD",
"centAmount": 2000,
"fractionDigits": 2
}
]
}
}

If a cart contains:

  • 3 tees, no tees are discounted as 3 tees are excluded from the discount.
  • 4 tees, 1 tee will be discounted from 1 application.
  • 5 tees, 2 tees will be discounted from 1 applications.
  • 8 tees, 2 tees will be discounted from 2 applications (3 excluded and 2 selected for the first application and 3 excluded for the second application).
  • 9 tees, 3 tees will be discounted from 2 applications (3 excluded and 2 selected for the first application and 3 excluded and 1 selected for the second application).

PatternComponent BETA

A component that defines the set of units to participate in the Discount.

CountOnLineItemUnits BETA

type
String
"CountOnLineItemUnits"
predicate
String

Valid LineItem predicate that determines the units participating in the Discount.

minCount
Int

Minimum number of units of a Line Item that match the predicate.

Default: 1
maxCount
Int

Maximum number of units of a Line Item that match the predicate. There might be more units matching the predicate, but they will not be participating to the resulting set.

The value must be greater than or equal to minCount. If not provided, the component will match all units that satisfy the predicate.

Minimum: 1
excludeCount
Int

Number of units of a Line Item to exclude on every application of the Discount.

Set only when configuring the targetPattern.

The units matched first (satisfying the pattern component) will be excluded from the resulting set. The minCountand maxCount are considered only after the exclusion. Pattern components are matched only if any further units satisfying the pattern component exist. For example, if 5 jeans are required but only 3 should be discounted, the excludeCount value must be 2.

Default: 0

CountOnCustomLineItemUnits BETA

type
String
"CountOnCustomLineItemUnits"
predicate
String

Valid CustomLineItem predicate that determines the units participating in the Discount.

minCount
Int

Minimum number of units of a Custom Line Item that match the predicate.

Default: 1
maxCount
Int

Maximum number of units of a Custom Line Item that match the predicate. There might be more units matching the predicate, but they will not be participating to the resulting set.

The value must be greater than or equal to minCount. If not provided, the component will match all units that satisfy the predicate.

Minimum: 1
excludeCount
Int

Number of units of a Custom Line Item to exclude on every application of the Discount.

Set only when configuring the targetPattern.

The units matched first (satisfying the pattern component) will be excluded from the resulting set. The minCountand maxCount are considered only after the exclusion. Pattern components are matched only if any further units satisfying the pattern component exist. For example, if 5 jeans are required but only 3 should be discounted, the excludeCount value must be 2.

Default: 0

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.

If two or more items have the same Price, it is not predictable which of the items are participating in the Discount and which are not. What we guarantee is that the total Discount over all participating items is correct.

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.

DiscountApplicationMode

This mode determines how absolute Discounts are applied on Line Items or Custom Line Items.

ProportionateDistribution

Distributes the Discount proportionately across eligible Line Items or Custom Line Items.

EvenDistribution

Distributes the Discount evenly across eligible Line Items or Custom Line Items.

IndividualApplication

Applies the Discount individually to eligible Line Item or Custom Line Item.

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:
200CartDiscountasapplication/json
Request Example:cURL
curl --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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"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:
200CartDiscountasapplication/json
Request Example:cURL
curl --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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"isActive": true,
"requiresDiscountCode": false,
"references": [],
"stackingMode": "Stacking"
}

Get CartDiscount in Store

Get CartDiscount by ID

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

Region in which the Project is hosted.

projectKey
String

key of the Project.

storeKey
String

key of the Store.

id
String

id of the CartDiscount.

Query parameters:
expand
The parameter can be passed multiple times.
Response:
200CartDiscountasapplication/json
Request Example:cURL
curl --get https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"isActive": true,
"requiresDiscountCode": false,
"references": [],
"stackingMode": "Stacking"
}

Get CartDiscount by Key

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

Region in which the Project is hosted.

projectKey
String

key of the Project.

storeKey
String

key of the Store.

key
String

key of the CartDiscount.

Query parameters:
expand
The parameter can be passed multiple times.
Response:
200CartDiscountasapplication/json
Request Example:cURL
curl --get https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"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.

Default: true
Response:
200CartDiscountPagedQueryResponseasapplication/json
Request Example:cURL
curl --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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"isActive": true,
"requiresDiscountCode": false,
"references": [],
"stackingMode": "Stacking"
}
]
}

Query CartDiscounts in Store

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

Region in which the Project is hosted.

projectKey
String

key of the Project.

storeKey
String

key of the Store.

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.

Default: true
Response:
200CartDiscountPagedQueryResponseasapplication/json
Request Example:cURL
curl --get https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"isActive": true,
"requiresDiscountCode": false,
"references": [],
"stackingMode": "Stacking"
}
]
}

Check if CartDiscount exists

Check if CartDiscount exists by ID

HEAD
https://api.{region}.commercetools.com/{projectKey}/cart-discounts/{id}

Checks if a CartDiscount exists for a given id. Returns a 200 OK status if the CartDiscount exists or a 404 Not Found otherwise.

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.

Response:
200
Request Example:cURL
curl --head https://api.{region}.commercetools.com/{projectKey}/cart-discounts/{id} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"

Check if CartDiscount exists by Key

HEAD
https://api.{region}.commercetools.com/{projectKey}/cart-discounts/key={key}

Checks if a CartDiscount exists for a given key. Returns a 200 OK status if the CartDiscount exists or a 404 Not Found otherwise.

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.

Response:
200
Request Example:cURL
curl --head https://api.{region}.commercetools.com/{projectKey}/cart-discounts/key={key} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"

Check if CartDiscount exists by Query Predicate

HEAD
https://api.{region}.commercetools.com/{projectKey}/cart-discounts

Checks if a CartDiscount exists for a given Query Predicate. Returns a 200 OK status if any CartDiscounts match the Query Predicate, or a 404 Not Found otherwise.

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.
Response:
200
Request Example:cURL
curl --head https://api.{region}.commercetools.com/{projectKey}/cart-discounts -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"

Check if CartDiscount exists in Store

Check if CartDiscount exists by ID

HEAD
https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/cart-discounts/{id}

Checks if a CartDiscount exists for a given id. Returns a 200 OK status if the CartDiscount exists or a 404 Not Found otherwise.

OAuth 2.0 Scopes:
view_orders:{projectKey}view_orders:{projectKey}:{storeKey}view_cart_discounts:{projectKey}view_cart_discounts:{projectKey}:{storeKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

storeKey
String

key of the Store.

id
String

id of the CartDiscount.

Response:
200
Request Example:cURL
curl --head https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/cart-discounts/{id} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"

Check if CartDiscount exists by Key

HEAD
https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/cart-discounts/key={key}

Checks if a CartDiscount exists for a given key. Returns a 200 OK status if the CartDiscount exists or a 404 Not Found otherwise.

OAuth 2.0 Scopes:
view_orders:{projectKey}view_orders:{projectKey}:{storeKey}view_cart_discounts:{projectKey}view_cart_discounts:{projectKey}:{storeKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

storeKey
String

key of the Store.

key
String

key of the CartDiscount.

Response:
200
Request Example:cURL
curl --head https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/cart-discounts/key={key} -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"

Check if CartDiscount exists by Query Predicate

HEAD
https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/cart-discounts

Checks if a CartDiscount exists for a given Query Predicate. Returns a 200 OK status if any CartDiscounts match the Query Predicate or a 404 Not Found otherwise.

OAuth 2.0 Scopes:
view_orders:{projectKey}view_orders:{projectKey}:{storeKey}view_cart_discounts:{projectKey}view_cart_discounts:{projectKey}:{storeKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

storeKey
String

key of the Store.

Query parameters:
where
The parameter can be passed multiple times.
Response:
200
Request Example:cURL
curl --head https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/cart-discounts -i \
--header "Authorization: Bearer ${BEARER_TOKEN}"

Create CartDiscount

POST
https://api.{region}.commercetools.com/{projectKey}/cart-discounts

Creating a Cart Discount produces the CartDiscountCreated Message.

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:CartDiscountDraftasapplication/json
Response:
201CartDiscountasapplication/json
Request Example:cURL
curl 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",
"stores" : [ {
"key" : "{{store-key}}"
} ],
"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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"isActive": true,
"requiresDiscountCode": false,
"references": [],
"stackingMode": "Stacking"
}

Create CartDiscount in Store

POST
https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/cart-discounts

When using the endpoint, the Store specified in the path and the Stores specified in the payload's stores field are added to the CartDiscount.

Creating a Cart Discount produces the CartDiscountCreated Message.

OAuth 2.0 Scopes:
manage_orders:{projectKey}manage_orders:{projectKey}:{storeKey}manage_cart_discounts:{projectKey}manage_cart_discounts:{projectKey}:{storeKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

storeKey
String

key of the Store.

Query parameters:
expand
The parameter can be passed multiple times.
Request Body:CartDiscountDraftasapplication/json
Response:
201CartDiscountasapplication/json
Request Example:cURL
curl https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/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",
"stores" : [ {
"key" : "{{store-key}}"
} ],
"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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"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:
application/json
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 ConcurrentModification error will be returned.

actions

Update actions to be performed on the CartDiscount.

Response:
200CartDiscountasapplication/json
Request Example:cURL
curl 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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"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:
application/json
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 ConcurrentModification error will be returned.

actions

Update actions to be performed on the CartDiscount.

Response:
200CartDiscountasapplication/json
Request Example:cURL
curl 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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"isActive": true,
"requiresDiscountCode": false,
"references": [],
"stackingMode": "Stacking"
}

Update CartDiscount in Store

Update CartDiscount by ID

POST
https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/cart-discounts/{id}

To update a CartDiscount, you must have permissions for all Stores the CartDiscount is associated with, except when removing a Store.

OAuth 2.0 Scopes:
manage_orders:{projectKey}manage_orders:{projectKey}:{storeKey}manage_cart_discounts:{projectKey}manage_cart_discounts:{projectKey}:{storeKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

storeKey
String

key of the Store.

id
String

id of the CartDiscount.

Query parameters:
expand
The parameter can be passed multiple times.
Request Body:
application/json
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 ConcurrentModification error will be returned.

actions

Update actions to be performed on the CartDiscount.

Response:
200CartDiscountasapplication/json
Request Example:cURL
curl https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"isActive": true,
"requiresDiscountCode": false,
"references": [],
"stackingMode": "Stacking"
}

Update CartDiscount by Key

POST
https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/cart-discounts/key={key}

To update a CartDiscount, you must have permissions for all Stores the CartDiscount is associated with, except when removing a Store.

OAuth 2.0 Scopes:
manage_orders:{projectKey}manage_orders:{projectKey}:{storeKey}manage_cart_discounts:{projectKey}manage_cart_discounts:{projectKey}:{storeKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

storeKey
String

key of the Store.

key
String

key of the CartDiscount.

Query parameters:
expand
The parameter can be passed multiple times.
Request Body:
application/json
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 ConcurrentModification error will be returned.

actions

Update actions to be performed on the CartDiscount.

Response:
200CartDiscountasapplication/json
Request Example:cURL
curl https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"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: 2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$
Example: json
{
"action": "setKey",
"key": "new-key"
}

Change Value

Changes the CartDiscountValue for relative, absolute and fixed price CartDiscounts. Changing to Gift Line Item is not supported.

action
String
"changeValue"

New value to set. When trying to set a CartDiscountValueGiftLineItemDraft an InvalidInput error is returned.

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

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.

If the limit for active Cart Discounts is reached, a MaxCartDiscountsReached error is returned.

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"
}

Add Store

If a referenced Store does not exist, a ReferencedResourceNotFound error is returned.

This action generates a CartDiscountStoreAdded Message.

action
String
"addStore"

Store to add.

A failed update can return the following errors:

Example: json
{
"action": "addStore",
"store": {
"key": "{{store-key}}"
}
}

Remove Store

If a referenced Store does not exist, a ReferencedResourceNotFound error is returned.

This action generates a CartDiscountStoreRemoved Message.

action
String
"removeStore"

Store to remove.

Example: json
{
"action": "removeStore",
"store": {
"key": "{{store-key}}"
}
}

Set Stores

If a referenced Store does not exist, a ReferencedResourceNotFound error is returned.

This action generates a CartDiscountStoresSet Message.

action
String
"setStores"
stores

Stores to set. Overrides the current list of Stores. If empty, any existing values will be removed.

A failed update can return the following errors:

MaxItems: 500
Example: json
{
"action": "setStores",
"stores": [
{
"key": "store-one"
},
{
"key": "store-two"
},
{
"key": "store-three"
}
]
}

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": {
"exampleStringField": "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. Removing a field that does not exist returns an InvalidOperation error. If value is provided, it is set for the field defined by name.

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

Delete CartDiscount

Delete CartDiscount by ID

DELETE
https://api.{region}.commercetools.com/{projectKey}/cart-discounts/{id}

Deleting a Cart Discount produces the CartDiscountDeleted Message.

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:
200CartDiscountasapplication/json
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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"isActive": true,
"requiresDiscountCode": false,
"references": [],
"stackingMode": "Stacking"
}

Delete CartDiscount by Key

DELETE
https://api.{region}.commercetools.com/{projectKey}/cart-discounts/key={key}

Deleting a Cart Discount produces the CartDiscountDeleted Message.

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:
200CartDiscountasapplication/json
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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"isActive": true,
"requiresDiscountCode": false,
"references": [],
"stackingMode": "Stacking"
}

Delete CartDiscount in Store

Delete CartDiscount by ID

DELETE
https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/cart-discounts/{id}

To delete a CartDiscount, specify the manage_cart_discounts:{projectKey}:{storeKey} scope for all Stores associated with the CartDiscount.

Deleting a Cart Discount produces the CartDiscountDeleted Message.

OAuth 2.0 Scopes:
manage_orders:{projectKey}manage_orders:{projectKey}:{storeKey}manage_cart_discounts:{projectKey}manage_cart_discounts:{projectKey}:{storeKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

storeKey
String

key of the Store.

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:
200CartDiscountasapplication/json
Request Example:cURL
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"isActive": true,
"requiresDiscountCode": false,
"references": [],
"stackingMode": "Stacking"
}

Delete CartDiscount by Key

DELETE
https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/cart-discounts/key={key}

To delete a CartDiscount, specify the manage_cart_discounts:{projectKey}:{storeKey} scope for all Stores associated with the CartDiscount.

Deleting a Cart Discount produces the CartDiscountDeleted Message.

OAuth 2.0 Scopes:
manage_orders:{projectKey}manage_orders:{projectKey}:{storeKey}manage_cart_discounts:{projectKey}manage_cart_discounts:{projectKey}:{storeKey}
Path parameters:
region
String

Region in which the Project is hosted.

projectKey
String

key of the Project.

storeKey
String

key of the Store.

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:
200CartDiscountasapplication/json
Request Example:cURL
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/in-store/key={storeKey}/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",
"stores": [
{
"key": "{{store-key}}",
"typeId": "store"
}
],
"isActive": true,
"requiresDiscountCode": false,
"references": [],
"stackingMode": "Stacking"
}