Cart::get_items_in_cart( bool $full_item_params = false )

Get the tickets currently in the cart for a given provider.


Parameters

$full_item_params

(bool) (Optional) Determines all the item params, including event_id, sub_total, and obj.

Default value: false


Top ↑

Return

(array) List of items.


Top ↑

Source

File: src/Tickets/Commerce/Cart.php

	public function get_items_in_cart( $full_item_params = false ) {
		$cart  = $this->get_repository();
		$items = $cart->get_items();

		// When Items is empty in any capacity return an empty array.
		if ( empty( $items ) ) {
			return [];
		}

		if ( $full_item_params ) {
			$items = array_map( static function ( $item ) {
				$item['obj']       = \Tribe__Tickets__Tickets::load_ticket_object( $item['ticket_id'] );
				// If it's an invalid ticket we just remove it.
				if ( ! $item['obj'] instanceof \Tribe__Tickets__Ticket_Object ) {
					return null;
				}

				$item['event_id']  = $item['obj']->get_event_id();
				$item['sub_total'] = Price::sub_total( $item['obj']->price, $item['quantity'] );

				return $item;
			}, $items );
		}

		return array_filter( $items );
	}

Top ↑

Changelog

Changelog
Version Description
5.1.9 Introduced.