Tribe__Tickets__Tickets::process_attendee_meta( int $product_id, array $meta )
Process the attendee meta into an array with value, slug, and label
Contents
Parameters
- $product_id
-
(int) (Required)
- $meta
-
(array) (Required)
Return
(array)
Source
File: src/Tribe/Tickets.php
public function process_attendee_meta( $product_id, $meta ) {
$meta_values = [];
if ( ! class_exists( 'Tribe__Tickets_Plus__Main' ) ) {
return $meta_values;
}
$meta_field_objects = Tribe__Tickets_Plus__Main::instance()->meta()->get_meta_fields_by_ticket( $product_id );
foreach ( $meta_field_objects as $field ) {
$value = null;
if ( 'checkbox' === $field->type ) {
$field_prefix = $field->slug . '_';
$value = [];
foreach ( $meta as $full_key => $check_value ) {
if ( 0 === strpos( $full_key, $field_prefix ) ) {
$short_key = substr( $full_key, strlen( $field_prefix ) );
$value[ $short_key ] = $check_value;
}
}
if ( empty( $value ) ) {
$value = null;
}
} elseif ( isset( $meta[ $field->slug ] ) ) {
$value = $meta[ $field->slug ];
}
$meta_values[ $field->slug ] = array(
'slug' => $field->slug,
'label' => $field->label,
'value' => $value,
);
}
return $meta_values;
}