An event that triggers when a pricing plan is changed.
The onPlanUpdated()
event handler runs when a pricing plan has changed.
The received PlanUpdatedEvent
object contains information about the pricing plan that was updated.
Note: Backend events don't work when previewing your site.
function onPlanUpdated(event: PlanUpdatedEvent): void;
Information about the pricing plan that was updated 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_onPlanUpdated(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": "2021-02-03T10:09:23.194Z",
* "triggeredByAnonymizeRequest": false
* },
* "entity": {
* "_id": "c61bbc26-a4d4-7e15-ada5-f99803abce33",
* "name": "Full membership",
* "description":"Full membership including weekends and holidays",
* "perks": [
* "Free parking",
* "Express line"
* ],
* "pricing": {
* "singlePaymentUnlimited": true,
* "price": {
* "value": "45",
* "currency": "USD"
* }
* },
* "public" : true,
* "_createdDate": "2020-01-03T10:13:15.194Z",
* "_updatedDate": "2021-02-03T10:09:23.194Z",
* "slug":"full-membership",
* "maxPurchasesPerBuyer": 1,
* "allowFutureStartDate": false,
* "buyerCanCancel": true,
* "termsAndConditions": "Copyright laws still apply."
* }
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.