Skip to content

Instantly share code, notes, and snippets.

@stompweb
Last active March 14, 2018 16:14
Show Gist options
  • Save stompweb/017e02251527185c93c6ddba2838e233 to your computer and use it in GitHub Desktop.
Save stompweb/017e02251527185c93c6ddba2838e233 to your computer and use it in GitHub Desktop.
Add event ticket
<?php
$event_id = Tribe__Events__API::createEvent(
array(
'post_title' => $event['title'],
'post_status' => 'publish',
'EventStartDate' => $event['date'],
'EventEndDate' => $event['date'],
'EventStartHour' => $event['start'],
'EventStartMinute' => '00',
'EventEndHour' => $event['finish'],
'EventEndMinute' => '00',
'EventCost' => $event['cost'],
));
$api = Tribe__Tickets_Plus__Commerce__WooCommerce__Main::get_instance();
// Create a ticket
$ticket = new Tribe__Tickets__Ticket_Object();
$ticket->name = 'Reservation';
$ticket->description = $ticket->name;
$ticket->price = 5;
$ticket->purchase_limit = 8;
// Save the ticket
$ticket->ID = $api->save_ticket($event_id, $ticket, array(
'ticket_name' => $ticket->name,
'ticket_woo_stock' => $ticket->purchase_limit,
));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment