Product Discounts
Product Discounts reduce certain Product Prices.
Product Discounts apply to Embedded Prices, as well as StandalonePrices. In the case of an Embedded Price, the system stores Product Discounts in the discounted field of the Embedded Price. For StandalonePrices, the API uses the discounted field of the StandalonePrice in its current, as well as its staged representation.
In the case of StandalonePrices, Discounts for Products in a published state apply based on the current ProductData. For Products not published, the staged ProductData is used to calculate the Discount.
Product Discounts are useful for scenarios when you want to display a discounted price before adding an item to the Cart.
A maximum of 500 Product Discounts can be active at the same time.
Only one Product Discount can apply to a Product at any given time. If more than one Product Discount matches a Price, the sortOrder determines which one applies.
When you create, update, or remove a discount, it can take up to 15 minutes for all the prices to be updated with the discounts. For more information, see Eventual Consistency.
The API will update both Embedded Prices and StandalonePrices associated to a ProductVariant, regardless of the Product's priceMode value.
Representations
ProductDiscount
idString | Unique identifier of the ProductDiscount. |
versionInt | Current version of the ProductDiscount. |
keyString | User-defined unique identifier of the ProductDiscount. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
name | Name of the ProductDiscount. |
description | Description of the ProductDiscount. |
value | Type of Discount and its corresponding value. |
predicateString | Valid ProductDiscount predicate. |
sortOrderString | Unique decimal value between 0 and 1 (stored as String literal) defining the order of Product Discounts to apply in case more than one is applicable and active. A Product Discount with a higher value is prioritized. |
isActiveBoolean | If |
referencesArray of Reference | References of all the resources that are addressed in the |
validFrom | Date and time (UTC) from which the Discount is effective. Take Eventual Consistency into account for calculated discount values. |
validUntil | Date and time (UTC) until which the Discount is effective. Take Eventual Consistency into account for calculated undiscounted values. |
createdAt | Date and time (UTC) the ProductDiscount was initially created. |
createdByBETA | Present on resources created after 1 February 2019 except for events not tracked. |
lastModifiedAt | Date and time (UTC) the ProductDiscount was last updated. |
lastModifiedByBETA | Present on resources created after 1 February 2019 except for events not tracked. |
{"id" : "d7a204f9-7746-4857-b17e-71f1235a691a","version" : 2,"value" : {"type" : "absolute","money" : [ {"type" : "centPrecision","fractionDigits" : 2,"currencyCode" : "EUR","centAmount" : 100} ],"id" : "3544d4a3-1279-443c-8699-4220753bf6f5"},"predicate" : "1=1","name" : {"en" : "test-discount1"},"description" : {"en" : "test-discount1"},"isActive" : false,"sortOrder" : "0.9534","references" : [ ],"createdAt" : "2016-02-24T09:44:57.858Z","lastModifiedAt" : "2016-02-24T09:44:57.939Z"}
ProductDiscountDraft
keyString | User-defined unique identifier for the ProductDiscount. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
name | Name of the ProductDiscount. |
description | Description of the ProductDiscount. |
value | Type of Discount and its corresponding value. |
predicateString | Valid ProductDiscount predicate. |
sortOrderString | Decimal value between 0 and 1 (passed as String literal) that defines the order of ProductDiscounts to apply in case more than one is applicable and active. A ProductDiscount with a higher |
isActiveBoolean | Set to |
validFrom | Date and time (UTC) from which the Discount is effective. Take Eventual Consistency into account for calculated discount values. |
validUntil | Date and time (UTC) until which the Discount is effective. Take Eventual Consistency into account for calculated undiscounted values. |
{"value" : {"type" : "absolute","money" : [ {"currencyCode" : "EUR","centAmount" : 100} ]},"predicate" : "1=1","name" : {"en" : "test-discount1"},"description" : {"en" : "test-discount1"},"isActive" : false,"sortOrder" : "0.9534"}
ProductDiscountPagedQueryResponse
PagedQueryResult with results containing an array of ProductDiscount.
limitInt | Number of results requested. |
offsetInt | Number of elements skipped. |
countInt | Actual number of results returned. |
totalInt | 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 |
resultsArray of ProductDiscount | ProductDiscounts matching the query. |
{"limit" : 20,"offset" : 0,"count" : 2,"total" : 2,"results" : [ {"id" : "d7a204f9-7746-4857-b17e-71f1235a691a","version" : 2,"value" : {"type" : "absolute","money" : [ {"type" : "centPrecision","fractionDigits" : 2,"currencyCode" : "EUR","centAmount" : 100} ]},"predicate" : "1=1","name" : {"en" : "test-discount1"},"description" : {"en" : "test-discount1"},"isActive" : false,"sortOrder" : "0.9534","references" : [ ],"createdAt" : "2016-02-24T09:44:57.858Z","lastModifiedAt" : "2016-02-24T09:44:57.939Z"}, {"id" : "29cc032d-8ee3-4763-b2ab-3fe0dda22a2d","version" : 2,"value" : {"type" : "absolute","money" : [ {"type" : "centPrecision","fractionDigits" : 2,"currencyCode" : "EUR","centAmount" : 100} ]},"predicate" : "1=1","name" : {"en" : "test-discount2"},"description" : {"en" : "test-discount2"},"isActive" : false,"sortOrder" : "0.9478","references" : [ ],"createdAt" : "2016-02-24T10:25:04.206Z","lastModifiedAt" : "2016-02-24T10:25:04.295Z"} ]}
ProductDiscountReference
Reference to a ProductDiscount.
idString | Unique identifier of the referenced ProductDiscount. |
typeIdString | "product-discount"References a ProductDiscount. |
obj | Contains the representation of the expanded ProductDiscount. Only present in responses to requests with Reference Expansion for ProductDiscounts. |
ProductDiscountResourceIdentifier
idString | Unique identifier of the referenced ProductDiscount. Either |
keyString | User-defined unique identifier of the referenced ProductDiscount. Either |
typeIdString | "product-discount"References a ProductDiscount. |
ProductDiscountReference
Reference to a ProductDiscount.
id- String
Unique ID of the referenced ProductDiscount.typeId- String -product-discountobj- Type - Optional
Contains the representation of the expanded ProductDiscount. Only present in responses to requests with Reference Expansion for ProductDiscounts.
ProductDiscountValue
Abstract parent type for the specific values, distinguished by the type field - relative, absolute, or external.
ProductDiscountValueRelative
Discounts the product price by a percentage, defined by the permyriad field.
typeString | "relative" |
permyriadInt | Fraction (per ten thousand) the price is reduced by. For example, |
ProductDiscountValueAbsolute
Discounts the Product's Price by a fixed amount, defined by the money field.
typeString | "absolute" |
moneyArray of CentPrecisionMoney | Money values in different currencies. An absolute ProductDiscount will only match a price if this 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$. |
ProductDiscountValueExternal
Discounts the Product Price by allowing the client to explicitly set a discounted value. Used when setting discounts using an external service.
typeString | "external" |
ProductDiscountValueDraft
Abstract parent draft type for the specific value drafts, distinguished by the type field - relative, absolute, or external.
ProductDiscountValueRelativeDraft
Discounts the Product Price by a percentage, defined by the permyriad field.
typeString | "relative" |
permyriadInt | Fraction (per ten thousand) the price is reduced by. For example, |
ProductDiscountValueAbsoluteDraft
Discounts the Product Price by a fixed amount, defined by the money field.
typeString | "absolute" |
moneyArray of Money | Money values in different currencies. An absolute ProductDiscount will only match a price if this 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$. |
ProductDiscountValueExternalDraft
Discounts the Product Price by allowing the client to explicitly set a discounted value. Use this when setting discounts using an external service.
typeString | "external" |
QueryPrice
idString | Unique identifier of the given Price. |
value | Money value of the given Price. |
country | Country for which the given Price is valid. Pattern:^[A-Z]{2}$ |
customerGroup | CustomerGroup for which the given Price is valid. |
channel |
|
validFrom | Date from which the given Price is valid. |
validUntil | Date until which the given Price is valid. |
discounted | DiscountedPrice you specify for the given Price. |
tiersArray of PriceTierDraft | Price tier applied when the minimum quantity for the LineItem of a ProductVariant with the related Price is reached in a Cart. |
custom | Custom Fields for the Price. |
Get ProductDiscount
Get ProductDiscount by ID
view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
expand | The parameter can be passed multiple times. |
curl -X GET https://api.{region}.commercetools.com/{projectKey}/product-discounts/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "d7a204f9-7746-4857-b17e-71f1235a691a","version" : 2,"value" : {"type" : "absolute","money" : [ {"type" : "centPrecision","fractionDigits" : 2,"currencyCode" : "EUR","centAmount" : 100} ],"id" : "3544d4a3-1279-443c-8699-4220753bf6f5"},"predicate" : "1=1","name" : {"en" : "test-discount1"},"description" : {"en" : "test-discount1"},"isActive" : false,"sortOrder" : "0.9534","references" : [ ],"createdAt" : "2016-02-24T09:44:57.858Z","lastModifiedAt" : "2016-02-24T09:44:57.939Z"}
Get ProductDiscount by Key
view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
expand | The parameter can be passed multiple times. |
curl -X GET https://api.{region}.commercetools.com/{projectKey}/product-discounts/key={key} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "d7a204f9-7746-4857-b17e-71f1235a691a","version" : 2,"value" : {"type" : "absolute","money" : [ {"type" : "centPrecision","fractionDigits" : 2,"currencyCode" : "EUR","centAmount" : 100} ],"id" : "3544d4a3-1279-443c-8699-4220753bf6f5"},"predicate" : "1=1","name" : {"en" : "test-discount1"},"description" : {"en" : "test-discount1"},"isActive" : false,"sortOrder" : "0.9534","references" : [ ],"createdAt" : "2016-02-24T09:44:57.858Z","lastModifiedAt" : "2016-02-24T09:44:57.939Z"}
Query ProductDiscounts
view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
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. |
limitInt | Number of results requested. |
offsetInt | Number of elements skipped. |
withTotalBoolean | Controls the calculation of the total number of query results. Set to |
curl -X GET https://api.{region}.commercetools.com/{projectKey}/product-discounts -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"limit" : 20,"offset" : 0,"count" : 2,"total" : 2,"results" : [ {"id" : "d7a204f9-7746-4857-b17e-71f1235a691a","version" : 2,"value" : {"type" : "absolute","money" : [ {"type" : "centPrecision","fractionDigits" : 2,"currencyCode" : "EUR","centAmount" : 100} ]},"predicate" : "1=1","name" : {"en" : "test-discount1"},"description" : {"en" : "test-discount1"},"isActive" : false,"sortOrder" : "0.9534","references" : [ ],"createdAt" : "2016-02-24T09:44:57.858Z","lastModifiedAt" : "2016-02-24T09:44:57.939Z"}, {"id" : "29cc032d-8ee3-4763-b2ab-3fe0dda22a2d","version" : 2,"value" : {"type" : "absolute","money" : [ {"type" : "centPrecision","fractionDigits" : 2,"currencyCode" : "EUR","centAmount" : 100} ]},"predicate" : "1=1","name" : {"en" : "test-discount2"},"description" : {"en" : "test-discount2"},"isActive" : false,"sortOrder" : "0.9478","references" : [ ],"createdAt" : "2016-02-24T10:25:04.206Z","lastModifiedAt" : "2016-02-24T10:25:04.295Z"} ]}
Create ProductDiscount
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
expand | The parameter can be passed multiple times. |
curl -X POST https://api.{region}.commercetools.com/{projectKey}/product-discounts -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"value" : {"type" : "absolute","money" : [ {"currencyCode" : "EUR","centAmount" : 100} ]},"predicate" : "1=1","name" : {"en" : "test-discount1"},"description" : {"en" : "test-discount1"},"isActive" : false,"sortOrder" : "0.9534"}DATA
{"id" : "d7a204f9-7746-4857-b17e-71f1235a691a","version" : 2,"value" : {"type" : "absolute","money" : [ {"type" : "centPrecision","fractionDigits" : 2,"currencyCode" : "EUR","centAmount" : 100} ],"id" : "3544d4a3-1279-443c-8699-4220753bf6f5"},"predicate" : "1=1","name" : {"en" : "test-discount1"},"description" : {"en" : "test-discount1"},"isActive" : false,"sortOrder" : "0.9534","references" : [ ],"createdAt" : "2016-02-24T09:44:57.858Z","lastModifiedAt" : "2016-02-24T09:44:57.939Z"}
Update ProductDiscount
Update ProductDiscount by ID
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
expand | The parameter can be passed multiple times. |
versionInt | Expected version of the ProductDiscount on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict will be returned. |
actionsArray of ProductDiscountUpdateAction | Update actions to be performed on the ProductDiscount. |
curl -X POST https://api.{region}.commercetools.com/{projectKey}/product-discounts/{id} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"version" : 1,"actions" : [ {"action" : "changeValue","value" : {"type" : "absolute","money" : [ {"currencyCode" : "EUR","centAmount" : 100} ]}} ]}DATA
{"id" : "d7a204f9-7746-4857-b17e-71f1235a691a","version" : 2,"value" : {"type" : "absolute","money" : [ {"type" : "centPrecision","fractionDigits" : 2,"currencyCode" : "EUR","centAmount" : 100} ],"id" : "3544d4a3-1279-443c-8699-4220753bf6f5"},"predicate" : "1=1","name" : {"en" : "test-discount1"},"description" : {"en" : "test-discount1"},"isActive" : false,"sortOrder" : "0.9534","references" : [ ],"createdAt" : "2016-02-24T09:44:57.858Z","lastModifiedAt" : "2016-02-24T09:44:57.939Z"}
Update ProductDiscount by Key
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
expand | The parameter can be passed multiple times. |
versionInt | Expected version of the ProductDiscount on which the changes should be applied. If the expected version does not match the actual version, a 409 Conflict will be returned. |
actionsArray of ProductDiscountUpdateAction | Update actions to be performed on the ProductDiscount. |
curl -X POST https://api.{region}.commercetools.com/{projectKey}/product-discounts/key={key} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA{"version" : 1,"actions" : [ {"action" : "changeValue","value" : {"type" : "absolute","money" : [ {"currencyCode" : "EUR","centAmount" : 100} ]}} ]}DATA
{"id" : "d7a204f9-7746-4857-b17e-71f1235a691a","version" : 2,"value" : {"type" : "absolute","money" : [ {"type" : "centPrecision","fractionDigits" : 2,"currencyCode" : "EUR","centAmount" : 100} ],"id" : "3544d4a3-1279-443c-8699-4220753bf6f5"},"predicate" : "1=1","name" : {"en" : "test-discount1"},"description" : {"en" : "test-discount1"},"isActive" : false,"sortOrder" : "0.9534","references" : [ ],"createdAt" : "2016-02-24T09:44:57.858Z","lastModifiedAt" : "2016-02-24T09:44:57.939Z"}
Update actions
Set Key
actionString | "setKey" |
keyString | Value to set. If empty, any existing value will be removed. MinLength:2MaxLength: 256Pattern: ^[A-Za-z0-9_-]+$ |
Change Value
actionString | "changeValue" |
value | New value to set. Must not be empty. |
{"action" : "changeValue","value" : {"type" : "relative","permyriad" : 2000}}
Change Predicate
actionString | "changePredicate" |
predicateString | New value to set. Must be a valid ProductDiscount predicate. |
{"action" : "changePredicate","predicate" : "product.id = \"{{product-id}}\""}
Change Is Active
actionString | "changeIsActive" |
isActiveBoolean | New value to set.
If set to |
{"action" : "changeIsActive","isActive" : false}
Set Valid From
actionString | "setValidFrom" |
validFrom | Value to set. If empty, any existing value will be removed. Take Eventual Consistency into account for calculated discount values. |
{"action" : "setValidFrom","validFrom" : "2018-10-12T14:05:00.000Z"}
Set Valid Until
actionString | "setValidUntil" |
validUntil | Value to set. If empty, any existing value will be removed. Take Eventual Consistency into account for calculated undiscounted values. |
{"action" : "setValidUntil","validUntil" : "2018-10-12T14:05:00.000Z"}
Set Valid From and Until
actionString | "setValidFromAndUntil" |
validFrom | Value to set. Take Eventual Consistency into account for calculated undiscounted values. |
validUntil | Value to set. Take Eventual Consistency into account for calculated undiscounted values. |
{"action" : "setValidFromAndUntil","validFrom" : "2018-10-12T14:00:00.000Z","validUntil" : "2018-10-12T14:05:00.000Z"}
Change Name
actionString | "changeName" |
name | New value to set. Must not be empty. |
{"action" : "changeName","name" : {"de" : "NewProductDiscountDE","en" : "NewProductDiscountEN"}}
Set Description
actionString | "setDescription" |
description | Value to set. If empty, any existing value will be removed. |
{"action" : "setDescription","description" : {"de" : "New Product Discount Description DE","en" : "New Product Discount Description EN"}}
Change Sort Order
actionString | "changeSortOrder" |
sortOrderString | New value to set.
Must not be empty.
The string value must be a number between |
{"action" : "changeSortOrder","sortOrder" : "0.3"}
Delete ProductDiscount
Delete ProductDiscount by ID
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
idString |
|
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/product-discounts/{id}?version={version} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "d7a204f9-7746-4857-b17e-71f1235a691a","version" : 2,"value" : {"type" : "absolute","money" : [ {"type" : "centPrecision","fractionDigits" : 2,"currencyCode" : "EUR","centAmount" : 100} ],"id" : "3544d4a3-1279-443c-8699-4220753bf6f5"},"predicate" : "1=1","name" : {"en" : "test-discount1"},"description" : {"en" : "test-discount1"},"isActive" : false,"sortOrder" : "0.9534","references" : [ ],"createdAt" : "2016-02-24T09:44:57.858Z","lastModifiedAt" : "2016-02-24T09:44:57.939Z"}
Delete ProductDiscount by Key
manage_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
keyString |
|
versionInt | Last seen version of the resource. |
expand | The parameter can be passed multiple times. |
curl -X DELETE https://api.{region}.commercetools.com/{projectKey}/product-discounts/key={key}?version={version} -i \--header 'Authorization: Bearer ${BEARER_TOKEN}'
{"id" : "d7a204f9-7746-4857-b17e-71f1235a691a","version" : 2,"value" : {"type" : "absolute","money" : [ {"type" : "centPrecision","fractionDigits" : 2,"currencyCode" : "EUR","centAmount" : 100} ],"id" : "3544d4a3-1279-443c-8699-4220753bf6f5"},"predicate" : "1=1","name" : {"en" : "test-discount1"},"description" : {"en" : "test-discount1"},"isActive" : false,"sortOrder" : "0.9534","references" : [ ],"createdAt" : "2016-02-24T09:44:57.858Z","lastModifiedAt" : "2016-02-24T09:44:57.939Z"}
Get Matching ProductDiscount
This endpoint can be used to simulate which Product Discounts would be applied if a specified Product Variant had a specified Price. Given Product and Product Variant IDs and a Price, this endpoint will return the ProductDiscount that would have been applied to that Price.
view_products:{projectKey}regionString | Region in which the Project is hosted. |
projectKeyString |
|
productIdString | ID of the specified Product. |
variantIdInt | ID of the specified Product Variant. |
stagedBoolean | Controls which projected representation is applied for the query.
Set to |
price | Specified Price of the specified Product Variant. |
curl -X POST https://api.{region}.commercetools.com/{projectKey}/product-discounts/matching -i \--header 'Authorization: Bearer ${BEARER_TOKEN}' \--header 'Content-Type: application/json' \--data-binary @- << DATA"{n "productId": "123456",n "variantId": 1,n "staged": false,n "price": {n "value": {n "centAmount": 100,n "currencyCode": "EUR"n }n }n}n"DATA
{"id" : "d7a204f9-7746-4857-b17e-71f1235a691a","version" : 2,"value" : {"type" : "absolute","money" : [ {"type" : "centPrecision","fractionDigits" : 2,"currencyCode" : "EUR","centAmount" : 100} ],"id" : "3544d4a3-1279-443c-8699-4220753bf6f5"},"predicate" : "1=1","name" : {"en" : "test-discount1"},"description" : {"en" : "test-discount1"},"isActive" : false,"sortOrder" : "0.9534","references" : [ ],"createdAt" : "2016-02-24T09:44:57.858Z","lastModifiedAt" : "2016-02-24T09:44:57.939Z"}
Specific Error Codes: