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>>;
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
type:
PromotionCondition[]
availableActions
property
type:
PromotionAction[]
constructor
method
type:
(connection: TransactionalConnection, configService: ConfigService, channelService: ChannelService, listQueryBuilder: ListQueryBuilder, configArgService: ConfigArgService, customFieldRelationService: CustomFieldRelationService, eventBus: EventBus, translatableSaver: TranslatableSaver, translator: TranslatorService) => PromotionService
findAll
method
type:
(ctx: RequestContext, options?: ListQueryOptions<Promotion>, relations: RelationPaths<Promotion> = []) => Promise<PaginatedList<Promotion>>
findOne
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
method
type:
(ctx: RequestContext, input: CreatePromotionInput) => Promise<ErrorResultUnion<CreatePromotionResult, Promotion>>
updatePromotion
method
type:
(ctx: RequestContext, input: UpdatePromotionInput) => Promise<ErrorResultUnion<UpdatePromotionResult, Promotion>>
softDeletePromotion
method
type:
(ctx: RequestContext, promotionId: ID) => Promise<DeletionResponse>
assignPromotionsToChannel
method
type:
(ctx: RequestContext, input: AssignPromotionsToChannelInput) => Promise<Promotion[]>
removePromotionsFromChannel
method
type:
(ctx: RequestContext, input: RemovePromotionsFromChannelInput) =>
validateCouponCode
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
method
type:
(ctx: RequestContext, orderId: ID) => Promise<Promotion[]>
runPromotionSideEffects
method
type:
(ctx: RequestContext, order: Order, promotionsPre: Promotion[]) =>
addPromotionsToOrder
method
type:
(ctx: RequestContext, order: Order) => Promise<Order>
Used internally to associate a Promotion with an Order, once an Order has been placed.