> Portal Navigation: > > - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version. > - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages). > - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`). > - Top-level index of all portals: https://dev.wix.com/docs/llms.txt > - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt # Method name: previewOnlineOrder(planId: string, options: PreviewOnlineOrderOptions) # Method package: wixPricingPlansBackend # Method menu location: wixPricingPlansBackend --> Checkout --> previewOnlineOrder # Method Link: https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/checkout/preview-online-order.md # Method Description: Provides a preview of an online order as if it was purchased. The `previewOnlineOrder()` function returns a Promise that resolves to a temporary preview of the online order. The buyer must be logged in to preview an online order. 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's `_id` and `subscriptionId` properties are displayed as a string of multiple zero characters (`000000-0000`). If [taxes are configured for the site](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection), taxes are applied to the preview. If not, the `tax` previews as`null`. You can preview the order to check purchase limitations, but the limitations are not enforced for the preview. 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`. This function is available to the site owner and the buyer. Because the buyer is logged in, you do not need to specify the `buyerId` when previewing an online order. To get a general price preview for a plan that's not buyer-specific, use the [previewPrice()](wix-pricing-plans-backend/checkout/preview-price) function. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Preview an online order as if it was purchased with a coupon ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { checkout } from 'wix-pricing-plans-backend'; /* Sample planId value: '38b3021a-8b43-4a31-98cc-4a05b522b7d3' * * Sample startDate value: new Date('August 01, 2022 11:00:00') */ export const myPreviewOnlineOrderFunction = webMethod(Permissions.Anyone, async (planId, startDate) => { try { const preview = await checkout.previewOnlineOrder(planId, startDate); const maxReached = preview.purchaseLimitExceeded; const orderPricing = preview.order.pricing; return preview; } catch (error) { console.error(error); }; }); /* Promise resolves to: * * { * "order": { * "_id": "00000000-0000-0000-0000-000000000000", * "planId": "38b3021a-8b43-4a31-98cc-4a05b522b7d3", * "subscriptionId": "00000000-0000-0000-0000-000000000000", * "buyer": { * "memberId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86", * "contactId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86" * }, * "priceDetails": { * "subtotal": "10", * "discount": "0", * "total": "10", * "planPrice": "10", * "currency": "USD", * "subscription": { * "cycleDuration": { * "count": 1, * "unit": "MONTH" * }, * "cycleCount": 12 * }, * "freeTrialDays": 30 * }, * "pricing": { * "subscription": { * "cycleDuration": { * "count": 1, * "unit": "MONTH" * }, * "cycleCount": 12 * }, * "prices": [ * { * "duration": { * "cycleFrom": 1, * "numberOfCycles": 12 * }, * "price": { * "subtotal": "10", * "discount": "0", * "total": "10", * "currency": "USD" * } * } * ] * }, * "type": "ONLINE", * "orderMethod": "UNKNOWN", * "status": "ACTIVE", * "autoRenewCanceled": false, * "lastPaymentStatus": "PAID", * "startDate": "2022-08-01T11:00:00.000Z", * "endDate": "2023-08-31T11:00:00.000Z", * "pausePeriods": [], * "freeTrialDays": 30, * "earliestEndDate": "2023-08-31T11:00:00.000Z", * "planName": "Diabetic Cooking", * "planDescription": "Special recipes for those with diabetes.", * "planPrice": "10", * "_createdDate": "2022-07-13T05:02:40.265Z", * "_updatedDate": "2022-07-13T05:02:40.265Z" * }, * "purchaseLimitExceeded": false * } */ ``` ---