Country.php
1.27 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
61
62
63
64
65
66
67
68
69
<?php
namespace ACA\WC\Settings\User;
use AC;
use AC\View;
/**
* @since 3.1
*/
class Country extends AC\Settings\Column
implements AC\Settings\FormatValue {
/**
* @var string
*/
private $address_type;
public function format( $country_code, $original_value ) {
$countries = WC()->countries->get_countries();
if ( ! isset( $countries[ $country_code ] ) ) {
return false;
}
return $countries[ $country_code ];
}
protected function define_options() {
return [
'address_type' => 'billing',
];
}
protected function get_display_options() {
$options = [
'shipping' => __( 'Shipping', 'codepress-admin-columns' ),
'billing' => __( 'Billing', 'codepress-admin-columns' ),
];
return $options;
}
public function create_view() {
$select = $this->create_element( 'select' )
->set_attribute( 'data-refresh', 'column' )
->set_options( $this->get_display_options() );
return new View( [
'label' => __( 'Display', 'codepress-admin-columns' ),
'setting' => $select,
] );
}
/**
* @return string
*/
public function get_address_type() {
return $this->address_type;
}
/**
* @param string $address_type
*/
public function set_address_type( $address_type ) {
$this->address_type = $address_type;
}
}