archivePlan( )


Archives a single plan. When a plan is archived, it's no longer visible as a public plan that can be chosen by site members or visitors. This is because the plan's public property is automatically set to false. Archived plans can't be purchased or reactivated. Plan archiving doesn't impact existing orders made for the plan. All orders for the plan are still active and keep their perks, payment options, and terms. Wix users can see archived plans in a site's dashboard under Pricing Plans -> Archived Plans.

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

Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Manage Pricing Plans
Learn more about app permissions.
Method Declaration
Copy
function archivePlan(_id: string): Promise<ArchivePlanResponse>;
Method Parameters
_idstringRequired

ID of the active plan to archive.

Returns
Return Type:Promise<ArchivePlanResponse>
JavaScript
import { plans } from "wix-pricing-plans.v2"; /* Sample _id value: '1421abaa-44c7-42ae-8a75-960fe7a8aa55' */ export async function myArchivePlanFunction(_id) { try { const archivedPlan = await plans.archivePlan(_id); return archivedPlan; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "_createdDate": "2023-12-31T11:23:01.664Z", * "_id": "1421abaa-44c7-42ae-8a75-960fe7a8aa55", * "_updatedDate": "2024-01-08T11:24:18.561Z", * "allowFutureStartDate": false, * "archived": true, * "buyerCanCancel": true, * "description": "Free Plan", * "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb", * "hasOrders": false, * "maxPurchasesPerBuyer": 0, * "name": "Basic", * "perks": { * "values": [] * }, * "pricing": { * "price": { * "currency": "EUR", * "value": "0" * }, * "singlePaymentForDuration": { * "count": 3, * "unit": "MONTH" * } * }, * "primary": false, * "public": false, * "slug": "basic", * "termsAndConditions": "After 90 day free trial ends, your plan will end and you will need to purchase a paid plan." * } */
Errors
400Invalid Argument

There is 1 error with this status code.

428Failed Precondition

There is 1 error with this status code.

This method may also return standard errors. Learn more about standard Wix errors.

Did this help?