TotalSales.php
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
declare(strict_types=1);
namespace ACA\WC\Column\User;
use AC\Column;
use ACA\WC\ConditionalFormat;
use ACA\WC\Helper\User;
use ACA\WC\Search;
use ACA\WC\Sorting;
use ACP;
use ACP\ConditionalFormat\FormattableConfig;
class TotalSales extends Column implements ACP\Sorting\Sortable, ACP\Export\Exportable, ACP\Search\Searchable,
ACP\ConditionalFormat\Formattable
{
public function __construct()
{
$this->set_type('column-wc-user-total-sales')
->set_label(__('Total Sales', 'codepress-admin-columns'))
->set_group('woocommerce');
}
public function get_value($user_id)
{
$spent = (new User())->get_total_sales($user_id);
return $spent
? wc_price($spent)
: $this->get_empty_char();
}
public function get_raw_value($user_id)
{
return (new User())->get_total_sales($user_id);
}
public function export()
{
return new ACP\Export\Model\StrippedValue($this);
}
public function conditional_format(): ?FormattableConfig
{
return new FormattableConfig(new ConditionalFormat\Formatter\User\TotalSalesFormatter());
}
public function search()
{
return new Search\User\TotalSales();
}
public function sorting()
{
return new Sorting\User\TotalSales();
}
}