Search...
onPlanCreated( )
Developer Preview
An event that is triggered when a pricing plan is created.
Description
The onPlanCreated()
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 wixPricingPlans_onPlanCreated(event: PlanCreated): void
onPlanCreated Parameters
NAME
TYPE
DESCRIPTION
event
Optional
PlanCreated
Information about the pricing plan that was created and metadata for the event.
Returns
This function does not return anything.
Return Type:
void
Was this helpful?
onPlanCreated example
Copy Code
1// Place this code in the events.js file2// of your site's Backend section.3// Add the file if it doesn't exist.45export function wixPricingPlans_onPlanCreated(event) {6 const planId = event.data._id;7 const planName = event.data.name;8 const eventTime = event.metadata.eventTime;910 console.log(`The plan, ${planName} with ID ${planId} was created at ${eventTime}. Full event object:`, event);11}1213/* Full event object:14 * {15 * "entity": {16 * "_createdDate": "2024-01-07T07:33:59.973Z",17 * "_id": "b20feb39-a452-453e-96ee-01036adcd04e",18 * "_updatedDate": "2024-01-07T07:33:59.973Z",19 * "allowFutureStartDate": false,20 * "archived": false,21 * "buyerCanCancel": true,22 * "description": "Full feature enablement - lifetime plan",23 * "hasOrders": false,24 * "maxPurchasesPerBuyer": 0,25 * "name": "Premium Plan - Lifetime Membership",26 * "perks": [27 * "Cloud drive and file upload services",28 * "Unlimited video content access"29 * ],30 * "pricing": {31 * "price": {32 * "currency": "EUR",33 * "value": "1000"34 * },35 * "singlePaymentUnlimited": true36 * },37 * "primary": false,38 * "public": true,39 * "slug": "premium-plan-lifetime-membership",40 * "termsAndConditions": "This plan allows unlimited app and site features usage for all time, subject to our fair usage agreement and basic human decency agreement.",41 * },42 * "metadata": {43 * "entityId": "b20feb39-a452-453e-96ee-01036adcd04e",44 * "eventTime": "2024-01-07T07:34:00.110589Z",45 * "id": "53be874c-0d44-4f53-9fce-d0cc565d447d",46 * "triggeredByAnonymizeRequest": false47 * }48 * }49 */