PromotionItemAction

PromotionItemAction

Documentation generated from promotion-action.ts on Feb 19 2019 at 16:20

Represents a PromotionAction which applies to individual OrderItems.

Example

// Applies a percentage discount to each OrderItem
const itemPercentageDiscount = new PromotionItemAction({
    code: 'item_percentage_discount',
    args: { discount: 'percentage' },
    execute(orderItem, orderLine, args) {
        return -orderLine.unitPrice * (args.discount / 100);
    },
    description: 'Discount every item by { discount }%',
});

Signature

class PromotionItemAction<T extends PromotionActionArgs = {}> {
  constructor(config: PromotionItemActionConfig<T>)
  execute(orderItem: OrderItem, orderLine: OrderLine, args: ConfigArg[], utils: PromotionUtils) => ;
}

Members

constructor

method
type:
(config: PromotionItemActionConfig<T>) => PromotionItemAction

execute

method
type:
(orderItem: OrderItem, orderLine: OrderLine, args: ConfigArg[], utils: PromotionUtils) =>
alpha