Promotion Condition

promotion-condition

PromotionUtils

An object containing utility methods which may be used in promotion check functions in order to determine whether a promotion should be applied.

TODO: Remove this and use the new init() method to inject providers where needed.

Signature

interface PromotionUtils {
  hasFacetValues: (orderLine: OrderLine, facetValueIds: ID[]) => Promise<boolean>;
}

Members

hasFacetValues

property
type:
(orderLine: OrderLine, facetValueIds: ID[]) => Promise<boolean>
Checks a given OrderLine against the facetValueIds and returns true if the associated ProductVariant & Product together have all the specified FacetValues.

CheckPromotionConditionFn

A function which checks whether or not a given Order satisfies the PromotionCondition.

Signature

type CheckPromotionConditionFn<T extends PromotionConditionArgs> = (
    order: Order,
    args: ConfigArgValues<T>,
    utils: PromotionUtils,
) => boolean | Promise<boolean>

PromotionCondition

PromotionConditions are used to create Promotions. The purpose of a PromotionCondition is to check the order against a particular predicate function (the check function) and to return true if the Order satisfies the condition, or false if it does not.

Signature

class PromotionCondition<T extends PromotionConditionArgs = {}> extends ConfigurableOperationDef<T> {
  readonly readonly priorityValue: number;
  constructor(config: PromotionConditionConfig<T>)
  async check(order: Order, args: ConfigArg[], utils: PromotionUtils) => Promise<boolean>;
}

Extends

Members

priorityValue

readonly property
type:
number

constructor

method
type:
(config: PromotionConditionConfig<T>) => PromotionCondition

check

async method
type:
(order: Order, args: ConfigArg[], utils: PromotionUtils) => Promise<boolean>