PromotionItemAction

PromotionItemAction

PromotionItemAction

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 = {}> extends PromotionAction<T> {
  constructor(config: PromotionItemActionConfig<T>)
}

Members

constructor

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