Search...
onCouponApplied( )
An event that is triggered when a coupon is used.
Description
The onCouponApplied()
event handler runs when an order with an applied coupon is completed, or when an order is manually marked as paid.
Note: Backend events don't work when previewing your site.
Authorization
Request
This endpoint does not take any parameters
Status/Error Codes
Was this helpful?
An event when a coupon is applied
Copy Code
1// Place this code in the events.js file2// of your site's Backend section.34export function wixMarketing_onCouponApplied(event) {5 const appliedCouponId = event.data.coupon._id;6 const appliedCouponName = event.data.coupon.name;7 const couponAppliedTime = event.metadata.eventTime;8 const appliedCouponOrderId = event.data.wixAppOrderId;9}1011/* Full event object12 *13 * {14 * "metadata": {15 * "id": "99a3d562-1650-40e6-97f5-3918e6ec94aa",16 * "entityId": "03a35393-7835-44b0-af53-6019a484b48b",17 * "eventTime": "2021-07-17T11:56:03.852350Z",18 * "triggeredByAnonymizeRequest": false19 * },20 * "data": {21 * "coupon": {22 * "_id": "03a35393-7835-44b0-af53-6019a484b48b",23 * "name": "Summer Sale 10% off",24 * "code": "SummerSale",25 * "startTime": "Wed Jun 30 2021 21:00:00 GMT+0000 (Coordinated Universal Time)",26 * "expirationTime": "Tue Aug 31 2021 20:59:59 GMT+0000 (Coordinated Universal Time)",27 * "limitPerCustomer": 1,28 * "active": true,29 * "scope": {30 * "namespace": "stores",31 * "group": {32 * "name": "product",33 * "entityId": "5376f9ec-b92e-efa9-e4a1-f4f480aa0d3a"34 * }35 * },36 * "_dateCreated": "Sun Jan 17 2021 11:40:56 GMT+0000 (Coordinated Universal Time)",37 * "numberOfUsages": 1,38 * "expired": false,39 * "displayData": {40 * "name": "Indonesian Blend",41 * "formattedPrice": "$35.00",42 * "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"43 * },44 * "limitedToOneItem": false,45 * "type": "PercentOff",46 * "percentOffRate": 1047 * },48 * "wixAppId": "1380b703-ce81-ff05-f115-39571d94dfcd",49 * "wixAppOrderId": "6758b1bc-539f-430c-a0ea-889130ef3351"50 * }51 * }52 *53 */