Search.../

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
orderId
string

Draft order ID.

startDate
Date

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:

Promise<Order>
NAME
TYPE
DESCRIPTION
_id
string

Order ID.

planId
string

ID of the plan that was ordered.

subscriptionId
string

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.

wixPayOrderId
string

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.

buyer
Buyer

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.

priceDetails
PriceDetails

Deprecated. Use pricing instead.

pricing
Pricing

Order pricing model, price, and payment schedule.

type
string

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
string

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.
autoRenewCanceled
boolean

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.

cancellation
Cancellation

Details about the cancellation of an order. Only present if the status is "CANCELED".

lastPaymentStatus
string

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.
startDate
Date

Start date and time for the ordered plan.

endDate
Date

Current date and time the ordered plan will expire.

endDate may be updated over the course of an order. If the order is paused, it will have a later endDate once it resumes. endDate may also be postponed.

Omitted if the order is valid until canceled and still "ACTIVE".

pausePeriods
Array<PausePeriod>

List of periods during which this order is paused.

freeTrialDays
string

Free trial period, in days. Only available for recurring plans.

earliestEndDate
Date

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.

currentCycle
CurrentCycle

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.

planName
string

Name of the plan at the time of the order.

planDescription
string

Description of the plan at the time of the order.

planPrice
string

Plan price as it was at the moment of order creation.

_createdDate
Date

Date and time the order was created.

_updatedDate
Date

Date and time the order was last updated. For example, the date and time an order was paused, resumed, or canceled.

Was this helpful?

Change the start date of a draft order

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { checkout } from 'wix-pricing-plans-backend';
3
4export const myChangeStartDateFunction = webMethod(Permissions.Anyone, () => {
5 const orderId = '4d771642-2e36-4078-a294-105649e1ed05';
6 const startDate = new Date('September 19, 2021 10:00:00');
7
8 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});
18
19/* 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": 1
50 * },
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 */