Gets an existing pricing plan by ID.
The getPlan()
function returns a Promise that resolves to a plan whose ID
matches the given ID.
Only users with "Manage Pricing Plans" permissions can get plans.
function getPlan(id: string): Promise<Plan>;
The ID of the plan to get.
import { Permissions, webMethod } from "wix-web-module";
import wixPricingPlansBackend from "wix-pricing-plans-backend";
export const myGetPlanFunction = webMethod(Permissions.Anyone, () => {
const id = "001c0674-d7c9-4c77-acb5-b492b427b201";
return wixPricingPlansBackend
.getPlan(id)
.then((plan) => {
console.log(plan);
})
.catch((error) => {
console.error(error);
});
});
/* Full plan object:
* {
* "_id": "001c0674-d7c9-4c77-acb5-b492b427b201",
* "name": "Gold",
* "description": "For expert gamers",
* "perks": [
* "Great value for your money",
* "Multi-user"
* ],
* "pricing": {
* "subscription": {
* "cycleDuration": {
* "count": 1,
* "unit": "MONTH"
* },
* "cycleCount": 2
* },
* "price": {
* "value": "100",
* "currency": "USD"
* },
* "freeTrialDays": 10
* },
* "public": true,
* "archived": false,
* "primary": false,
* "hasOrders": false,
* "_createdDate": "2020-12-24T11:23:48.308Z",
* "_updatedDate": "2020-12-30T11:39:45.523Z",
* "slug": "gold",
* "maxPurchasesPerBuyer": 1,
* "allowFutureStartDate": false,
* "buyerCanCancel": true,
* "termsAndConditions": "No sharing please."
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.