---
displayed_sidebar: servicesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# OrderService
## constructor
### Parameters
___
## Properties
`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__container__",
"type": "`any`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__moduleDeclaration__",
"type": "`Record`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "addressRepository_",
"type": "Repository<[Address](../../entities/classes/entities.Address.mdx)>",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "cartService_",
"type": "[CartService](services.CartService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customerService_",
"type": "[CustomerService](services.CustomerService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discountService_",
"type": "[DiscountService](services.DiscountService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "draftOrderService_",
"type": "[DraftOrderService](services.DraftOrderService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "eventBus_",
"type": "[EventBusService](services.EventBusService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "featureFlagRouter_",
"type": "`FlagRouter`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fulfillmentProviderService_",
"type": "[FulfillmentProviderService](services.FulfillmentProviderService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fulfillmentService_",
"type": "[FulfillmentService](services.FulfillmentService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "giftCardService_",
"type": "[GiftCardService](services.GiftCardService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "inventoryService_",
"type": "[IInventoryService](../../inventory/interfaces/inventory.IInventoryService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lineItemService_",
"type": "[LineItemService](services.LineItemService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "manager_",
"type": "`EntityManager`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "newTotalsService_",
"type": "[NewTotalsService](services.NewTotalsService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "orderRepository_",
"type": "Repository<[Order](../../entities/classes/entities.Order.mdx)> & `object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "paymentProviderService_",
"type": "[PaymentProviderService](services.PaymentProviderService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "productVariantInventoryService_",
"type": "[ProductVariantInventoryService](services.ProductVariantInventoryService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "regionService_",
"type": "[RegionService](services.RegionService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shippingOptionService_",
"type": "[ShippingOptionService](services.ShippingOptionService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shippingProfileService_",
"type": "[ShippingProfileService](services.ShippingProfileService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "taxProviderService_",
"type": "[TaxProviderService](services.TaxProviderService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "totalsService_",
"type": "[TotalsService](services.TotalsService.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.CANCELED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.canceled\"",
"expandable": false,
"children": []
},
{
"name": "Events.COMPLETED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.completed\"",
"expandable": false,
"children": []
},
{
"name": "Events.FULFILLMENT_CANCELED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.fulfillment_canceled\"",
"expandable": false,
"children": []
},
{
"name": "Events.FULFILLMENT_CREATED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.fulfillment_created\"",
"expandable": false,
"children": []
},
{
"name": "Events.GIFT_CARD_CREATED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.gift_card_created\"",
"expandable": false,
"children": []
},
{
"name": "Events.ITEMS_RETURNED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.items_returned\"",
"expandable": false,
"children": []
},
{
"name": "Events.PAYMENT_CAPTURED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.payment_captured\"",
"expandable": false,
"children": []
},
{
"name": "Events.PAYMENT_CAPTURE_FAILED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.payment_capture_failed\"",
"expandable": false,
"children": []
},
{
"name": "Events.PLACED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.placed\"",
"expandable": false,
"children": []
},
{
"name": "Events.REFUND_CREATED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.refund_created\"",
"expandable": false,
"children": []
},
{
"name": "Events.REFUND_FAILED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.refund_failed\"",
"expandable": false,
"children": []
},
{
"name": "Events.RETURN_ACTION_REQUIRED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.return_action_required\"",
"expandable": false,
"children": []
},
{
"name": "Events.RETURN_REQUESTED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.return_requested\"",
"expandable": false,
"children": []
},
{
"name": "Events.SHIPMENT_CREATED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.shipment_created\"",
"expandable": false,
"children": []
},
{
"name": "Events.SWAP_CREATED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.swap_created\"",
"expandable": false,
"children": []
},
{
"name": "Events.UPDATED",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "\"order.updated\"",
"expandable": false,
"children": []
}
]} />
___
## Accessors
### activeManager\_
#### Returns
___
## Methods
### addShippingMethod
#### Parameters
`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "config",
"type": "`CreateShippingMethodDto`",
"description": "",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
___
### archive
Archives an order. It only alloved, if the order has been fulfilled
and payment has been captured.
#### Parameters
#### 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": []
}
]} />
#### Returns
___
### cancel
Cancels an order.
Throws if fulfillment process has been initiated.
Throws if payment process has been initiated.
#### Parameters
#### Returns
___
### cancelFulfillment
Cancels a fulfillment (if related to an order)
#### Parameters
#### Returns
___
### capturePayment
Captures payment for an order.
#### Parameters
#### Returns
___
### completeOrder
#### Parameters
#### Returns
___
### createFromCart
Creates an order from a cart
#### 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": []
},
{
"name": "config.no_notification",
"type": "`boolean`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
___
### createGiftCardsFromLineItem\_
#### Parameters
#### Returns
___
### createRefund
Refunds a given amount back to the customer.
#### 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": "config.no_notification",
"type": "`boolean`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### 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
___
### decorateTotalsLegacy
#### 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": []
}
]} />
#### Returns
___
### getTotalsRelations
#### Parameters
#### Returns
___
### list
#### Parameters
#### Returns
___
### listAndCount
#### 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
___
### retrieve
Gets an order by id.
#### Parameters
#### Returns
___
### retrieveByCartId
Gets an order by cart id.
#### Parameters
#### Returns
___
### retrieveByCartIdWithTotals
#### Parameters
#### Returns
___
### retrieveByExternalId
Gets an order by id.
#### Parameters
#### Returns
___
### retrieveLegacy
#### Parameters
#### Returns
___
### retrieveWithTotals
#### Parameters
#### Returns
___
### shouldRetryTransaction\_
#### Parameters
` \\| `object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
___
### transformQueryForTotals
#### Parameters
#### 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
___
### updateBillingAddress
Updates the order's billing address.
#### Parameters
#### Returns
___
### updateShippingAddress
Updates the order's shipping address.
#### 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
___
### withTransaction
#### Parameters
#### Returns