createOnlineOrder( )


Creates an order online for currently logged-in member.

The createOnlineOrder() function returns a Promise that resolves to an Order object when the order has been created. The order is for the currently logged-in member. The buyer must be logged in for you to be able to create an order.

Note: The pricing plan createOnlineOrder() and createOfflineOrder() functions replace the deprecated paid plans orderPlan() function. The deprecated function will continue to work, but will not receive updates. To keep any existing code compatible with future changes, see the migration instructions.

Purchasing a plan:

  1. Starts with creating an order.
  2. For non-free plans, calling the Wix Pay startPayment() function with the wixPayOrderId value as the paymentId parameter to enable your buyer to pay for the order. (Do not call the Wix Pay createPayment() function to create the payment ID because this createOnlineOrder() function does that for you.)
  3. If the order is free, do not call the Wix Pay startPayment() function after createOnlineOrder(). The order is created and considered paid for.

Once an online order is paid for, the status of the order is no longer "DRAFT" and at this point, its startDate cannot be changed.

Creating an online order causes:

  • The order status to be set to "PENDING" if the start date is in the future. Otherwise, the status is set to "ACTIVE".

The onOrderCreated() event handler runs when an online order is created.

Note: If startDate is not used in the function, the missing parameter has to be passed as undefined, for example: function createOnlineOrder(planId, undefined, couponCode)

Method Declaration
Copy
Method Parameters
planIdstringRequired

ID of the plan being ordered.


startDateDate

Start date and time for the ordered plan.


couponCodestring

Coupon code to apply.

To learn more about coupons, see applyCoupon().

Returns
Return Type:Promise<Order>
Was this helpful?
Yes
No