Skip to main content
Skip to main content

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> & &#123; findOneWithRelations: Method findOneWithRelations ; findWithRelations: Method findWithRelations &#125;Required
paymentRepository_Repository<Payment>Required
productVariantService_ProductVariantServiceRequired
shippingOptionService_ShippingOptionServiceRequired
transactionManager_undefined | EntityManagerRequired
EventsobjectRequired
Events.CREATEDstringRequired
Events.UPDATEDstringRequired

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

Methods

atomicPhase_

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.

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

PromisePromise<TResult>Required
the result of the transactional work

create

Creates a draft order.

Parameters

data to create draft order from

Returns

PromisePromise<DraftOrder>Required
the created draft order

delete

Deletes draft order idempotently.

Parameters

draftOrderIdstringRequired
id of draft order to delete

Returns

PromisePromise<undefined | DraftOrder>Required
empty promise

list

Lists draft orders

Parameters

selectoranyRequired
query object for find
configurable attributes for find

Returns

PromisePromise<DraftOrder[]>Required
list of draft orders

listAndCount

Lists draft orders alongside the count

Parameters

selectoranyRequired
query selector to filter draft orders
query config

Returns

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

registerCartCompletion

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

PromisePromise<UpdateResult>Required
the created order

retrieve

Retrieves a draft order with the given id.

Parameters

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

Returns

PromisePromise<DraftOrder>Required
the draft order

retrieveByCartId

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

PromisePromise<DraftOrder>Required
the draft order

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | &#123; code: string &#125;Required

Returns

booleanboolean

update

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

PromisePromise<DraftOrder>Required
the updated draft order

withTransaction

Parameters

transactionManagerEntityManager

Returns

DraftOrderServiceDraftOrderServiceRequired
Was this section helpful?