Hooks::filter_cart_meta( array $meta, array $tickets )

Modifies the Cart Meta fields for editing on the Attendee Registration page.


Parameters #

$meta

(array) (Required)

$tickets

(array) (Required)


Top ↑

Return #

(array)


Top ↑

Source #

File: src/Tickets_Plus/Commerce/Attendee_Registration/Hooks.php

	public function filter_cart_meta( $meta, $tickets ) {
		$cookie = tribe_get_request_var( Cart::$cookie_query_arg );

		// If we dont have a cookie hash passed we just bail, since it means it's not Tickets Commerce.
		if ( empty( $cookie ) ) {
			return $meta;
		}

		$meta = [];
		/* @var Cart $cart */
		$cart = tribe( Cart::class );
		$cart->set_cart_hash( $cookie );
		$items = $cart->get_items_in_cart( true );

		foreach ( $items as $ticket_id => $item ) {
			$attendees        = Arr::get( $item, [ 'extra', 'attendees' ], [] );
			$meta_to_be_added = [
				'ticket_id' => $ticket_id,
				'provider'  => Commerce::PROVIDER,
				'items'     => [],
			];

			foreach ( $attendees as $attendee ) {
				if ( empty( $attendee['meta'] ) ) {
					continue;
				}
				$meta_to_be_added['items'][] = $attendee['meta'];

			}
			$meta[] = $meta_to_be_added;
		}

		return $meta;
	}

Top ↑

Changelog #

Changelog
Version Description
5.3.0 Introduced.