> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

# Method name: makePlanPrimary(_id: string)

# Method package: wixPricingPlansV2

# Method menu location: wixPricingPlansV2 --> plans --> makePlanPrimary

# Method Link: https://dev.wix.com/docs/velo/apis/wix-pricing-plans-v2/plans/make-plan-primary.md

# Method Description:

Marks a pricing plan as the primary pricing plan. When viewing pricing plans on a site, the primary plan is highlighted with a customizable ribbon. 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 Make Plan Primary causes the existing primary plan to lose its primary status.



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Make a plan a primary plan (dashboard page code)

```javascript
import { plans } from 'wix-pricing-plans.v2';

/* Sample _id value: '0b9a1993-c1ff-4952-9575-915b48d1a5e0' */

export async function myMakePlanPrimaryFunction(_id) {
  try {
    const primaryPlan = await plans.makePlanPrimary(_id);

    return primaryPlan;
  } catch(error) {
    console.error(error);
    // Handle the error
  }
}

/* Promise resolves to:
 * {
 *   "_id": "b20feb39-a452-453e-96ee-01036adcd04e",
 *   "_createdDate": "2024-01-07T07:33:59.973Z",
 *   "_updatedDate": "2024-01-07T13:32:11.263Z",
 *   "allowFutureStartDate": false,
 *   "archived": false,
 *   "buyerCanCancel": true,
 *   "description": "Full feature enablement - lifetime plan",
 *   "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",
 *   "hasOrders": false,
 *   "maxPurchasesPerBuyer": 0,
 *   "name": "Premium Plan - Lifetime Membership",
 *   "perks": {
 *     "values": [
 *       "Cloud drive and file upload services",
 *       "Unlimited video content access"
 *     ]
 *   },
 *   "pricing": {
 *     "price": {
 *       "currency": "EUR",
 *       "value": "1000"
 *     },
 *     "singlePaymentUnlimited": true
 *   },
 *   "primary": true,
 *   "public": true,
 *   "slug": "premium-plan-lifetime-membership",
 *   "termsAndConditions": "This plan allows unlimited app and site features usage for all time, subject to our fair usage agreement and basic human decency agreement."
 * }
 */
```

## Make a plan a primary plan (export from backend code)

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { plans } from 'wix-pricing-plans.v2';
import { elevate } from 'wix-auth';

/* Sample _id value: '0b9a1993-c1ff-4952-9575-915b48d1a5e0' */

export const myMakePlanPrimaryFunction = webMethod(Permissions.Anyone, async (_id) => {
  try {
    const elevatedMakePlanPrimary = elevate(plans.makePlanPrimary);
    const primaryPlan = await elevatedMakePlanPrimary(_id);

    return primaryPlan;
  } catch(error) {
    console.error(error);
    // Handle the error
  }
});

/* Promise resolves to:
 * {
 *   "_id": "b20feb39-a452-453e-96ee-01036adcd04e",
 *   "_createdDate": "2024-01-07T07:33:59.973Z",
 *   "_updatedDate": "2024-01-07T13:32:11.263Z",
 *   "allowFutureStartDate": false,
 *   "archived": false,
 *   "buyerCanCancel": true,
 *   "description": "Full feature enablement - lifetime plan",
 *   "formId": "ee62cefa-bdc2-4b5d-baab-6faeef83cecb",
 *   "hasOrders": false,
 *   "maxPurchasesPerBuyer": 0,
 *   "name": "Premium Plan - Lifetime Membership",
 *   "perks": {
 *     "values": [
 *       "Cloud drive and file upload services",
 *       "Unlimited video content access"
 *     ]
 *   },
 *   "pricing": {
 *     "price": {
 *       "currency": "EUR",
 *       "value": "1000"
 *     },
 *     "singlePaymentUnlimited": true
 *   },
 *   "primary": true,
 *   "public": true,
 *   "slug": "premium-plan-lifetime-membership",
 *   "termsAndConditions": "This plan allows unlimited app and site features usage for all time, subject to our fair usage agreement and basic human decency agreement."
 * }
 */

```

## Make a plan primary  

```javascript
/*************************************
 * Backend code - plan-functions.web.js *
 *************************************/

import { Permissions, webMethod } from 'wix-web-module';
import { plans } from 'wix-pricing-plans.v2';
import { elevate } from 'wix-auth';

const elevatedListPublicPlans = elevate(plans.listPublicPlans);
const elevatedMakePlanPrimary = elevate(plans.makePlanPrimary);

export const listPublicPlans = webMethod(Permissions.Anyone, async () => {
  try {
    const response = await elevatedListPublicPlans();
    const plansList = response.plans;

    return plansList;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
});

export const makePlanPrimaryFunction = webMethod(Permissions.Anyone, async (_id) => {
  try {
    const primaryPlan = await elevatedMakePlanPrimary(_id);

    return primaryPlan;
  } catch (error) {
    console.error(error);
    // Handle the error
  }
});

/*************
 * Page code *
 *************/

import { listPublicPlans, makePlanPrimaryFunction } from 'backend/plan-functions.web';

$w.onReady(function () {
  populateDropdown();
  $w('#plansList').onChange(async () => {
    await makePlanPrimaryFunction(
      $w('#plansList').value
    )
  });
});

async function populateDropdown() {
  const plans = await listPublicPlans();
  $w('#plansList').options = plans.map(item => ({
    label: item.name,
    value: item._id
  })
  )
}
```

---