Custom Woocommerce report
-
Hi,
I’m trying to create a custom Woocommerce report based on an order field. I added a field on the billing section thanks to
woocommerce_billing_fields
filter.
The field works well, I succeed to display it on order’s page in admin (like this :get_post_meta($order->ID, '_billing_options', true);
).I created a new class extending WC_Admin_Report, overriding
output_report()
andget_main_chart()
. Here’s the faulty code in get_main_chart :$query_data = array( 'ID' => array( 'type' => 'post_data', 'function' => 'COUNT', 'name' => 'total_orders', 'distinct' => true, ), '_billing_options' => array( 'type' => 'meta', 'function' => '', 'name' => 'organization' ), '_order_total' => array( 'type' => 'meta', 'function' => 'SUM', 'name' => 'order_total' ), ); $sales_by_organization_orders = $this->get_order_report_data( array( 'data' => $query_data, 'query_type' => 'get_results', 'group_by' => 'organization', 'filter_range' => true, 'order_types' => wc_get_order_types( 'sales-reports' ), 'order_status' => array( 'completed' ), 'parent_order_status' => false, ) );
It’s not working, I didn’t return any result. However if I use ‘_billing_country’ instead of ‘_billing_options’ it’s works very well.
Maybe I’m missing something. If anyone know how to do this? Thanks!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Custom Woocommerce report’ is closed to new replies.