Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// Force the Name field in the Event Ticket (Plus) ticket attendee information is unique (which may be intentionally hidden [which makes this even more important since you can see/fix the issue of the name fields needing to be unique per Event Tickets for The Events Calendar, currently & oddly.])
function makeEventTicketAttendeeNamesUnique() {
$('.tribe-tickets__iac-field--name .tribe-tickets__form-field-input').each(function (i) {
if (!$(this).hasClass('duplicate-prevented')) {
var originalValue = $(this).val();
$(this).val(originalValue + ' #' + (i + 1));
$(this).addClass('duplicate-prevented');
}
});
}
// Only bother running on event detail pages where tickets are offered
$('body.single-tribe_events').on('click change', 'a,button,input', function () {
// Instant update
makeEventTicketAttendeeNamesUnique();
// Account for the modal overlay for ticket info to be shown before augmenting
setTimeout(function () {
makeEventTicketAttendeeNamesUnique();
}, 1000);
setTimeout(function () {
makeEventTicketAttendeeNamesUnique();
}, 5000);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment