Skip to main content

Class: DraftOrderService

Handles draft orders

Implements

Hierarchy

  • TransactionBaseService

    DraftOrderService

Constructors

constructor

new DraftOrderService(__namedParameters)

Parameters

NameType
__namedParametersInjectedDependencies

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

NameType
CREATEDstring
UPDATEDstring

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

NameTypeDescription
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

NameTypeDescription
dataDraftOrderCreatePropsdata 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

NameTypeDescription
draftOrderIdstringid 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

NameTypeDescription
selectoranyquery object for find
configFindConfig<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

NameTypeDescription
selectoranyquery selector to filter draft orders
configFindConfig<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

NameTypeDescription
draftOrderIdstringid of draft order to complete
orderIdstringid 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

NameTypeDescription
draftOrderIdstringid of the draft order to retrieve
configFindConfig<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

NameTypeDescription
cartIdstringcart id that the draft orders's cart has
configFindConfig<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

NameType
errRecord<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

NameTypeDescription
idstringid of the draft order
dataObjectvalues to update the order with
data.no_notification_orderboolean-

Returns

Promise<DraftOrder>

the updated draft order

Defined in

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


withTransaction

withTransaction(transactionManager?): DraftOrderService

Parameters

NameType
transactionManager?EntityManager

Returns

DraftOrderService

Inherited from

TransactionBaseService.withTransaction

Defined in

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

Was this page helpful?