Reserves tickets for an event.
The reserve()
function returns a Promise that resolves to a
ReservationResponse
when the tickets have been reserved.
Retrieve ticket IDs to specify which tickets to reserve from the Events/Tickets collection. Each ticket must have a unique ID.
Note: To work with the Wix Events API, you need to publish your site.
Note:
You can use the backend createReservation()
function to reserve tickets.
function reserve(
eventId: string,
tickets: Array<TicketSelection>,
): Promise<ReservationResponse>;
ID of the event to reserve tickets for.
Tickets to reserve.
import wixEventsFrontend from "wix-events-frontend";
const selectedTickets = [
{ ticketId: "1234-123456-123456-1234", quantity: 1 },
{ ticketId: "2345-234567-234567-2345", quantity: 2 },
];
wixEventsFrontend.tickets.reserve(eventId, selectedTickets).then((response) => {
let reservationId = response.id;
let expirationTime = response.expirationTime;
let firstReservation = response.reservations[0];
let invoice = response.invoice;
let grandTotal = invoice.grandTotal.amount;
});
/* response:
*
* {
* "id": "97948a8a-e902-453d-a0a9-5ee6a674fd36",
* "reservations": [
* {
* "quantity": 1,
* "ticket": {
* "price": {
* "amount": "6.00",
* "currency": "USD"
* },
* "free": false,
* "name": "VIP ticket",
* "description": "Super special ticket",
* "limitPerCheckout": 0,
* "orderIndex": 0,
* "policy": "No returns",
* "eventId": "9a513b88-a223-4144-b0dc-938fd7cc5b4a",
* "_id": "de8e3fd8-b257-40a7-933b-77c627d884e4"
* }
* }, {
* "quantity": 2,
* "ticket": {
* "price": {
* "amount": "3.50",
* "currency": "USD"
* },
* "free": false,
* "name": "Regular ticket",
* "description": "Just a regular ticket",
* "limitPerCheckout": 0,
* "orderIndex": 0,
* "policy": "No refunds",
* "eventId": "9a513b88-a223-4144-b0dc-938fd7cc5b4a",
* "_id": "9207637c-3d49-43af-b91e-32e496620c60"
* }
* }
* ],
* "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"
* }
* },
* "expirationTime": "2020-04-22T12:49:59.233Z"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.