Tribe__Tickets__Data_API::ticket_has_meta_fields( $post_id, null $context = null )
Return if tickets have meta fields
Contents
Parameters
- $post_id
-
(Required)
- $context
-
(null) (Optional)
Default value: null
Return
(bool)
Source
File: src/Tribe/Data_API.php
public function ticket_has_meta_fields( $post_id, $context = null ) {
$services = $this->detect_by_id( $post_id );
if ( ! is_array( $services ) ) {
$services = array();
}
$has_meta_fields = false;
$products = [];
// if no class then look for tickets by event/post id
if ( ! isset( $services['class'] ) ) {
$products = $this->get_product_ids_from_tickets( Tribe__Tickets__Tickets::get_all_event_tickets( $post_id ) );
}
$has_products = ! empty( $products );
// if no product ids and id is not ticket related return false
$is_ticket_related = array_intersect( array( 'order', 'ticket', 'attendee', 'product' ), $services );
if ( ! $has_products && ! $is_ticket_related ) {
return false;
}
// if the id is a product add the id to the array
$is_product = array_intersect( array( 'product' ), $services );
if ( ! $has_products && $is_product ) {
$has_products = true;
$products[] = absint( $post_id );
}
//elseif handle order id ticket&attendee
$is_order_ticket_attendee = array_intersect( array( 'order', 'ticket', 'attendee' ), $services );
if ( ! $has_products && $is_order_ticket_attendee ) {
$products = $this->get_product_ids_from_attendees( $this->get_attendees( $post_id, $context, $services ) );
}
if ( ! empty( $products ) ) {
$has_meta_fields = $this->check_for_meta_fields_by_product_id( $products );
}
return $has_meta_fields;
}