order - JS SDK Store Reference

This documentation provides a reference to the sdk.store.order set of methods used to send requests to Medusa's Store API routes.

list#

This method retrieves a paginated list of orders matching the specified filters. It sends a request to the List Orders API route.

Example#

To retrieve the list of orders:

Code
1sdk.store.order.list()2.then(({ orders, count, offset, limit }) => {3  console.log(orders)4})

To configure the pagination, pass the limit and offset query parameters.

For example, to retrieve only 10 items and skip 10 items:

Code
1sdk.store.order.list({2  limit: 10,3  offset: 104})5.then(({ orders, count, offset, limit }) => {6  console.log(orders)7})

Using the fields query parameter, you can specify the fields and relations to retrieve in each order:

Code
1sdk.store.order.list({2  fields: "id,*items"3})4.then(({ orders, count, offset, limit }) => {5  console.log(orders)6})

Learn more about the fields property in the API reference.

Parameters#

queryStoreOrderFiltersOptional
Configure the fields to retrieve in the orders.
headersClientHeadersOptional
Headers to pass in the request.

Returns#

PromisePromise<StoreOrderListResponse>
The paginated list of orders.

retrieve#

This method retrieves an order by its ID. It sends a request to the Get Order API route.

Example#

To retrieve an order by its ID:

Code
1sdk.store.order.retrieve("order_123")2.then(({ order }) => {3  console.log(order)4})

To specify the fields and relations to retrieve:

Code
1sdk.store.order.retrieve("order_123", {2  fields: "id,*items"3})4.then(({ order }) => {5  console.log(order)6})

Learn more about the fields property in the API reference.

Parameters#

idstring
The order's ID.
querySelectParamsOptional
Configure the fields to retrieve in the order.
headersClientHeadersOptional
Headers to pass in the request.

Returns#

PromisePromise<object>
The order's details.

requestTransfer#

This method requests a order transfer from a guest account to the current, logged in customer account.

Customer requesting the transfer must be logged in.

Example#

Code
1sdk.store.order.requestTransfer(2  "order_123",3  {4    description: "I want to transfer this order to my friend."5  },6  {},7  {8    Authorization: `Bearer ${token}`9  }10)11.then(({ order }) => {12  console.log(order)13})

Parameters#

idstring
The transfer's details.
querySelectParamsOptional
Configure the fields to retrieve in the order.
headersClientHeadersOptional
Headers to pass in the request.

Returns#

PromisePromise<StoreOrderResponse>
The order details.

cancelTransfer#

This method cancels an order transfer request.

Customer requesting the transfer must be logged in.

Example#

Code
1sdk.store.order.cancelTransfer(2  "order_123",3  {},4  {5    Authorization: `Bearer ${token}`6  }7)8.then(({ order }) => {9  console.log(order)10})

Parameters#

idstring
The order's ID.
querySelectParamsOptional
Configure the fields to retrieve in the order.
headersClientHeadersOptional
Headers to pass in the request.

Returns#

PromisePromise<StoreOrderResponse>
The order details.

acceptTransfer#

The method called for the original owner to accept the order transfer to a new owner.

Example#

Code
1sdk.store.order.acceptTransfer(2  "order_123",3  {4    token: "transfer_token"5  },6  {7    Authorization: `Bearer ${token}`8  }9)10.then(({ order }) => {11  console.log(order)12})

Parameters#

idstring
The order's ID.
The payload containing the transfer token.
querySelectParamsOptional
Configure the fields to retrieve in the order.
headersClientHeadersOptional
Headers to pass in the request.

Returns#

PromisePromise<StoreOrderResponse>
The order details.

declineTransfer#

The method called for the original owner to decline the order transfer to a new owner.

Example#

Code
1sdk.store.order.declineTransfer(2  "order_123",3  {4    token: "transfer_token"5  },6  {7    Authorization: `Bearer ${token}`8  }9)10.then(({ order }) => {11  console.log(order)12})

Parameters#

idstring
The order's ID.
The payload containing the transfer token.
querySelectParamsOptional
Configure the fields to retrieve in the order.
headersClientHeadersOptional
Headers to pass in the request.

Returns#

PromisePromise<StoreOrderResponse>
The order details.
Was this page helpful?
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break