Skip to main content
Skip to main content

DiscountConditionService

Provides layer to manipulate discount conditions.

Implements

Constructors

constructor

**new DiscountConditionService**(«destructured»)

Parameters

__namedParametersInjectedDependenciesRequired

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
discountConditionRepository_Repository<DiscountCondition> & { addConditionResources: Method addConditionResources ; canApplyForCustomer: Method canApplyForCustomer ; findOneWithDiscount: Method findOneWithDiscount ; getJoinTableResourceIdentifiers: Method getJoinTableResourceIdentifiers ; isValidForProduct: Method isValidForProduct ; queryConditionTable: Method queryConditionTable ; removeConditionResources: Method removeConditionResources }Required
eventBus_EventBusServiceRequired
manager_EntityManagerRequired
transactionManager_undefined | EntityManagerRequired

Accessors

activeManager_

Protected get**activeManager_**(): EntityManager

Returns

EntityManager

EntityManagerEntityManagerRequired

Methods

atomicPhase_

Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise&#60;TResult&#62;

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.

TResultobjectRequired
TErrorobjectRequired

Parameters

work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (error: TError) => Promise<void | TResult>
the isolation level to be used for the work.
maybeErrorHandlerOrDontFail(error: TError) => Promise<void | TResult>
Potential error handler

Returns

Promise<TResult>

PromisePromise<TResult>Required
the result of the transactional work

delete

**delete**(discountConditionId): Promise&#60;void \| [DiscountCondition](/references/services/classes/DiscountCondition)&#62;

Parameters

discountConditionIdstringRequired

Returns

Promise<void | DiscountCondition>

PromisePromise<void | DiscountCondition>Required

removeResources

**removeResources**(data): Promise&#60;void&#62;

Parameters

dataOmit<DiscountConditionInput, "id"> & { id: string }Required

Returns

Promise<void>

PromisePromise<void>Required

retrieve

**retrieve**(conditionId, config?): Promise&#60;[DiscountCondition](/references/services/classes/DiscountCondition)&#62;

Parameters

conditionIdstringRequired

Returns

Promise<DiscountCondition>

PromisePromise<DiscountCondition>Required

shouldRetryTransaction_

Protected **shouldRetryTransaction_**(err): boolean

Parameters

errRecord<string, unknown> | { code: string }Required

Returns

boolean

booleanboolean

upsertCondition

**upsertCondition**(data, overrideExisting?): Promise&#60;([DiscountConditionProduct](/references/services/classes/DiscountConditionProduct) \| [DiscountConditionProductType](/references/services/classes/DiscountConditionProductType) \| [DiscountConditionProductCollection](/references/services/classes/DiscountConditionProductCollection) \| [DiscountConditionProductTag](/references/services/classes/DiscountConditionProductTag) \| [DiscountConditionCustomerGroup](/references/services/classes/DiscountConditionCustomerGroup))[]&#62;

Parameters

overrideExistingbooleanRequired

Default: true

Returns

Promise<(DiscountConditionProduct | DiscountConditionProductType | DiscountConditionProductCollection | DiscountConditionProductTag | DiscountConditionCustomerGroup)[]>


withTransaction

**withTransaction**(transactionManager?): [DiscountConditionService](/references/services/classes/DiscountConditionService)

Parameters

transactionManagerEntityManager

Returns

DiscountConditionService

DiscountConditionServiceDiscountConditionServiceRequired

resolveConditionType_

Static Protected **resolveConditionType_**(data): undefined \| &#123; resource_ids: (string \| &#123; id: string &#125;)[] ; type: [DiscountConditionType](/references/services/enums/DiscountConditionType) &#125;

Parameters

Returns

undefined | { resource_ids: (string \| &#123; id: string &#125;)[] ; type: [DiscountConditionType](/references/services/enums/DiscountConditionType) }

undefined \| &#123; resource_ids: (string \| &#123; id: string &#125;)[] ; type: DiscountConditionType &#125;undefined | { resource_ids: (string \| &#123; id: string &#125;)[] ; type: [DiscountConditionType](/references/services/enums/DiscountConditionType) }
Was this section helpful?