Files
medusa-store/www/apps/docs/content/references/services/classes/services.OrderService.mdx
github-actions[bot] 5a550e73b4 chore(docs): Generated References (#6222)
Generated the following references:
- `entities`
- `file`
- `fulfillment`
- `inventory`
- `js_client`
- `medusa`
- `medusa_config`
- `medusa_react`
- `modules`
- `notification`
- `payment`
- `price_selection`
- `pricing`
- `product`
- `search`
- `services`
- `stock_location`
- `tax`
- `tax_calculation`
- `types`
- `workflows`

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
2024-01-25 18:12:27 +00:00

433 lines
37 KiB
Plaintext

---
displayed_sidebar: servicesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# OrderService
## constructor
### Parameters
<ParameterTypes parameters={[{"name":"__namedParameters","type":"`InjectedDependencies`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="new OrderService"/>
___
## Properties
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"name":"EntityManager","type":"`EntityManager`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="activeManager_"/>
___
## Methods
### withTransaction
#### Parameters
<ParameterTypes parameters={[{"name":"transactionManager","type":"`EntityManager`","description":"","optional":true,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="withTransaction"/>
#### Returns
<ParameterTypes parameters={[{"name":"this","type":"`this`","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="withTransaction"/>
### shouldRetryTransaction\_
#### Parameters
<ParameterTypes parameters={[{"name":"err","type":"`Record<string, unknown>` \\| `object`","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="shouldRetryTransaction_"/>
#### Returns
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;TResult&#62;","optional":false,"defaultValue":"","description":"the result of the transactional work","expandable":false,"children":[]}]} sectionTitle="atomicPhase_"/>
### list
#### Parameters
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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"/>
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;[Order](../../entities/classes/entities.Order.mdx)&#62;","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="retrieveLegacy"/>
### retrieveWithTotals
#### Parameters
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"name":"orderId","type":"`string`","description":"id of the order to complete","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="completeOrder"/>
#### Returns
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"name":"cartOrId","type":"`string` \\| [Cart](../../entities/classes/entities.Cart.mdx)","description":"","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="createFromCart"/>
#### Returns
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"name":"Promise","type":"Promise&#60;void&#62;","optional":false,"defaultValue":"","description":"the result of the update operation","expandable":false,"children":[]}]} sectionTitle="updateShippingAddress"/>
### addShippingMethod
#### Parameters
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"name":"orderId","type":"`string`","description":"id of order to cancel.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="cancel"/>
#### Returns
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"name":"orderId","type":"`string`","description":"id of order to capture payment for.","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="capturePayment"/>
#### Returns
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"name":"fulfillmentId","type":"`string`","description":"the ID of the fulfillment to cancel","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="cancelFulfillment"/>
#### Returns
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"name":"orderId","type":"`string`","description":"the order to archive","optional":false,"defaultValue":"","expandable":false,"children":[]}]} sectionTitle="archive"/>
#### Returns
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"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
<ParameterTypes parameters={[{"name":"string[]","type":"`string`[]","optional":false,"defaultValue":"","description":"","expandable":false,"children":[]}]} sectionTitle="getTotalsRelations"/>