DiscountService
Provides layer to manipulate discounts.
Implements
constructor
Parameters
__namedParameters
objectRequired__namedParameters.discountRepository
anyRequired__namedParameters.discountRuleRepository
anyRequired__namedParameters.giftCardRepository
anyRequired__namedParameters.discountConditionRepository
anyRequired__namedParameters.discountConditionService
anyRequired__namedParameters.totalsService
anyRequired__namedParameters.newTotalsService
anyRequired__namedParameters.productService
anyRequired__namedParameters.regionService
anyRequired__namedParameters.customerService
anyRequired__namedParameters.eventBusService
anyRequired__namedParameters.featureFlagRouter
anyRequiredProperties
manager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequired__container__
anyRequiredEvents
objectRequiredEvents.CREATED
stringRequiredDefault: "discount.created"
featureFlagRouter_
FlagRouterRequired__configModule__
Record<string, unknown>__moduleDeclaration__
Record<string, unknown>Accessors
activeManager_
Returns
EntityManager
EntityManagerRequiredMethods
withTransaction
Parameters
transactionManager
EntityManagerReturns
this
thisRequiredshouldRetryTransaction_
Parameters
err
Record<string, unknown> | objectRequiredReturns
boolean
booleanRequiredatomicPhase_
Wraps some work within a transactional block. If the service already has a transaction manager attached this will be reused, otherwise a new transaction manager is created.
Type Parameters
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise
Promise<TResult>RequiredvalidateDiscountRule_
Creates a discount rule with provided data given that the data is validated.
Type Parameters
T
objectRequiredParameters
discountRule
TRequiredReturns
T
TRequiredlist
Parameters
selector
FilterableDiscountPropsRequiredDefault: {}
Returns
listAndCount
Parameters
selector
FilterableDiscountPropsRequiredDefault: {}
Returns
create
Creates a discount with provided data given that the data is validated. Normalizes discount code to uppercase.
Parameters
discount
CreateDiscountInputRequiredReturns
retrieve
Gets a discount by id.
Parameters
discountId
stringRequiredDefault: {}
Returns
retrieveByCode
Gets the discount by discount code.
Parameters
discountCode
stringRequiredDefault: {}
Returns
listByCodes
List all the discounts corresponding to the given codes
Parameters
discountCodes
string[]RequiredDefault: {}
Returns
update
Updates a discount.
Parameters
discountId
stringRequiredupdate
UpdateDiscountInputRequiredReturns
createDynamicCode
Creates a dynamic code for a discount id.
Parameters
discountId
stringRequireddata
CreateDynamicDiscountInputRequiredReturns
deleteDynamicCode
Deletes a dynamic code for a discount id.
Parameters
discountId
stringRequiredcode
stringRequiredReturns
Promise
Promise<void>RequiredaddRegion
Adds a region to the discount regions array.
Parameters
discountId
stringRequiredregionId
stringRequiredReturns
removeRegion
Removes a region from the discount regions array.
Parameters
discountId
stringRequiredregionId
stringRequiredReturns
delete
Deletes a discount idempotently
Parameters
discountId
stringRequiredReturns
Promise
Promise<void>RequiredvalidateDiscountForProduct
Parameters
discountRuleId
stringRequiredproductId
stringReturns
Promise
Promise<boolean>RequiredcalculateDiscountForLineItem
Parameters
discountId
stringRequiredcalculationContextData
CalculationContextDataRequiredReturns
Promise
Promise<number>RequiredvalidateDiscountForCartOrThrow
Parameters
Returns
Promise
Promise<void>RequiredhasCustomersGroupCondition
Parameters
Returns
boolean
booleanRequiredhasReachedLimit
Parameters
Returns
boolean
booleanRequiredhasNotStarted
Parameters
Returns
boolean
booleanRequiredhasExpired
Parameters
Returns
boolean
booleanRequiredisDisabled
Parameters
Returns
boolean
booleanRequiredisValidForRegion
Parameters
region_id
stringRequiredReturns
Promise
Promise<boolean>RequiredcanApplyForCustomer
Parameters
discountRuleId
stringRequiredcustomerId
undefined | stringRequiredReturns
Promise
Promise<boolean>Required