🚨 Announcing Vendure v2 Beta

PromotionService

PromotionService

Contains methods relating to Promotion entities.

Signature

class PromotionService {
  availableConditions: PromotionCondition[] = [];
  availableActions: PromotionAction[] = [];
  constructor(connection: TransactionalConnection, configService: ConfigService, channelService: ChannelService, listQueryBuilder: ListQueryBuilder, configArgService: ConfigArgService, customFieldRelationService: CustomFieldRelationService, eventBus: EventBus)
  findAll(ctx: RequestContext, options?: ListQueryOptions<Promotion>, relations: RelationPaths<Promotion> = []) => Promise<PaginatedList<Promotion>>;
  async findOne(ctx: RequestContext, adjustmentSourceId: ID, relations: RelationPaths<Promotion> = []) => Promise<Promotion | undefined>;
  getPromotionConditions(ctx: RequestContext) => ConfigurableOperationDefinition[];
  getPromotionActions(ctx: RequestContext) => ConfigurableOperationDefinition[];
  async createPromotion(ctx: RequestContext, input: CreatePromotionInput) => Promise<ErrorResultUnion<CreatePromotionResult, Promotion>>;
  async updatePromotion(ctx: RequestContext, input: UpdatePromotionInput) => Promise<ErrorResultUnion<UpdatePromotionResult, Promotion>>;
  async softDeletePromotion(ctx: RequestContext, promotionId: ID) => Promise<DeletionResponse>;
  async assignPromotionsToChannel(ctx: RequestContext, input: AssignPromotionsToChannelInput) => Promise<Promotion[]>;
  async removePromotionsFromChannel(ctx: RequestContext, input: RemovePromotionsFromChannelInput) => ;
  async validateCouponCode(ctx: RequestContext, couponCode: string, customerId?: ID) => Promise<JustErrorResults<ApplyCouponCodeResult> | Promotion>;
  getActivePromotionsInChannel(ctx: RequestContext) => ;
  async getActivePromotionsOnOrder(ctx: RequestContext, orderId: ID) => Promise<Promotion[]>;
  async runPromotionSideEffects(ctx: RequestContext, order: Order, promotionsPre: Promotion[]) => ;
  async addPromotionsToOrder(ctx: RequestContext, order: Order) => Promise<Order>;
}

Members

availableConditions

property

availableActions

property
type:
PromotionAction[]

constructor

method
type:
(connection: TransactionalConnection, configService: ConfigService, channelService: ChannelService, listQueryBuilder: ListQueryBuilder, configArgService: ConfigArgService, customFieldRelationService: CustomFieldRelationService, eventBus: EventBus) => PromotionService

findAll

method
type:
(ctx: RequestContext, options?: ListQueryOptions<Promotion>, relations: RelationPaths<Promotion> = []) => Promise<PaginatedList<Promotion>>

findOne

async method
type:
(ctx: RequestContext, adjustmentSourceId: ID, relations: RelationPaths<Promotion> = []) => Promise<Promotion | undefined>

getPromotionConditions

method
type:
(ctx: RequestContext) => ConfigurableOperationDefinition[]

getPromotionActions

method
type:
(ctx: RequestContext) => ConfigurableOperationDefinition[]

createPromotion

async method
type:
(ctx: RequestContext, input: CreatePromotionInput) => Promise<ErrorResultUnion<CreatePromotionResult, Promotion>>

updatePromotion

async method
type:
(ctx: RequestContext, input: UpdatePromotionInput) => Promise<ErrorResultUnion<UpdatePromotionResult, Promotion>>

softDeletePromotion

async method
type:
(ctx: RequestContext, promotionId: ID) => Promise<DeletionResponse>

assignPromotionsToChannel

async method
type:
(ctx: RequestContext, input: AssignPromotionsToChannelInput) => Promise<Promotion[]>

removePromotionsFromChannel

async method
type:
(ctx: RequestContext, input: RemovePromotionsFromChannelInput) =>

validateCouponCode

async method
type:
(ctx: RequestContext, couponCode: string, customerId?: ID) => Promise<JustErrorResults<ApplyCouponCodeResult> | Promotion>
Checks the validity of a coupon code, by checking that it is associated with an existing, enabled and non-expired Promotion. Additionally, if there is a usage limit on the coupon code, this method will enforce that limit against the specified Customer.

getActivePromotionsInChannel

method
type:
(ctx: RequestContext) =>

getActivePromotionsOnOrder

async method
type:
(ctx: RequestContext, orderId: ID) => Promise<Promotion[]>

runPromotionSideEffects

async method
type:
(ctx: RequestContext, order: Order, promotionsPre: Promotion[]) =>

addPromotionsToOrder

async method
type:
(ctx: RequestContext, order: Order) => Promise<Order>
Used internally to associate a Promotion with an Order, once an Order has been placed.