Skip to main content
Skip to main content

LineItemService

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
cartRepository_Repository<Cart> & objectRequired
featureFlagRouter_FlagRouterRequired
itemTaxLineRepo_Repository<LineItemTaxLine> & objectRequired
lineItemAdjustmentService_LineItemAdjustmentServiceRequired
lineItemRepository_Repository<LineItem> & objectRequired
manager_EntityManagerRequired
pricingService_PricingServiceRequired
productService_ProductServiceRequired
productVariantService_ProductVariantServiceRequired
regionService_RegionServiceRequired
taxProviderService_TaxProviderServiceRequired
transactionManager_undefined | EntityManagerRequired

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

Methods

atomicPhase_

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

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

PromisePromise<TResult>Required
the result of the transactional work

cloneTo

Parameters

idsstring | string[]Required
dataDeepPartial<LineItem>Required

Default: {}

optionsobjectRequired
options.setOriginalLineItemIdboolean

Returns

PromisePromise<LineItem[]>Required

create

Create a line item

Type Parameters

TobjectRequired
TResultobjectRequired

Parameters

dataTRequired
the line item object to create

Returns

PromisePromise<TResult>Required
the created line item

createReturnLines

Creates return line items for a given cart based on the return items in a return.

Parameters

returnIdstringRequired
the id to generate return items from.
cartIdstringRequired
the cart to assign the return line items to.

Returns

PromisePromise<LineItem[]>Required
the created line items

createTaxLine

Create a line item tax line.

Parameters

argsDeepPartial<LineItemTaxLine>Required
tax line partial passed to the repo create method

Returns

LineItemTaxLineobjectRequired
A Line Item Tax Line represents the taxes applied on a line item.

delete

Deletes a line item.

Parameters

idstringRequired
the id of the line item to delete

Returns

PromisePromise<undefined | null | LineItem>Required
the result of the delete operation

deleteWithTaxLines

Parameters

idstringRequired
the id of the line item to delete

Returns

PromisePromise<undefined | null | LineItem>Required
the result of the delete operation

Deprecated

no the cascade on the entity takes care of it Deletes a line item with the tax lines.


generate

Generate a single or multiple line item without persisting the data into the db

Type Parameters

TobjectRequired
TResultobjectRequired

Parameters

variantIdOrDataTRequired
regionIdOrContextT extends string ? string : GenerateLineItemContextRequired
quantitynumber
contextGenerateLineItemContextRequired

Default: {}

Returns

PromisePromise<TResult>Required

generateLineItem

Parameters

variantobjectRequired
variant.idstringRequired
variant.productobjectRequired
variant.product.discountablebooleanRequired
variant.product.is_giftcardbooleanRequired
variant.product.thumbnailnull | stringRequired
variant.product.titlestringRequired
variant.product_idstringRequired
variant.titlestringRequired
quantitynumberRequired
contextGenerateLineItemContext & objectRequired

Returns

PromisePromise<LineItem>Required

list

Parameters

selectorSelector<LineItem>Required
configFindConfig<LineItem>Required

Returns

PromisePromise<LineItem[]>Required

retrieve

Retrieves a line item by its id.

Parameters

idstringRequired
the id of the line item to retrieve
configobjectRequired
the config to be used at query building

Default: {}

Returns

PromisePromise<LineItem>Required
the line item

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanboolean

update

Updates a line item

Parameters

idOrSelectorstring | Selector<LineItem>Required
the id or selector of the line item(s) to update
dataPartial<LineItem>Required
the properties to update the line item(s)

Returns

PromisePromise<LineItem[]>Required
the updated line item(s)

validateGenerateArguments

Type Parameters

TobjectRequired
TResultobjectRequired

Parameters

variantIdOrDatastring | TRequired
regionIdOrContextT extends string ? string : GenerateLineItemContextRequired
quantitynumber

Returns

voidvoid

withTransaction

Parameters

transactionManagerEntityManager

Returns

LineItemServiceobjectRequired
Was this section helpful?