This API is subject to change. Bug fixes and new features will be released based on developer feedback throughout the preview period.
Retrieves a preview of an order's pricing as if it was purchased.
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()
.
function getPricePreview(
planId: string,
options: GetPricePreviewOptions,
): Promise<GetPricePreviewResponse>;
ID of plan to preview.
Options for getting a price preview.
import { orders } from "wix-pricing-plans.v2";
/* Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10' */
export async function myGetPricePreviewFunction(planId) {
try {
const pricePreview = await orders.getPricePreview(planId);
return pricePreview;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "prices": [
* {
* "duration": {
* "cycleFrom": 1,
* "numberOfCycles": 2
* },
* "price": {
* "currency": "USD",
* "discount": "0"
* "proration": "0",
* "subtotal": "500.00",
* "tax": {
* "name": "Tax",
* "includedInPrice": false,
* "rate": "6.5",
* "amount": "32.50"
* },
* "total": "532.50"
* }
* }
* ]
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.