Search.../

onCouponCreated( )

An event that is triggered when a coupon is created.

Description

The onCouponCreated() event handler runs when a new coupon is created.

Note: Backend events don't work when previewing your site.

Syntax

function onCouponCreated(event: CouponEvent): void

onCouponCreated Parameters

NAME
TYPE
DESCRIPTION
event
CouponEvent

Information about a newly created coupon.

Returns

This function does not return anything.

Return Type:

void

Related Content:

Was this helpful?

An event when a coupon is created

Copy Code
1// Place this code in the events.js file
2// of your site's Backend section.
3
4export function wixMarketing_onCouponCreated(event) {
5 const newCouponId = event.entity._id;
6 const newCouponType = event.entity.type;
7 const couponValidFrom = event.entity.startTime;
8}
9
10/* Full event object
11 *
12 * {
13 * "metadata": {
14 * "id": "c4ea2c0a-0952-48ad-9b15-39e660448663",
15 * "entityId": "03a35393-7835-44b0-af53-6019a484b48b",
16 * "eventTime": "2021-01-17T11:40:56.795047Z",
17 * "triggeredByAnonymizeRequest": false
18 * },
19 * "entity": {
20 * "_id": "03a35393-7835-44b0-af53-6019a484b48b",
21 * "name": "Summer Sale 10% off",
22 * "code": "SummerSale",
23 * "startTime": "Wed Jun 30 2021 21:00:00 GMT+0000 (Coordinated Universal Time)",
24 * "expirationTime": "Tue Aug 31 2021 20:59:59 GMT+0000 (Coordinated Universal Time)",
25 * "limitPerCustomer": 1,
26 * "active": true,
27 * "scope": {
28 * "namespace": "stores"
29 * },
30 * "_dateCreated": "Sun Jan 17 2021 11:40:56 GMT+0000 (Coordinated Universal Time)",
31 * "expired": false,
32 * "displayData": null,
33 * "limitedToOneItem": true,
34 * "type": "PercentOff",
35 * "percentOffRate": 10
36 * }
37 * }
38 *
39 */