Handling Ticket Quantities with WooCommerce

The default ticket form generated by Event Tickets Plus with WooCommerce leaves the quantity selector set to zero for each listed ticket.

This is generally a sensible default, as customers may or may not wish to purchase tickets of a certain type—and if they do wish to make a purchase, it is hard to know exactly how many they will want.

Sometimes, however—particularly if only one type of ticket is for sale at any given time—it makes sense to have the default quantity set to one.

Using a Template Override

The general process for setting up template overrides (which is safest method of overriding and customizing our plugins) is described in our Themer's Guide. ⚠️ If you're not familiar with this process, you'll want to review the guide before continuing.

In this particular scenario we are going to copy:

/event-tickets-plus/src/views/wootickets/tickets.php

To:

/themes/YOUR_THEME/wootickets/tickets.php

Set the Default Input Value

Within that file, locate the following (should be around lines 55-60):

https://gist.github.com/theeventscalendar/395c8daab325775da9b4

See that part that reads 'input_value' => 0? Simply change the 0 to 1 and you're done!

Using JavaScript

The above method for altering the input value is focused mainly on WooCommerce. You can use JavaScript to alter the input quantities for any eCommerce platform, but adding code like the following to your theme's functions.php file:

function tribe_events_alter_tickets_default_quantity() {
	wp_enqueue_script( 'jquery' );
	?>
        <style>
        tr.tribe-tickets-meta-row {
		display: table-row !important;
	}
        </style>
	<script>
		jQuery(document).ready( function () {
			jQuery( 'input.tribe-ticket-quantity' ).val( 1 );
		});
	</script>
	<?php
}
add_action( 'wp_head', 'tribe_events_alter_tickets_default_quantity' );

The quantity is stepped, specifically, by this line of code:

jQuery( 'input.tribe-ticket-quantity' ).val( 1 );

So to change the quantity, just the val() value to whatever you'd like.