Skip to main content
Skip to main content

DraftOrderService

internal.internal.DraftOrderService

Handles draft orders

Implements

Properties

__configModule__Record<string, unknown>
__container__anyRequired
__moduleDeclaration__Record<string, unknown>
cartService_CartServiceRequired
customShippingOptionService_CustomShippingOptionServiceRequired
draftOrderRepository_Repository<DraftOrder>Required
eventBus_EventBusServiceRequired
lineItemService_LineItemServiceRequired
manager_EntityManagerRequired
orderRepository_Repository<Order> & { findOneWithRelations: Method findOneWithRelations ; findWithRelations: Method findWithRelations }Required
paymentRepository_Repository<Payment>Required
productVariantService_ProductVariantServiceRequired
shippingOptionService_ShippingOptionServiceRequired
transactionManager_undefined | EntityManagerRequired
EventsobjectRequired
Events.CREATEDstringRequired
Events.UPDATEDstringRequired

Accessors

activeManager_

Protected get activeManager_(): EntityManager

Returns

EntityManager

EntityManagerEntityManagerRequired

Inherited from

TransactionBaseService.activeManager_

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.

TResultobjectRequired
TErrorobjectRequired

Parameters

work(transactionManager: EntityManager) => Promise<TResult>Required
the transactional work to be done
isolationOrErrorHandlerIsolationLevel | (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>

PromisePromise<TResult>Required
the result of the transactional work

Inherited from

TransactionBaseService.atomicPhase_


create

create(data): Promise<DraftOrder>

Creates a draft order.

Parameters

data to create draft order from

Returns

Promise<DraftOrder>

PromisePromise<DraftOrder>Required
the created draft order

delete

delete(draftOrderId): Promise<undefined | DraftOrder>

Deletes draft order idempotently.

Parameters

draftOrderIdstringRequired
id of draft order to delete

Returns

Promise<undefined | DraftOrder>

PromisePromise<undefined | DraftOrder>Required
empty promise

list

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

Lists draft orders

Parameters

selectoranyRequired
query object for find
configurable attributes for find

Returns

Promise<DraftOrder[]>

PromisePromise<DraftOrder[]>Required
list of draft orders

listAndCount

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

Lists draft orders alongside the count

Parameters

selectoranyRequired
query selector to filter draft orders
query config

Returns

Promise<[DraftOrder[], number]>

PromisePromise<[DraftOrder[], number]>Required
draft orders

registerCartCompletion

registerCartCompletion(draftOrderId, orderId): Promise<UpdateResult>

Registers a draft order as completed, when an order has been completed.

Parameters

draftOrderIdstringRequired
id of draft order to complete
orderIdstringRequired
id of order completed from draft order cart

Returns

Promise<UpdateResult>

PromisePromise<UpdateResult>Required
the created order

retrieve

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

Retrieves a draft order with the given id.

Parameters

draftOrderIdstringRequired
id of the draft order to retrieve
query object for findOne

Returns

Promise<DraftOrder>

PromisePromise<DraftOrder>Required
the draft order

retrieveByCartId

retrieveByCartId(cartId, config?): Promise<DraftOrder>

Retrieves a draft order based on its associated cart id

Parameters

cartIdstringRequired
cart id that the draft orders's cart has
query object for findOne

Returns

Promise<DraftOrder>

PromisePromise<DraftOrder>Required
the draft order

shouldRetryTransaction_

Protected shouldRetryTransaction_(err): boolean

Parameters

errRecord<string, unknown> | { code: string }Required

Returns

boolean

booleanboolean

Inherited from

TransactionBaseService.shouldRetryTransaction_


update

update(id, data): Promise<DraftOrder>

Updates a draft order with the given data

Parameters

idstringRequired
id of the draft order
dataobjectRequired
values to update the order with
data.no_notification_orderbooleanRequired

Returns

Promise<DraftOrder>

PromisePromise<DraftOrder>Required
the updated draft order

withTransaction

withTransaction(transactionManager?): DraftOrderService

Parameters

transactionManagerEntityManager

Returns

DraftOrderService

DraftOrderServiceDraftOrderServiceRequired

Inherited from

TransactionBaseService.withTransaction

Was this section helpful?