Skip to main content

maxSelectedObjects

Type: number | object[]
Default: not set

Restrict the number of objects a user is allowed to select.

This restriction can be implemented in two ways: as a maximum total number of selected objects (by passing in a number), or you can set different limits for each category or ticket type, or even combination thereof (by passing in an object).

Total Limit

When using a number X, the user will be able to select a max of X objects overall.

maxSelectedObjects: 5

Ticket Type Limit

You can limit the number of selectable objects per ticket type by passing an array of objects to the maxSelectedObjects parameter. For an explanation about ticket types and multilevel pricing, please refer to here.

Each object in the array should have two properties: ticketType and `quantity:

maxSelectedObjects: [
{ ticketType: 'adult', quantity: 2 },
{ ticketType: 'child', quantity: 3 }
]

You can also combine ticket type limits with a total limit. For example, to limit users to selecting up to 4 objects in total, but with a maximum of 2 objects for the "adult" ticket type and a maximum of 3 objects for the "child" ticket type, do this:

maxSelectedObjects: [
{ ticketType: 'adult', quantity: 2 },
{ ticketType: 'child', quantity: 3 },
{ total: 4 }
]
Only passed ticket types will be selectable

If you don't pass in all ticket types, the ticket buyer will not be able to select tickets in the missing ticket types. E.g. if the max number of adult tickets is set to 2, and no max is set for child tickets, the ticket buyer will only be able to select adult tickets.

Category Limit

You can limit the number of selectable objects per category by passing an array of objects to the maxSelectedObjects parameter.

maxSelectedObjects: [
{ category: 'balcony', quantity: 4 },
{ category: 'stalls', quantity: 5 }
]

You can also combine category limits with a total limit. For example, to limit users to selecting up to 7 objects in total, but with a maximum of 5 objects the "balcony" category and a maximum of 4 objects on the "stalls" category, do this:

maxSelectedObjects: [
{ category: 'balcony', quantity: 5 },
{ category: 'stalls', quantity: 4 },
{ total: 7 }
]

Finally, you can combine category and ticket type limits as well:

maxSelectedObjects: [
{
category: "balcony",
ticketTypes: [
{ ticketType: 'adult', quantity: 1 },
{ ticketType: 'child', quantity: 1 }
]
},
{
category: "stalls",
ticketTypes: [
{ ticketType: 'adult', quantity: 1 },
{ ticketType: 'child', quantity: 2 }
]
}
]
Only passed categories will be selectable

If you don't pass in all categories, the ticket buyer will not be able to select tickets in the missing categories. E.g. if the max number of balcony tickets is set to 2, and no max is set for stalls tickets, the ticket buyer will only be able to select balcony tickets.

Example

Notes

Security notice

You should also validate this server side; a somewhat clever user can change this value right from the browser to bypass the validation.