Files
medusa-store/www/apps/docs/content/references/services/classes/services.OrderService.mdx
Shahed Nasser bb87db8342 docs: prep for v2 documentation (#6710)
This PR includes documentation that preps for v2 docs (but doesn't introduce new docs).

_Note: The number of file changes in the PR is due to find-and-replace within the `references` which is unavoidable. Let me know if I should move it to another PR._

## Changes

- Change Medusa version in base OAS used for v2.
- Fix to docblock generator related to not catching all path parameters.
- Added typedoc plugin that generates ER Diagrams, which will be used specifically for data model references in commerce modules.
- Changed OAS tool to output references in `www/apps/api-reference/specs-v2` directory when the `--v2` option is used.
- Added a version switcher to the API reference to switch between V1 and V2. This switcher is enabled by an environment variable, so it won't be visible/usable at the moment.
- Upgraded docusaurus to v3.0.1
- Added new Vale rules to ensure correct spelling of Medusa Admin and module names.
- Added new components to the `docs-ui` package that will be used in future documentation changes.
2024-03-18 07:47:35 +00:00

433 lines
36 KiB
Plaintext

---
displayed_sidebar: servicesSidebar
---
import TypeList from "@site/src/components/TypeList"
# OrderService
## constructor
### Parameters
<TypeList types={[{"name":"__namedParameters","type":"`InjectedDependencies`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="new OrderService"/>
___
## Properties
<TypeList types={[{"name":"manager_","type":"`EntityManager`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"transactionManager_","type":"`undefined` \\| `EntityManager`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"__container__","type":"`any`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"Events","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"Events.GIFT_CARD_CREATED","type":"`string`","description":"","optional":false,"defaultValue":"\"order.gift_card_created\"","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.SHIPMENT_CREATED","type":"`string`","description":"","optional":false,"defaultValue":"\"order.shipment_created\"","expandable":false,"children":[]},{"name":"Events.FULFILLMENT_CREATED","type":"`string`","description":"","optional":false,"defaultValue":"\"order.fulfillment_created\"","expandable":false,"children":[]},{"name":"Events.FULFILLMENT_CANCELED","type":"`string`","description":"","optional":false,"defaultValue":"\"order.fulfillment_canceled\"","expandable":false,"children":[]},{"name":"Events.RETURN_REQUESTED","type":"`string`","description":"","optional":false,"defaultValue":"\"order.return_requested\"","expandable":false,"children":[]},{"name":"Events.ITEMS_RETURNED","type":"`string`","description":"","optional":false,"defaultValue":"\"order.items_returned\"","expandable":false,"children":[]},{"name":"Events.RETURN_ACTION_REQUIRED","type":"`string`","description":"","optional":false,"defaultValue":"\"order.return_action_required\"","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.SWAP_CREATED","type":"`string`","description":"","optional":false,"defaultValue":"\"order.swap_created\"","expandable":false,"children":[]},{"name":"Events.PLACED","type":"`string`","description":"","optional":false,"defaultValue":"\"order.placed\"","expandable":false,"children":[]},{"name":"Events.UPDATED","type":"`string`","description":"","optional":false,"defaultValue":"\"order.updated\"","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":"orderRepository_","type":"Repository&#60;[Order](../../entities/classes/entities.Order.mdx)&#62; & `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customerService_","type":"[CustomerService](services.CustomerService.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"paymentProviderService_","type":"[PaymentProviderService](services.PaymentProviderService.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":"discountService_","type":"[DiscountService](services.DiscountService.mdx)","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":"lineItemService_","type":"[LineItemService](services.LineItemService.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"totalsService_","type":"[TotalsService](services.TotalsService.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"newTotalsService_","type":"[NewTotalsService](services.NewTotalsService.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"taxProviderService_","type":"[TaxProviderService](services.TaxProviderService.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"regionService_","type":"[RegionService](services.RegionService.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"cartService_","type":"[CartService](services.CartService.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"addressRepository_","type":"Repository&#60;[Address](../../entities/classes/entities.Address.mdx)&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"giftCardService_","type":"[GiftCardService](services.GiftCardService.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"draftOrderService_","type":"[DraftOrderService](services.DraftOrderService.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":"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":"remoteLink_","type":"`RemoteLink`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"productVariantInventoryService_","type":"[ProductVariantInventoryService](services.ProductVariantInventoryService.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"__configModule__","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"__moduleDeclaration__","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="OrderService"/>
___
## Accessors
### activeManager\_
#### Returns
<TypeList types={[{"name":"EntityManager","type":"`EntityManager`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="activeManager_"/>
___
## Methods
### withTransaction
#### Parameters
<TypeList types={[{"name":"transactionManager","type":"`EntityManager`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="withTransaction"/>
#### Returns
<TypeList types={[{"name":"this","type":"`this`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="withTransaction"/>
### shouldRetryTransaction\_
#### Parameters
<TypeList types={[{"name":"err","type":"`Record<string, unknown>` \\| `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="shouldRetryTransaction_"/>
#### Returns
<TypeList types={[{"name":"boolean","type":"`boolean`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="shouldRetryTransaction_"/>
### 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
<TypeList types={[{"name":"TResult","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"TError","type":"`object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="atomicPhase_"/>
#### Parameters
<TypeList types={[{"name":"work","type":"(`transactionManager`: `EntityManager`) => Promise&#60;TResult&#62;","description":"the transactional work to be done","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"isolationOrErrorHandler","type":"`IsolationLevel` \\| (`error`: TError) => Promise&#60;void \\| TResult&#62;","description":"the isolation level to be used for the work.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"maybeErrorHandlerOrDontFail","type":"(`error`: TError) => Promise&#60;void \\| TResult&#62;","description":"Potential error handler","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="atomicPhase_"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;TResult&#62;","optional":false,"defaultValue":"","description":"the result of the transactional work","expandable":false,"children":[]}]} sectionTitle="atomicPhase_"/>
### list
#### Parameters
<TypeList types={[{"name":"selector","type":"[Selector](../../medusa/types/medusa.Selector.mdx)&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","description":"the query object for find","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"[FindConfig](../../medusa/interfaces/medusa.FindConfig.mdx)&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","description":"the config to be used for find","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="list"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)[]&#62;","optional":false,"defaultValue":"","description":"the result of the find operation","expandable":false,"children":[]}]} sectionTitle="list"/>
### listAndCount
#### Parameters
<TypeList types={[{"name":"selector","type":"[QuerySelector](../../medusa/types/medusa.QuerySelector.mdx)&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","description":"the query object for find","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"[FindConfig](../../medusa/interfaces/medusa.FindConfig.mdx)&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","description":"the config to be used for find","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="listAndCount"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[[Order](../../entities/classes/entities.Order.mdx)[], number]&#62;","optional":false,"defaultValue":"","description":"the result of the find operation","expandable":false,"children":[]}]} sectionTitle="listAndCount"/>
### transformQueryForTotals
#### Parameters
<TypeList types={[{"name":"config","type":"[FindConfig](../../medusa/interfaces/medusa.FindConfig.mdx)&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="transformQueryForTotals"/>
#### Returns
<TypeList types={[{"name":"relations","type":"`undefined` \\| `string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"select","type":"`undefined` \\| keyof [Order](../../entities/classes/entities.Order.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"totalsToSelect","type":"`undefined` \\| keyof [Order](../../entities/classes/entities.Order.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="transformQueryForTotals"/>
<TypeList types={[{"name":"relations","type":"`undefined` \\| `string`[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"select","type":"`undefined` \\| keyof [Order](../../entities/classes/entities.Order.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"totalsToSelect","type":"`undefined` \\| keyof [Order](../../entities/classes/entities.Order.mdx)[]","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="transformQueryForTotals"/>
### retrieve
Gets an order by id.
#### Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"id or selector of order to retrieve","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"[FindConfig](../../medusa/interfaces/medusa.FindConfig.mdx)&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","description":"config of order to retrieve","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} sectionTitle="retrieve"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"the order document","expandable":false,"children":[]}]} sectionTitle="retrieve"/>
### retrieveLegacy
#### Parameters
<TypeList types={[{"name":"orderIdOrSelector","type":"`string` \\| [Selector](../../medusa/types/medusa.Selector.mdx)&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"[FindConfig](../../medusa/interfaces/medusa.FindConfig.mdx)&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} sectionTitle="retrieveLegacy"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="retrieveLegacy"/>
### retrieveWithTotals
#### Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"[FindConfig](../../medusa/interfaces/medusa.FindConfig.mdx)&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"context","type":"`TotalsContext`","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} sectionTitle="retrieveWithTotals"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="retrieveWithTotals"/>
### retrieveByCartId
Gets an order by cart id.
#### Parameters
<TypeList types={[{"name":"cartId","type":"`string`","description":"cart id to find order","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"[FindConfig](../../medusa/interfaces/medusa.FindConfig.mdx)&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","description":"the config to be used to find order","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} sectionTitle="retrieveByCartId"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"the order document","expandable":false,"children":[]}]} sectionTitle="retrieveByCartId"/>
### retrieveByCartIdWithTotals
#### Parameters
<TypeList types={[{"name":"cartId","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"options","type":"[FindConfig](../../medusa/interfaces/medusa.FindConfig.mdx)&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} sectionTitle="retrieveByCartIdWithTotals"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="retrieveByCartIdWithTotals"/>
### retrieveByExternalId
Gets an order by id.
#### Parameters
<TypeList types={[{"name":"externalId","type":"`string`","description":"id of order to retrieve","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"[FindConfig](../../medusa/interfaces/medusa.FindConfig.mdx)&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","description":"query config to get order by","optional":false,"defaultValue":"{}","expandable":false,"children":[]}]} sectionTitle="retrieveByExternalId"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"the order document","expandable":false,"children":[]}]} sectionTitle="retrieveByExternalId"/>
### completeOrder
#### Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"id of the order to complete","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="completeOrder"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"the result of the find operation","expandable":false,"children":[]}]} sectionTitle="completeOrder"/>
### createFromCart
Creates an order from a cart
#### Parameters
<TypeList types={[{"name":"cartOrId","type":"`string` \\| [Cart](../../entities/classes/entities.Cart.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="createFromCart"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"resolves to the creation result.","expandable":false,"children":[]}]} sectionTitle="createFromCart"/>
### createGiftCardsFromLineItem\_
#### Parameters
<TypeList types={[{"name":"order","type":"[Order](../../entities/classes/entities.Order.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"lineItem","type":"[LineItem](../../entities/classes/entities.LineItem.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"manager","type":"`EntityManager`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="createGiftCardsFromLineItem_"/>
#### Returns
<TypeList types={[{"name":"Promise&#60;GiftCard&#62;[]","type":"Promise&#60;[GiftCard](../../entities/classes/entities.GiftCard.mdx)&#62;[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="createGiftCardsFromLineItem_"/>
### 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
<TypeList types={[{"name":"orderId","type":"`string`","description":"the id of the order that has been shipped","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"fulfillmentId","type":"`string`","description":"the fulfillment that has now been shipped","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"`object`","description":"the config of the order that has been shipped","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config.metadata","type":"`Record<string, unknown>`","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
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"the resulting order following the update.","expandable":false,"children":[]}]} sectionTitle="createShipment"/>
### updateBillingAddress
Updates the order's billing address.
#### Parameters
<TypeList types={[{"name":"order","type":"[Order](../../entities/classes/entities.Order.mdx)","description":"the order to update","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address","type":"[Address](../../entities/classes/entities.Address.mdx)","description":"the value to set the billing address to","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="updateBillingAddress"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;void&#62;","optional":false,"defaultValue":"","description":"the result of the update operation","expandable":false,"children":[]}]} sectionTitle="updateBillingAddress"/>
### updateShippingAddress
Updates the order's shipping address.
#### Parameters
<TypeList types={[{"name":"order","type":"[Order](../../entities/classes/entities.Order.mdx)","description":"the order to update","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"address","type":"[Address](../../entities/classes/entities.Address.mdx)","description":"the value to set the shipping address to","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="updateShippingAddress"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;void&#62;","optional":false,"defaultValue":"","description":"the result of the update operation","expandable":false,"children":[]}]} sectionTitle="updateShippingAddress"/>
### addShippingMethod
#### Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"optionId","type":"`string`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"`CreateShippingMethodDto`","description":"","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"data","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="addShippingMethod"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="addShippingMethod"/>
### 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
<TypeList types={[{"name":"orderId","type":"`string`","description":"the id of the order. Must be a string that\n can be casted to an ObjectId","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"update","type":"`UpdateOrderInput`","description":"an object with the update values.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="update"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"resolves to the update result.","expandable":false,"children":[]}]} sectionTitle="update"/>
### cancel
Cancels an order.
Throws if fulfillment process has been initiated.
Throws if payment process has been initiated.
#### Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"id of order to cancel.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="cancel"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"result of the update operation.","expandable":false,"children":[]}]} sectionTitle="cancel"/>
### capturePayment
Captures payment for an order.
#### Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"id of order to capture payment for.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="capturePayment"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"result of the update operation.","expandable":false,"children":[]}]} sectionTitle="capturePayment"/>
### 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
<TypeList types={[{"name":"item","type":"[LineItem](../../entities/classes/entities.LineItem.mdx)","description":"the line item to check has sufficient fulfillable\n quantity.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"quantity","type":"`number`","description":"the quantity that is requested to be fulfilled.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="validateFulfillmentLineItem"/>
#### Returns
<TypeList types={[{"name":"null \\| LineItem","type":"`null` \\| [LineItem](../../entities/classes/entities.LineItem.mdx)","optional":false,"defaultValue":"","description":"a line item that has the requested fulfillment quantity\n set.","expandable":false,"children":[]}]} sectionTitle="validateFulfillmentLineItem"/>
### 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
<TypeList types={[{"name":"orderId","type":"`string`","description":"id of order to fulfil.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"itemsToFulfill","type":"`FulFillmentItemType`[]","description":"items to fulfil.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"`object`","description":"the config to fulfil.","optional":false,"defaultValue":"{}","expandable":false,"children":[]},{"name":"config.no_notification","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"config.location_id","type":"`string`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"config.metadata","type":"`Record<string, unknown>`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="createFulfillment"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"result of the update operation.","expandable":false,"children":[]}]} sectionTitle="createFulfillment"/>
### cancelFulfillment
Cancels a fulfillment (if related to an order)
#### Parameters
<TypeList types={[{"name":"fulfillmentId","type":"`string`","description":"the ID of the fulfillment to cancel","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="cancelFulfillment"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"updated order","expandable":false,"children":[]}]} sectionTitle="cancelFulfillment"/>
### getFulfillmentItems
Retrieves the order line items, given an array of items.
#### Parameters
<TypeList types={[{"name":"order","type":"[Order](../../entities/classes/entities.Order.mdx)","description":"the order to get line items from","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"items","type":"`FulFillmentItemType`[]","description":"the items to get","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"transformer","type":"(`item`: `undefined` \\| [LineItem](../../entities/classes/entities.LineItem.mdx), `quantity`: `number`) => `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
<TypeList types={[{"name":"Promise","type":"Promise&#60;[LineItem](../../entities/classes/entities.LineItem.mdx)[]&#62;","optional":false,"defaultValue":"","description":"the line items generated by the transformer.","expandable":false,"children":[]}]} sectionTitle="getFulfillmentItems"/>
### archive
Archives an order. It only alloved, if the order has been fulfilled
and payment has been captured.
#### Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"the order to archive","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="archive"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"the result of the update operation","expandable":false,"children":[]}]} sectionTitle="archive"/>
### createRefund
Refunds a given amount back to the customer.
#### Parameters
<TypeList types={[{"name":"orderId","type":"`string`","description":"id of the order to refund.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"refundAmount","type":"`number`","description":"the amount to refund.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"reason","type":"`string`","description":"the reason to refund.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"config","type":"`object`","description":"the config for refund.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"note","type":"`string`","description":"note for refund.","optional":true,"defaultValue":"","expandable":false,"children":[]},{"name":"config.no_notification","type":"`boolean`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="createRefund"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"the result of the refund operation.","expandable":false,"children":[]}]} sectionTitle="createRefund"/>
### decorateTotalsLegacy
#### Parameters
<TypeList types={[{"name":"order","type":"[Order](../../entities/classes/entities.Order.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"totalsFields","type":"`string`[]","description":"","optional":false,"defaultValue":"[]","expandable":false,"children":[]}]} sectionTitle="decorateTotalsLegacy"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="decorateTotalsLegacy"/>
### decorateTotals
`**decorateTotals**(order, totalsFields?): Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;`
Calculate and attach the different total fields on the object
#### Parameters
<TypeList types={[{"name":"order","type":"[Order](../../entities/classes/entities.Order.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"totalsFields","type":"`string`[]","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="decorateTotals"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"Calculate and attach the different total fields on the object","expandable":false,"children":[]}]} sectionTitle="decorateTotals"/>
`**decorateTotals**(order, context?): Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;`
Calculate and attach the different total fields on the object
#### Parameters
<TypeList types={[{"name":"order","type":"[Order](../../entities/classes/entities.Order.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"context","type":"`TotalsContext`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="decorateTotals"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"Calculate and attach the different total fields on the object","expandable":false,"children":[]}]} sectionTitle="decorateTotals"/>
### 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
<TypeList types={[{"name":"orderId","type":"`string`","description":"the order to return.","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"receivedReturn","type":"[Return](../../entities/classes/entities.Return.mdx)","description":"the received return","optional":false,"defaultValue":"","expandable":false,"children":[]},{"name":"customRefundAmount","type":"`number`","description":"the custom refund amount return","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="registerReturnReceived"/>
#### Returns
<TypeList types={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"the result of the update operation","expandable":false,"children":[]}]} sectionTitle="registerReturnReceived"/>
### getTotalsRelations
#### Parameters
<TypeList types={[{"name":"config","type":"[FindConfig](../../medusa/interfaces/medusa.FindConfig.mdx)&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="getTotalsRelations"/>
#### Returns
<TypeList types={[{"name":"string[]","type":"`string`[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="getTotalsRelations"/>