Marks a pricing plan as the primary pricing plan.
The makePlanPrimary()
function returns a Promise that resolves to the
pricing plan that is now the primary one.
Only a single plan can be marked as a primary plan at any given time. If
there is an existing plan marked as primary, calling makePlanPrimary()
causes the existing primary plan to lose its status.
When viewing pricing plans on the site, the primary plan is highlighted with a customizable ribbon.
Only users with "Manage Pricing Plans" permissions can mark a plan as a primary plan.
function makePlanPrimary(id: string): Promise<Plan>;
ID of the plan to be set as the primary plan.
import { Permissions, webMethod } from "wix-web-module";
import wixPricingPlansBackend from "wix-pricing-plans-backend";
export const myMakePlanPrimaryFunction = webMethod(Permissions.Anyone, () => {
const planId = "3743d382-a4d4-7e15-ada5-340ad4b5d760";
return wixPricingPlansBackend
.makePlanPrimary(planId)
.then((plan) => {
console.log(plan);
})
.catch((error) => {
console.error(error);
});
});
/* Full plan object - primary is true:
*
* {
* "plan": {
* "_id": "3743d382-a4d4-7e15-ada5-340ad4b5d760",
* "name": "Ultimate",
* "description": "The ultimate gaming experience",
* "perks": [
* "There are no words to describe this extreme game",
* "Easy yet challenging"
* ],
* "pricing": {
* "subscription": {
* "cycleDuration": {
* "count": 1,
* "unit": "YEAR"
* },
* "cycleCount": 0
* },
* "price": {
* "value": "50",
* "currency": "USD"
* }
* },
* "public": true,
* "archived": false,
* "primary": true,
* "hasOrders": false,
* "_createdDate": "2020-12-21T15:13:03.444Z",
* "_updatedDate": "2020-12-31T11:51:16.859Z",
* "slug": "ultimate",
* "allowFutureStartDate": false,
* "buyerCanCancel": true
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.