Skip to main content
Skip to main content

DraftOrderService

Handles draft orders

Implements

constructor

Parameters

__namedParametersInjectedDependenciesRequired

Properties

manager_EntityManagerRequired
transactionManager_undefined | EntityManagerRequired
__container__anyRequired
EventsobjectRequired
Events.CREATEDstringRequired

Default: "draft_order.created"

Events.UPDATEDstringRequired

Default: "draft_order.updated"

draftOrderRepository_Repository<DraftOrder>Required
paymentRepository_Repository<Payment>Required
orderRepository_Repository<Order> & objectRequired
eventBus_EventBusServiceRequired
cartService_CartServiceRequired
lineItemService_LineItemServiceRequired
productVariantService_ProductVariantServiceRequired
shippingOptionService_ShippingOptionServiceRequired
customShippingOptionService_CustomShippingOptionServiceRequired
__configModule__Record<string, unknown>
__moduleDeclaration__Record<string, unknown>

Accessors

activeManager_

Returns

EntityManagerEntityManagerRequired

Methods

withTransaction

Parameters

transactionManagerEntityManager

Returns

thisthisRequired

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

Returns

booleanbooleanRequired

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.

Type Parameters

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

PromisePromise<TResult>Required
the result of the transactional work

retrieve

Retrieves a draft order with the given id.

Parameters

draftOrderIdstringRequired
id of the draft order to retrieve
configFindConfig<DraftOrder>Required
query object for findOne

Default: {}

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
configFindConfig<DraftOrder>Required
query object for findOne

Default: {}

Returns

PromisePromise<DraftOrder>Required
the draft order

delete

Deletes draft order idempotently.

Parameters

draftOrderIdstringRequired
id of draft order to delete

Returns

PromisePromise<undefined | DraftOrder>Required
empty promise

listAndCount

Lists draft orders alongside the count

Parameters

selectoranyRequired
query selector to filter draft orders
configFindConfig<DraftOrder>Required
query config

Returns

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

list

Lists draft orders

Parameters

selectoranyRequired
query object for find
configFindConfig<DraftOrder>Required
configurable attributes for find

Returns

PromisePromise<DraftOrder[]>Required
list of draft orders

create

Creates a draft order.

Parameters

dataDraftOrderCreatePropsRequired
data to create draft order from

Returns

PromisePromise<DraftOrder>Required
the created draft order

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

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
Was this section helpful?