Class: DraftOrderService
Handles draft orders
Implements
Hierarchy
TransactionBaseService
↳
DraftOrderService
Constructors
constructor
• new DraftOrderService(__namedParameters
)
Parameters
Name | Type |
---|---|
__namedParameters | InjectedDependencies |
Overrides
TransactionBaseService.constructor
Defined in
medusa/src/services/draft-order.ts:67
Properties
__configModule__
• Protected
Optional
Readonly
__configModule__: Record
<string
, unknown
>
Inherited from
TransactionBaseService.__configModule__
Defined in
medusa/src/interfaces/transaction-base-service.ts:14
__container__
• Protected
Readonly
__container__: any
Inherited from
TransactionBaseService.__container__
Defined in
medusa/src/interfaces/transaction-base-service.ts:13
__moduleDeclaration__
• Protected
Optional
Readonly
__moduleDeclaration__: Record
<string
, unknown
>
Inherited from
TransactionBaseService.__moduleDeclaration__
Defined in
medusa/src/interfaces/transaction-base-service.ts:15
cartService_
• Protected
Readonly
cartService_: CartService
Defined in
medusa/src/services/draft-order.ts:61
customShippingOptionService_
• Protected
Readonly
customShippingOptionService_: CustomShippingOptionService
Defined in
medusa/src/services/draft-order.ts:65
draftOrderRepository_
• Protected
Readonly
draftOrderRepository_: Repository
<DraftOrder
>
Defined in
medusa/src/services/draft-order.ts:57
eventBus_
• Protected
Readonly
eventBus_: EventBusService
Defined in
medusa/src/services/draft-order.ts:60
lineItemService_
• Protected
Readonly
lineItemService_: LineItemService
Defined in
medusa/src/services/draft-order.ts:62
manager_
• Protected
manager_: EntityManager
Inherited from
TransactionBaseService.manager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:5
orderRepository_
• Protected
Readonly
orderRepository_: Repository
<Order
> & { findOneWithRelations
: (relations
: FindOptionsRelations
<Order
>, optionsWithoutRelations
: Omit
<FindManyOptions
<Order
>, "relations"
>) => Promise
<Order
> ; findWithRelations
: (relations
: FindOptionsRelations
<Order
>, optionsWithoutRelations
: Omit
<FindManyOptions
<Order
>, "relations"
>) => Promise
<Order
[]> }
Defined in
medusa/src/services/draft-order.ts:59
paymentRepository_
• Protected
Readonly
paymentRepository_: Repository
<Payment
>
Defined in
medusa/src/services/draft-order.ts:58
productVariantService_
• Protected
Readonly
productVariantService_: ProductVariantService
Defined in
medusa/src/services/draft-order.ts:63
shippingOptionService_
• Protected
Readonly
shippingOptionService_: ShippingOptionService
Defined in
medusa/src/services/draft-order.ts:64
transactionManager_
• Protected
transactionManager_: undefined
| EntityManager
Inherited from
TransactionBaseService.transactionManager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:6
Events
▪ Static
Readonly
Events: Object
Type declaration
Name | Type |
---|---|
CREATED | string |
UPDATED | string |
Defined in
medusa/src/services/draft-order.ts:52
Accessors
activeManager_
• Protected
get
activeManager_(): EntityManager
Returns
EntityManager
Inherited from
TransactionBaseService.activeManager_
Defined in
medusa/src/interfaces/transaction-base-service.ts:8
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
medusa/src/interfaces/transaction-base-service.ts:56
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
medusa/src/services/draft-order.ts:260
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
medusa/src/services/draft-order.ts:156
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
medusa/src/services/draft-order.ts:238
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
medusa/src/services/draft-order.ts:180
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
medusa/src/services/draft-order.ts:421
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
medusa/src/services/draft-order.ts:98
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
medusa/src/services/draft-order.ts:131
shouldRetryTransaction_
▸ Protected
shouldRetryTransaction_(err
): boolean
Parameters
Name | Type |
---|---|
err | Record <string , unknown > | { code : string } |
Returns
boolean
Inherited from
TransactionBaseService.shouldRetryTransaction_
Defined in
medusa/src/interfaces/transaction-base-service.ts:37
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
medusa/src/services/draft-order.ts:450
withTransaction
▸ withTransaction(transactionManager?
): DraftOrderService
Parameters
Name | Type |
---|---|
transactionManager? | EntityManager |
Returns
Inherited from
TransactionBaseService.withTransaction