Search.../

getPricePreview( )

Retrieves a preview of an order's pricing as if it was purchased.

Description

The getPricePreview() function returns a Promise that resolves to a temporary preview of the order's price.

The price preview uses the same logic for calculating prices as used when purchasing a plan, but the preview is not saved. If taxes are configured for the site, taxes are applied to the preview. If not, the tax previews as null.

Buyers do not have to be logged in to preview the price, as such, the details returned by this function are not buyer-specific. To generate a preview of a purchase for a specific-buyer, use the getOfflineOrderPreview().

Syntax

function getPricePreview(planId: string, options: GetPricePreviewOptions): Promise<GetPricePreviewResponse>

getPricePreview Parameters

NAME
TYPE
DESCRIPTION
planId
string

ID of plan to preview.

options
Optional
GetPricePreviewOptions

Options for getting a price preview.

Returns

Fulfilled - A preview of the pricing for the order.

Return Type:

Promise<
GetPricePreviewResponse
>
NAME
TYPE
DESCRIPTION
prices
Array<
SpannedPrice
>

Pricing details.

Was this helpful?

getPricePreview example

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