Promotion Action
An abstract class which is extended by PromotionItemAction, PromotionOrderAction, and PromotionShippingAction.
- Extends:
ConfigurableOperationDef<T>
priorityValue
number0Used to determine the order of application of multiple Promotions
on the same Order. See the Promotion priorityScore field for
more information.
constructor
(config: PromotionActionConfig<T, U>) => PromotionActionRepresents a PromotionAction which applies to individual OrderLines.
Example
- Extends:
PromotionAction<T, U>
constructor
(config: PromotionItemActionConfig<T, U>) => PromotionItemActionRepresents a PromotionAction which applies to the Order as a whole.
Example
- Extends:
PromotionAction<T, U>
constructor
(config: PromotionOrderActionConfig<T, U>) => PromotionOrderActionRepresents a PromotionAction which applies to the shipping cost of an Order.
- Extends:
PromotionAction<T, U>
constructor
(config: PromotionShippingActionConfig<T, U>) => PromotionShippingActionThe function which is used by a PromotionItemAction to calculate the discount on the OrderLine for each item.
The function which is used by a PromotionLineAction to calculate the discount on the OrderLine.
The function which is used by a PromotionOrderAction to calculate the discount on the Order.
The function which is used by a PromotionOrderAction to calculate the discount on the Order.
The signature of a PromotionAction's side-effect functions onActivate and onDeactivate.
Configuration for all types of PromotionAction.
- Extends:
ConfigurableOperationDefOptions<T>
priorityValue
number0Used to determine the order of application of multiple Promotions
on the same Order. See the Promotion priorityScore field for
more information.
conditions
U extends undefined ? undefined : ConditionTuple<Exclude<U, undefined>>Allows PromotionActions to define one or more PromotionConditions as dependencies. Having a PromotionCondition as a dependency has the following consequences:
- A Promotion using this PromotionAction is only valid if it also contains all PromotionConditions on which it depends.
- The
execute()function will receive a statically-typedstateargument which will contain the return values of the PromotionConditions'check()function.
onActivate
An optional side effect function which is invoked when the promotion becomes active. It can be used for things like adding a free gift to the order or other side effects that are unrelated to price calculations.
If used, make sure to use the corresponding onDeactivate function to clean up
or reverse any side effects as needed.
onDeactivate
Used to reverse or clean up any side effects executed as part of the onActivate function.
Configuration for a PromotionItemAction
- Extends:
PromotionActionConfig<T, U>
execute
ExecutePromotionItemActionFn<T, U>The function which contains the promotion calculation logic. Should resolve to a number which represents the amount by which to discount the OrderLine, i.e. the number should be negative.
Configuration for a PromotionLineAction
- Extends:
PromotionActionConfig<T, U>
execute
ExecutePromotionLineActionFn<T, U>The function which contains the promotion calculation logic. Should resolve to a number which represents the amount by which to discount the OrderLine, i.e. the number should be negative.
- Extends:
PromotionActionConfig<T, U>
execute
ExecutePromotionOrderActionFn<T, U>The function which contains the promotion calculation logic. Should resolve to a number which represents the amount by which to discount the Order, i.e. the number should be negative.
- Extends:
PromotionActionConfig<T, U>
execute
ExecutePromotionShippingActionFn<T, U>The function which contains the promotion calculation logic. Should resolve to a number which represents the amount by which to discount the Shipping, i.e. the number should be negative.
Represents a PromotionAction which applies to individual OrderLines. The difference from PromotionItemAction is that it applies regardless of the Quantity of the OrderLine.
Example
- Extends:
PromotionAction<T, U>
constructor
(config: PromotionLineActionConfig<T, U>) => PromotionLineAction