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.
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.
This function requires elevated permissions and runs only on the backend and on dashboard pages.
function reorderEventPolicies(
policyId: string,
eventId: string,
options: ReorderEventPoliciesOptions,
): Promise<ReorderEventPoliciesResponse>;
Event policy ID.
Event ID.
Options for Reorder Event Policies function.
import { policies } from "wix-events.v2";
// define event ID and policies to reorder
const eventId = "3d3d5c04-ece0-45a8-85f0-11a58edaa192";
const options = {
policyId: "52f15c5c-ea06-44f4-866a-b1cfa6f4f790",
beforePolicyId: "6933ddf1-26c7-46c3-9924-e78c833d6cca",
};
// reorder policies
async function elevatedReorderPoliciesFunction() {
const elevatedReorderPolicies = wixAuth.elevate(
policies.reorderEventPolicies,
);
try {
const result = await elevatedReorderPolicies(eventId, options);
return result;
} catch (error) {
console.error(error);
// Handle the error
}
}
/* Returns a promise that resolves to
the reordered policies.
{
"policies": [
{
"_id": "52f15c5c-ea06-44f4-866a-b1cfa6f4f790",
"revision": "2",
"_createdDate": "2023-03-07T14:15:44.312Z",
"_updatedDate": "2023-03-07T14:33:00.876Z",
"name": "Terms and Conditions Event 1",
"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>",
"eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
},
{
"_id": "6933ddf1-26c7-46c3-9924-e78c833d6cca",
"revision": "2",
"_createdDate": "2023-03-07T13:18:09.185Z",
"_updatedDate": "2023-03-07T14:33:01.072Z",
"name": "Terms and Conditions Event 2",
"body": "<p><code>Nobody will be allowed admission to the Event without a valid ticket or pass.</code></p>",
"eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
},
{
"_id": "b9d5f876-f961-497a-9f30-9edae95d8f87",
"revision": "1",
"_createdDate": "2023-03-07T14:16:25.452Z",
"_updatedDate": "2023-03-07T14:16:25.452Z",
"name": "Terms and Conditions Event 3",
"body": "<p><code>All tickets or passes should be checked on purchase, as mistakes cannot always be rectified.</code></p>",
"eventId": "3d3d5c04-ece0-45a8-85f0-11a58edaa192"
}
]
}
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.