Skip to main content
Skip to main content

DraftOrderService

Handles draft orders

Implements

constructor

Parameters

__namedParametersInjectedDependenciesRequired

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> & objectRequired
paymentRepository_Repository<Payment>Required
productVariantService_ProductVariantServiceRequired
shippingOptionService_ShippingOptionServiceRequired
transactionManager_undefined | EntityManagerRequired
EventsobjectRequired
Events.CREATEDstringRequired

Default: "draft_order.created"

Events.UPDATEDstringRequired

Default: "draft_order.updated"


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.

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

create

Creates a draft order.

Parameters

dataDraftOrderCreatePropsRequired
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
configFindConfig<DraftOrder>Required
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
configFindConfig<DraftOrder>Required
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
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

shouldRetryTransaction_

Parameters

errRecord<string, unknown> | objectRequired

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

DraftOrderServiceobjectRequired
Handles draft orders
Was this section helpful?