createOfflineOrder( )


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.

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.
Authentication

This function requires elevated permissions and runs only on the backend and on dashboard pages.

Permissions
Manage Orders
Learn more about app permissions.
Method Declaration
Copy
function createOfflineOrder(
  planId: string,
  memberId: string,
  options: CreateOfflineOrderOptions,
): Promise<CreateOfflineOrderResponse>;
Method Parameters
planIdstringRequired

ID of the plan being ordered, from the Plans API.


memberIdstringRequired

ID of the member ordering the plan, from the Members API.


optionsCreateOfflineOrderOptions

Options for creating an offline order.

Returns
Return Type:Promise<CreateOfflineOrderResponse>
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" * } */
Errors
400Invalid Argument

There are 3 errors with this status code.

403Permission Denied

There is 1 error with this status code.

428Failed Precondition

There are 9 errors with this status code.

This method may also return standard errors. Learn more about standard Wix errors.

Did this help?