Search.../

getCurrentMemberOrder( )

Gets an order for the currently logged-in member.

Description

The getCurrentMemberOrder() function returns a Promise that resolves to information about a specified order for the currently-logged in member.

Syntax

function getCurrentMemberOrder(orderId: string): Promise<Order>

getCurrentMemberOrder Parameters

NAME
TYPE
DESCRIPTION
orderId
string

ID of the order to get.

Returns

Fulfilled - The requested pricing plan order.

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?

Get the current member's order by ID

Copy Code
1import { orders } from 'wix-pricing-plans-backend';
2
3// Sample orderId value: 'a5accf44-6eba-4d1e-a1b6-49d5ddc2de9d'
4
5export async function myGetCurrentMemberOrderFunction(orderId) {
6 try {
7 const order = await orders.getCurrentMemberOrder(orderId);
8 const id = order._id;
9 const status = order.status;
10
11 return order;
12 } catch (error) {
13 console.error(error);
14 }
15}
16
17/* Promise resolves to:
18 *
19 * {
20 * "_id": "a5accf44-6eba-4d1e-a1b6-49d5ddc2de9d",
21 * "planId": "6d7537c5-beac-44a3-bea3-b947ddc56b31",
22 * "subscriptionId": "5288d8eb-916a-438e-8819-69a00ac72acb",
23 * "wixPayOrderId": "bee58368-5bc4-4868-85af-a490d1dc0dbf",
24 * "buyer": {
25 * "memberId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86",
26 * "contactId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86"
27 * },
28 * "priceDetails": {
29 * "subtotal": "14.99",
30 * "discount": "0",
31 * "total": "14.99",
32 * "planPrice": "14.99",
33 * "currency": "EUR",
34 * "subscription": {
35 * "cycleDuration": {
36 * "count": 1,
37 * "unit": "MONTH"
38 * },
39 * "cycleCount": 0
40 * }
41 * },
42 * "pricing": {
43 * "subscription": {
44 * "cycleDuration": {
45 * "count": 1,
46 * "unit": "MONTH"
47 * },
48 * "cycleCount": 0
49 * },
50 * "prices": [
51 * {
52 * "duration": {
53 * "cycleFrom": 1
54 * },
55 * "price": {
56 * "subtotal": "14.99",
57 * "discount": "0",
58 * "total": "14.99",
59 * "currency": "EUR"
60 * }
61 * }
62 * ]
63 * },
64 * "type": "OFFLINE",
65 * "orderMethod": "UNKNOWN",
66 * "status": "ACTIVE",
67 * "autoRenewCanceled": false,
68 * "lastPaymentStatus": "PAID",
69 * "startDate": "2022-07-11T13:45:53.129Z",
70 * "pausePeriods": [],
71 * "currentCycle": {
72 * "index": 1,
73 * "startedDate": "2022-07-11T13:45:53.129Z",
74 * "endedDate": "2022-08-11T13:45:53.129Z"
75 * },
76 * "planName": "2x Week",
77 * "planDescription": "",
78 * "planPrice": "14.99",
79 * "_createdDate": "2022-07-08T08:35:25.288Z",
80 * "_updatedDate": "2022-07-08T08:35:27.476Z"
81 * }
82 */