An event that triggers when a pricing plan is created.
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.
function onPlanCreated(event: PlanCreatedEvent): void;
Information about the pricing plan that's created and metadata for the event.
// Place this code in the events.js file
// of your site's Backend section.
// Add the file if it doesn't exist.
export function wixPricingPlans_onPlanCreated(event) {
const planId = event.entity._id;
const planDescription = event.entity.description;
const eventId = event.metadata.id;
const eventTime = event.metadata.eventTime;
}
/* Full event object:
* {
* "metadata": {
* "id": "3743d382-a4d4-7e15-ada5-340ad4b5d760",
* "entityId": "c61bbc26-a4d4-7e15-ada5-f99803abce33",
* "eventTime": "2020-02-03T10:13:15.194Z",
* "triggeredByAnonymizeRequest": false
* },
* "entity": {
* "_id": "c61bbc26-a4d4-7e15-ada5-f99803abce33",
* "name": "Full membership",
* "description":"Full membership including weekends",
* "perks": [
* "Free parking",
* "Express line"
* ],
* "pricing": {
* "singlePaymentUnlimited": true,
* "price": {
* "value": "40",
* "currency": "USD"
* }
* },
* "public" : true,
* "_createdDate": "2020-02-03T10:13:15.194Z",
* "_updatedDate": "2020-02-03T10:13:15.194Z",
* "slug":"full-membership",
* "maxPurchasesPerBuyer": 1,
* "allowFutureStartDate": false,
* "buyerCanCancel": true,
* "termsAndConditions": "Copyright laws apply."
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.