public function get_sales($form_id = 0, $start_date = false, $end_date = false, $status = 'publish')
{
$this->setup_dates($start_date, $end_date);
// Make sure start date is valid
if (is_wp_error($this->start_date)) {
return $this->start_date;
}
// Make sure end date is valid
if (is_wp_error($this->end_date)) {
return $this->end_date;
}
if (empty($form_id)) {
// Global sale stats
add_filter('give_count_payments_where', array($this, 'count_where'));
if (is_array($status)) {
$count = 0;
foreach ($status as $payment_status) {
$count += give_count_payments()->{$payment_status};
}
} else {
$count = give_count_payments()->{$status};
}
remove_filter('give_count_payments_where', array($this, 'count_where'));
} else {
$this->timestamp = false;
// Product specific stats
global $give_logs;
add_filter('posts_where', array($this, 'payments_where'));
$count = $give_logs->get_log_count($form_id, 'sale');
remove_filter('posts_where', array($this, 'payments_where'));
}
return $count;
}