I have to create another list from the list and I found the WC-Report-Sales-By-Date. However I don’t think it’s the correct page to edit.
Where do I find the page analytics/order to change it?
The main objective is to add a list after those infos with the “attribution” and the sum ($) of each attribution.
I tried to create a filter to change one data
The code from wc-report-sales-by-date:
$this->report_data->total_coupons = number_format(array_sum(wp_list_pluck($this->report_data->coupons, 'discount_amount')), 2, '.', '');
And on Functions.php:
function custom_admin_report_data($report_data)
{
// HERE you make your calculations and changes
// New amout to set (example)
$new_calculated_amount = 100;
//number_format(array_sum(wp_list_pluck($this->report_data->coupons, 'discount_amount')), 2, '.', '');
// Set the new amounts for "total_coupons" key
$report_data->total_coupons = $new_calculated_amount;
// Raw data output just for testing, to get the keys and the structure of the data
// to be removed
echo '<pre>';
print_r($report_data);
echo '</pre>';
// Return the changed data object
return $report_data;
}
add_filter('woocommerce_admin_report_data', 'custom_admin_report_data', 10, 1);
I tried to change the data from class-wc-report-sales-by-date.php by adding a function on functions.php but nothing occurred.
Matheus Padilha is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.