Promotion

Promotion

Promotion

A Promotion is used to define a set of conditions under which promotions actions (typically discounts) will be applied to an Order.

Each assigned PromotionCondition is checked against the Order, and if they all return true, then each assign PromotionItemAction / PromotionOrderAction is applied to the Order.

Signature

class Promotion extends AdjustmentSource implements ChannelAware, SoftDeletable {
  type = AdjustmentType.PROMOTION;
  constructor(input?: DeepPartial<Promotion> & {
            promotionConditions?: Array<PromotionCondition<any>>;
            promotionActions?: Array<PromotionAction<any>>;
        })
  @Column({ type: Date, nullable: true, default: null })
    deletedAt: Date | null;
  @Column() name: string;
  @Column() enabled: boolean;
  @ManyToMany(type => Channel)
    @JoinTable()
    channels: Channel[];
  @Column('simple-json') conditions: ConfigurableOperation[];
  @Column('simple-json') actions: ConfigurableOperation[];
  @Column() priorityScore: number;
  async apply(args: ApplyOrderActionArgs | ApplyOrderItemActionArgs) => Promise<Adjustment | undefined>;
  async test(order: Order, utils: PromotionUtils) => Promise<boolean>;
}

Members

type

property
type:

constructor

method
type:
(input?: DeepPartial<Promotion> & { promotionConditions?: Array<PromotionCondition<any>>; promotionActions?: Array<PromotionAction<any>>; }) => Promotion

deletedAt

property
type:
Date | null

name

property
type:
string

enabled

property
type:
boolean

channels

property
type:
Channel[]

conditions

property
type:
ConfigurableOperation[]

actions

property
type:
ConfigurableOperation[]

priorityScore

property
type:
number

apply

async method
type:
(args: ApplyOrderActionArgs | ApplyOrderItemActionArgs) => Promise<Adjustment | undefined>

test

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