getOfflineOrderPreview( )


Performs a dry run of a purchase and provides an order preview.

The preview uses the same logic as purchasing a plan, but the preview is not saved. Because an order is not actually created, the preview order's orderId and subscriptionId are displayed as a string of multiple zero characters (000000-0000). Tax is only calculated if the site has it configured.
If a pricing plan has a limit on the amount of purchases per buyer, that limit is not considered for generating the preview. But, if that limit has been reached and this order would then exceed the amount of purchases permitted for this buyer, then purchaseLimitExceeded will return as true.

To get a general price preview for a plan that's not buyer-specific, call Get Price Preview.

Authentication

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

Permissions
Manage Orders
Learn more about app permissions.
Method Declaration
Copy
function getOfflineOrderPreview(
  planId: string,
  memberId: string,
  options: GetOfflineOrderPreviewOptions,
): Promise<GetOfflineOrderPreviewResponse>;
Method Parameters
planIdstringRequired

ID of the plan of the previewed order.


memberIdstringRequired

Member ID of the buyer the previewed order is for, from the Members API.


optionsGetOfflineOrderPreviewOptions

Options for previewing the offline order.

Returns
Return Type:Promise<GetOfflineOrderPreviewResponse>
JavaScript
import { orders } from "wix-pricing-plans.v2"; /* Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10' * * Sample memberId value: '695568ff-1dc2-49ff-83db-2b518d35692b' */ export async function myGetOfflineOrderPreviewFunction(planId, memberId) { try { const orderPreview = await orders.getOfflineOrderPreview(planId, memberId); return orderPreview; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * order: { * "_createdDate": "2024-01-31T08:51:46.516Z", * "_id": "00000000-0000-0000-0000-000000000000", * "_updatedDate": "2024-01-31T08:51:46.516Z", * "autoRenewCanceled": false, * "buyer": { * "contactId": "695568ff-1dc2-49ff-83db-2b518d35692b", * "memberId": "695568ff-1dc2-49ff-83db-2b518d35692b" * }, * "currentCycle": { * "endedDate": "2024-03-01T08:51:46.516Z", * "index": 0, * "startedDate": "2024-01-31T08:51:46.516Z" * }, * "cycles": [ * { * "endedDate": "2024-03-01T08:51:46.516Z", * "index": 0, * "startedDate": "2024-01-31T08:51:46.516Z" * } * ], * "endDate": "2026-03-01T08:51:46.516Z", * "earliestEndDate": "2026-03-01T08:51:46.516Z", * "formData": { * "submissionData": {} * }, * "freeTrialDays": 30, * "lastPaymentStatus": "PAID", * "order": { * "autoRenewCanceled": false, * "buyer": { * "contactId": "695568ff-1dc2-49ff-83db-2b518d35692b", * "memberId": "695568ff-1dc2-49ff-83db-2b518d35692b" * }, * "currentCycle": { * "endedDate": "2024-03-01T08:51:46.516Z", * "index": 0, * "startedDate": "2024-01-31T08:51:46.516Z" * }, * "cycles": [ * { * "endedDate": "2024-03-01T08:51:46.516Z", * "index": 0, * "startedDate": "2024-01-31T08:51:46.516Z" * } * ], * "endDate": "2026-03-01T08:51:46.516Z", * "earliestEndDate": "2026-03-01T08:51:46.516Z", * "formData": { * "submissionData": {} * }, * "freeTrialDays": 30, * "lastPaymentStatus": "PAID", * "orderMethod": "UNKNOWN", * "orderType": "OFFLINE", * "pausePeriods": [], * "planDescription": "Complete with all features. One month free trial.", * "planId": "838f2c9d-c8d0-4799-a10a-e2f23849db10", * "planName": "Premium Plan - annual - 30 day trial", * "planPrice": "500", * "priceDetails": { * "currency": "USD", * "discount": "0", * "freeTrialDays": 30, * "planPrice": "500", * "subtotal": "500.00", * "total": "500.00", * "subscription": { * "cycleCount": 2, * "cycleDuration": { * "count": 1, * "unit": "YEAR" * } * } * }, * "pricing": { * "prices": [ * { * "duration": { * "cycleFrom": 1, * "numberOfCycles": 2 * }, * "price": { * "currency": "USD", * "discount": "0", * "fees": [], * "proration": "0", * "subtotal": "500.00", * "total": "500.00" * } * } * ], * "subscription": { * "cycleCount": 2, * "cycleDuration": { * "count": 1, * "unit": "YEAR" * } * } * }, * "seller": { * "subscriptionId": "00000000-0000-0000-0000-000000000000" * }, * "startDate": "2024-01-31T08:51:46.516Z", * "status": "ACTIVE", * "statusNew": "ACTIVE", * "type": "OFFLINE" * }, * "orderMethod": "UNKNOWN", * "pausePeriods": [], * "planDescription": "Complete with all features. One month free trial.", * "planId": "838f2c9d-c8d0-4799-a10a-e2f23849db10", * "planName": "Premium Plan - annual - 30 day trial", * "planPrice": "500", * "pricing": { * "prices": [ * { * "duration": { * "cycleFrom": 1, * "numberOfCycles": 2 * }, * "price": { * "currency": "USD", * "discount": "0", * "fees": [], * "proration": "0", * "subtotal": "500.00", * "total": "500.00" * } * } * ], * "subscription": { * "cycleCount": 2, * "cycleDuration": { * "count": 1, * "unit": "YEAR" * } * } * }, * "startDate": "2024-01-31T08:51:46.516Z", * "status": "ACTIVE", * "statusNew": "ACTIVE", * "subscriptionId": "00000000-0000-0000-0000-000000000000", * "type": "OFFLINE" * } * "purchaseLimitExceeded": false * } */
Errors
400Invalid Argument

There are 2 errors with this status code.

428Failed Precondition

There are 9 errors with this status code.

This method may also return standard errors. Learn more about standard Wix errors.

Did this help?