Gets an order for the currently logged-in member.
The getCurrentMemberOrder()
function returns a Promise that resolves to information about a specified order for the currently-logged in member.
function getCurrentMemberOrder(orderId: string): Promise<Order>;
ID of the order to get.
import { Permissions, webMethod } from "wix-web-module";
import { orders } from "wix-pricing-plans-backend";
// Sample orderId value: 'a5accf44-6eba-4d1e-a1b6-49d5ddc2de9d'
export const myGetCurrentMemberOrderFunction = webMethod(
Permissions.Anyone,
async (orderId) => {
try {
const order = await orders.getCurrentMemberOrder(orderId);
const id = order._id;
const status = order.status;
return order;
} catch (error) {
console.error(error);
}
},
);
/* Promise resolves to:
*
* {
* "_id": "a5accf44-6eba-4d1e-a1b6-49d5ddc2de9d",
* "planId": "6d7537c5-beac-44a3-bea3-b947ddc56b31",
* "subscriptionId": "5288d8eb-916a-438e-8819-69a00ac72acb",
* "wixPayOrderId": "bee58368-5bc4-4868-85af-a490d1dc0dbf",
* "buyer": {
* "memberId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86",
* "contactId": "ea3d74df-b7dc-4ca1-a7c9-c416b9017a86"
* },
* "priceDetails": {
* "subtotal": "14.99",
* "discount": "0",
* "total": "14.99",
* "planPrice": "14.99",
* "currency": "EUR",
* "subscription": {
* "cycleDuration": {
* "count": 1,
* "unit": "MONTH"
* },
* "cycleCount": 0
* }
* },
* "pricing": {
* "subscription": {
* "cycleDuration": {
* "count": 1,
* "unit": "MONTH"
* },
* "cycleCount": 0
* },
* "prices": [
* {
* "duration": {
* "cycleFrom": 1
* },
* "price": {
* "subtotal": "14.99",
* "discount": "0",
* "total": "14.99",
* "currency": "EUR"
* }
* }
* ]
* },
* "type": "OFFLINE",
* "orderMethod": "UNKNOWN",
* "status": "ACTIVE",
* "autoRenewCanceled": false,
* "lastPaymentStatus": "PAID",
* "startDate": "2022-07-11T13:45:53.129Z",
* "pausePeriods": [],
* "currentCycle": {
* "index": 1,
* "startedDate": "2022-07-11T13:45:53.129Z",
* "endedDate": "2022-08-11T13:45:53.129Z"
* },
* "planName": "2x Week",
* "planDescription": "",
* "planPrice": "14.99",
* "_createdDate": "2022-07-08T08:35:25.288Z",
* "_updatedDate": "2022-07-08T08:35:27.476Z"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.