Tribe__Tickets__Editor__Blocks__Tickets::ticket_availability( array $tickets = array() )
Check for ticket availability
Contents
Parameters
- $tickets
-
(array) (Optional) (IDs of tickets to check)
Default value: array()
Return
(void)
Source
File: src/Tribe/Editor/Blocks/Tickets.php
public function ticket_availability( $tickets = array() ) {
$response = array( 'html' => '' );
$tickets = tribe_get_request_var( 'tickets', array() );
// Bail if we receive no tickets
if ( empty( $tickets ) ) {
wp_send_json_error( $response );
}
// Parse the tickets and create the array for the response
foreach ( $tickets as $ticket_id ) {
$ticket = Tribe__Tickets__Tickets::load_ticket_object( $ticket_id );
$available = $ticket->available();
$response['tickets'][ $ticket_id ]['available'] = $available;
// If there are no more available we will send the template part HTML to update the DOM
if ( 0 === $available ) {
$response['tickets'][ $ticket_id ]['unavailable_html'] = tribe( 'tickets.editor.template' )->template( 'blocks/tickets/quantity-unavailable', $ticket, false );
}
}
wp_send_json_success( $response );
}
Changelog
| Version | Description |
|---|---|
| 4.9 | Introduced. |