Class: LineItemAdjustmentService
Provides layer to manipulate line item adjustments.
Hierarchy
TransactionBaseService
Copy to Clipboard↳
LineItemAdjustmentService
Copy to Clipboard
Constructors
constructor
• new LineItemAdjustmentService(__namedParameters
Copy to Clipboard)
Parameters
Name | Type |
---|---|
__namedParameters Copy to Clipboard | LineItemAdjustmentServiceProps Copy to Clipboard |
Overrides
TransactionBaseService.constructor
Defined in
packages/medusa/src/services/line-item-adjustment.ts:39
Properties
__configModule__
• Protected
Copy to Clipboard Optional
Copy to Clipboard Readonly
Copy to Clipboard __configModule__: Record
Copy to Clipboard<string
Copy to Clipboard, unknown
Copy to Clipboard>
Inherited from
TransactionBaseService.__configModule__
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:10
__container__
• Protected
Copy to Clipboard Readonly
Copy to Clipboard __container__: any
Copy to Clipboard
Inherited from
TransactionBaseService.__container__
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:9
__moduleDeclaration__
• Protected
Copy to Clipboard Optional
Copy to Clipboard Readonly
Copy to Clipboard __moduleDeclaration__: Record
Copy to Clipboard<string
Copy to Clipboard, unknown
Copy to Clipboard>
Inherited from
TransactionBaseService.__moduleDeclaration__
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:11
discountService
• Private
Copy to Clipboard Readonly
Copy to Clipboard discountService: DiscountService
Copy to Clipboard
Defined in
packages/medusa/src/services/line-item-adjustment.ts:37
lineItemAdjustmentRepo_
• Private
Copy to Clipboard Readonly
Copy to Clipboard lineItemAdjustmentRepo_: typeof LineItemAdjustmentRepository
Copy to Clipboard
Defined in
packages/medusa/src/services/line-item-adjustment.ts:36
manager_
• Protected
Copy to Clipboard Readonly
Copy to Clipboard manager_: EntityManager
Copy to Clipboard
Overrides
TransactionBaseService.manager_
Defined in
packages/medusa/src/services/line-item-adjustment.ts:33
transactionManager_
• Protected
Copy to Clipboard transactionManager_: undefined
Copy to Clipboard | EntityManager
Copy to Clipboard
Overrides
TransactionBaseService.transactionManager_
Defined in
packages/medusa/src/services/line-item-adjustment.ts:34
Methods
atomicPhase_
▸ Protected
Copy to Clipboard atomicPhase_<TResult
Copy to Clipboard, TError
Copy to Clipboard>(work
Copy to Clipboard, isolationOrErrorHandler?
Copy to Clipboard, maybeErrorHandlerOrDontFail?
Copy to Clipboard): Promise
Copy to Clipboard<TResult
Copy to Clipboard>
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
Name |
---|
TResult Copy to Clipboard |
TError Copy to Clipboard |
Parameters
Name | Type | Description |
---|---|---|
work Copy to Clipboard | (transactionManager Copy to Clipboard: EntityManager Copy to Clipboard) => Promise Copy to Clipboard<TResult Copy to Clipboard> | the transactional work to be done |
isolationOrErrorHandler? Copy to Clipboard | IsolationLevel Copy to Clipboard | (error Copy to Clipboard: TError Copy to Clipboard) => Promise Copy to Clipboard<void Copy to Clipboard | TResult Copy to Clipboard> | the isolation level to be used for the work. |
maybeErrorHandlerOrDontFail? Copy to Clipboard | (error Copy to Clipboard: TError Copy to Clipboard) => Promise Copy to Clipboard<void Copy to Clipboard | TResult Copy to Clipboard> | Potential error handler |
Returns
Promise
Copy to Clipboard<TResult
Copy to Clipboard>
the result of the transactional work
Inherited from
TransactionBaseService.atomicPhase_
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:50
create
▸ create(data
Copy to Clipboard): Promise
Copy to Clipboard<LineItemAdjustment
Copy to Clipboard>
Creates a line item adjustment
Parameters
Name | Type | Description |
---|---|---|
data Copy to Clipboard | Partial Copy to Clipboard<LineItemAdjustment Copy to Clipboard> | the line item adjustment to create |
Returns
Promise
Copy to Clipboard<LineItemAdjustment
Copy to Clipboard>
line item adjustment
Defined in
packages/medusa/src/services/line-item-adjustment.ts:90
createAdjustmentForLineItem
▸ createAdjustmentForLineItem(cart
Copy to Clipboard, lineItem
Copy to Clipboard): Promise
Copy to Clipboard<LineItemAdjustment
Copy to Clipboard[]>
Creates adjustment for a line item
Parameters
Name | Type | Description |
---|---|---|
cart Copy to Clipboard | Cart Copy to Clipboard | the cart object holding discounts |
lineItem Copy to Clipboard | LineItem Copy to Clipboard | the line item for which a line item adjustment might be created |
Returns
Promise
Copy to Clipboard<LineItemAdjustment
Copy to Clipboard[]>
a line item adjustment or undefined if no adjustment was created
Defined in
packages/medusa/src/services/line-item-adjustment.ts:263
createAdjustments
▸ createAdjustments(cart
Copy to Clipboard, lineItem?
Copy to Clipboard): Promise
Copy to Clipboard<LineItemAdjustment
Copy to Clipboard[] | LineItemAdjustment
Copy to Clipboard[][]>
Creates adjustment for a line item
Parameters
Name | Type | Description |
---|---|---|
cart Copy to Clipboard | Cart Copy to Clipboard | the cart object holding discounts |
lineItem? Copy to Clipboard | LineItem Copy to Clipboard | the line item for which a line item adjustment might be created |
Returns
Promise
Copy to Clipboard<LineItemAdjustment
Copy to Clipboard[] | LineItemAdjustment
Copy to Clipboard[][]>
if a lineItem was given, returns a line item adjustment or undefined if no adjustment was created otherwise returns an array of line item adjustments for each line item in the cart
Defined in
packages/medusa/src/services/line-item-adjustment.ts:291
delete
▸ delete(selectorOrIds
Copy to Clipboard): Promise
Copy to Clipboard<void
Copy to Clipboard>
Deletes line item adjustments matching a selector
Parameters
Name | Type | Description |
---|---|---|
selectorOrIds Copy to Clipboard | string Copy to Clipboard | string Copy to Clipboard[] | FilterableLineItemAdjustmentProps Copy to Clipboard & { discount_id? Copy to Clipboard: FindOperator Copy to Clipboard<null Copy to Clipboard | string Copy to Clipboard> } | the query object for find or the line item adjustment id |
Returns
Promise
Copy to Clipboard<void
Copy to Clipboard>
the result of the delete operation
Defined in
packages/medusa/src/services/line-item-adjustment.ts:155
generateAdjustments
▸ generateAdjustments(calculationContextData
Copy to Clipboard, generatedLineItem
Copy to Clipboard, context
Copy to Clipboard): Promise
Copy to Clipboard<GeneratedAdjustment
Copy to Clipboard[]>
Creates adjustment for a line item
Parameters
Name | Type | Description |
---|---|---|
calculationContextData Copy to Clipboard | CalculationContextData Copy to Clipboard | the calculationContextData object holding discounts |
generatedLineItem Copy to Clipboard | LineItem Copy to Clipboard | the line item for which a line item adjustment might be created |
context Copy to Clipboard | AdjustmentContext Copy to Clipboard | the line item for which a line item adjustment might be created |
Returns
Promise
Copy to Clipboard<GeneratedAdjustment
Copy to Clipboard[]>
a line item adjustment or undefined if no adjustment was created
Defined in
packages/medusa/src/services/line-item-adjustment.ts:189
list
▸ list(selector?
Copy to Clipboard, config?
Copy to Clipboard): Promise
Copy to Clipboard<LineItemAdjustment
Copy to Clipboard[]>
Lists line item adjustments
Parameters
Name | Type | Description |
---|---|---|
selector Copy to Clipboard | FilterableLineItemAdjustmentProps Copy to Clipboard | the query object for find |
config Copy to Clipboard | FindConfig Copy to Clipboard<LineItemAdjustment Copy to Clipboard> | the config to be used for find |
Returns
Promise
Copy to Clipboard<LineItemAdjustment
Copy to Clipboard[]>
the result of the find operation
Defined in
packages/medusa/src/services/line-item-adjustment.ts:138
retrieve
▸ retrieve(lineItemAdjustmentId
Copy to Clipboard, config?
Copy to Clipboard): Promise
Copy to Clipboard<LineItemAdjustment
Copy to Clipboard>
Retrieves a line item adjustment by id.
Parameters
Name | Type | Description |
---|---|---|
lineItemAdjustmentId Copy to Clipboard | string Copy to Clipboard | the id of the line item adjustment to retrieve |
config Copy to Clipboard | FindConfig Copy to Clipboard<LineItemAdjustment Copy to Clipboard> | the config to retrieve the line item adjustment by |
Returns
Promise
Copy to Clipboard<LineItemAdjustment
Copy to Clipboard>
the line item adjustment.
Defined in
packages/medusa/src/services/line-item-adjustment.ts:58
shouldRetryTransaction_
▸ Protected
Copy to Clipboard shouldRetryTransaction_(err
Copy to Clipboard): boolean
Copy to Clipboard
Parameters
Name | Type |
---|---|
err Copy to Clipboard | Record Copy to Clipboard<string Copy to Clipboard, unknown Copy to Clipboard> | { code Copy to Clipboard: string Copy to Clipboard } |
Returns
boolean
Copy to Clipboard
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:31
update
▸ update(id
Copy to Clipboard, data
Copy to Clipboard): Promise
Copy to Clipboard<LineItemAdjustment
Copy to Clipboard>
Creates a line item adjustment
Parameters
Name | Type | Description |
---|---|---|
id Copy to Clipboard | string Copy to Clipboard | the line item adjustment id to update |
data Copy to Clipboard | Partial Copy to Clipboard<LineItemAdjustment Copy to Clipboard> | the line item adjustment to create |
Returns
Promise
Copy to Clipboard<LineItemAdjustment
Copy to Clipboard>
line item adjustment
Defined in
packages/medusa/src/services/line-item-adjustment.ts:107
withTransaction
▸ withTransaction(transactionManager?
Copy to Clipboard): LineItemAdjustmentService
Copy to Clipboard
Parameters
Name | Type |
---|---|
transactionManager? Copy to Clipboard | EntityManager Copy to Clipboard |
Returns
LineItemAdjustmentService
Copy to Clipboard
Inherited from
TransactionBaseService.withTransaction
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:14