Hello
yes, but I have no time to do it for free ??
// add field "orders per company"
add_filter('woe_get_order_fields', function ($fields) {
$fields['company_num_orders'] = array( 'label' => 'Total orders per Company', 'colname' => 'Total orders per Company', 'checked' => 1 );
return $fields;
});
// calculate new field
add_filter('woe_get_order_value_company_num_orders', function ($value,$order, $field) {
global $wpdb;
$company = $order->get_billing_company();
if( $company )
$count = $wpdb->get_var( "SELECT COUNT(*)
FROM $wpdb->posts as posts
LEFT JOIN {$wpdb->postmeta} AS meta ON posts.ID = meta.post_id
WHERE meta.meta_key = '_billing_company'
AND posts.post_type = 'shop_order'
AND posts.post_status IN ( '" . implode( "','", array_map( 'esc_sql', array_keys( wc_get_order_statuses() ) ) ) . "' )
AND meta_value = '" . esc_sql( $company ) . "'
" );
else
$count = 0;
return $count;
}, 10, 3);