Skip to main content
Skip to main content

LineItemService

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

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

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

Methods

withTransaction

Parameters

transactionManagerEntityManager

Returns

thisthisRequired

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanbooleanRequired

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

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

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

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
contextGenerateLineItemContextRequired

Default: {}

quantitynumber

Returns

PromisePromise<TResult>Required
Generate a single or multiple line item without persisting the data into the db

generateLineItem

Parameters

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

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

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)

delete

**delete**(ids): Promise&#60;[LineItem](../../entities/classes/entities.LineItem.mdx)[]&#62;

Deletes a line item.

Parameters

idsstring[]Required

Returns

PromisePromise<LineItem[]>Required
the result of the delete operation

**delete**(id): Promise&#60;void \| [LineItem](../../entities/classes/entities.LineItem.mdx)&#62;

Deletes a line item.

Parameters

idstringRequired
the id of the line item to delete

Returns

PromisePromise<void | LineItem>Required
the result of the delete operation

deleteWithTaxLines

Parameters

idstringRequired
the id of the line item to delete

Returns

PromisePromise<void | 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.

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.

cloneTo

Parameters

idsstring | string[]Required
dataDeepPartial<LineItem>Required

Default: {}

optionsobjectRequired
options.setOriginalLineItemIdboolean

Returns

PromisePromise<LineItem[]>Required

validateGenerateArguments

Type Parameters

TobjectRequired
TResultobjectRequired

Parameters

variantIdOrDatastring | TRequired
regionIdOrContextT extends string ? string : GenerateLineItemContextRequired
quantitynumber

Returns

voidvoidRequired
Was this section helpful?