Search.../

getPlan( )

Gets an existing pricing plan by ID.

Description

The getPlan() function returns a Promise that resolves to a plan whose ID matches the given ID.

Only users with "Manage Pricing Plans" permissions can get plans.

Syntax

function getPlan(id: string): Promise<Plan>

getPlan Parameters

NAME
TYPE
DESCRIPTION
id
string

The ID of the plan to get.

Returns

Fulfilled - The retrieved plan's information.

Return Type:

Promise<Plan>
NAME
TYPE
DESCRIPTION
_id
string

Plan ID.

name
string

Plan name.

description
string

Plan description.

perks
Array<string>

List of text strings that promote the pricing plan (for example, "Plenty of parking" or "Free gift on your birthday").

pricing
Pricing

Plan price, payment schedule, and expiration.

public
boolean

Whether the plan is public (visible to site visitors).

archived
boolean

Whether the plan is archived. Archived plans are not visible and can't be purchased anymore, but existing purchases remain in effect.

primary
boolean

Whether the plan is marked as primary. If true, the plan is highlighted on the site with a custom ribbon. Defaults to false.

hasOrders
boolean

Whether the plan has any orders (including pending and unpaid orders).

_createdDate
Date

Date plan was created.

_updatedDate
Date

Date plan was last updated.

slug
string

URL-friendly version of the plan name. Unique across all plans in the same site.

allowFutureStartDate
boolean

Whether the buyer can start the plan at a later date.

buyerCanCancel
boolean

Whether the buyer is allowed to cancel their plan. If false, calling the cancelOrder() function returns an error.

maxPurchasesPerBuyer
number

Whether the same buyer can purchase the plan multiple times. 1 means the buyer can only purchase the plan once. An empty value or 0 means no limitation.

termsAndConditions
string

Any terms and conditions that apply to the plan. This information is displayed during checkout.

Was this helpful?

Get a plan

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import wixPricingPlansBackend from 'wix-pricing-plans-backend';
3
4export const myGetPlanFunction = webMethod(Permissions.Anyone, () => {
5 const id = '001c0674-d7c9-4c77-acb5-b492b427b201';
6
7 return wixPricingPlansBackend.getPlan(id)
8 .then((plan) => {
9 console.log(plan);
10 })
11 .catch((error) => {
12 console.error(error);
13 });
14});
15
16/* Full plan object:
17 * {
18 * "_id": "001c0674-d7c9-4c77-acb5-b492b427b201",
19 * "name": "Gold",
20 * "description": "For expert gamers",
21 * "perks": [
22 * "Great value for your money",
23 * "Multi-user"
24 * ],
25 * "pricing": {
26 * "subscription": {
27 * "cycleDuration": {
28 * "count": 1,
29 * "unit": "MONTH"
30 * },
31 * "cycleCount": 2
32 * },
33 * "price": {
34 * "value": "100",
35 * "currency": "USD"
36 * },
37 * "freeTrialDays": 10
38 * },
39 * "public": true,
40 * "archived": false,
41 * "primary": false,
42 * "hasOrders": false,
43 * "_createdDate": "2020-12-24T11:23:48.308Z",
44 * "_updatedDate": "2020-12-30T11:39:45.523Z",
45 * "slug": "gold",
46 * "maxPurchasesPerBuyer": 1,
47 * "allowFutureStartDate": false,
48 * "buyerCanCancel": true,
49 * "termsAndConditions": "No sharing please."
50 * }
51 */