17 December 2024
Composable Commerce
HTTP API
Enhancement
Pricing and DiscountsAudit LogGraphQL

We've introduced a new target for Cart Discounts, CartDiscountPatternTarget, in public beta. This enhancement provides greater flexibility and control over discount configurations when setting up multi-purchase promotions, such as Buy One, Get One (BOGO), compared to Multibuy Discount target. Previously, with Multibuy discount target, you could only create a percentage-off discount and you could not repeat the discounts and apply them in the same order.

Changes:

The following changes were introduced in terms of GraphQL SDL:

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
type CartDiscountPatternTarget implements CartDiscountTarget {
  triggerPattern: [PatternComponent!]!
  targetPattern: [PatternComponent!]!
  maxOccurrence: Int
  selectionMode: SelectionMode!
  type: String!
}

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
input CartDiscountPatternTargetInput {
  triggerPattern: [PatternComponentInput!]!
  targetPattern: [PatternComponentInput!]!
  maxOccurrence: Int
  selectionMode: SelectionMode
}

extend input CartDiscountTargetInput {
  "BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
  pattern: CartDiscountPatternTargetInput
}

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
type CountOnCustomLineItemUnits implements PatternComponent {
  predicate: String!
  minCount: Int
  maxCount: Int
  excludeCount: Int
  type: String!
}

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
input CountOnCustomLineItemUnitsInput @ignoreDraftConventionValidation {
  predicate: String!
  minCount: Int = 1
  maxCount: Int
  excludeCount: Int
}

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
type CountOnLineItemUnits implements PatternComponent {
  predicate: String!
  minCount: Int
  maxCount: Int
  excludeCount: Int
  type: String!
}

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
input CountOnLineItemUnitsInput @ignoreDraftConventionValidation {
  predicate: String!
  minCount: Int = 1
  maxCount: Int
  excludeCount: Int
}

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
interface PatternComponent {
  type: String!
}

"BETA: This feature can be subject to change and should be used carefully in production. https://docs.commercetools.com/api/contract#public-beta"
input PatternComponentInput {
  CountOnLineItemUnits: CountOnLineItemUnitsInput
  CountOnCustomLineItemUnits: CountOnCustomLineItemUnitsInput
}

extend input CartDiscountValueInput {
  fixedCart: FixedPriceCartDiscountValueInput
}

type FixedPriceCartDiscountValue implements CartDiscountValue {
  type: String!
  money: [BaseMoney!]!
  applicationMode: DiscountApplicationMode!
}

input FixedPriceCartDiscountValueInput {
  money: [CartDiscountValueBaseMoneyInput!]!
  applicationMode: DiscountApplicationMode!
}