Search.../

getOrder( )

Retrieves an order.

Description

The getOrder() function returns a Promise that resolves when the specified order is retrieved.

To retrieve an order's payment and refund details, including amounts, payment methods, and payment statuses, pass the order ID to listTransactionsForSingleOrder( ).

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function getOrder(_id: string): Promise<Order>

getOrder Parameters

NAME
TYPE
DESCRIPTION
_id
string

ID of the order to retrieve.

Returns

Fulfilled - The requested order.

Return Type:

Promise<
Order
>
NAME
TYPE
DESCRIPTION
_createdDate
Date

Date and time the order was created.

_id
string

Order ID.

_updatedDate
Date

Date and time the order was last updated in ISO-8601 format.

activities
Array<
Activity
>

Order activities.

additionalFees
Array<
AdditionalFee
>

Additional fees applied to the order.

appliedDiscounts
Array<
AppliedDiscount
>

Applied discounts.

archived
boolean

Whether order is archived.

attributionSource
string

Order attribution source.

balanceSummary
BalanceSummary

Balance summary.

billingInfo
AddressWithContact

Billing address and contact details.

buyerInfo
BuyerInfo

Buyer information.

buyerLanguage
string

Language for communication with the buyer. Defaults to the site language. For a site that supports multiple languages, this is the language the buyer selected.

buyerNote
string

Buyer note left by the customer.

channelInfo
ChannelInfo

Information about the sales channel that submitted this order.

checkoutId
string

Checkout ID.

createdBy
CreatedBy

ID of the order's initiator.

currency
string

Currency used for the pricing of this order in ISO-4217 format.

customFields
Array<
CustomField
>

Custom fields.

extendedFields
ExtendedFields

Custom field data for the order object.

Extended fields must be configured in the Wix Dev Center before they can be accessed with API calls.

fulfillmentStatus
string

Order fulfillment status.

lineItems
Array<
OrderLineItem
>

Order line items.

number
string

Order number displayed in the site owner's dashboard (auto-generated).

paymentStatus
string

Order payment status.

  • NOT_PAID - This can be an order made online, but not yet paid. In such cases order.status will be INITIALIZED.
  • This status also applies when an offline order needs to be manually marked as paid. In such cases order.status will be APPROVED.
  • PAID - All payments associated with this order are paid. For online payments: payment.regularPaymentDetails.status: APPROVED. For gift cards: payment.giftCardPaymentDetails.voided: false.
  • PARTIALLY_REFUNDED - Order was refunded, but refund amount is less than order total price.
  • FULLY_REFUNDED - Order fully refunded. Refund amount equals total price.
  • PENDING - Payments received but not yet confirmed by the payment provider.
  • PARTIALLY_PAID - At least one payment was received and approved, covering less than total price amount.
priceSummary
PriceSummary

Order price summary.

purchaseFlowId
string

Persistent ID that correlates between the various eCommerce elements: cart, checkout, and order.

recipientInfo
AddressWithContact

Order recipient address and contact details.

This field may differ from the address in shippingInfo.logistics when:

  • The chosen shipping option is pickup point or store pickup.
  • No shipping option is selected.
seenByAHuman
boolean

Whether a human has seen the order. Set when an order is clicked on in the dashboard.

shippingInfo
ShippingInformation

Shipping info and selected shipping option details.

siteLanguage
string

Site language in which original values are shown.

status
string

Order status.

  • INITIALIZED - Order was created, but not yet approved or declined.
  • APPROVED - Order was approved. This happens when either the online payment succeeded or the order is an offline order. Once an order is approved, many side effects are triggered. For example, holding of stock in the inventory and sending of notification emails.
  • CANCELED - Order was canceled by the user.
taxIncludedInPrices
boolean

Whether tax is included in line item prices.

taxSummary
TaxSummary

Tax summary.

weightUnit
string

Weight measurement unit - defaults to site's weight unit.

Was this helpful?

Get an order (export from backend code)

Copy Code
1/*****************************************
2 * Backend code - my-backend-file.web.js *
3 ****************************************/
4
5import { Permissions, webMethod } from 'wix-web-module';
6import { orders } from 'wix-ecom-backend';
7
8export const myGetOrderFunction = webMethod(Permissions.Anyone, async (orderId) => {
9 try {
10 const retrievedOrder = await orders.getOrder(orderId);
11 console.log('Success! Retrieved order:', retrievedOrder);
12 return retrievedOrder;
13 } catch (error) {
14 console.error(error);
15 // Handle the error
16 }
17});
18
19/*************
20 * Page code *
21 ************/
22
23import { myGetOrderFunction } from 'backend/my-backend-file.web';
24
25// Sample orderId:
26const orderId = '67668940-527d-4465-94c6-5475d8c7a412';
27
28myGetOrderFunction(orderId)
29 .then((order) => {
30 const orderNumber = order.number;
31 const orderId = order._id;
32 console.log('Success! Retrieved order:', order);
33 return order;
34 })
35 .catch((error) => {
36 console.error(error);
37 // Handle the error
38 });
39
40/*
41 * Promise resolves to:
42 *
43 * {
44 * "_id": "67668940-527d-4465-94c6-5475d8c7a412",
45 * "number": "10124",
46 * "_createdDate": "2022-07-31T13:42:13.136Z",
47 * "_updatedDate": "2022-07-31T14:58:11.663Z",
48 * "lineItems": [
49 * {
50 * "_id": "00000000-0000-0000-0000-000000000001",
51 * "productName": {
52 * "original": "Brazilian Arabica",
53 * "translated": "Brazilian Arabica"
54 * },
55 * "catalogReference": {
56 * "catalogItemId": "0614129c-8777-9f3b-4dfe-b80a54df10d5",
57 * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e",
58 * "options": {
59 * "options": {
60 * "Weight": "500g",
61 * "Ground for": "Stovetop"
62 * },
63 * "variantId": "00000000-0000-003f-0005-a316f7c67df7",
64 * "customTextFields": {
65 * "What would you like written on the custom label?": "Enjoy our finest coffee."
66 * }
67 * }
68 * },
69 * "quantity": 1,
70 * "totalDiscount": {
71 * "amount": "0",
72 * "formattedAmount": "$0.00"
73 * },
74 * "descriptionLines": [
75 * {
76 * "name": {
77 * "original": "Weight",
78 * "translated": "Weight"
79 * },
80 * "plainText": {
81 * "original": "500g",
82 * "translated": "500g"
83 * },
84 * "lineType": "PLAIN_TEXT",
85 * "plainTextValue": {
86 * "original": "500g",
87 * "translated": "500g"
88 * }
89 * },
90 * {
91 * "name": {
92 * "original": "Ground for",
93 * "translated": "Ground for"
94 * },
95 * "plainText": {
96 * "original": "Stovetop",
97 * "translated": "Stovetop"
98 * },
99 * "lineType": "PLAIN_TEXT",
100 * "plainTextValue": {
101 * "original": "Stovetop",
102 * "translated": "Stovetop"
103 * }
104 * },
105 * {
106 * "name": {
107 * "original": "What would you like written on the custom label?",
108 * "translated": "What would you like written on the custom label?"
109 * },
110 * "plainText": {
111 * "original": "Enjoy our finest coffee.",
112 * "translated": "Enjoy our finest coffee."
113 * },
114 * "lineType": "PLAIN_TEXT",
115 * "plainTextValue": {
116 * "original": "Enjoy our finest coffee.",
117 * "translated": "Enjoy our finest coffee."
118 * }
119 * }
120 * ],
121 * "image": "wix:image://v1/nsplsh_306d666a306a4a74306459~mv2_d_4517_2992_s_4_2.jpg#originWidth=4517&originHeight=2992",
122 * "physicalProperties": {
123 * "weight": 0.5,
124 * "shippable": true
125 * },
126 * "itemType": {
127 * "preset": "PHYSICAL"
128 * },
129 * "fulfillerId": "85e29287-a5bf-4c25-b303-a2ddc9d975e2",
130 * "refundQuantity": 0,
131 * "price": {
132 * "amount": "48.75",
133 * "formattedAmount": "$48.75"
134 * },
135 * "priceBeforeDiscounts": {
136 * "amount": "48.75",
137 * "formattedAmount": "$48.75"
138 * },
139 * "totalPriceBeforeTax": {
140 * "amount": "48.75",
141 * "formattedAmount": "$48.75"
142 * },
143 * "totalPriceAfterTax": {
144 * "amount": "50.70",
145 * "formattedAmount": "$50.70"
146 * },
147 * "paymentOption": "FULL_PAYMENT_ONLINE",
148 * "taxDetails": {
149 * "taxableAmount": {
150 * "amount": "48.75",
151 * "formattedAmount": "$48.75"
152 * },
153 * "taxRate": "0.04",
154 * "totalTax": {
155 * "amount": "1.95",
156 * "formattedAmount": "$1.95"
157 * }
158 * }
159 * }
160 * ],
161 * "buyerInfo": {
162 * "contactId": "f61f30cd-7474-47b7-95a2-339c0fcacbd3",
163 * "email": "janedoe@gmail.com",
164 * "visitorId": "b52ec002-40dd-469c-9f9f-833988e8048d"
165 * },
166 * "paymentStatus": "PAID",
167 * "fulfillmentStatus": "NOT_FULFILLED",
168 * "buyerLanguage": "en",
169 * "weightUnit": "LB",
170 * "currency": "USD",
171 * "taxIncludedInPrices": false,
172 * "priceSummary": {
173 * "subtotal": {
174 * "amount": "48.75",
175 * "formattedAmount": "$48.75"
176 * },
177 * "shipping": {
178 * "amount": "5.0",
179 * "formattedAmount": "$5.00"
180 * },
181 * "tax": {
182 * "amount": "1.95",
183 * "formattedAmount": "$1.95"
184 * },
185 * "discount": {
186 * "amount": "0",
187 * "formattedAmount": "$0.00"
188 * },
189 * "totalPrice": {
190 * "amount": "55.70",
191 * "formattedAmount": "$55.70"
192 * },
193 * "total": {
194 * "amount": "55.70",
195 * "formattedAmount": "$55.70"
196 * },
197 * "totalWithGiftCard": {
198 * "amount": "55.70",
199 * "formattedAmount": "$55.70"
200 * },
201 * "totalWithoutGiftCard": {
202 * "amount": "55.70",
203 * "formattedAmount": "$55.70"
204 * },
205 * "totalAdditionalFees": {
206 * "amount": "0",
207 * "formattedAmount": "$0.00"
208 * }
209 * },
210 * "billingInfo": {
211 * "address": {
212 * "addressLine1": "525 5th Avenue",
213 * "city": "New York",
214 * "subdivision": "US-NY",
215 * "country": "US",
216 * "postalCode": "10173"
217 * },
218 * "contactDetails": {
219 * "firstName": "Jane",
220 * "lastName": "Doe",
221 * "phone": "0555555555"
222 * }
223 * },
224 * "shippingInfo": {
225 * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc",
226 * "code": "a0fde0a4-6f4e-3716-64be-c0acbde1696a",
227 * "title": "U.S Shipping",
228 * "logistics": {
229 * "deliveryTime": "3 - 5 business days",
230 * "shippingDestination": {
231 * "address": {
232 * "addressLine1": "525 5th Avenue",
233 * "city": "New York",
234 * "subdivision": "US-NY",
235 * "country": "US",
236 * "postalCode": "10173"
237 * },
238 * "contactDetails": {
239 * "firstName": "Jane",
240 * "lastName": "Doe",
241 * "phone":
242