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

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