Search.../

archivePlan( )

Archives a single pricing plan.

Description

The archivePlan() function returns a promise that resolves to the newly-archived plan.

When a plan is archived, the plan:

  • Is no longer available for display or selection by visitors. This is because the plan's visibility property is automatically set to false.
  • Cannot be purchased.
  • Cannot be "un-archived" (meaning, the plan cannot be made active again).

Plan archiving does not impact existing purchases made for the plan. All purchases for the plan are still active and keep their payment options and terms.

Site owners can see archived plans in the Dashboard under Pricing Plans -> Archived Plans.

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

Note: An attempt to archive an already-archived plan throws an error.

Syntax

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

archivePlan Parameters

NAME
TYPE
DESCRIPTION
id
string

ID of the active plan to archive.

Returns

Fulfilled - The archived plan. 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?

Archive a plan

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import wixPricingPlansBackend from 'wix-pricing-plans-backend';
3
4export const myArchivePlanFunction = webMethod(Permissions.Anyone, () => {
5 const planId = '411a5551-b0f6-4826-8a41-ebae2879f857';
6 return wixPricingPlansBackend.archivePlan(planId)
7 .then((plan) => {
8 const archivedPlanId = plan._id;
9 console.log(archivedPlanId);
10 })
11 .catch((error) => {
12 console.error(error);
13 });
14});
15
16/* Returns a promise that resolves to a plan object for the archived plan:
17 *
18 * {
19 * "plan": {
20 * "_id": "411a5551-b0f6-4826-8a41-ebae2879f857",
21 * "name": "Gold",
22 * "description": "Gold membership to the MyGame World of Online Gaming",
23 * "perks": [
24 * "Multiplayer",
25 * "Multiple devices",
26 * "No ads",
27 * "Unlimited access"
28 * ],
29 * "pricing": {
30 * "subscription": {
31 * "cycleDuration": {
32 * "count": 1,
33 * "unit": "WEEK"
34 * },
35 * "cycleCount": 1
36 * },
37 * "price": {
38 * "value": "15",
39 * "currency": "USD"
40 * }
41 * },
42 * "public": false,
43 * "archived": true,
44 * "primary": false,
45 * "hasOrders": false,
46 * "_createdDate": "2020-12-21T15:13:09.492Z",
47 * "_updatedDate": "2020-12-30T08:02:14.867Z",
48 * "slug": "gold",
49 * "allowFutureStartDate": false,
50 * "buyerCanCancel": true,
51 * "termsAndConditions": "No sharing access with others!"
52 * }
53 */