> 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: getPlan(_id: string)

# Method package: wixPricingPlansV2

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

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

# Method Description:

Retrieves a pricing plan by ID.



# Method Code Examples:

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

## Get a plan (dashboard page code)

```javascript
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."
 * } 
 */
```

## Get a 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: '838f2c9d-c8d0-4799-a10a-e2f23849db10' */

export const myGetPlanFunction = webMethod(Permissions.Anyone, async (_id) => {
  try {
    const elevatedGetPlan = elevate(plans.getPlan);
    const myPlan = await elevatedGetPlan(_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."
 * } 
 */
```

## Duplicate a plan 

```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 elevatedListPlans = elevate(plans.listPlans);
const elevatedGetPlan = elevate(plans.getPlan);
const elevatedCreatePlan = elevate(plans.createPlan);

export const listPlans = webMethod(Permissions.Anyone, async () => {
  try {
    const response = await elevatedListPlans();
    const allPlans = response.plans;

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

export const getPlan = webMethod(Permissions.Anyone, async (planId) => {
  try {
    const selectedPlan = await elevatedGetPlan(planId);

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

export const createPlan = webMethod(Permissions.Anyone, async (plan) => {
  try {
    const newPlan = await elevatedCreatePlan(plan);

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


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

import { listPlans, getPlan, createPlan } from 'backend/plan-functions.web';
$w.onReady(async function () {
  $w('#plansDropdown').disable();
  $w('#clonePlanBtn').disable();
  populatePlansDropdown();

  let selectedPlan;

  $w('#plansDropdown').onChange(async () => {
    const planId = $w('#plansDropdown').value;
    selectedPlan = await getPlan(planId);

    // Set default value for the new plan name
    $w('#planName').value = `${selectedPlan.name}-duplicate`
    $w('#clonePlanBtn').enable();
  });
  
  $w('#clonePlanBtn').onClick(async () => {
    const newPlan = selectedPlan;
    // Use inputs to set the new plan name and price
    newPlan.name = $w('#planName').value;
    newPlan.pricing.price.value = $w('#price').value;

    await createPlan(newPlan);
  });
});

async function populatePlansDropdown() {
  const plans = await listPlans();
  $w('#plansDropdown').options = plans.map((plan) => {
    return {
      label: plan.name,
      value: plan._id
    }
  });
  $w('#plansDropdown').enable();
}
```

---