> 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`). > - 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, memberId: string, options: CreateOfflineOrderOptions) # Method package: wixPricingPlansV2 # Method menu location: wixPricingPlansV2 --> orders --> createOfflineOrder # Method Link: https://dev.wix.com/docs/velo/apis/wix-pricing-plans-v2/orders/create-offline-order.md # Method Description: Creates an order for a buyer who purchased the plan with an offline transaction. An offline order is handled off of the Wix site and is marked as `type`: `offline`. If a pricing plan has a limit on the amount of purchases per buyer, that limit is ignored for offline orders. Tax is only applied if the site [has it configured](https://support.wix.com/en/article/pricing-plans-setting-up-tax-collection). When creating a free offline order: 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"`. " When creating a non-free offline order: 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"` based on the data passed in the `paid` boolean in the request. Payment for an offline order can be set in 1 of 2 ways: + During order creation, set `paid`: `true`. + After creation, call Mark As Paid. # Method Code Examples: *** Note: do not assume any prop names or enum values other than the ones in the example. ## Create an offline order (dashboard page code) ```javascript import { orders } from 'wix-pricing-plans.v2'; /* Sample planId value: 'cb4a8c57-273a-4567-94e3-cc43d5d339f2' * * Sample memberId value: '554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4' */ export async function myCreateOfflineOrderFunction(planId, memberId) { try { const newOrder = await orders.createOfflineOrder(planId, memberId); return newOrder; } catch (error) { console.error(error); // Handle the error } } /* Promise resolves to: * { * "_createdDate": "2024-01-28T09:49:21.041Z", * "_id": "82d99338-5653-459a-a751-b57483f7cfb5", * "_updatedDate": "2024-01-28T09:49:21.041Z", * "autoRenewCanceled": false, * "buyer": { * "contactId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4", * "memberId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4" * }, * "currentCycle": { * "endedDate": "2024-04-27T09:49:21.041Z", * "index": 0, * "startedDate": "2024-01-28T09:49:21.041Z" * }, * "cycles": [ * { * "endedDate": "2024-04-27T09:49:21.041Z", * "index": 0, * "startedDate": "2024-01-28T09:49:21.041Z" * } * ], * "earliestEndDate": "2026-04-27T09:49:21.041Z", * "endDate": "2026-04-27T09:49:21.041Z", * "formData": { * "submissionData": { * "formId": "3ef36359-24bd-471a-aa8b-a5ca683b50f4", * "submissionData": {}, * "submissionId": "e65d5d60-7e07-4d2f-971f-e471dcebd0d2" * }, * }, * "freeTrialDays": 90, * "lastPaymentStatus": "UNPAID", * "pausePeriods": [], * "planDescription": "3 mo free trial with discount for 1 year", * "planId": "cb4a8c57-273a-4567-94e3-cc43d5d339f2", * "planName": "Beginner's Plan", * "planPrice": "50", * "pricing": { * "prices": [ * { * "duration": { * "cycleFrom": 1, * "numberOfCycles": 2 * }, * "price": { * "currency": "USD", * "discount": "0", * "fees": [], * "proration": "0", * "subtotal": "50.00", * "total": "50.00" * } * } * ], * "subscription": { * "cycleCount": 2, * "cycleDuration": { * "count": 1, * "unit": "YEAR" * } * } * }, * "startDate": "2024-01-28T09:49:21.041Z", * "statusNew": "DRAFT", * "subscriptionId": "305f8fc9-3724-4cac-9f67-4e29f2c46def", * "type": "OFFLINE", * "wixPayOrderId": "2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb" * } */ ``` ## Create an offline order (export from backend code) ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { orders } from 'wix-pricing-plans.v2'; import { elevate } from 'wix-auth'; /* * Sample planId value: 'cb4a8c57-273a-4567-94e3-cc43d5d339f2' * * Sample memberId value: '554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4' */ const elevatedCreateOfflineOrder = elevate(orders.createOfflineOrder); export const myCreateOfflineOrderFunction = webMethod(Permissions.Anyone, async (planId, memberId) => { try { const newOrder = await elevatedCreateOfflineOrder(planId, memberId); return newOrder; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: * { * "_createdDate": "2024-01-28T09:49:21.041Z", * "_id": "82d99338-5653-459a-a751-b57483f7cfb5", * "_updatedDate": "2024-01-28T09:49:21.041Z", * "autoRenewCanceled": false, * "buyer": { * "contactId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4", * "memberId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4" * }, * "currentCycle": { * "endedDate": "2024-04-27T09:49:21.041Z", * "index": 0, * "startedDate": "2024-01-28T09:49:21.041Z" * }, * "cycles": [ * { * "endedDate": "2024-04-27T09:49:21.041Z", * "index": 0, * "startedDate": "2024-01-28T09:49:21.041Z" * } * ], * "earliestEndDate": "2026-04-27T09:49:21.041Z", * "endDate": "2026-04-27T09:49:21.041Z", * "formData": { * "submissionData": { * "formId": "3ef36359-24bd-471a-aa8b-a5ca683b50f4", * "submissionData": {}, * "submissionId": "e65d5d60-7e07-4d2f-971f-e471dcebd0d2" * }, * }, * "freeTrialDays": 90, * "lastPaymentStatus": "UNPAID", * "pausePeriods": [], * "planDescription": "3 mo free trial with discount for 1 year", * "planId": "cb4a8c57-273a-4567-94e3-cc43d5d339f2", * "planName": "Beginner's Plan", * "planPrice": "50", * "pricing": { * "prices": [ * { * "duration": { * "cycleFrom": 1, * "numberOfCycles": 2 * }, * "price": { * "currency": "USD", * "discount": "0", * "fees": [], * "proration": "0", * "subtotal": "50.00", * "total": "50.00" * } * } * ], * "subscription": { * "cycleCount": 2, * "cycleDuration": { * "count": 1, * "unit": "YEAR" * } * } * }, * "startDate": "2024-01-28T09:49:21.041Z", * "statusNew": "DRAFT", * "subscriptionId": "305f8fc9-3724-4cac-9f67-4e29f2c46def", * "type": "OFFLINE", * "wixPayOrderId": "2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb" * } */ ``` ## Create an offline order for an existing member ```javascript /******************************* * Backend code - utils.web.js * *******************************/ import { Permissions, webMethod } from 'wix-web-module'; import { orders, plans } from 'wix-pricing-plans.v2'; import { elevate } from 'wix-auth'; const elevatedListPublicPlans = elevate(plans.listPublicPlans); const elevatedCreateOfflineOrder = elevate(orders.createOfflineOrder); const elevatedMarkAsPaid = elevate(orders.markAsPaid); export const listPublicPlans = webMethod( Permissions.Anyone, async () => { try { const plansResponse = await elevatedListPublicPlans(); const plans = plansResponse.plans; return plans; } catch (error) { console.error(error); // Handle the error } }); export const createOfflineOrder = webMethod( Permissions.Anyone, async (planId, memberId) => { try { const newOrder = await elevatedCreateOfflineOrder(planId, memberId); return newOrder; } catch (error) { console.error(error); // Handle the error } }); export const markAsPaid = webMethod( Permissions.Anyone, async (orderId) => { try { await elevatedMarkAsPaid(orderId); return; } catch (error) { console.error(error); // Handle the error } }); /************* * Page code * *************/ import { createOfflineOrder, listPublicPlans, markAsPaid } from 'backend/utils.web'; import { members } from 'wix-members.v2'; $w.onReady(async function () { $w('#newOrderBtn').disable(); await populatePlansDropdown(); let planId; let memberId; // Populate #membersDropdown const membersQueryResults = await members.queryMembers().find(); $w('#membersListDropdown').options = membersQueryResults.items.map(member => { return { label: member.profile.nickname, value: member._id } }); $w('#membersListDropdown').onChange(() => { memberId = $w('#membersListDropdown').value; }); $w('#plansDropdown').onChange(() => { planId = $w('#plansDropdown').value; $w('#newOrderBtn').enable(); }); $w('#newOrderBtn').onClick(async () => { const newOrder = await createOfflineOrder(planId, memberId); const orderId = newOrder.orders._id; markAsPaid(orderId); }); }); async function populatePlansDropdown() { const plans = await listPublicPlans(); $w('#plansListDropdown').options = plans.map((item) => { return { label: item.name, value: item._id } }); } ``` ## Create an offline order with options ```javascript import { Permissions, webMethod } from 'wix-web-module'; import { orders } from 'wix-pricing-plans.v2'; import { elevate } from 'wix-auth'; /* * Sample planId value: 'cb4a8c57-273a-4567-94e3-cc43d5d339f2' * * Sample memberId value: '554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4' * * Sample options value: * { * couponCode: 'e4ddd93a-5601-4696-99dd-3356f0e558c0', * paid: true, * startDate: '2024-01-29T11:50:21.041Z', * submissionId: '9e128ddb-f62f-4a4a-adb5-064af40f18db' * } */ const elevatedCreateOfflineOrder = elevate(orders.createOfflineOrder); export const myCreateOfflineOrderFunctionWithOptions = webMethod(Permissions.Anyone, async (planId, memberId, options) => { try { const newOrder = await elevatedCreateOfflineOrder(planId, memberId, options); return newOrder; } catch (error) { console.error(error); // Handle the error } }); /* Promise resolves to: * { * order: { * "_createdDate": "2024-01-28T09:49:21.041Z", * "_id": "82d99338-5653-459a-a751-b57483f7cfb5", * "_updatedDate": "2024-01-28T09:49:21.041Z", * "autoRenewCanceled": false, * "buyer": { * "contactId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4", * "memberId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4" * }, * "cycles": [ * { * "endedDate": "2024-04-27T09:49:21.041Z", * "index": 0, * "startedDate": "2024-01-28T09:49:21.041Z" * } * ], * "currentCycle": { * "endedDate": "2024-04-27T09:49:21.041Z", * "index": 0, * "startedDate": "2024-01-28T09:49:21.041Z" * }, * "endDate": "2026-04-27T09:49:21.041Z", * "earliestEndDate": "2026-04-27T09:49:21.041Z", * "formData": { * "formId": "3ef36359-24bd-471a-aa8b-a5ca683b50f4", * "submissionData": {}, * "submissionId": "e65d5d60-7e07-4d2f-971f-e471dcebd0d2" * }, * "freeTrialDays": 90, * "lastPaymentStatus": "UNPAID", * "pausePeriods": [], * "planDescription": "3 mo free trial with discount for 1 year", * "planId": "cb4a8c57-273a-4567-94e3-cc43d5d339f2", * "planName": "Beginner's Plan", * "planPrice": "50", * "pricing": { * "prices": [ * { * "duration": { * "cycleFrom": 1, * "numberOfCycles": 2 * }, * "price": { * "currency": "USD", * "discount": "0", * "fees": [], * "proration": "0", * "subtotal": "50.00", * "total": "50.00" * } * } * ], * "subscription": { * "cycleCount": 2, * "cycleDuration": { * "count": 1, * "unit": "YEAR" * } * } * }, * "startDate": "2024-01-28T09:49:21.041Z", * "status": "ACTIVE", * "statusNew": "DRAFT", * "subscriptionId": "305f8fc9-3724-4cac-9f67-4e29f2c46def", * "type": "OFFLINE", * "wixPayOrderId": "2f0e79d8-f15d-46c6-ac1a-10ec7a2030fb" * } * } */ ``` ---