|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Order item. |
|
4
|
|
|
* |
|
5
|
|
|
* @author Pronamic <[email protected]> |
|
6
|
|
|
* @copyright 2005-2018 Pronamic |
|
7
|
|
|
* @license GPL-3.0-or-later |
|
8
|
|
|
* @package Pronamic\WordPress\Pay\Gateways\OmniKassa2 |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\OmniKassa2; |
|
12
|
|
|
|
|
13
|
|
|
/** |
|
14
|
|
|
* Order item. |
|
15
|
|
|
* |
|
16
|
|
|
* @author Reüel van der Steege |
|
17
|
|
|
* @version 2.0.3 |
|
18
|
|
|
* @since 2.0.3 |
|
19
|
|
|
*/ |
|
20
|
|
|
class OrderItem { |
|
21
|
|
|
/** |
|
22
|
|
|
* Item id. |
|
23
|
|
|
* |
|
24
|
|
|
* @var string |
|
25
|
|
|
*/ |
|
26
|
|
|
private $id; |
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Item name (required). |
|
30
|
|
|
* |
|
31
|
|
|
* @var string |
|
32
|
|
|
*/ |
|
33
|
|
|
private $name; |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Description. |
|
37
|
|
|
* |
|
38
|
|
|
* @var string |
|
39
|
|
|
*/ |
|
40
|
|
|
private $description; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Quantity (required). |
|
44
|
|
|
* |
|
45
|
|
|
* @var int |
|
46
|
|
|
*/ |
|
47
|
|
|
private $quantity; |
|
48
|
|
|
|
|
49
|
|
|
/** |
|
50
|
|
|
* Amount (required). |
|
51
|
|
|
* |
|
52
|
|
|
* @var Money |
|
53
|
|
|
*/ |
|
54
|
|
|
private $amount; |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Tax. |
|
58
|
|
|
* |
|
59
|
|
|
* @var Money |
|
60
|
|
|
*/ |
|
61
|
|
|
private $tax; |
|
62
|
|
|
|
|
63
|
|
|
/** |
|
64
|
|
|
* Category; physical or digital (required). |
|
65
|
|
|
* |
|
66
|
|
|
* @var string |
|
67
|
|
|
*/ |
|
68
|
|
|
private $category; |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* VAT category. |
|
72
|
|
|
* |
|
73
|
|
|
* @var string |
|
74
|
|
|
*/ |
|
75
|
|
|
private $vat_category; |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Construct order result. |
|
79
|
|
|
* |
|
80
|
|
|
* @param array $item Order item data. |
|
81
|
|
|
* |
|
82
|
|
|
* @return self |
|
83
|
|
|
*/ |
|
84
|
|
|
public function __construct( array $item ) { |
|
85
|
|
|
if ( isset( $item['id'] ) ) { |
|
86
|
|
|
$this->id = $item['id']; |
|
87
|
|
|
} |
|
88
|
|
|
|
|
89
|
|
|
if ( isset( $item['name'] ) ) { |
|
90
|
|
|
$this->name = $item['name']; |
|
91
|
|
|
} |
|
92
|
|
|
|
|
93
|
|
|
if ( isset( $item['description'] ) ) { |
|
94
|
|
|
$this->description = $item['description']; |
|
95
|
|
|
} |
|
96
|
|
|
|
|
97
|
|
|
if ( isset( $item['quantity'] ) ) { |
|
98
|
|
|
$this->quantity = intval( $item['quantity'] ); |
|
99
|
|
|
} |
|
100
|
|
|
|
|
101
|
|
|
if ( isset( $item['amount'] ) ) { |
|
102
|
|
|
$this->amount = $item['amount']; |
|
103
|
|
|
} |
|
104
|
|
|
|
|
105
|
|
|
if ( isset( $item['tax'] ) ) { |
|
106
|
|
|
$this->tax = $item['tax']; |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
if ( isset( $item['category'] ) ) { |
|
110
|
|
|
$this->category = $item['category']; |
|
111
|
|
|
} |
|
112
|
|
|
|
|
113
|
|
|
if ( isset( $item['vat_category'] ) ) { |
|
114
|
|
|
$this->vat_category = intval( $item['vat_category'] ); |
|
115
|
|
|
} |
|
116
|
|
|
} |
|
117
|
|
|
|
|
118
|
|
|
/** |
|
119
|
|
|
* Get item ID. |
|
120
|
|
|
* |
|
121
|
|
|
* @return string |
|
122
|
|
|
*/ |
|
123
|
|
|
public function get_id() { |
|
124
|
|
|
return $this->id; |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
/** |
|
128
|
|
|
* Get item name. |
|
129
|
|
|
* |
|
130
|
|
|
* @return string |
|
131
|
|
|
*/ |
|
132
|
|
|
public function get_name() { |
|
133
|
|
|
return $this->name; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
|
|
/** |
|
137
|
|
|
* Get item description. |
|
138
|
|
|
* |
|
139
|
|
|
* @return int|string |
|
140
|
|
|
*/ |
|
141
|
|
|
public function get_description() { |
|
142
|
|
|
return $this->description; |
|
143
|
|
|
} |
|
144
|
|
|
|
|
145
|
|
|
/** |
|
146
|
|
|
* Get quantity. |
|
147
|
|
|
* |
|
148
|
|
|
* @return int |
|
149
|
|
|
*/ |
|
150
|
|
|
public function get_quantity() { |
|
151
|
|
|
return $this->quantity; |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
/** |
|
155
|
|
|
* Get amount. |
|
156
|
|
|
* |
|
157
|
|
|
* @return Money |
|
158
|
|
|
*/ |
|
159
|
|
|
public function get_amount() { |
|
160
|
|
|
return $this->amount; |
|
161
|
|
|
} |
|
162
|
|
|
|
|
163
|
|
|
/** |
|
164
|
|
|
* Get tax. |
|
165
|
|
|
* |
|
166
|
|
|
* @return Money |
|
167
|
|
|
*/ |
|
168
|
|
|
public function get_tax() { |
|
169
|
|
|
return $this->tax; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
|
|
/** |
|
173
|
|
|
* Get category. |
|
174
|
|
|
* |
|
175
|
|
|
* @return string |
|
176
|
|
|
*/ |
|
177
|
|
|
public function get_category() { |
|
178
|
|
|
return $this->category; |
|
179
|
|
|
} |
|
180
|
|
|
|
|
181
|
|
|
/** |
|
182
|
|
|
* Get VAT category. |
|
183
|
|
|
* |
|
184
|
|
|
* @return int |
|
185
|
|
|
*/ |
|
186
|
|
|
public function get_vat_category() { |
|
187
|
|
|
return $this->vat_category; |
|
|
|
|
|
|
188
|
|
|
} |
|
189
|
|
|
} |
|
190
|
|
|
|