Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save barryhughes/b27845f1b39c86d3900bd8df897cda2a to your computer and use it in GitHub Desktop.
Save barryhughes/b27845f1b39c86d3900bd8df897cda2a to your computer and use it in GitHub Desktop.
Programmatically add a WooCommerce ticket (Event Tickets Plus 4.7.1)
<?php
Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance()->ticket_add( $event_id, [
'ticket_name' => 'Test ticket ' . uniqid(),
'ticket_provider' => 'Tribe__Tickets_Plus__Commerce__WooCommerce__Main',
'ticket_price' => '100',
'tribe_ticket' => [
'mode' => 'global',
'event_capacity' => '100',
'capacity' => ''
],
'ticket_description' => 'Wine and cheese night',
'ticket_show_description' => '1',
'ticket_start_date' => '',
'ticket_start_time' => '',
'ticket_end_date' => '',
'ticket_end_time' => '',
'ticket_sku' => uniqid(),
'ticket_id' => '',
] );
@pattyok
Copy link

pattyok commented Jan 8, 2022

In case anyone is finding this some time later... the syntax has changed a bit (I'm using Event TIckets 5.2.2).

To set the capacity use 'tribe-ticket' with a dash instead of underscore

'tribe-ticket'   => array(
			'mode'           => 'capped',
			'event_capacity' => 25,
			'capacity'       => '',
		),

Options for 'mode' are

  • 'capped' for shared capacity
  • 'own' for this ticket only (for that you only need 'mode' and 'capacity')
  • leave mode and capacity blank for unlimited

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment