LineItemService
internal.internal.LineItemService
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
EntityManagerRequiredInherited 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.
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>RequiredInherited from
TransactionBaseService.atomicPhase_
cloneTo
cloneTo(ids
, data?
, options?
): Promise
<LineItem
[]>
Parameters
ids
string | string[]Requireddata
DeepPartial<LineItem>options
objectoptions.setOriginalLineItemId
booleanReturns
Promise
<LineItem
[]>
create
create<T
, TResult
>(data
): Promise
<TResult
>
Create a line item
T
objectRequiredTResult
objectRequiredParameters
data
TRequiredReturns
Promise
<TResult
>
Promise
Promise<TResult>RequiredcreateReturnLines
createReturnLines(returnId
, cartId
): Promise
<LineItem
[]>
Creates return line items for a given cart based on the return items in a return.
Parameters
returnId
stringRequiredcartId
stringRequiredReturns
Promise
<LineItem
[]>
the created line items
createTaxLine
createTaxLine(args
): LineItemTaxLine
Create a line item tax line.
Parameters
Returns
delete
delete(id
): Promise
<undefined
| null
| LineItem
>
Deletes a line item.
Parameters
id
stringRequiredReturns
Promise
<undefined
| null
| LineItem
>
the result of the delete operation
deleteWithTaxLines
deleteWithTaxLines(id
): Promise
<undefined
| null
| LineItem
>
Parameters
id
stringRequiredReturns
Promise
<undefined
| null
| LineItem
>
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
T
objectRequiredTResult
objectRequiredParameters
Returns
Promise
<TResult
>
Promise
Promise<TResult>RequiredgenerateLineItem
Protected
generateLineItem(variant
, quantity
, context
): Promise
<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
numberRequiredReturns
Promise
<LineItem
>
list
list(selector
, config?
): Promise
<LineItem
[]>
Parameters
config
FindConfig<LineItem>Returns
Promise
<LineItem
[]>
retrieve
retrieve(id
, config?
): Promise
<LineItem
>
Retrieves a line item by its id.
Parameters
id
stringRequiredconfig
objectReturns
Promise
<LineItem
>
the line item
shouldRetryTransaction_
Protected
shouldRetryTransaction_(err
): boolean
Parameters
err
Record<string, unknown> | { code: string }RequiredReturns
boolean
boolean
booleanInherited from
TransactionBaseService.shouldRetryTransaction_
update
update(idOrSelector
, data
): Promise
<LineItem
[]>
Updates a line item
Parameters
Returns
Promise
<LineItem
[]>
the updated line item(s)
validateGenerateArguments
Protected
validateGenerateArguments<T
, TResult
>(variantIdOrData
, regionIdOrContext
, quantity?
): void
T
objectRequiredTResult
objectRequiredParameters
variantIdOrData
string | TRequiredquantity
numberReturns
void
void
voidwithTransaction
withTransaction(transactionManager?
): LineItemService
Parameters
transactionManager
EntityManager