Files
medusa-store/www/apps/docs/content/references/js-client/classes/OrdersResource.mdx
Shahed Nasser c6dff873de docs: update docusaurus to v3 (#5625)
* update dependencies

* update onboarding mdx

* fixes for mdx issues

* fixes for mdx compatibility

* resolve mdx errors

* fixes in reference

* fix check errors

* revert change in vale action

* fix node version in action

* fix summary in markdown
2023-11-13 20:11:50 +02:00

1954 lines
68 KiB
Plaintext

---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/OrdersResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# OrdersResource
This class is used to send requests to [Store Order API Routes](https://docs.medusajs.com/api/store#orders). All its method
are available in the JS Client under the `medusa.orders` property.
Orders are purchases made by customers, typically through a storefront.
Orders are placed and created using [CartsResource](CartsResource.mdx). The methods in this class allow retrieving and claiming orders.
Related Guide: [How to retrieve order details in a storefront](https://docs.medusajs.com/modules/orders/storefront/retrieve-order-details).
## Methods
### confirmRequest
Verify the claim order token provided to the customer when they request ownership of an order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.orders
.confirmRequest(token)
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "payload",
"type": "[StorePostCustomersCustomerAcceptClaimReq](../internal/classes/internal.StorePostCustomersCustomerAcceptClaimReq.mdx)",
"description": "The claim order to verify.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "token",
"type": "`string`",
"description": "The claim token generated by previous request to the Claim Order API Route.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)",
"optional": false,
"defaultValue": "",
"description": "Resolves when the claim order is verified successfully.",
"expandable": false,
"children": []
}
]} />
___
### lookupOrder
Look up an order using filters. If the filters don't narrow down the results to a single order, a `404` response is returned with no orders.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.orders
.lookupOrder({
display_id: 1,
email: "user@example.com",
})
.then(({ order }) => {
console.log(order.id)
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "payload",
"type": "[StoreGetOrdersParams](../internal/classes/internal.StoreGetOrdersParams.mdx)",
"description": "Filters used to retrieve the order.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "display_id",
"type": "`number`",
"description": "Display ID of the order.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "email",
"type": "`string`",
"description": "Email of the order.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "expand",
"type": "`string`",
"description": "Comma-separated relations that should be expanded in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fields",
"type": "`string`",
"description": "Comma-separated fields that should be included in the returned data.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shipping_address",
"type": "[ShippingAddressPayload](../internal/classes/internal.ShippingAddressPayload.mdx)",
"description": "Filter the retrieved order by its shipping address details.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "postal_code",
"type": "`string`",
"description": "Postal code.",
"optional": true,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[StoreOrdersRes](../internal/types/internal.StoreOrdersRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the details of the order.",
"expandable": false,
"children": [
{
"name": "StoreOrdersRes",
"type": "`object`",
"description": "The order's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "order",
"type": "[Order](../internal/classes/internal.Order.mdx)",
"description": "Order details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "billing_address",
"type": "[Address](../internal/classes/internal.Address.mdx)",
"description": "The details of the billing address associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "billing_address_id",
"type": "`string`",
"description": "The ID of the billing address associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "canceled_at",
"type": "`Date`",
"description": "The date the order was canceled on.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "cart",
"type": "[Cart](../internal/classes/internal.Cart.mdx)",
"description": "The details of the cart associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "cart_id",
"type": "`string`",
"description": "The ID of the cart associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "claims",
"type": "[ClaimOrder](../internal/classes/internal.ClaimOrder.mdx)[]",
"description": "The details of the claims created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "currency",
"type": "[Currency](../internal/classes/internal.Currency.mdx)",
"description": "The details of the currency used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "currency_code",
"type": "`string`",
"description": "The 3 character currency code that is used in the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customer",
"type": "[Customer](../internal/classes/internal.Customer.mdx)",
"description": "The details of the customer associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "customer_id",
"type": "`string`",
"description": "The ID of the customer associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discount_total",
"type": "`number`",
"description": "The total of discount rounded",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discounts",
"type": "[Discount](../internal/classes/internal.Discount-1.mdx)[]",
"description": "The details of the discounts applied on the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "display_id",
"type": "`number`",
"description": "The order's display ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "draft_order",
"type": "[DraftOrder](../internal/classes/internal.DraftOrder.mdx)",
"description": "The details of the draft order this order was created from.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "draft_order_id",
"type": "`string`",
"description": "The ID of the draft order this order was created from.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "edits",
"type": "[OrderEdit](../internal/classes/internal.OrderEdit.mdx)[]",
"description": "The details of the order edits done on the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "email",
"type": "`string`",
"description": "The email associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "external_id",
"type": "``null`` \\| `string`",
"description": "The ID of an external order.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fulfillment_status",
"type": "[FulfillmentStatus](../internal/enums/internal.FulfillmentStatus.mdx)",
"description": "The order's fulfillment status",
"optional": false,
"defaultValue": "not_fulfilled",
"expandable": false,
"children": []
},
{
"name": "fulfillments",
"type": "[Fulfillment](../internal/classes/internal.Fulfillment.mdx)[]",
"description": "The details of the fulfillments created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "gift_card_tax_total",
"type": "`number`",
"description": "The total of gift cards with taxes",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gift_card_total",
"type": "`number`",
"description": "The total of gift cards",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gift_card_transactions",
"type": "[GiftCardTransaction](../internal/classes/internal.GiftCardTransaction.mdx)[]",
"description": "The gift card transactions made in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "gift_cards",
"type": "[GiftCard](../internal/classes/internal.GiftCard-1.mdx)[]",
"description": "The details of the gift card used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The order's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "idempotency_key",
"type": "`string`",
"description": "Randomly generated key used to continue the processing of the order in case of failure.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "item_tax_total",
"type": "``null`` \\| `number`",
"description": "The tax total applied on items",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "items",
"type": "[LineItem](../internal/classes/internal.LineItem.mdx)[]",
"description": "The details of the line items that belong to the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "no_notification",
"type": "`boolean`",
"description": "Flag for describing whether or not notifications related to this should be send.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "paid_total",
"type": "`number`",
"description": "The total amount paid",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payment_status",
"type": "[PaymentStatus](../internal/enums/internal.PaymentStatus.mdx)",
"description": "The order's payment status",
"optional": false,
"defaultValue": "not_paid",
"expandable": false,
"children": []
},
{
"name": "payments",
"type": "[Payment](../internal/classes/internal.Payment.mdx)[]",
"description": "The details of the payments used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "raw_discount_total",
"type": "`number`",
"description": "The total of discount",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "refundable_amount",
"type": "`number`",
"description": "The amount that can be refunded",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "refunded_total",
"type": "`number`",
"description": "The total amount refunded if the order is returned.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "refunds",
"type": "[Refund](../internal/classes/internal.Refund.mdx)[]",
"description": "The details of the refunds created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region",
"type": "[Region](../internal/classes/internal.Region.mdx)",
"description": "The details of the region this order was created in.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region_id",
"type": "`string`",
"description": "The ID of the region this order was created in.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "returnable_items",
"type": "[LineItem](../internal/classes/internal.LineItem.mdx)[]",
"description": "The details of the line items that are returnable as part of the order, swaps, or claims",
"optional": true,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "returns",
"type": "[Return](../internal/classes/internal.Return.mdx)[]",
"description": "The details of the returns created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "sales_channel",
"type": "[SalesChannel](../internal/classes/internal.SalesChannel.mdx)",
"description": "The details of the sales channel this order belongs to.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "sales_channel_id",
"type": "``null`` \\| `string`",
"description": "The ID of the sales channel this order belongs to.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shipping_address",
"type": "[Address](../internal/classes/internal.Address.mdx)",
"description": "The details of the shipping address associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "shipping_address_id",
"type": "`string`",
"description": "The ID of the shipping address associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shipping_methods",
"type": "[ShippingMethod](../internal/classes/internal.ShippingMethod-4.mdx)[]",
"description": "The details of the shipping methods used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "shipping_tax_total",
"type": "``null`` \\| `number`",
"description": "The tax total applied on shipping",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shipping_total",
"type": "`number`",
"description": "The total of shipping",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "status",
"type": "[OrderStatus](../internal/enums/internal.OrderStatus.mdx)",
"description": "The order's status",
"optional": false,
"defaultValue": "pending",
"expandable": false,
"children": []
},
{
"name": "subtotal",
"type": "`number`",
"description": "The subtotal of the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "swaps",
"type": "[Swap](../internal/classes/internal.Swap.mdx)[]",
"description": "The details of the swaps created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "tax_rate",
"type": "``null`` \\| `number`",
"description": "The order's tax rate",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_total",
"type": "``null`` \\| `number`",
"description": "The total of tax",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "total",
"type": "`number`",
"description": "The total amount of the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
### requestCustomerOrders
Allow the logged-in customer to claim ownership of one or more orders. This generates a token that can be used later on to verify the claim using the [confirmRequest](OrdersResource.mdx#confirmrequest) method.
This also emits the event `order-update-token.created`. So, if you have a notification provider installed that handles this event and sends the customer a notification, such as an email,
the customer should receive instructions on how to finalize their claim ownership.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged in or use api token
medusa.orders
.requestCustomerOrders({
order_ids,
})
.then(() => {
// successful
})
.catch(() => {
// an error occurred
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "payload",
"type": "[StorePostCustomersCustomerOrderClaimReq](../internal/classes/internal.StorePostCustomersCustomerOrderClaimReq.mdx)",
"description": "The orders to claim.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "order_ids",
"type": "`string`[]",
"description": "The ID of the orders to claim",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)",
"optional": false,
"defaultValue": "",
"description": "Resolves when the request is created successfully.",
"expandable": false,
"children": []
}
]} />
___
### retrieve
Retrieve an Order's details.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.orders.retrieve(orderId).then(({ order }) => {
console.log(order.id)
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "id",
"type": "`string`",
"description": "The order's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[StoreOrdersRes](../internal/types/internal.StoreOrdersRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the details of the order.",
"expandable": false,
"children": [
{
"name": "StoreOrdersRes",
"type": "`object`",
"description": "The order's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "order",
"type": "[Order](../internal/classes/internal.Order.mdx)",
"description": "Order details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "billing_address",
"type": "[Address](../internal/classes/internal.Address.mdx)",
"description": "The details of the billing address associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "billing_address_id",
"type": "`string`",
"description": "The ID of the billing address associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "canceled_at",
"type": "`Date`",
"description": "The date the order was canceled on.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "cart",
"type": "[Cart](../internal/classes/internal.Cart.mdx)",
"description": "The details of the cart associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "cart_id",
"type": "`string`",
"description": "The ID of the cart associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "claims",
"type": "[ClaimOrder](../internal/classes/internal.ClaimOrder.mdx)[]",
"description": "The details of the claims created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "currency",
"type": "[Currency](../internal/classes/internal.Currency.mdx)",
"description": "The details of the currency used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "currency_code",
"type": "`string`",
"description": "The 3 character currency code that is used in the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customer",
"type": "[Customer](../internal/classes/internal.Customer.mdx)",
"description": "The details of the customer associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "customer_id",
"type": "`string`",
"description": "The ID of the customer associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discount_total",
"type": "`number`",
"description": "The total of discount rounded",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discounts",
"type": "[Discount](../internal/classes/internal.Discount-1.mdx)[]",
"description": "The details of the discounts applied on the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "display_id",
"type": "`number`",
"description": "The order's display ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "draft_order",
"type": "[DraftOrder](../internal/classes/internal.DraftOrder.mdx)",
"description": "The details of the draft order this order was created from.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "draft_order_id",
"type": "`string`",
"description": "The ID of the draft order this order was created from.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "edits",
"type": "[OrderEdit](../internal/classes/internal.OrderEdit.mdx)[]",
"description": "The details of the order edits done on the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "email",
"type": "`string`",
"description": "The email associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "external_id",
"type": "``null`` \\| `string`",
"description": "The ID of an external order.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fulfillment_status",
"type": "[FulfillmentStatus](../internal/enums/internal.FulfillmentStatus.mdx)",
"description": "The order's fulfillment status",
"optional": false,
"defaultValue": "not_fulfilled",
"expandable": false,
"children": []
},
{
"name": "fulfillments",
"type": "[Fulfillment](../internal/classes/internal.Fulfillment.mdx)[]",
"description": "The details of the fulfillments created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "gift_card_tax_total",
"type": "`number`",
"description": "The total of gift cards with taxes",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gift_card_total",
"type": "`number`",
"description": "The total of gift cards",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gift_card_transactions",
"type": "[GiftCardTransaction](../internal/classes/internal.GiftCardTransaction.mdx)[]",
"description": "The gift card transactions made in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "gift_cards",
"type": "[GiftCard](../internal/classes/internal.GiftCard-1.mdx)[]",
"description": "The details of the gift card used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The order's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "idempotency_key",
"type": "`string`",
"description": "Randomly generated key used to continue the processing of the order in case of failure.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "item_tax_total",
"type": "``null`` \\| `number`",
"description": "The tax total applied on items",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "items",
"type": "[LineItem](../internal/classes/internal.LineItem.mdx)[]",
"description": "The details of the line items that belong to the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "no_notification",
"type": "`boolean`",
"description": "Flag for describing whether or not notifications related to this should be send.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "paid_total",
"type": "`number`",
"description": "The total amount paid",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payment_status",
"type": "[PaymentStatus](../internal/enums/internal.PaymentStatus.mdx)",
"description": "The order's payment status",
"optional": false,
"defaultValue": "not_paid",
"expandable": false,
"children": []
},
{
"name": "payments",
"type": "[Payment](../internal/classes/internal.Payment.mdx)[]",
"description": "The details of the payments used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "raw_discount_total",
"type": "`number`",
"description": "The total of discount",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "refundable_amount",
"type": "`number`",
"description": "The amount that can be refunded",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "refunded_total",
"type": "`number`",
"description": "The total amount refunded if the order is returned.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "refunds",
"type": "[Refund](../internal/classes/internal.Refund.mdx)[]",
"description": "The details of the refunds created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region",
"type": "[Region](../internal/classes/internal.Region.mdx)",
"description": "The details of the region this order was created in.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region_id",
"type": "`string`",
"description": "The ID of the region this order was created in.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "returnable_items",
"type": "[LineItem](../internal/classes/internal.LineItem.mdx)[]",
"description": "The details of the line items that are returnable as part of the order, swaps, or claims",
"optional": true,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "returns",
"type": "[Return](../internal/classes/internal.Return.mdx)[]",
"description": "The details of the returns created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "sales_channel",
"type": "[SalesChannel](../internal/classes/internal.SalesChannel.mdx)",
"description": "The details of the sales channel this order belongs to.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "sales_channel_id",
"type": "``null`` \\| `string`",
"description": "The ID of the sales channel this order belongs to.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shipping_address",
"type": "[Address](../internal/classes/internal.Address.mdx)",
"description": "The details of the shipping address associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "shipping_address_id",
"type": "`string`",
"description": "The ID of the shipping address associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shipping_methods",
"type": "[ShippingMethod](../internal/classes/internal.ShippingMethod-4.mdx)[]",
"description": "The details of the shipping methods used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "shipping_tax_total",
"type": "``null`` \\| `number`",
"description": "The tax total applied on shipping",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shipping_total",
"type": "`number`",
"description": "The total of shipping",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "status",
"type": "[OrderStatus](../internal/enums/internal.OrderStatus.mdx)",
"description": "The order's status",
"optional": false,
"defaultValue": "pending",
"expandable": false,
"children": []
},
{
"name": "subtotal",
"type": "`number`",
"description": "The subtotal of the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "swaps",
"type": "[Swap](../internal/classes/internal.Swap.mdx)[]",
"description": "The details of the swaps created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "tax_rate",
"type": "``null`` \\| `number`",
"description": "The order's tax rate",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_total",
"type": "``null`` \\| `number`",
"description": "The total of tax",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "total",
"type": "`number`",
"description": "The total amount of the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />
___
### retrieveByCartId
Retrieve an order's details by the ID of the cart that was used to create the order.
#### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
medusa.orders.retrieveByCartId(cartId).then(({ order }) => {
console.log(order.id)
})
```
#### Parameters
<ParameterTypes parameters={[
{
"name": "cart_id",
"type": "`string`",
"description": "The cart's ID.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
#### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[StoreOrdersRes](../internal/types/internal.StoreOrdersRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the details of the order.",
"expandable": false,
"children": [
{
"name": "StoreOrdersRes",
"type": "`object`",
"description": "The order's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "order",
"type": "[Order](../internal/classes/internal.Order.mdx)",
"description": "Order details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "billing_address",
"type": "[Address](../internal/classes/internal.Address.mdx)",
"description": "The details of the billing address associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "billing_address_id",
"type": "`string`",
"description": "The ID of the billing address associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "canceled_at",
"type": "`Date`",
"description": "The date the order was canceled on.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "cart",
"type": "[Cart](../internal/classes/internal.Cart.mdx)",
"description": "The details of the cart associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "cart_id",
"type": "`string`",
"description": "The ID of the cart associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "claims",
"type": "[ClaimOrder](../internal/classes/internal.ClaimOrder.mdx)[]",
"description": "The details of the claims created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "created_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was created.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "currency",
"type": "[Currency](../internal/classes/internal.Currency.mdx)",
"description": "The details of the currency used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "currency_code",
"type": "`string`",
"description": "The 3 character currency code that is used in the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "customer",
"type": "[Customer](../internal/classes/internal.Customer.mdx)",
"description": "The details of the customer associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "customer_id",
"type": "`string`",
"description": "The ID of the customer associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discount_total",
"type": "`number`",
"description": "The total of discount rounded",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "discounts",
"type": "[Discount](../internal/classes/internal.Discount-1.mdx)[]",
"description": "The details of the discounts applied on the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "display_id",
"type": "`number`",
"description": "The order's display ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "draft_order",
"type": "[DraftOrder](../internal/classes/internal.DraftOrder.mdx)",
"description": "The details of the draft order this order was created from.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "draft_order_id",
"type": "`string`",
"description": "The ID of the draft order this order was created from.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "edits",
"type": "[OrderEdit](../internal/classes/internal.OrderEdit.mdx)[]",
"description": "The details of the order edits done on the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "email",
"type": "`string`",
"description": "The email associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "external_id",
"type": "``null`` \\| `string`",
"description": "The ID of an external order.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "fulfillment_status",
"type": "[FulfillmentStatus](../internal/enums/internal.FulfillmentStatus.mdx)",
"description": "The order's fulfillment status",
"optional": false,
"defaultValue": "not_fulfilled",
"expandable": false,
"children": []
},
{
"name": "fulfillments",
"type": "[Fulfillment](../internal/classes/internal.Fulfillment.mdx)[]",
"description": "The details of the fulfillments created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "gift_card_tax_total",
"type": "`number`",
"description": "The total of gift cards with taxes",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gift_card_total",
"type": "`number`",
"description": "The total of gift cards",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "gift_card_transactions",
"type": "[GiftCardTransaction](../internal/classes/internal.GiftCardTransaction.mdx)[]",
"description": "The gift card transactions made in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "gift_cards",
"type": "[GiftCard](../internal/classes/internal.GiftCard-1.mdx)[]",
"description": "The details of the gift card used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "id",
"type": "`string`",
"description": "The order's ID",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "idempotency_key",
"type": "`string`",
"description": "Randomly generated key used to continue the processing of the order in case of failure.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "item_tax_total",
"type": "``null`` \\| `number`",
"description": "The tax total applied on items",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "items",
"type": "[LineItem](../internal/classes/internal.LineItem.mdx)[]",
"description": "The details of the line items that belong to the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "metadata",
"type": "`Record<string, unknown>`",
"description": "An optional key-value map with additional details",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "no_notification",
"type": "`boolean`",
"description": "Flag for describing whether or not notifications related to this should be send.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "paid_total",
"type": "`number`",
"description": "The total amount paid",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "payment_status",
"type": "[PaymentStatus](../internal/enums/internal.PaymentStatus.mdx)",
"description": "The order's payment status",
"optional": false,
"defaultValue": "not_paid",
"expandable": false,
"children": []
},
{
"name": "payments",
"type": "[Payment](../internal/classes/internal.Payment.mdx)[]",
"description": "The details of the payments used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "raw_discount_total",
"type": "`number`",
"description": "The total of discount",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "refundable_amount",
"type": "`number`",
"description": "The amount that can be refunded",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "refunded_total",
"type": "`number`",
"description": "The total amount refunded if the order is returned.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "refunds",
"type": "[Refund](../internal/classes/internal.Refund.mdx)[]",
"description": "The details of the refunds created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region",
"type": "[Region](../internal/classes/internal.Region.mdx)",
"description": "The details of the region this order was created in.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "region_id",
"type": "`string`",
"description": "The ID of the region this order was created in.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "returnable_items",
"type": "[LineItem](../internal/classes/internal.LineItem.mdx)[]",
"description": "The details of the line items that are returnable as part of the order, swaps, or claims",
"optional": true,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "returns",
"type": "[Return](../internal/classes/internal.Return.mdx)[]",
"description": "The details of the returns created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "sales_channel",
"type": "[SalesChannel](../internal/classes/internal.SalesChannel.mdx)",
"description": "The details of the sales channel this order belongs to.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "sales_channel_id",
"type": "``null`` \\| `string`",
"description": "The ID of the sales channel this order belongs to.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shipping_address",
"type": "[Address](../internal/classes/internal.Address.mdx)",
"description": "The details of the shipping address associated with the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "shipping_address_id",
"type": "`string`",
"description": "The ID of the shipping address associated with the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shipping_methods",
"type": "[ShippingMethod](../internal/classes/internal.ShippingMethod-4.mdx)[]",
"description": "The details of the shipping methods used in the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "shipping_tax_total",
"type": "``null`` \\| `number`",
"description": "The tax total applied on shipping",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "shipping_total",
"type": "`number`",
"description": "The total of shipping",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "status",
"type": "[OrderStatus](../internal/enums/internal.OrderStatus.mdx)",
"description": "The order's status",
"optional": false,
"defaultValue": "pending",
"expandable": false,
"children": []
},
{
"name": "subtotal",
"type": "`number`",
"description": "The subtotal of the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "swaps",
"type": "[Swap](../internal/classes/internal.Swap.mdx)[]",
"description": "The details of the swaps created for the order.",
"optional": false,
"defaultValue": "",
"expandable": true,
"children": []
},
{
"name": "tax_rate",
"type": "``null`` \\| `number`",
"description": "The order's tax rate",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "tax_total",
"type": "``null`` \\| `number`",
"description": "The total of tax",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "total",
"type": "`number`",
"description": "The total amount of the order",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "updated_at",
"type": "`Date`",
"description": "The date with timezone at which the resource was updated.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />