Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save KZeni/a6f6beda651a6ab39146e367722be3a4 to your computer and use it in GitHub Desktop.
Save KZeni/a6f6beda651a6ab39146e367722be3a4 to your computer and use it in GitHub Desktop.
// 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