> 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: createOnlineOrder(planId: string, startDate: Date)

# Method package: wixPricingPlansFrontend

# Method menu location: wixPricingPlansFrontend --> Checkout --> createOnlineOrder

# Method Link: https://dev.wix.com/docs/velo/apis/wix-pricing-plans-frontend/checkout/create-online-order.md

# Method Description:

Orders a pricing plan.

To process pricing plans on a site, a site first must be set up to offer pricing plans
 as described in [Pricing Plans: An Overview](https://support.wix.com/en/article/pricing-plans-an-overview).
 When setting up a site to accept pricing plans, [define the plans you want to offer](https://support.wix.com/en/article/pricing-plans-creating-a-one-time-payment-plan).

 Ordering a plan places an order for the plan, without actually purchasing it. You can then continue the
 payment process with [Wix Pay](https://dev.wix.com/docs/velo/apis/wix-pay-frontend/introduction.md), which applies the plan to the buyer on completion of payment.

 To understand how `createOnlineOrder()` is used in a customized pricing plan lifecycle,
 see the Custom Purchase Flow API ([SDK](https://dev.wix.com/docs/sdk/frontend-modules/pricing-plans/custom-purchase-flow/introduction.md) | [Velo](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-frontend/custom-purchase-flow/introduction.md)).


 > **Note:**
 > + To work with the Pricing Plans API, a site needs to be published.



# Method Code Examples:

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

## Order a pricing plan by clicking a button

```javascript
import { checkout } from 'wix-pricing-plans-frontend';

// Sample planId value: '099e2c86-3b7e-4477-8c27-f77402b8cced'

$w.onReady(function () {
  $w('#myOrderButton').onClick((event) => {
    checkout.createOnlineOrder(planId)
    .then((order) => {
      const id = order._id;
      const status = order.status;  
      
      console.log('Success! Created order:', order);
      return order;
    })
    .catch((error) => {
      console.error(error);
    })
  });
});

/* Promise resolves to: 
 * {
 *   "_id": "ec66a557-5f23-4b71-91c5-6ea98a694537",
 *   "planId": "099e2c86-3b7e-4477-8c27-f77402b8cceb",
 *   "subscriptionId": "6f61e080-be4a-4859-a49e-b44b5da87129",
 *   "wixPayOrderId": "d7c01c4b-c04d-4ebe-bd66-3973fa1fdb53",
 *   "buyer": {
 *     "memberId": "0c9bca47-1f00-4b92-af1c-7852452e949a",
 *     "contactId": "0c9bca47-1f00-4b92-af1c-7852452e949a"
 *   },
 *   "priceDetails": {
 *     "subtotal": "74.99",
 *     "discount": "0",
 *     "total": "74.99",
 *     "planPrice": "74.99",
 *     "currency": "EUR",
 *     "subscription": {
 *       "cycleDuration": {
 *         "count": 1,
 *         "unit": "MONTH"
 *       },
 *       "cycleCount": 3
 *     }
 *   },
 *   "pricing": {
 *     "subscription": {
 *       "cycleDuration": {
 *         "count": 1,
 *         "unit": "MONTH"
 *       },
 *         "cycleCount": 3
 *     },
 *     "prices": [
 *       {
 *         "duration": {
 *           "cycleFrom": 1,
 *           "numberOfCycles": 3
 *         },
 *         "price": {
 *           "subtotal": "74.99",
 *           "discount": "0",
 *           "total": "74.99",
 *           "currency": "EUR"
 *         }
 *     }]
 *   },
 *   "type": "ONLINE",
 *   "orderMethod": "UNKNOWN",
 *   "status": "DRAFT",
 *   "autoRenewCanceled": false,
 *   "lastPaymentStatus": "UNPAID",
 *   "startDate": "2022-08-22T19:51:36.470Z",
 *   "endDate": "2022-11-22T19:51:36.470Z",
 *   "pausePeriods": [],
 *   "earliestEndDate": "2022-11-22T19:51:36.470Z",
 *   "currentCycle": {
 *     "index": 1,
 *     "startedDate": "2022-08-22T19:51:36.470Z",
 *     "endedDate": "2022-09-22T19:51:36.470Z"
 *   },
 *   "planName": "Platinum Pro",
 *   "planDescription": "",
 *   "planPrice": "74.99",
 *   "_createdDate": "2022-08-22T19:51:36.470Z",
 *   "_updatedDate": "2022-08-22T19:51:36.470Z"
 * }
 */
```

## A full order plan scenario

```javascript
/****************************************
 * Code on a plan viewer dynamic page   *
 ****************************************/

// For navigating to a dynamic page:
import wixLocationFrontend from 'wix-location-frontend';

$w.onReady( function () {
  $w('#viewButton').onClick((event) => {
    let $item = $w.at(event.context);
    let clickedItem = $item('#planDataset').getCurrentItem();
    let slug = clickedItem.slug;
    wixLocationFrontend.to('/plans/' + slug);
  });
});

/****************************************
 * Lightbox code                        *
 ****************************************/

// For working with a lightbox:
import wixWindowFrontend from 'wix-window-frontend';

$w.onReady(function () {
  const receivedData = wixWindowFrontend.lightbox.getContext();
  $w('#orderData').text = receivedData;
});

// This code assumes that the closeButton_click
// event handler was added using the "Properties
// & Events" panel. Make sure to do the same if you 
// copy this code.
// 
// Note that the "Close" button was created 
// using standard elements. It was not added 
// using Lightbox Settings.

export function closeButton_click(event) {
    wixWindowFrontend.lightbox.close();
};

/****************************************
 * Code on a single-plan dynamic page   *
 ****************************************/

// For working with a lightbox:
import wixWindowFrontend from 'wix-window-frontend';

import { checkout } from 'wix-pricing-plans-frontend';

$w.onReady(function () {
  $w('#dynamicDataset').onReady( () => {
    const currentPlanObject = $w('#dynamicDataset').getCurrentItem();
    const planId = currentPlanObject._id;
    $w('#planName').text = currentPlanObject.name;
    $w('#planDescription').text = currentPlanObject.description;

    $w('orderPlanButton').onClick((event) => {
      const order = checkout.createOnlineOrder(planId)
      .then((order) => {
        const planWithOrder = {
          plan: currentPlanObject,
          order: order
        };
        wixWindowFrontend.openLightbox('orderCreated', planWithOrder);
      });
    });
  });
});

```

---