Files
medusa-store/www/apps/docs/content/references/services/classes/OrderService.mdx
Shahed Nasser c51dce164d docs: general fixes to references (#5653)
* fixed typedoc plugin's escape strategy

* move props comments to the associated property

* regenerate references
2023-11-17 19:36:58 +02:00

2116 lines
44 KiB
Plaintext

---
displayed_sidebar: servicesSidebar
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# OrderService
## Constructors
### constructor
`**new OrderService**(«destructured»)`
#### Parameters
<ParameterTypes parameters={[
{
"name": "__namedParameters",
"type": "[InjectedDependencies](../types/InjectedDependencies-19.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
## Properties
<ParameterTypes parameters={[
{
"name": "__configModule__",
"type": "`Record<string, unknown>`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__container__",
"type": "`any`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "__moduleDeclaration__",
"type": "`Record<string, unknown>`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "addressRepository_",
"type": "Repository&#60;[Address](Address.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "cartService_",
"type": "[CartService](CartService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customerService_",
"type": "[CustomerService](CustomerService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discountService_",
"type": "[DiscountService](DiscountService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "draftOrderService_",
"type": "[DraftOrderService](DraftOrderService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "eventBus_",
"type": "[EventBusService](EventBusService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "featureFlagRouter_",
"type": "[FlagRouter](FlagRouter.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fulfillmentProviderService_",
"type": "[FulfillmentProviderService](FulfillmentProviderService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fulfillmentService_",
"type": "[FulfillmentService](FulfillmentService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "giftCardService_",
"type": "[GiftCardService](GiftCardService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "inventoryService_",
"type": "[IInventoryService](../interfaces/IInventoryService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lineItemService_",
"type": "[LineItemService](LineItemService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "manager_",
"type": "EntityManager",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "newTotalsService_",
"type": "[NewTotalsService](NewTotalsService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "orderRepository_",
"type": "Repository&#60;[Order](Order.mdx)&#62; & ``{ findOneWithRelations: Method findOneWithRelations ; findWithRelations: Method findWithRelations }``",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "paymentProviderService_",
"type": "[PaymentProviderService](PaymentProviderService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "productVariantInventoryService_",
"type": "[ProductVariantInventoryService](ProductVariantInventoryService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "regionService_",
"type": "[RegionService](RegionService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shippingOptionService_",
"type": "[ShippingOptionService](ShippingOptionService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shippingProfileService_",
"type": "[ShippingProfileService](ShippingProfileService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "taxProviderService_",
"type": "[TaxProviderService](TaxProviderService.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "totalsService_",
"type": "[TotalsService](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\_
`Protected get**activeManager_**(): EntityManager`
#### Returns
EntityManager
<ParameterTypes parameters={[
{
"name": "EntityManager",
"type": "EntityManager",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
## Methods
### addShippingMethod
`**addShippingMethod**(orderId, optionId, data?, config?): Promise&#60;[Order](Order.mdx)&#62;`
#### 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": "data",
"type": "`Record<string, unknown>`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "config",
"type": "[CreateShippingMethodDto](../types/CreateShippingMethodDto.mdx)",
"description": "",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### archive
`**archive**(orderId): Promise&#60;[Order](Order.mdx)&#62;`
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": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the result of the update operation",
"expandable": false,
"children": []
}
]} />
___
### atomicPhase\_
`Protected **atomicPhase_**<TypeParameter TResult, TypeParameter TError>(work, isolationOrErrorHandler?, maybeErrorHandlerOrDontFail?): Promise&#60;TResult&#62;`
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.
<ParameterTypes parameters={[
{
"name": "TResult",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "TError",
"type": "`object`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### 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": []
}
]} />
#### Returns
Promise&#60;TResult&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;TResult&#62;",
"optional": false,
"defaultValue": "",
"description": "the result of the transactional work",
"expandable": false,
"children": []
}
]} />
___
### cancel
`**cancel**(orderId): Promise&#60;[Order](Order.mdx)&#62;`
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": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "result of the update operation.",
"expandable": false,
"children": []
}
]} />
___
### cancelFulfillment
`**cancelFulfillment**(fulfillmentId): Promise&#60;[Order](Order.mdx)&#62;`
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": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "updated order",
"expandable": false,
"children": []
}
]} />
___
### capturePayment
`**capturePayment**(orderId): Promise&#60;[Order](Order.mdx)&#62;`
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": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "result of the update operation.",
"expandable": false,
"children": []
}
]} />
___
### completeOrder
`**completeOrder**(orderId): Promise&#60;[Order](Order.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "orderId",
"type": "`string`",
"description": "id of the order to complete",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the result of the find operation",
"expandable": false,
"children": []
}
]} />
___
### createFromCart
`**createFromCart**(cartOrId): Promise&#60;[Order](Order.mdx)&#62;`
Creates an order from a cart
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartOrId",
"type": "`string` \\| [Cart](Cart.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "resolves to the creation result.",
"expandable": false,
"children": []
}
]} />
___
### createFulfillment
`**createFulfillment**(orderId, itemsToFulfill, config?): Promise&#60;[Order](Order.mdx)&#62;`
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](../types/FulFillmentItemType.mdx)[]",
"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.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": []
},
{
"name": "config.no_notification",
"type": "`boolean`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "result of the update operation.",
"expandable": false,
"children": []
}
]} />
___
### createGiftCardsFromLineItem\_
`Protected **createGiftCardsFromLineItem_**(order, lineItem, manager): Promise&#60;[GiftCard](GiftCard.mdx)&#62;[]`
#### Parameters
<ParameterTypes parameters={[
{
"name": "order",
"type": "[Order](Order.mdx)",
"description": "An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "lineItem",
"type": "[LineItem](LineItem.mdx)",
"description": "Line Items are created when a product is added to a Cart. When Line Items are purchased they will get copied to the resulting order, swap, or claim, and can eventually be referenced in Fulfillments and Returns. Line items may also be used for order edits.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "manager",
"type": "EntityManager",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[GiftCard](GiftCard.mdx)&#62;[]
<ParameterTypes parameters={[
{
"name": "Promise&#60;GiftCard&#62;[]",
"type": "Promise&#60;[GiftCard](GiftCard.mdx)&#62;[]",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### createRefund
`**createRefund**(orderId, refundAmount, reason, note?, config?): Promise&#60;[Order](Order.mdx)&#62;`
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": "note",
"type": "`string`",
"description": "note for refund.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "config",
"type": "`object`",
"description": "the config for refund.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "config.no_notification",
"type": "`boolean`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the result of the refund operation.",
"expandable": false,
"children": []
}
]} />
___
### createShipment
`**createShipment**(orderId, fulfillmentId, trackingLinks?, config?): Promise&#60;[Order](Order.mdx)&#62;`
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": "trackingLinks",
"type": "[TrackingLink](TrackingLink.mdx)[]",
"description": "array of tracking numbers associated with the shipment",
"optional": true,
"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": "config.no_notification",
"type": "`boolean`",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the resulting order following the update.",
"expandable": false,
"children": []
}
]} />
___
### decorateTotals
`**decorateTotals**(order, totalsFields?): Promise&#60;[Order](Order.mdx)&#62;`
Calculate and attach the different total fields on the object
#### Parameters
<ParameterTypes parameters={[
{
"name": "order",
"type": "[Order](Order.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "totalsFields",
"type": "`string`[]",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
`**decorateTotals**(order, context?): Promise&#60;[Order](Order.mdx)&#62;`
Calculate and attach the different total fields on the object
#### Parameters
<ParameterTypes parameters={[
{
"name": "order",
"type": "[Order](Order.mdx)",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "context",
"type": "[TotalsContext](../types/TotalsContext.mdx)",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### decorateTotalsLegacy
`Protected **decorateTotalsLegacy**(order, totalsFields?): Promise&#60;[Order](Order.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "order",
"type": "[Order](Order.mdx)",
"description": "An order is a purchase made by a customer. It holds details about payment and fulfillment of the order. An order may also be created from a draft order, which is created by an admin user.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "totalsFields",
"type": "`string`[]",
"description": "",
"optional": false,
"defaultValue": "[]",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### getFulfillmentItems
`Protected **getFulfillmentItems**(order, items, transformer): Promise&#60;[LineItem](LineItem.mdx)[]&#62;`
Retrieves the order line items, given an array of items.
#### Parameters
<ParameterTypes parameters={[
{
"name": "order",
"type": "[Order](Order.mdx)",
"description": "the order to get line items from",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "items",
"type": "[FulFillmentItemType](../types/FulFillmentItemType.mdx)[]",
"description": "the items to get",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "transformer",
"type": "(`item`: `undefined` \\| [LineItem](LineItem.mdx), `quantity`: `number`) => `unknown`",
"description": "a function to apply to each of the items retrieved from the order, should return a line item. If the transformer returns an undefined value the line item will be filtered from the returned array.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[LineItem](LineItem.mdx)[]&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[LineItem](LineItem.mdx)[]&#62;",
"optional": false,
"defaultValue": "",
"description": "the line items generated by the transformer.",
"expandable": false,
"children": []
}
]} />
___
### getTotalsRelations
`Private **getTotalsRelations**(config): string[]`
#### Parameters
<ParameterTypes parameters={[
{
"name": "config",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Order](Order.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`string`[]
<ParameterTypes parameters={[
{
"name": "string[]",
"type": "`string`[]",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### list
`**list**(selector, config?): Promise&#60;[Order](Order.mdx)[]&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "selector",
"type": "[Selector](../types/Selector.mdx)&#60;[Order](Order.mdx)&#62;",
"description": "the query object for find",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "config",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Order](Order.mdx)&#62;",
"description": "the config to be used for find",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)[]&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)[]&#62;",
"optional": false,
"defaultValue": "",
"description": "the result of the find operation",
"expandable": false,
"children": []
}
]} />
___
### listAndCount
`**listAndCount**(selector, config?): Promise&#60;[[Order](Order.mdx)[], number]&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "selector",
"type": "[QuerySelector](../types/QuerySelector.mdx)&#60;[Order](Order.mdx)&#62;",
"description": "the query object for find",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "config",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Order](Order.mdx)&#62;",
"description": "the config to be used for find",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[[Order](Order.mdx)[], number]&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[[Order](Order.mdx)[], number]&#62;",
"optional": false,
"defaultValue": "",
"description": "the result of the find operation",
"expandable": false,
"children": []
}
]} />
___
### registerReturnReceived
`**registerReturnReceived**(orderId, receivedReturn, customRefundAmount?): Promise&#60;[Order](Order.mdx)&#62;`
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](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": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the result of the update operation",
"expandable": false,
"children": []
}
]} />
___
### retrieve
`**retrieve**(orderId, config?): Promise&#60;[Order](Order.mdx)&#62;`
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](../interfaces/FindConfig.mdx)&#60;[Order](Order.mdx)&#62;",
"description": "config of order to retrieve",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the order document",
"expandable": false,
"children": []
}
]} />
___
### retrieveByCartId
`**retrieveByCartId**(cartId, config?): Promise&#60;[Order](Order.mdx)&#62;`
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](../interfaces/FindConfig.mdx)&#60;[Order](Order.mdx)&#62;",
"description": "the config to be used to find order",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the order document",
"expandable": false,
"children": []
}
]} />
___
### retrieveByCartIdWithTotals
`**retrieveByCartIdWithTotals**(cartId, options?): Promise&#60;[Order](Order.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "cartId",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "options",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Order](Order.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### retrieveByExternalId
`**retrieveByExternalId**(externalId, config?): Promise&#60;[Order](Order.mdx)&#62;`
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](../interfaces/FindConfig.mdx)&#60;[Order](Order.mdx)&#62;",
"description": "query config to get order by",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "the order document",
"expandable": false,
"children": []
}
]} />
___
### retrieveLegacy
`Protected **retrieveLegacy**(orderIdOrSelector, config?): Promise&#60;[Order](Order.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "orderIdOrSelector",
"type": "`string` \\| [Selector](../types/Selector.mdx)&#60;[Order](Order.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "config",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Order](Order.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### retrieveWithTotals
`**retrieveWithTotals**(orderId, options?, context?): Promise&#60;[Order](Order.mdx)&#62;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "orderId",
"type": "`string`",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "options",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Order](Order.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
},
{
"name": "context",
"type": "[TotalsContext](../types/TotalsContext.mdx)",
"description": "",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### shouldRetryTransaction\_
`Protected **shouldRetryTransaction_**(err): boolean`
#### Parameters
<ParameterTypes parameters={[
{
"name": "err",
"type": "`Record<string, unknown>` \\| ``{ code: string }``",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`boolean`
<ParameterTypes parameters={[
{
"name": "boolean",
"type": "`boolean`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
___
### transformQueryForTotals
`Protected **transformQueryForTotals**(config): &#123; relations: undefined \| string[] ; select: undefined \| keyof [Order](Order.mdx)[] ; totalsToSelect: undefined \| keyof [Order](Order.mdx)[] &#125;`
#### Parameters
<ParameterTypes parameters={[
{
"name": "config",
"type": "[FindConfig](../interfaces/FindConfig.mdx)&#60;[Order](Order.mdx)&#62;",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
`object`
<ParameterTypes parameters={[
{
"name": "object",
"type": "`object`",
"optional": true,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />
<ParameterTypes parameters={[
{
"name": "relations",
"type": "`undefined` \\| `string`[]",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "select",
"type": "`undefined` \\| keyof [Order](Order.mdx)[]",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "totalsToSelect",
"type": "`undefined` \\| keyof [Order](Order.mdx)[]",
"description": "",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
___
### update
`**update**(orderId, update): Promise&#60;[Order](Order.mdx)&#62;`
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 can be casted to an ObjectId",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "update",
"type": "[UpdateOrderInput](../types/UpdateOrderInput.mdx)",
"description": "an object with the update values.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;[Order](Order.mdx)&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;[Order](Order.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "resolves to the update result.",
"expandable": false,
"children": []
}
]} />
___
### updateBillingAddress
`Protected **updateBillingAddress**(order, address): Promise&#60;void&#62;`
Updates the order's billing address.
#### Parameters
<ParameterTypes parameters={[
{
"name": "order",
"type": "[Order](Order.mdx)",
"description": "the order to update",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "address",
"type": "[Address](Address.mdx)",
"description": "the value to set the billing address to",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;void&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;void&#62;",
"optional": false,
"defaultValue": "",
"description": "the result of the update operation",
"expandable": false,
"children": []
}
]} />
___
### updateShippingAddress
`Protected **updateShippingAddress**(order, address): Promise&#60;void&#62;`
Updates the order's shipping address.
#### Parameters
<ParameterTypes parameters={[
{
"name": "order",
"type": "[Order](Order.mdx)",
"description": "the order to update",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "address",
"type": "[Address](Address.mdx)",
"description": "the value to set the shipping address to",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
Promise&#60;void&#62;
<ParameterTypes parameters={[
{
"name": "Promise",
"type": "Promise&#60;void&#62;",
"optional": false,
"defaultValue": "",
"description": "the result of the update operation",
"expandable": false,
"children": []
}
]} />
___
### validateFulfillmentLineItem
`Protected **validateFulfillmentLineItem**(item, quantity): null \| [LineItem](LineItem.mdx)`
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](LineItem.mdx)",
"description": "the line item to check has sufficient fulfillable 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": []
}
]} />
#### Returns
`null` \| [LineItem](LineItem.mdx)
<ParameterTypes parameters={[
{
"name": "null \\| LineItem",
"type": "`null` \\| [LineItem](LineItem.mdx)",
"optional": true,
"defaultValue": "",
"description": "a line item that has the requested fulfillment quantity\n set.",
"expandable": false,
"children": []
}
]} />
___
### withTransaction
`**withTransaction**(transactionManager?): [OrderService](OrderService.mdx)`
#### Parameters
<ParameterTypes parameters={[
{
"name": "transactionManager",
"type": "EntityManager",
"description": "",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]} />
#### Returns
[OrderService](OrderService.mdx)
<ParameterTypes parameters={[
{
"name": "OrderService",
"type": "[OrderService](OrderService.mdx)",
"optional": false,
"defaultValue": "",
"description": "",
"expandable": false,
"children": []
}
]} />