Introduction
With Events Policies APIs, you can manage the policies for a particular event. For example, you can create, update, and delete policies. You can also reorder policies in the Event Dashboard and checkout form.
Policies define terms & conditions for the events, such as terms for canceling attendance, transferring a ticket to another person, and so on. For example: "Participants are entitled to a 100% refund if canceling attendance 1 week prior to the event. After this date, participants will be refunded 50% of the ticket price."
A policy agreement checkbox will be added to the RSVP or checkout form. The policy text can be read in a pop-up window if you click the policy name. By default, there are no policies when you first create an event.
Terminology
- Policy: text that defines terms & conditions, as relevant.
- Event Dashboard: controls center which allows users to manage their site events settings and features.
- Checkout form: the final step in the ticket purchasing process where the customer fills in personal info, reads policies and pays money.
Setup
To use the Policies API, install the @wix/events
package using npm or Yarn:
1npm install @wix/events
or
1yarn add @wix/events
Then import { policies }
from @wix/events
:
1import { policies } from '@wix/events'
Creates a policy.
The createPolicy()
function returns a Promise that resolves to the newly-created policy.
You can create up to 3 policies per event. If you try to create more than 3, you'll get the "Maximum number of policies for the event has been reached" error.
Permission Scopes
For app development, you must have one of the following permission scopes:function createPolicy(policy: Policy): Promise<Policy>
Permanently deletes a policy.
The deletePolicy()
function returns a Promise that resolves when the specified policy is deleted.
Deleted policies are not returned by the getPolicy()
or queryPolicies()
functions.
Permission Scopes
For app development, you must have one of the following permission scopes:function deletePolicy(policyId: string): Promise<void>
Retrieves a policy by ID.
The getPolicy()
function returns a Promise that resolves to a policy whose ID matches the given ID.
Permission Scopes
For app development, you must have one of the following permission scopes:function getPolicy(policyId: string): Promise<Policy>
Creates a query to retrieve a list of policies, given the provided paging and filter.
The queryPolicies()
function builds a query to retrieve a list of policies and returns a PoliciesQueryBuilder object.
The returned object contains the query definition which is typically used to run the query using the find()
function.
You can refine the query by chaining PoliciesQueryBuilder
functions onto the query. PoliciesQueryBuilder
functions enable you to sort, filter and control the results that PoliciesQueryBuilder.find()
returns.
The query runs with the following PoliciesQueryBuilder
defaults that you can override:
limit
: 50
descending
: _createdDate
The functions that are chained to queryPolicies()
are applied in the order they are called. For example, if you sort on the _createdDate
property in ascending order and then on the id property in descending order, the results are sorted by the created date and then, if there are multiple results with the same date, the items are sorted by the id.
The table below shows which PoliciesQueryBuilder
functions are supported for queryPoliciesGuests()
. You can only use one filter function for each property. If a property is used in more than one filter, only the first filter will work.
PROPERTY | SUPPORTED FILTERS & SORTING |
---|---|
_id | eq() ,ne() ,in() ,exists() ,ascending() ,descending() |
revision | eq() ,ne() ,in() ,lt() ,le() ,gt() ,ge() ,exists() ,ascending() ,descending() |
_createdDate | eq() ,ne() ,in() ,lt() ,le() ,gt() ,ge() ,exists() ,ascending() ,descending() |
_updatedDate | eq() ,ne() ,in() ,lt() ,le() ,gt() ,ge() ,exists() ,ascending() ,descending() |
name | eq() ,ne() ,in() ,exists() ,ascending() ,descending() |
body | eq() ,ne() ,in() ,exists() ,ascending() ,descending() |
eventId | eq() ,ne() ,in() ,exists() ,ascending() ,descending() |
Permission Scopes
For app development, you must have one of the following permission scopes:function queryPolicies(): PoliciesQueryBuilder
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.
Permission Scopes
For app development, you must have one of the following permission scopes:function reorderEventPolicies(policyId: string, eventId: string, options: ReorderEventPoliciesOptions): Promise<ReorderEventPoliciesResponse>
Updates a policy.
The updatePolicy()
function returns a Promise that resolves to the newly-updated policy.
Each time the policy is updated, revision
increments by 1. The existing revision
must be included when updating the policy. This ensures you're working with the latest policy and prevents unintended overwrites.
Permission Scopes
For app development, you must have one of the following permission scopes:function updatePolicy(_id: string, policy: UpdatePolicy): Promise<Policy>