Abstract_Cart::get_items_in_cart( bool $full_item_params = false )
Get the tickets currently in the cart for a given provider.
Contents
Parameters
- $full_item_params
-
(bool) (Optional) Determines all the item params, including event_id, sub_total, and obj.
Default value: false
Return
(TECTicketsCommerceCartarray<string,) mixed> List of items.
Source
File: src/Tickets/Commerce/Cart/Abstract_Cart.php
public function get_items_in_cart( $full_item_params = false ): array {
$items = $this->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'] = Tickets::load_ticket_object( $item['ticket_id'] );
// If it's an invalid ticket we just remove it.
if ( ! $item['obj'] instanceof Ticket_Object ) {
return null;
}
$sub_total_value = Value::create();
$sub_total_value->set_value( $item['obj']->price );
$item['event_id'] = $item['obj']->get_event_id();
$item['sub_total'] = $sub_total_value->sub_total( $item['quantity'] );
return $item;
},
$items
);
}
return array_filter( $items );
}
Changelog
| Version | Description |
|---|---|
| 5.10.0 | Introduced. |