Last active
March 14, 2018 16:14
-
-
Save stompweb/017e02251527185c93c6ddba2838e233 to your computer and use it in GitHub Desktop.
Add event ticket
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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