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.

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
Optional
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
Optional
string

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

Was this helpful?

Hide a plan

Code Example

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