getOrder( )
Retrieves an order.
Description
The getOrder()
function returns a Promise that resolves when the specified order is retrieved.
Syntax
function getOrder(_id: string): Promise<Order>
getOrder Parameters
NAME
TYPE
DESCRIPTION
ID of the order to retrieve.
Returns
Fulfilled - The requested order.
Return Type:
NAME
TYPE
DESCRIPTION
Date and time the order was created.
Order ID.
Order activities.
Additional fees applied to the order.
Applied discounts.
Whether order is archived.
Order attribution source.
Billing address and contact details.
Buyer information.
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.
Information about the sales channel that submitted this order.
Checkout ID.
ID of the order's initiator.
Custom fields.
Order fulfillment status.
Order line items.
Order number displayed in the site owner's business manager (auto-generated).
Order payment status.
NOT_PAID
- This can be an order made online, but not yet paid. In such casesorder.status
will beINITIALIZED
.- This status also applies when an offline order needs to be manually marked as paid. In such cases
order.status
will beAPPROVED
. 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.
Order price summary.
Whether a human has seen the order. Set when an order is clicked on in the Business Manager.
Shipping info and selected shipping option details.
Site language in which original values are shown.
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.
Whether tax is included in line item prices.
Tax summary.
Weight measurement unit - defaults to site's weight unit.
Was this helpful?
Get an order
1/**************************************2 * Backend code - my-backend-file.jsw *3 *************************************/45import { orders } from 'wix-ecom-backend';67export async function myGetOrderFunction(orderId) {8 try {9 const retrievedOrder = await orders.getOrder(orderId);10 console.log('Success! Retrieved order:', retrievedOrder);11 return retrievedOrder;12 } catch (error) {13 console.error(error);14 // Handle the error15 }16}1718/*************19 * Page code *20 ************/2122import { myGetOrderFunction } from 'backend/my-backend-file';2324// Sample orderId:25const orderId = '67668940-527d-4465-94c6-5475d8c7a412';2627myGetCheckoutFunction(orderId)28 .then((order) => {29 const orderNumber = order.number;30 const orderId = order._id;31 console.log('Success! Retrieved order:', order);32 return order;33 })34 .catch((error) => {35 console.error(error);36 // Handle the error37 });3839/*40 * Promise resolves to:41 *42 * {43 * "_id": "67668940-527d-4465-94c6-5475d8c7a412",44 * "number": "10124",45 * "_createdDate": "2022-07-31T13:42:13.136Z",46 * "_updatedDate": "2022-07-31T14:58:11.663Z",47 * "lineItems": [48 * {49 * "_id": "00000000-0000-0000-0000-000000000001",50 * "productName": {51 * "original": "Brazilian Arabica",52 * "translated": "Brazilian Arabica"53 * },54 * "catalogReference": {55 * "catalogItemId": "0614129c-8777-9f3b-4dfe-b80a54df10d5",56 * "appId": "1380b703-ce81-ff05-f115-39571d94dfcd",57 * "options": {58 * "options": {59 * "Weight": "500g",60 * "Ground for": "Stovetop"61 * },62 * "variantId": "00000000-0000-003f-0005-a316f7c67df7",63 * "customTextFields": {64 * "What would you like written on the custom label?": "Enjoy our finest coffee."65 * }66 * }67 * },68 * "quantity": 1,69 * "totalDiscount": {70 * "amount": "0",71 * "formattedAmount": "$0.00"72 * },73 * "descriptionLines": [74 * {75 * "name": {76 * "original": "Weight",77 * "translated": "Weight"78 * },79 * "plainText": {80 * "original": "500g",81 * "translated": "500g"82 * },83 * "lineType": "PLAIN_TEXT",84 * "plainTextValue": {85 * "original": "500g",86 * "translated": "500g"87 * }88 * },89 * {90 * "name": {91 * "original": "Ground for",92 * "translated": "Ground for"93 * },94 * "plainText": {95 * "original": "Stovetop",96 * "translated": "Stovetop"97 * },98 * "lineType": "PLAIN_TEXT",99 * "plainTextValue": {100 * "original": "Stovetop",101 * "translated": "Stovetop"102 * }103 * },104 * {105 * "name": {106 * "original": "What would you like written on the custom label?",107 * "translated": "What would you like written on the custom label?"108 * },109 * "plainText": {110 * "original": "Enjoy our finest coffee.",111 * "translated": "Enjoy our finest coffee."112 * },113 * "lineType": "PLAIN_TEXT",114 * "plainTextValue": {115 * "original": "Enjoy our finest coffee.",116 * "translated": "Enjoy our finest coffee."117 * }118 * }119 * ],120 * "image": "wix:image://v1/nsplsh_306d666a306a4a74306459~mv2_d_4517_2992_s_4_2.jpg#originWidth=4517&originHeight=2992",121 * "physicalProperties": {122 * "weight": 0.5,123 * "shippable": true124 * },125 * "itemType": {126 * "preset": "PHYSICAL"127 * },128 * "fulfillerId": "85e29287-a5bf-4c25-b303-a2ddc9d975e2",129 * "refundQuantity": 0,130 * "price": {131 * "amount": "48.75",132 * "formattedAmount": "$48.75"133 * },134 * "priceBeforeDiscounts": {135 * "amount": "48.75",136 * "formattedAmount": "$48.75"137 * },138 * "totalPriceBeforeTax": {139 * "amount": "48.75",140 * "formattedAmount": "$48.75"141 * },142 * "totalPriceAfterTax": {143 * "amount": "50.70",144 * "formattedAmount": "$50.70"145 * },146 * "paymentOption": "FULL_PAYMENT_ONLINE",147 * "taxDetails": {148 * "taxableAmount": {149 * "amount": "48.75",150 * "formattedAmount": "$48.75"151 * },152 * "taxRate": "0.04",153 * "totalTax": {154 * "amount": "1.95",155 * "formattedAmount": "$1.95"156 * }157 * }158 * }159 * ],160 * "buyerInfo": {161 * "contactId": "f61f30cd-7474-47b7-95a2-339c0fcacbd3",162 * "email": "janedoe@gmail.com",163 * "visitorId": "b52ec002-40dd-469c-9f9f-833988e8048d"164 * },165 * "paymentStatus": "PAID",166 * "fulfillmentStatus": "NOT_FULFILLED",167 * "buyerLanguage": "en",168 * "weightUnit": "LB",169 * "currency": "USD",170 * "taxIncludedInPrices": false,171 * "priceSummary": {172 * "subtotal": {173 * "amount": "48.75",174 * "formattedAmount": "$48.75"175 * },176 * "shipping": {177 * "amount": "5.0",178 * "formattedAmount": "$5.00"179 * },180 * "tax": {181 * "amount": "1.95",182 * "formattedAmount": "$1.95"183 * },184 * "discount": {185 * "amount": "0",186 * "formattedAmount": "$0.00"187 * },188 * "totalPrice": {189 * "amount": "55.70",190 * "formattedAmount": "$55.70"191 * },192 * "total": {193 * "amount": "55.70",194 * "formattedAmount": "$55.70"195 * },196 * "totalWithGiftCard": {197 * "amount": "55.70",198 * "formattedAmount": "$55.70"199 * },200 * "totalWithoutGiftCard": {201 * "amount": "55.70",202 * "formattedAmount": "$55.70"203 * },204 * "totalAdditionalFees": {205 * "amount": "0",206 * "formattedAmount": "$0.00"207 * }208 * },209 * "billingInfo": {210 * "address": {211 * "addressLine1": "525 5th Avenue",212 * "city": "New York",213 * "subdivision": "US-NY",214 * "country": "US",215 * "postalCode": "10173"216 * },217 * "contactDetails": {218 * "firstName": "Jane",219 * "lastName": "Doe",220 * "phone": "0555555555"221 * }222 * },223 * "shippingInfo": {224 * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc",225 * "code": "a0fde0a4-6f4e-3716-64be-c0acbde1696a",226 * "title": "U.S Shipping",227 * "logistics": {228 * "deliveryTime": "3 - 5 business days",229 * "shippingDestination": {230 * "address": {231 * "addressLine1": "525 5th Avenue",232 * "city": "New York",233 * "subdivision": "US-NY",234 * "country": "US",235 * "postalCode": "10173"236 * },237 * "contactDetails": {238 * "firstName": "Jane",239 * "lastName": "Doe",240 * "phone": "0555555555"241 * }242 * }243 * },244 * "cost": {245 * "price": {246 * "amount": "5",247 * "formattedAmount": "$5.00"248 * },249 * "totalPriceBeforeTax": {250 * "amount": "5",251 * "formattedAmount": "$5.00"252 * },253 * "totalPriceAfterTax": {254 * "amount": "5.0",255 * "formattedAmount": "$5.00"256 * },257 * "taxDetails": {258 * "taxRate": "0.0",259 * "totalTax": {260 * "amount": "0.0",261 * "formattedAmount": "$0.00"262 * }263 * },264 * "discount": {265 * "amount": "0",266 * "formattedAmount": "$0.00"267 * }268 * },269 * "region": {270 * "name": "Region 3"271 * }272 * },273 * "buyerNote": "This is a buyerNote",274 * "status": "APPROVED",275 * "taxSummary": {276 * "totalTax": {277 * "amount": "1.95",278 * "formattedAmount": "$1.95"279 * },280 * "manualTaxRate": "0.04"281 * },282 * "appliedDiscounts": [],283 * "activities": [],284 * "attributionSource": "UNSPECIFIED",285 * "createdBy": {286 * "visitorId": "b52ec002-40dd-469c-9f9f-833988e8048d"287 * },288 * "channelInfo": {289 * "type": "WEB"290 * },291 * "checkoutId": "62d01935-e0d3-4063-9e78-da099462e90c",292 * "customFields": [],293 * "cartId": "52fec024-4379-4a96-9237-9660030be6fe",294 * "isInternalOrderCreate": false,295 * "payNow": {296 * "subtotal": {297 * "amount": "48.75",298 * "formattedAmount": "$48.75"299 * },300 * "shipping": {301 * "amount": "5.0",302 * "formattedAmount": "$5.00"303 * },304 * "tax": {305 * "amount": "1.95",306 * "formattedAmount": "$1.95"307 * },308 * "discount": {309 * "amount": "0",310 * "formattedAmount": "$0.00"311 * },312 * "totalPrice": {313 * "amount": "55.70",314 * "formattedAmount": "$55.70"315 * },316 * "total": {317 * "amount": "55.70",318 * "formattedAmount": "$55.70"319 * },320 * "totalWithGiftCard": {321 * "amount": "55.70",322 * "formattedAmount": "$55.70"323 * },324 * "totalWithoutGiftCard": {325 * "amount": "55.70",326 * "formattedAmount": "$55.70"327 * }328 * },329 * "balanceSummary": {330 * "balance": {331 * "amount": "0.0",332 * "formattedAmount": "$0.00"333 * }334 * },335 * "additionalFees": []336 * }337 *338 */