/** * Decreases the total earnings of a cross-sell/up-sell download. Primarily for when a purchase is refunded. * * @since 1.1 * @param int $download_id Download ID * @param int $amount Earnings * @return void */ function edd_csau_decrease_earnings($download_id, $amount, $type) { $earnings = edd_csau_get_download_earnings_stats($download_id, $type); if ($earnings > 0) { // Only decrease if greater than zero $earnings = $earnings - $amount; } if (update_post_meta($download_id, '_edd_download_' . $type . '_earnings', $earnings)) { return $earnings; } return false; }
/** * Build all the reports data * * @access public * @since 1.5 * @return array $reports_data All the data for customer reports */ public function reports_data() { $reports_data = array(); $downloads = $this->products->posts; $download_ids = $this->products->query_vars['post__in']; if (!empty($download_ids)) { foreach ($downloads as $download) { global $edd_logs; $reports_data[] = array('ID' => $download, 'title' => get_the_title($download), 'sales' => edd_csau_get_download_sales_stats($download, $this->type), 'earnings' => edd_csau_get_download_earnings_stats($download, $this->type)); } } return $reports_data; }