Ticket::get_status_quantity( int|string|WP_Post $ticket_id )
Given a valid ticket will fetch the quantity of orders on each one of the registered status based on the counting that is handled by the Order status transitions system.
Contents
Parameters
- $ticket_id
-
(int|string|WP_Post) (Required) Which ticket we are fetching the count for.
Return
(TECTicketsCommercearray<string,int>|WP_Error)
Source
File: src/Tickets/Commerce/Ticket.php
public function get_status_quantity( $ticket_id ) {
$ticket = get_post( $ticket_id );
if ( ! $ticket ) {
return new \WP_Error( 'tec-tickets-commerce-non-existent-ticket' );
}
$all_statuses = tribe( Status_Handler::class )->get_all();
$status_qty = [];
foreach ( $all_statuses as $status ) {
$value = get_post_meta( $ticket->ID, static::get_status_count_meta_key( $status ), true );
if ( empty( $value ) ) {
$value = 0;
}
$status_qty[ $status->get_slug() ] = (int) $value;
}
return $status_qty;
}
Changelog
| Version | Description |
|---|---|
| 5.2.0 | Introduced. |