Class: DraftOrderService
Handles draft orders
Implements
Hierarchy
TransactionBaseService
↳
DraftOrderService
Constructors
constructor
• new DraftOrderService(__namedParameters
)
Parameters
Name | Type |
---|---|
__namedParameters | InjectedDependencies |
Overrides
TransactionBaseService.constructor
Defined in
packages/medusa/src/services/draft-order.ts:54
Properties
__configModule__
• Protected
Optional
Readonly
__configModule__: Record
<string
, unknown
>
Inherited from
TransactionBaseService.__configModule__
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:10
__container__
• Protected
Readonly
__container__: any
Inherited from
TransactionBaseService.__container__
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:9
__moduleDeclaration__
• Protected
Optional
Readonly
__moduleDeclaration__: Record
<string
, unknown
>
Inherited from
TransactionBaseService.__moduleDeclaration__
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:11
cartService_
• Protected
Readonly
cartService_: CartService
Defined in
packages/medusa/src/services/draft-order.ts:48
customShippingOptionService_
• Protected
Readonly
customShippingOptionService_: CustomShippingOptionService
Defined in
packages/medusa/src/services/draft-order.ts:52
draftOrderRepository_
• Protected
Readonly
draftOrderRepository_: typeof DraftOrderRepository
Defined in
packages/medusa/src/services/draft-order.ts:44
eventBus_
• Protected
Readonly
eventBus_: EventBusService
Defined in
packages/medusa/src/services/draft-order.ts:47
lineItemService_
• Protected
Readonly
lineItemService_: LineItemService
Defined in
packages/medusa/src/services/draft-order.ts:49
manager_
• Protected
manager_: EntityManager
Overrides
TransactionBaseService.manager_
Defined in
packages/medusa/src/services/draft-order.ts:41
orderRepository_
• Protected
Readonly
orderRepository_: typeof OrderRepository
Defined in
packages/medusa/src/services/draft-order.ts:46
paymentRepository_
• Protected
Readonly
paymentRepository_: typeof PaymentRepository
Defined in
packages/medusa/src/services/draft-order.ts:45
productVariantService_
• Protected
Readonly
productVariantService_: ProductVariantService
Defined in
packages/medusa/src/services/draft-order.ts:50
shippingOptionService_
• Protected
Readonly
shippingOptionService_: ShippingOptionService
Defined in
packages/medusa/src/services/draft-order.ts:51
transactionManager_
• Protected
transactionManager_: undefined
| EntityManager
Overrides
TransactionBaseService.transactionManager_
Defined in
packages/medusa/src/services/draft-order.ts:42
Events
▪ Static
Readonly
Events: Object
Type declaration
Name | Type |
---|---|
CREATED | string |
UPDATED | string |
Defined in
packages/medusa/src/services/draft-order.ts:36
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.
Type parameters
Name |
---|
TResult |
TError |
Parameters
Name | Type | Description |
---|---|---|
work | (transactionManager : EntityManager ) => Promise <TResult > | the transactional work to be done |
isolationOrErrorHandler? | IsolationLevel | (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
>
the result of the transactional work
Inherited from
TransactionBaseService.atomicPhase_
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:50
create
▸ create(data
): Promise
<DraftOrder
>
Creates a draft order.
Parameters
Name | Type | Description |
---|---|---|
data | DraftOrderCreateProps | data to create draft order from |
Returns
Promise
<DraftOrder
>
the created draft order
Defined in
packages/medusa/src/services/draft-order.ts:248
delete
▸ delete(draftOrderId
): Promise
<undefined
| DraftOrder
>
Deletes draft order idempotently.
Parameters
Name | Type | Description |
---|---|---|
draftOrderId | string | id of draft order to delete |
Returns
Promise
<undefined
| DraftOrder
>
empty promise
Defined in
packages/medusa/src/services/draft-order.ts:147
list
▸ list(selector
, config?
): Promise
<DraftOrder
[]>
Lists draft orders
Parameters
Name | Type | Description |
---|---|---|
selector | any | query object for find |
config | FindConfig <DraftOrder > | configurable attributes for find |
Returns
Promise
<DraftOrder
[]>
list of draft orders
Defined in
packages/medusa/src/services/draft-order.ts:225
listAndCount
▸ listAndCount(selector
, config?
): Promise
<[DraftOrder
[], number
]>
Lists draft orders alongside the count
Parameters
Name | Type | Description |
---|---|---|
selector | any | query selector to filter draft orders |
config | FindConfig <DraftOrder > | query config |
Returns
Promise
<[DraftOrder
[], number
]>
draft orders
Defined in
packages/medusa/src/services/draft-order.ts:171
registerCartCompletion
▸ registerCartCompletion(draftOrderId
, orderId
): Promise
<UpdateResult
>
Registers a draft order as completed, when an order has been completed.
Parameters
Name | Type | Description |
---|---|---|
draftOrderId | string | id of draft order to complete |
orderId | string | id of order completed from draft order cart |
Returns
Promise
<UpdateResult
>
the created order
Defined in
packages/medusa/src/services/draft-order.ts:365
retrieve
▸ retrieve(draftOrderId
, config?
): Promise
<DraftOrder
>
Retrieves a draft order with the given id.
Parameters
Name | Type | Description |
---|---|---|
draftOrderId | string | id of the draft order to retrieve |
config | FindConfig <DraftOrder > | query object for findOne |
Returns
Promise
<DraftOrder
>
the draft order
Defined in
packages/medusa/src/services/draft-order.ts:87
retrieveByCartId
▸ retrieveByCartId(cartId
, config?
): Promise
<DraftOrder
>
Retrieves a draft order based on its associated cart id
Parameters
Name | Type | Description |
---|---|---|
cartId | string | cart id that the draft orders's cart has |
config | FindConfig <DraftOrder > | query object for findOne |
Returns
Promise
<DraftOrder
>
the draft order
Defined in
packages/medusa/src/services/draft-order.ts:121
shouldRetryTransaction_
▸ Protected
shouldRetryTransaction_(err
): boolean
Parameters
Name | Type |
---|---|
err | Record <string , unknown > | { code : string } |
Returns
boolean
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:31
update
▸ update(id
, data
): Promise
<DraftOrder
>
Updates a draft order with the given data
Parameters
Name | Type | Description |
---|---|---|
id | string | id of the draft order |
data | Object | values to update the order with |
data.no_notification_order | boolean | - |
Returns
Promise
<DraftOrder
>
the updated draft order
Defined in
packages/medusa/src/services/draft-order.ts:394
withTransaction
▸ withTransaction(transactionManager?
): DraftOrderService
Parameters
Name | Type |
---|---|
transactionManager? | EntityManager |
Returns
Inherited from
TransactionBaseService.withTransaction
Defined in
packages/medusa/src/interfaces/transaction-base-service.ts:14