An event that is triggered when a coupon is created.
The onCouponCreated()
event handler runs when a new coupon is created.
Note: Backend events don't work when previewing your site.
function onCouponCreated(event: CouponEvent): void;
Information about a newly created coupon.
// Place this code in the events.js file
// of your site's Backend section.
export function wixMarketing_onCouponCreated(event) {
const newCouponId = event.entity._id;
const newCouponType = event.entity.type;
const couponValidFrom = event.entity.startTime;
}
/* Full event object
*
* {
* "metadata": {
* "id": "c4ea2c0a-0952-48ad-9b15-39e660448663",
* "entityId": "03a35393-7835-44b0-af53-6019a484b48b",
* "eventTime": "2021-01-17T11:40:56.795047Z",
* "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"
* },
* "_dateCreated": "Sun Jan 17 2021 11:40:56 GMT+0000 (Coordinated Universal Time)",
* "expired": false,
* "displayData": null,
* "limitedToOneItem": true,
* "type": "PercentOff",
* "percentOffRate": 10
* }
* }
*
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.