Search.../

reorderEventPolicies( )

Changes policy order in an event dashboard and agreement checkbox on the checkout form. For example, if we have 3 policies in the list, after using this function the 3rd policy will become the 1st, and other policies will move by 1 position. By default, the policies are arranged by the created date in descending order.

Description

Note: it is possible to use both beforePolicyId and afterPolicyId at the same time but only the last one defined will be executed.

The reorderEventPolicies() function returns a Promise that resolves to the newly-reordered policy.

Admin Method

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

Syntax

function reorderEventPolicies(policyId: string, eventId: string, options: ReorderEventPoliciesOptions): Promise<ReorderEventPoliciesResponse>

reorderEventPolicies Parameters

NAME
TYPE
DESCRIPTION
policyId
string

Event policy ID.

eventId
string

Event ID.

options
Optional
ReorderEventPoliciesOptions

Options for Reorder Event Policies function.

Returns

Return Type:

Promise<
ReorderEventPoliciesResponse
>
NAME
TYPE
DESCRIPTION
policies
Array<
Policy
>

Ordered event policies.

Was this helpful?

Reorder Policies (dashboard page code)

Copy Code
1import { policies } from 'wix-events.v2';
2
3// define event ID and policies to reorder
4const eventId = '3d3d5c04-ece0-45a8-85f0-11a58edaa192';
5const options = {
6 policyId: '52f15c5c-ea06-44f4-866a-b1cfa6f4f790',
7 beforePolicyId: '6933ddf1-26c7-46c3-9924-e78c833d6cca'
8};
9
10// reorder policies
11async function elevatedReorderPoliciesFunction(){
12 const elevatedReorderPolicies = wixAuth.elevate(policies.reorderEventPolicies);
13 try {
14 const result = await elevatedReorderPolicies(eventId, options);
15 return result;
16 }
17 catch (error) {
18 console.error(error);
19 // Handle the error
20 }
21 };
22
23/* Returns a promise that resolves to
24 the reordered policies.
25{
26 "policies": [
27 {
28 "_id": "52f15c5c-ea06-44f4-866a-b1cfa6f4f790",
29 "revision": "2",
30 "_createdDate": "2023-03-07T14:15:44.312Z",
31 "_updatedDate": "2023-03-07T14:33:00.876Z",
32 "name": "Terms and Conditions Event 1",
33 "body": "<p><code>Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.</code></p>",
34 "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
35 },
36 {
37 "_id": "6933ddf1-26c7-46c3-9924-e78c833d6cca",
38 "revision": "2",
39 "_createdDate": "2023-03-07T13:18:09.185Z",
40 "_updatedDate": "2023-03-07T14:33:01.072Z",
41 "name": "Terms and Conditions Event 2",
42 "body": "<p><code>Nobody will be allowed admission to the Event without a valid ticket or pass.</code></p>",
43 "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
44 },
45 {
46 "_id": "b9d5f876-f961-497a-9f30-9edae95d8f87",
47 "revision": "1",
48 "_createdDate": "2023-03-07T14:16:25.452Z",
49 "_updatedDate": "2023-03-07T14:16:25.452Z",
50 "name": "Terms and Conditions Event 3",
51 "body": "<p><code>All tickets or passes should be checked on purchase, as mistakes cannot always be rectified.</code></p>",
52 "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
53 }
54 ]
55}
56*/
Reorder Policies (export from backend code)

Copy Code
1import { Permissions, webMethod } from 'wix-web-module';
2import { policies } from 'wix-events.v2';
3import { elevate } from 'wix-auth';
4
5// define event ID and policies to reorder
6const eventId = '3d3d5c04-ece0-45a8-85f0-11a58edaa192';
7const options = {
8 policyId: '52f15c5c-ea06-44f4-866a-b1cfa6f4f790',
9 beforePolicyId: '6933ddf1-26c7-46c3-9924-e78c833d6cca'
10};
11
12export const elevatedReorderPoliciesFunction = webMethod(Permissions.Anyone, async () => {
13 const elevatedReorderPolicies = elevate(policies.reorderEventPolicies);
14 try {
15 const result = await elevatedReorderPolicies(eventId, options);
16 return result;
17 }
18 catch (error) {
19 console.error(error);
20 // Handle the error
21 }
22 });
23
24/* Promise resolves to:
25 * {
26 * "policies": [
27 * {
28 * "_id": "52f15c5c-ea06-44f4-866a-b1cfa6f4f790",
29 * "revision": "2",
30 * "_createdDate": "2023-03-07T14:15:44.312Z",
31 * "_updatedDate": "2023-03-07T14:33:00.876Z",
32 * "name": "Terms and Conditions Event 1",
33 * "body": "<p><code>Tickets to this Event are issued on behalf of the Organiser and are subject to the following terms and conditions.</code></p>",
34 * "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
35 * },
36 * {
37 * "_id": "6933ddf1-26c7-46c3-9924-e78c833d6cca",
38 * "revision": "2",
39 * "_createdDate": "2023-03-07T13:18:09.185Z",
40 * "_updatedDate": "2023-03-07T14:33:01.072Z",
41 * "name": "Terms and Conditions Event 2",
42 * "body": "<p><code>Nobody will be allowed admission to the Event without a valid ticket or pass.</code></p>",
43 * "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
44 * },
45 * {
46 * "_id": "b9d5f876-f961-497a-9f30-9edae95d8f87",
47 * "revision": "1",
48 * "_createdDate": "2023-03-07T14:16:25.452Z",
49 * "_updatedDate": "2023-03-07T14:16:25.452Z",
50 * "name": "Terms and Conditions Event 3",
51 * "body": "<p><code>All tickets or passes should be checked on purchase, as mistakes cannot always be rectified.</code></p>",
52 * "eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
53 * }
54 * ]
55 * }
56 */
57