---
displayed_sidebar: servicesSidebar
---
import TypeList from "@site/src/components/TypeList"
# OrderService
## constructor
### Parameters
___
## Properties
`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"__moduleDeclaration__","type":"`Record`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="OrderService"/>
___
## Accessors
### activeManager\_
#### Returns
___
## Methods
### withTransaction
#### Parameters
#### Returns
### shouldRetryTransaction\_
#### Parameters
` \\| `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="shouldRetryTransaction_"/>
#### Returns
### 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
#### 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":[]}]} sectionTitle="atomicPhase_"/>
#### Returns
### list
#### Parameters
#### Returns
### listAndCount
#### Parameters
#### Returns
### transformQueryForTotals
#### Parameters
#### Returns
### retrieve
Gets an order by id.
#### Parameters
#### Returns
### retrieveLegacy
#### Parameters
#### Returns
### retrieveWithTotals
#### Parameters
#### Returns
### retrieveByCartId
Gets an order by cart id.
#### Parameters
#### Returns
### retrieveByCartIdWithTotals
#### Parameters
#### Returns
### retrieveByExternalId
Gets an order by id.
#### Parameters
#### Returns
### completeOrder
#### Parameters
#### Returns
### createFromCart
Creates an order from a cart
#### Parameters
#### Returns
### createGiftCardsFromLineItem\_
#### Parameters
#### Returns
### createShipment
Adds a shipment to the order to indicate that an order has left the
warehouse. Will ask the fulfillment provider for any documents that may
have been created in regards to the shipment.
#### Parameters
`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"trackingLinks","type":"[TrackingLink](../../entities/classes/entities.TrackingLink.mdx)[]","description":"array of tracking numbers associated with the shipment","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"config.no_notification","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="createShipment"/>
#### Returns
### updateBillingAddress
Updates the order's billing address.
#### Parameters
#### Returns
### updateShippingAddress
Updates the order's shipping address.
#### Parameters
#### Returns
### addShippingMethod
#### Parameters
`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="addShippingMethod"/>
#### Returns
### update
Updates an order. Metadata updates should
use dedicated method, e.g. `setMetadata` etc. The function
will throw errors if metadata updates are attempted.
#### Parameters
#### Returns
### cancel
Cancels an order.
Throws if fulfillment process has been initiated.
Throws if payment process has been initiated.
#### Parameters
#### Returns
### capturePayment
Captures payment for an order.
#### Parameters
#### Returns
### validateFulfillmentLineItem
Checks that a given quantity of a line item can be fulfilled. Fails if the
fulfillable quantity is lower than the requested fulfillment quantity.
Fulfillable quantity is calculated by subtracting the already fulfilled
quantity from the quantity that was originally purchased.
#### Parameters
#### Returns
### createFulfillment
Creates fulfillments for an order.
In a situation where the order has more than one shipping method,
we need to partition the order items, such that they can be sent
to their respective fulfillment provider.
#### Parameters
`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="createFulfillment"/>
#### Returns
### cancelFulfillment
Cancels a fulfillment (if related to an order)
#### Parameters
#### Returns
### getFulfillmentItems
Retrieves the order line items, given an array of items.
#### Parameters
`unknown`","description":"a function to apply to each of the items\n retrieved from the order, should return a line item. If the transformer\n returns an undefined value the line item will be filtered from the\n returned array.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="getFulfillmentItems"/>
#### Returns
### archive
Archives an order. It only alloved, if the order has been fulfilled
and payment has been captured.
#### Parameters
#### Returns
### createRefund
Refunds a given amount back to the customer.
#### Parameters
#### Returns
### decorateTotalsLegacy
#### Parameters
#### Returns
### decorateTotals
`**decorateTotals**(order, totalsFields?): Promise<[Order](../../entities/classes/entities.Order.mdx)>`
Calculate and attach the different total fields on the object
#### Parameters
#### Returns
`**decorateTotals**(order, context?): Promise<[Order](../../entities/classes/entities.Order.mdx)>`
Calculate and attach the different total fields on the object
#### Parameters
#### Returns
### registerReturnReceived
Handles receiving a return. This will create a
refund to the customer. If the returned items don't match the requested
items the return status will be updated to requires\_action. This behaviour
is useful in situations where a custom refund amount is requested, but the
returned items are not matching the requested items. Setting the
allowMismatch argument to true, will process the return, ignoring any
mismatches.
#### Parameters
#### Returns
### getTotalsRelations
#### Parameters
#### Returns