Search.../

onPlanCreated( )

An event that triggers when a pricing plan is created.

Description

The onPlanCreated() event handler runs when a pricing plan is created. The received PlanCreatedEvent object contains information about the pricing plan that is created.

Note: Backend events don't work when previewing your site.

Syntax

function onPlanCreated(event: PlanCreatedEvent): void

onPlanCreated Parameters

NAME
TYPE
DESCRIPTION
event
PlanCreatedEvent

Information about the pricing plan that's created and metadata for the event.

Returns

This function does not return anything.

Return Type:

void

Was this helpful?

An event triggered when a pricing plan is created

Copy Code
1// Place this code in the events.js file
2// of your site's Backend section.
3// Add the file if it doesn't exist.
4
5export function wixPricingPlans_onPlanCreated(event) {
6 const planId = event.entity._id;
7 const planDescription = event.entity.description;
8 const eventId = event.metadata.id;
9 const eventTime = event.metadata.eventTime;
10}
11
12/* Full event object:
13 * {
14 * "metadata": {
15 * "id": "3743d382-a4d4-7e15-ada5-340ad4b5d760",
16 * "entityId": "c61bbc26-a4d4-7e15-ada5-f99803abce33",
17 * "eventTime": "2020-02-03T10:13:15.194Z",
18 * "triggeredByAnonymizeRequest": false
19 * },
20 * "entity": {
21 * "_id": "c61bbc26-a4d4-7e15-ada5-f99803abce33",
22 * "name": "Full membership",
23 * "description":"Full membership including weekends",
24 * "perks": [
25 * "Free parking",
26 * "Express line"
27 * ],
28 * "pricing": {
29 * "singlePaymentUnlimited": true,
30 * "price": {
31 * "value": "40",
32 * "currency": "USD"
33 * }
34 * },
35 * "public" : true,
36 * "_createdDate": "2020-02-03T10:13:15.194Z",
37 * "_updatedDate": "2020-02-03T10:13:15.194Z",
38 * "slug":"full-membership",
39 * "maxPurchasesPerBuyer": 1,
40 * "allowFutureStartDate": false,
41 * "buyerCanCancel": true,
42 * "termsAndConditions": "Copyright laws apply."
43 * }
44 * }
45 */