IsCustomer.php
1.16 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
<?php
namespace ACA\WC\Column\Order;
use AC;
use ACA\WC\Search;
use ACA\WC\Sorting\Order\OrderData;
use ACP;
class IsCustomer extends AC\Column implements ACP\Search\Searchable, ACP\Sorting\Sortable
{
public function __construct()
{
$this->set_type('column-order_is_customer')
->set_label(__('Is Customer', 'codepress-admin-columns'))
->set_group('woocommerce');
}
public function get_value($id)
{
$customer_id = $this->get_customer_id($id);
return $customer_id !== 0
? ac_helper()->icon->yes(get_userdata($customer_id)->display_name)
: ac_helper()->icon->no(__('Guest', 'woocommerce'));
}
public function get_raw_value($id)
{
return $this->get_customer_id($id) !== 0;
}
private function get_customer_id($id)
{
$order = wc_get_order($id);
return $order ? $order->get_customer_id() : 0;
}
public function search()
{
return new Search\Order\IsCustomer();
}
public function sorting()
{
return new OrderData('customer_id', new ACP\Sorting\Type\DataType(ACP\Sorting\Type\DataType::NUMERIC));
}
}