Search.../

setPlanVisibility( )

Sets visibility for non-archived pricing plans. Public plans are plans that are set to visible.

Description

The setPlanVisibility() function 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 visibility 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.

Only users with "Manage Pricing Plans" permissions can change plan visibility.

Syntax

function setPlanVisibility(id: string, visible: boolean): Promise<Plan>

setPlanVisibility Parameters

NAME
TYPE
DESCRIPTION
id
string

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

visible
boolean

Whether the plan is visible.

Returns

Fulfilled - The plan's information. Rejected - Error message.

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?

Hide a plan

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import wixPricingPlansBackend from 'wix-pricing-plans-backend';
3
4export const mySetPlanVisibilityFunction = webMethod(Permissions.Anyone, () => {
5 const planId = '3743d382-a4d4-7e15-ada5-340ad4b5d760';
6 const visibilityToggle = false;
7 return wixPricingPlansBackend.setPlanVisibility(planId, visibilityToggle)
8 .then(() => {
9 console.log("Plan hidden"); // Plan is visible in the Dashboard
10 })
11 .catch((error) => {
12 console.error(error);
13 });
14 });
15
16/* Full event object:
17 * {
18 * "metadata": {
19 * "id": "3743d382-a4d4-7e15-ada5-340ad4b5d760",
20 * "entityId": "c61bbc26-a4d4-7e15-ada5-f99803abce33",
21 * "eventTime": "2020-02-03T10:13:15.194Z",
22 * "triggeredByAnonymizeRequest": false
23 * },
24 * "entity": {
25 * "_id": "c61bbc26-a4d4-7e15-ada5-f99803abce33",
26 * "name": "Full membership",
27 * "description":"Full membership including weekends",
28 * "perks": [
29 * "Free parking",
30 * "Express line"
31 * ],
32 * "pricing": {
33 * "singlePaymentUnlimited": true,
34 * "price": {
35 * "value": "40",
36 * "currency": "USD"
37 * }
38 * },
39 * "public" : true,
40 * "_createdDate": "2020-02-03T10:13:15.194Z",
41 * "_updatedDate": "2020-02-03T10:13:15.194Z",
42 * "slug":"full-membership",
43 * "maxPurchasesPerBuyer": 1,
44 * "allowFutureStartDate": false,
45 * "buyerCanCancel": true,
46 * "termsAndConditions": "Copyright laws apply."
47 * }
48 * }
49 */