LineItemService
Constructors
constructor
**new LineItemService**(«destructured»)
Parameters
Properties
__configModule__
Record<string, unknown>__container__
anyRequired__moduleDeclaration__
Record<string, unknown>cartRepository_
Repository<Cart> & { findOneWithRelations: Method findOneWithRelations ; findWithRelations: Method findWithRelations }RequireditemTaxLineRepo_
Repository<LineItemTaxLine> & { deleteForCart: Method deleteForCart ; upsertLines: Method upsertLines }Requiredmanager_
EntityManagerRequiredtransactionManager_
undefined | EntityManagerRequiredAccessors
activeManager_
Protected get**activeManager_**(): EntityManager
Returns
EntityManager
EntityManager
EntityManagerRequiredMethods
atomicPhase_
Protected **atomicPhase_**<TypeParameter TResult, TypeParameter 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.
TResult
objectRequiredTError
objectRequiredParameters
work
(transactionManager: EntityManager) => Promise<TResult>RequiredisolationOrErrorHandler
IsolationLevel | (error: TError) => Promise<void | TResult>maybeErrorHandlerOrDontFail
(error: TError) => Promise<void | TResult>Returns
Promise<TResult>
Promise
Promise<TResult>RequiredcloneTo
**cloneTo**(ids, data?, options?): Promise<[LineItem](/references/services/classes/LineItem)[]>
Parameters
ids
string | string[]RequiredDefault: {}
options
objectRequiredoptions.setOriginalLineItemId
booleanReturns
Promise<LineItem[]>
create
**create**<TypeParameter T, TypeParameter TResult>(data): Promise<TResult>
Create a line item
T
objectRequiredTResult
objectRequiredParameters
data
TRequiredReturns
Promise<TResult>
Promise
Promise<TResult>RequiredcreateReturnLines
**createReturnLines**(returnId, cartId): Promise<[LineItem](/references/services/classes/LineItem)[]>
Creates return line items for a given cart based on the return items in a return.
Parameters
returnId
stringRequiredcartId
stringRequiredReturns
Promise<LineItem[]>
createTaxLine
**createTaxLine**(args): [LineItemTaxLine](/references/services/classes/LineItemTaxLine)
Create a line item tax line.
Parameters
Returns
delete
**delete**(id): Promise<undefined \| null \| [LineItem](/references/services/classes/LineItem)>
Deletes a line item.
Parameters
id
stringRequiredReturns
Promise<undefined | null | LineItem>
deleteWithTaxLines
**deleteWithTaxLines**(id): Promise<undefined \| null \| [LineItem](/references/services/classes/LineItem)>
Parameters
id
stringRequiredReturns
Promise<undefined | null | LineItem>
Deprecated
no the cascade on the entity takes care of it Deletes a line item with the tax lines.
generate
**generate**<TypeParameter T, TypeParameter TResult>(variantIdOrData, regionIdOrContext, quantity?, context?): Promise<TResult>
Generate a single or multiple line item without persisting the data into the db
T
objectRequiredTResult
objectRequiredParameters
variantIdOrData
TRequiredquantity
numberDefault: {}
Returns
Promise<TResult>
Promise
Promise<TResult>RequiredgenerateLineItem
Protected **generateLineItem**(variant, quantity, context): Promise<[LineItem](/references/services/classes/LineItem)>
Parameters
variant
objectRequiredvariant.id
stringRequiredvariant.product
objectRequiredvariant.product.discountable
booleanRequiredvariant.product.is_giftcard
booleanRequiredvariant.product.thumbnail
null | stringRequiredvariant.product.title
stringRequiredvariant.product_id
stringRequiredvariant.title
stringRequiredquantity
numberRequiredcontext
GenerateLineItemContext & { variantPricing: [ProductVariantPricing](/references/services/types/ProductVariantPricing) }RequiredReturns
Promise<LineItem>
list
**list**(selector, config?): Promise<[LineItem](/references/services/classes/LineItem)[]>
Parameters
Returns
Promise<LineItem[]>
retrieve
**retrieve**(id, config?): Promise<[LineItem](/references/services/classes/LineItem)>
Retrieves a line item by its id.
Parameters
id
stringRequiredconfig
objectRequiredDefault: {}
Returns
Promise<LineItem>
shouldRetryTransaction_
Protected **shouldRetryTransaction_**(err): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanupdate
**update**(idOrSelector, data): Promise<[LineItem](/references/services/classes/LineItem)[]>
Updates a line item
Parameters
Returns
Promise<LineItem[]>
validateGenerateArguments
Protected **validateGenerateArguments**<TypeParameter T, TypeParameter TResult>(variantIdOrData, regionIdOrContext, quantity?): void
T
objectRequiredTResult
objectRequiredParameters
variantIdOrData
string | TRequiredquantity
numberReturns
void
void
voidwithTransaction
**withTransaction**(transactionManager?): [LineItemService](/references/services/classes/LineItemService)
Parameters
transactionManager
EntityManager