6.5 KiB
Class: LineItemService
Provides layer to manipulate line items.
Hierarchy
-
"medusa-interfaces"↳
LineItemService
Constructors
constructor
• new LineItemService(__namedParameters)
Parameters
| Name | Type |
|---|---|
__namedParameters |
InjectedDependencies |
Overrides
BaseService.constructor
Defined in
Properties
cartRepository_
• Protected Readonly cartRepository_: typeof CartRepository
Defined in
itemTaxLineRepo_
• Protected Readonly itemTaxLineRepo_: typeof LineItemTaxLineRepository
Defined in
lineItemAdjustmentService_
• Protected Readonly lineItemAdjustmentService_: LineItemAdjustmentService
Defined in
lineItemRepository_
• Protected Readonly lineItemRepository_: typeof LineItemRepository
Defined in
manager_
• Protected Readonly manager_: EntityManager
Defined in
productService_
• Protected Readonly productService_: ProductService
Defined in
productVariantService_
• Protected Readonly productVariantService_: ProductVariantService
Defined in
regionService_
• Protected Readonly regionService_: RegionService
Defined in
Methods
create
▸ create(data): Promise<LineItem>
Create a line item
Parameters
| Name | Type | Description |
|---|---|---|
data |
Partial<LineItem> |
the line item object to create |
Returns
Promise<LineItem>
the created line item
Defined in
createReturnLines
▸ createReturnLines(returnId, cartId): Promise<LineItem[]>
Creates return line items for a given cart based on the return items in a return.
Parameters
| Name | Type | Description |
|---|---|---|
returnId |
string |
the id to generate return items from. |
cartId |
string |
the cart to assign the return line items to. |
Returns
Promise<LineItem[]>
the created line items
Defined in
delete
▸ delete(id): Promise<undefined | LineItem>
Deletes a line item.
Parameters
| Name | Type | Description |
|---|---|---|
id |
string |
the id of the line item to delete |
Returns
Promise<undefined | LineItem>
the result of the delete operation
Defined in
generate
▸ generate(variantId, regionId, quantity, context?): Promise<LineItem>
Parameters
| Name | Type |
|---|---|
variantId |
string |
regionId |
string |
quantity |
number |
context |
Object |
context.cart? |
Cart |
context.customer_id? |
string |
context.metadata? |
Record<string, unknown> |
context.unit_price? |
number |
Returns
Promise<LineItem>
Defined in
list
▸ list(selector, config?): Promise<LineItem[]>
Parameters
| Name | Type | Default value |
|---|---|---|
selector |
any |
undefined |
config |
Object |
undefined |
config.order |
Object |
undefined |
config.order.created_at |
string |
"DESC" |
config.skip |
number |
0 |
config.take |
number |
50 |
Returns
Promise<LineItem[]>
Defined in
retrieve
▸ retrieve(id, config?): Promise<LineItem>
Retrieves a line item by its id.
Parameters
| Name | Type | Description |
|---|---|---|
id |
string |
the id of the line item to retrieve |
config |
Object |
the config to be used at query building |
Returns
Promise<LineItem>
the line item
Defined in
update
▸ update(id, data): Promise<LineItem>
Updates a line item
Parameters
| Name | Type | Description |
|---|---|---|
id |
string |
the id of the line item to update |
data |
Partial<LineItem> |
the properties to update on line item |
Returns
Promise<LineItem>
the update line item
Defined in
withTransaction
▸ withTransaction(transactionManager): LineItemService
Parameters
| Name | Type |
|---|---|
transactionManager |
EntityManager |