Search.../

archivePlan( )

Archives a single 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 public 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.

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

Admin Method

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

Syntax

function archivePlan(_id: string): Promise<ArchivePlanResponse>

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<
ArchivePlanResponse
>
NAME
TYPE
DESCRIPTION
plan
Plan

Archived plan info.

Was this helpful?

Archive a plan (dashboard page code)

Copy Code
1import { plans } from 'wix-pricing-plans.v2';
2
3/* Sample _id value: '1421abaa-44c7-42ae-8a75-960fe7a8aa55' */
4
5export async function myArchivePlanFunction(_id) {
6 try {
7 const archivedPlan = await plans.archivePlan(_id);
8
9 return archivedPlan;
10 } catch(error) {
11 console.error(error);
12 // Handle the error
13 }
14}
15
16/* Promise resolves to:
17 * {
18 * "_createdDate": "2023-12-31T11:23:01.664Z",
19 * "_id": "1421abaa-44c7-42ae-8a75-960fe7a8aa55",
20 * "_updatedDate": "2024-01-08T11:24:18.561Z",
21 * "allowFutureStartDate": false,
22 * "archived": true,
23 * "buyerCanCancel": true,
24 * "description": "Free Plan",
25 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",
26 * "hasOrders": false,
27 * "maxPurchasesPerBuyer": 0,
28 * "name": "Basic",
29 * "perks": {
30 * "values": []
31 * },
32 * "pricing": {
33 * "price": {
34 * "currency": "EUR",
35 * "value": "0"
36 * },
37 * "singlePaymentForDuration": {
38 * "count": 3,
39 * "unit": "MONTH"
40 * }
41 * },
42 * "primary": false,
43 * "public": false,
44 * "slug": "basic",
45 * "termsAndConditions": "After 90 day free trial ends, your plan will end and you will need to purchase a paid plan."
46 * }
47 */
Archive 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: '1421abaa-44c7-42ae-8a75-960fe7a8aa55' */
6
7export const myArchivePlanFunction = webMethod(Permissions.Anyone, async (_id) => {
8 try {
9 const elevatedArchivePlan = elevate(plans.archivePlan);
10 const archivedPlan = await elevatedArchivePlan(_id);
11
12 return archivedPlan;
13 } catch(error) {
14 console.error(error);
15 // Handle the error
16 }
17});
18
19/* Promise resolves to:
20 * {
21 * "_createdDate": "2023-12-31T11:23:01.664Z",
22 * "_id": "1421abaa-44c7-42ae-8a75-960fe7a8aa55",
23 * "_updatedDate": "2024-01-08T11:24:18.561Z",
24 * "allowFutureStartDate": false,
25 * "archived": true,
26 * "buyerCanCancel": true,
27 * "description": "Free Plan",
28 * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",
29 * "hasOrders": false,
30 * "maxPurchasesPerBuyer": 0,
31 * "name": "Basic",
32 * "perks": {
33 * "values": []
34 * },
35 * "pricing": {
36 * "price": {
37 * "currency": "EUR",
38 * "value": "0"
39 * },
40 * "singlePaymentForDuration": {
41 * "count": 3,
42 * "unit": "MONTH"
43 * }
44 * },
45 * "primary": false,
46 * "public": false,
47 * "slug": "basic",
48 * "termsAndConditions": "After 90 day free trial ends, your plan will end and you will need to purchase a paid plan."
49 * }
50 */