Skip to main content

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, translatableSaver: TranslatableSaver, translator: TranslatorService)
findAll(ctx: RequestContext, options?: ListQueryOptions<Promotion>, relations: RelationPaths<Promotion> = []) => Promise<PaginatedList<Promotion>>;
findOne(ctx: RequestContext, adjustmentSourceId: ID, relations: RelationPaths<Promotion> = []) => Promise<Promotion | undefined>;
getPromotionConditions(ctx: RequestContext) => ConfigurableOperationDefinition[];
getPromotionActions(ctx: RequestContext) => ConfigurableOperationDefinition[];
createPromotion(ctx: RequestContext, input: CreatePromotionInput) => Promise<ErrorResultUnion<CreatePromotionResult, Promotion>>;
updatePromotion(ctx: RequestContext, input: UpdatePromotionInput) => Promise<ErrorResultUnion<UpdatePromotionResult, Promotion>>;
softDeletePromotion(ctx: RequestContext, promotionId: ID) => Promise<DeletionResponse>;
assignPromotionsToChannel(ctx: RequestContext, input: AssignPromotionsToChannelInput) => Promise<Promotion[]>;
removePromotionsFromChannel(ctx: RequestContext, input: RemovePromotionsFromChannelInput) => ;
validateCouponCode(ctx: RequestContext, couponCode: string, customerId?: ID) => Promise<JustErrorResults<ApplyCouponCodeResult> | Promotion>;
getActivePromotionsInChannel(ctx: RequestContext) => ;
getActivePromotionsOnOrder(ctx: RequestContext, orderId: ID) => Promise<Promotion[]>;
runPromotionSideEffects(ctx: RequestContext, order: Order, promotionsPre: Promotion[]) => ;
addPromotionsToOrder(ctx: RequestContext, order: Order) => Promise<Order>;
}

availableConditions

availableActions

property

constructor

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

findAll

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

findOne

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

getPromotionConditions

method
(ctx: RequestContext) => ConfigurableOperationDefinition[]

getPromotionActions

method
(ctx: RequestContext) => ConfigurableOperationDefinition[]

createPromotion

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

updatePromotion

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

softDeletePromotion

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

assignPromotionsToChannel

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

removePromotionsFromChannel

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

validateCouponCode

method
(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
(ctx: RequestContext) =>

getActivePromotionsOnOrder

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

runPromotionSideEffects

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

addPromotionsToOrder

method
(ctx: RequestContext, order: Order) => Promise<Order>

Used internally to associate a Promotion with an Order, once an Order has been placed.