Skip to main content

Class: LineItemService

Provides layer to manipulate line items.

Hierarchy

  • "medusa-interfaces"

    LineItemService

Constructors

constructor

new LineItemService(__namedParameters)

Parameters

NameType
__namedParametersInjectedDependencies

Overrides

BaseService.constructor

Defined in

services/line-item.ts:38

Properties

cartRepository_

Protected Readonly cartRepository_: typeof CartRepository

Defined in

services/line-item.ts:32


itemTaxLineRepo_

Protected Readonly itemTaxLineRepo_: typeof LineItemTaxLineRepository

Defined in

services/line-item.ts:31


lineItemAdjustmentService_

Protected Readonly lineItemAdjustmentService_: LineItemAdjustmentService

Defined in

services/line-item.ts:36


lineItemRepository_

Protected Readonly lineItemRepository_: typeof LineItemRepository

Defined in

services/line-item.ts:30


manager_

Protected Readonly manager_: EntityManager

Defined in

services/line-item.ts:29


productService_

Protected Readonly productService_: ProductService

Defined in

services/line-item.ts:34


productVariantService_

Protected Readonly productVariantService_: ProductVariantService

Defined in

services/line-item.ts:33


regionService_

Protected Readonly regionService_: RegionService

Defined in

services/line-item.ts:35

Methods

create

create(data): Promise<LineItem>

Create a line item

Parameters

NameTypeDescription
dataPartial<LineItem>the line item object to create

Returns

Promise<LineItem>

the created line item

Defined in

services/line-item.ts:261


createReturnLines

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

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

Parameters

NameTypeDescription
returnIdstringthe id to generate return items from.
cartIdstringthe cart to assign the return line items to.

Returns

Promise<LineItem[]>

the created line items

Defined in

services/line-item.ts:133


delete

delete(id): Promise<undefined | LineItem>

Deletes a line item.

Parameters

NameTypeDescription
idstringthe id of the line item to delete

Returns

Promise<undefined | LineItem>

the result of the delete operation

Defined in

services/line-item.ts:309


generate

generate(variantId, regionId, quantity, context?): Promise<LineItem>

Parameters

NameType
variantIdstring
regionIdstring
quantitynumber
contextObject
context.cart?Cart
context.customer_id?string
context.metadata?Record<string, unknown>
context.unit_price?number

Returns

Promise<LineItem>

Defined in

services/line-item.ts:186


list

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

Parameters

NameTypeDefault value
selectoranyundefined
configObjectundefined
config.orderObjectundefined
config.order.created_atstring"DESC"
config.skipnumber0
config.takenumber50

Returns

Promise<LineItem[]>

Defined in

services/line-item.ts:81


retrieve

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

Retrieves a line item by its id.

Parameters

NameTypeDescription
idstringthe id of the line item to retrieve
configObjectthe config to be used at query building

Returns

Promise<LineItem>

the line item

Defined in

services/line-item.ts:102


update

update(id, data): Promise<LineItem>

Updates a line item

Parameters

NameTypeDescription
idstringthe id of the line item to update
dataPartial<LineItem>the properties to update on line item

Returns

Promise<LineItem>

the update line item

Defined in

services/line-item.ts:280


withTransaction

withTransaction(transactionManager): LineItemService

Parameters

NameType
transactionManagerEntityManager

Returns

LineItemService

Defined in

services/line-item.ts:60