Retrieves a pricing plan by the specified ID.
The getPlan()
function returns a Promise that resolves to a plan whose ID matched the specified ID.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function getPlan(_id: string): Promise<Plan>;
Plan ID.
import { plans } from "wix-pricing-plans.v2";
/* Sample _id value: '838f2c9d-c8d0-4799-a10a-e2f23849db10' */
export async function myGetPlanFunction(_id) {
try {
const myPlan = await plans.getPlan(_id);
return myPlan;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Promise resolves to:
* {
* "_createdDate": "2024-01-07T07:28:42.863Z",
* "_id": "838f2c9d-c8d0-4799-a10a-e2f23849db10",
* "_updatedDate": "2024-01-07T08:36:07.520Z",
* "allowFutureStartDate": false,
* "archived": false,
* "buyerCanCancel": true,
* "description": "Complete with all features. One month free trial.",
* "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",
* "hasOrders": false,
* "maxPurchasesPerBuyer": 0,
* "name": "Premium Plan - annual - 30 day trial",
* "perks": {
* "values": [
* "Unlimited video library streaming access",
* "File sharing enabled for all channels"
* ]
* },
* "pricing": {
* "freeTrialDays": 30,
* "price": {
* "currency": "EUR",
* "value": "500"
* },
* "subscription": {
* "cycleCount": 2,
* "cycleDuration": {
* "count": 1,
* "unit": "YEAR"
* }
* }
* },
* "primary": false,
* "public": true,
* "slug": "premium-plan-annual-30-day-trial-1",
* "termsAndConditions": "Unlimited usage of services, subject to Fair Usage and Code of Conduct policies."
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.