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:
- Starts with creating an order.
- For non-free plans, calling the Wix Pay
startPayment()
function with thewixPayOrderId
value as thepaymentId
parameter to enable your buyer to pay for the order. (Do not call the Wix PaycreatePayment()
function to create the payment ID because thiscreateOnlineOrder()
function does that for you.) - If the order is free, do not call the Wix Pay
startPayment()
function aftercreateOnlineOrder()
. 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, thestatus
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)
ID of the plan being ordered.
Start date and time for the ordered plan.
Coupon code to apply.
To learn more about coupons, see applyCoupon().