IsCustomer.php
1.08 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
declare(strict_types=1);
namespace ACA\WC\Search\Order;
use AC;
use ACA\WC\Search;
use ACP;
use ACP\Search\Operators;
use ACP\Search\Query\Bindings\QueryArguments;
use ACP\Search\Value;
class IsCustomer extends ACP\Search\Comparison implements ACP\Search\Comparison\Values
{
public function __construct()
{
parent::__construct(
new Operators([
Operators::EQ,
])
);
}
protected function create_query_bindings($operator, Value $value)
{
$bindings = new QueryArguments();
$bindings->query_arguments([
'field_query' => [
[
'field' => 'customer_id',
'value' => 0,
'compare' => $value->get_value() === '0' ? '=' : '!=',
],
],
]);
return $bindings;
}
public function get_values()
{
return AC\Helper\Select\Options::create_from_array([
'0' => __('Guest', 'woocommerce'),
'1' => __('Customer', 'woocommerce'),
]);
}
}