Tribe__Tickets_Plus__Commerce__EDD__Stock_Control::get_purchased_inventory( int $ticket_id, array $order_statuses = array() )
Returns the amount of inventory purchased for the specified ticket.
Contents
By default this is calculated only for orders with "valid" order statuses (pending and completed), but the optional param $order_statuses can be used to pass in an alternative list if the calculation should be restricted to pending orders only (for example).
See also
Parameters
- $ticket_id
-
(int) (Required)
- $order_statuses
-
(array) (Optional)
Default value: array()
Return
(int)
Source
File: src/Tribe/Commerce/EDD/Stock_Control.php
public function get_purchased_inventory( $ticket_id, array $order_statuses = [] ) { global $wpdb; if ( empty( $order_statuses ) ) { $order_statuses = $this->get_valid_payment_statuses(); } $order_statuses = $this->escape_fields( $order_statuses ); $sql = " SELECT COUNT( * ) FROM $wpdb->postmeta JOIN $wpdb->posts ON $wpdb->posts.ID = $wpdb->postmeta.post_id WHERE $wpdb->postmeta.meta_key = '_tribe_eddticket_product' AND $wpdb->postmeta.meta_value = %s "; $sql .= empty( $order_statuses ) ? ';' : "AND post_status IN ( $order_statuses );"; return (int) $wpdb->get_var( $wpdb->prepare( $sql, $ticket_id ) ); }