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.
Purchasing a plan:
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.)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:
"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)
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()
.