> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

> **Deprecated.** This method is deprecated. Planned removal date: 2025-01-01.

# Method name: verifyCoupon(eventId: string, reservationId: string, coupon: string)

# Method package: wixEventsFrontend

# Method menu location: wixEventsFrontend --> Tickets --> verifyCoupon

# Method Link: https://dev.wix.com/docs/velo/apis/wix-events-frontend/tickets/verify-coupon.md

# Method Description:

**Deprecated.**
This method will be deprecated on March 30, 2026. Replace with [getInvoice()](https://dev.wix.com/docs/sdk/backend-modules/events/orders/get-invoice.md).

> **Migration Instructions**
>
> To stay compatible with future changes, migrate to
> [`getInvoice()`](https://dev.wix.com/docs/sdk/backend-modules/events/orders/get-invoice.md). The coupon verification is now performed under the hood by the `getInvoice()` method.
>
> To migrate to the new method:
>
> 1. Add a backend file to your site.
>
> 2. Write a code so that it replaces the `verifyCoupon()` method from the frontend with the `getInvoice()` method from the backend. Export your backend function so that it can be used in the frontend.
>
> 3. Import your backend function into the frontend file. Test your changes to make sure your code behaves as expected.

 If the coupon has been verified, the `VerifyCouponResponse` contains
 an `invoice` property with an invoice that includes the coupon discounts. 

 If the coupon fails verification, the `VerifyCouponResponse` contains
 a `discountErrors` property including information about why the verification
 failed. 

 You may want to call `verifyCoupon()` in an input element's `onCustomValidation()`
 to validate a coupon code while the form is being filled out.

> **Note:** The frontend Events APIs aren't functional when previewing a site. View a published version of a site to see their complete functionality



# Method Code Examples:

*** Note: do not assume any prop names or enum values other than the ones in the example.

## Verify a ticket coupon

```javascript
import wixEventsFrontend from 'wix-events-frontend';

// ...

const eventId = // Get the event ID

// ...

let reservationId = // Returned from the reserve() function

// ...

let coupon = // get coupon

wixEventsFrontend.tickets.verifyCoupon(eventId, reservationId, coupon) 
  .then((result) => {
    if (result.discountErrors) {
      // handle verification failure
      let firstErrorCode = result.discountErrors.error[0].code;
    } else {
      // handle coupon verified
    }
  }); 

/* result - error case:
 *
 * {
 *   "discountErrors":{
 *     "error":[
 *       {
 *         "code":"ERROR_COUPON_DOES_NOT_EXIST"
 *       }
 *     ]
 *   }
 * }
*/

/* result - verified case
 *
 * {
 *   "invoice": {
 *     "items": [
 *       {
 *         "id": "de8e3fd8-b257-40a7-933b-77c627d884e4",
 *         "quantity": 2,
 *         "name": "VIP ticket",
 *         "price": {
 *           "amount": "6.00",
 *           "currency": "USD"
 *         },
 *         "total": {
 *           "amount": "12.00",
 *           "currency": "USD"
 *         },
 *         "discount":{
 *           "amount":{
 *             "amount":"2.0",
 *             "currency":"USD"
 *           },
 *           "afterDiscount":{
 *             "amount":"10.00",
 *             "currency":"USD"
 *           },
 *           "code":"CouponCode",
 *           "name":"Coupon Name",
 *           "couponId":"3b2e333c-5376-4b36-8543-00bae6dd8f59",
 *           "discounts":[
 *             {
 *               "amount":{
 *                 "amount":"2.0",
 *                 "currency":"USD"
 *               },
 *               "coupon":{
 *                 "name":"Coupon Name",
 *                 "code":"CouponCode",
 *                 "couponId":"3b2e333c-5376-4b36-8543-00bae6dd8f59"
 *               }
 *             }
 *           ]
 *         },
 *         "fees": [
 *           {
 *             "name": "WIX_FEE",
 *             "type": "FEE_ADDED",
 *             "rate": "2.5",
 *             "amount": {
 *               "amount": "0",
 *               "currency": "USD"
 *             }
 *           }
 *         ]
 *       },
 *       {
 *         "id": "9207637c-3d49-43af-b91e-32e496620c60",
 *         "quantity": 1,
 *         "name": "Regular ticket",
 *         "price": {
 *           "amount": "3.50",
 *           "currency": "USD"
 *         },
 *         "total": {
 *           "amount": "3.50",
 *           "currency": "USD"
 *         },
 *         "discount":{
 *           "amount":{
 *             "amount":"1.0",
 *             "currency":"USD"
 *           },
 *           "afterDiscount":{
 *             "amount":"2.50",
 *             "currency":"USD"
 *           },
 *           "code":"CouponCode",
 *           "name":"Coupon Name",
 *           "couponId":"3b2e333c-5376-4b36-8543-00bae6dd8f59",
 *           "discounts":[
 *             {
 *               "amount":{
 *                 "amount":"1.0",
 *                 "currency":"USD"
 *               },
 *               "coupon":{
 *                 "name":"Coupon Name",
 *                 "code":"CouponCode",
 *                 "couponId":"3b2e333c-5376-4b36-8543-00bae6dd8f59"
 *               }
 *             }
 *           ]
 *         },
 *         "fees": [
 *           {
 *             "name": "WIX_FEE",
 *             "type": "FEE_ADDED",
 *             "rate": "2.5",
 *             "amount": {
 *               "amount": "0",
 *               "currency": "USD"
 *             }
 *           }
 *         ]
 *       }
 *     ],
 *     "total":{
 *       "amount":"15.50",
 *       "currency":"BIF"
 *     },
 *     "discount":{
 *       "amount":{
 *         "amount":"3.0",
 *         "currency":"BIF"
 *       },
 *       "afterDiscount":{
 *         "amount":"12.50",
 *         "currency":"BIF"
 *       },
 *       "code":"CouponCode",
 *       "name":"Coupon Name",
 *       "couponId":"3b2e333c-5376-4b36-8543-00bae6dd8f59",
 *       "discounts":[
 *         {
 *           "amount":{
 *             "amount":"3.0",
 *             "currency":"BIF"
 *           },
 *           "coupon":{
 *             "name":"Coupon Name",
 *             "code":"CouponCode",
 *             "couponId":"3b2e333c-5376-4b36-8543-00bae6dd8f59"
 *           }
 *         }
 *       ]
 *     },
 *     "subTotal":{
 *       "amount":"15.50",
 *       "currency":"BIF"
 *     },
 *     "grandTotal":{
 *       "amount":"12.50",
 *       "currency":"BIF"
 *     },
 *     "fees":[],
 *     "revenue":{
 *       "amount":"12.50",
 *       "currency":"BIF"
 *     }
 *   }
 * }
 */
```

## Validate a coupon code in an element's `onCustomValidation()`

```javascript
import wixEventsFrontend from 'wix-events-frontend';

// ...

const eventId = // Get the event ID

// ...

let reservationId = // Returned from the reserve() function

// ...

let coupon = // get coupon

$w("#couponCode").onCustomValidation((value, reject) => {
  wixEventsFrontend.tickets.verifyCoupon(eventId, reservationId, coupon) 
    .then((result) => {
      if (result.discountErrors) {
        // handle verification failure
        $w("#couponCode").updateValidityIndication();
        $w("#couponErrorMsg").show();
        $w("#couponSuccessMsg").hide();
        reject("Coupon is invalid");
      } else {
        // handle coupon verified
        $w("#couponErrorMsg").hide()
				$w("#couponSuccessMsg").show()
      }
    });
});
```

## Reserve, checkout, and update tickets

```javascript
import wixEventsFrontend from 'wix-events-frontend';
import wixData from 'wix-data';
import wixPayFrontend from 'wix-pay-frontend';

let eventId;
let reservationId;
let orderNumber;
let tickets;

$w.onReady(function () {
  // Retrieve data and set up page
  await getData();
  $w("#ticketRepeater").onItemReady(displayTickets);
  $w("#ticketRepeater").data = tickets;

  // Define button click actions
  $w("#reservationButton").onClick(reserveTickets);
  $w("#checkoutButton").onClick(checkoutTickets);
  $w("#updateButton").onClick(updateTickets);

  // Verify coupon code when it is entered
  $w("#couponCode").onCustomValidation(verifyCouponCode);
});

async function getData() {
  // Run a query that returns only one event. Add
  // additional filtering to the query if necessary.
  const eventResults = await wixData.query("Events/Events")
    .eq("title", "My Event")
    .find();

  if (eventResults.items.length > 0) {
    eventId = eventResults.items[0]._id;

    // Get tickets for the event
    const ticketResults = await wixData.query("Events/Tickets")
      .eq("event", eventId)
      .find();

      if (ticketResults.items.length > 0) {
        tickets = ticketResults.items;
      } else {
        $w("#ticketRepeater").hide();
        console.log("Could not find tickets");
      }
  } else {
    console.log("Could not find event");
  }
}

function displayTickets($item, itemData, index) {
  $item("#ticketName").text = itemData.name;
  $item("#ticketPrice").text = itemData.price.toString();
  $item("#ticketQuantity").value = 0;
}

function reserveTickets() {
  const selectedTickets = getSelectedTickets();

  wixEventsFrontend.tickets.reserve(eventId, selectedTickets)
    .then((reservation) => {
      reservationId = reservation.id;
    })
    .catch((error) => {
      console.log("Error", error.message)
    });
}

function getSelectedTickets() {
  let selectedTickets = [];

  $w("#ticketRepeater").forEachItem(($item, itemData, index) => {
    if ($item("#ticketQuantity").value > 0) {
      selectedTickets.push( {
        "ticketId": itemData._id,
        "quantity": $item("#ticketQuantity").value
      });
    }
  });

  return selectedTickets;
}

function checkoutTickets() {
  wixEventsFrontend.tickets.checkout(eventId, reservationId, {
    "formValues": getFormValues(),
    "coupon": $w("#couponCode").value
  })
    .then(({order}) => {
      orderNumber = order.orderNumber
      wixPayFrontend.startPayment(order.paymentId);
      // Note that PDF tickets are available before payment is complete
      $w("#ticketsPdfLink").value = order.ticketsPdf;
    })
    .catch((error) => {
      console.log("Error", error.message)
    });
}

function updateTickets() {
  wixEventsFrontend.tickets.updateOrder(eventId, orderNumber, {
    "formValues": getFormValues()
  })
    .catch((error) => {
      console.log("Error", error.message)
    });
}

function verifyCouponCode(value, reject) {
  const coupon = $w("#couponCode").value;
  wixEventsFrontend.tickets.verifyCoupon(eventId, reservationId, coupon) 
    .then((result) => {
      if (result.discountErrors) {
        // handle verification failure
        $w("#couponCode").updateValidityIndication();
        $w("#couponErrorMsg").show();
        $w("#couponSuccessMsg").hide();
        reject("Coupon is invalid");
      } else {
        // handle coupon verified
        $w("#couponErrorMsg").hide()
        $w("#couponSuccessMsg").show()
      }
    });
}

function getFormValues() {
  return [
    {"name": "firstName", "value": $w("#firstName").value},
    {"name": "lastName", "value": $w("#lastName").value},
    {"name": "email", "value": $w("#email").value},
    {"name": "custom", "value": $w("#foodAllergies").value},

    // When a form contains an address, the way you format the
    // address information for submission depends on what type
    // of input elements you use to gather that information.

    // Wix address input element.
    {"name": "address", "value": $w("#address").value},

    // Single element which is not an address
    // input element, such as a text input.
    {"name": "address", "value": [$w("#address").value]},

    // Multiple elements for the
    // various parts of an address.
    {
      "name": "address", 
      "value": [
        $w("#street").value,
        $w("#city").value,
        $w("#state").value,
        $w("#country").value,
        $w("#postalCode").value
      ]
    },

    // When a form contains an input for adding more guests to an
    // RSVP, format the guest names for submission in an array
    // where each element is the full name of a guest.
    {"name": "additionalGuests", "value": $w("#additionalGuests").value},
    {
      "name": "guestNames",
      "value": [
        `${$w("#guest1FirstName").value} ${$w("#guest1LastName").value}`,
        `${$w("#guest2FirstName").value} ${$w("#guest2LastName").value}`,
      ]
    }
  ];
}
```

---