Skip to main content
Skip to main content

DraftOrderService

Handles draft orders

Implements

Hierarchy

  • TransactionBaseService

    DraftOrderService

Constructors

constructor

new DraftOrderService(«destructured»)

Parameters

Name
«destructured»

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: Method findOneWithRelations ; findWithRelations: Method findWithRelations }

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

NameType
CREATEDstring
UPDATEDstring

Defined in

medusa/src/services/draft-order.ts:52

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

-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.

Name
TResult
TError

Parameters

NameDescription
work(transactionManager: EntityManager) => Promise<TResult>
isolationOrErrorHandler?IsolationLevel | (error: TError) => Promise<void | TResult>
maybeErrorHandlerOrDontFail?(error: TError) => Promise<void | TResult>

Returns

Promise<TResult>

-Promise: 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

NameDescription
dataDraftOrderCreateProps

Returns

Promise<DraftOrder>

-Promise: the created draft order -DraftOrder:

Defined in

medusa/src/services/draft-order.ts:260


delete

delete(draftOrderId): Promise<undefined | DraftOrder>

Deletes draft order idempotently.

Parameters

NameDescription
draftOrderIdstring

Returns

Promise<undefined | DraftOrder>

-Promise: empty promise -undefined \| DraftOrder: (optional)

Defined in

medusa/src/services/draft-order.ts:156


list

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

Lists draft orders

Parameters

NameDescription
selectorany
configFindConfig<DraftOrder>

Returns

Promise<DraftOrder[]>

-Promise: list of draft orders -DraftOrder[]: -DraftOrder:

Defined in

medusa/src/services/draft-order.ts:238


listAndCount

listAndCount(selector, config?): Promise<[DraftOrder[], number]>

Lists draft orders alongside the count

Parameters

NameDescription
selectorany
configFindConfig<DraftOrder>

Returns

Promise<[DraftOrder[], number]>

-Promise: draft orders -DraftOrder[]: -number: (optional)

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

NameDescription
draftOrderIdstring
orderIdstring

Returns

Promise<UpdateResult>

-Promise: the created order -UpdateResult:

Defined in

medusa/src/services/draft-order.ts:420


retrieve

retrieve(draftOrderId, config?): Promise<DraftOrder>

Retrieves a draft order with the given id.

Parameters

NameDescription
draftOrderIdstring
configFindConfig<DraftOrder>

Returns

Promise<DraftOrder>

-Promise: the draft order -DraftOrder:

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

NameDescription
cartIdstring
configFindConfig<DraftOrder>

Returns

Promise<DraftOrder>

-Promise: the draft order -DraftOrder:

Defined in

medusa/src/services/draft-order.ts:131


shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

Name
err

Returns

boolean

-boolean: (optional)

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

NameDescription
idstring
dataobject
data.no_notification_orderboolean

Returns

Promise<DraftOrder>

-Promise: the updated draft order -DraftOrder:

Defined in

medusa/src/services/draft-order.ts:449


withTransaction

withTransaction(transactionManager?): DraftOrderService

Parameters

Name
transactionManager?

Returns

DraftOrderService

-DraftOrderService:

Inherited from

TransactionBaseService.withTransaction

Defined in

medusa/src/interfaces/transaction-base-service.ts:20

Was this section helpful?