promotion-condition
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 ConfigArgs = ConfigArgs> extends ConfigurableOperationDef<T> {
readonly readonly priorityValue: number;
constructor(config: PromotionConditionConfig<T>)
async check(ctx: RequestContext, order: Order, args: ConfigArg[]) => Promise<boolean>;
}
Extends
Members
priorityValue
readonly property
type:
number
default:
0
Used to determine the order of application of multiple Promotions
on the same Order. See the Promotion
priorityScore
field for
more information.
constructor
method
type:
(config: PromotionConditionConfig<T>) => PromotionCondition
check
async method
type:
(ctx: RequestContext, order: Order, args: ConfigArg[]) => Promise<boolean>
PromotionConditionConfig
This object is used to configure a PromotionCondition.
Signature
interface PromotionConditionConfig<T extends ConfigArgs> extends ConfigurableOperationDefOptions<T> {
check: CheckPromotionConditionFn<T>;
priorityValue?: number;
}
Extends
Members
check
property
type:
CheckPromotionConditionFn<T>
priorityValue
property
type:
number
CheckPromotionConditionFn
A function which checks whether or not a given Order satisfies the PromotionCondition.
Signature
type CheckPromotionConditionFn<T extends ConfigArgs> = (
ctx: RequestContext,
order: Order,
args: ConfigArgValues<T>,
) => boolean | Promise<boolean>