The code in this file sets up the repeater to display the different ticket types for the event, and allows visitors to buy varying amounts of each ticket by clicking the button.
In this file, we:
Configure the repeater items to reflect the various tickets in the Events/Tickets collection.
Add an onClick() event handler to the Buy Tickets button. The handler calls reserveTickets() from reserveTickets.js to reserve the tickets and navigate the visitor to a payment form.
The code in this file manages the ticket reservation process for the event. The code retrieves the correct event, collects the selected ticket types and quantities, reserves the tickets, and then navigates the visitor to a payment form.
We defined the following methods:
getEventId(): Finds the event in the Events/Events collection by title, and returns the event’s id.
getSelectedTickets(): Reads the visitor’s ticket selections from the page and returns a list of objects representing ticket types where the visitor chose an amount. Each object has the following fields:
ticketId: The unique ID of the ticket type selected.
quantity: The number of tickets the visitor chose for that type.
reserveTickets(): Exported method. Uses getEventId() and getSelectedTickets() to reserve the visitor’s selected tickets for the event, and then redirects to a payment form page upon success, or logs an error if the reservation fails.
Join the Wix Studio community on Discord, where experienced developers and fellow creators come together to share tips, troubleshoot issues, and collaborate.
Building a coded solution on your own can be challenging. Let an experienced Wix developer build it for you, so you can keep working on your site or business.
Visit the Wix Marketplace to find a trusted developer.