Skip to main content
Skip to main content

LineItemService

internal.internal.LineItemService

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
cartRepository_Repository<Cart> & { findOneWithRelations: Method findOneWithRelations ; findWithRelations: Method findWithRelations }Required
featureFlagRouter_FlagRouterRequired
itemTaxLineRepo_Repository<LineItemTaxLine> & { deleteForCart: Method deleteForCart ; upsertLines: Method upsertLines }Required
lineItemAdjustmentService_LineItemAdjustmentServiceRequired
lineItemRepository_Repository<LineItem> & { findByReturn: Method findByReturn }Required
manager_EntityManagerRequired
pricingService_PricingServiceRequired
productService_ProductServiceRequired
productVariantService_ProductVariantServiceRequired
regionService_RegionServiceRequired
taxProviderService_TaxProviderServiceRequired
transactionManager_undefined | EntityManagerRequired

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

EntityManagerEntityManagerRequired

Inherited from

TransactionBaseService.activeManager_

Methods

atomicPhase_

Protected atomicPhase_<TResult, TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise<TResult>

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

Inherited from

TransactionBaseService.atomicPhase_


cloneTo

cloneTo(ids, data?, options?): Promise<LineItem[]>

Parameters

idsstring | string[]Required
dataDeepPartial<LineItem>
optionsobject
options.setOriginalLineItemIdboolean

Returns

Promise<LineItem[]>

PromisePromise<LineItem[]>Required

create

create<T, TResult>(data): Promise<TResult>

Create a line item

TobjectRequired
TResultobjectRequired

Parameters

dataTRequired
the line item object to create

Returns

Promise<TResult>

PromisePromise<TResult>Required
the created line item

createReturnLines

createReturnLines(returnId, cartId): Promise<LineItem[]>

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

Promise<LineItem[]>

PromisePromise<LineItem[]>Required
the created line items

createTaxLine

createTaxLine(args): LineItemTaxLine

Create a line item tax line.

Parameters

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

Returns

LineItemTaxLine

LineItemTaxLineLineItemTaxLineRequired
a new line item tax line

delete

delete(id): Promise<undefined | null | LineItem>

Deletes a line item.

Parameters

idstringRequired
the id of the line item to delete

Returns

Promise<undefined | null | LineItem>

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

deleteWithTaxLines

deleteWithTaxLines(id): Promise<undefined | null | LineItem>

Parameters

idstringRequired
the id of the line item to delete

Returns

Promise<undefined | null | LineItem>

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<T, TResult>(variantIdOrData, regionIdOrContext, quantity?, context?): Promise<TResult>

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

TobjectRequired
TResultobjectRequired

Parameters

variantIdOrDataTRequired
regionIdOrContextT extends string ? string : GenerateLineItemContextRequired
quantitynumber

Returns

Promise<TResult>

PromisePromise<TResult>Required

generateLineItem

Protected generateLineItem(variant, quantity, context): Promise<LineItem>

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 & { variantPricing: ProductVariantPricing }Required

Returns

Promise<LineItem>

PromisePromise<LineItem>Required

list

list(selector, config?): Promise<LineItem[]>

Parameters

selectorSelector<LineItem>Required

Returns

Promise<LineItem[]>

PromisePromise<LineItem[]>Required

retrieve

retrieve(id, config?): Promise<LineItem>

Retrieves a line item by its id.

Parameters

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

Returns

Promise<LineItem>

PromisePromise<LineItem>Required
the line item

shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

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

Returns

boolean

booleanboolean

Inherited from

TransactionBaseService.shouldRetryTransaction_


update

update(idOrSelector, data): Promise<LineItem[]>

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

Promise<LineItem[]>

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

validateGenerateArguments

Protected validateGenerateArguments<T, TResult>(variantIdOrData, regionIdOrContext, quantity?): void

TobjectRequired
TResultobjectRequired

Parameters

variantIdOrDatastring | TRequired
regionIdOrContextT extends string ? string : GenerateLineItemContextRequired
quantitynumber

Returns

void

voidvoid

withTransaction

withTransaction(transactionManager?): LineItemService

Parameters

transactionManagerEntityManager

Returns

LineItemService

LineItemServiceLineItemServiceRequired

Inherited from

TransactionBaseService.withTransaction

Was this section helpful?