An event that is triggered when a coupon is updated.
The onCouponUpdated()
event handler runs when a coupon is updated.
Note: Backend events don't work when previewing your site.
function onCouponUpdated(event: CouponEvent): void;
Information about an updated coupon.
// Place this code in the events.js file
// of your site's Backend section.
export function wixMarketing_onCouponUpdated(event) {
const updatedCouponId = event.entity._id;
const updatedCouponCode = event.entity.code;
const productIdCouponAppliesTo = event.entity.scope.group.entityId;
}
/* Full event object
*
* {
* "metadata": {
* "id": "77aff6e5-974c-49f0-adc1-255363cd5c55",
* "entityId": "03a35393-7835-44b0-af53-6019a484b48b",
* "eventTime": "2021-01-17T11:49:44.606828Z",
* "triggeredByAnonymizeRequest": false
* },
* "entity": {
* "_id": "03a35393-7835-44b0-af53-6019a484b48b",
* "name": "Summer Sale 10% off",
* "code": "SummerSale",
* "startTime": "Wed Jun 30 2021 21:00:00 GMT+0000 (Coordinated Universal Time)",
* "expirationTime": "Tue Aug 31 2021 20:59:59 GMT+0000 (Coordinated Universal Time)",
* "limitPerCustomer": 1,
* "active": true,
* "scope": {
* "namespace": "stores",
* "group": {
* "name": "product",
* "entityId": "5376f9ec-b92e-efa9-e4a1-f4f480aa0d3a"
* }
* },
* "_dateCreated": "Sun Jan 17 2021 11:40:56 GMT+0000 (Coordinated Universal Time)",
* "expired": false,
* "displayData": {
* "name": "Indonesian Blend",
* "formattedPrice": "$35.00",
* "mediaItem": "https://static.wixstatic.com/media/nsplsh_316b6449475f3235386255~mv2_d_2977_3951_s_4_2.jpg/v1/fit/w_2977,h_3951,q_90/file.jpg"
* },
* "limitedToOneItem": false,
* "type": "PercentOff",
* "percentOffRate": 10
* }
* }
*
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.