Created
August 23, 2021 01:14
-
-
Save n8kowald/2edec02fe34055465885d70380013856 to your computer and use it in GitHub Desktop.
Tribe Tickets Plus - echo_attendee_meta
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 | |
// nkowald - The only way to hide Ticket ID and Security Code is using the tribe_tickets_plus_woo_meta_data_enabled filter. | |
/** | |
* Echoes attendee meta for every attendee in selected order | |
* | |
* @since 5.2.7 | |
* | |
* @param string $order_id Order or RSVP post ID. | |
* @param string $ticket_id The specific ticket to output attendees for. | |
*/ | |
protected function echo_attendee_meta( $order_id, $ticket_id = null ) { | |
/** @var \Tribe__Tickets_Plus__Commerce__WooCommerce__Main $woo_provider */ | |
$woo_provider = tribe( 'tickets-plus.commerce.woo' ); | |
$attendees = $woo_provider->get_attendees_by_id( $order_id ); | |
foreach ( $attendees as $attendee ) { | |
// Skip attendees that are not for this ticket type. | |
if ( ! empty( $ticket_id ) && $ticket_id != $attendee['product_id'] ) { | |
continue; | |
} | |
$table_columns = []; | |
// nkowald - Ticket ID added into $table_columns (not filterable). | |
$table_columns[] = [ | |
sprintf( | |
'<strong class="tribe-attendee-meta-heading">%1$s</strong>', | |
esc_html_x( 'Ticket ID', 'Attendee meta table.', 'event-tickets-plus' ) | |
), | |
sprintf( | |
'<strong class="tribe-attendee-meta-heading">%1$s</strong>', | |
esc_html( $attendee['ticket_id'] ) | |
), | |
]; | |
$table_columns = $this->maybe_add_iac_data( $attendee, $table_columns ); | |
$attendee_meta_data = $this->get_attendee_meta( $attendee['product_id'], $attendee['qr_ticket_id'] ); | |
/** | |
* Allow filtering for the Attendee meta data. | |
* | |
* @since 5.2.8 | |
* | |
* @param array $fields Array of attendee meta data. | |
*/ | |
$fields = apply_filters( 'tribe_tickets_plus_woo_meta_data_filter', $attendee_meta_data ); | |
// nkowald - Does not contain ticket id or security code. | |
var_dump($fields); | |
if ( ! empty( $fields ) ) { | |
foreach ( $fields as $field ) { | |
$table_columns[] = [ | |
esc_html( $field['label'] ), | |
esc_html( $field['value'] ), | |
]; | |
} | |
} | |
// nkowald - Security Code added into $table_columns (not filterable). | |
$table_columns[] = [ | |
esc_html_x( 'Security Code', 'Attendee meta table.', 'event-tickets-plus' ), | |
esc_html( $attendee['security_code'] ), | |
]; | |
$table = new \Tribe__Simple_Table( $table_columns ); | |
$table->html_escape_td_values = false; | |
$table->table_attributes = [ | |
'class' => 'tribe-attendee-meta', | |
]; | |
echo wp_kses_post( $table->output_table() ); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment