Search.../

setPlanVisibility( )

Sets visibility for non-archived pricing plans.

Description

The setPlanVisibility() functions returns a Promise that resolves to a pricing plan when its visibility has successfully been set.

By default, pricing plans are public, meaning they are visible. Plans can be hidden so that site members and visitors cannot see or choose them.

As opposed to archiving, setting visibility can be reversed. This means that a public plan can be hidden, and a hidden plan can be made public (visible).

Note: An archived plan always remains archived and cannot be made active again. When archiving a plan, its public property is automatically set to false so that it is hidden.

Changing a plan's visibility does not impact existing orders for the plan. All orders for hidden plans are still active and keep their terms and payment options.

Admin Method

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

Syntax

function setPlanVisibility(_id: string, visible: boolean): Promise<SetPlanVisibilityResponse>

setPlanVisibility Parameters

NAME
TYPE
DESCRIPTION
_id
string

The ID of the plan to either display or hide on the site page.

visible
boolean

Whether to set the plan as visible.

Returns

Fulfilled - The plan's information.

Rejected - Error message.

Return Type:

Promise<
SetPlanVisibilityResponse
>
NAME
TYPE
DESCRIPTION
plan
Plan

Plan info.

Was this helpful?

Hide a plan (dashboard page code)

Copy Code
1import { plans } from 'wix-pricing-plans.v2';
2
3/* Sample _id value: 'cb4a8c57-273a-4567-94e3-cc43d5d339f2'
4 *
5 * Sample visible value: false
6 */
7
8export async function mySetPlanVisibilityFunction(_id, visible) {
9 try {
10 const hiddenPlan = plans.setPlanVisibility(_id,visible);
11
12 return hiddenPlan;
13 } catch(error) {
14 console.error(error);
15 // Handle the error
16 }
17}
18
19/* Promise resolves to:
20 * {
21 * "plan": {
22 * "_createdDate": "2024-01-07T07:10:30.074Z",
23 * "_id": "cb4a8c57-273a-4567-94e3-cc43d5d339f2",
24 * "_updatedDate": "2024-01-14T09:29:12.581Z",
25 * "allowFutureStartDate": false,
26 * "archived": false,
27 * "buyerCanCancel": true,
28 * "description": "3 mo free trial with discount for 1 year",
29 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",
30 * "hasOrders": false,
31 * "maxPurchasesPerBuyer": 0,
32 * "name": "Beginner's Plan",
33 * "perks": {
34 * "values": []
35 * },
36 * "primary": false,
37 * "pricing": {
38 * "cycleCount": 2,
39 * "cycleDuration": {
40 * "count": 1,
41 * "unit": "YEAR"
42 * },
43 * "freeTrialDays": 90,
44 * "price": {
45 * "currency": "EUR",
46 * "value": "50"
47 * },
48 * "subscription": {
49 * "cycleCount": 2,
50 * "cycleDuration": {
51 * "count": 1,
52 * "unit": "YEAR"
53 * }
54 * }
55 * },
56 * "public": false,
57 * "slug": "beginners-plan",
58 * "termsAndConditions": ""
59 * }
60 * }
61 */
Hide a plan (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { plans } from 'wix-pricing-plans.v2';
3import { elevate } from 'wix-auth';
4
5/* Sample _id value: 'cb4a8c57-273a-4567-94e3-cc43d5d339f2'
6 *
7 * Sample visible value: false
8 */
9
10export const mySetPlanVisibilityFunction = webMethod(Permissions.Anyone, async (_id, visible) => {
11 try {
12 const elevatedSetPlanVisibility = elevate(plans.setPlanVisibility);
13 const hiddenPlan = elevatedSetPlanVisibility(_id,visible);
14
15 return hiddenPlan;
16 } catch(error) {
17 console.error(error);
18 // Handle the error
19 }
20});
21
22/* Promise resolves to:
23 * {
24 * "plan": {
25 * "_createdDate": "2024-01-07T07:10:30.074Z",
26 * "_id": "cb4a8c57-273a-4567-94e3-cc43d5d339f2",
27 * "_updatedDate": "2024-01-14T09:29:12.581Z",
28 * "allowFutureStartDate": false,
29 * "archived": false,
30 * "buyerCanCancel": true,
31 * "description": "3 mo free trial with discount for 1 year",
32 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",
33 * "hasOrders": false,
34 * "maxPurchasesPerBuyer": 0,
35 * "name": "Beginner's Plan",
36 * "perks": {
37 * "values": []
38 * },
39 * "primary": false,
40 * "pricing": {
41 * "cycleCount": 2,
42 * "cycleDuration": {
43 * "count": 1,
44 * "unit": "YEAR"
45 * },
46 * "freeTrialDays": 90,
47 * "price": {
48 * "currency": "EUR",
49 * "value": "50"
50 * },
51 * "subscription": {
52 * "cycleCount": 2,
53 * "cycleDuration": {
54 * "count": 1,
55 * "unit": "YEAR"
56 * }
57 * }
58 * },
59 * "public": false,
60 * "slug": "beginners-plan",
61 * "termsAndConditions": ""
62 * }
63 * }
64 */
65