Tribe__Tickets_Plus__Meta::get_ticket_meta( array $meta, array $tickets )

Get ticket meta for Attendee Registration.


Parameters #

$meta

(array) (Required) List of meta for each ticket for Attendee Registration.

$tickets

(array) (Required) List of tickets with their ID and quantity.


Top ↑

Return #

(array) List of meta for each ticket for Attendee Registration.


Top ↑

Source #

File: src/Tribe/Meta.php

	public function get_ticket_meta( $meta, $tickets ) {
		/** @var Tribe__Tickets_Plus__Meta__Contents $contents */
		$contents = tribe( 'tickets-plus.meta.contents' );

		// Get ticket IDs.
		$tickets_for_meta = wp_list_pluck( $tickets, 'quantity', 'ticket_id' );

		$stored_meta = $contents->get_ticket_stored_meta( $tickets_for_meta );

		foreach ( $tickets as $ticket ) {
			$ticket_id = (int) $ticket['ticket_id'];

			$ticket_meta = isset( $stored_meta[ $ticket_id ] ) ? $stored_meta[ $ticket_id ] : [];

			$meta_to_be_added = [
				'ticket_id' => $ticket_id,
				'provider'  => $ticket['provider'],
				'items'     => [],
			];

			if ( ! is_array( $ticket_meta ) || empty( $ticket_meta[ $ticket_id ] ) ) {
				$meta[] = $meta_to_be_added;

				continue;
			}

			$meta_to_be_added['items'] = array_values( $ticket_meta[ $ticket_id ] );

			$meta[] = $meta_to_be_added;
		}

		return $meta;
	}

Top ↑

Changelog #

Changelog
Version Description
4.11.0 Introduced.