Tribe__Tickets__Commerce__PayPal__Order::get_item_quantity( int|null $ticket_id = null )
Returns the quantity of tickets part of the Order.
Contents
Parameters
- $ticket_id
-
(int|null) (Optional) An optional ticket post ID; if this parameter is passed then the method will return the quantity of specific tickets part of the Order.
Default value: null
Return
(float|int) Either the total quantity of tickets part of the Order or the quantity of a specific ticket part of the Order.
Source
File: src/Tribe/Commerce/PayPal/Order.php
public function get_item_quantity( $ticket_id = null ) {
$items = $this->meta['items'];
if ( null !== $ticket_id ) {
$items = wp_list_filter( $items, array( 'ticket_id' => $ticket_id ) );
}
$quantities = array_filter( wp_list_pluck( $items, 'quantity' ), 'is_numeric' );
return ! empty( $quantities )
? array_sum( array_map( 'intval', $quantities ) )
: 0;
}
Changelog
| Version | Description |
|---|---|
| 4.7 | Introduced. |