Search.../

getOfflineOrderPreview( )

Developer Preview

Provides a preview of an offline order as if it was purchased.

Description

The getOfflineOrderPreview() function returns a Promise that resolves to a temporary preview of the offline order.

The preview uses the same logic as purchasing a plan, but the preview is not saved. Because an order is not actually created, the preview's _id and subscriptionId properties are displayed as a string of multiple zero characters (000000-0000).

If taxes are configured for the site, taxes are applied to the preview. If not, tax previews as null.

You can preview the order to check purchase limitations, but the limitations are not enforced for the preview. If a pricing plan has a limit on the amount of purchases per buyer, that limit is not considered for generating the preview. But, if that limit has been reached and this order would then exceed the amount of purchases permitted for this buyer, then purchaseLimitExceeded will return as true. Thus function is not available to the buyer. You specify the member ID for the buyer whose order should be previewed. To get a general price preview for a plan that's not buyer-specific, use the getPricePreview() function.

Admin Method

This function requires elevated permissions to run. This function is not universal and runs only on the backend.

Syntax

function getOfflineOrderPreview(planId: string, memberId: string, options: GetOfflineOrderPreviewOptions): Promise<GetOfflineOrderPreviewResponse>

getOfflineOrderPreview Parameters

NAME
TYPE
DESCRIPTION
planId
string

ID of the plan of the previewed order.

memberId
string

Member ID of the buyer the previewed order is for.

options
Optional
GetOfflineOrderPreviewOptions

Options for previewing the offline order.

Returns

Fulfilled - A preview of the order.

Return Type:

Promise<
GetOfflineOrderPreviewResponse
>
NAME
TYPE
DESCRIPTION
order
Order

The previewed order, as if the plan had been ordered.

purchaseLimitExceeded
boolean

Whether this previewed order would exceed the permitted amount of purchases available for this plan for this buyer.

Always false for plans that do not have purchase limits.

Was this helpful?

Create an offline order preview (dashboard page code)

Copy Code
1import { orders } from 'wix-pricing-plans.v2';
2
3/* Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10'
4 *
5 * Sample memberId value: '695568ff-1dc2-49ff-83db-2b518d35692b'
6 */
7
8export async function myGetOfflineOrderPreviewFunction(planId, memberId) {
9 try {
10 const orderPreview = await orders.getOfflineOrderPreview(planId, memberId);
11
12 return orderPreview;
13 } catch (error) {
14 console.error(error);
15 // Handle the error
16 }
17}
18
19/* Promise resolves to:
20 * {
21 * order: {
22 * "_createdDate": "2024-01-31T08:51:46.516Z",
23 * "_id": "00000000-0000-0000-0000-000000000000",
24 * "_updatedDate": "2024-01-31T08:51:46.516Z",
25 * "autoRenewCanceled": false,
26 * "buyer": {
27 * "contactId": "695568ff-1dc2-49ff-83db-2b518d35692b",
28 * "memberId": "695568ff-1dc2-49ff-83db-2b518d35692b"
29 * },
30 * "currentCycle": {
31 * "endedDate": "2024-03-01T08:51:46.516Z",
32 * "index": 0,
33 * "startedDate": "2024-01-31T08:51:46.516Z"
34 * },
35 * "cycles": [
36 * {
37 * "endedDate": "2024-03-01T08:51:46.516Z",
38 * "index": 0,
39 * "startedDate": "2024-01-31T08:51:46.516Z"
40 * }
41 * ],
42 * "endDate": "2026-03-01T08:51:46.516Z",
43 * "earliestEndDate": "2026-03-01T08:51:46.516Z",
44 * "formData": {
45 * "submissionData": {}
46 * },
47 * "freeTrialDays": 30,
48 * "lastPaymentStatus": "PAID",
49 * "order": {
50 * "autoRenewCanceled": false,
51 * "buyer": {
52 * "contactId": "695568ff-1dc2-49ff-83db-2b518d35692b",
53 * "memberId": "695568ff-1dc2-49ff-83db-2b518d35692b"
54 * },
55 * "currentCycle": {
56 * "endedDate": "2024-03-01T08:51:46.516Z",
57 * "index": 0,
58 * "startedDate": "2024-01-31T08:51:46.516Z"
59 * },
60 * "cycles": [
61 * {
62 * "endedDate": "2024-03-01T08:51:46.516Z",
63 * "index": 0,
64 * "startedDate": "2024-01-31T08:51:46.516Z"
65 * }
66 * ],
67 * "endDate": "2026-03-01T08:51:46.516Z",
68 * "earliestEndDate": "2026-03-01T08:51:46.516Z",
69 * "formData": {
70 * "submissionData": {}
71 * },
72 * "freeTrialDays": 30,
73 * "lastPaymentStatus": "PAID",
74 * "orderMethod": "UNKNOWN",
75 * "orderType": "OFFLINE",
76 * "pausePeriods": [],
77 * "planDescription": "Complete with all features. One month free trial.",
78 * "planId": "838f2c9d-c8d0-4799-a10a-e2f23849db10",
79 * "planName": "Premium Plan - annual - 30 day trial",
80 * "planPrice": "500",
81 * "priceDetails": {
82 * "currency": "USD",
83 * "discount": "0",
84 * "freeTrialDays": 30,
85 * "planPrice": "500",
86 * "subtotal": "500.00",
87 * "total": "500.00",
88 * "subscription": {
89 * "cycleCount": 2,
90 * "cycleDuration": {
91 * "count": 1,
92 * "unit": "YEAR"
93 * }
94 * }
95 * },
96 * "pricing": {
97 * "prices": [
98 * {
99 * "duration": {
100 * "cycleFrom": 1,
101 * "numberOfCycles": 2
102 * },
103 * "price": {
104 * "currency": "USD",
105 * "discount": "0",
106 * "fees": [],
107 * "proration": "0",
108 * "subtotal": "500.00",
109 * "total": "500.00"
110 * }
111 * }
112 * ],
113 * "subscription": {
114 * "cycleCount": 2,
115 * "cycleDuration": {
116 * "count": 1,
117 * "unit": "YEAR"
118 * }
119 * }
120 * },
121 * "seller": {
122 * "subscriptionId": "00000000-0000-0000-0000-000000000000"
123 * },
124 * "startDate": "2024-01-31T08:51:46.516Z",
125 * "status": "ACTIVE",
126 * "statusNew": "ACTIVE",
127 * "type": "OFFLINE"
128 * },
129 * "orderMethod": "UNKNOWN",
130 * "pausePeriods": [],
131 * "planDescription": "Complete with all features. One month free trial.",
132 * "planId": "838f2c9d-c8d0-4799-a10a-e2f23849db10",
133 * "planName": "Premium Plan - annual - 30 day trial",
134 * "planPrice": "500",
135 * "pricing": {
136 * "prices": [
137 * {
138 * "duration": {
139 * "cycleFrom": 1,
140 * "numberOfCycles": 2
141 * },
142 * "price": {
143 * "currency": "USD",
144 * "discount": "0",
145 * "fees": [],
146 * "proration": "0",
147 * "subtotal": "500.00",
148 * "total": "500.00"
149 * }
150 * }
151 * ],
152 * "subscription": {
153 * "cycleCount": 2,
154 * "cycleDuration": {
155 * "count": 1,
156 * "unit": "YEAR"
157 * }
158 * }
159 * },
160 * "startDate": "2024-01-31T08:51:46.516Z",
161 * "status": "ACTIVE",
162 * "statusNew": "ACTIVE",
163 * "subscriptionId": "00000000-0000-0000-0000-000000000000",
164 * "type": "OFFLINE"
165 * }
166 * "purchaseLimitExceeded": false
167 * }
168 */
Create an offline order preview (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { orders } from 'wix-pricing-plans.v2';
3import { elevate } from 'wix-auth';
4
5/* Sample planId value: '838f2c9d-c8d0-4799-a10a-e2f23849db10'
6 *
7 * Sample memberId value: '695568ff-1dc2-49ff-83db-2b518d35692b'
8 */
9
10const elevatedGetOfflineOrderPreview = elevate(orders.getOfflineOrderPreview);
11
12export const myGetOfflineOrderPreviewFunction = webMethod(Permissions.Anyone, async (planId, memberId) => {
13 try {
14 const orderPreview = await elevatedGetOfflineOrderPreview(planId, memberId);
15
16 return orderPreview;
17 } catch (error) {
18 console.error(error);
19 // Handle the error
20 }
21});
22
23/* Promise resolves to:
24 * {
25 * order: {
26 * "_createdDate": "2024-01-31T08:51:46.516Z",
27 * "_id": "00000000-0000-0000-0000-000000000000",
28 * "_updatedDate": "2024-01-31T08:51:46.516Z",
29 * "autoRenewCanceled": false,
30 * "buyer": {
31 * "contactId": "695568ff-1dc2-49ff-83db-2b518d35692b",
32 * "memberId": "695568ff-1dc2-49ff-83db-2b518d35692b"
33 * },
34 * "currentCycle": {
35 * "endedDate": "2024-03-01T08:51:46.516Z",
36 * "index": 0,
37 * "startedDate": "2024-01-31T08:51:46.516Z"
38 * },
39 * "cycles": [
40 * {
41 * "endedDate": "2024-03-01T08:51:46.516Z",
42 * "index": 0,
43 * "startedDate": "2024-01-31T08:51:46.516Z"
44 * }
45 * ],
46 * "endDate": "2026-03-01T08:51:46.516Z",
47 * "earliestEndDate": "2026-03-01T08:51:46.516Z",
48 * "formData": {
49 * "submissionData": {}
50 * },
51 * "freeTrialDays": 30,
52 * "lastPaymentStatus": "PAID",
53 * "order": {
54 * "autoRenewCanceled": false,
55 * "buyer": {
56 * "contactId": "695568ff-1dc2-49ff-83db-2b518d35692b",
57 * "memberId": "695568ff-1dc2-49ff-83db-2b518d35692b"
58 * },
59 * "currentCycle": {
60 * "endedDate": "2024-03-01T08:51:46.516Z",
61 * "index": 0,
62 * "startedDate": "2024-01-31T08:51:46.516Z"
63 * },
64 * "cycles": [
65 * {
66 * "endedDate": "2024-03-01T08:51:46.516Z",
67 * "index": 0,
68 * "startedDate": "2024-01-31T08:51:46.516Z"
69 * }
70 * ],
71 * "endDate": "2026-03-01T08:51:46.516Z",
72 * "earliestEndDate": "2026-03-01T08:51:46.516Z",
73 * "formData": {
74 * "submissionData": {}
75 * },
76 * "freeTrialDays": 30,
77 * "lastPaymentStatus": "PAID",
78 * "orderMethod": "UNKNOWN",
79 * "orderType": "OFFLINE",
80 * "pausePeriods": [],
81 * "planDescription": "Complete with all features. One month free trial.",
82 * "planId": "838f2c9d-c8d0-4799-a10a-e2f23849db10",
83 * "planName": "Premium Plan - annual - 30 day trial",
84 * "planPrice": "500",
85 * "priceDetails": {
86 * "currency": "USD",
87 * "discount": "0",
88 * "freeTrialDays": 30,
89 * "planPrice": "500",
90 * "subtotal": "500.00",
91 * "total": "500.00",
92 * "subscription": {
93 * "cycleCount": 2,
94 * "cycleDuration": {
95 * "count": 1,
96 * "unit": "YEAR"
97 * }
98 * }
99 * },
100 * "pricing": {
101 * "prices": [
102 * {
103 * "duration": {
104 * "cycleFrom": 1,
105 * "numberOfCycles": 2
106 * },
107 * "price": {
108 * "currency": "USD",
109 * "discount": "0",
110 * "fees": [],
111 * "proration": "0",
112 * "subtotal": "500.00",
113 * "total": "500.00"
114 * }
115 * }
116 * ],
117 * "subscription": {
118 * "cycleCount": 2,
119 * "cycleDuration": {
120 * "count": 1,
121 * "unit": "YEAR"
122 * }
123 * }
124 * },
125 * "seller": {
126 * "subscriptionId": "00000000-0000-0000-0000-000000000000"
127 * },
128 * "startDate": "2024-01-31T08:51:46.516Z",
129 * "status": "ACTIVE",
130 * "statusNew": "ACTIVE",
131 * "type": "OFFLINE"
132 * },
133 * "orderMethod": "UNKNOWN",
134 * "pausePeriods": [],
135 * "planDescription": "Complete with all features. One month free trial.",
136 * "planId": "838f2c9d-c8d0-4799-a10a-e2f23849db10",
137 * "planName": "Premium Plan - annual - 30 day trial",
138 * "planPrice": "500",
139 * "pricing": {
140 * "prices": [
141 * {
142 * "duration": {
143 * "cycleFrom": 1,
144 * "numberOfCycles": 2
145 * },
146 * "price": {
147 * "currency": "USD",
148 * "discount": "0",
149 * "fees": [],
150 * "proration": "0",
151 * "subtotal": "500.00",
152 * "total": "500.00"
153 * }
154 * }
155 * ],
156 * "subscription": {
157 * "cycleCount": 2,
158 * "cycleDuration": {
159 * "count": 1,
160 * "unit": "YEAR"
161 * }
162 * }
163 * },
164 * "startDate": "2024-01-31T08:51:46.516Z",
165 * "status": "ACTIVE",
166 * "statusNew": "ACTIVE",
167 * "subscriptionId": "00000000-0000-0000-0000-000000000000",
168 * "type": "OFFLINE"
169 * }
170 * "purchaseLimitExceeded": false
171 * }
172 */
173
Create an offline order preview with options

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { orders } from 'wix-pricing-plans.v2';
3import { elevate } from 'wix-auth';
4
5/* Sample planId value: 'd2fa5805-0d1a-4cfb-9b43-e683cf5fa990'
6 *
7 * Sample memberId value: '554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4'
8 *
9 * Sample options value:
10 * {
11 * couponCode: 'seasonal',
12 * startDate: new Date()
13 * }
14 */
15
16const elevatedGetOfflineOrderPreview = elevate(orders.getOfflineOrderPreview);
17
18export const myGetOfflineOrderPreviewFunction = webMethod(Permissions.Anyone, async (planId, memberId, options) => {
19 try {
20 const orderPreview = await elevatedGetOfflineOrderPreview(planId, memberId, options);
21
22 return orderPreview;
23 } catch (error) {
24 console.error(error);
25 // Handle the error
26 }
27});
28
29/* Promise resolves to:
30 * {
31 * "order": {
32 * "_createdDate": "2024-02-01T07:58:49.777Z",
33 * "_id": "00000000-0000-0000-0000-000000000000",
34 * "_updatedDate": "2024-02-01T07:58:49.777Z",
35 * "autoRenewCanceled": false,
36 * "buyer": {
37 * "contactId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4",
38 * "memberId": "554c9e11-f4d8-4579-ac3a-a17f7e6cb0b4"
39 * },
40 * "currentCycle": {
41 * "endedDate": "2024-02-15T07:58:49.387Z",
42 * "index": 0,
43 * "startedDate": "2024-02-01T07:58:49.387Z"
44 * },
45 * "formData": {
46 * "fomrId":
47 * "submissionData": {
48 * "email_0fd2": "Jboss@email.com",
49 * "form_field_aa30": false,
50 * "first_name_c551": "Jason",
51 * "last_name_78e9": "Bollinger",
52 * "phone_8cf1": "212-909-2222"
53 * },
54 * "submissionId": "10206732-e789-40e9-957d-2c7f3398efc6"
55 * },
56 * "freeTrialDays": 14,
57 * "lastPaymentStatus": "PAID",
58 * "pausePeriods": [],
59 * "planDescription": "The value plan",
60 * "planId": "d2fa5805-0d1a-4cfb-9b43-e683cf5fa990",
61 * "planName": "Silver Membership - Monthly",
62 * "planPrice": "100",
63 * "status": "ACTIVE",
64 * "orderMethod": "UNKNOWN",
65 * "pricing": {
66 * "prices": [
67 * {
68 * "duration": {
69 * "cycleFrom": 1,
70 * "numberOfCycles": 1
71 * },
72 * "price": {
73 * "coupon": {
74 * "code": "seasonal",
75 * "amount": "95.00",
76 * "_id": "8673834a-a5c6-4e77-af9c-83f9bf609659"
77 * },
78 * "total": "30.00",
79 * "proration": "0",
80 * "fees": [
81 * {
82 * "name": "Setup Fee",
83 * "amount": "25"
84 * }
85 * ],
86 * "currency": "USD",
87 * "subtotal": "125.00",
88 * "discount": "95.00"
89 * }
90 * },
91 * {
92 * "duration": {
93 * "cycleFrom": 2
94 * },
95 * "price": {
96 * "coupon": {
97 * "code": "seasonal",
98 * "amount": "95.00",
99 * "_id": "8673834a-a5c6-4e77-af9c-83f9bf609659"
100 * },
101 * "total": "5.00",
102 * "proration": "0",
103 * "fees": [],
104 * "currency": "USD",
105 * "subtotal": "100.00",
106 * "discount": "95.00"
107 * }
108 * }
109 * ]
110 * "subscription": {
111 * "cycleCount": 0,
112 * "cycleDuration": {
113 * "count": 1,
114 * "unit": "MONTH"
115 * }
116 * }
117 * },
118 * "startDate": "2024-02-01T07:58:49.387Z",
119 * "status": "ACTIVE",
120 * "subscriptionId": "00000000-0000-0000-0000-000000000000",
121 * "type": "OFFLINE",
122 * },
123 * "purchaseLimitExceeded": false
124 * }
125 */
126