---
displayed_sidebar: servicesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# DraftOrderService
Handles draft orders
#### Implements
## Constructors
### constructor
**new DraftOrderService**(`«destructured»`)
#### Parameters
## Properties
",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__container__",
"type": "`any`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__moduleDeclaration__",
"type": "Record<`string`, `unknown`\\>",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "cartService_",
"type": "[`CartService`](CartService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customShippingOptionService_",
"type": "[`CustomShippingOptionService`](CustomShippingOptionService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "draftOrderRepository_",
"type": "`Repository`<[`DraftOrder`](DraftOrder.mdx)\\>",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "eventBus_",
"type": "[`EventBusService`](EventBusService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lineItemService_",
"type": "[`LineItemService`](LineItemService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "manager_",
"type": "`EntityManager`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "orderRepository_",
"type": "`Repository`<[`Order`](Order.mdx)\\> & { `findOneWithRelations`: Method findOneWithRelations ; `findWithRelations`: Method findWithRelations }",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "paymentRepository_",
"type": "`Repository`<[`Payment`](Payment.mdx)\\>",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "productVariantService_",
"type": "[`ProductVariantService`](ProductVariantService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shippingOptionService_",
"type": "[`ShippingOptionService`](ShippingOptionService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "transactionManager_",
"type": "`undefined` \\| `EntityManager`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "Events",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "Events.CREATED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"draft_order.created\"",
"expandable": false,
"children": []
},
{
"name": "Events.UPDATED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"draft_order.updated\"",
"expandable": false,
"children": []
}
]} />
## Accessors
### activeManager\_
`Protected` `get` **activeManager_**(): `EntityManager`
#### Returns
`EntityManager`
## 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.
#### Parameters
`Promise`<`TResult`\\>",
"description": "the transactional work to be done",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "isolationOrErrorHandler",
"type": "`IsolationLevel` \\| (`error`: `TError`) => `Promise`<`void` \\| `TResult`\\>",
"description": "the isolation level to be used for the work.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "maybeErrorHandlerOrDontFail",
"type": "(`error`: `TError`) => `Promise`<`void` \\| `TResult`\\>",
"description": "Potential error handler",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`Promise`<`TResult`\>
",
"optional": false,
"defaultValue": "",
"description": "the result of the transactional work",
"expandable": false,
"children": []
}
]} />
___
### create
**create**(`data`): `Promise`<[`DraftOrder`](DraftOrder.mdx)\>
Creates a draft order.
#### Parameters
#### Returns
`Promise`<[`DraftOrder`](DraftOrder.mdx)\>
",
"optional": false,
"defaultValue": "",
"description": "the created draft order",
"expandable": false,
"children": []
}
]} />
___
### delete
**delete**(`draftOrderId`): `Promise`<`undefined` \| [`DraftOrder`](DraftOrder.mdx)\>
Deletes draft order idempotently.
#### Parameters
#### Returns
`Promise`<`undefined` \| [`DraftOrder`](DraftOrder.mdx)\>
",
"optional": false,
"defaultValue": "",
"description": "empty promise",
"expandable": false,
"children": []
}
]} />
___
### list
**list**(`selector`, `config?`): `Promise`<[`DraftOrder`](DraftOrder.mdx)[]\>
Lists draft orders
#### Parameters
",
"description": "configurable attributes for find",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`Promise`<[`DraftOrder`](DraftOrder.mdx)[]\>
",
"optional": false,
"defaultValue": "",
"description": "list of draft orders",
"expandable": false,
"children": []
}
]} />
___
### listAndCount
**listAndCount**(`selector`, `config?`): `Promise`<[[`DraftOrder`](DraftOrder.mdx)[], `number`]\>
Lists draft orders alongside the count
#### Parameters
",
"description": "query config",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`Promise`<[[`DraftOrder`](DraftOrder.mdx)[], `number`]\>
",
"optional": false,
"defaultValue": "",
"description": "draft orders",
"expandable": false,
"children": []
}
]} />
___
### registerCartCompletion
**registerCartCompletion**(`draftOrderId`, `orderId`): `Promise`<`UpdateResult`\>
Registers a draft order as completed, when an order has been completed.
#### Parameters
#### Returns
`Promise`<`UpdateResult`\>
",
"optional": false,
"defaultValue": "",
"description": "the created order",
"expandable": false,
"children": []
}
]} />
___
### retrieve
**retrieve**(`draftOrderId`, `config?`): `Promise`<[`DraftOrder`](DraftOrder.mdx)\>
Retrieves a draft order with the given id.
#### Parameters
",
"description": "query object for findOne",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
`Promise`<[`DraftOrder`](DraftOrder.mdx)\>
",
"optional": false,
"defaultValue": "",
"description": "the draft order",
"expandable": false,
"children": []
}
]} />
___
### retrieveByCartId
**retrieveByCartId**(`cartId`, `config?`): `Promise`<[`DraftOrder`](DraftOrder.mdx)\>
Retrieves a draft order based on its associated cart id
#### Parameters
",
"description": "query object for findOne",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
`Promise`<[`DraftOrder`](DraftOrder.mdx)\>
",
"optional": false,
"defaultValue": "",
"description": "the draft order",
"expandable": false,
"children": []
}
]} />
___
### shouldRetryTransaction\_
`Protected` **shouldRetryTransaction_**(`err`): `boolean`
#### Parameters
\\| { `code`: `string` }",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`boolean`
___
### update
**update**(`id`, `data`): `Promise`<[`DraftOrder`](DraftOrder.mdx)\>
Updates a draft order with the given data
#### Parameters
#### Returns
`Promise`<[`DraftOrder`](DraftOrder.mdx)\>
",
"optional": false,
"defaultValue": "",
"description": "the updated draft order",
"expandable": false,
"children": []
}
]} />
___
### withTransaction
**withTransaction**(`transactionManager?`): [`DraftOrderService`](DraftOrderService.mdx)
#### Parameters
#### Returns
[`DraftOrderService`](DraftOrderService.mdx)