changeStartDate( )
Change the start date of a draft order.
Description
The changeStartDate()
function returns a promise that resolves to a draft of the Order
object with an updated startDate
.
This function cannot be called on paid orders. When an order is paid for, it is no longer considered a draft and its start date cannot be changed.
The onOrderStartDateChanged()
and onOrderUpdated()
event handlers run when the start date of an order is changed.
The member must be logged in to change the start date of their order. Members cannot change the start date of other members' orders.
Syntax
function changeStartDate(orderId: string, startDate: Date): Promise<Order>
changeStartDate Parameters
NAME
TYPE
DESCRIPTION
Draft order ID.
New start date and time to update the startDate
at which the order will become active.
Returns
Fulfilled - The order of the plan.
Return Type:
NAME
TYPE
DESCRIPTION
Order ID.
ID of the plan that was ordered.
ID of the related Wix subscription.
Every pricing plan order corresponds to a Wix subscription, including orders for single payment plans. You can see all orders from your site's Subscriptions page in the Dashboard.
ID of the associated Wix Pay order.
Created by the createOnlineOrder()
or createfflineOrder()
function. For online orders, send this value as a parameter to the Wix Pay startPayment()
function to enable your buyer to pay for the order. wixPayOrderId
is omitted if the order is free.
The buyer's IDs. Includes memberId
and contactId
.
Currently, Pricing Plan orders are limited to members only. contactId
is returned, but a buyer will not be able to order a plan without a memberId
.
Deprecated. Use pricing
instead.
How the order was processed. Supported values:
"ONLINE"
. The buyer ordered the plan using the site."OFFLINE"
. The buyer made a manual, offline order without using the site.
Status of the order. Supported values:
"DRAFT"
. The order has been initiated but payment hasn't been processed yet. The plan isn't yet available for use."PENDING"
. The order has been processed and its start date is set in the future. The plan isn't yet available for use."ACTIVE"
. The order has been processed. The plan is available for use."PAUSED"
. The order, and use of the plan, is paused. For example, if the buyer is away. The order, and use of the plan, can be resumed."ENDED"
. The order has completed its duration and is no longer available for use."CANCELED"
. The order has been canceled.
Whether the order will be canceled at the next payment date.
If true
, the order status
will be CANCELED
and the next payment won't be charged. Omitted for single payment orders.
Details about the cancellation of an order. Only present if the status
is "CANCELED"
.
Status of the last payment for the order. This is updated automatically for online orders. The site owner updates this manually for offline orders. Supported values:
"PAID"
. The last payment was paid."REFUNDED"
. The last payment was refunded."FAILED"
. The last payment transaction didn't complete."UNPAID"
. The last payment wasn't paid."PENDING"
. Awaiting payment."NOT_APPLICABLE"
. No payment was necessary. For example, for free plans or free trials.
Start date and time for the ordered plan.
List of periods during which this order is paused.
Free trial period, in days. Only available for recurring plans.
Earliest end date and time that the plan for this order can expire.
This is calculated by adding all pause periods to the original end date. Omitted if the order is active until canceled. Reserved for future use.
Current payment cycle for the order.
currentCycle
will be omitted if the order's status is CANCELED
or ENDED
, or if the startDate
hasn't passed yet.
Name of the plan at the time of the order.
Description of the plan at the time of the order.
Plan price as it was at the moment of order creation.
Date and time the order was created.
Date and time the order was last updated. For example, the date and time an order was paused, resumed, or canceled.
Related Content:
Was this helpful?
Change the start date of a draft order
1import { Permissions, webMethod } from 'wix-web-module';2import { checkout } from 'wix-pricing-plans-backend';34export const myChangeStartDateFunction = webMethod(Permissions.Anyone, () => {5 const orderId = '4d771642-2e36-4078-a294-105649e1ed05';6 const startDate = new Date('September 19, 2021 10:00:00');78 return checkout.changeStartDate(orderId, startDate)9 .then((draft) => {10 const orderPlan = draft.planName;11 const orderStatus = draft.status;12 const orderStart = draft.startDate;13 })14 .catch((error) => {15 console.error(error);16 });17});1819/* Promise resolves to:20 *21 * {22 * "_id": "4d771642-2e36-4078-a294-105649e1ed05",23 * "planId": "5cfdba28-283f-4859-98f8-ebb7af542d41",24 * "subscriptionId": "0a0304bc-7aae-474c-a2b5-81e3e7925c24",25 * "wixPayOrderId": "cd5e42ba-5de4-4ba1-b2e3-410cd46dde60",26 * "buyer": {27 * "memberId": "4c47c608-cfa8-4037-93ac-738f09560ed3",28 * "contactId": "4c47c608-cfa8-4037-93ac-738f09560ed3"29 * },30 * "priceDetails": {31 * "subtotal": "25",32 * "discount": "0",33 * "total": "25",34 * "planPrice": "25",35 * "currency": "USD",36 * "singlePaymentForDuration": {37 * "count": 6,38 * "unit": "MONTH"39 * }40 * },41 * "pricing": {42 * "singlePaymentForDuration": {43 * "count": 6,44 * "unit": "MONTH"45 * },46 * "prices": [47 * {48 * "duration": {49 * "cycleFrom": 150 * },51 * "price": {52 * "subtotal": "25",53 * "discount": "0",54 * "total": "25",55 * "currency": "USD"56 * }57 * }58 * ]59 * },60 * "type": "ONLINE",61 * "orderMethod": "UNKNOWN",62 * "status": "DRAFT",63 * "lastPaymentStatus": "UNPAID",64 * "startDate": "2021-09-19T10:00:00.000Z",65 * "endDate": "2022-03-19T10:00:00.000Z",66 * "pausePeriods": [],67 * "earliestEndDate": "2022-03-19T10:00:00.000Z",68 * "currentCycle": {69 * "index": 1,70 * "startedDate": "2021-09-19T10:00:00.000Z",71 * "endedDate": "2022-03-19T10:00:00.000Z"72 * },73 * "planName": "Vegetarian Cooking",74 * "planDescription": "Weekly delivery of vegetarian recipes and vegan recipes",75 * "planPrice": "25",76 * "_createdDate": "2021-08-26T16:32:20.808Z",77 * "_updatedDate": "2021-08-27T14:53:10.084Z"78 * }79 */