Search.../

getOfflineOrderPreview( )

Provides a preview of an offline order as if it was purchased.

Description

The getOfflineOrderPreview() function returns a Promise that resolves to a temporary preview of the offline 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, taxes are applied to the preview. If not, 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. Thus function is not available to the buyer. You specify the member ID for the buyer whose order should be previewed. To get a general price preview for a plan that's not buyer-specific, use the getPricePreview() function.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function getOfflineOrderPreview(planId: string, options: GetOfflineOrderPreviewOptions): Promise<GetOfflineOrderPreviewResponse>

getOfflineOrderPreview Parameters

NAME
TYPE
DESCRIPTION
planId
string

ID of the plan of the previewed order.

options
Optional
GetOfflineOrderPreviewOptions

Options for previewing the offline order.

Returns

Fulfilled - A preview of the order.

Return Type:

Promise<
GetOfflineOrderPreviewResponse
>
NAME
TYPE
DESCRIPTION
order
Order

The previewed order, as if the plan had been ordered.

purchaseLimitExceeded
boolean

Whether this previewed order would exceed the permitted amount of purchases available for this plan for this buyer.

Always false for plans that do not have purchase limits.

Was this helpful?

getOfflineOrderPreview example

Copy Code
1import { orders } from 'wix-pricing-plans.v2';
2
3 async function getOfflineOrderPreview(planId, options) {
4 try {
5 const result = await orders.getOfflineOrderPreview(planId, options);
6
7 return result;
8 } catch (error) {
9 console.error(error);
10 // Handle the error
11 }
12 }
13