Archives a single plan.
The archivePlan()
function returns a Promise that resolves to the newly-archived plan.
When a plan is archived, the plan
public
property is automatically set to false
.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.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function archivePlan(_id: string): Promise<ArchivePlanResponse>;
ID of the active plan to archive.
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."
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.