> 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: createOfflineOrder(planId: string, buyerId: string, options: CreateOfflineOrderOptions)

# Method package: wixPricingPlansBackend

# Method menu location: wixPricingPlansBackend --> Checkout --> createOfflineOrder

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

# Method Description:

Creates an order for a buyer who purchased the plan with an offline transaction.

The `createOfflineOrder()` function returns a Promise that resolves to an `Order` object when the
 order has been created.

 Payment of an offline order is handled in 1 of 2 ways:
 + When creating the order, select `true` in the `paid` request parameter.
 + After creation, with the [`markAsPaid()`](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/orders/mark-as-paid.md) function.

 Creating a *non-free* offline order causes:
 + The order's status is set to `"PENDING"` if the start date is in the future. Otherwise, the status is set to `"ACTIVE"`.
 + The order's last payment status is set to `"UNPAID"` or `"PAID"`.

 Creating a *free* offline order causes:
 + The order's status is set to `"PENDING"` if the start date is in the future. Otherwise, the status is set to `"ACTIVE"`.
 + The order's last payment status is set to `"NOT_APPLICABLE"`.

 The [`onOrderCreated()`](https://dev.wix.com/docs/velo/apis/wix-pricing-plans-backend/events/on-order-created.md) event handler runs when an offline order is created.

 > **Note**: Only site visitors with the **Manage Pricing Plans** and **Manage Subscriptions** [permissions](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Froles-and-permissions/roles)
 > can create offline orders. You can override the permissions by setting the function's `suppressAuth`
 > option to `true`.



# Method Code Examples:

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

## Create an offline order

```javascript
import { Permissions, webMethod } from 'wix-web-module';
import { checkout } from 'wix-pricing-plans-backend';

// Sample planId value: '099e2c86-3b7e-4477-8c27-f77402b8cceb'
// 
// Sample buyerId value: '0c9bca47-1f00-4b92-af1c-7852452e949a'

export const myCreateOfflineOrderFunction = webMethod(Permissions.Anyone, async (planId, buyerId) => {
  try {
    const order = await checkout.createOfflineOrder(planId, buyerId);
    const plan = order.planName;
    const orderType = order.type;
    
    return order;
  } catch (error) {
    console.error(error);
  }
});

/* Promise resolves to: 
 * 
 *  {
 *    "_id": "810a10b7-9da4-4de3-87e3-b4a3d7ed9654",
 *    "planId": "099e2c86-3b7e-4477-8c27-f77402b8cceb",
 *    "subscriptionId": "8bd53121-a1b3-4754-981e-64d5779a6821",
 *    "wixPayOrderId": "6c56901d-d17f-44c8-acfa-05979b63e11f",
 *    "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": "OFFLINE",
 *    "orderMethod": "UNKNOWN",
 *    "status": "ACTIVE",
 *    "autoRenewCanceled": false,
 *    "lastPaymentStatus": "UNPAID",
 *    "startDate": "2022-07-13T04:20:50.320Z",
 *    "endDate": "2022-10-13T04:20:50.320Z",
 *    "pausePeriods": [],
 *    "earliestEndDate": "2022-10-13T04:20:50.320Z",
 *    "currentCycle": {
 *      "index": 1,
 *      "startedDate": "2022-07-13T04:20:50.320Z",
 *      "endedDate": "2022-08-13T04:20:50.320Z"
 *    },
 *    "planName": "Platinum Pro",
 *    "planDescription": "",
 *    "planPrice": "74.99",
 *    "_createdDate": "2022-07-13T04:20:50.320Z",
 *    "_updatedDate": "2022-07-13T04:20:50.320Z"
 *  }
 */
```

## Create an offline order with additional options

```javascript

import { Permissions, webMethod } from 'wix-web-module';
import { checkout } from 'wix-pricing-plans-backend';

/* Sample planId value: '099e2c86-3b7e-4477-8c27-f77402b8cceb'
 * 
 * Sample buyerId value: 'fac761ea-e6f1-4e3d-8b30-a4852f091416'
 *
 * Sample options value:
 * {
 *   startDate: new Date('2022-09-15T03:00:00Z'),
 *   paid: true,
 *   suppressAuth: true,
 *   couponCode: 'ONEMONTHFREE'
 * }
 */

export const myCreateOfflineOrderWithOptionsFunction = webMethod(Permissions.Anyone, async (planId, buyerId, options) => {
  try {
    const order = await checkout.createOfflineOrder(planId, buyerId, options);
    const plan = order.planName;
    const orderType = order.type;

    return order;
  } catch (error) {
    console.error(error);
  }
});

/* Promise resolves to: 
 * 
 * {
 *   "_id": "5080a56a-b6f6-4841-b5ad-2d46e9702619",
 *   "planId": "099e2c86-3b7e-4477-8c27-f77402b8cceb",
 *   "subscriptionId": "00f669b9-9084-43b2-bcdf-991a1e7905d3",
 *   "wixPayOrderId": "6ff8a88b-6946-43ad-af86-00b90339e10d",
 *   "buyer": {
 *     "memberId": "fac761ea-e6f1-4e3d-8b30-a4852f091416",
 *     "contactId": "fac761ea-e6f1-4e3d-8b30-a4852f091416"
 *   },
 *   "priceDetails": {
 *     "subtotal": "74.99",
 *     "discount": "74.99",
 *     "total": "0",
 *     "planPrice": "74.99",
 *     "currency": "EUR",
 *     "subscription": {
 *       "cycleDuration": {
 *         "count": 1,
 *         "unit": "MONTH"
 *       },
 *       "cycleCount": 3
 *     },
 *     "coupon": {
 *       "code": "ONEMONTHFREE",
 *       "amount": "74.99",
 *       "_id": "5061dd91-8cfc-4948-aae2-66fbc4b31af7"
 *     }
 *   },
 *   "pricing": {
 *     "subscription": {
 *       "cycleDuration": {
 *         "count": 1,
 *         "unit": "MONTH"
 *       },
 *       "cycleCount": 3
 *     },
 *     "prices": [
 *       {
 *         "duration": {
 *           "cycleFrom": 1,
 *           "numberOfCycles": 1
 *         },
 *         "price": {
 *           "subtotal": "74.99",
 *           "coupon": {
 *             "code": "ONEMONTHFREE",
 *             "amount": "74.99",
 *             "_id": "5061dd91-8cfc-4948-aae2-66fbc4b31af7"
 *           },
 *           "discount": "74.99",
 *           "total": "0",
 *           "currency": "EUR"
 *         }
 *       },
 *       {
 *         "duration": {
 *           "cycleFrom": 2,
 *           "numberOfCycles": 2
 *         },
 *         "price": {
 *           "subtotal": "74.99",
 *           "discount": "0",
 *           "total": "74.99",
 *           "currency": "EUR"
 *         }
 *       }
 *     ]
 *   },
 *   "type": "OFFLINE",
 *   "orderMethod": "UNKNOWN",
 *   "status": "ACTIVE",
 *   "autoRenewCanceled": false,
 *   "lastPaymentStatus": "PAID",
 *   "startDate": "2022-09-15T03:00:00.000Z",
 *   "endDate": "2022-12-15T03:00:00.000Z",
 *   "pausePeriods": [],
 *   "earliestEndDate": "2022-12-15T03:00:00.000Z",
 *   "planName": "Platinum Pro",
 *   "planDescription": "",
 *   "planPrice": "74.99",
 *   "_createdDate": "2022-09-12T14:10:16.041Z",
 *   "_updatedDate": "2022-09-12T14:10:16.041Z"
 * }
 */

```

---