getOrder( )


Retrieves an order.

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( ).

Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Manage eCommerce - all permissions
Read eCommerce - all read permissions
Manage Stores - all permissions
Read Stores - all read permissions
Manage Orders
Read Orders
Manage Restaurants - all permissions
Learn more about app permissions.
Method Declaration
Copy
function getOrder(_id: string): Promise<Order>;
Method Parameters
_idstringRequired

ID of the order to retrieve.

Returns
Return Type:Promise<Order>
Get an order (export from backend code)
JavaScript
/***************************************** * Backend code - my-backend-file.web.js * ****************************************/ import { Permissions, webMethod } from "wix-web-module"; import { orders } from "wix-ecom-backend"; export const myGetOrderFunction = webMethod( Permissions.Anyone, async (orderId) => { try { const retrievedOrder = await orders.getOrder(orderId); console.log("Success! Retrieved order:", retrievedOrder); return retrievedOrder; } catch (error) { console.error(error); // Handle the error } }, ); /************* * Page code * ************/ import { myGetOrderFunction } from "backend/my-backend-file.web"; // Sample orderId: const orderId = "67668940-527d-4465-94c6-5475d8c7a412"; myGetOrderFunction(orderId) .then((order) => { const orderNumber = order.number; const orderId = order._id; console.log("Success! Retrieved order:", order); return order; }) .catch((error) => { console.error(error); // Handle the error }); /* * Promise resolves to: * * { * "_id": "67668940-527d-4465-94c6-5475d8c7a412", * "number": "10124", * "_createdDate": "2022-07-31T13:42:13.136Z", * "_updatedDate": "2022-07-31T14:58:11.663Z", * "lineItems": [ * { * "_id": "00000000-0000-0000-0000-000000000001", * "productName": { * "original": "Brazilian Arabica", * "translated": "Brazilian Arabica" * }, * "catalogReference": { * "catalogItemId": "0614129c-8777-9f3b-4dfe-b80a54df10d5", * "appId": "215238eb-22a5-4c36-9e7b-e7c08025e04e", * "options": { * "options": { * "Weight": "500g", * "Ground for": "Stovetop" * }, * "variantId": "00000000-0000-003f-0005-a316f7c67df7", * "customTextFields": { * "What would you like written on the custom label?": "Enjoy our finest coffee." * } * } * }, * "quantity": 1, * "totalDiscount": { * "amount": "0", * "formattedAmount": "$0.00" * }, * "descriptionLines": [ * { * "name": { * "original": "Weight", * "translated": "Weight" * }, * "plainText": { * "original": "500g", * "translated": "500g" * }, * "lineType": "PLAIN_TEXT", * "plainTextValue": { * "original": "500g", * "translated": "500g" * } * }, * { * "name": { * "original": "Ground for", * "translated": "Ground for" * }, * "plainText": { * "original": "Stovetop", * "translated": "Stovetop" * }, * "lineType": "PLAIN_TEXT", * "plainTextValue": { * "original": "Stovetop", * "translated": "Stovetop" * } * }, * { * "name": { * "original": "What would you like written on the custom label?", * "translated": "What would you like written on the custom label?" * }, * "plainText": { * "original": "Enjoy our finest coffee.", * "translated": "Enjoy our finest coffee." * }, * "lineType": "PLAIN_TEXT", * "plainTextValue": { * "original": "Enjoy our finest coffee.", * "translated": "Enjoy our finest coffee." * } * } * ], * "image": "wix:image://v1/nsplsh_306d666a306a4a74306459~mv2_d_4517_2992_s_4_2.jpg#originWidth=4517&originHeight=2992", * "physicalProperties": { * "weight": 0.5, * "shippable": true * }, * "itemType": { * "preset": "PHYSICAL" * }, * "fulfillerId": "85e29287-a5bf-4c25-b303-a2ddc9d975e2", * "refundQuantity": 0, * "price": { * "amount": "48.75", * "formattedAmount": "$48.75" * }, * "priceBeforeDiscounts": { * "amount": "48.75", * "formattedAmount": "$48.75" * }, * "totalPriceBeforeTax": { * "amount": "48.75", * "formattedAmount": "$48.75" * }, * "totalPriceAfterTax": { * "amount": "50.70", * "formattedAmount": "$50.70" * }, * "paymentOption": "FULL_PAYMENT_ONLINE", * "taxDetails": { * "taxableAmount": { * "amount": "48.75", * "formattedAmount": "$48.75" * }, * "taxRate": "0.04", * "totalTax": { * "amount": "1.95", * "formattedAmount": "$1.95" * } * } * } * ], * "buyerInfo": { * "contactId": "f61f30cd-7474-47b7-95a2-339c0fcacbd3", * "email": "janedoe@gmail.com", * "visitorId": "b52ec002-40dd-469c-9f9f-833988e8048d" * }, * "paymentStatus": "PAID", * "fulfillmentStatus": "NOT_FULFILLED", * "buyerLanguage": "en", * "weightUnit": "LB", * "currency": "USD", * "taxIncludedInPrices": false, * "priceSummary": { * "subtotal": { * "amount": "48.75", * "formattedAmount": "$48.75" * }, * "shipping": { * "amount": "5.0", * "formattedAmount": "$5.00" * }, * "tax": { * "amount": "1.95", * "formattedAmount": "$1.95" * }, * "discount": { * "amount": "0", * "formattedAmount": "$0.00" * }, * "totalPrice": { * "amount": "55.70", * "formattedAmount": "$55.70" * }, * "total": { * "amount": "55.70", * "formattedAmount": "$55.70" * }, * "totalWithGiftCard": { * "amount": "55.70", * "formattedAmount": "$55.70" * }, * "totalWithoutGiftCard": { * "amount": "55.70", * "formattedAmount": "$55.70" * }, * "totalAdditionalFees": { * "amount": "0", * "formattedAmount": "$0.00" * } * }, * "billingInfo": { * "address": { * "addressLine1": "525 5th Avenue", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10173" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "0555555555" * } * }, * "shippingInfo": { * "carrierId": "c8a08776-c095-4dec-8553-8f9698d86adc", * "code": "a0fde0a4-6f4e-3716-64be-c0acbde1696a", * "title": "U.S Shipping", * "logistics": { * "deliveryTime": "3 - 5 business days", * "shippingDestination": { * "address": { * "addressLine1": "525 5th Avenue", * "city": "New York", * "subdivision": "US-NY", * "country": "US", * "postalCode": "10173" * }, * "contactDetails": { * "firstName": "Jane", * "lastName": "Doe", * "phone": "0555555555" * } * } * }, * "cost": { * "price": { * "amount": "5", * "formattedAmount": "$5.00" * }, * "totalPriceBeforeTax": { * "amount": "5", * "formattedAmount": "$5.00" * }, * "totalPriceAfterTax": { * "amount": "5.0", * "formattedAmount": "$5.00" * }, * "taxDetails": { * "taxRate": "0.0", * "totalTax": { * "amount": "0.0", * "formattedAmount": "$0.00" * } * }, * "discount": { * "amount": "0", * "formattedAmount": "$0.00" * } * }, * "region": { * "name": "Region 3" * } * }, * "buyerNote": "This is a buyerNote", * "status": "APPROVED", * "taxSummary": { * "totalTax": { * "amount": "1.95", * "formattedAmount": "$1.95" * }, * "manualTaxRate": "0.04" * }, * "appliedDiscounts": [], * "activities": [], * "attributionSource": "UNSPECIFIED", * "createdBy": { * "visitorId": "b52ec002-40dd-469c-9f9f-833988e8048d" * }, * "channelInfo": { * "type": "WEB" * }, * "checkoutId": "62d01935-e0d3-4063-9e78-da099462e90c", * "customFields": [], * "cartId": "52fec024-4379-4a96-9237-9660030be6fe", * "payNow": { * "subtotal": { * "amount": "48.75", * "formattedAmount": "$48.75" * }, * "shipping": { * "amount": "5.0", * "formattedAmount": "$5.00" * }, * "tax": { * "amount": "1.95", * "formattedAmount": "$1.95" * }, * "discount": { * "amount": "0", * "formattedAmount": "$0.00" * }, * "totalPrice": { * "amount": "55.70", * "formattedAmount": "$55.70" * }, * "total": { * "amount": "55.70", * "formattedAmount": "$55.70" * }, * "totalWithGiftCard": { * "amount": "55.70", * "formattedAmount": "$55.70" * }, * "totalWithoutGiftCard": { * "amount": "55.70", * "formattedAmount": "$55.70" * } * }, * "balanceSummary": { * "balance": { * "amount": "0.0", * "formattedAmount": "$0.00" * } * }, * "additionalFees": [] * } * */
Errors

This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.

Did this help?