getOrder( )


Gets an existing pricing plan order by ID.

The getOrder() function returns a Promise that resolves to information about the specified order.

Note: Only site visitors with the Manage Pricing Plans and Manage Subscriptions permissions can get orders. You can override the permissions by setting the function's suppressAuth option to true.

Method Declaration
Copy
function getOrder(orderId: string, options: Options): Promise<Order>;
Method Parameters
orderIdstringRequired

ID of the order to get.


optionsOptions

Options to use when getting an order.

Returns
Return Type:Promise<Order>
JavaScript
import { Permissions, webMethod } from "wix-web-module"; import { orders } from "wix-pricing-plans-backend"; // Sample orderId: '02b7de48-b433-4d4b-b847-08c41c2b2b78' export const myGetOrderFunction = webMethod( Permissions.Anyone, async (orderId) => { try { const order = await orders.getOrder(orderId); const id = order._id; const status = order.status; return order; } catch (error) { console.error(error); } }, ); /* Promise resolves to: * { * "_id": "02b7de48-b433-4d4b-b847-08c41c2b2b78", * "planId": "7251b9e9-3852-4e9f-958e-af630f039802", * "subscriptionId": "45f4ab2c-bc09-4736-be68-674cc2169ad1", * "buyer": { * "memberId": "4c47c608-cfa8-4037-93ac-738f09560ed3", * "contactId": "4c47c608-cfa8-4037-93ac-738f09560ed3" * }, * "priceDetails": { * "subtotal": "0", * "discount": "0", * "total": "0", * "planPrice": "0", * "currency": "USD", * "singlePaymentUnlimited": true * }, * "pricing": { * "singlePaymentUnlimited": true, * "prices": [ * { * "duration": { * "cycleFrom": 1 * }, * "price": { * "subtotal": "0", * "discount": "0", * "total": "0", * "currency": "USD" * } * } * ] * }, * "type": "ONLINE", * "orderMethod": "UNKNOWN", * "status": "ACTIVE", * "lastPaymentStatus": "NOT_APPLICABLE", * "startDate": "2021-10-31T11:00:00.000Z", * "pausePeriods": [], * "currentCycle": { * "index": 1, * "startedDate": "2021-10-31T11:00:00.000Z" * }, * "planName": "Family Cooking", * "planDescription": "Weekly delivery of home cooking recipes and time-saving tips", * "planPrice": "0", * "_createdDate": "2021-09-02T06:13:28.595Z", * "_updatedDate": "2021-09-02T06:13:28.738Z" * } */
Errors

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

Did this help?