Tribe__Tickets__Tickets::get_event_for_ticket( $ticket_product )
Returns the event post corresponding to the possible ticket object/ticket ID.
Contents
This is used to help differentiate between products which act as tickets for an event and those which do not. If $possible_ticket is not related to any events then boolean false will be returned.
This stub method should be treated as if it were an abstract method – ie, the concrete class ought to provide the implementation.
Parameters
- $ticket_product
-
(Required)
Return
(bool|WP_Post)
Source
File: src/Tribe/Tickets.php
public function get_event_for_ticket( $ticket_product ) {
if ( is_object( $ticket_product ) && isset( $ticket_product->ID ) ) {
$ticket_product = $ticket_product->ID;
}
if ( null === ( $product = get_post( $ticket_product ) ) ) {
return false;
}
$event_id = get_post_meta( $ticket_product, $this->event_key, true );
if ( ! $event_id && '' === ( $event_id = get_post_meta( $ticket_product, $this->attendee_event_key, true ) ) ) {
return false;
}
if ( in_array( get_post_type( $event_id ), Tribe__Tickets__Main::instance()->post_types() ) ) {
return get_post( $event_id );
}
return false;
}