Queries and mutations for managing Cart Discounts in the platform.
Queries
Query Cart Discounts
| Arguments | |
|---|---|
whereString | |
sortArray of String | |
limitInt | |
offsetInt | |
Get Cart Discount
| Arguments | |
|---|---|
idString | Queries with specified ID |
keyString | Queries with specified key |
Mutations
Create Cart Discount
| Arguments | |
|---|---|
draft | |
storeKey | The mutation is only performed if the resource is part of the store. Can be used with store-specific OAuth permissions. |
Update Cart Discount
| Arguments | |
|---|---|
versionLong | |
actionsArray of CartDiscountUpdateAction | |
storeKey | The mutation is only performed if the resource is part of the store. Can be used with store-specific OAuth permissions. |
idString | Queries with specified ID |
keyString | Queries with specified key |
Delete Cart Discount
| Arguments | |
|---|---|
versionLong | |
storeKey | The mutation is only performed if the resource is part of the store. Can be used with store-specific OAuth permissions. |
idString | Queries with specified ID |
keyString | Queries with specified key |
Output types
CartDiscount
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 cart discounts that do not require a discount code (isActive=true and requiresDiscountCode=false) is limited to 100.
cartPredicateString | Valid Cart Predicate. |
stackingMode | Indicates whether the application of the CartDiscount causes other discounts to be ignored. Can beStacking, or StopAfterThisDiscount |
isActiveBoolean | Indicates if the CartDiscount is active and can be applied to the Cart. |
requiresDiscountCodeBoolean | Indicates if the Discount is used in connection with a DiscountCode. |
keyString | User-defined unique identifier of the CartDiscount. |
discountGroupRef | Reference to a DiscountGroup that the CartDiscount belongs to. |
nameString | Name of the CartDiscount. |
descriptionString | Description of the CartDiscount. |
nameAllLocalesArray of LocalizedString | Name of the CartDiscount. |
descriptionAllLocalesArray of LocalizedString | Description of the CartDiscount. |
referenceRefsArray of Reference | |
custom | Custom Fields of the CartDiscount. |
validFrom | Date and time (UTC) from which the Discount is effective. |
validUntil | Date and time (UTC) until which the Discount is effective. |
storesRefArray of KeyReference | |
storesArray of Store | |
discountGroup | Reference to a DiscountGroup that the CartDiscount belongs to. |
value | Effect of the CartDiscount on the target. |
target | Segment of the Cart that is discounted. Absent if the value is giftLineItem. |
sortOrderString | Value between
0 and 1 that determines the order in which the CartDiscounts are applied; a CartDiscount with a higher value is prioritized.It is unique among all CartDiscounts and DiscountGroups. If the CartDiscount is part of a DiscountGroup, it uses the sort order of the DiscountGroup. |
recurringOrderScope | BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta |
idString | Unique identifier of the CartDiscount. |
versionLong | Current version of the CartDiscount. |
createdAt | Date and time (UTC) the CartDiscount was initially created. |
lastModifiedAt | Date and time (UTC) the CartDiscount was last updated. |
createdBy | IDs and references that created the CartDiscount. |
lastModifiedBy | IDs and references that last modified the CartDiscount. |
StackingMode
Stacking- Default. Continue applying other matching discounts after applying this one.
StopAfterThisDiscount- Don’t apply any more matching discounts after this one.
CartDiscountValue
typeString |
CartDiscountTarget
typeString |
Cart Discount Query Result
offsetInt | |
countInt | |
totalLong | |
existsBoolean | |
resultsArray of CartDiscount |
Input types
CartDiscountDraft
value | Effect of the CartDiscount on the target. |
cartPredicateString | Valid Cart Predicate. |
target | Segment of the Cart that will be discounted. Must not be set if the value is giftLineItem. |
sortOrderString | Value between
0 and 1 that determines the order in which the CartDiscounts will be applied; a CartDiscount with a higher value will be prioritized.If the value is used by another Cart Discount or Discount Group, a DuplicateField error is returned.
If the CartDiscount is part of a DiscountGroup, it will use the sort order of the DiscountGroup. |
nameArray of LocalizedStringItemInputType | Name of the CartDiscount. |
descriptionArray of LocalizedStringItemInputType | Description of the CartDiscount. |
validFrom | Date and time (UTC) from which the Discount is effective. |
validUntil | Date and time (UTC) until which the Discount is effective. |
stackingMode | Specifies whether the application of this discount causes the following discounts to be ignored. Can beStacking, or StopAfterThisDiscountDefault: Stacking |
requiresDiscountCodeBoolean | States whether the Discount can only be used in a connection with a DiscountCode. Default: false |
isActiveBoolean | 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 |
custom | Custom Fields for the CartDiscount. |
keyString | User-defined unique identifier for the CartDiscount. If the value is used by another Cart Discount, a DuplicateField error is returned. |
storesArray of ResourceIdentifierInput |
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. |
discountGroup | Reference to a DiscountGroup that the CartDiscount must belong to. A CartDiscount can only be added to a DiscountGroup if its target.type is lineItems, customLineItems, multiBuyLineItems, multiBuyCustomLineItems, or pattern; otherwise, an InvalidInput error is returned. |
recurringOrderScope | Scope of the Cart Discount for Recurring Orders. If not set, the default is NonRecurringOrdersOnlyDraft. |
CartDiscountValueInput
relative | |
relativeCart | |
absolute | |
absoluteCart | |
fixed | |
fixedCart | |
giftLineItem |
RelativeDiscountValueInput
permyriadInt |
RelativeCartDiscountValueInput
permyriadInt | |
applicationMode | Can be ProportionateDistribution, EvenDistribution, or IndividualApplication |
DiscountApplicationMode
ProportionateDistributionEvenDistributionIndividualApplication
AbsoluteDiscountValueInput
moneyArray of MoneyInput |
AbsoluteCartDiscountValueInput
moneyArray of MoneyInput | |
applicationMode | Can be ProportionateDistribution, EvenDistribution, or IndividualApplication |
FixedPriceDiscountValueInput
moneyArray of CartDiscountValueBaseMoneyInput |
CartDiscountValueBaseMoneyInput
centPrecision | |
highPrecision | |
currencyCode | CurrencyCode and centAmount are deprecated. Please use Money(centPrecision) or HighPrecisionMoney(highPrecision). |
centAmountLong | CurrencyCode and centAmount are deprecated. Please use Money(centPrecision) or HighPrecisionMoney(highPrecision). |
FixedPriceCartDiscountValueInput
moneyArray of CartDiscountValueBaseMoneyInput | |
applicationMode | Can be ProportionateDistribution, EvenDistribution, or IndividualApplication |
GiftLineItemValueInput
product | |
variantIdInt | |
distributionChannel | |
supplyChannel |
CartDiscountTargetInput
lineItems | |
customLineItems | |
shipping | |
multiBuyLineItems | |
multiBuyCustomLineItems | |
totalPrice | |
pattern |
LineItemsTargetInput
predicateString |
CustomLineItemsTargetInput
predicateString |
ShippingTargetInput
dummyString |
MultiBuyLineItemsTargetInput
SelectionMode
CheapestMostExpensive
MultiBuyCustomLineItemsTargetInput
CartDiscountTotalPriceTargetInput
dummyString |
CartDiscountPatternTargetInput
triggerPatternArray of PatternComponentInput | |
targetPatternArray of PatternComponentInput | |
maxOccurrenceInt | |
selectionMode | Can be Cheapest, or MostExpensive |
PatternComponentInput
CountOnLineItemUnits | |
CountOnCustomLineItemUnits |
CountOnLineItemUnitsInput
predicateString | |
minCountInt | Default: 1 |
maxCountInt | |
excludeCountInt |
CountOnCustomLineItemUnitsInput
predicateString | |
minCountInt | Default: 1 |
maxCountInt | |
excludeCountDEPRECATEDInt | Please use 'triggerPattern' to exclude. |
StackingMode
Stacking- Default. Continue applying other matching discounts after applying this one.
StopAfterThisDiscount- Don’t apply any more matching discounts after this one.
CartDiscountUpdateAction
setStores | |
addStore | |
removeStore | |
setRecurringOrderScope | BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta |
changeCartPredicate | |
changeIsActive | |
changeName | |
changeRequiresDiscountCode | |
changeSortOrder | |
changeStackingMode | |
changeTarget | |
changeValue | |
setCustomField | |
setCustomType | |
setDescription | |
setKey | |
setValidFrom | |
setValidFromAndUntil | |
setValidUntil | |
setDiscountGroup |
Update actions
Set Stores
storesArray of ResourceIdentifierInput | Stores to set.
Overrides the current list of Stores.
Set to an empty array to remove all existing values.
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. |
Add Store
store | Store to add.
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. |
Remove Store
store | Store to remove. |
Set Recurring Order Scope
Sets the scope of the Cart Discount for Recurring Orders.
recurringOrderScope | Scope of the Cart Discount for Recurring Orders. |
Change Cart Predicate
cartPredicateString | New value to set. |
Change Is Active
isActiveBoolean | 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. |
Change Name
nameArray of LocalizedStringItemInputType | New value to set. |
Change Requires Discount Code
requiresDiscountCodeBoolean | New value to set. If
true, the Cart Discount can only be used with a DiscountCode.When set to false, if the number of active Cart Discounts without a Discount Code exceeds the limit, a MaxCartDiscountsReached error is returned. |
Change Sort Order
sortOrderString | New value to set (between
0 and 1).
A Discount with a higher sortOrder is prioritized.If the value is used by another Cart Discount or Discount Group, a DuplicateField error is returned. |
Change Stacking Mode
stackingMode | New value to set. Can beStacking, or StopAfterThisDiscount |
StackingMode
Stacking- Default. Continue applying other matching discounts after applying this one.
StopAfterThisDiscount- Don’t apply any more matching discounts after this one.
Change Target
target | New value to set. For a CartDiscountValueRelative, if applicationMode is set, the target must be CartDiscountPatternTarget.
If applicationMode is ProportionateDistribution or EvenDistribution, the CartDiscountPatternTarget triggerPattern must be non-empty.
If either conditions are not met, an InvalidOperation error is returned. |
CartDiscountTargetInput
lineItems | |
customLineItems | |
shipping | |
multiBuyLineItems | |
multiBuyCustomLineItems | |
totalPrice | |
pattern |
LineItemsTargetInput
predicateString |
CustomLineItemsTargetInput
predicateString |
ShippingTargetInput
dummyString |
MultiBuyLineItemsTargetInput
SelectionMode
CheapestMostExpensive
MultiBuyCustomLineItemsTargetInput
CartDiscountTotalPriceTargetInput
dummyString |
CartDiscountPatternTargetInput
triggerPatternArray of PatternComponentInput | |
targetPatternArray of PatternComponentInput | |
maxOccurrenceInt | |
selectionMode | Can be Cheapest, or MostExpensive |
PatternComponentInput
CountOnLineItemUnits | |
CountOnCustomLineItemUnits |
CountOnLineItemUnitsInput
predicateString | |
minCountInt | Default: 1 |
maxCountInt | |
excludeCountInt |
CountOnCustomLineItemUnitsInput
predicateString | |
minCountInt | Default: 1 |
maxCountInt | |
excludeCountDEPRECATEDInt | Please use 'triggerPattern' to exclude. |
Change Value
value | New value to set. When trying to set a CartDiscountValueGiftLineItemDraft an InvalidInput error is returned. |
CartDiscountValueInput
relative | |
relativeCart | |
absolute | |
absoluteCart | |
fixed | |
fixedCart | |
giftLineItem |
RelativeDiscountValueInput
permyriadInt |
RelativeCartDiscountValueInput
permyriadInt | |
applicationMode | Can be ProportionateDistribution, EvenDistribution, or IndividualApplication |
DiscountApplicationMode
ProportionateDistributionEvenDistributionIndividualApplication
AbsoluteDiscountValueInput
moneyArray of MoneyInput |
AbsoluteCartDiscountValueInput
moneyArray of MoneyInput | |
applicationMode | Can be ProportionateDistribution, EvenDistribution, or IndividualApplication |
FixedPriceDiscountValueInput
moneyArray of CartDiscountValueBaseMoneyInput |
CartDiscountValueBaseMoneyInput
centPrecision | |
highPrecision | |
currencyCode | CurrencyCode and centAmount are deprecated. Please use Money(centPrecision) or HighPrecisionMoney(highPrecision). |
centAmountLong | CurrencyCode and centAmount are deprecated. Please use Money(centPrecision) or HighPrecisionMoney(highPrecision). |
FixedPriceCartDiscountValueInput
moneyArray of CartDiscountValueBaseMoneyInput | |
applicationMode | Can be ProportionateDistribution, EvenDistribution, or IndividualApplication |
GiftLineItemValueInput
product | |
variantIdInt | |
distributionChannel | |
supplyChannel |
Set Custom Field
nameString | Name of the Custom Field. |
valueString | 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. |
Set Custom Type
fieldsArray of CustomFieldInput | |
type | |
typeKeyString | |
typeIdString |
Set Description
descriptionArray of LocalizedStringItemInputType | Value to set. If omitted, any existing value is removed. |
Set Key
keyString | Value to set. If omitted, any existing value is removed. If the value is used by another Cart Discount, a DuplicateField error is returned. |
Set Valid From
validFrom | Value to set. If omitted, any existing value is removed. |
Set Valid From And Until
Set Valid Until
validUntil | Value to set. If omitted, any existing value is removed. |
Set Discount Group
discountGroup | Reference to a DiscountGroup that the CartDiscount must belong to. If omitted, any existing value is removed. A CartDiscount can only be added to a DiscountGroup if its target.type is lineItems, customLineItems, multiBuyLineItems, multiBuyCustomLineItems, or pattern; otherwise, an InvalidInput error is returned. |
sortOrderString | New value to set (between
0 and 1) that determines the order in which the CartDiscounts are applied; a CartDiscount with a higher value is prioritized.Required if discountGroup is absent. If discountGroup is set, the CartDiscount will use the sort order of the DiscountGroup. |