@@ -11,30 +11,30 @@ discard block |
||
11 | 11 | class WPInv_Invoice extends GetPaid_Data { |
12 | 12 | |
13 | 13 | /** |
14 | - * Which data store to load. |
|
15 | - * |
|
16 | - * @var string |
|
17 | - */ |
|
14 | + * Which data store to load. |
|
15 | + * |
|
16 | + * @var string |
|
17 | + */ |
|
18 | 18 | protected $data_store_name = 'invoice'; |
19 | 19 | |
20 | 20 | /** |
21 | - * This is the name of this object type. |
|
22 | - * |
|
23 | - * @var string |
|
24 | - */ |
|
21 | + * This is the name of this object type. |
|
22 | + * |
|
23 | + * @var string |
|
24 | + */ |
|
25 | 25 | protected $object_type = 'invoice'; |
26 | 26 | |
27 | 27 | /** |
28 | - * Item Data array. This is the core item data exposed in APIs. |
|
29 | - * |
|
30 | - * @since 1.0.19 |
|
31 | - * @var array |
|
32 | - */ |
|
33 | - protected $data = array( |
|
34 | - 'parent_id' => 0, |
|
35 | - 'status' => 'wpi-pending', |
|
36 | - 'version' => '', |
|
37 | - 'date_created' => null, |
|
28 | + * Item Data array. This is the core item data exposed in APIs. |
|
29 | + * |
|
30 | + * @since 1.0.19 |
|
31 | + * @var array |
|
32 | + */ |
|
33 | + protected $data = array( |
|
34 | + 'parent_id' => 0, |
|
35 | + 'status' => 'wpi-pending', |
|
36 | + 'version' => '', |
|
37 | + 'date_created' => null, |
|
38 | 38 | 'date_modified' => null, |
39 | 39 | 'due_date' => null, |
40 | 40 | 'completed_date' => null, |
@@ -76,20 +76,20 @@ discard block |
||
76 | 76 | 'transaction_id' => '', |
77 | 77 | 'currency' => '', |
78 | 78 | 'disable_taxes' => false, |
79 | - 'subscription_id' => null, |
|
80 | - 'is_viewed' => false, |
|
81 | - 'email_cc' => '', |
|
82 | - 'template' => 'quantity', // hours, amount only |
|
79 | + 'subscription_id' => null, |
|
80 | + 'is_viewed' => false, |
|
81 | + 'email_cc' => '', |
|
82 | + 'template' => 'quantity', // hours, amount only |
|
83 | 83 | ); |
84 | 84 | |
85 | 85 | /** |
86 | - * Stores meta in cache for future reads. |
|
87 | - * |
|
88 | - * A group must be set to to enable caching. |
|
89 | - * |
|
90 | - * @var string |
|
91 | - */ |
|
92 | - protected $cache_group = 'getpaid_invoices'; |
|
86 | + * Stores meta in cache for future reads. |
|
87 | + * |
|
88 | + * A group must be set to to enable caching. |
|
89 | + * |
|
90 | + * @var string |
|
91 | + */ |
|
92 | + protected $cache_group = 'getpaid_invoices'; |
|
93 | 93 | |
94 | 94 | /** |
95 | 95 | * Stores a reference to the original WP_Post object |
@@ -103,102 +103,102 @@ discard block |
||
103 | 103 | * |
104 | 104 | * @var int |
105 | 105 | */ |
106 | - protected $recurring_item = null; |
|
106 | + protected $recurring_item = null; |
|
107 | 107 | |
108 | - /** |
|
108 | + /** |
|
109 | 109 | * Stores an array of item totals. |
110 | - * |
|
111 | - * e.g $totals['discount'] = array( |
|
112 | - * 'initial' => 10, |
|
113 | - * 'recurring' => 10, |
|
114 | - * ) |
|
110 | + * |
|
111 | + * e.g $totals['discount'] = array( |
|
112 | + * 'initial' => 10, |
|
113 | + * 'recurring' => 10, |
|
114 | + * ) |
|
115 | 115 | * |
116 | 116 | * @var array |
117 | 117 | */ |
118 | - protected $totals = array(); |
|
118 | + protected $totals = array(); |
|
119 | 119 | |
120 | - /** |
|
121 | - * Stores the status transition information. |
|
122 | - * |
|
123 | - * @since 1.0.19 |
|
124 | - * @var bool |
|
125 | - */ |
|
126 | - protected $status_transition = false; |
|
120 | + /** |
|
121 | + * Stores the status transition information. |
|
122 | + * |
|
123 | + * @since 1.0.19 |
|
124 | + * @var bool |
|
125 | + */ |
|
126 | + protected $status_transition = false; |
|
127 | 127 | |
128 | 128 | /** |
129 | - * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
130 | - * |
|
131 | - * @param int/string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, number or object to read. |
|
132 | - */ |
|
129 | + * Get the invoice if ID is passed, otherwise the invoice is new and empty. |
|
130 | + * |
|
131 | + * @param int/string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, number or object to read. |
|
132 | + */ |
|
133 | 133 | public function __construct( $invoice = false ) { |
134 | 134 | |
135 | 135 | parent::__construct( $invoice ); |
136 | 136 | |
137 | - if ( is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
138 | - $this->set_id( $invoice ); |
|
139 | - } elseif ( $invoice instanceof self ) { |
|
140 | - $this->set_id( $invoice->get_id() ); |
|
141 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
142 | - $this->set_id( $invoice->ID ); |
|
143 | - } elseif ( is_array( $invoice ) ) { |
|
144 | - $this->set_props( $invoice ); |
|
145 | - |
|
146 | - if ( isset( $invoice['ID'] ) ) { |
|
147 | - $this->set_id( $invoice['ID'] ); |
|
148 | - } |
|
149 | - |
|
150 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
151 | - $this->set_id( $invoice_id ); |
|
152 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
153 | - $this->set_id( $invoice_id ); |
|
154 | - } else { |
|
155 | - $this->set_object_read( true ); |
|
156 | - } |
|
137 | + if ( is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
138 | + $this->set_id( $invoice ); |
|
139 | + } elseif ( $invoice instanceof self ) { |
|
140 | + $this->set_id( $invoice->get_id() ); |
|
141 | + } elseif ( ! empty( $invoice->ID ) ) { |
|
142 | + $this->set_id( $invoice->ID ); |
|
143 | + } elseif ( is_array( $invoice ) ) { |
|
144 | + $this->set_props( $invoice ); |
|
145 | + |
|
146 | + if ( isset( $invoice['ID'] ) ) { |
|
147 | + $this->set_id( $invoice['ID'] ); |
|
148 | + } |
|
149 | + |
|
150 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
151 | + $this->set_id( $invoice_id ); |
|
152 | + } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
153 | + $this->set_id( $invoice_id ); |
|
154 | + } else { |
|
155 | + $this->set_object_read( true ); |
|
156 | + } |
|
157 | 157 | |
158 | 158 | // Load the datastore. |
159 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
159 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
160 | 160 | |
161 | - if ( $this->get_id() > 0 ) { |
|
161 | + if ( $this->get_id() > 0 ) { |
|
162 | 162 | $this->post = get_post( $this->get_id() ); |
163 | 163 | $this->ID = $this->get_id(); |
164 | - $this->data_store->read( $this ); |
|
164 | + $this->data_store->read( $this ); |
|
165 | 165 | } |
166 | 166 | |
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
170 | - * Given an invoice key/number, it returns its id. |
|
171 | - * |
|
172 | - * |
|
173 | - * @static |
|
174 | - * @param string $value The invoice key or number |
|
175 | - * @param string $field Either key or number. |
|
176 | - * @since 1.0.15 |
|
177 | - * @return int |
|
178 | - */ |
|
179 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
170 | + * Given an invoice key/number, it returns its id. |
|
171 | + * |
|
172 | + * |
|
173 | + * @static |
|
174 | + * @param string $value The invoice key or number |
|
175 | + * @param string $field Either key or number. |
|
176 | + * @since 1.0.15 |
|
177 | + * @return int |
|
178 | + */ |
|
179 | + public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
180 | 180 | global $wpdb; |
181 | 181 | |
182 | - // Trim the value. |
|
183 | - $value = trim( $value ); |
|
182 | + // Trim the value. |
|
183 | + $value = trim( $value ); |
|
184 | 184 | |
185 | - if ( empty( $value ) ) { |
|
186 | - return 0; |
|
187 | - } |
|
185 | + if ( empty( $value ) ) { |
|
186 | + return 0; |
|
187 | + } |
|
188 | 188 | |
189 | 189 | // Valid fields. |
190 | 190 | $fields = array( 'key', 'number' ); |
191 | 191 | |
192 | - // Ensure a field has been passed. |
|
193 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
194 | - return 0; |
|
195 | - } |
|
192 | + // Ensure a field has been passed. |
|
193 | + if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
194 | + return 0; |
|
195 | + } |
|
196 | 196 | |
197 | - // Maybe retrieve from the cache. |
|
198 | - $invoice_id = wp_cache_get( $field, "getpaid_invoice_{$field}s_to_ids" ); |
|
199 | - if ( ! empty( $invoice_id ) ) { |
|
200 | - return $invoice_id; |
|
201 | - } |
|
197 | + // Maybe retrieve from the cache. |
|
198 | + $invoice_id = wp_cache_get( $field, "getpaid_invoice_{$field}s_to_ids" ); |
|
199 | + if ( ! empty( $invoice_id ) ) { |
|
200 | + return $invoice_id; |
|
201 | + } |
|
202 | 202 | |
203 | 203 | // Fetch from the db. |
204 | 204 | $table = $wpdb->prefix . 'getpaid_invoices'; |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
207 | 207 | ); |
208 | 208 | |
209 | - if ( empty( $invoice_id ) ) { |
|
210 | - return 0; |
|
211 | - } |
|
209 | + if ( empty( $invoice_id ) ) { |
|
210 | + return 0; |
|
211 | + } |
|
212 | 212 | |
213 | - // Update the cache with our data |
|
214 | - wp_cache_set( $field, $invoice_id, "getpaid_invoice_{$field}s_to_ids" ); |
|
213 | + // Update the cache with our data |
|
214 | + wp_cache_set( $field, $invoice_id, "getpaid_invoice_{$field}s_to_ids" ); |
|
215 | 215 | |
216 | - return $invoice_id; |
|
216 | + return $invoice_id; |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | /** |
@@ -239,53 +239,53 @@ discard block |
||
239 | 239 | */ |
240 | 240 | |
241 | 241 | /** |
242 | - * Get parent invoice ID. |
|
243 | - * |
|
244 | - * @since 1.0.19 |
|
245 | - * @param string $context View or edit context. |
|
246 | - * @return int |
|
247 | - */ |
|
248 | - public function get_parent_id( $context = 'view' ) { |
|
249 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
242 | + * Get parent invoice ID. |
|
243 | + * |
|
244 | + * @since 1.0.19 |
|
245 | + * @param string $context View or edit context. |
|
246 | + * @return int |
|
247 | + */ |
|
248 | + public function get_parent_id( $context = 'view' ) { |
|
249 | + return (int) $this->get_prop( 'parent_id', $context ); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | /** |
253 | - * Get parent invoice. |
|
254 | - * |
|
255 | - * @since 1.0.19 |
|
256 | - * @return WPInv_Invoice |
|
257 | - */ |
|
253 | + * Get parent invoice. |
|
254 | + * |
|
255 | + * @since 1.0.19 |
|
256 | + * @return WPInv_Invoice |
|
257 | + */ |
|
258 | 258 | public function get_parent_payment() { |
259 | 259 | return new WPInv_Invoice( $this->get_parent_id() ); |
260 | 260 | } |
261 | 261 | |
262 | 262 | /** |
263 | - * Alias for self::get_parent_payment(). |
|
264 | - * |
|
265 | - * @since 1.0.19 |
|
266 | - * @return WPInv_Invoice |
|
267 | - */ |
|
263 | + * Alias for self::get_parent_payment(). |
|
264 | + * |
|
265 | + * @since 1.0.19 |
|
266 | + * @return WPInv_Invoice |
|
267 | + */ |
|
268 | 268 | public function get_parent() { |
269 | 269 | return $this->get_parent_payment(); |
270 | 270 | } |
271 | 271 | |
272 | 272 | /** |
273 | - * Get invoice status. |
|
274 | - * |
|
275 | - * @since 1.0.19 |
|
276 | - * @param string $context View or edit context. |
|
277 | - * @return string |
|
278 | - */ |
|
279 | - public function get_status( $context = 'view' ) { |
|
280 | - return $this->get_prop( 'status', $context ); |
|
273 | + * Get invoice status. |
|
274 | + * |
|
275 | + * @since 1.0.19 |
|
276 | + * @param string $context View or edit context. |
|
277 | + * @return string |
|
278 | + */ |
|
279 | + public function get_status( $context = 'view' ) { |
|
280 | + return $this->get_prop( 'status', $context ); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | /** |
284 | - * Get invoice status nice name. |
|
285 | - * |
|
286 | - * @since 1.0.19 |
|
287 | - * @return string |
|
288 | - */ |
|
284 | + * Get invoice status nice name. |
|
285 | + * |
|
286 | + * @since 1.0.19 |
|
287 | + * @return string |
|
288 | + */ |
|
289 | 289 | public function get_status_nicename() { |
290 | 290 | $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
291 | 291 | |
@@ -299,20 +299,20 @@ discard block |
||
299 | 299 | } |
300 | 300 | |
301 | 301 | /** |
302 | - * Get plugin version when the invoice was created. |
|
303 | - * |
|
304 | - * @since 1.0.19 |
|
305 | - * @param string $context View or edit context. |
|
306 | - * @return string |
|
307 | - */ |
|
308 | - public function get_version( $context = 'view' ) { |
|
309 | - return $this->get_prop( 'version', $context ); |
|
310 | - } |
|
302 | + * Get plugin version when the invoice was created. |
|
303 | + * |
|
304 | + * @since 1.0.19 |
|
305 | + * @param string $context View or edit context. |
|
306 | + * @return string |
|
307 | + */ |
|
308 | + public function get_version( $context = 'view' ) { |
|
309 | + return $this->get_prop( 'version', $context ); |
|
310 | + } |
|
311 | 311 | |
312 | - /** |
|
313 | - * @deprecated |
|
314 | - */ |
|
315 | - public function get_invoice_date( $formatted = true ) { |
|
312 | + /** |
|
313 | + * @deprecated |
|
314 | + */ |
|
315 | + public function get_invoice_date( $formatted = true ) { |
|
316 | 316 | $date_completed = $this->get_date_completed(); |
317 | 317 | $invoice_date = $date_completed != '0000-00-00 00:00:00' ? $date_completed : ''; |
318 | 318 | |
@@ -329,187 +329,187 @@ discard block |
||
329 | 329 | } |
330 | 330 | |
331 | 331 | /** |
332 | - * Get date when the invoice was created. |
|
333 | - * |
|
334 | - * @since 1.0.19 |
|
335 | - * @param string $context View or edit context. |
|
336 | - * @return string |
|
337 | - */ |
|
338 | - public function get_date_created( $context = 'view' ) { |
|
339 | - return $this->get_prop( 'date_created', $context ); |
|
340 | - } |
|
332 | + * Get date when the invoice was created. |
|
333 | + * |
|
334 | + * @since 1.0.19 |
|
335 | + * @param string $context View or edit context. |
|
336 | + * @return string |
|
337 | + */ |
|
338 | + public function get_date_created( $context = 'view' ) { |
|
339 | + return $this->get_prop( 'date_created', $context ); |
|
340 | + } |
|
341 | 341 | |
342 | - /** |
|
343 | - * Alias for self::get_date_created(). |
|
344 | - * |
|
345 | - * @since 1.0.19 |
|
346 | - * @param string $context View or edit context. |
|
347 | - * @return string |
|
348 | - */ |
|
349 | - public function get_created_date( $context = 'view' ) { |
|
350 | - return $this->get_date_created( $context ); |
|
351 | - } |
|
352 | - |
|
353 | - /** |
|
354 | - * Get GMT date when the invoice was created. |
|
355 | - * |
|
356 | - * @since 1.0.19 |
|
357 | - * @param string $context View or edit context. |
|
358 | - * @return string |
|
359 | - */ |
|
360 | - public function get_date_created_gmt( $context = 'view' ) { |
|
342 | + /** |
|
343 | + * Alias for self::get_date_created(). |
|
344 | + * |
|
345 | + * @since 1.0.19 |
|
346 | + * @param string $context View or edit context. |
|
347 | + * @return string |
|
348 | + */ |
|
349 | + public function get_created_date( $context = 'view' ) { |
|
350 | + return $this->get_date_created( $context ); |
|
351 | + } |
|
352 | + |
|
353 | + /** |
|
354 | + * Get GMT date when the invoice was created. |
|
355 | + * |
|
356 | + * @since 1.0.19 |
|
357 | + * @param string $context View or edit context. |
|
358 | + * @return string |
|
359 | + */ |
|
360 | + public function get_date_created_gmt( $context = 'view' ) { |
|
361 | 361 | $date = $this->get_date_created( $context ); |
362 | 362 | |
363 | 363 | if ( $date ) { |
364 | 364 | $date = get_gmt_from_date( $date ); |
365 | 365 | } |
366 | - return $date; |
|
366 | + return $date; |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
370 | - * Get date when the invoice was last modified. |
|
371 | - * |
|
372 | - * @since 1.0.19 |
|
373 | - * @param string $context View or edit context. |
|
374 | - * @return string |
|
375 | - */ |
|
376 | - public function get_date_modified( $context = 'view' ) { |
|
377 | - return $this->get_prop( 'date_modified', $context ); |
|
378 | - } |
|
370 | + * Get date when the invoice was last modified. |
|
371 | + * |
|
372 | + * @since 1.0.19 |
|
373 | + * @param string $context View or edit context. |
|
374 | + * @return string |
|
375 | + */ |
|
376 | + public function get_date_modified( $context = 'view' ) { |
|
377 | + return $this->get_prop( 'date_modified', $context ); |
|
378 | + } |
|
379 | 379 | |
380 | - /** |
|
381 | - * Alias for self::get_date_modified(). |
|
382 | - * |
|
383 | - * @since 1.0.19 |
|
384 | - * @param string $context View or edit context. |
|
385 | - * @return string |
|
386 | - */ |
|
387 | - public function get_modified_date( $context = 'view' ) { |
|
388 | - return $this->get_date_modified( $context ); |
|
380 | + /** |
|
381 | + * Alias for self::get_date_modified(). |
|
382 | + * |
|
383 | + * @since 1.0.19 |
|
384 | + * @param string $context View or edit context. |
|
385 | + * @return string |
|
386 | + */ |
|
387 | + public function get_modified_date( $context = 'view' ) { |
|
388 | + return $this->get_date_modified( $context ); |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
392 | - * Get GMT date when the invoice was last modified. |
|
393 | - * |
|
394 | - * @since 1.0.19 |
|
395 | - * @param string $context View or edit context. |
|
396 | - * @return string |
|
397 | - */ |
|
398 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
392 | + * Get GMT date when the invoice was last modified. |
|
393 | + * |
|
394 | + * @since 1.0.19 |
|
395 | + * @param string $context View or edit context. |
|
396 | + * @return string |
|
397 | + */ |
|
398 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
399 | 399 | $date = $this->get_date_modified( $context ); |
400 | 400 | |
401 | 401 | if ( $date ) { |
402 | 402 | $date = get_gmt_from_date( $date ); |
403 | 403 | } |
404 | - return $date; |
|
404 | + return $date; |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
408 | - * Get the invoice due date. |
|
409 | - * |
|
410 | - * @since 1.0.19 |
|
411 | - * @param string $context View or edit context. |
|
412 | - * @return string |
|
413 | - */ |
|
414 | - public function get_due_date( $context = 'view' ) { |
|
415 | - return $this->get_prop( 'due_date', $context ); |
|
408 | + * Get the invoice due date. |
|
409 | + * |
|
410 | + * @since 1.0.19 |
|
411 | + * @param string $context View or edit context. |
|
412 | + * @return string |
|
413 | + */ |
|
414 | + public function get_due_date( $context = 'view' ) { |
|
415 | + return $this->get_prop( 'due_date', $context ); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
419 | - * Alias for self::get_due_date(). |
|
420 | - * |
|
421 | - * @since 1.0.19 |
|
422 | - * @param string $context View or edit context. |
|
423 | - * @return string |
|
424 | - */ |
|
425 | - public function get_date_due( $context = 'view' ) { |
|
426 | - return $this->get_due_date( $context ); |
|
419 | + * Alias for self::get_due_date(). |
|
420 | + * |
|
421 | + * @since 1.0.19 |
|
422 | + * @param string $context View or edit context. |
|
423 | + * @return string |
|
424 | + */ |
|
425 | + public function get_date_due( $context = 'view' ) { |
|
426 | + return $this->get_due_date( $context ); |
|
427 | 427 | } |
428 | 428 | |
429 | 429 | /** |
430 | - * Get the invoice GMT due date. |
|
431 | - * |
|
432 | - * @since 1.0.19 |
|
433 | - * @param string $context View or edit context. |
|
434 | - * @return string |
|
435 | - */ |
|
436 | - public function get_due_date_gmt( $context = 'view' ) { |
|
430 | + * Get the invoice GMT due date. |
|
431 | + * |
|
432 | + * @since 1.0.19 |
|
433 | + * @param string $context View or edit context. |
|
434 | + * @return string |
|
435 | + */ |
|
436 | + public function get_due_date_gmt( $context = 'view' ) { |
|
437 | 437 | $date = $this->get_due_date( $context ); |
438 | 438 | |
439 | 439 | if ( $date ) { |
440 | 440 | $date = get_gmt_from_date( $date ); |
441 | 441 | } |
442 | - return $date; |
|
442 | + return $date; |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | /** |
446 | - * Alias for self::get_due_date_gmt(). |
|
447 | - * |
|
448 | - * @since 1.0.19 |
|
449 | - * @param string $context View or edit context. |
|
450 | - * @return string |
|
451 | - */ |
|
452 | - public function get_gmt_date_due( $context = 'view' ) { |
|
453 | - return $this->get_due_date_gmt( $context ); |
|
446 | + * Alias for self::get_due_date_gmt(). |
|
447 | + * |
|
448 | + * @since 1.0.19 |
|
449 | + * @param string $context View or edit context. |
|
450 | + * @return string |
|
451 | + */ |
|
452 | + public function get_gmt_date_due( $context = 'view' ) { |
|
453 | + return $this->get_due_date_gmt( $context ); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | /** |
457 | - * Get date when the invoice was completed. |
|
458 | - * |
|
459 | - * @since 1.0.19 |
|
460 | - * @param string $context View or edit context. |
|
461 | - * @return string |
|
462 | - */ |
|
463 | - public function get_completed_date( $context = 'view' ) { |
|
464 | - return $this->get_prop( 'completed_date', $context ); |
|
457 | + * Get date when the invoice was completed. |
|
458 | + * |
|
459 | + * @since 1.0.19 |
|
460 | + * @param string $context View or edit context. |
|
461 | + * @return string |
|
462 | + */ |
|
463 | + public function get_completed_date( $context = 'view' ) { |
|
464 | + return $this->get_prop( 'completed_date', $context ); |
|
465 | 465 | } |
466 | 466 | |
467 | 467 | /** |
468 | - * Alias for self::get_completed_date(). |
|
469 | - * |
|
470 | - * @since 1.0.19 |
|
471 | - * @param string $context View or edit context. |
|
472 | - * @return string |
|
473 | - */ |
|
474 | - public function get_date_completed( $context = 'view' ) { |
|
475 | - return $this->get_completed_date( $context ); |
|
468 | + * Alias for self::get_completed_date(). |
|
469 | + * |
|
470 | + * @since 1.0.19 |
|
471 | + * @param string $context View or edit context. |
|
472 | + * @return string |
|
473 | + */ |
|
474 | + public function get_date_completed( $context = 'view' ) { |
|
475 | + return $this->get_completed_date( $context ); |
|
476 | 476 | } |
477 | 477 | |
478 | 478 | /** |
479 | - * Get GMT date when the invoice was was completed. |
|
480 | - * |
|
481 | - * @since 1.0.19 |
|
482 | - * @param string $context View or edit context. |
|
483 | - * @return string |
|
484 | - */ |
|
485 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
479 | + * Get GMT date when the invoice was was completed. |
|
480 | + * |
|
481 | + * @since 1.0.19 |
|
482 | + * @param string $context View or edit context. |
|
483 | + * @return string |
|
484 | + */ |
|
485 | + public function get_completed_date_gmt( $context = 'view' ) { |
|
486 | 486 | $date = $this->get_completed_date( $context ); |
487 | 487 | |
488 | 488 | if ( $date ) { |
489 | 489 | $date = get_gmt_from_date( $date ); |
490 | 490 | } |
491 | - return $date; |
|
491 | + return $date; |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | /** |
495 | - * Alias for self::get_completed_date_gmt(). |
|
496 | - * |
|
497 | - * @since 1.0.19 |
|
498 | - * @param string $context View or edit context. |
|
499 | - * @return string |
|
500 | - */ |
|
501 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
502 | - return $this->get_completed_date_gmt( $context ); |
|
495 | + * Alias for self::get_completed_date_gmt(). |
|
496 | + * |
|
497 | + * @since 1.0.19 |
|
498 | + * @param string $context View or edit context. |
|
499 | + * @return string |
|
500 | + */ |
|
501 | + public function get_gmt_completed_date( $context = 'view' ) { |
|
502 | + return $this->get_completed_date_gmt( $context ); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | /** |
506 | - * Get the invoice number. |
|
507 | - * |
|
508 | - * @since 1.0.19 |
|
509 | - * @param string $context View or edit context. |
|
510 | - * @return string |
|
511 | - */ |
|
512 | - public function get_number( $context = 'view' ) { |
|
506 | + * Get the invoice number. |
|
507 | + * |
|
508 | + * @since 1.0.19 |
|
509 | + * @param string $context View or edit context. |
|
510 | + * @return string |
|
511 | + */ |
|
512 | + public function get_number( $context = 'view' ) { |
|
513 | 513 | $number = $this->get_prop( 'number', $context ); |
514 | 514 | |
515 | 515 | if ( empty( $number ) ) { |
@@ -517,17 +517,17 @@ discard block |
||
517 | 517 | $this->set_number( $number ); |
518 | 518 | } |
519 | 519 | |
520 | - return $number; |
|
520 | + return $number; |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | /** |
524 | - * Get the invoice key. |
|
525 | - * |
|
526 | - * @since 1.0.19 |
|
527 | - * @param string $context View or edit context. |
|
528 | - * @return string |
|
529 | - */ |
|
530 | - public function get_key( $context = 'view' ) { |
|
524 | + * Get the invoice key. |
|
525 | + * |
|
526 | + * @since 1.0.19 |
|
527 | + * @param string $context View or edit context. |
|
528 | + * @return string |
|
529 | + */ |
|
530 | + public function get_key( $context = 'view' ) { |
|
531 | 531 | $key = $this->get_prop( 'key', $context ); |
532 | 532 | |
533 | 533 | if ( empty( $key ) ) { |
@@ -535,24 +535,24 @@ discard block |
||
535 | 535 | $this->set_key( $key ); |
536 | 536 | } |
537 | 537 | |
538 | - return $key; |
|
538 | + return $key; |
|
539 | 539 | } |
540 | 540 | |
541 | 541 | /** |
542 | - * Get the invoice type. |
|
543 | - * |
|
544 | - * @since 1.0.19 |
|
545 | - * @param string $context View or edit context. |
|
546 | - * @return string |
|
547 | - */ |
|
548 | - public function get_type( $context = 'view' ) { |
|
542 | + * Get the invoice type. |
|
543 | + * |
|
544 | + * @since 1.0.19 |
|
545 | + * @param string $context View or edit context. |
|
546 | + * @return string |
|
547 | + */ |
|
548 | + public function get_type( $context = 'view' ) { |
|
549 | 549 | return $this->get_prop( 'type', $context ); |
550 | - } |
|
550 | + } |
|
551 | 551 | |
552 | - /** |
|
553 | - * @deprecated |
|
554 | - */ |
|
555 | - public function get_invoice_quote_type( $post_id ) { |
|
552 | + /** |
|
553 | + * @deprecated |
|
554 | + */ |
|
555 | + public function get_invoice_quote_type( $post_id ) { |
|
556 | 556 | if ( empty( $post_id ) ) { |
557 | 557 | return ''; |
558 | 558 | } |
@@ -569,35 +569,35 @@ discard block |
||
569 | 569 | } |
570 | 570 | |
571 | 571 | /** |
572 | - * Get the invoice post type. |
|
573 | - * |
|
574 | - * @since 1.0.19 |
|
575 | - * @param string $context View or edit context. |
|
576 | - * @return string |
|
577 | - */ |
|
578 | - public function get_post_type( $context = 'view' ) { |
|
572 | + * Get the invoice post type. |
|
573 | + * |
|
574 | + * @since 1.0.19 |
|
575 | + * @param string $context View or edit context. |
|
576 | + * @return string |
|
577 | + */ |
|
578 | + public function get_post_type( $context = 'view' ) { |
|
579 | 579 | return $this->get_prop( 'post_type', $context ); |
580 | 580 | } |
581 | 581 | |
582 | 582 | /** |
583 | - * Get the invoice mode. |
|
584 | - * |
|
585 | - * @since 1.0.19 |
|
586 | - * @param string $context View or edit context. |
|
587 | - * @return string |
|
588 | - */ |
|
589 | - public function get_mode( $context = 'view' ) { |
|
583 | + * Get the invoice mode. |
|
584 | + * |
|
585 | + * @since 1.0.19 |
|
586 | + * @param string $context View or edit context. |
|
587 | + * @return string |
|
588 | + */ |
|
589 | + public function get_mode( $context = 'view' ) { |
|
590 | 590 | return $this->get_prop( 'mode', $context ); |
591 | 591 | } |
592 | 592 | |
593 | 593 | /** |
594 | - * Get the invoice path. |
|
595 | - * |
|
596 | - * @since 1.0.19 |
|
597 | - * @param string $context View or edit context. |
|
598 | - * @return string |
|
599 | - */ |
|
600 | - public function get_path( $context = 'view' ) { |
|
594 | + * Get the invoice path. |
|
595 | + * |
|
596 | + * @since 1.0.19 |
|
597 | + * @param string $context View or edit context. |
|
598 | + * @return string |
|
599 | + */ |
|
600 | + public function get_path( $context = 'view' ) { |
|
601 | 601 | $path = $this->get_prop( 'path', $context ); |
602 | 602 | |
603 | 603 | if ( empty( $path ) ) { |
@@ -605,73 +605,73 @@ discard block |
||
605 | 605 | $path = sanitize_title( $prefix . $this->get_id() ); |
606 | 606 | } |
607 | 607 | |
608 | - return $path; |
|
608 | + return $path; |
|
609 | 609 | } |
610 | 610 | |
611 | 611 | /** |
612 | - * Get the invoice name/title. |
|
613 | - * |
|
614 | - * @since 1.0.19 |
|
615 | - * @param string $context View or edit context. |
|
616 | - * @return string |
|
617 | - */ |
|
618 | - public function get_name( $context = 'view' ) { |
|
612 | + * Get the invoice name/title. |
|
613 | + * |
|
614 | + * @since 1.0.19 |
|
615 | + * @param string $context View or edit context. |
|
616 | + * @return string |
|
617 | + */ |
|
618 | + public function get_name( $context = 'view' ) { |
|
619 | 619 | $name = $this->get_prop( 'title', $context ); |
620 | 620 | |
621 | - return empty( $name ) ? $this->get_number( $context ) : $name; |
|
621 | + return empty( $name ) ? $this->get_number( $context ) : $name; |
|
622 | 622 | } |
623 | 623 | |
624 | 624 | /** |
625 | - * Alias of self::get_name(). |
|
626 | - * |
|
627 | - * @since 1.0.19 |
|
628 | - * @param string $context View or edit context. |
|
629 | - * @return string |
|
630 | - */ |
|
631 | - public function get_title( $context = 'view' ) { |
|
632 | - return $this->get_name( $context ); |
|
625 | + * Alias of self::get_name(). |
|
626 | + * |
|
627 | + * @since 1.0.19 |
|
628 | + * @param string $context View or edit context. |
|
629 | + * @return string |
|
630 | + */ |
|
631 | + public function get_title( $context = 'view' ) { |
|
632 | + return $this->get_name( $context ); |
|
633 | 633 | } |
634 | 634 | |
635 | 635 | /** |
636 | - * Get the invoice description. |
|
637 | - * |
|
638 | - * @since 1.0.19 |
|
639 | - * @param string $context View or edit context. |
|
640 | - * @return string |
|
641 | - */ |
|
642 | - public function get_description( $context = 'view' ) { |
|
643 | - return $this->get_prop( 'description', $context ); |
|
636 | + * Get the invoice description. |
|
637 | + * |
|
638 | + * @since 1.0.19 |
|
639 | + * @param string $context View or edit context. |
|
640 | + * @return string |
|
641 | + */ |
|
642 | + public function get_description( $context = 'view' ) { |
|
643 | + return $this->get_prop( 'description', $context ); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | /** |
647 | - * Alias of self::get_description(). |
|
648 | - * |
|
649 | - * @since 1.0.19 |
|
650 | - * @param string $context View or edit context. |
|
651 | - * @return string |
|
652 | - */ |
|
653 | - public function get_excerpt( $context = 'view' ) { |
|
654 | - return $this->get_description( $context ); |
|
647 | + * Alias of self::get_description(). |
|
648 | + * |
|
649 | + * @since 1.0.19 |
|
650 | + * @param string $context View or edit context. |
|
651 | + * @return string |
|
652 | + */ |
|
653 | + public function get_excerpt( $context = 'view' ) { |
|
654 | + return $this->get_description( $context ); |
|
655 | 655 | } |
656 | 656 | |
657 | 657 | /** |
658 | - * Alias of self::get_description(). |
|
659 | - * |
|
660 | - * @since 1.0.19 |
|
661 | - * @param string $context View or edit context. |
|
662 | - * @return string |
|
663 | - */ |
|
664 | - public function get_summary( $context = 'view' ) { |
|
665 | - return $this->get_description( $context ); |
|
658 | + * Alias of self::get_description(). |
|
659 | + * |
|
660 | + * @since 1.0.19 |
|
661 | + * @param string $context View or edit context. |
|
662 | + * @return string |
|
663 | + */ |
|
664 | + public function get_summary( $context = 'view' ) { |
|
665 | + return $this->get_description( $context ); |
|
666 | 666 | } |
667 | 667 | |
668 | 668 | /** |
669 | - * Returns the user info. |
|
670 | - * |
|
671 | - * @since 1.0.19 |
|
669 | + * Returns the user info. |
|
670 | + * |
|
671 | + * @since 1.0.19 |
|
672 | 672 | * @param string $context View or edit context. |
673 | - * @return array |
|
674 | - */ |
|
673 | + * @return array |
|
674 | + */ |
|
675 | 675 | public function get_user_info( $context = 'view' ) { |
676 | 676 | |
677 | 677 | $user_info = array( |
@@ -688,605 +688,605 @@ discard block |
||
688 | 688 | 'company' => $this->get_company( $context ), |
689 | 689 | 'vat_number' => $this->get_vat_number( $context ), |
690 | 690 | 'discount' => $this->get_discount_code( $context ), |
691 | - ); |
|
691 | + ); |
|
692 | 692 | |
693 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
693 | + return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
694 | 694 | |
695 | 695 | } |
696 | 696 | |
697 | 697 | /** |
698 | - * Get the customer id. |
|
699 | - * |
|
700 | - * @since 1.0.19 |
|
701 | - * @param string $context View or edit context. |
|
702 | - * @return int |
|
703 | - */ |
|
704 | - public function get_author( $context = 'view' ) { |
|
705 | - return (int) $this->get_prop( 'author', $context ); |
|
698 | + * Get the customer id. |
|
699 | + * |
|
700 | + * @since 1.0.19 |
|
701 | + * @param string $context View or edit context. |
|
702 | + * @return int |
|
703 | + */ |
|
704 | + public function get_author( $context = 'view' ) { |
|
705 | + return (int) $this->get_prop( 'author', $context ); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | /** |
709 | - * Alias of self::get_author(). |
|
710 | - * |
|
711 | - * @since 1.0.19 |
|
712 | - * @param string $context View or edit context. |
|
713 | - * @return int |
|
714 | - */ |
|
715 | - public function get_user_id( $context = 'view' ) { |
|
716 | - return $this->get_author( $context ); |
|
709 | + * Alias of self::get_author(). |
|
710 | + * |
|
711 | + * @since 1.0.19 |
|
712 | + * @param string $context View or edit context. |
|
713 | + * @return int |
|
714 | + */ |
|
715 | + public function get_user_id( $context = 'view' ) { |
|
716 | + return $this->get_author( $context ); |
|
717 | 717 | } |
718 | 718 | |
719 | - /** |
|
720 | - * Alias of self::get_author(). |
|
721 | - * |
|
722 | - * @since 1.0.19 |
|
723 | - * @param string $context View or edit context. |
|
724 | - * @return int |
|
725 | - */ |
|
726 | - public function get_customer_id( $context = 'view' ) { |
|
727 | - return $this->get_author( $context ); |
|
719 | + /** |
|
720 | + * Alias of self::get_author(). |
|
721 | + * |
|
722 | + * @since 1.0.19 |
|
723 | + * @param string $context View or edit context. |
|
724 | + * @return int |
|
725 | + */ |
|
726 | + public function get_customer_id( $context = 'view' ) { |
|
727 | + return $this->get_author( $context ); |
|
728 | 728 | } |
729 | 729 | |
730 | 730 | /** |
731 | - * Get the customer's ip. |
|
732 | - * |
|
733 | - * @since 1.0.19 |
|
734 | - * @param string $context View or edit context. |
|
735 | - * @return string |
|
736 | - */ |
|
737 | - public function get_ip( $context = 'view' ) { |
|
738 | - return $this->get_prop( 'user_ip', $context ); |
|
731 | + * Get the customer's ip. |
|
732 | + * |
|
733 | + * @since 1.0.19 |
|
734 | + * @param string $context View or edit context. |
|
735 | + * @return string |
|
736 | + */ |
|
737 | + public function get_ip( $context = 'view' ) { |
|
738 | + return $this->get_prop( 'user_ip', $context ); |
|
739 | 739 | } |
740 | 740 | |
741 | 741 | /** |
742 | - * Alias of self::get_ip(). |
|
743 | - * |
|
744 | - * @since 1.0.19 |
|
745 | - * @param string $context View or edit context. |
|
746 | - * @return string |
|
747 | - */ |
|
748 | - public function get_user_ip( $context = 'view' ) { |
|
749 | - return $this->get_ip( $context ); |
|
742 | + * Alias of self::get_ip(). |
|
743 | + * |
|
744 | + * @since 1.0.19 |
|
745 | + * @param string $context View or edit context. |
|
746 | + * @return string |
|
747 | + */ |
|
748 | + public function get_user_ip( $context = 'view' ) { |
|
749 | + return $this->get_ip( $context ); |
|
750 | 750 | } |
751 | 751 | |
752 | - /** |
|
753 | - * Alias of self::get_ip(). |
|
754 | - * |
|
755 | - * @since 1.0.19 |
|
756 | - * @param string $context View or edit context. |
|
757 | - * @return string |
|
758 | - */ |
|
759 | - public function get_customer_ip( $context = 'view' ) { |
|
760 | - return $this->get_ip( $context ); |
|
752 | + /** |
|
753 | + * Alias of self::get_ip(). |
|
754 | + * |
|
755 | + * @since 1.0.19 |
|
756 | + * @param string $context View or edit context. |
|
757 | + * @return string |
|
758 | + */ |
|
759 | + public function get_customer_ip( $context = 'view' ) { |
|
760 | + return $this->get_ip( $context ); |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | /** |
764 | - * Get the customer's first name. |
|
765 | - * |
|
766 | - * @since 1.0.19 |
|
767 | - * @param string $context View or edit context. |
|
768 | - * @return string |
|
769 | - */ |
|
770 | - public function get_first_name( $context = 'view' ) { |
|
771 | - return $this->get_prop( 'first_name', $context ); |
|
764 | + * Get the customer's first name. |
|
765 | + * |
|
766 | + * @since 1.0.19 |
|
767 | + * @param string $context View or edit context. |
|
768 | + * @return string |
|
769 | + */ |
|
770 | + public function get_first_name( $context = 'view' ) { |
|
771 | + return $this->get_prop( 'first_name', $context ); |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | /** |
775 | - * Alias of self::get_first_name(). |
|
776 | - * |
|
777 | - * @since 1.0.19 |
|
778 | - * @param string $context View or edit context. |
|
779 | - * @return int |
|
780 | - */ |
|
781 | - public function get_user_first_name( $context = 'view' ) { |
|
782 | - return $this->get_first_name( $context ); |
|
775 | + * Alias of self::get_first_name(). |
|
776 | + * |
|
777 | + * @since 1.0.19 |
|
778 | + * @param string $context View or edit context. |
|
779 | + * @return int |
|
780 | + */ |
|
781 | + public function get_user_first_name( $context = 'view' ) { |
|
782 | + return $this->get_first_name( $context ); |
|
783 | 783 | } |
784 | 784 | |
785 | - /** |
|
786 | - * Alias of self::get_first_name(). |
|
787 | - * |
|
788 | - * @since 1.0.19 |
|
789 | - * @param string $context View or edit context. |
|
790 | - * @return int |
|
791 | - */ |
|
792 | - public function get_customer_first_name( $context = 'view' ) { |
|
793 | - return $this->get_first_name( $context ); |
|
785 | + /** |
|
786 | + * Alias of self::get_first_name(). |
|
787 | + * |
|
788 | + * @since 1.0.19 |
|
789 | + * @param string $context View or edit context. |
|
790 | + * @return int |
|
791 | + */ |
|
792 | + public function get_customer_first_name( $context = 'view' ) { |
|
793 | + return $this->get_first_name( $context ); |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | /** |
797 | - * Get the customer's last name. |
|
798 | - * |
|
799 | - * @since 1.0.19 |
|
800 | - * @param string $context View or edit context. |
|
801 | - * @return string |
|
802 | - */ |
|
803 | - public function get_last_name( $context = 'view' ) { |
|
804 | - return $this->get_prop( 'last_name', $context ); |
|
797 | + * Get the customer's last name. |
|
798 | + * |
|
799 | + * @since 1.0.19 |
|
800 | + * @param string $context View or edit context. |
|
801 | + * @return string |
|
802 | + */ |
|
803 | + public function get_last_name( $context = 'view' ) { |
|
804 | + return $this->get_prop( 'last_name', $context ); |
|
805 | 805 | } |
806 | 806 | |
807 | 807 | /** |
808 | - * Alias of self::get_last_name(). |
|
809 | - * |
|
810 | - * @since 1.0.19 |
|
811 | - * @param string $context View or edit context. |
|
812 | - * @return int |
|
813 | - */ |
|
814 | - public function get_user_last_name( $context = 'view' ) { |
|
815 | - return $this->get_last_name( $context ); |
|
808 | + * Alias of self::get_last_name(). |
|
809 | + * |
|
810 | + * @since 1.0.19 |
|
811 | + * @param string $context View or edit context. |
|
812 | + * @return int |
|
813 | + */ |
|
814 | + public function get_user_last_name( $context = 'view' ) { |
|
815 | + return $this->get_last_name( $context ); |
|
816 | 816 | } |
817 | 817 | |
818 | 818 | /** |
819 | - * Alias of self::get_last_name(). |
|
820 | - * |
|
821 | - * @since 1.0.19 |
|
822 | - * @param string $context View or edit context. |
|
823 | - * @return int |
|
824 | - */ |
|
825 | - public function get_customer_last_name( $context = 'view' ) { |
|
826 | - return $this->get_last_name( $context ); |
|
819 | + * Alias of self::get_last_name(). |
|
820 | + * |
|
821 | + * @since 1.0.19 |
|
822 | + * @param string $context View or edit context. |
|
823 | + * @return int |
|
824 | + */ |
|
825 | + public function get_customer_last_name( $context = 'view' ) { |
|
826 | + return $this->get_last_name( $context ); |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | /** |
830 | - * Get the customer's full name. |
|
831 | - * |
|
832 | - * @since 1.0.19 |
|
833 | - * @param string $context View or edit context. |
|
834 | - * @return string |
|
835 | - */ |
|
836 | - public function get_full_name( $context = 'view' ) { |
|
837 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
830 | + * Get the customer's full name. |
|
831 | + * |
|
832 | + * @since 1.0.19 |
|
833 | + * @param string $context View or edit context. |
|
834 | + * @return string |
|
835 | + */ |
|
836 | + public function get_full_name( $context = 'view' ) { |
|
837 | + return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
838 | 838 | } |
839 | 839 | |
840 | 840 | /** |
841 | - * Alias of self::get_full_name(). |
|
842 | - * |
|
843 | - * @since 1.0.19 |
|
844 | - * @param string $context View or edit context. |
|
845 | - * @return int |
|
846 | - */ |
|
847 | - public function get_user_full_name( $context = 'view' ) { |
|
848 | - return $this->get_full_name( $context ); |
|
841 | + * Alias of self::get_full_name(). |
|
842 | + * |
|
843 | + * @since 1.0.19 |
|
844 | + * @param string $context View or edit context. |
|
845 | + * @return int |
|
846 | + */ |
|
847 | + public function get_user_full_name( $context = 'view' ) { |
|
848 | + return $this->get_full_name( $context ); |
|
849 | 849 | } |
850 | 850 | |
851 | 851 | /** |
852 | - * Alias of self::get_full_name(). |
|
853 | - * |
|
854 | - * @since 1.0.19 |
|
855 | - * @param string $context View or edit context. |
|
856 | - * @return int |
|
857 | - */ |
|
858 | - public function get_customer_full_name( $context = 'view' ) { |
|
859 | - return $this->get_full_name( $context ); |
|
852 | + * Alias of self::get_full_name(). |
|
853 | + * |
|
854 | + * @since 1.0.19 |
|
855 | + * @param string $context View or edit context. |
|
856 | + * @return int |
|
857 | + */ |
|
858 | + public function get_customer_full_name( $context = 'view' ) { |
|
859 | + return $this->get_full_name( $context ); |
|
860 | 860 | } |
861 | 861 | |
862 | 862 | /** |
863 | - * Get the customer's phone number. |
|
864 | - * |
|
865 | - * @since 1.0.19 |
|
866 | - * @param string $context View or edit context. |
|
867 | - * @return string |
|
868 | - */ |
|
869 | - public function get_phone( $context = 'view' ) { |
|
870 | - return $this->get_prop( 'phone', $context ); |
|
863 | + * Get the customer's phone number. |
|
864 | + * |
|
865 | + * @since 1.0.19 |
|
866 | + * @param string $context View or edit context. |
|
867 | + * @return string |
|
868 | + */ |
|
869 | + public function get_phone( $context = 'view' ) { |
|
870 | + return $this->get_prop( 'phone', $context ); |
|
871 | 871 | } |
872 | 872 | |
873 | 873 | /** |
874 | - * Alias of self::get_phone(). |
|
875 | - * |
|
876 | - * @since 1.0.19 |
|
877 | - * @param string $context View or edit context. |
|
878 | - * @return int |
|
879 | - */ |
|
880 | - public function get_phone_number( $context = 'view' ) { |
|
881 | - return $this->get_phone( $context ); |
|
874 | + * Alias of self::get_phone(). |
|
875 | + * |
|
876 | + * @since 1.0.19 |
|
877 | + * @param string $context View or edit context. |
|
878 | + * @return int |
|
879 | + */ |
|
880 | + public function get_phone_number( $context = 'view' ) { |
|
881 | + return $this->get_phone( $context ); |
|
882 | 882 | } |
883 | 883 | |
884 | 884 | /** |
885 | - * Alias of self::get_phone(). |
|
886 | - * |
|
887 | - * @since 1.0.19 |
|
888 | - * @param string $context View or edit context. |
|
889 | - * @return int |
|
890 | - */ |
|
891 | - public function get_user_phone( $context = 'view' ) { |
|
892 | - return $this->get_phone( $context ); |
|
885 | + * Alias of self::get_phone(). |
|
886 | + * |
|
887 | + * @since 1.0.19 |
|
888 | + * @param string $context View or edit context. |
|
889 | + * @return int |
|
890 | + */ |
|
891 | + public function get_user_phone( $context = 'view' ) { |
|
892 | + return $this->get_phone( $context ); |
|
893 | 893 | } |
894 | 894 | |
895 | 895 | /** |
896 | - * Alias of self::get_phone(). |
|
897 | - * |
|
898 | - * @since 1.0.19 |
|
899 | - * @param string $context View or edit context. |
|
900 | - * @return int |
|
901 | - */ |
|
902 | - public function get_customer_phone( $context = 'view' ) { |
|
903 | - return $this->get_phone( $context ); |
|
896 | + * Alias of self::get_phone(). |
|
897 | + * |
|
898 | + * @since 1.0.19 |
|
899 | + * @param string $context View or edit context. |
|
900 | + * @return int |
|
901 | + */ |
|
902 | + public function get_customer_phone( $context = 'view' ) { |
|
903 | + return $this->get_phone( $context ); |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | /** |
907 | - * Get the customer's email address. |
|
908 | - * |
|
909 | - * @since 1.0.19 |
|
910 | - * @param string $context View or edit context. |
|
911 | - * @return string |
|
912 | - */ |
|
913 | - public function get_email( $context = 'view' ) { |
|
914 | - return $this->get_prop( 'email', $context ); |
|
907 | + * Get the customer's email address. |
|
908 | + * |
|
909 | + * @since 1.0.19 |
|
910 | + * @param string $context View or edit context. |
|
911 | + * @return string |
|
912 | + */ |
|
913 | + public function get_email( $context = 'view' ) { |
|
914 | + return $this->get_prop( 'email', $context ); |
|
915 | 915 | } |
916 | 916 | |
917 | 917 | /** |
918 | - * Alias of self::get_email(). |
|
919 | - * |
|
920 | - * @since 1.0.19 |
|
921 | - * @param string $context View or edit context. |
|
922 | - * @return string |
|
923 | - */ |
|
924 | - public function get_email_address( $context = 'view' ) { |
|
925 | - return $this->get_email( $context ); |
|
918 | + * Alias of self::get_email(). |
|
919 | + * |
|
920 | + * @since 1.0.19 |
|
921 | + * @param string $context View or edit context. |
|
922 | + * @return string |
|
923 | + */ |
|
924 | + public function get_email_address( $context = 'view' ) { |
|
925 | + return $this->get_email( $context ); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | /** |
929 | - * Alias of self::get_email(). |
|
930 | - * |
|
931 | - * @since 1.0.19 |
|
932 | - * @param string $context View or edit context. |
|
933 | - * @return int |
|
934 | - */ |
|
935 | - public function get_user_email( $context = 'view' ) { |
|
936 | - return $this->get_email( $context ); |
|
929 | + * Alias of self::get_email(). |
|
930 | + * |
|
931 | + * @since 1.0.19 |
|
932 | + * @param string $context View or edit context. |
|
933 | + * @return int |
|
934 | + */ |
|
935 | + public function get_user_email( $context = 'view' ) { |
|
936 | + return $this->get_email( $context ); |
|
937 | 937 | } |
938 | 938 | |
939 | 939 | /** |
940 | - * Alias of self::get_email(). |
|
941 | - * |
|
942 | - * @since 1.0.19 |
|
943 | - * @param string $context View or edit context. |
|
944 | - * @return int |
|
945 | - */ |
|
946 | - public function get_customer_email( $context = 'view' ) { |
|
947 | - return $this->get_email( $context ); |
|
940 | + * Alias of self::get_email(). |
|
941 | + * |
|
942 | + * @since 1.0.19 |
|
943 | + * @param string $context View or edit context. |
|
944 | + * @return int |
|
945 | + */ |
|
946 | + public function get_customer_email( $context = 'view' ) { |
|
947 | + return $this->get_email( $context ); |
|
948 | 948 | } |
949 | 949 | |
950 | 950 | /** |
951 | - * Get the customer's country. |
|
952 | - * |
|
953 | - * @since 1.0.19 |
|
954 | - * @param string $context View or edit context. |
|
955 | - * @return string |
|
956 | - */ |
|
957 | - public function get_country( $context = 'view' ) { |
|
958 | - $country = $this->get_prop( 'country', $context ); |
|
959 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
951 | + * Get the customer's country. |
|
952 | + * |
|
953 | + * @since 1.0.19 |
|
954 | + * @param string $context View or edit context. |
|
955 | + * @return string |
|
956 | + */ |
|
957 | + public function get_country( $context = 'view' ) { |
|
958 | + $country = $this->get_prop( 'country', $context ); |
|
959 | + return empty( $country ) ? wpinv_get_default_country() : $country; |
|
960 | 960 | } |
961 | 961 | |
962 | 962 | /** |
963 | - * Alias of self::get_country(). |
|
964 | - * |
|
965 | - * @since 1.0.19 |
|
966 | - * @param string $context View or edit context. |
|
967 | - * @return int |
|
968 | - */ |
|
969 | - public function get_user_country( $context = 'view' ) { |
|
970 | - return $this->get_country( $context ); |
|
963 | + * Alias of self::get_country(). |
|
964 | + * |
|
965 | + * @since 1.0.19 |
|
966 | + * @param string $context View or edit context. |
|
967 | + * @return int |
|
968 | + */ |
|
969 | + public function get_user_country( $context = 'view' ) { |
|
970 | + return $this->get_country( $context ); |
|
971 | 971 | } |
972 | 972 | |
973 | 973 | /** |
974 | - * Alias of self::get_country(). |
|
975 | - * |
|
976 | - * @since 1.0.19 |
|
977 | - * @param string $context View or edit context. |
|
978 | - * @return int |
|
979 | - */ |
|
980 | - public function get_customer_country( $context = 'view' ) { |
|
981 | - return $this->get_country( $context ); |
|
974 | + * Alias of self::get_country(). |
|
975 | + * |
|
976 | + * @since 1.0.19 |
|
977 | + * @param string $context View or edit context. |
|
978 | + * @return int |
|
979 | + */ |
|
980 | + public function get_customer_country( $context = 'view' ) { |
|
981 | + return $this->get_country( $context ); |
|
982 | 982 | } |
983 | 983 | |
984 | 984 | /** |
985 | - * Get the customer's state. |
|
986 | - * |
|
987 | - * @since 1.0.19 |
|
988 | - * @param string $context View or edit context. |
|
989 | - * @return string |
|
990 | - */ |
|
991 | - public function get_state( $context = 'view' ) { |
|
992 | - $state = $this->get_prop( 'state', $context ); |
|
993 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
985 | + * Get the customer's state. |
|
986 | + * |
|
987 | + * @since 1.0.19 |
|
988 | + * @param string $context View or edit context. |
|
989 | + * @return string |
|
990 | + */ |
|
991 | + public function get_state( $context = 'view' ) { |
|
992 | + $state = $this->get_prop( 'state', $context ); |
|
993 | + return empty( $state ) ? wpinv_get_default_state() : $state; |
|
994 | 994 | } |
995 | 995 | |
996 | 996 | /** |
997 | - * Alias of self::get_state(). |
|
998 | - * |
|
999 | - * @since 1.0.19 |
|
1000 | - * @param string $context View or edit context. |
|
1001 | - * @return int |
|
1002 | - */ |
|
1003 | - public function get_user_state( $context = 'view' ) { |
|
1004 | - return $this->get_state( $context ); |
|
997 | + * Alias of self::get_state(). |
|
998 | + * |
|
999 | + * @since 1.0.19 |
|
1000 | + * @param string $context View or edit context. |
|
1001 | + * @return int |
|
1002 | + */ |
|
1003 | + public function get_user_state( $context = 'view' ) { |
|
1004 | + return $this->get_state( $context ); |
|
1005 | 1005 | } |
1006 | 1006 | |
1007 | 1007 | /** |
1008 | - * Alias of self::get_state(). |
|
1009 | - * |
|
1010 | - * @since 1.0.19 |
|
1011 | - * @param string $context View or edit context. |
|
1012 | - * @return int |
|
1013 | - */ |
|
1014 | - public function get_customer_state( $context = 'view' ) { |
|
1015 | - return $this->get_state( $context ); |
|
1008 | + * Alias of self::get_state(). |
|
1009 | + * |
|
1010 | + * @since 1.0.19 |
|
1011 | + * @param string $context View or edit context. |
|
1012 | + * @return int |
|
1013 | + */ |
|
1014 | + public function get_customer_state( $context = 'view' ) { |
|
1015 | + return $this->get_state( $context ); |
|
1016 | 1016 | } |
1017 | 1017 | |
1018 | 1018 | /** |
1019 | - * Get the customer's city. |
|
1020 | - * |
|
1021 | - * @since 1.0.19 |
|
1022 | - * @param string $context View or edit context. |
|
1023 | - * @return string |
|
1024 | - */ |
|
1025 | - public function get_city( $context = 'view' ) { |
|
1026 | - return $this->get_prop( 'city', $context ); |
|
1019 | + * Get the customer's city. |
|
1020 | + * |
|
1021 | + * @since 1.0.19 |
|
1022 | + * @param string $context View or edit context. |
|
1023 | + * @return string |
|
1024 | + */ |
|
1025 | + public function get_city( $context = 'view' ) { |
|
1026 | + return $this->get_prop( 'city', $context ); |
|
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | /** |
1030 | - * Alias of self::get_city(). |
|
1031 | - * |
|
1032 | - * @since 1.0.19 |
|
1033 | - * @param string $context View or edit context. |
|
1034 | - * @return string |
|
1035 | - */ |
|
1036 | - public function get_user_city( $context = 'view' ) { |
|
1037 | - return $this->get_city( $context ); |
|
1030 | + * Alias of self::get_city(). |
|
1031 | + * |
|
1032 | + * @since 1.0.19 |
|
1033 | + * @param string $context View or edit context. |
|
1034 | + * @return string |
|
1035 | + */ |
|
1036 | + public function get_user_city( $context = 'view' ) { |
|
1037 | + return $this->get_city( $context ); |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | /** |
1041 | - * Alias of self::get_city(). |
|
1042 | - * |
|
1043 | - * @since 1.0.19 |
|
1044 | - * @param string $context View or edit context. |
|
1045 | - * @return string |
|
1046 | - */ |
|
1047 | - public function get_customer_city( $context = 'view' ) { |
|
1048 | - return $this->get_city( $context ); |
|
1041 | + * Alias of self::get_city(). |
|
1042 | + * |
|
1043 | + * @since 1.0.19 |
|
1044 | + * @param string $context View or edit context. |
|
1045 | + * @return string |
|
1046 | + */ |
|
1047 | + public function get_customer_city( $context = 'view' ) { |
|
1048 | + return $this->get_city( $context ); |
|
1049 | 1049 | } |
1050 | 1050 | |
1051 | 1051 | /** |
1052 | - * Get the customer's zip. |
|
1053 | - * |
|
1054 | - * @since 1.0.19 |
|
1055 | - * @param string $context View or edit context. |
|
1056 | - * @return string |
|
1057 | - */ |
|
1058 | - public function get_zip( $context = 'view' ) { |
|
1059 | - return $this->get_prop( 'zip', $context ); |
|
1052 | + * Get the customer's zip. |
|
1053 | + * |
|
1054 | + * @since 1.0.19 |
|
1055 | + * @param string $context View or edit context. |
|
1056 | + * @return string |
|
1057 | + */ |
|
1058 | + public function get_zip( $context = 'view' ) { |
|
1059 | + return $this->get_prop( 'zip', $context ); |
|
1060 | 1060 | } |
1061 | 1061 | |
1062 | 1062 | /** |
1063 | - * Alias of self::get_zip(). |
|
1064 | - * |
|
1065 | - * @since 1.0.19 |
|
1066 | - * @param string $context View or edit context. |
|
1067 | - * @return string |
|
1068 | - */ |
|
1069 | - public function get_user_zip( $context = 'view' ) { |
|
1070 | - return $this->get_zip( $context ); |
|
1063 | + * Alias of self::get_zip(). |
|
1064 | + * |
|
1065 | + * @since 1.0.19 |
|
1066 | + * @param string $context View or edit context. |
|
1067 | + * @return string |
|
1068 | + */ |
|
1069 | + public function get_user_zip( $context = 'view' ) { |
|
1070 | + return $this->get_zip( $context ); |
|
1071 | 1071 | } |
1072 | 1072 | |
1073 | 1073 | /** |
1074 | - * Alias of self::get_zip(). |
|
1075 | - * |
|
1076 | - * @since 1.0.19 |
|
1077 | - * @param string $context View or edit context. |
|
1078 | - * @return string |
|
1079 | - */ |
|
1080 | - public function get_customer_zip( $context = 'view' ) { |
|
1081 | - return $this->get_zip( $context ); |
|
1074 | + * Alias of self::get_zip(). |
|
1075 | + * |
|
1076 | + * @since 1.0.19 |
|
1077 | + * @param string $context View or edit context. |
|
1078 | + * @return string |
|
1079 | + */ |
|
1080 | + public function get_customer_zip( $context = 'view' ) { |
|
1081 | + return $this->get_zip( $context ); |
|
1082 | 1082 | } |
1083 | 1083 | |
1084 | 1084 | /** |
1085 | - * Get the customer's company. |
|
1086 | - * |
|
1087 | - * @since 1.0.19 |
|
1088 | - * @param string $context View or edit context. |
|
1089 | - * @return string |
|
1090 | - */ |
|
1091 | - public function get_company( $context = 'view' ) { |
|
1092 | - return $this->get_prop( 'company', $context ); |
|
1085 | + * Get the customer's company. |
|
1086 | + * |
|
1087 | + * @since 1.0.19 |
|
1088 | + * @param string $context View or edit context. |
|
1089 | + * @return string |
|
1090 | + */ |
|
1091 | + public function get_company( $context = 'view' ) { |
|
1092 | + return $this->get_prop( 'company', $context ); |
|
1093 | 1093 | } |
1094 | 1094 | |
1095 | 1095 | /** |
1096 | - * Alias of self::get_company(). |
|
1097 | - * |
|
1098 | - * @since 1.0.19 |
|
1099 | - * @param string $context View or edit context. |
|
1100 | - * @return string |
|
1101 | - */ |
|
1102 | - public function get_user_company( $context = 'view' ) { |
|
1103 | - return $this->get_company( $context ); |
|
1096 | + * Alias of self::get_company(). |
|
1097 | + * |
|
1098 | + * @since 1.0.19 |
|
1099 | + * @param string $context View or edit context. |
|
1100 | + * @return string |
|
1101 | + */ |
|
1102 | + public function get_user_company( $context = 'view' ) { |
|
1103 | + return $this->get_company( $context ); |
|
1104 | 1104 | } |
1105 | 1105 | |
1106 | 1106 | /** |
1107 | - * Alias of self::get_company(). |
|
1108 | - * |
|
1109 | - * @since 1.0.19 |
|
1110 | - * @param string $context View or edit context. |
|
1111 | - * @return string |
|
1112 | - */ |
|
1113 | - public function get_customer_company( $context = 'view' ) { |
|
1114 | - return $this->get_company( $context ); |
|
1107 | + * Alias of self::get_company(). |
|
1108 | + * |
|
1109 | + * @since 1.0.19 |
|
1110 | + * @param string $context View or edit context. |
|
1111 | + * @return string |
|
1112 | + */ |
|
1113 | + public function get_customer_company( $context = 'view' ) { |
|
1114 | + return $this->get_company( $context ); |
|
1115 | 1115 | } |
1116 | 1116 | |
1117 | 1117 | /** |
1118 | - * Get the customer's vat number. |
|
1119 | - * |
|
1120 | - * @since 1.0.19 |
|
1121 | - * @param string $context View or edit context. |
|
1122 | - * @return string |
|
1123 | - */ |
|
1124 | - public function get_vat_number( $context = 'view' ) { |
|
1125 | - return $this->get_prop( 'vat_number', $context ); |
|
1118 | + * Get the customer's vat number. |
|
1119 | + * |
|
1120 | + * @since 1.0.19 |
|
1121 | + * @param string $context View or edit context. |
|
1122 | + * @return string |
|
1123 | + */ |
|
1124 | + public function get_vat_number( $context = 'view' ) { |
|
1125 | + return $this->get_prop( 'vat_number', $context ); |
|
1126 | 1126 | } |
1127 | 1127 | |
1128 | 1128 | /** |
1129 | - * Alias of self::get_vat_number(). |
|
1130 | - * |
|
1131 | - * @since 1.0.19 |
|
1132 | - * @param string $context View or edit context. |
|
1133 | - * @return string |
|
1134 | - */ |
|
1135 | - public function get_user_vat_number( $context = 'view' ) { |
|
1136 | - return $this->get_vat_number( $context ); |
|
1129 | + * Alias of self::get_vat_number(). |
|
1130 | + * |
|
1131 | + * @since 1.0.19 |
|
1132 | + * @param string $context View or edit context. |
|
1133 | + * @return string |
|
1134 | + */ |
|
1135 | + public function get_user_vat_number( $context = 'view' ) { |
|
1136 | + return $this->get_vat_number( $context ); |
|
1137 | 1137 | } |
1138 | 1138 | |
1139 | 1139 | /** |
1140 | - * Alias of self::get_vat_number(). |
|
1141 | - * |
|
1142 | - * @since 1.0.19 |
|
1143 | - * @param string $context View or edit context. |
|
1144 | - * @return string |
|
1145 | - */ |
|
1146 | - public function get_customer_vat_number( $context = 'view' ) { |
|
1147 | - return $this->get_vat_number( $context ); |
|
1140 | + * Alias of self::get_vat_number(). |
|
1141 | + * |
|
1142 | + * @since 1.0.19 |
|
1143 | + * @param string $context View or edit context. |
|
1144 | + * @return string |
|
1145 | + */ |
|
1146 | + public function get_customer_vat_number( $context = 'view' ) { |
|
1147 | + return $this->get_vat_number( $context ); |
|
1148 | 1148 | } |
1149 | 1149 | |
1150 | 1150 | /** |
1151 | - * Get the customer's vat rate. |
|
1152 | - * |
|
1153 | - * @since 1.0.19 |
|
1154 | - * @param string $context View or edit context. |
|
1155 | - * @return string |
|
1156 | - */ |
|
1157 | - public function get_vat_rate( $context = 'view' ) { |
|
1158 | - return $this->get_prop( 'vat_rate', $context ); |
|
1151 | + * Get the customer's vat rate. |
|
1152 | + * |
|
1153 | + * @since 1.0.19 |
|
1154 | + * @param string $context View or edit context. |
|
1155 | + * @return string |
|
1156 | + */ |
|
1157 | + public function get_vat_rate( $context = 'view' ) { |
|
1158 | + return $this->get_prop( 'vat_rate', $context ); |
|
1159 | 1159 | } |
1160 | 1160 | |
1161 | 1161 | /** |
1162 | - * Alias of self::get_vat_rate(). |
|
1163 | - * |
|
1164 | - * @since 1.0.19 |
|
1165 | - * @param string $context View or edit context. |
|
1166 | - * @return string |
|
1167 | - */ |
|
1168 | - public function get_user_vat_rate( $context = 'view' ) { |
|
1169 | - return $this->get_vat_rate( $context ); |
|
1170 | - } |
|
1171 | - |
|
1162 | + * Alias of self::get_vat_rate(). |
|
1163 | + * |
|
1164 | + * @since 1.0.19 |
|
1165 | + * @param string $context View or edit context. |
|
1166 | + * @return string |
|
1167 | + */ |
|
1168 | + public function get_user_vat_rate( $context = 'view' ) { |
|
1169 | + return $this->get_vat_rate( $context ); |
|
1170 | + } |
|
1171 | + |
|
1172 | + /** |
|
1173 | + * Alias of self::get_vat_rate(). |
|
1174 | + * |
|
1175 | + * @since 1.0.19 |
|
1176 | + * @param string $context View or edit context. |
|
1177 | + * @return string |
|
1178 | + */ |
|
1179 | + public function get_customer_vat_rate( $context = 'view' ) { |
|
1180 | + return $this->get_vat_rate( $context ); |
|
1181 | + } |
|
1182 | + |
|
1183 | + /** |
|
1184 | + * Get the customer's address. |
|
1185 | + * |
|
1186 | + * @since 1.0.19 |
|
1187 | + * @param string $context View or edit context. |
|
1188 | + * @return string |
|
1189 | + */ |
|
1190 | + public function get_address( $context = 'view' ) { |
|
1191 | + return $this->get_prop( 'address', $context ); |
|
1192 | + } |
|
1193 | + |
|
1172 | 1194 | /** |
1173 | - * Alias of self::get_vat_rate(). |
|
1174 | - * |
|
1175 | - * @since 1.0.19 |
|
1176 | - * @param string $context View or edit context. |
|
1177 | - * @return string |
|
1178 | - */ |
|
1179 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
1180 | - return $this->get_vat_rate( $context ); |
|
1195 | + * Alias of self::get_address(). |
|
1196 | + * |
|
1197 | + * @since 1.0.19 |
|
1198 | + * @param string $context View or edit context. |
|
1199 | + * @return string |
|
1200 | + */ |
|
1201 | + public function get_user_address( $context = 'view' ) { |
|
1202 | + return $this->get_address( $context ); |
|
1203 | + } |
|
1204 | + |
|
1205 | + /** |
|
1206 | + * Alias of self::get_address(). |
|
1207 | + * |
|
1208 | + * @since 1.0.19 |
|
1209 | + * @param string $context View or edit context. |
|
1210 | + * @return string |
|
1211 | + */ |
|
1212 | + public function get_customer_address( $context = 'view' ) { |
|
1213 | + return $this->get_address( $context ); |
|
1181 | 1214 | } |
1182 | 1215 | |
1183 | 1216 | /** |
1184 | - * Get the customer's address. |
|
1185 | - * |
|
1186 | - * @since 1.0.19 |
|
1187 | - * @param string $context View or edit context. |
|
1188 | - * @return string |
|
1189 | - */ |
|
1190 | - public function get_address( $context = 'view' ) { |
|
1191 | - return $this->get_prop( 'address', $context ); |
|
1192 | - } |
|
1193 | - |
|
1194 | - /** |
|
1195 | - * Alias of self::get_address(). |
|
1196 | - * |
|
1197 | - * @since 1.0.19 |
|
1198 | - * @param string $context View or edit context. |
|
1199 | - * @return string |
|
1200 | - */ |
|
1201 | - public function get_user_address( $context = 'view' ) { |
|
1202 | - return $this->get_address( $context ); |
|
1203 | - } |
|
1204 | - |
|
1205 | - /** |
|
1206 | - * Alias of self::get_address(). |
|
1207 | - * |
|
1208 | - * @since 1.0.19 |
|
1209 | - * @param string $context View or edit context. |
|
1210 | - * @return string |
|
1211 | - */ |
|
1212 | - public function get_customer_address( $context = 'view' ) { |
|
1213 | - return $this->get_address( $context ); |
|
1214 | - } |
|
1215 | - |
|
1216 | - /** |
|
1217 | - * Get whether the customer has viewed the invoice or not. |
|
1218 | - * |
|
1219 | - * @since 1.0.19 |
|
1220 | - * @param string $context View or edit context. |
|
1221 | - * @return bool |
|
1222 | - */ |
|
1223 | - public function get_is_viewed( $context = 'view' ) { |
|
1224 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
1225 | - } |
|
1226 | - |
|
1227 | - /** |
|
1228 | - * Get other recipients for invoice communications. |
|
1229 | - * |
|
1230 | - * @since 1.0.19 |
|
1231 | - * @param string $context View or edit context. |
|
1232 | - * @return bool |
|
1233 | - */ |
|
1234 | - public function get_email_cc( $context = 'view' ) { |
|
1235 | - return $this->get_prop( 'email_cc', $context ); |
|
1236 | - } |
|
1237 | - |
|
1238 | - /** |
|
1239 | - * Get invoice template. |
|
1240 | - * |
|
1241 | - * @since 1.0.19 |
|
1242 | - * @param string $context View or edit context. |
|
1243 | - * @return bool |
|
1244 | - */ |
|
1245 | - public function get_template( $context = 'view' ) { |
|
1246 | - return $this->get_prop( 'template', $context ); |
|
1247 | - } |
|
1248 | - |
|
1249 | - /** |
|
1250 | - * Get whether the customer has confirmed their address. |
|
1251 | - * |
|
1252 | - * @since 1.0.19 |
|
1253 | - * @param string $context View or edit context. |
|
1254 | - * @return bool |
|
1255 | - */ |
|
1256 | - public function get_address_confirmed( $context = 'view' ) { |
|
1257 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
1258 | - } |
|
1259 | - |
|
1260 | - /** |
|
1261 | - * Alias of self::get_address_confirmed(). |
|
1262 | - * |
|
1263 | - * @since 1.0.19 |
|
1264 | - * @param string $context View or edit context. |
|
1265 | - * @return bool |
|
1266 | - */ |
|
1267 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
1268 | - return $this->get_address_confirmed( $context ); |
|
1269 | - } |
|
1270 | - |
|
1271 | - /** |
|
1272 | - * Alias of self::get_address(). |
|
1273 | - * |
|
1274 | - * @since 1.0.19 |
|
1275 | - * @param string $context View or edit context. |
|
1276 | - * @return bool |
|
1277 | - */ |
|
1278 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
1279 | - return $this->get_address_confirmed( $context ); |
|
1280 | - } |
|
1281 | - |
|
1282 | - /** |
|
1283 | - * Get the invoice subtotal. |
|
1284 | - * |
|
1285 | - * @since 1.0.19 |
|
1286 | - * @param string $context View or edit context. |
|
1287 | - * @return float |
|
1288 | - */ |
|
1289 | - public function get_subtotal( $context = 'view' ) { |
|
1217 | + * Get whether the customer has viewed the invoice or not. |
|
1218 | + * |
|
1219 | + * @since 1.0.19 |
|
1220 | + * @param string $context View or edit context. |
|
1221 | + * @return bool |
|
1222 | + */ |
|
1223 | + public function get_is_viewed( $context = 'view' ) { |
|
1224 | + return (bool) $this->get_prop( 'is_viewed', $context ); |
|
1225 | + } |
|
1226 | + |
|
1227 | + /** |
|
1228 | + * Get other recipients for invoice communications. |
|
1229 | + * |
|
1230 | + * @since 1.0.19 |
|
1231 | + * @param string $context View or edit context. |
|
1232 | + * @return bool |
|
1233 | + */ |
|
1234 | + public function get_email_cc( $context = 'view' ) { |
|
1235 | + return $this->get_prop( 'email_cc', $context ); |
|
1236 | + } |
|
1237 | + |
|
1238 | + /** |
|
1239 | + * Get invoice template. |
|
1240 | + * |
|
1241 | + * @since 1.0.19 |
|
1242 | + * @param string $context View or edit context. |
|
1243 | + * @return bool |
|
1244 | + */ |
|
1245 | + public function get_template( $context = 'view' ) { |
|
1246 | + return $this->get_prop( 'template', $context ); |
|
1247 | + } |
|
1248 | + |
|
1249 | + /** |
|
1250 | + * Get whether the customer has confirmed their address. |
|
1251 | + * |
|
1252 | + * @since 1.0.19 |
|
1253 | + * @param string $context View or edit context. |
|
1254 | + * @return bool |
|
1255 | + */ |
|
1256 | + public function get_address_confirmed( $context = 'view' ) { |
|
1257 | + return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
1258 | + } |
|
1259 | + |
|
1260 | + /** |
|
1261 | + * Alias of self::get_address_confirmed(). |
|
1262 | + * |
|
1263 | + * @since 1.0.19 |
|
1264 | + * @param string $context View or edit context. |
|
1265 | + * @return bool |
|
1266 | + */ |
|
1267 | + public function get_user_address_confirmed( $context = 'view' ) { |
|
1268 | + return $this->get_address_confirmed( $context ); |
|
1269 | + } |
|
1270 | + |
|
1271 | + /** |
|
1272 | + * Alias of self::get_address(). |
|
1273 | + * |
|
1274 | + * @since 1.0.19 |
|
1275 | + * @param string $context View or edit context. |
|
1276 | + * @return bool |
|
1277 | + */ |
|
1278 | + public function get_customer_address_confirmed( $context = 'view' ) { |
|
1279 | + return $this->get_address_confirmed( $context ); |
|
1280 | + } |
|
1281 | + |
|
1282 | + /** |
|
1283 | + * Get the invoice subtotal. |
|
1284 | + * |
|
1285 | + * @since 1.0.19 |
|
1286 | + * @param string $context View or edit context. |
|
1287 | + * @return float |
|
1288 | + */ |
|
1289 | + public function get_subtotal( $context = 'view' ) { |
|
1290 | 1290 | $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
1291 | 1291 | |
1292 | 1292 | // Backwards compatibility. |
@@ -1298,155 +1298,155 @@ discard block |
||
1298 | 1298 | } |
1299 | 1299 | |
1300 | 1300 | /** |
1301 | - * Get the invoice discount total. |
|
1302 | - * |
|
1303 | - * @since 1.0.19 |
|
1304 | - * @param string $context View or edit context. |
|
1305 | - * @return float |
|
1306 | - */ |
|
1307 | - public function get_total_discount( $context = 'view' ) { |
|
1308 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
1301 | + * Get the invoice discount total. |
|
1302 | + * |
|
1303 | + * @since 1.0.19 |
|
1304 | + * @param string $context View or edit context. |
|
1305 | + * @return float |
|
1306 | + */ |
|
1307 | + public function get_total_discount( $context = 'view' ) { |
|
1308 | + return (float) $this->get_prop( 'total_discount', $context ); |
|
1309 | 1309 | } |
1310 | 1310 | |
1311 | 1311 | /** |
1312 | - * Get the invoice tax total. |
|
1313 | - * |
|
1314 | - * @since 1.0.19 |
|
1315 | - * @param string $context View or edit context. |
|
1316 | - * @return float |
|
1317 | - */ |
|
1318 | - public function get_total_tax( $context = 'view' ) { |
|
1319 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
1320 | - } |
|
1312 | + * Get the invoice tax total. |
|
1313 | + * |
|
1314 | + * @since 1.0.19 |
|
1315 | + * @param string $context View or edit context. |
|
1316 | + * @return float |
|
1317 | + */ |
|
1318 | + public function get_total_tax( $context = 'view' ) { |
|
1319 | + return (float) $this->get_prop( 'total_tax', $context ); |
|
1320 | + } |
|
1321 | 1321 | |
1322 | - /** |
|
1323 | - * @deprecated |
|
1324 | - */ |
|
1325 | - public function get_final_tax( $currency = false ) { |
|
1326 | - $tax = $this->get_total_tax(); |
|
1322 | + /** |
|
1323 | + * @deprecated |
|
1324 | + */ |
|
1325 | + public function get_final_tax( $currency = false ) { |
|
1326 | + $tax = $this->get_total_tax(); |
|
1327 | 1327 | |
1328 | 1328 | if ( $currency ) { |
1329 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
1329 | + return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
1330 | 1330 | } |
1331 | 1331 | |
1332 | 1332 | return $tax; |
1333 | 1333 | } |
1334 | 1334 | |
1335 | 1335 | /** |
1336 | - * Get the invoice fees total. |
|
1337 | - * |
|
1338 | - * @since 1.0.19 |
|
1339 | - * @param string $context View or edit context. |
|
1340 | - * @return float |
|
1341 | - */ |
|
1342 | - public function get_total_fees( $context = 'view' ) { |
|
1343 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
1336 | + * Get the invoice fees total. |
|
1337 | + * |
|
1338 | + * @since 1.0.19 |
|
1339 | + * @param string $context View or edit context. |
|
1340 | + * @return float |
|
1341 | + */ |
|
1342 | + public function get_total_fees( $context = 'view' ) { |
|
1343 | + return (float) $this->get_prop( 'total_fees', $context ); |
|
1344 | 1344 | } |
1345 | 1345 | |
1346 | 1346 | /** |
1347 | - * Alias for self::get_total_fees(). |
|
1348 | - * |
|
1349 | - * @since 1.0.19 |
|
1350 | - * @param string $context View or edit context. |
|
1351 | - * @return float |
|
1352 | - */ |
|
1353 | - public function get_fees_total( $context = 'view' ) { |
|
1354 | - return $this->get_total_fees( $context ); |
|
1347 | + * Alias for self::get_total_fees(). |
|
1348 | + * |
|
1349 | + * @since 1.0.19 |
|
1350 | + * @param string $context View or edit context. |
|
1351 | + * @return float |
|
1352 | + */ |
|
1353 | + public function get_fees_total( $context = 'view' ) { |
|
1354 | + return $this->get_total_fees( $context ); |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | /** |
1358 | - * Get the invoice total. |
|
1359 | - * |
|
1360 | - * @since 1.0.19 |
|
1358 | + * Get the invoice total. |
|
1359 | + * |
|
1360 | + * @since 1.0.19 |
|
1361 | 1361 | * @return float |
1362 | - */ |
|
1363 | - public function get_total() { |
|
1364 | - $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
|
1365 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
1362 | + */ |
|
1363 | + public function get_total() { |
|
1364 | + $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
|
1365 | + return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
1366 | 1366 | } |
1367 | 1367 | |
1368 | 1368 | /** |
1369 | - * Get the initial invoice total. |
|
1370 | - * |
|
1371 | - * @since 1.0.19 |
|
1369 | + * Get the initial invoice total. |
|
1370 | + * |
|
1371 | + * @since 1.0.19 |
|
1372 | 1372 | * @param string $context View or edit context. |
1373 | 1373 | * @return float |
1374 | - */ |
|
1374 | + */ |
|
1375 | 1375 | public function get_initial_total() { |
1376 | 1376 | |
1377 | - if ( empty( $this->totals ) ) { |
|
1378 | - $this->recalculate_total(); |
|
1379 | - } |
|
1377 | + if ( empty( $this->totals ) ) { |
|
1378 | + $this->recalculate_total(); |
|
1379 | + } |
|
1380 | 1380 | |
1381 | - $tax = $this->totals['tax']['initial']; |
|
1382 | - $fee = $this->totals['fee']['initial']; |
|
1383 | - $discount = $this->totals['discount']['initial']; |
|
1384 | - $subtotal = $this->totals['subtotal']['initial']; |
|
1385 | - $total = $tax + $fee - $discount + $subtotal; |
|
1381 | + $tax = $this->totals['tax']['initial']; |
|
1382 | + $fee = $this->totals['fee']['initial']; |
|
1383 | + $discount = $this->totals['discount']['initial']; |
|
1384 | + $subtotal = $this->totals['subtotal']['initial']; |
|
1385 | + $total = $tax + $fee - $discount + $subtotal; |
|
1386 | 1386 | |
1387 | - if ( 0 > $total ) { |
|
1388 | - $total = 0; |
|
1389 | - } |
|
1387 | + if ( 0 > $total ) { |
|
1388 | + $total = 0; |
|
1389 | + } |
|
1390 | 1390 | |
1391 | 1391 | return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
1392 | - } |
|
1392 | + } |
|
1393 | 1393 | |
1394 | - /** |
|
1395 | - * Get the recurring invoice total. |
|
1396 | - * |
|
1397 | - * @since 1.0.19 |
|
1394 | + /** |
|
1395 | + * Get the recurring invoice total. |
|
1396 | + * |
|
1397 | + * @since 1.0.19 |
|
1398 | 1398 | * @param string $context View or edit context. |
1399 | 1399 | * @return float |
1400 | - */ |
|
1400 | + */ |
|
1401 | 1401 | public function get_recurring_total() { |
1402 | 1402 | |
1403 | - if ( empty( $this->totals ) ) { |
|
1404 | - $this->recalculate_total(); |
|
1405 | - } |
|
1403 | + if ( empty( $this->totals ) ) { |
|
1404 | + $this->recalculate_total(); |
|
1405 | + } |
|
1406 | 1406 | |
1407 | - $tax = $this->totals['tax']['recurring']; |
|
1408 | - $fee = $this->totals['fee']['recurring']; |
|
1409 | - $discount = $this->totals['discount']['recurring']; |
|
1410 | - $subtotal = $this->totals['subtotal']['recurring']; |
|
1411 | - $total = $tax + $fee - $discount + $subtotal; |
|
1407 | + $tax = $this->totals['tax']['recurring']; |
|
1408 | + $fee = $this->totals['fee']['recurring']; |
|
1409 | + $discount = $this->totals['discount']['recurring']; |
|
1410 | + $subtotal = $this->totals['subtotal']['recurring']; |
|
1411 | + $total = $tax + $fee - $discount + $subtotal; |
|
1412 | 1412 | |
1413 | - if ( 0 > $total ) { |
|
1414 | - $total = 0; |
|
1415 | - } |
|
1413 | + if ( 0 > $total ) { |
|
1414 | + $total = 0; |
|
1415 | + } |
|
1416 | 1416 | |
1417 | 1417 | return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
1418 | - } |
|
1418 | + } |
|
1419 | 1419 | |
1420 | - /** |
|
1421 | - * Returns recurring payment details. |
|
1422 | - * |
|
1423 | - * @since 1.0.19 |
|
1420 | + /** |
|
1421 | + * Returns recurring payment details. |
|
1422 | + * |
|
1423 | + * @since 1.0.19 |
|
1424 | 1424 | * @param string $field Optionally provide a field to return. |
1425 | - * @param string $currency Whether to include the currency. |
|
1425 | + * @param string $currency Whether to include the currency. |
|
1426 | 1426 | * @return float |
1427 | - */ |
|
1427 | + */ |
|
1428 | 1428 | public function get_recurring_details( $field = '', $currency = false ) { |
1429 | 1429 | |
1430 | - // Maybe recalculate totals. |
|
1431 | - if ( empty( $this->totals ) ) { |
|
1432 | - $this->recalculate_total(); |
|
1433 | - } |
|
1430 | + // Maybe recalculate totals. |
|
1431 | + if ( empty( $this->totals ) ) { |
|
1432 | + $this->recalculate_total(); |
|
1433 | + } |
|
1434 | 1434 | |
1435 | - // Prepare recurring totals. |
|
1435 | + // Prepare recurring totals. |
|
1436 | 1436 | $data = apply_filters( |
1437 | - 'wpinv_get_invoice_recurring_details', |
|
1438 | - array( |
|
1439 | - 'cart_details' => $this->get_cart_details(), |
|
1440 | - 'subtotal' => $this->totals['subtotal']['recurring'], |
|
1441 | - 'discount' => $this->totals['discount']['recurring'], |
|
1442 | - 'tax' => $this->totals['tax']['recurring'], |
|
1443 | - 'fee' => $this->totals['fee']['recurring'], |
|
1444 | - 'total' => $this->get_recurring_total(), |
|
1445 | - ), |
|
1446 | - $this, |
|
1447 | - $field, |
|
1448 | - $currency |
|
1449 | - ); |
|
1437 | + 'wpinv_get_invoice_recurring_details', |
|
1438 | + array( |
|
1439 | + 'cart_details' => $this->get_cart_details(), |
|
1440 | + 'subtotal' => $this->totals['subtotal']['recurring'], |
|
1441 | + 'discount' => $this->totals['discount']['recurring'], |
|
1442 | + 'tax' => $this->totals['tax']['recurring'], |
|
1443 | + 'fee' => $this->totals['fee']['recurring'], |
|
1444 | + 'total' => $this->get_recurring_total(), |
|
1445 | + ), |
|
1446 | + $this, |
|
1447 | + $field, |
|
1448 | + $currency |
|
1449 | + ); |
|
1450 | 1450 | |
1451 | 1451 | if ( isset( $data[$field] ) ) { |
1452 | 1452 | return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
@@ -1456,145 +1456,145 @@ discard block |
||
1456 | 1456 | } |
1457 | 1457 | |
1458 | 1458 | /** |
1459 | - * Get the invoice fees. |
|
1460 | - * |
|
1461 | - * @since 1.0.19 |
|
1462 | - * @param string $context View or edit context. |
|
1463 | - * @return array |
|
1464 | - */ |
|
1465 | - public function get_fees( $context = 'view' ) { |
|
1466 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
1459 | + * Get the invoice fees. |
|
1460 | + * |
|
1461 | + * @since 1.0.19 |
|
1462 | + * @param string $context View or edit context. |
|
1463 | + * @return array |
|
1464 | + */ |
|
1465 | + public function get_fees( $context = 'view' ) { |
|
1466 | + return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
1467 | 1467 | } |
1468 | 1468 | |
1469 | 1469 | /** |
1470 | - * Get the invoice discounts. |
|
1471 | - * |
|
1472 | - * @since 1.0.19 |
|
1473 | - * @param string $context View or edit context. |
|
1474 | - * @return array |
|
1475 | - */ |
|
1476 | - public function get_discounts( $context = 'view' ) { |
|
1477 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
1470 | + * Get the invoice discounts. |
|
1471 | + * |
|
1472 | + * @since 1.0.19 |
|
1473 | + * @param string $context View or edit context. |
|
1474 | + * @return array |
|
1475 | + */ |
|
1476 | + public function get_discounts( $context = 'view' ) { |
|
1477 | + return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
1478 | 1478 | } |
1479 | 1479 | |
1480 | 1480 | /** |
1481 | - * Get the invoice taxes. |
|
1482 | - * |
|
1483 | - * @since 1.0.19 |
|
1484 | - * @param string $context View or edit context. |
|
1485 | - * @return array |
|
1486 | - */ |
|
1487 | - public function get_taxes( $context = 'view' ) { |
|
1488 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
1481 | + * Get the invoice taxes. |
|
1482 | + * |
|
1483 | + * @since 1.0.19 |
|
1484 | + * @param string $context View or edit context. |
|
1485 | + * @return array |
|
1486 | + */ |
|
1487 | + public function get_taxes( $context = 'view' ) { |
|
1488 | + return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
1489 | 1489 | } |
1490 | 1490 | |
1491 | 1491 | /** |
1492 | - * Get the invoice items. |
|
1493 | - * |
|
1494 | - * @since 1.0.19 |
|
1495 | - * @param string $context View or edit context. |
|
1496 | - * @return GetPaid_Form_Item[] |
|
1497 | - */ |
|
1498 | - public function get_items( $context = 'view' ) { |
|
1492 | + * Get the invoice items. |
|
1493 | + * |
|
1494 | + * @since 1.0.19 |
|
1495 | + * @param string $context View or edit context. |
|
1496 | + * @return GetPaid_Form_Item[] |
|
1497 | + */ |
|
1498 | + public function get_items( $context = 'view' ) { |
|
1499 | 1499 | return $this->get_prop( 'items', $context ); |
1500 | 1500 | } |
1501 | 1501 | |
1502 | 1502 | /** |
1503 | - * Get the invoice's payment form. |
|
1504 | - * |
|
1505 | - * @since 1.0.19 |
|
1506 | - * @param string $context View or edit context. |
|
1507 | - * @return int |
|
1508 | - */ |
|
1509 | - public function get_payment_form( $context = 'view' ) { |
|
1510 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
1503 | + * Get the invoice's payment form. |
|
1504 | + * |
|
1505 | + * @since 1.0.19 |
|
1506 | + * @param string $context View or edit context. |
|
1507 | + * @return int |
|
1508 | + */ |
|
1509 | + public function get_payment_form( $context = 'view' ) { |
|
1510 | + return intval( $this->get_prop( 'payment_form', $context ) ); |
|
1511 | 1511 | } |
1512 | 1512 | |
1513 | 1513 | /** |
1514 | - * Get the invoice's submission id. |
|
1515 | - * |
|
1516 | - * @since 1.0.19 |
|
1517 | - * @param string $context View or edit context. |
|
1518 | - * @return string |
|
1519 | - */ |
|
1520 | - public function get_submission_id( $context = 'view' ) { |
|
1521 | - return $this->get_prop( 'submission_id', $context ); |
|
1514 | + * Get the invoice's submission id. |
|
1515 | + * |
|
1516 | + * @since 1.0.19 |
|
1517 | + * @param string $context View or edit context. |
|
1518 | + * @return string |
|
1519 | + */ |
|
1520 | + public function get_submission_id( $context = 'view' ) { |
|
1521 | + return $this->get_prop( 'submission_id', $context ); |
|
1522 | 1522 | } |
1523 | 1523 | |
1524 | 1524 | /** |
1525 | - * Get the invoice's discount code. |
|
1526 | - * |
|
1527 | - * @since 1.0.19 |
|
1528 | - * @param string $context View or edit context. |
|
1529 | - * @return string |
|
1530 | - */ |
|
1531 | - public function get_discount_code( $context = 'view' ) { |
|
1532 | - return $this->get_prop( 'discount_code', $context ); |
|
1525 | + * Get the invoice's discount code. |
|
1526 | + * |
|
1527 | + * @since 1.0.19 |
|
1528 | + * @param string $context View or edit context. |
|
1529 | + * @return string |
|
1530 | + */ |
|
1531 | + public function get_discount_code( $context = 'view' ) { |
|
1532 | + return $this->get_prop( 'discount_code', $context ); |
|
1533 | 1533 | } |
1534 | 1534 | |
1535 | 1535 | /** |
1536 | - * Get the invoice's gateway. |
|
1537 | - * |
|
1538 | - * @since 1.0.19 |
|
1539 | - * @param string $context View or edit context. |
|
1540 | - * @return string |
|
1541 | - */ |
|
1542 | - public function get_gateway( $context = 'view' ) { |
|
1543 | - return $this->get_prop( 'gateway', $context ); |
|
1536 | + * Get the invoice's gateway. |
|
1537 | + * |
|
1538 | + * @since 1.0.19 |
|
1539 | + * @param string $context View or edit context. |
|
1540 | + * @return string |
|
1541 | + */ |
|
1542 | + public function get_gateway( $context = 'view' ) { |
|
1543 | + return $this->get_prop( 'gateway', $context ); |
|
1544 | 1544 | } |
1545 | 1545 | |
1546 | 1546 | /** |
1547 | - * Get the invoice's gateway display title. |
|
1548 | - * |
|
1549 | - * @since 1.0.19 |
|
1550 | - * @return string |
|
1551 | - */ |
|
1547 | + * Get the invoice's gateway display title. |
|
1548 | + * |
|
1549 | + * @since 1.0.19 |
|
1550 | + * @return string |
|
1551 | + */ |
|
1552 | 1552 | public function get_gateway_title() { |
1553 | 1553 | $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
1554 | 1554 | return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
1555 | 1555 | } |
1556 | 1556 | |
1557 | 1557 | /** |
1558 | - * Get the invoice's transaction id. |
|
1559 | - * |
|
1560 | - * @since 1.0.19 |
|
1561 | - * @param string $context View or edit context. |
|
1562 | - * @return string |
|
1563 | - */ |
|
1564 | - public function get_transaction_id( $context = 'view' ) { |
|
1565 | - return $this->get_prop( 'transaction_id', $context ); |
|
1558 | + * Get the invoice's transaction id. |
|
1559 | + * |
|
1560 | + * @since 1.0.19 |
|
1561 | + * @param string $context View or edit context. |
|
1562 | + * @return string |
|
1563 | + */ |
|
1564 | + public function get_transaction_id( $context = 'view' ) { |
|
1565 | + return $this->get_prop( 'transaction_id', $context ); |
|
1566 | 1566 | } |
1567 | 1567 | |
1568 | 1568 | /** |
1569 | - * Get the invoice's currency. |
|
1570 | - * |
|
1571 | - * @since 1.0.19 |
|
1572 | - * @param string $context View or edit context. |
|
1573 | - * @return string |
|
1574 | - */ |
|
1575 | - public function get_currency( $context = 'view' ) { |
|
1569 | + * Get the invoice's currency. |
|
1570 | + * |
|
1571 | + * @since 1.0.19 |
|
1572 | + * @param string $context View or edit context. |
|
1573 | + * @return string |
|
1574 | + */ |
|
1575 | + public function get_currency( $context = 'view' ) { |
|
1576 | 1576 | $currency = $this->get_prop( 'currency', $context ); |
1577 | 1577 | return empty( $currency ) ? wpinv_get_currency() : $currency; |
1578 | 1578 | } |
1579 | 1579 | |
1580 | 1580 | /** |
1581 | - * Checks if we are charging taxes for this invoice. |
|
1582 | - * |
|
1583 | - * @since 1.0.19 |
|
1584 | - * @param string $context View or edit context. |
|
1585 | - * @return bool |
|
1586 | - */ |
|
1587 | - public function get_disable_taxes( $context = 'view' ) { |
|
1581 | + * Checks if we are charging taxes for this invoice. |
|
1582 | + * |
|
1583 | + * @since 1.0.19 |
|
1584 | + * @param string $context View or edit context. |
|
1585 | + * @return bool |
|
1586 | + */ |
|
1587 | + public function get_disable_taxes( $context = 'view' ) { |
|
1588 | 1588 | return (bool) $this->get_prop( 'disable_taxes', $context ); |
1589 | 1589 | } |
1590 | 1590 | |
1591 | 1591 | /** |
1592 | - * Retrieves the subscription id for an invoice. |
|
1593 | - * |
|
1594 | - * @since 1.0.19 |
|
1595 | - * @param string $context View or edit context. |
|
1596 | - * @return int |
|
1597 | - */ |
|
1592 | + * Retrieves the subscription id for an invoice. |
|
1593 | + * |
|
1594 | + * @since 1.0.19 |
|
1595 | + * @param string $context View or edit context. |
|
1596 | + * @return int |
|
1597 | + */ |
|
1598 | 1598 | public function get_subscription_id( $context = 'view' ) { |
1599 | 1599 | $subscription_id = $this->get_prop( 'subscription_id', $context ); |
1600 | 1600 | |
@@ -1607,12 +1607,12 @@ discard block |
||
1607 | 1607 | } |
1608 | 1608 | |
1609 | 1609 | /** |
1610 | - * Retrieves the payment meta for an invoice. |
|
1611 | - * |
|
1612 | - * @since 1.0.19 |
|
1613 | - * @param string $context View or edit context. |
|
1614 | - * @return array |
|
1615 | - */ |
|
1610 | + * Retrieves the payment meta for an invoice. |
|
1611 | + * |
|
1612 | + * @since 1.0.19 |
|
1613 | + * @param string $context View or edit context. |
|
1614 | + * @return array |
|
1615 | + */ |
|
1616 | 1616 | public function get_payment_meta( $context = 'view' ) { |
1617 | 1617 | |
1618 | 1618 | return array( |
@@ -1632,11 +1632,11 @@ discard block |
||
1632 | 1632 | } |
1633 | 1633 | |
1634 | 1634 | /** |
1635 | - * Retrieves the cart details for an invoice. |
|
1636 | - * |
|
1637 | - * @since 1.0.19 |
|
1638 | - * @return array |
|
1639 | - */ |
|
1635 | + * Retrieves the cart details for an invoice. |
|
1636 | + * |
|
1637 | + * @since 1.0.19 |
|
1638 | + * @return array |
|
1639 | + */ |
|
1640 | 1640 | public function get_cart_details() { |
1641 | 1641 | $items = $this->get_items(); |
1642 | 1642 | $cart_details = array(); |
@@ -1646,16 +1646,16 @@ discard block |
||
1646 | 1646 | } |
1647 | 1647 | |
1648 | 1648 | return $cart_details; |
1649 | - } |
|
1649 | + } |
|
1650 | 1650 | |
1651 | - /** |
|
1652 | - * Retrieves the recurring item. |
|
1653 | - * |
|
1654 | - * @return null|GetPaid_Form_Item |
|
1655 | - */ |
|
1656 | - public function get_recurring( $object = false ) { |
|
1651 | + /** |
|
1652 | + * Retrieves the recurring item. |
|
1653 | + * |
|
1654 | + * @return null|GetPaid_Form_Item |
|
1655 | + */ |
|
1656 | + public function get_recurring( $object = false ) { |
|
1657 | 1657 | |
1658 | - // Are we returning an object? |
|
1658 | + // Are we returning an object? |
|
1659 | 1659 | if ( $object ) { |
1660 | 1660 | return $this->get_item( $this->recurring_item ); |
1661 | 1661 | } |
@@ -1663,58 +1663,58 @@ discard block |
||
1663 | 1663 | return $this->recurring_item; |
1664 | 1664 | } |
1665 | 1665 | |
1666 | - /** |
|
1667 | - * Retrieves the subscription name. |
|
1668 | - * |
|
1669 | - * @since 1.0.19 |
|
1670 | - * @return string |
|
1671 | - */ |
|
1672 | - public function get_subscription_name() { |
|
1666 | + /** |
|
1667 | + * Retrieves the subscription name. |
|
1668 | + * |
|
1669 | + * @since 1.0.19 |
|
1670 | + * @return string |
|
1671 | + */ |
|
1672 | + public function get_subscription_name() { |
|
1673 | 1673 | |
1674 | - // Retrieve the recurring name |
|
1674 | + // Retrieve the recurring name |
|
1675 | 1675 | $item = $this->get_recurring( true ); |
1676 | 1676 | |
1677 | - // Abort if it does not exist. |
|
1677 | + // Abort if it does not exist. |
|
1678 | 1678 | if ( empty( $item ) ) { |
1679 | 1679 | return ''; |
1680 | 1680 | } |
1681 | 1681 | |
1682 | - // Return the item name. |
|
1682 | + // Return the item name. |
|
1683 | 1683 | return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
1684 | - } |
|
1685 | - |
|
1686 | - /** |
|
1687 | - * Retrieves the view url. |
|
1688 | - * |
|
1689 | - * @since 1.0.19 |
|
1690 | - * @return string |
|
1691 | - */ |
|
1692 | - public function get_view_url() { |
|
1684 | + } |
|
1685 | + |
|
1686 | + /** |
|
1687 | + * Retrieves the view url. |
|
1688 | + * |
|
1689 | + * @since 1.0.19 |
|
1690 | + * @return string |
|
1691 | + */ |
|
1692 | + public function get_view_url() { |
|
1693 | 1693 | $invoice_url = get_permalink( $this->get_id() ); |
1694 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
1694 | + $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
1695 | 1695 | return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
1696 | - } |
|
1696 | + } |
|
1697 | 1697 | |
1698 | - /** |
|
1699 | - * Retrieves the payment url. |
|
1700 | - * |
|
1701 | - * @since 1.0.19 |
|
1702 | - * @return string |
|
1703 | - */ |
|
1704 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
1698 | + /** |
|
1699 | + * Retrieves the payment url. |
|
1700 | + * |
|
1701 | + * @since 1.0.19 |
|
1702 | + * @return string |
|
1703 | + */ |
|
1704 | + public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
1705 | 1705 | |
1706 | - // Retrieve the checkout url. |
|
1706 | + // Retrieve the checkout url. |
|
1707 | 1707 | $pay_url = wpinv_get_checkout_uri(); |
1708 | 1708 | |
1709 | - // Maybe force ssl. |
|
1709 | + // Maybe force ssl. |
|
1710 | 1710 | if ( is_ssl() ) { |
1711 | 1711 | $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
1712 | 1712 | } |
1713 | 1713 | |
1714 | - // Add the invoice key. |
|
1715 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
1714 | + // Add the invoice key. |
|
1715 | + $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
1716 | 1716 | |
1717 | - // (Maybe?) add a secret |
|
1717 | + // (Maybe?) add a secret |
|
1718 | 1718 | if ( $secret ) { |
1719 | 1719 | $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
1720 | 1720 | } |
@@ -1723,18 +1723,18 @@ discard block |
||
1723 | 1723 | } |
1724 | 1724 | |
1725 | 1725 | /** |
1726 | - * Magic method for accessing invoice properties. |
|
1727 | - * |
|
1728 | - * @since 1.0.15 |
|
1729 | - * @access public |
|
1730 | - * |
|
1731 | - * @param string $key Discount data to retrieve |
|
1732 | - * @param string $context View or edit context. |
|
1733 | - * @return mixed Value of the given invoice property (if set). |
|
1734 | - */ |
|
1735 | - public function get( $key, $context = 'view' ) { |
|
1726 | + * Magic method for accessing invoice properties. |
|
1727 | + * |
|
1728 | + * @since 1.0.15 |
|
1729 | + * @access public |
|
1730 | + * |
|
1731 | + * @param string $key Discount data to retrieve |
|
1732 | + * @param string $context View or edit context. |
|
1733 | + * @return mixed Value of the given invoice property (if set). |
|
1734 | + */ |
|
1735 | + public function get( $key, $context = 'view' ) { |
|
1736 | 1736 | return $this->get_prop( $key, $context ); |
1737 | - } |
|
1737 | + } |
|
1738 | 1738 | |
1739 | 1739 | /* |
1740 | 1740 | |-------------------------------------------------------------------------- |
@@ -1747,118 +1747,118 @@ discard block |
||
1747 | 1747 | */ |
1748 | 1748 | |
1749 | 1749 | /** |
1750 | - * Magic method for setting invoice properties. |
|
1751 | - * |
|
1752 | - * @since 1.0.19 |
|
1753 | - * @access public |
|
1754 | - * |
|
1755 | - * @param string $key Discount data to retrieve |
|
1756 | - * @param mixed $value new value. |
|
1757 | - * @return mixed Value of the given invoice property (if set). |
|
1758 | - */ |
|
1759 | - public function set( $key, $value ) { |
|
1750 | + * Magic method for setting invoice properties. |
|
1751 | + * |
|
1752 | + * @since 1.0.19 |
|
1753 | + * @access public |
|
1754 | + * |
|
1755 | + * @param string $key Discount data to retrieve |
|
1756 | + * @param mixed $value new value. |
|
1757 | + * @return mixed Value of the given invoice property (if set). |
|
1758 | + */ |
|
1759 | + public function set( $key, $value ) { |
|
1760 | 1760 | |
1761 | 1761 | $setter = "set_$key"; |
1762 | 1762 | if ( is_callable( array( $this, $setter ) ) ) { |
1763 | 1763 | $this->{$setter}( $value ); |
1764 | 1764 | } |
1765 | 1765 | |
1766 | - } |
|
1767 | - |
|
1768 | - /** |
|
1769 | - * Sets item status. |
|
1770 | - * |
|
1771 | - * @since 1.0.19 |
|
1772 | - * @param string $new_status New status. |
|
1773 | - * @param string $note Optional note to add. |
|
1774 | - * @param bool $manual_update Is this a manual status change?. |
|
1775 | - * @return array details of change. |
|
1776 | - */ |
|
1777 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
1778 | - $old_status = $this->get_status(); |
|
1779 | - |
|
1780 | - $this->set_prop( 'status', $new_status ); |
|
1781 | - |
|
1782 | - // If setting the status, ensure it's set to a valid status. |
|
1783 | - if ( true === $this->object_read ) { |
|
1784 | - |
|
1785 | - // Only allow valid new status. |
|
1786 | - if ( ! array_key_exists( $new_status, wpinv_get_invoice_statuses( false, true ) ) ) { |
|
1787 | - $new_status = 'wpi-pending'; |
|
1788 | - } |
|
1789 | - |
|
1790 | - // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
1791 | - if ( $old_status && ! array_key_exists( $new_status, wpinv_get_invoice_statuses( false, true ) ) ) { |
|
1792 | - $old_status = 'wpi-pending'; |
|
1793 | - } |
|
1794 | - } |
|
1795 | - |
|
1796 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
1797 | - $this->status_transition = array( |
|
1798 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
1799 | - 'to' => $new_status, |
|
1800 | - 'note' => $note, |
|
1801 | - 'manual' => (bool) $manual_update, |
|
1802 | - ); |
|
1803 | - |
|
1804 | - if ( $manual_update ) { |
|
1805 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
1806 | - } |
|
1807 | - |
|
1808 | - $this->maybe_set_date_paid(); |
|
1809 | - |
|
1810 | - } |
|
1811 | - |
|
1812 | - return array( |
|
1813 | - 'from' => $old_status, |
|
1814 | - 'to' => $new_status, |
|
1815 | - ); |
|
1816 | - } |
|
1817 | - |
|
1818 | - /** |
|
1819 | - * Maybe set date paid. |
|
1820 | - * |
|
1821 | - * Sets the date paid variable when transitioning to the payment complete |
|
1822 | - * order status. |
|
1823 | - * |
|
1824 | - * @since 1.0.19 |
|
1825 | - */ |
|
1826 | - public function maybe_set_date_paid() { |
|
1827 | - |
|
1828 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
1829 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
1830 | - } |
|
1831 | - } |
|
1832 | - |
|
1833 | - /** |
|
1834 | - * Set parent invoice ID. |
|
1835 | - * |
|
1836 | - * @since 1.0.19 |
|
1837 | - */ |
|
1838 | - public function set_parent_id( $value ) { |
|
1839 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
1840 | - return; |
|
1841 | - } |
|
1842 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
1843 | - } |
|
1844 | - |
|
1845 | - /** |
|
1846 | - * Set plugin version when the invoice was created. |
|
1847 | - * |
|
1848 | - * @since 1.0.19 |
|
1849 | - */ |
|
1850 | - public function set_version( $value ) { |
|
1851 | - $this->set_prop( 'version', $value ); |
|
1852 | - } |
|
1853 | - |
|
1854 | - /** |
|
1855 | - * Set date when the invoice was created. |
|
1856 | - * |
|
1857 | - * @since 1.0.19 |
|
1858 | - * @param string $value Value to set. |
|
1766 | + } |
|
1767 | + |
|
1768 | + /** |
|
1769 | + * Sets item status. |
|
1770 | + * |
|
1771 | + * @since 1.0.19 |
|
1772 | + * @param string $new_status New status. |
|
1773 | + * @param string $note Optional note to add. |
|
1774 | + * @param bool $manual_update Is this a manual status change?. |
|
1775 | + * @return array details of change. |
|
1776 | + */ |
|
1777 | + public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
1778 | + $old_status = $this->get_status(); |
|
1779 | + |
|
1780 | + $this->set_prop( 'status', $new_status ); |
|
1781 | + |
|
1782 | + // If setting the status, ensure it's set to a valid status. |
|
1783 | + if ( true === $this->object_read ) { |
|
1784 | + |
|
1785 | + // Only allow valid new status. |
|
1786 | + if ( ! array_key_exists( $new_status, wpinv_get_invoice_statuses( false, true ) ) ) { |
|
1787 | + $new_status = 'wpi-pending'; |
|
1788 | + } |
|
1789 | + |
|
1790 | + // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
|
1791 | + if ( $old_status && ! array_key_exists( $new_status, wpinv_get_invoice_statuses( false, true ) ) ) { |
|
1792 | + $old_status = 'wpi-pending'; |
|
1793 | + } |
|
1794 | + } |
|
1795 | + |
|
1796 | + if ( true === $this->object_read && $old_status !== $new_status ) { |
|
1797 | + $this->status_transition = array( |
|
1798 | + 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
1799 | + 'to' => $new_status, |
|
1800 | + 'note' => $note, |
|
1801 | + 'manual' => (bool) $manual_update, |
|
1802 | + ); |
|
1803 | + |
|
1804 | + if ( $manual_update ) { |
|
1805 | + do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
1806 | + } |
|
1807 | + |
|
1808 | + $this->maybe_set_date_paid(); |
|
1809 | + |
|
1810 | + } |
|
1811 | + |
|
1812 | + return array( |
|
1813 | + 'from' => $old_status, |
|
1814 | + 'to' => $new_status, |
|
1815 | + ); |
|
1816 | + } |
|
1817 | + |
|
1818 | + /** |
|
1819 | + * Maybe set date paid. |
|
1820 | + * |
|
1821 | + * Sets the date paid variable when transitioning to the payment complete |
|
1822 | + * order status. |
|
1823 | + * |
|
1824 | + * @since 1.0.19 |
|
1825 | + */ |
|
1826 | + public function maybe_set_date_paid() { |
|
1827 | + |
|
1828 | + if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
1829 | + $this->set_date_completed( current_time( 'mysql' ) ); |
|
1830 | + } |
|
1831 | + } |
|
1832 | + |
|
1833 | + /** |
|
1834 | + * Set parent invoice ID. |
|
1835 | + * |
|
1836 | + * @since 1.0.19 |
|
1837 | + */ |
|
1838 | + public function set_parent_id( $value ) { |
|
1839 | + if ( $value && ( $value === $this->get_id() ) ) { |
|
1840 | + return; |
|
1841 | + } |
|
1842 | + $this->set_prop( 'parent_id', absint( $value ) ); |
|
1843 | + } |
|
1844 | + |
|
1845 | + /** |
|
1846 | + * Set plugin version when the invoice was created. |
|
1847 | + * |
|
1848 | + * @since 1.0.19 |
|
1849 | + */ |
|
1850 | + public function set_version( $value ) { |
|
1851 | + $this->set_prop( 'version', $value ); |
|
1852 | + } |
|
1853 | + |
|
1854 | + /** |
|
1855 | + * Set date when the invoice was created. |
|
1856 | + * |
|
1857 | + * @since 1.0.19 |
|
1858 | + * @param string $value Value to set. |
|
1859 | 1859 | * @return bool Whether or not the date was set. |
1860 | - */ |
|
1861 | - public function set_date_created( $value ) { |
|
1860 | + */ |
|
1861 | + public function set_date_created( $value ) { |
|
1862 | 1862 | $date = strtotime( $value ); |
1863 | 1863 | |
1864 | 1864 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1871,13 +1871,13 @@ discard block |
||
1871 | 1871 | } |
1872 | 1872 | |
1873 | 1873 | /** |
1874 | - * Set date invoice due date. |
|
1875 | - * |
|
1876 | - * @since 1.0.19 |
|
1877 | - * @param string $value Value to set. |
|
1874 | + * Set date invoice due date. |
|
1875 | + * |
|
1876 | + * @since 1.0.19 |
|
1877 | + * @param string $value Value to set. |
|
1878 | 1878 | * @return bool Whether or not the date was set. |
1879 | - */ |
|
1880 | - public function set_due_date( $value ) { |
|
1879 | + */ |
|
1880 | + public function set_due_date( $value ) { |
|
1881 | 1881 | $date = strtotime( $value ); |
1882 | 1882 | |
1883 | 1883 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1885,29 +1885,29 @@ discard block |
||
1885 | 1885 | return true; |
1886 | 1886 | } |
1887 | 1887 | |
1888 | - $this->set_prop( 'due_date', '' ); |
|
1888 | + $this->set_prop( 'due_date', '' ); |
|
1889 | 1889 | return false; |
1890 | 1890 | |
1891 | 1891 | } |
1892 | 1892 | |
1893 | 1893 | /** |
1894 | - * Alias of self::set_due_date(). |
|
1895 | - * |
|
1896 | - * @since 1.0.19 |
|
1897 | - * @param string $value New name. |
|
1898 | - */ |
|
1899 | - public function set_date_due( $value ) { |
|
1900 | - $this->set_due_date( $value ); |
|
1894 | + * Alias of self::set_due_date(). |
|
1895 | + * |
|
1896 | + * @since 1.0.19 |
|
1897 | + * @param string $value New name. |
|
1898 | + */ |
|
1899 | + public function set_date_due( $value ) { |
|
1900 | + $this->set_due_date( $value ); |
|
1901 | 1901 | } |
1902 | 1902 | |
1903 | 1903 | /** |
1904 | - * Set date invoice was completed. |
|
1905 | - * |
|
1906 | - * @since 1.0.19 |
|
1907 | - * @param string $value Value to set. |
|
1904 | + * Set date invoice was completed. |
|
1905 | + * |
|
1906 | + * @since 1.0.19 |
|
1907 | + * @param string $value Value to set. |
|
1908 | 1908 | * @return bool Whether or not the date was set. |
1909 | - */ |
|
1910 | - public function set_completed_date( $value ) { |
|
1909 | + */ |
|
1910 | + public function set_completed_date( $value ) { |
|
1911 | 1911 | $date = strtotime( $value ); |
1912 | 1912 | |
1913 | 1913 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1915,29 +1915,29 @@ discard block |
||
1915 | 1915 | return true; |
1916 | 1916 | } |
1917 | 1917 | |
1918 | - $this->set_prop( 'completed_date', '' ); |
|
1918 | + $this->set_prop( 'completed_date', '' ); |
|
1919 | 1919 | return false; |
1920 | 1920 | |
1921 | 1921 | } |
1922 | 1922 | |
1923 | 1923 | /** |
1924 | - * Alias of self::set_completed_date(). |
|
1925 | - * |
|
1926 | - * @since 1.0.19 |
|
1927 | - * @param string $value New name. |
|
1928 | - */ |
|
1929 | - public function set_date_completed( $value ) { |
|
1930 | - $this->set_completed_date( $value ); |
|
1924 | + * Alias of self::set_completed_date(). |
|
1925 | + * |
|
1926 | + * @since 1.0.19 |
|
1927 | + * @param string $value New name. |
|
1928 | + */ |
|
1929 | + public function set_date_completed( $value ) { |
|
1930 | + $this->set_completed_date( $value ); |
|
1931 | 1931 | } |
1932 | 1932 | |
1933 | 1933 | /** |
1934 | - * Set date when the invoice was last modified. |
|
1935 | - * |
|
1936 | - * @since 1.0.19 |
|
1937 | - * @param string $value Value to set. |
|
1934 | + * Set date when the invoice was last modified. |
|
1935 | + * |
|
1936 | + * @since 1.0.19 |
|
1937 | + * @param string $value Value to set. |
|
1938 | 1938 | * @return bool Whether or not the date was set. |
1939 | - */ |
|
1940 | - public function set_date_modified( $value ) { |
|
1939 | + */ |
|
1940 | + public function set_date_modified( $value ) { |
|
1941 | 1941 | $date = strtotime( $value ); |
1942 | 1942 | |
1943 | 1943 | if ( $date && $value !== '0000-00-00 00:00:00' ) { |
@@ -1945,706 +1945,706 @@ discard block |
||
1945 | 1945 | return true; |
1946 | 1946 | } |
1947 | 1947 | |
1948 | - $this->set_prop( 'date_modified', '' ); |
|
1948 | + $this->set_prop( 'date_modified', '' ); |
|
1949 | 1949 | return false; |
1950 | 1950 | |
1951 | 1951 | } |
1952 | 1952 | |
1953 | 1953 | /** |
1954 | - * Set the invoice number. |
|
1955 | - * |
|
1956 | - * @since 1.0.19 |
|
1957 | - * @param string $value New number. |
|
1958 | - */ |
|
1959 | - public function set_number( $value ) { |
|
1954 | + * Set the invoice number. |
|
1955 | + * |
|
1956 | + * @since 1.0.19 |
|
1957 | + * @param string $value New number. |
|
1958 | + */ |
|
1959 | + public function set_number( $value ) { |
|
1960 | 1960 | $number = sanitize_text_field( $value ); |
1961 | - $this->set_prop( 'number', $number ); |
|
1961 | + $this->set_prop( 'number', $number ); |
|
1962 | 1962 | } |
1963 | 1963 | |
1964 | 1964 | /** |
1965 | - * Set the invoice type. |
|
1966 | - * |
|
1967 | - * @since 1.0.19 |
|
1968 | - * @param string $value Type. |
|
1969 | - */ |
|
1970 | - public function set_type( $value ) { |
|
1965 | + * Set the invoice type. |
|
1966 | + * |
|
1967 | + * @since 1.0.19 |
|
1968 | + * @param string $value Type. |
|
1969 | + */ |
|
1970 | + public function set_type( $value ) { |
|
1971 | 1971 | $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
1972 | - $this->set_prop( 'type', $type ); |
|
1973 | - } |
|
1972 | + $this->set_prop( 'type', $type ); |
|
1973 | + } |
|
1974 | 1974 | |
1975 | 1975 | /** |
1976 | - * Set the invoice post type. |
|
1977 | - * |
|
1978 | - * @since 1.0.19 |
|
1979 | - * @param string $value Post type. |
|
1980 | - */ |
|
1981 | - public function set_post_type( $value ) { |
|
1976 | + * Set the invoice post type. |
|
1977 | + * |
|
1978 | + * @since 1.0.19 |
|
1979 | + * @param string $value Post type. |
|
1980 | + */ |
|
1981 | + public function set_post_type( $value ) { |
|
1982 | 1982 | if ( getpaid_is_invoice_post_type( $value ) ) { |
1983 | - $this->set_type( $value ); |
|
1983 | + $this->set_type( $value ); |
|
1984 | 1984 | $this->set_prop( 'post_type', $value ); |
1985 | 1985 | } |
1986 | 1986 | } |
1987 | 1987 | |
1988 | 1988 | /** |
1989 | - * Set the invoice key. |
|
1990 | - * |
|
1991 | - * @since 1.0.19 |
|
1992 | - * @param string $value New key. |
|
1993 | - */ |
|
1994 | - public function set_key( $value ) { |
|
1989 | + * Set the invoice key. |
|
1990 | + * |
|
1991 | + * @since 1.0.19 |
|
1992 | + * @param string $value New key. |
|
1993 | + */ |
|
1994 | + public function set_key( $value ) { |
|
1995 | 1995 | $key = sanitize_text_field( $value ); |
1996 | - $this->set_prop( 'key', $key ); |
|
1996 | + $this->set_prop( 'key', $key ); |
|
1997 | 1997 | } |
1998 | 1998 | |
1999 | 1999 | /** |
2000 | - * Set the invoice mode. |
|
2001 | - * |
|
2002 | - * @since 1.0.19 |
|
2003 | - * @param string $value mode. |
|
2004 | - */ |
|
2005 | - public function set_mode( $value ) { |
|
2000 | + * Set the invoice mode. |
|
2001 | + * |
|
2002 | + * @since 1.0.19 |
|
2003 | + * @param string $value mode. |
|
2004 | + */ |
|
2005 | + public function set_mode( $value ) { |
|
2006 | 2006 | if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
2007 | 2007 | $this->set_prop( 'value', $value ); |
2008 | 2008 | } |
2009 | 2009 | } |
2010 | 2010 | |
2011 | 2011 | /** |
2012 | - * Set the invoice path. |
|
2013 | - * |
|
2014 | - * @since 1.0.19 |
|
2015 | - * @param string $value path. |
|
2016 | - */ |
|
2017 | - public function set_path( $value ) { |
|
2012 | + * Set the invoice path. |
|
2013 | + * |
|
2014 | + * @since 1.0.19 |
|
2015 | + * @param string $value path. |
|
2016 | + */ |
|
2017 | + public function set_path( $value ) { |
|
2018 | 2018 | $this->set_prop( 'path', $value ); |
2019 | 2019 | } |
2020 | 2020 | |
2021 | 2021 | /** |
2022 | - * Set the invoice name. |
|
2023 | - * |
|
2024 | - * @since 1.0.19 |
|
2025 | - * @param string $value New name. |
|
2026 | - */ |
|
2027 | - public function set_name( $value ) { |
|
2022 | + * Set the invoice name. |
|
2023 | + * |
|
2024 | + * @since 1.0.19 |
|
2025 | + * @param string $value New name. |
|
2026 | + */ |
|
2027 | + public function set_name( $value ) { |
|
2028 | 2028 | $name = sanitize_text_field( $value ); |
2029 | - $this->set_prop( 'name', $name ); |
|
2029 | + $this->set_prop( 'name', $name ); |
|
2030 | 2030 | } |
2031 | 2031 | |
2032 | 2032 | /** |
2033 | - * Alias of self::set_name(). |
|
2034 | - * |
|
2035 | - * @since 1.0.19 |
|
2036 | - * @param string $value New name. |
|
2037 | - */ |
|
2038 | - public function set_title( $value ) { |
|
2039 | - $this->set_name( $value ); |
|
2033 | + * Alias of self::set_name(). |
|
2034 | + * |
|
2035 | + * @since 1.0.19 |
|
2036 | + * @param string $value New name. |
|
2037 | + */ |
|
2038 | + public function set_title( $value ) { |
|
2039 | + $this->set_name( $value ); |
|
2040 | 2040 | } |
2041 | 2041 | |
2042 | 2042 | /** |
2043 | - * Set the invoice description. |
|
2044 | - * |
|
2045 | - * @since 1.0.19 |
|
2046 | - * @param string $value New description. |
|
2047 | - */ |
|
2048 | - public function set_description( $value ) { |
|
2043 | + * Set the invoice description. |
|
2044 | + * |
|
2045 | + * @since 1.0.19 |
|
2046 | + * @param string $value New description. |
|
2047 | + */ |
|
2048 | + public function set_description( $value ) { |
|
2049 | 2049 | $description = wp_kses_post( $value ); |
2050 | - return $this->set_prop( 'description', $description ); |
|
2050 | + return $this->set_prop( 'description', $description ); |
|
2051 | + } |
|
2052 | + |
|
2053 | + /** |
|
2054 | + * Alias of self::set_description(). |
|
2055 | + * |
|
2056 | + * @since 1.0.19 |
|
2057 | + * @param string $value New description. |
|
2058 | + */ |
|
2059 | + public function set_excerpt( $value ) { |
|
2060 | + $this->set_description( $value ); |
|
2061 | + } |
|
2062 | + |
|
2063 | + /** |
|
2064 | + * Alias of self::set_description(). |
|
2065 | + * |
|
2066 | + * @since 1.0.19 |
|
2067 | + * @param string $value New description. |
|
2068 | + */ |
|
2069 | + public function set_summary( $value ) { |
|
2070 | + $this->set_description( $value ); |
|
2071 | + } |
|
2072 | + |
|
2073 | + /** |
|
2074 | + * Set the receiver of the invoice. |
|
2075 | + * |
|
2076 | + * @since 1.0.19 |
|
2077 | + * @param int $value New author. |
|
2078 | + */ |
|
2079 | + public function set_author( $value ) { |
|
2080 | + $user = get_user_by( 'id', (int) $value ); |
|
2081 | + |
|
2082 | + if ( $user && $user->ID ) { |
|
2083 | + $this->set_prop( 'author', $user->ID ); |
|
2084 | + $this->set_prop( 'email', $user->user_email ); |
|
2085 | + } |
|
2086 | + |
|
2051 | 2087 | } |
2052 | 2088 | |
2053 | 2089 | /** |
2054 | - * Alias of self::set_description(). |
|
2055 | - * |
|
2056 | - * @since 1.0.19 |
|
2057 | - * @param string $value New description. |
|
2058 | - */ |
|
2059 | - public function set_excerpt( $value ) { |
|
2060 | - $this->set_description( $value ); |
|
2090 | + * Alias of self::set_author(). |
|
2091 | + * |
|
2092 | + * @since 1.0.19 |
|
2093 | + * @param int $value New user id. |
|
2094 | + */ |
|
2095 | + public function set_user_id( $value ) { |
|
2096 | + $this->set_author( $value ); |
|
2061 | 2097 | } |
2062 | 2098 | |
2063 | 2099 | /** |
2064 | - * Alias of self::set_description(). |
|
2065 | - * |
|
2066 | - * @since 1.0.19 |
|
2067 | - * @param string $value New description. |
|
2068 | - */ |
|
2069 | - public function set_summary( $value ) { |
|
2070 | - $this->set_description( $value ); |
|
2100 | + * Alias of self::set_author(). |
|
2101 | + * |
|
2102 | + * @since 1.0.19 |
|
2103 | + * @param int $value New user id. |
|
2104 | + */ |
|
2105 | + public function set_customer_id( $value ) { |
|
2106 | + $this->set_author( $value ); |
|
2071 | 2107 | } |
2072 | 2108 | |
2073 | 2109 | /** |
2074 | - * Set the receiver of the invoice. |
|
2075 | - * |
|
2076 | - * @since 1.0.19 |
|
2077 | - * @param int $value New author. |
|
2078 | - */ |
|
2079 | - public function set_author( $value ) { |
|
2080 | - $user = get_user_by( 'id', (int) $value ); |
|
2081 | - |
|
2082 | - if ( $user && $user->ID ) { |
|
2083 | - $this->set_prop( 'author', $user->ID ); |
|
2084 | - $this->set_prop( 'email', $user->user_email ); |
|
2085 | - } |
|
2086 | - |
|
2110 | + * Set the customer's ip. |
|
2111 | + * |
|
2112 | + * @since 1.0.19 |
|
2113 | + * @param string $value ip address. |
|
2114 | + */ |
|
2115 | + public function set_ip( $value ) { |
|
2116 | + $this->set_prop( 'ip', $value ); |
|
2087 | 2117 | } |
2088 | 2118 | |
2089 | 2119 | /** |
2090 | - * Alias of self::set_author(). |
|
2091 | - * |
|
2092 | - * @since 1.0.19 |
|
2093 | - * @param int $value New user id. |
|
2094 | - */ |
|
2095 | - public function set_user_id( $value ) { |
|
2096 | - $this->set_author( $value ); |
|
2120 | + * Alias of self::set_ip(). |
|
2121 | + * |
|
2122 | + * @since 1.0.19 |
|
2123 | + * @param string $value ip address. |
|
2124 | + */ |
|
2125 | + public function set_user_ip( $value ) { |
|
2126 | + $this->set_ip( $value ); |
|
2097 | 2127 | } |
2098 | 2128 | |
2099 | 2129 | /** |
2100 | - * Alias of self::set_author(). |
|
2101 | - * |
|
2102 | - * @since 1.0.19 |
|
2103 | - * @param int $value New user id. |
|
2104 | - */ |
|
2105 | - public function set_customer_id( $value ) { |
|
2106 | - $this->set_author( $value ); |
|
2130 | + * Set the customer's first name. |
|
2131 | + * |
|
2132 | + * @since 1.0.19 |
|
2133 | + * @param string $value first name. |
|
2134 | + */ |
|
2135 | + public function set_first_name( $value ) { |
|
2136 | + $this->set_prop( 'first_name', $value ); |
|
2107 | 2137 | } |
2108 | 2138 | |
2109 | 2139 | /** |
2110 | - * Set the customer's ip. |
|
2111 | - * |
|
2112 | - * @since 1.0.19 |
|
2113 | - * @param string $value ip address. |
|
2114 | - */ |
|
2115 | - public function set_ip( $value ) { |
|
2116 | - $this->set_prop( 'ip', $value ); |
|
2140 | + * Alias of self::set_first_name(). |
|
2141 | + * |
|
2142 | + * @since 1.0.19 |
|
2143 | + * @param string $value first name. |
|
2144 | + */ |
|
2145 | + public function set_user_first_name( $value ) { |
|
2146 | + $this->set_first_name( $value ); |
|
2117 | 2147 | } |
2118 | 2148 | |
2119 | 2149 | /** |
2120 | - * Alias of self::set_ip(). |
|
2121 | - * |
|
2122 | - * @since 1.0.19 |
|
2123 | - * @param string $value ip address. |
|
2124 | - */ |
|
2125 | - public function set_user_ip( $value ) { |
|
2126 | - $this->set_ip( $value ); |
|
2150 | + * Alias of self::set_first_name(). |
|
2151 | + * |
|
2152 | + * @since 1.0.19 |
|
2153 | + * @param string $value first name. |
|
2154 | + */ |
|
2155 | + public function set_customer_first_name( $value ) { |
|
2156 | + $this->set_first_name( $value ); |
|
2127 | 2157 | } |
2128 | 2158 | |
2129 | 2159 | /** |
2130 | - * Set the customer's first name. |
|
2131 | - * |
|
2132 | - * @since 1.0.19 |
|
2133 | - * @param string $value first name. |
|
2134 | - */ |
|
2135 | - public function set_first_name( $value ) { |
|
2136 | - $this->set_prop( 'first_name', $value ); |
|
2160 | + * Set the customer's last name. |
|
2161 | + * |
|
2162 | + * @since 1.0.19 |
|
2163 | + * @param string $value last name. |
|
2164 | + */ |
|
2165 | + public function set_last_name( $value ) { |
|
2166 | + $this->set_prop( 'last_name', $value ); |
|
2137 | 2167 | } |
2138 | 2168 | |
2139 | 2169 | /** |
2140 | - * Alias of self::set_first_name(). |
|
2141 | - * |
|
2142 | - * @since 1.0.19 |
|
2143 | - * @param string $value first name. |
|
2144 | - */ |
|
2145 | - public function set_user_first_name( $value ) { |
|
2146 | - $this->set_first_name( $value ); |
|
2170 | + * Alias of self::set_last_name(). |
|
2171 | + * |
|
2172 | + * @since 1.0.19 |
|
2173 | + * @param string $value last name. |
|
2174 | + */ |
|
2175 | + public function set_user_last_name( $value ) { |
|
2176 | + $this->set_last_name( $value ); |
|
2147 | 2177 | } |
2148 | 2178 | |
2149 | 2179 | /** |
2150 | - * Alias of self::set_first_name(). |
|
2151 | - * |
|
2152 | - * @since 1.0.19 |
|
2153 | - * @param string $value first name. |
|
2154 | - */ |
|
2155 | - public function set_customer_first_name( $value ) { |
|
2156 | - $this->set_first_name( $value ); |
|
2180 | + * Alias of self::set_last_name(). |
|
2181 | + * |
|
2182 | + * @since 1.0.19 |
|
2183 | + * @param string $value last name. |
|
2184 | + */ |
|
2185 | + public function set_customer_last_name( $value ) { |
|
2186 | + $this->set_last_name( $value ); |
|
2157 | 2187 | } |
2158 | 2188 | |
2159 | 2189 | /** |
2160 | - * Set the customer's last name. |
|
2161 | - * |
|
2162 | - * @since 1.0.19 |
|
2163 | - * @param string $value last name. |
|
2164 | - */ |
|
2165 | - public function set_last_name( $value ) { |
|
2166 | - $this->set_prop( 'last_name', $value ); |
|
2190 | + * Set the customer's phone number. |
|
2191 | + * |
|
2192 | + * @since 1.0.19 |
|
2193 | + * @param string $value phone. |
|
2194 | + */ |
|
2195 | + public function set_phone( $value ) { |
|
2196 | + $this->set_prop( 'phone', $value ); |
|
2167 | 2197 | } |
2168 | 2198 | |
2169 | 2199 | /** |
2170 | - * Alias of self::set_last_name(). |
|
2171 | - * |
|
2172 | - * @since 1.0.19 |
|
2173 | - * @param string $value last name. |
|
2174 | - */ |
|
2175 | - public function set_user_last_name( $value ) { |
|
2176 | - $this->set_last_name( $value ); |
|
2200 | + * Alias of self::set_phone(). |
|
2201 | + * |
|
2202 | + * @since 1.0.19 |
|
2203 | + * @param string $value phone. |
|
2204 | + */ |
|
2205 | + public function set_user_phone( $value ) { |
|
2206 | + $this->set_phone( $value ); |
|
2177 | 2207 | } |
2178 | 2208 | |
2179 | 2209 | /** |
2180 | - * Alias of self::set_last_name(). |
|
2181 | - * |
|
2182 | - * @since 1.0.19 |
|
2183 | - * @param string $value last name. |
|
2184 | - */ |
|
2185 | - public function set_customer_last_name( $value ) { |
|
2186 | - $this->set_last_name( $value ); |
|
2210 | + * Alias of self::set_phone(). |
|
2211 | + * |
|
2212 | + * @since 1.0.19 |
|
2213 | + * @param string $value phone. |
|
2214 | + */ |
|
2215 | + public function set_customer_phone( $value ) { |
|
2216 | + $this->set_phone( $value ); |
|
2187 | 2217 | } |
2188 | 2218 | |
2189 | 2219 | /** |
2190 | - * Set the customer's phone number. |
|
2191 | - * |
|
2192 | - * @since 1.0.19 |
|
2193 | - * @param string $value phone. |
|
2194 | - */ |
|
2195 | - public function set_phone( $value ) { |
|
2196 | - $this->set_prop( 'phone', $value ); |
|
2220 | + * Alias of self::set_phone(). |
|
2221 | + * |
|
2222 | + * @since 1.0.19 |
|
2223 | + * @param string $value phone. |
|
2224 | + */ |
|
2225 | + public function set_phone_number( $value ) { |
|
2226 | + $this->set_phone( $value ); |
|
2197 | 2227 | } |
2198 | 2228 | |
2199 | 2229 | /** |
2200 | - * Alias of self::set_phone(). |
|
2201 | - * |
|
2202 | - * @since 1.0.19 |
|
2203 | - * @param string $value phone. |
|
2204 | - */ |
|
2205 | - public function set_user_phone( $value ) { |
|
2206 | - $this->set_phone( $value ); |
|
2230 | + * Set the customer's email address. |
|
2231 | + * |
|
2232 | + * @since 1.0.19 |
|
2233 | + * @param string $value email address. |
|
2234 | + */ |
|
2235 | + public function set_email( $value ) { |
|
2236 | + $this->set_prop( 'email', $value ); |
|
2207 | 2237 | } |
2208 | 2238 | |
2209 | 2239 | /** |
2210 | - * Alias of self::set_phone(). |
|
2211 | - * |
|
2212 | - * @since 1.0.19 |
|
2213 | - * @param string $value phone. |
|
2214 | - */ |
|
2215 | - public function set_customer_phone( $value ) { |
|
2216 | - $this->set_phone( $value ); |
|
2240 | + * Alias of self::set_email(). |
|
2241 | + * |
|
2242 | + * @since 1.0.19 |
|
2243 | + * @param string $value email address. |
|
2244 | + */ |
|
2245 | + public function set_user_email( $value ) { |
|
2246 | + $this->set_email( $value ); |
|
2217 | 2247 | } |
2218 | 2248 | |
2219 | 2249 | /** |
2220 | - * Alias of self::set_phone(). |
|
2221 | - * |
|
2222 | - * @since 1.0.19 |
|
2223 | - * @param string $value phone. |
|
2224 | - */ |
|
2225 | - public function set_phone_number( $value ) { |
|
2226 | - $this->set_phone( $value ); |
|
2250 | + * Alias of self::set_email(). |
|
2251 | + * |
|
2252 | + * @since 1.0.19 |
|
2253 | + * @param string $value email address. |
|
2254 | + */ |
|
2255 | + public function set_email_address( $value ) { |
|
2256 | + $this->set_email( $value ); |
|
2227 | 2257 | } |
2228 | 2258 | |
2229 | 2259 | /** |
2230 | - * Set the customer's email address. |
|
2231 | - * |
|
2232 | - * @since 1.0.19 |
|
2233 | - * @param string $value email address. |
|
2234 | - */ |
|
2235 | - public function set_email( $value ) { |
|
2236 | - $this->set_prop( 'email', $value ); |
|
2260 | + * Alias of self::set_email(). |
|
2261 | + * |
|
2262 | + * @since 1.0.19 |
|
2263 | + * @param string $value email address. |
|
2264 | + */ |
|
2265 | + public function set_customer_email( $value ) { |
|
2266 | + $this->set_email( $value ); |
|
2237 | 2267 | } |
2238 | 2268 | |
2239 | 2269 | /** |
2240 | - * Alias of self::set_email(). |
|
2241 | - * |
|
2242 | - * @since 1.0.19 |
|
2243 | - * @param string $value email address. |
|
2244 | - */ |
|
2245 | - public function set_user_email( $value ) { |
|
2246 | - $this->set_email( $value ); |
|
2270 | + * Set the customer's country. |
|
2271 | + * |
|
2272 | + * @since 1.0.19 |
|
2273 | + * @param string $value country. |
|
2274 | + */ |
|
2275 | + public function set_country( $value ) { |
|
2276 | + $this->set_prop( 'country', $value ); |
|
2247 | 2277 | } |
2248 | 2278 | |
2249 | 2279 | /** |
2250 | - * Alias of self::set_email(). |
|
2251 | - * |
|
2252 | - * @since 1.0.19 |
|
2253 | - * @param string $value email address. |
|
2254 | - */ |
|
2255 | - public function set_email_address( $value ) { |
|
2256 | - $this->set_email( $value ); |
|
2280 | + * Alias of self::set_country(). |
|
2281 | + * |
|
2282 | + * @since 1.0.19 |
|
2283 | + * @param string $value country. |
|
2284 | + */ |
|
2285 | + public function set_user_country( $value ) { |
|
2286 | + $this->set_country( $value ); |
|
2257 | 2287 | } |
2258 | 2288 | |
2259 | 2289 | /** |
2260 | - * Alias of self::set_email(). |
|
2261 | - * |
|
2262 | - * @since 1.0.19 |
|
2263 | - * @param string $value email address. |
|
2264 | - */ |
|
2265 | - public function set_customer_email( $value ) { |
|
2266 | - $this->set_email( $value ); |
|
2290 | + * Alias of self::set_country(). |
|
2291 | + * |
|
2292 | + * @since 1.0.19 |
|
2293 | + * @param string $value country. |
|
2294 | + */ |
|
2295 | + public function set_customer_country( $value ) { |
|
2296 | + $this->set_country( $value ); |
|
2267 | 2297 | } |
2268 | 2298 | |
2269 | 2299 | /** |
2270 | - * Set the customer's country. |
|
2271 | - * |
|
2272 | - * @since 1.0.19 |
|
2273 | - * @param string $value country. |
|
2274 | - */ |
|
2275 | - public function set_country( $value ) { |
|
2276 | - $this->set_prop( 'country', $value ); |
|
2300 | + * Set the customer's state. |
|
2301 | + * |
|
2302 | + * @since 1.0.19 |
|
2303 | + * @param string $value state. |
|
2304 | + */ |
|
2305 | + public function set_state( $value ) { |
|
2306 | + $this->set_prop( 'state', $value ); |
|
2277 | 2307 | } |
2278 | 2308 | |
2279 | 2309 | /** |
2280 | - * Alias of self::set_country(). |
|
2281 | - * |
|
2282 | - * @since 1.0.19 |
|
2283 | - * @param string $value country. |
|
2284 | - */ |
|
2285 | - public function set_user_country( $value ) { |
|
2286 | - $this->set_country( $value ); |
|
2310 | + * Alias of self::set_state(). |
|
2311 | + * |
|
2312 | + * @since 1.0.19 |
|
2313 | + * @param string $value state. |
|
2314 | + */ |
|
2315 | + public function set_user_state( $value ) { |
|
2316 | + $this->set_state( $value ); |
|
2287 | 2317 | } |
2288 | 2318 | |
2289 | 2319 | /** |
2290 | - * Alias of self::set_country(). |
|
2291 | - * |
|
2292 | - * @since 1.0.19 |
|
2293 | - * @param string $value country. |
|
2294 | - */ |
|
2295 | - public function set_customer_country( $value ) { |
|
2296 | - $this->set_country( $value ); |
|
2320 | + * Alias of self::set_state(). |
|
2321 | + * |
|
2322 | + * @since 1.0.19 |
|
2323 | + * @param string $value state. |
|
2324 | + */ |
|
2325 | + public function set_customer_state( $value ) { |
|
2326 | + $this->set_state( $value ); |
|
2297 | 2327 | } |
2298 | 2328 | |
2299 | 2329 | /** |
2300 | - * Set the customer's state. |
|
2301 | - * |
|
2302 | - * @since 1.0.19 |
|
2303 | - * @param string $value state. |
|
2304 | - */ |
|
2305 | - public function set_state( $value ) { |
|
2306 | - $this->set_prop( 'state', $value ); |
|
2330 | + * Set the customer's city. |
|
2331 | + * |
|
2332 | + * @since 1.0.19 |
|
2333 | + * @param string $value city. |
|
2334 | + */ |
|
2335 | + public function set_city( $value ) { |
|
2336 | + $this->set_prop( 'city', $value ); |
|
2307 | 2337 | } |
2308 | 2338 | |
2309 | 2339 | /** |
2310 | - * Alias of self::set_state(). |
|
2311 | - * |
|
2312 | - * @since 1.0.19 |
|
2313 | - * @param string $value state. |
|
2314 | - */ |
|
2315 | - public function set_user_state( $value ) { |
|
2316 | - $this->set_state( $value ); |
|
2340 | + * Alias of self::set_city(). |
|
2341 | + * |
|
2342 | + * @since 1.0.19 |
|
2343 | + * @param string $value city. |
|
2344 | + */ |
|
2345 | + public function set_user_city( $value ) { |
|
2346 | + $this->set_city( $value ); |
|
2317 | 2347 | } |
2318 | 2348 | |
2319 | 2349 | /** |
2320 | - * Alias of self::set_state(). |
|
2321 | - * |
|
2322 | - * @since 1.0.19 |
|
2323 | - * @param string $value state. |
|
2324 | - */ |
|
2325 | - public function set_customer_state( $value ) { |
|
2326 | - $this->set_state( $value ); |
|
2350 | + * Alias of self::set_city(). |
|
2351 | + * |
|
2352 | + * @since 1.0.19 |
|
2353 | + * @param string $value city. |
|
2354 | + */ |
|
2355 | + public function set_customer_city( $value ) { |
|
2356 | + $this->set_city( $value ); |
|
2327 | 2357 | } |
2328 | 2358 | |
2329 | 2359 | /** |
2330 | - * Set the customer's city. |
|
2331 | - * |
|
2332 | - * @since 1.0.19 |
|
2333 | - * @param string $value city. |
|
2334 | - */ |
|
2335 | - public function set_city( $value ) { |
|
2336 | - $this->set_prop( 'city', $value ); |
|
2360 | + * Set the customer's zip code. |
|
2361 | + * |
|
2362 | + * @since 1.0.19 |
|
2363 | + * @param string $value zip. |
|
2364 | + */ |
|
2365 | + public function set_zip( $value ) { |
|
2366 | + $this->set_prop( 'zip', $value ); |
|
2337 | 2367 | } |
2338 | 2368 | |
2339 | 2369 | /** |
2340 | - * Alias of self::set_city(). |
|
2341 | - * |
|
2342 | - * @since 1.0.19 |
|
2343 | - * @param string $value city. |
|
2344 | - */ |
|
2345 | - public function set_user_city( $value ) { |
|
2346 | - $this->set_city( $value ); |
|
2370 | + * Alias of self::set_zip(). |
|
2371 | + * |
|
2372 | + * @since 1.0.19 |
|
2373 | + * @param string $value zip. |
|
2374 | + */ |
|
2375 | + public function set_user_zip( $value ) { |
|
2376 | + $this->set_zip( $value ); |
|
2347 | 2377 | } |
2348 | 2378 | |
2349 | 2379 | /** |
2350 | - * Alias of self::set_city(). |
|
2351 | - * |
|
2352 | - * @since 1.0.19 |
|
2353 | - * @param string $value city. |
|
2354 | - */ |
|
2355 | - public function set_customer_city( $value ) { |
|
2356 | - $this->set_city( $value ); |
|
2380 | + * Alias of self::set_zip(). |
|
2381 | + * |
|
2382 | + * @since 1.0.19 |
|
2383 | + * @param string $value zip. |
|
2384 | + */ |
|
2385 | + public function set_customer_zip( $value ) { |
|
2386 | + $this->set_zip( $value ); |
|
2357 | 2387 | } |
2358 | 2388 | |
2359 | 2389 | /** |
2360 | - * Set the customer's zip code. |
|
2361 | - * |
|
2362 | - * @since 1.0.19 |
|
2363 | - * @param string $value zip. |
|
2364 | - */ |
|
2365 | - public function set_zip( $value ) { |
|
2366 | - $this->set_prop( 'zip', $value ); |
|
2390 | + * Set the customer's company. |
|
2391 | + * |
|
2392 | + * @since 1.0.19 |
|
2393 | + * @param string $value company. |
|
2394 | + */ |
|
2395 | + public function set_company( $value ) { |
|
2396 | + $this->set_prop( 'company', $value ); |
|
2367 | 2397 | } |
2368 | 2398 | |
2369 | 2399 | /** |
2370 | - * Alias of self::set_zip(). |
|
2371 | - * |
|
2372 | - * @since 1.0.19 |
|
2373 | - * @param string $value zip. |
|
2374 | - */ |
|
2375 | - public function set_user_zip( $value ) { |
|
2376 | - $this->set_zip( $value ); |
|
2400 | + * Alias of self::set_company(). |
|
2401 | + * |
|
2402 | + * @since 1.0.19 |
|
2403 | + * @param string $value company. |
|
2404 | + */ |
|
2405 | + public function set_user_company( $value ) { |
|
2406 | + $this->set_company( $value ); |
|
2377 | 2407 | } |
2378 | 2408 | |
2379 | 2409 | /** |
2380 | - * Alias of self::set_zip(). |
|
2381 | - * |
|
2382 | - * @since 1.0.19 |
|
2383 | - * @param string $value zip. |
|
2384 | - */ |
|
2385 | - public function set_customer_zip( $value ) { |
|
2386 | - $this->set_zip( $value ); |
|
2410 | + * Alias of self::set_company(). |
|
2411 | + * |
|
2412 | + * @since 1.0.19 |
|
2413 | + * @param string $value company. |
|
2414 | + */ |
|
2415 | + public function set_customer_company( $value ) { |
|
2416 | + $this->set_company( $value ); |
|
2387 | 2417 | } |
2388 | 2418 | |
2389 | 2419 | /** |
2390 | - * Set the customer's company. |
|
2391 | - * |
|
2392 | - * @since 1.0.19 |
|
2393 | - * @param string $value company. |
|
2394 | - */ |
|
2395 | - public function set_company( $value ) { |
|
2396 | - $this->set_prop( 'company', $value ); |
|
2420 | + * Set the customer's var number. |
|
2421 | + * |
|
2422 | + * @since 1.0.19 |
|
2423 | + * @param string $value var number. |
|
2424 | + */ |
|
2425 | + public function set_vat_number( $value ) { |
|
2426 | + $this->set_prop( 'vat_number', $value ); |
|
2397 | 2427 | } |
2398 | 2428 | |
2399 | 2429 | /** |
2400 | - * Alias of self::set_company(). |
|
2401 | - * |
|
2402 | - * @since 1.0.19 |
|
2403 | - * @param string $value company. |
|
2404 | - */ |
|
2405 | - public function set_user_company( $value ) { |
|
2406 | - $this->set_company( $value ); |
|
2430 | + * Alias of self::set_vat_number(). |
|
2431 | + * |
|
2432 | + * @since 1.0.19 |
|
2433 | + * @param string $value var number. |
|
2434 | + */ |
|
2435 | + public function set_user_vat_number( $value ) { |
|
2436 | + $this->set_vat_number( $value ); |
|
2407 | 2437 | } |
2408 | 2438 | |
2409 | 2439 | /** |
2410 | - * Alias of self::set_company(). |
|
2411 | - * |
|
2412 | - * @since 1.0.19 |
|
2413 | - * @param string $value company. |
|
2414 | - */ |
|
2415 | - public function set_customer_company( $value ) { |
|
2416 | - $this->set_company( $value ); |
|
2440 | + * Alias of self::set_vat_number(). |
|
2441 | + * |
|
2442 | + * @since 1.0.19 |
|
2443 | + * @param string $value var number. |
|
2444 | + */ |
|
2445 | + public function set_customer_vat_number( $value ) { |
|
2446 | + $this->set_vat_number( $value ); |
|
2417 | 2447 | } |
2418 | 2448 | |
2419 | 2449 | /** |
2420 | - * Set the customer's var number. |
|
2421 | - * |
|
2422 | - * @since 1.0.19 |
|
2423 | - * @param string $value var number. |
|
2424 | - */ |
|
2425 | - public function set_vat_number( $value ) { |
|
2426 | - $this->set_prop( 'vat_number', $value ); |
|
2450 | + * Set the customer's vat rate. |
|
2451 | + * |
|
2452 | + * @since 1.0.19 |
|
2453 | + * @param string $value var rate. |
|
2454 | + */ |
|
2455 | + public function set_vat_rate( $value ) { |
|
2456 | + $this->set_prop( 'vat_rate', $value ); |
|
2427 | 2457 | } |
2428 | 2458 | |
2429 | 2459 | /** |
2430 | - * Alias of self::set_vat_number(). |
|
2431 | - * |
|
2432 | - * @since 1.0.19 |
|
2433 | - * @param string $value var number. |
|
2434 | - */ |
|
2435 | - public function set_user_vat_number( $value ) { |
|
2436 | - $this->set_vat_number( $value ); |
|
2460 | + * Alias of self::set_vat_rate(). |
|
2461 | + * |
|
2462 | + * @since 1.0.19 |
|
2463 | + * @param string $value var number. |
|
2464 | + */ |
|
2465 | + public function set_user_vat_rate( $value ) { |
|
2466 | + $this->set_vat_rate( $value ); |
|
2437 | 2467 | } |
2438 | 2468 | |
2439 | 2469 | /** |
2440 | - * Alias of self::set_vat_number(). |
|
2441 | - * |
|
2442 | - * @since 1.0.19 |
|
2443 | - * @param string $value var number. |
|
2444 | - */ |
|
2445 | - public function set_customer_vat_number( $value ) { |
|
2446 | - $this->set_vat_number( $value ); |
|
2470 | + * Alias of self::set_vat_rate(). |
|
2471 | + * |
|
2472 | + * @since 1.0.19 |
|
2473 | + * @param string $value var number. |
|
2474 | + */ |
|
2475 | + public function set_customer_vat_rate( $value ) { |
|
2476 | + $this->set_vat_rate( $value ); |
|
2447 | 2477 | } |
2448 | 2478 | |
2449 | 2479 | /** |
2450 | - * Set the customer's vat rate. |
|
2451 | - * |
|
2452 | - * @since 1.0.19 |
|
2453 | - * @param string $value var rate. |
|
2454 | - */ |
|
2455 | - public function set_vat_rate( $value ) { |
|
2456 | - $this->set_prop( 'vat_rate', $value ); |
|
2480 | + * Set the customer's address. |
|
2481 | + * |
|
2482 | + * @since 1.0.19 |
|
2483 | + * @param string $value address. |
|
2484 | + */ |
|
2485 | + public function set_address( $value ) { |
|
2486 | + $this->set_prop( 'address', $value ); |
|
2457 | 2487 | } |
2458 | 2488 | |
2459 | 2489 | /** |
2460 | - * Alias of self::set_vat_rate(). |
|
2461 | - * |
|
2462 | - * @since 1.0.19 |
|
2463 | - * @param string $value var number. |
|
2464 | - */ |
|
2465 | - public function set_user_vat_rate( $value ) { |
|
2466 | - $this->set_vat_rate( $value ); |
|
2490 | + * Alias of self::set_address(). |
|
2491 | + * |
|
2492 | + * @since 1.0.19 |
|
2493 | + * @param string $value address. |
|
2494 | + */ |
|
2495 | + public function set_user_address( $value ) { |
|
2496 | + $this->set_address( $value ); |
|
2467 | 2497 | } |
2468 | 2498 | |
2469 | 2499 | /** |
2470 | - * Alias of self::set_vat_rate(). |
|
2471 | - * |
|
2472 | - * @since 1.0.19 |
|
2473 | - * @param string $value var number. |
|
2474 | - */ |
|
2475 | - public function set_customer_vat_rate( $value ) { |
|
2476 | - $this->set_vat_rate( $value ); |
|
2500 | + * Alias of self::set_address(). |
|
2501 | + * |
|
2502 | + * @since 1.0.19 |
|
2503 | + * @param string $value address. |
|
2504 | + */ |
|
2505 | + public function set_customer_address( $value ) { |
|
2506 | + $this->set_address( $value ); |
|
2477 | 2507 | } |
2478 | 2508 | |
2479 | 2509 | /** |
2480 | - * Set the customer's address. |
|
2481 | - * |
|
2482 | - * @since 1.0.19 |
|
2483 | - * @param string $value address. |
|
2484 | - */ |
|
2485 | - public function set_address( $value ) { |
|
2486 | - $this->set_prop( 'address', $value ); |
|
2510 | + * Set whether the customer has viewed the invoice or not. |
|
2511 | + * |
|
2512 | + * @since 1.0.19 |
|
2513 | + * @param int|bool $value confirmed. |
|
2514 | + */ |
|
2515 | + public function set_is_viewed( $value ) { |
|
2516 | + $this->set_prop( 'is_viewed', $value ); |
|
2487 | 2517 | } |
2488 | 2518 | |
2489 | 2519 | /** |
2490 | - * Alias of self::set_address(). |
|
2491 | - * |
|
2492 | - * @since 1.0.19 |
|
2493 | - * @param string $value address. |
|
2494 | - */ |
|
2495 | - public function set_user_address( $value ) { |
|
2496 | - $this->set_address( $value ); |
|
2520 | + * Set extra email recipients. |
|
2521 | + * |
|
2522 | + * @since 1.0.19 |
|
2523 | + * @param string $value email recipients. |
|
2524 | + */ |
|
2525 | + public function set_email_cc( $value ) { |
|
2526 | + $this->set_prop( 'email_cc', $value ); |
|
2497 | 2527 | } |
2498 | 2528 | |
2499 | 2529 | /** |
2500 | - * Alias of self::set_address(). |
|
2501 | - * |
|
2502 | - * @since 1.0.19 |
|
2503 | - * @param string $value address. |
|
2504 | - */ |
|
2505 | - public function set_customer_address( $value ) { |
|
2506 | - $this->set_address( $value ); |
|
2530 | + * Set the invoice template. |
|
2531 | + * |
|
2532 | + * @since 1.0.19 |
|
2533 | + * @param string $value email recipients. |
|
2534 | + */ |
|
2535 | + public function set_template( $value ) { |
|
2536 | + if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
2537 | + $this->set_prop( 'template', $value ); |
|
2538 | + } |
|
2507 | 2539 | } |
2508 | 2540 | |
2509 | 2541 | /** |
2510 | - * Set whether the customer has viewed the invoice or not. |
|
2511 | - * |
|
2512 | - * @since 1.0.19 |
|
2513 | - * @param int|bool $value confirmed. |
|
2514 | - */ |
|
2515 | - public function set_is_viewed( $value ) { |
|
2516 | - $this->set_prop( 'is_viewed', $value ); |
|
2517 | - } |
|
2518 | - |
|
2519 | - /** |
|
2520 | - * Set extra email recipients. |
|
2521 | - * |
|
2522 | - * @since 1.0.19 |
|
2523 | - * @param string $value email recipients. |
|
2524 | - */ |
|
2525 | - public function set_email_cc( $value ) { |
|
2526 | - $this->set_prop( 'email_cc', $value ); |
|
2527 | - } |
|
2528 | - |
|
2529 | - /** |
|
2530 | - * Set the invoice template. |
|
2531 | - * |
|
2532 | - * @since 1.0.19 |
|
2533 | - * @param string $value email recipients. |
|
2534 | - */ |
|
2535 | - public function set_template( $value ) { |
|
2536 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
2537 | - $this->set_prop( 'template', $value ); |
|
2538 | - } |
|
2539 | - } |
|
2540 | - |
|
2541 | - /** |
|
2542 | - * Set the customer's address confirmed status. |
|
2543 | - * |
|
2544 | - * @since 1.0.19 |
|
2545 | - * @param int|bool $value confirmed. |
|
2546 | - */ |
|
2547 | - public function set_address_confirmed( $value ) { |
|
2548 | - $this->set_prop( 'address_confirmed', $value ); |
|
2542 | + * Set the customer's address confirmed status. |
|
2543 | + * |
|
2544 | + * @since 1.0.19 |
|
2545 | + * @param int|bool $value confirmed. |
|
2546 | + */ |
|
2547 | + public function set_address_confirmed( $value ) { |
|
2548 | + $this->set_prop( 'address_confirmed', $value ); |
|
2549 | 2549 | } |
2550 | 2550 | |
2551 | 2551 | /** |
2552 | - * Alias of self::set_address_confirmed(). |
|
2553 | - * |
|
2554 | - * @since 1.0.19 |
|
2555 | - * @param int|bool $value confirmed. |
|
2556 | - */ |
|
2557 | - public function set_user_address_confirmed( $value ) { |
|
2558 | - $this->set_address_confirmed( $value ); |
|
2552 | + * Alias of self::set_address_confirmed(). |
|
2553 | + * |
|
2554 | + * @since 1.0.19 |
|
2555 | + * @param int|bool $value confirmed. |
|
2556 | + */ |
|
2557 | + public function set_user_address_confirmed( $value ) { |
|
2558 | + $this->set_address_confirmed( $value ); |
|
2559 | 2559 | } |
2560 | 2560 | |
2561 | 2561 | /** |
2562 | - * Alias of self::set_address_confirmed(). |
|
2563 | - * |
|
2564 | - * @since 1.0.19 |
|
2565 | - * @param int|bool $value confirmed. |
|
2566 | - */ |
|
2567 | - public function set_customer_address_confirmed( $value ) { |
|
2568 | - $this->set_address_confirmed( $value ); |
|
2562 | + * Alias of self::set_address_confirmed(). |
|
2563 | + * |
|
2564 | + * @since 1.0.19 |
|
2565 | + * @param int|bool $value confirmed. |
|
2566 | + */ |
|
2567 | + public function set_customer_address_confirmed( $value ) { |
|
2568 | + $this->set_address_confirmed( $value ); |
|
2569 | 2569 | } |
2570 | 2570 | |
2571 | 2571 | /** |
2572 | - * Set the invoice sub total. |
|
2573 | - * |
|
2574 | - * @since 1.0.19 |
|
2575 | - * @param float $value sub total. |
|
2576 | - */ |
|
2577 | - public function set_subtotal( $value ) { |
|
2578 | - $this->set_prop( 'subtotal', $value ); |
|
2572 | + * Set the invoice sub total. |
|
2573 | + * |
|
2574 | + * @since 1.0.19 |
|
2575 | + * @param float $value sub total. |
|
2576 | + */ |
|
2577 | + public function set_subtotal( $value ) { |
|
2578 | + $this->set_prop( 'subtotal', $value ); |
|
2579 | 2579 | } |
2580 | 2580 | |
2581 | 2581 | /** |
2582 | - * Set the invoice discount amount. |
|
2583 | - * |
|
2584 | - * @since 1.0.19 |
|
2585 | - * @param float $value discount total. |
|
2586 | - */ |
|
2587 | - public function set_total_discount( $value ) { |
|
2588 | - $this->set_prop( 'total_discount', $value ); |
|
2582 | + * Set the invoice discount amount. |
|
2583 | + * |
|
2584 | + * @since 1.0.19 |
|
2585 | + * @param float $value discount total. |
|
2586 | + */ |
|
2587 | + public function set_total_discount( $value ) { |
|
2588 | + $this->set_prop( 'total_discount', $value ); |
|
2589 | 2589 | } |
2590 | 2590 | |
2591 | 2591 | /** |
2592 | - * Alias of self::set_total_discount(). |
|
2593 | - * |
|
2594 | - * @since 1.0.19 |
|
2595 | - * @param float $value discount total. |
|
2596 | - */ |
|
2597 | - public function set_discount( $value ) { |
|
2598 | - $this->set_total_discount( $value ); |
|
2592 | + * Alias of self::set_total_discount(). |
|
2593 | + * |
|
2594 | + * @since 1.0.19 |
|
2595 | + * @param float $value discount total. |
|
2596 | + */ |
|
2597 | + public function set_discount( $value ) { |
|
2598 | + $this->set_total_discount( $value ); |
|
2599 | 2599 | } |
2600 | 2600 | |
2601 | 2601 | /** |
2602 | - * Set the invoice tax amount. |
|
2603 | - * |
|
2604 | - * @since 1.0.19 |
|
2605 | - * @param float $value tax total. |
|
2606 | - */ |
|
2607 | - public function set_total_tax( $value ) { |
|
2608 | - $this->set_prop( 'total_tax', $value ); |
|
2602 | + * Set the invoice tax amount. |
|
2603 | + * |
|
2604 | + * @since 1.0.19 |
|
2605 | + * @param float $value tax total. |
|
2606 | + */ |
|
2607 | + public function set_total_tax( $value ) { |
|
2608 | + $this->set_prop( 'total_tax', $value ); |
|
2609 | 2609 | } |
2610 | 2610 | |
2611 | 2611 | /** |
2612 | - * Alias of self::set_total_tax(). |
|
2613 | - * |
|
2614 | - * @since 1.0.19 |
|
2615 | - * @param float $value tax total. |
|
2616 | - */ |
|
2617 | - public function set_tax_total( $value ) { |
|
2618 | - $this->set_total_tax( $value ); |
|
2612 | + * Alias of self::set_total_tax(). |
|
2613 | + * |
|
2614 | + * @since 1.0.19 |
|
2615 | + * @param float $value tax total. |
|
2616 | + */ |
|
2617 | + public function set_tax_total( $value ) { |
|
2618 | + $this->set_total_tax( $value ); |
|
2619 | 2619 | } |
2620 | 2620 | |
2621 | 2621 | /** |
2622 | - * Set the invoice fees amount. |
|
2623 | - * |
|
2624 | - * @since 1.0.19 |
|
2625 | - * @param float $value fees total. |
|
2626 | - */ |
|
2627 | - public function set_total_fees( $value ) { |
|
2628 | - $this->set_prop( 'total_fees', $value ); |
|
2622 | + * Set the invoice fees amount. |
|
2623 | + * |
|
2624 | + * @since 1.0.19 |
|
2625 | + * @param float $value fees total. |
|
2626 | + */ |
|
2627 | + public function set_total_fees( $value ) { |
|
2628 | + $this->set_prop( 'total_fees', $value ); |
|
2629 | 2629 | } |
2630 | 2630 | |
2631 | 2631 | /** |
2632 | - * Alias of self::set_total_fees(). |
|
2633 | - * |
|
2634 | - * @since 1.0.19 |
|
2635 | - * @param float $value fees total. |
|
2636 | - */ |
|
2637 | - public function set_fees_total( $value ) { |
|
2638 | - $this->set_total_fees( $value ); |
|
2632 | + * Alias of self::set_total_fees(). |
|
2633 | + * |
|
2634 | + * @since 1.0.19 |
|
2635 | + * @param float $value fees total. |
|
2636 | + */ |
|
2637 | + public function set_fees_total( $value ) { |
|
2638 | + $this->set_total_fees( $value ); |
|
2639 | 2639 | } |
2640 | 2640 | |
2641 | 2641 | /** |
2642 | - * Set the invoice fees. |
|
2643 | - * |
|
2644 | - * @since 1.0.19 |
|
2645 | - * @param array $value fees. |
|
2646 | - */ |
|
2647 | - public function set_fees( $value ) { |
|
2642 | + * Set the invoice fees. |
|
2643 | + * |
|
2644 | + * @since 1.0.19 |
|
2645 | + * @param array $value fees. |
|
2646 | + */ |
|
2647 | + public function set_fees( $value ) { |
|
2648 | 2648 | |
2649 | 2649 | $this->set_prop( 'fees', array() ); |
2650 | 2650 | |
@@ -2662,23 +2662,23 @@ discard block |
||
2662 | 2662 | } |
2663 | 2663 | |
2664 | 2664 | /** |
2665 | - * Set the invoice taxes. |
|
2666 | - * |
|
2667 | - * @since 1.0.19 |
|
2668 | - * @param array $value taxes. |
|
2669 | - */ |
|
2670 | - public function set_taxes( $value ) { |
|
2671 | - $this->set_prop( 'taxes', $value ); |
|
2665 | + * Set the invoice taxes. |
|
2666 | + * |
|
2667 | + * @since 1.0.19 |
|
2668 | + * @param array $value taxes. |
|
2669 | + */ |
|
2670 | + public function set_taxes( $value ) { |
|
2671 | + $this->set_prop( 'taxes', $value ); |
|
2672 | 2672 | } |
2673 | 2673 | |
2674 | 2674 | /** |
2675 | - * Set the invoice discounts. |
|
2676 | - * |
|
2677 | - * @since 1.0.19 |
|
2678 | - * @param array $value discounts. |
|
2679 | - */ |
|
2680 | - public function set_discounts( $value ) { |
|
2681 | - $this->set_prop( 'discounts', array() ); |
|
2675 | + * Set the invoice discounts. |
|
2676 | + * |
|
2677 | + * @since 1.0.19 |
|
2678 | + * @param array $value discounts. |
|
2679 | + */ |
|
2680 | + public function set_discounts( $value ) { |
|
2681 | + $this->set_prop( 'discounts', array() ); |
|
2682 | 2682 | |
2683 | 2683 | // Ensure that we have an array. |
2684 | 2684 | if ( ! is_array( $value ) ) { |
@@ -2693,12 +2693,12 @@ discard block |
||
2693 | 2693 | } |
2694 | 2694 | |
2695 | 2695 | /** |
2696 | - * Set the invoice items. |
|
2697 | - * |
|
2698 | - * @since 1.0.19 |
|
2699 | - * @param GetPaid_Form_Item[] $value items. |
|
2700 | - */ |
|
2701 | - public function set_items( $value ) { |
|
2696 | + * Set the invoice items. |
|
2697 | + * |
|
2698 | + * @since 1.0.19 |
|
2699 | + * @param GetPaid_Form_Item[] $value items. |
|
2700 | + */ |
|
2701 | + public function set_items( $value ) { |
|
2702 | 2702 | |
2703 | 2703 | // Remove existing items. |
2704 | 2704 | $this->set_prop( 'items', array() ); |
@@ -2715,83 +2715,83 @@ discard block |
||
2715 | 2715 | } |
2716 | 2716 | |
2717 | 2717 | /** |
2718 | - * Set the payment form. |
|
2719 | - * |
|
2720 | - * @since 1.0.19 |
|
2721 | - * @param int $value payment form. |
|
2722 | - */ |
|
2723 | - public function set_payment_form( $value ) { |
|
2724 | - $this->set_prop( 'payment_form', $value ); |
|
2718 | + * Set the payment form. |
|
2719 | + * |
|
2720 | + * @since 1.0.19 |
|
2721 | + * @param int $value payment form. |
|
2722 | + */ |
|
2723 | + public function set_payment_form( $value ) { |
|
2724 | + $this->set_prop( 'payment_form', $value ); |
|
2725 | 2725 | } |
2726 | 2726 | |
2727 | 2727 | /** |
2728 | - * Set the submission id. |
|
2729 | - * |
|
2730 | - * @since 1.0.19 |
|
2731 | - * @param string $value submission id. |
|
2732 | - */ |
|
2733 | - public function set_submission_id( $value ) { |
|
2734 | - $this->set_prop( 'submission_id', $value ); |
|
2728 | + * Set the submission id. |
|
2729 | + * |
|
2730 | + * @since 1.0.19 |
|
2731 | + * @param string $value submission id. |
|
2732 | + */ |
|
2733 | + public function set_submission_id( $value ) { |
|
2734 | + $this->set_prop( 'submission_id', $value ); |
|
2735 | 2735 | } |
2736 | 2736 | |
2737 | 2737 | /** |
2738 | - * Set the discount code. |
|
2739 | - * |
|
2740 | - * @since 1.0.19 |
|
2741 | - * @param string $value discount code. |
|
2742 | - */ |
|
2743 | - public function set_discount_code( $value ) { |
|
2744 | - $this->set_prop( 'discount_code', $value ); |
|
2738 | + * Set the discount code. |
|
2739 | + * |
|
2740 | + * @since 1.0.19 |
|
2741 | + * @param string $value discount code. |
|
2742 | + */ |
|
2743 | + public function set_discount_code( $value ) { |
|
2744 | + $this->set_prop( 'discount_code', $value ); |
|
2745 | 2745 | } |
2746 | 2746 | |
2747 | 2747 | /** |
2748 | - * Set the gateway. |
|
2749 | - * |
|
2750 | - * @since 1.0.19 |
|
2751 | - * @param string $value gateway. |
|
2752 | - */ |
|
2753 | - public function set_gateway( $value ) { |
|
2754 | - $this->set_prop( 'gateway', $value ); |
|
2748 | + * Set the gateway. |
|
2749 | + * |
|
2750 | + * @since 1.0.19 |
|
2751 | + * @param string $value gateway. |
|
2752 | + */ |
|
2753 | + public function set_gateway( $value ) { |
|
2754 | + $this->set_prop( 'gateway', $value ); |
|
2755 | 2755 | } |
2756 | 2756 | |
2757 | 2757 | /** |
2758 | - * Set the transaction id. |
|
2759 | - * |
|
2760 | - * @since 1.0.19 |
|
2761 | - * @param string $value transaction id. |
|
2762 | - */ |
|
2763 | - public function set_transaction_id( $value ) { |
|
2764 | - $this->set_prop( 'transaction_id', $value ); |
|
2758 | + * Set the transaction id. |
|
2759 | + * |
|
2760 | + * @since 1.0.19 |
|
2761 | + * @param string $value transaction id. |
|
2762 | + */ |
|
2763 | + public function set_transaction_id( $value ) { |
|
2764 | + $this->set_prop( 'transaction_id', $value ); |
|
2765 | 2765 | } |
2766 | 2766 | |
2767 | 2767 | /** |
2768 | - * Set the currency id. |
|
2769 | - * |
|
2770 | - * @since 1.0.19 |
|
2771 | - * @param string $value currency id. |
|
2772 | - */ |
|
2773 | - public function set_currency( $value ) { |
|
2774 | - $this->set_prop( 'currency', $value ); |
|
2768 | + * Set the currency id. |
|
2769 | + * |
|
2770 | + * @since 1.0.19 |
|
2771 | + * @param string $value currency id. |
|
2772 | + */ |
|
2773 | + public function set_currency( $value ) { |
|
2774 | + $this->set_prop( 'currency', $value ); |
|
2775 | 2775 | } |
2776 | 2776 | |
2777 | - /** |
|
2778 | - * Set whether to disable taxes. |
|
2779 | - * |
|
2780 | - * @since 1.0.19 |
|
2781 | - * @param bool $value value. |
|
2782 | - */ |
|
2783 | - public function set_disable_taxes( $value ) { |
|
2784 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
2785 | - } |
|
2777 | + /** |
|
2778 | + * Set whether to disable taxes. |
|
2779 | + * |
|
2780 | + * @since 1.0.19 |
|
2781 | + * @param bool $value value. |
|
2782 | + */ |
|
2783 | + public function set_disable_taxes( $value ) { |
|
2784 | + $this->set_prop( 'disable_taxes', (bool) $value ); |
|
2785 | + } |
|
2786 | 2786 | |
2787 | 2787 | /** |
2788 | - * Set the subscription id. |
|
2789 | - * |
|
2790 | - * @since 1.0.19 |
|
2791 | - * @param string $value subscription id. |
|
2792 | - */ |
|
2793 | - public function set_subscription_id( $value ) { |
|
2794 | - $this->set_prop( 'subscription_id', $value ); |
|
2788 | + * Set the subscription id. |
|
2789 | + * |
|
2790 | + * @since 1.0.19 |
|
2791 | + * @param string $value subscription id. |
|
2792 | + */ |
|
2793 | + public function set_subscription_id( $value ) { |
|
2794 | + $this->set_prop( 'subscription_id', $value ); |
|
2795 | 2795 | } |
2796 | 2796 | |
2797 | 2797 | /* |
@@ -2830,12 +2830,12 @@ discard block |
||
2830 | 2830 | */ |
2831 | 2831 | public function is_taxable() { |
2832 | 2832 | return $this->get_disable_taxes(); |
2833 | - } |
|
2833 | + } |
|
2834 | 2834 | |
2835 | - /** |
|
2836 | - * @deprecated |
|
2837 | - */ |
|
2838 | - public function has_vat() { |
|
2835 | + /** |
|
2836 | + * @deprecated |
|
2837 | + */ |
|
2838 | + public function has_vat() { |
|
2839 | 2839 | global $wpinv_euvat, $wpi_country; |
2840 | 2840 | |
2841 | 2841 | $requires_vat = false; |
@@ -2846,17 +2846,17 @@ discard block |
||
2846 | 2846 | } |
2847 | 2847 | |
2848 | 2848 | return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
2849 | - } |
|
2849 | + } |
|
2850 | 2850 | |
2851 | - /** |
|
2852 | - * Checks to see if the invoice requires payment. |
|
2853 | - */ |
|
2854 | - public function is_free() { |
|
2851 | + /** |
|
2852 | + * Checks to see if the invoice requires payment. |
|
2853 | + */ |
|
2854 | + public function is_free() { |
|
2855 | 2855 | $is_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
2856 | 2856 | |
2857 | - if ( $is_free && $this->is_recurring() ) { |
|
2858 | - $is_free = ! ( (float) wpinv_round_amount( $this->get_recurring_total() ) > 0 ); |
|
2859 | - } |
|
2857 | + if ( $is_free && $this->is_recurring() ) { |
|
2858 | + $is_free = ! ( (float) wpinv_round_amount( $this->get_recurring_total() ) > 0 ); |
|
2859 | + } |
|
2860 | 2860 | |
2861 | 2861 | return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
2862 | 2862 | } |
@@ -2867,30 +2867,30 @@ discard block |
||
2867 | 2867 | public function is_paid() { |
2868 | 2868 | $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
2869 | 2869 | return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
2870 | - } |
|
2870 | + } |
|
2871 | 2871 | |
2872 | - /** |
|
2872 | + /** |
|
2873 | 2873 | * Checks if the invoice needs payment. |
2874 | 2874 | */ |
2875 | - public function needs_payment() { |
|
2876 | - $needs_payment = ! $this->is_paid() && ! $this->is_free(); |
|
2875 | + public function needs_payment() { |
|
2876 | + $needs_payment = ! $this->is_paid() && ! $this->is_free(); |
|
2877 | 2877 | return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
2878 | 2878 | } |
2879 | 2879 | |
2880 | - /** |
|
2880 | + /** |
|
2881 | 2881 | * Checks if the invoice is refunded. |
2882 | 2882 | */ |
2883 | - public function is_refunded() { |
|
2883 | + public function is_refunded() { |
|
2884 | 2884 | $is_refunded = $this->has_status( 'wpi-refunded' ); |
2885 | 2885 | return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
2886 | - } |
|
2886 | + } |
|
2887 | 2887 | |
2888 | - /** |
|
2888 | + /** |
|
2889 | 2889 | * Checks if the invoice is draft. |
2890 | 2890 | */ |
2891 | - public function is_draft() { |
|
2891 | + public function is_draft() { |
|
2892 | 2892 | return $this->has_status( 'draft, auto-draft' ); |
2893 | - } |
|
2893 | + } |
|
2894 | 2894 | |
2895 | 2895 | /** |
2896 | 2896 | * Checks if the invoice has a given status. |
@@ -2898,9 +2898,9 @@ discard block |
||
2898 | 2898 | public function has_status( $status ) { |
2899 | 2899 | $status = wpinv_parse_list( $status ); |
2900 | 2900 | return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
2901 | - } |
|
2901 | + } |
|
2902 | 2902 | |
2903 | - /** |
|
2903 | + /** |
|
2904 | 2904 | * Checks if the invoice is of a given type. |
2905 | 2905 | */ |
2906 | 2906 | public function is_type( $type ) { |
@@ -2923,25 +2923,25 @@ discard block |
||
2923 | 2923 | */ |
2924 | 2924 | public function has_free_trial() { |
2925 | 2925 | return $this->is_recurring() && 0 == $this->get_initial_total(); |
2926 | - } |
|
2926 | + } |
|
2927 | 2927 | |
2928 | - /** |
|
2928 | + /** |
|
2929 | 2929 | * @deprecated |
2930 | 2930 | */ |
2931 | 2931 | public function is_free_trial() { |
2932 | 2932 | $this->has_free_trial(); |
2933 | 2933 | } |
2934 | 2934 | |
2935 | - /** |
|
2935 | + /** |
|
2936 | 2936 | * Check if the initial payment if 0. |
2937 | 2937 | * |
2938 | 2938 | */ |
2939 | - public function is_initial_free() { |
|
2939 | + public function is_initial_free() { |
|
2940 | 2940 | $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
2941 | 2941 | return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
2942 | 2942 | } |
2943 | 2943 | |
2944 | - /** |
|
2944 | + /** |
|
2945 | 2945 | * Check if the recurring item has a free trial. |
2946 | 2946 | * |
2947 | 2947 | */ |
@@ -2954,21 +2954,21 @@ discard block |
||
2954 | 2954 | |
2955 | 2955 | $item = new WPInv_Item( $this->recurring_item ); |
2956 | 2956 | return $item->has_free_trial(); |
2957 | - } |
|
2957 | + } |
|
2958 | 2958 | |
2959 | - /** |
|
2959 | + /** |
|
2960 | 2960 | * Check if the free trial is a result of a discount. |
2961 | 2961 | */ |
2962 | 2962 | public function is_free_trial_from_discount() { |
2963 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
2964 | - } |
|
2963 | + return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
2964 | + } |
|
2965 | 2965 | |
2966 | - /** |
|
2966 | + /** |
|
2967 | 2967 | * @deprecated |
2968 | 2968 | */ |
2969 | 2969 | public function discount_first_payment_only() { |
2970 | 2970 | |
2971 | - $discount_code = $this->get_discount_code(); |
|
2971 | + $discount_code = $this->get_discount_code(); |
|
2972 | 2972 | if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
2973 | 2973 | return true; |
2974 | 2974 | } |
@@ -3000,19 +3000,19 @@ discard block |
||
3000 | 3000 | public function add_item( $item ) { |
3001 | 3001 | |
3002 | 3002 | // Make sure that it is available for purchase. |
3003 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
3004 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
3003 | + if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
3004 | + return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
3005 | 3005 | } |
3006 | 3006 | |
3007 | 3007 | // Do we have a recurring item? |
3008 | - if ( $item->is_recurring() ) { |
|
3008 | + if ( $item->is_recurring() ) { |
|
3009 | 3009 | |
3010 | - // An invoice can only contain one recurring item. |
|
3011 | - if ( ! empty( $this->recurring_item ) ) { |
|
3012 | - return false; |
|
3013 | - } |
|
3010 | + // An invoice can only contain one recurring item. |
|
3011 | + if ( ! empty( $this->recurring_item ) ) { |
|
3012 | + return false; |
|
3013 | + } |
|
3014 | 3014 | |
3015 | - $this->recurring_item = $item->get_id(); |
|
3015 | + $this->recurring_item = $item->get_id(); |
|
3016 | 3016 | } |
3017 | 3017 | |
3018 | 3018 | // Invoice id. |
@@ -3023,25 +3023,25 @@ discard block |
||
3023 | 3023 | $items[ $item->get_id() ] = $item; |
3024 | 3024 | |
3025 | 3025 | $this->set_prop( 'items', $items ); |
3026 | - return true; |
|
3026 | + return true; |
|
3027 | 3027 | } |
3028 | 3028 | |
3029 | 3029 | /** |
3030 | - * Retrieves a specific item. |
|
3031 | - * |
|
3032 | - * @since 1.0.19 |
|
3033 | - */ |
|
3034 | - public function get_item( $item_id ) { |
|
3030 | + * Retrieves a specific item. |
|
3031 | + * |
|
3032 | + * @since 1.0.19 |
|
3033 | + */ |
|
3034 | + public function get_item( $item_id ) { |
|
3035 | 3035 | $items = $this->get_items(); |
3036 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
3036 | + return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
3037 | 3037 | } |
3038 | 3038 | |
3039 | 3039 | /** |
3040 | - * Removes a specific item. |
|
3041 | - * |
|
3042 | - * @since 1.0.19 |
|
3043 | - */ |
|
3044 | - public function remove_item( $item_id ) { |
|
3040 | + * Removes a specific item. |
|
3041 | + * |
|
3042 | + * @since 1.0.19 |
|
3043 | + */ |
|
3044 | + public function remove_item( $item_id ) { |
|
3045 | 3045 | $items = $this->get_items(); |
3046 | 3046 | |
3047 | 3047 | if ( $item_id == $this->recurring_item ) { |
@@ -3069,38 +3069,38 @@ discard block |
||
3069 | 3069 | if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) { |
3070 | 3070 | |
3071 | 3071 | $amount = $fees[ $fee ]['amount'] += $amount; |
3072 | - $fees[ $fee ] = array( |
|
3072 | + $fees[ $fee ] = array( |
|
3073 | 3073 | 'amount' => $amount, |
3074 | 3074 | 'recurring' => (bool) $recurring, |
3075 | 3075 | ); |
3076 | 3076 | |
3077 | - } else { |
|
3078 | - $fees[ $fee ] = array( |
|
3077 | + } else { |
|
3078 | + $fees[ $fee ] = array( |
|
3079 | 3079 | 'amount' => $amount, |
3080 | 3080 | 'recurring' => (bool) $recurring, |
3081 | 3081 | ); |
3082 | - } |
|
3082 | + } |
|
3083 | 3083 | |
3084 | 3084 | $this->set_prop( 'fees', $fee ); |
3085 | 3085 | |
3086 | 3086 | } |
3087 | 3087 | |
3088 | 3088 | /** |
3089 | - * Retrieves a specific fee. |
|
3090 | - * |
|
3091 | - * @since 1.0.19 |
|
3092 | - */ |
|
3093 | - public function get_fee( $fee ) { |
|
3089 | + * Retrieves a specific fee. |
|
3090 | + * |
|
3091 | + * @since 1.0.19 |
|
3092 | + */ |
|
3093 | + public function get_fee( $fee ) { |
|
3094 | 3094 | $fees = $this->get_fees(); |
3095 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
3095 | + return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
3096 | 3096 | } |
3097 | 3097 | |
3098 | 3098 | /** |
3099 | - * Removes a specific fee. |
|
3100 | - * |
|
3101 | - * @since 1.0.19 |
|
3102 | - */ |
|
3103 | - public function remove_fee( $fee ) { |
|
3099 | + * Removes a specific fee. |
|
3100 | + * |
|
3101 | + * @since 1.0.19 |
|
3102 | + */ |
|
3103 | + public function remove_fee( $fee ) { |
|
3104 | 3104 | $fees = $this->get_fees(); |
3105 | 3105 | if ( isset( $fees[ $fee ] ) ) { |
3106 | 3106 | unset( $fees[ $fee ] ); |
@@ -3123,44 +3123,44 @@ discard block |
||
3123 | 3123 | if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) { |
3124 | 3124 | |
3125 | 3125 | $amount = $discounts[ $discount ]['amount'] += $amount; |
3126 | - $discounts[ $discount ] = array( |
|
3126 | + $discounts[ $discount ] = array( |
|
3127 | 3127 | 'amount' => $amount, |
3128 | 3128 | 'recurring' => (bool) $recurring, |
3129 | 3129 | ); |
3130 | 3130 | |
3131 | - } else { |
|
3132 | - $discounts[ $discount ] = array( |
|
3131 | + } else { |
|
3132 | + $discounts[ $discount ] = array( |
|
3133 | 3133 | 'amount' => $amount, |
3134 | 3134 | 'recurring' => (bool) $recurring, |
3135 | 3135 | ); |
3136 | - } |
|
3136 | + } |
|
3137 | 3137 | |
3138 | 3138 | $this->set_prop( 'discounts', $discount ); |
3139 | 3139 | |
3140 | 3140 | } |
3141 | 3141 | |
3142 | 3142 | /** |
3143 | - * Retrieves a specific discount. |
|
3144 | - * |
|
3145 | - * @since 1.0.19 |
|
3146 | - */ |
|
3147 | - public function get_discount( $discount = false ) { |
|
3143 | + * Retrieves a specific discount. |
|
3144 | + * |
|
3145 | + * @since 1.0.19 |
|
3146 | + */ |
|
3147 | + public function get_discount( $discount = false ) { |
|
3148 | 3148 | |
3149 | - // Backwards compatibilty. |
|
3150 | - if ( empty( $discount ) ) { |
|
3151 | - return $this->get_total_discount(); |
|
3152 | - } |
|
3149 | + // Backwards compatibilty. |
|
3150 | + if ( empty( $discount ) ) { |
|
3151 | + return $this->get_total_discount(); |
|
3152 | + } |
|
3153 | 3153 | |
3154 | 3154 | $discounts = $this->get_discounts(); |
3155 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
3155 | + return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
3156 | 3156 | } |
3157 | 3157 | |
3158 | 3158 | /** |
3159 | - * Removes a specific discount. |
|
3160 | - * |
|
3161 | - * @since 1.0.19 |
|
3162 | - */ |
|
3163 | - public function remove_discount( $discount ) { |
|
3159 | + * Removes a specific discount. |
|
3160 | + * |
|
3161 | + * @since 1.0.19 |
|
3162 | + */ |
|
3163 | + public function remove_discount( $discount ) { |
|
3164 | 3164 | $discounts = $this->get_discounts(); |
3165 | 3165 | if ( isset( $discounts[ $discount ] ) ) { |
3166 | 3166 | unset( $discounts[ $discount ] ); |
@@ -3186,38 +3186,38 @@ discard block |
||
3186 | 3186 | if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) { |
3187 | 3187 | |
3188 | 3188 | $amount = $taxes[ $tax ]['amount'] += $amount; |
3189 | - $taxes[ $tax ] = array( |
|
3189 | + $taxes[ $tax ] = array( |
|
3190 | 3190 | 'amount' => $amount, |
3191 | 3191 | 'recurring' => (bool) $recurring, |
3192 | 3192 | ); |
3193 | 3193 | |
3194 | - } else { |
|
3195 | - $taxes[ $tax ] = array( |
|
3194 | + } else { |
|
3195 | + $taxes[ $tax ] = array( |
|
3196 | 3196 | 'amount' => $amount, |
3197 | 3197 | 'recurring' => (bool) $recurring, |
3198 | 3198 | ); |
3199 | - } |
|
3199 | + } |
|
3200 | 3200 | |
3201 | 3201 | $this->set_prop( 'taxes', $tax ); |
3202 | 3202 | |
3203 | 3203 | } |
3204 | 3204 | |
3205 | 3205 | /** |
3206 | - * Retrieves a specific tax. |
|
3207 | - * |
|
3208 | - * @since 1.0.19 |
|
3209 | - */ |
|
3210 | - public function get_tax( $tax ) { |
|
3206 | + * Retrieves a specific tax. |
|
3207 | + * |
|
3208 | + * @since 1.0.19 |
|
3209 | + */ |
|
3210 | + public function get_tax( $tax ) { |
|
3211 | 3211 | $taxes = $this->get_taxes(); |
3212 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
3212 | + return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
3213 | 3213 | } |
3214 | 3214 | |
3215 | 3215 | /** |
3216 | - * Removes a specific tax. |
|
3217 | - * |
|
3218 | - * @since 1.0.19 |
|
3219 | - */ |
|
3220 | - public function remove_tax( $tax ) { |
|
3216 | + * Removes a specific tax. |
|
3217 | + * |
|
3218 | + * @since 1.0.19 |
|
3219 | + */ |
|
3220 | + public function remove_tax( $tax ) { |
|
3221 | 3221 | $taxes = $this->get_discounts(); |
3222 | 3222 | if ( isset( $taxes[ $tax ] ) ) { |
3223 | 3223 | unset( $taxes[ $tax ] ); |
@@ -3226,160 +3226,160 @@ discard block |
||
3226 | 3226 | } |
3227 | 3227 | |
3228 | 3228 | /** |
3229 | - * Recalculates the invoice subtotal. |
|
3230 | - * |
|
3231 | - * @since 1.0.19 |
|
3232 | - * @return float The recalculated subtotal |
|
3233 | - */ |
|
3234 | - public function recalculate_subtotal() { |
|
3229 | + * Recalculates the invoice subtotal. |
|
3230 | + * |
|
3231 | + * @since 1.0.19 |
|
3232 | + * @return float The recalculated subtotal |
|
3233 | + */ |
|
3234 | + public function recalculate_subtotal() { |
|
3235 | 3235 | $items = $this->get_items(); |
3236 | - $subtotal = 0; |
|
3237 | - $recurring = 0; |
|
3236 | + $subtotal = 0; |
|
3237 | + $recurring = 0; |
|
3238 | 3238 | |
3239 | 3239 | foreach ( $items as $item ) { |
3240 | - $subtotal += $item->get_sub_total(); |
|
3241 | - $recurring += $item->get_recurring_sub_total(); |
|
3240 | + $subtotal += $item->get_sub_total(); |
|
3241 | + $recurring += $item->get_recurring_sub_total(); |
|
3242 | 3242 | } |
3243 | 3243 | |
3244 | - if ( $this->is_renewal() ) { |
|
3245 | - $this->set_subtotal( $recurring ); |
|
3246 | - } else { |
|
3247 | - $this->set_subtotal( $subtotal ); |
|
3248 | - } |
|
3244 | + if ( $this->is_renewal() ) { |
|
3245 | + $this->set_subtotal( $recurring ); |
|
3246 | + } else { |
|
3247 | + $this->set_subtotal( $subtotal ); |
|
3248 | + } |
|
3249 | 3249 | |
3250 | - $this->totals['subtotal'] = array( |
|
3251 | - 'initial' => $subtotal, |
|
3252 | - 'recurring' => $recurring, |
|
3253 | - ); |
|
3250 | + $this->totals['subtotal'] = array( |
|
3251 | + 'initial' => $subtotal, |
|
3252 | + 'recurring' => $recurring, |
|
3253 | + ); |
|
3254 | 3254 | |
3255 | 3255 | return $this->is_renewal() ? $recurring : $subtotal; |
3256 | 3256 | } |
3257 | 3257 | |
3258 | 3258 | /** |
3259 | - * Recalculates the invoice discount total. |
|
3260 | - * |
|
3261 | - * @since 1.0.19 |
|
3262 | - * @return float The recalculated discount |
|
3263 | - */ |
|
3264 | - public function recalculate_total_discount() { |
|
3259 | + * Recalculates the invoice discount total. |
|
3260 | + * |
|
3261 | + * @since 1.0.19 |
|
3262 | + * @return float The recalculated discount |
|
3263 | + */ |
|
3264 | + public function recalculate_total_discount() { |
|
3265 | 3265 | $discounts = $this->get_discounts(); |
3266 | - $discount = 0; |
|
3267 | - $recurring = 0; |
|
3266 | + $discount = 0; |
|
3267 | + $recurring = 0; |
|
3268 | 3268 | |
3269 | 3269 | foreach ( $discounts as $data ) { |
3270 | 3270 | |
3271 | - if ( $data['recurring'] ) { |
|
3272 | - $recurring += $data['amount']; |
|
3273 | - } else { |
|
3274 | - $discount += $data['amount']; |
|
3275 | - } |
|
3271 | + if ( $data['recurring'] ) { |
|
3272 | + $recurring += $data['amount']; |
|
3273 | + } else { |
|
3274 | + $discount += $data['amount']; |
|
3275 | + } |
|
3276 | 3276 | |
3277 | - } |
|
3277 | + } |
|
3278 | 3278 | |
3279 | - if ( $this->is_renewal() ) { |
|
3280 | - $this->set_total_discount( $recurring ); |
|
3281 | - } else { |
|
3282 | - $this->set_total_discount( $discount ); |
|
3283 | - } |
|
3279 | + if ( $this->is_renewal() ) { |
|
3280 | + $this->set_total_discount( $recurring ); |
|
3281 | + } else { |
|
3282 | + $this->set_total_discount( $discount ); |
|
3283 | + } |
|
3284 | 3284 | |
3285 | - $this->totals['discount'] = array( |
|
3286 | - 'initial' => $discount, |
|
3287 | - 'recurring' => $recurring, |
|
3288 | - ); |
|
3285 | + $this->totals['discount'] = array( |
|
3286 | + 'initial' => $discount, |
|
3287 | + 'recurring' => $recurring, |
|
3288 | + ); |
|
3289 | 3289 | |
3290 | - return $this->is_renewal() ? $recurring : $discount; |
|
3290 | + return $this->is_renewal() ? $recurring : $discount; |
|
3291 | 3291 | |
3292 | 3292 | } |
3293 | 3293 | |
3294 | 3294 | /** |
3295 | - * Recalculates the invoice tax total. |
|
3296 | - * |
|
3297 | - * @since 1.0.19 |
|
3298 | - * @return float The recalculated tax |
|
3299 | - */ |
|
3300 | - public function recalculate_total_tax() { |
|
3295 | + * Recalculates the invoice tax total. |
|
3296 | + * |
|
3297 | + * @since 1.0.19 |
|
3298 | + * @return float The recalculated tax |
|
3299 | + */ |
|
3300 | + public function recalculate_total_tax() { |
|
3301 | 3301 | $taxes = $this->get_taxes(); |
3302 | - $tax = 0; |
|
3303 | - $recurring = 0; |
|
3302 | + $tax = 0; |
|
3303 | + $recurring = 0; |
|
3304 | 3304 | |
3305 | 3305 | foreach ( $taxes as $data ) { |
3306 | 3306 | |
3307 | - if ( $data['recurring'] ) { |
|
3308 | - $recurring += $data['amount']; |
|
3309 | - } else { |
|
3310 | - $tax += $data['amount']; |
|
3311 | - } |
|
3307 | + if ( $data['recurring'] ) { |
|
3308 | + $recurring += $data['amount']; |
|
3309 | + } else { |
|
3310 | + $tax += $data['amount']; |
|
3311 | + } |
|
3312 | 3312 | |
3313 | - } |
|
3313 | + } |
|
3314 | 3314 | |
3315 | - if ( $this->is_renewal() ) { |
|
3316 | - $this->set_total_tax( $recurring ); |
|
3317 | - } else { |
|
3318 | - $this->set_total_tax( $tax ); |
|
3319 | - } |
|
3315 | + if ( $this->is_renewal() ) { |
|
3316 | + $this->set_total_tax( $recurring ); |
|
3317 | + } else { |
|
3318 | + $this->set_total_tax( $tax ); |
|
3319 | + } |
|
3320 | 3320 | |
3321 | - $this->totals['tax'] = array( |
|
3322 | - 'initial' => $tax, |
|
3323 | - 'recurring' => $recurring, |
|
3324 | - ); |
|
3321 | + $this->totals['tax'] = array( |
|
3322 | + 'initial' => $tax, |
|
3323 | + 'recurring' => $recurring, |
|
3324 | + ); |
|
3325 | 3325 | |
3326 | - return $this->is_renewal() ? $recurring : $tax; |
|
3326 | + return $this->is_renewal() ? $recurring : $tax; |
|
3327 | 3327 | |
3328 | 3328 | } |
3329 | 3329 | |
3330 | 3330 | /** |
3331 | - * Recalculates the invoice fees total. |
|
3332 | - * |
|
3333 | - * @since 1.0.19 |
|
3334 | - * @return float The recalculated fee |
|
3335 | - */ |
|
3336 | - public function recalculate_total_fees() { |
|
3337 | - $fees = $this->get_fees(); |
|
3338 | - $fee = 0; |
|
3339 | - $recurring = 0; |
|
3331 | + * Recalculates the invoice fees total. |
|
3332 | + * |
|
3333 | + * @since 1.0.19 |
|
3334 | + * @return float The recalculated fee |
|
3335 | + */ |
|
3336 | + public function recalculate_total_fees() { |
|
3337 | + $fees = $this->get_fees(); |
|
3338 | + $fee = 0; |
|
3339 | + $recurring = 0; |
|
3340 | 3340 | |
3341 | 3341 | foreach ( $fees as $data ) { |
3342 | 3342 | |
3343 | - if ( $data['recurring'] ) { |
|
3344 | - $recurring += $data['amount']; |
|
3345 | - } else { |
|
3346 | - $fee += $data['amount']; |
|
3347 | - } |
|
3343 | + if ( $data['recurring'] ) { |
|
3344 | + $recurring += $data['amount']; |
|
3345 | + } else { |
|
3346 | + $fee += $data['amount']; |
|
3347 | + } |
|
3348 | 3348 | |
3349 | - } |
|
3349 | + } |
|
3350 | 3350 | |
3351 | 3351 | if ( $this->is_renewal() ) { |
3352 | - $this->set_total_fees( $recurring ); |
|
3353 | - } else { |
|
3354 | - $this->set_total_fees( $fee ); |
|
3355 | - } |
|
3352 | + $this->set_total_fees( $recurring ); |
|
3353 | + } else { |
|
3354 | + $this->set_total_fees( $fee ); |
|
3355 | + } |
|
3356 | 3356 | |
3357 | - $this->totals['fee'] = array( |
|
3358 | - 'initial' => $fee, |
|
3359 | - 'recurring' => $recurring, |
|
3360 | - ); |
|
3357 | + $this->totals['fee'] = array( |
|
3358 | + 'initial' => $fee, |
|
3359 | + 'recurring' => $recurring, |
|
3360 | + ); |
|
3361 | 3361 | |
3362 | 3362 | $this->set_total_fees( $fee ); |
3363 | 3363 | return $this->is_renewal() ? $recurring : $fee; |
3364 | 3364 | } |
3365 | 3365 | |
3366 | 3366 | /** |
3367 | - * Recalculates the invoice total. |
|
3368 | - * |
|
3369 | - * @since 1.0.19 |
|
3367 | + * Recalculates the invoice total. |
|
3368 | + * |
|
3369 | + * @since 1.0.19 |
|
3370 | 3370 | * @return float The invoice total |
3371 | - */ |
|
3372 | - public function recalculate_total() { |
|
3371 | + */ |
|
3372 | + public function recalculate_total() { |
|
3373 | 3373 | $this->recalculate_subtotal(); |
3374 | 3374 | $this->recalculate_total_fees(); |
3375 | 3375 | $this->recalculate_total_discount(); |
3376 | 3376 | $this->recalculate_total_tax(); |
3377 | - return $this->get_total(); |
|
3378 | - } |
|
3377 | + return $this->get_total(); |
|
3378 | + } |
|
3379 | 3379 | |
3380 | - /** |
|
3381 | - * @deprecated |
|
3382 | - */ |
|
3380 | + /** |
|
3381 | + * @deprecated |
|
3382 | + */ |
|
3383 | 3383 | public function recalculate_totals( $temp = false ) { |
3384 | 3384 | $this->update_items( $temp ); |
3385 | 3385 | $this->save( true ); |
@@ -3443,9 +3443,9 @@ discard block |
||
3443 | 3443 | } |
3444 | 3444 | |
3445 | 3445 | return $note_id; |
3446 | - } |
|
3446 | + } |
|
3447 | 3447 | |
3448 | - /** |
|
3448 | + /** |
|
3449 | 3449 | * Generates a unique key for the invoice. |
3450 | 3450 | */ |
3451 | 3451 | public function generate_key( $string = '' ) { |
@@ -3466,106 +3466,106 @@ discard block |
||
3466 | 3466 | $number = $next_number; |
3467 | 3467 | } |
3468 | 3468 | |
3469 | - $number = wpinv_format_invoice_number( $number, $this->post_type ); |
|
3469 | + $number = wpinv_format_invoice_number( $number, $this->post_type ); |
|
3470 | 3470 | |
3471 | - return $number; |
|
3472 | - } |
|
3471 | + return $number; |
|
3472 | + } |
|
3473 | 3473 | |
3474 | - /** |
|
3475 | - * Handle the status transition. |
|
3476 | - */ |
|
3477 | - protected function status_transition() { |
|
3478 | - $status_transition = $this->status_transition; |
|
3474 | + /** |
|
3475 | + * Handle the status transition. |
|
3476 | + */ |
|
3477 | + protected function status_transition() { |
|
3478 | + $status_transition = $this->status_transition; |
|
3479 | 3479 | |
3480 | - // Reset status transition variable. |
|
3481 | - $this->status_transition = false; |
|
3480 | + // Reset status transition variable. |
|
3481 | + $this->status_transition = false; |
|
3482 | 3482 | |
3483 | - if ( $status_transition ) { |
|
3484 | - try { |
|
3483 | + if ( $status_transition ) { |
|
3484 | + try { |
|
3485 | 3485 | |
3486 | - // Fire a hook for the status change. |
|
3487 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
3486 | + // Fire a hook for the status change. |
|
3487 | + do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition ); |
|
3488 | 3488 | |
3489 | - // @deprecated this is deprecated and will be removed in the future. |
|
3490 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3489 | + // @deprecated this is deprecated and will be removed in the future. |
|
3490 | + do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3491 | 3491 | |
3492 | - if ( ! empty( $status_transition['from'] ) ) { |
|
3492 | + if ( ! empty( $status_transition['from'] ) ) { |
|
3493 | 3493 | |
3494 | - /* translators: 1: old invoice status 2: new invoice status */ |
|
3495 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
3494 | + /* translators: 1: old invoice status 2: new invoice status */ |
|
3495 | + $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
3496 | 3496 | |
3497 | - // Fire another hook. |
|
3498 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
3499 | - do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this ); |
|
3497 | + // Fire another hook. |
|
3498 | + do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this ); |
|
3499 | + do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this ); |
|
3500 | 3500 | |
3501 | - // @deprecated this is deprecated and will be removed in the future. |
|
3502 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3501 | + // @deprecated this is deprecated and will be removed in the future. |
|
3502 | + do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3503 | 3503 | |
3504 | - // Note the transition occurred. |
|
3505 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3504 | + // Note the transition occurred. |
|
3505 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3506 | 3506 | |
3507 | - // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
3508 | - if ( |
|
3509 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed' ), true ) |
|
3510 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3511 | - ) { |
|
3512 | - do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition ); |
|
3513 | - } |
|
3514 | - } else { |
|
3515 | - /* translators: %s: new invoice status */ |
|
3516 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
3507 | + // Work out if this was for a payment, and trigger a payment_status hook instead. |
|
3508 | + if ( |
|
3509 | + in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed' ), true ) |
|
3510 | + && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3511 | + ) { |
|
3512 | + do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition ); |
|
3513 | + } |
|
3514 | + } else { |
|
3515 | + /* translators: %s: new invoice status */ |
|
3516 | + $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
3517 | 3517 | |
3518 | - // Note the transition occurred. |
|
3519 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3518 | + // Note the transition occurred. |
|
3519 | + $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3520 | 3520 | |
3521 | - } |
|
3522 | - } catch ( Exception $e ) { |
|
3523 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
3524 | - } |
|
3525 | - } |
|
3526 | - } |
|
3521 | + } |
|
3522 | + } catch ( Exception $e ) { |
|
3523 | + $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
3524 | + } |
|
3525 | + } |
|
3526 | + } |
|
3527 | 3527 | |
3528 | - /** |
|
3529 | - * Updates an invoice status. |
|
3530 | - */ |
|
3531 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
3528 | + /** |
|
3529 | + * Updates an invoice status. |
|
3530 | + */ |
|
3531 | + public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
3532 | 3532 | |
3533 | - // Fires before updating a status. |
|
3534 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
3533 | + // Fires before updating a status. |
|
3534 | + do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
3535 | 3535 | |
3536 | - // Update the status. |
|
3537 | - $this->set_status( $new_status, $note, $manual ); |
|
3536 | + // Update the status. |
|
3537 | + $this->set_status( $new_status, $note, $manual ); |
|
3538 | 3538 | |
3539 | - // Save the order. |
|
3540 | - return $this->save(); |
|
3539 | + // Save the order. |
|
3540 | + return $this->save(); |
|
3541 | 3541 | |
3542 | - } |
|
3542 | + } |
|
3543 | 3543 | |
3544 | - /** |
|
3545 | - * @deprecated |
|
3546 | - */ |
|
3547 | - public function refresh_item_ids() { |
|
3544 | + /** |
|
3545 | + * @deprecated |
|
3546 | + */ |
|
3547 | + public function refresh_item_ids() { |
|
3548 | 3548 | $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
3549 | 3549 | update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
3550 | - } |
|
3550 | + } |
|
3551 | 3551 | |
3552 | - /** |
|
3553 | - * @deprecated |
|
3554 | - */ |
|
3555 | - public function update_items( $temp = false ) { |
|
3552 | + /** |
|
3553 | + * @deprecated |
|
3554 | + */ |
|
3555 | + public function update_items( $temp = false ) { |
|
3556 | 3556 | |
3557 | - $this->set_items( $this->get_items() ); |
|
3557 | + $this->set_items( $this->get_items() ); |
|
3558 | 3558 | |
3559 | - if ( ! $temp ) { |
|
3560 | - $this->save(); |
|
3561 | - } |
|
3559 | + if ( ! $temp ) { |
|
3560 | + $this->save(); |
|
3561 | + } |
|
3562 | 3562 | |
3563 | 3563 | return $this; |
3564 | - } |
|
3564 | + } |
|
3565 | 3565 | |
3566 | - /** |
|
3567 | - * @deprecated |
|
3568 | - */ |
|
3566 | + /** |
|
3567 | + * @deprecated |
|
3568 | + */ |
|
3569 | 3569 | public function validate_discount() { |
3570 | 3570 | |
3571 | 3571 | $discount_code = $this->get_discount_code(); |
@@ -3581,25 +3581,25 @@ discard block |
||
3581 | 3581 | |
3582 | 3582 | } |
3583 | 3583 | |
3584 | - /** |
|
3585 | - * Refunds an invoice. |
|
3586 | - */ |
|
3584 | + /** |
|
3585 | + * Refunds an invoice. |
|
3586 | + */ |
|
3587 | 3587 | public function refund() { |
3588 | - $this->set_status( 'wpi-refunded' ); |
|
3588 | + $this->set_status( 'wpi-refunded' ); |
|
3589 | 3589 | $this->save(); |
3590 | 3590 | } |
3591 | 3591 | |
3592 | - /** |
|
3593 | - * Save data to the database. |
|
3594 | - * |
|
3595 | - * @since 1.0.19 |
|
3596 | - * @return int invoice ID |
|
3597 | - */ |
|
3598 | - public function save() { |
|
3599 | - $this->maybe_set_date_paid(); |
|
3600 | - parent::save(); |
|
3601 | - $this->status_transition(); |
|
3602 | - return $this->get_id(); |
|
3603 | - } |
|
3592 | + /** |
|
3593 | + * Save data to the database. |
|
3594 | + * |
|
3595 | + * @since 1.0.19 |
|
3596 | + * @return int invoice ID |
|
3597 | + */ |
|
3598 | + public function save() { |
|
3599 | + $this->maybe_set_date_paid(); |
|
3600 | + parent::save(); |
|
3601 | + $this->status_transition(); |
|
3602 | + return $this->get_id(); |
|
3603 | + } |
|
3604 | 3604 | |
3605 | 3605 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -10,753 +10,753 @@ discard block |
||
10 | 10 | class GetPaid_Payment_Form_Submission { |
11 | 11 | |
12 | 12 | /** |
13 | - * Submission ID |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
17 | - public $id = null; |
|
13 | + * Submission ID |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | + public $id = null; |
|
18 | 18 | |
19 | - /** |
|
20 | - * Sets the associated payment form. |
|
21 | - * |
|
22 | - * @var GetPaid_Payment_Form |
|
23 | - */ |
|
19 | + /** |
|
20 | + * Sets the associated payment form. |
|
21 | + * |
|
22 | + * @var GetPaid_Payment_Form |
|
23 | + */ |
|
24 | 24 | protected $payment_form = null; |
25 | 25 | |
26 | 26 | /** |
27 | - * The country for the submission. |
|
28 | - * |
|
29 | - * @var string |
|
30 | - */ |
|
31 | - public $country = null; |
|
32 | - |
|
33 | - /** |
|
34 | - * The state for the submission. |
|
35 | - * |
|
36 | - * @since 1.0.19 |
|
37 | - * @var string |
|
38 | - */ |
|
39 | - public $state = null; |
|
40 | - |
|
41 | - /** |
|
42 | - * The invoice associated with the submission. |
|
43 | - * |
|
44 | - * @var WPInv_Invoice |
|
45 | - */ |
|
46 | - protected $invoice = null; |
|
47 | - |
|
48 | - /** |
|
49 | - * The discount associated with the submission. |
|
50 | - * |
|
51 | - * @var WPInv_Discount |
|
52 | - */ |
|
53 | - protected $discount = null; |
|
54 | - |
|
55 | - /** |
|
56 | - * The raw submission data. |
|
57 | - * |
|
58 | - * @var array |
|
59 | - */ |
|
60 | - protected $data = null; |
|
61 | - |
|
62 | - /** |
|
63 | - * Whether this submission contains a recurring item. |
|
64 | - * |
|
65 | - * @var bool |
|
66 | - */ |
|
67 | - public $has_recurring = false; |
|
68 | - |
|
69 | - /** |
|
70 | - * The sub total amount for the submission. |
|
71 | - * |
|
72 | - * @var float |
|
73 | - */ |
|
74 | - public $subtotal_amount = 0; |
|
75 | - |
|
76 | - /** |
|
77 | - * The total discount amount for the submission. |
|
78 | - * |
|
79 | - * @var float |
|
80 | - */ |
|
81 | - protected $total_discount_amount = 0; |
|
82 | - |
|
83 | - /** |
|
84 | - * The total tax amount for the submission. |
|
85 | - * |
|
86 | - * @var float |
|
87 | - */ |
|
88 | - protected $total_tax_amount = 0; |
|
89 | - |
|
90 | - /** |
|
91 | - * The total fees amount for the submission. |
|
92 | - * |
|
93 | - * @var float |
|
94 | - */ |
|
95 | - protected $total_fees_amount = 0; |
|
96 | - |
|
97 | - /** |
|
98 | - * An array of fees for the submission. |
|
99 | - * |
|
100 | - * @var array |
|
101 | - */ |
|
102 | - protected $fees = array(); |
|
103 | - |
|
104 | - /** |
|
105 | - * An array of discounts for the submission. |
|
106 | - * |
|
107 | - * @var array |
|
108 | - */ |
|
109 | - protected $discounts = array(); |
|
110 | - |
|
111 | - /** |
|
112 | - * An array of taxes for the submission. |
|
113 | - * |
|
114 | - * @var array |
|
115 | - */ |
|
116 | - protected $taxes = array(); |
|
117 | - |
|
118 | - /** |
|
119 | - * An array of items for the submission. |
|
120 | - * |
|
121 | - * @var GetPaid_Form_Item[] |
|
122 | - */ |
|
123 | - protected $items = array(); |
|
124 | - |
|
125 | - /** |
|
126 | - * The last error. |
|
127 | - * |
|
128 | - * @var string |
|
129 | - */ |
|
130 | - public $last_error = null; |
|
131 | - |
|
132 | - /** |
|
133 | - * Is the discount valid? |
|
134 | - * |
|
135 | - * @var string |
|
136 | - */ |
|
137 | - public $is_discount_valid = true; |
|
27 | + * The country for the submission. |
|
28 | + * |
|
29 | + * @var string |
|
30 | + */ |
|
31 | + public $country = null; |
|
32 | + |
|
33 | + /** |
|
34 | + * The state for the submission. |
|
35 | + * |
|
36 | + * @since 1.0.19 |
|
37 | + * @var string |
|
38 | + */ |
|
39 | + public $state = null; |
|
40 | + |
|
41 | + /** |
|
42 | + * The invoice associated with the submission. |
|
43 | + * |
|
44 | + * @var WPInv_Invoice |
|
45 | + */ |
|
46 | + protected $invoice = null; |
|
47 | + |
|
48 | + /** |
|
49 | + * The discount associated with the submission. |
|
50 | + * |
|
51 | + * @var WPInv_Discount |
|
52 | + */ |
|
53 | + protected $discount = null; |
|
54 | + |
|
55 | + /** |
|
56 | + * The raw submission data. |
|
57 | + * |
|
58 | + * @var array |
|
59 | + */ |
|
60 | + protected $data = null; |
|
61 | + |
|
62 | + /** |
|
63 | + * Whether this submission contains a recurring item. |
|
64 | + * |
|
65 | + * @var bool |
|
66 | + */ |
|
67 | + public $has_recurring = false; |
|
68 | + |
|
69 | + /** |
|
70 | + * The sub total amount for the submission. |
|
71 | + * |
|
72 | + * @var float |
|
73 | + */ |
|
74 | + public $subtotal_amount = 0; |
|
75 | + |
|
76 | + /** |
|
77 | + * The total discount amount for the submission. |
|
78 | + * |
|
79 | + * @var float |
|
80 | + */ |
|
81 | + protected $total_discount_amount = 0; |
|
82 | + |
|
83 | + /** |
|
84 | + * The total tax amount for the submission. |
|
85 | + * |
|
86 | + * @var float |
|
87 | + */ |
|
88 | + protected $total_tax_amount = 0; |
|
89 | + |
|
90 | + /** |
|
91 | + * The total fees amount for the submission. |
|
92 | + * |
|
93 | + * @var float |
|
94 | + */ |
|
95 | + protected $total_fees_amount = 0; |
|
96 | + |
|
97 | + /** |
|
98 | + * An array of fees for the submission. |
|
99 | + * |
|
100 | + * @var array |
|
101 | + */ |
|
102 | + protected $fees = array(); |
|
138 | 103 | |
139 | 104 | /** |
140 | - * Class constructor. |
|
141 | - * |
|
142 | - */ |
|
143 | - public function __construct() { |
|
105 | + * An array of discounts for the submission. |
|
106 | + * |
|
107 | + * @var array |
|
108 | + */ |
|
109 | + protected $discounts = array(); |
|
144 | 110 | |
145 | - // Set the state and country to the default state and country. |
|
146 | - $this->country = wpinv_default_billing_country(); |
|
147 | - $this->state = wpinv_get_default_state(); |
|
111 | + /** |
|
112 | + * An array of taxes for the submission. |
|
113 | + * |
|
114 | + * @var array |
|
115 | + */ |
|
116 | + protected $taxes = array(); |
|
117 | + |
|
118 | + /** |
|
119 | + * An array of items for the submission. |
|
120 | + * |
|
121 | + * @var GetPaid_Form_Item[] |
|
122 | + */ |
|
123 | + protected $items = array(); |
|
124 | + |
|
125 | + /** |
|
126 | + * The last error. |
|
127 | + * |
|
128 | + * @var string |
|
129 | + */ |
|
130 | + public $last_error = null; |
|
131 | + |
|
132 | + /** |
|
133 | + * Is the discount valid? |
|
134 | + * |
|
135 | + * @var string |
|
136 | + */ |
|
137 | + public $is_discount_valid = true; |
|
148 | 138 | |
149 | - // Do we have an actual submission? |
|
150 | - if ( isset( $_POST['getpaid_payment_form_submission'] ) ) { |
|
151 | - $this->load_data( $_POST ); |
|
152 | - } |
|
153 | - } |
|
139 | + /** |
|
140 | + * Class constructor. |
|
141 | + * |
|
142 | + */ |
|
143 | + public function __construct() { |
|
144 | + |
|
145 | + // Set the state and country to the default state and country. |
|
146 | + $this->country = wpinv_default_billing_country(); |
|
147 | + $this->state = wpinv_get_default_state(); |
|
148 | + |
|
149 | + // Do we have an actual submission? |
|
150 | + if ( isset( $_POST['getpaid_payment_form_submission'] ) ) { |
|
151 | + $this->load_data( $_POST ); |
|
152 | + } |
|
153 | + } |
|
154 | 154 | |
155 | - /** |
|
156 | - * Loads submission data. |
|
157 | - * |
|
158 | - * @param array $data |
|
159 | - */ |
|
160 | - public function load_data( $data ) { |
|
155 | + /** |
|
156 | + * Loads submission data. |
|
157 | + * |
|
158 | + * @param array $data |
|
159 | + */ |
|
160 | + public function load_data( $data ) { |
|
161 | 161 | |
162 | - // Prepare submitted data... |
|
163 | - $data = wp_unslash( $data ); |
|
162 | + // Prepare submitted data... |
|
163 | + $data = wp_unslash( $data ); |
|
164 | 164 | |
165 | - // Fitter the data. |
|
166 | - $data = apply_filters( 'getpaid_submission_data', $data, $this ); |
|
165 | + // Fitter the data. |
|
166 | + $data = apply_filters( 'getpaid_submission_data', $data, $this ); |
|
167 | 167 | |
168 | - $this->data = $data; |
|
168 | + $this->data = $data; |
|
169 | 169 | |
170 | - $this->id = md5( wp_json_encode( $data ) ); |
|
170 | + $this->id = md5( wp_json_encode( $data ) ); |
|
171 | 171 | |
172 | - // Every submission needs an active payment form. |
|
173 | - if ( empty( $data['form_id'] ) ) { |
|
174 | - $this->last_error = __( 'Missing payment form', 'invoicing' ); |
|
172 | + // Every submission needs an active payment form. |
|
173 | + if ( empty( $data['form_id'] ) ) { |
|
174 | + $this->last_error = __( 'Missing payment form', 'invoicing' ); |
|
175 | 175 | return; |
176 | - } |
|
176 | + } |
|
177 | 177 | |
178 | - // Fetch the payment form. |
|
179 | - $form = new GetPaid_Payment_Form( $data['form_id'] ); |
|
178 | + // Fetch the payment form. |
|
179 | + $form = new GetPaid_Payment_Form( $data['form_id'] ); |
|
180 | 180 | |
181 | - if ( ! $form->is_active() ) { |
|
182 | - $this->last_error = __( 'Payment form not active', 'invoicing' ); |
|
183 | - return; |
|
184 | - } |
|
181 | + if ( ! $form->is_active() ) { |
|
182 | + $this->last_error = __( 'Payment form not active', 'invoicing' ); |
|
183 | + return; |
|
184 | + } |
|
185 | 185 | |
186 | - // Fetch the payment form. |
|
187 | - $this->payment_form = $form; |
|
186 | + // Fetch the payment form. |
|
187 | + $this->payment_form = $form; |
|
188 | 188 | |
189 | - // For existing invoices, make sure that it is valid. |
|
189 | + // For existing invoices, make sure that it is valid. |
|
190 | 190 | if ( ! empty( $data['invoice_id'] ) ) { |
191 | 191 | $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
192 | 192 | |
193 | 193 | if ( empty( $invoice ) ) { |
194 | - $this->last_error = __( 'Invalid invoice', 'invoicing' ); |
|
194 | + $this->last_error = __( 'Invalid invoice', 'invoicing' ); |
|
195 | 195 | return; |
196 | 196 | } |
197 | 197 | |
198 | - $this->payment_form->set_items( $invoice->get_items() ); |
|
198 | + $this->payment_form->set_items( $invoice->get_items() ); |
|
199 | 199 | |
200 | - $this->country = $invoice->get_country(); |
|
201 | - $this->state = $invoice->get_state(); |
|
200 | + $this->country = $invoice->get_country(); |
|
201 | + $this->state = $invoice->get_state(); |
|
202 | 202 | |
203 | - // Default forms do not have items. |
|
203 | + // Default forms do not have items. |
|
204 | 204 | } else if ( $form->is_default() && isset( $data['form_items'] ) ) { |
205 | - $this->payment_form->set_items( $data['form_items'] ); |
|
206 | - } |
|
207 | - |
|
208 | - // User's country. |
|
209 | - if ( ! empty( $data['wpinv_country'] ) ) { |
|
210 | - $this->country = $data['wpinv_country']; |
|
211 | - } |
|
212 | - |
|
213 | - // User's state. |
|
214 | - if ( ! empty( $data['wpinv_state'] ) ) { |
|
215 | - $this->country = $data['wpinv_state']; |
|
216 | - } |
|
217 | - |
|
218 | - // Handle discounts. |
|
219 | - $this->maybe_prepare_discount(); |
|
220 | - |
|
221 | - // Handle items. |
|
222 | - $selected_items = array(); |
|
223 | - if ( ! empty( $data['getpaid-items'] ) ) { |
|
224 | - $selected_items = wpinv_clean( $data['getpaid-items'] ); |
|
225 | - } |
|
226 | - |
|
227 | - foreach ( $this->payment_form->get_items() as $item ) { |
|
228 | - |
|
229 | - // Continue if this is an optional item and it has not been selected. |
|
230 | - if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) { |
|
231 | - continue; |
|
232 | - } |
|
233 | - |
|
234 | - // (maybe) let customers change the quantities and prices. |
|
235 | - if ( isset( $selected_items[ $item->get_id() ] ) ) { |
|
236 | - |
|
237 | - // Maybe change the quantities. |
|
238 | - if ( $item->allows_quantities() && is_numeric( $selected_items[ $item->get_id() ]['quantity'] ) ) { |
|
239 | - $item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] ); |
|
240 | - } |
|
241 | - |
|
242 | - // Maybe change the price. |
|
243 | - if ( $item->user_can_set_their_price() ) { |
|
244 | - $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] ); |
|
245 | - |
|
246 | - // But don't get lower than the minimum price. |
|
247 | - if ( $price < $item->get_minimum_price() ) { |
|
248 | - $price = $item->get_minimum_price(); |
|
249 | - } |
|
250 | - |
|
251 | - $item->set_price( $price ); |
|
252 | - |
|
253 | - } |
|
254 | - |
|
255 | - } |
|
256 | - |
|
257 | - // Add the item to the form. |
|
258 | - $this->add_item( $item ); |
|
259 | - |
|
260 | - } |
|
261 | - |
|
262 | - // Fired when we are done processing a submission. |
|
263 | - do_action( 'getpaid_process_submission', $this ); |
|
264 | - |
|
265 | - // Remove invalid discount. |
|
266 | - $this->maybe_remove_discount(); |
|
267 | - |
|
268 | - } |
|
269 | - |
|
270 | - /** |
|
271 | - * Returns the payment form. |
|
272 | - * |
|
273 | - * @since 1.0.19 |
|
274 | - * @return GetPaid_Payment_Form |
|
275 | - */ |
|
276 | - public function get_payment_form() { |
|
277 | - return $this->payment_form; |
|
278 | - } |
|
279 | - |
|
280 | - /** |
|
281 | - * Returns the associated invoice. |
|
282 | - * |
|
283 | - * @since 1.0.19 |
|
284 | - * @return WPInv_Invoice |
|
285 | - */ |
|
286 | - public function get_invoice() { |
|
287 | - return $this->invoice; |
|
288 | - } |
|
289 | - |
|
290 | - /** |
|
291 | - * Checks whether there is an invoice associated with this submission. |
|
292 | - * |
|
293 | - * @since 1.0.19 |
|
294 | - * @return bool |
|
295 | - */ |
|
296 | - public function has_invoice() { |
|
297 | - return ! empty( $this->invoice ); |
|
298 | - } |
|
205 | + $this->payment_form->set_items( $data['form_items'] ); |
|
206 | + } |
|
207 | + |
|
208 | + // User's country. |
|
209 | + if ( ! empty( $data['wpinv_country'] ) ) { |
|
210 | + $this->country = $data['wpinv_country']; |
|
211 | + } |
|
212 | + |
|
213 | + // User's state. |
|
214 | + if ( ! empty( $data['wpinv_state'] ) ) { |
|
215 | + $this->country = $data['wpinv_state']; |
|
216 | + } |
|
217 | + |
|
218 | + // Handle discounts. |
|
219 | + $this->maybe_prepare_discount(); |
|
220 | + |
|
221 | + // Handle items. |
|
222 | + $selected_items = array(); |
|
223 | + if ( ! empty( $data['getpaid-items'] ) ) { |
|
224 | + $selected_items = wpinv_clean( $data['getpaid-items'] ); |
|
225 | + } |
|
226 | + |
|
227 | + foreach ( $this->payment_form->get_items() as $item ) { |
|
228 | + |
|
229 | + // Continue if this is an optional item and it has not been selected. |
|
230 | + if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) { |
|
231 | + continue; |
|
232 | + } |
|
233 | + |
|
234 | + // (maybe) let customers change the quantities and prices. |
|
235 | + if ( isset( $selected_items[ $item->get_id() ] ) ) { |
|
236 | + |
|
237 | + // Maybe change the quantities. |
|
238 | + if ( $item->allows_quantities() && is_numeric( $selected_items[ $item->get_id() ]['quantity'] ) ) { |
|
239 | + $item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] ); |
|
240 | + } |
|
241 | + |
|
242 | + // Maybe change the price. |
|
243 | + if ( $item->user_can_set_their_price() ) { |
|
244 | + $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] ); |
|
245 | + |
|
246 | + // But don't get lower than the minimum price. |
|
247 | + if ( $price < $item->get_minimum_price() ) { |
|
248 | + $price = $item->get_minimum_price(); |
|
249 | + } |
|
250 | + |
|
251 | + $item->set_price( $price ); |
|
252 | + |
|
253 | + } |
|
254 | + |
|
255 | + } |
|
256 | + |
|
257 | + // Add the item to the form. |
|
258 | + $this->add_item( $item ); |
|
259 | + |
|
260 | + } |
|
261 | + |
|
262 | + // Fired when we are done processing a submission. |
|
263 | + do_action( 'getpaid_process_submission', $this ); |
|
264 | + |
|
265 | + // Remove invalid discount. |
|
266 | + $this->maybe_remove_discount(); |
|
267 | + |
|
268 | + } |
|
269 | + |
|
270 | + /** |
|
271 | + * Returns the payment form. |
|
272 | + * |
|
273 | + * @since 1.0.19 |
|
274 | + * @return GetPaid_Payment_Form |
|
275 | + */ |
|
276 | + public function get_payment_form() { |
|
277 | + return $this->payment_form; |
|
278 | + } |
|
279 | + |
|
280 | + /** |
|
281 | + * Returns the associated invoice. |
|
282 | + * |
|
283 | + * @since 1.0.19 |
|
284 | + * @return WPInv_Invoice |
|
285 | + */ |
|
286 | + public function get_invoice() { |
|
287 | + return $this->invoice; |
|
288 | + } |
|
289 | + |
|
290 | + /** |
|
291 | + * Checks whether there is an invoice associated with this submission. |
|
292 | + * |
|
293 | + * @since 1.0.19 |
|
294 | + * @return bool |
|
295 | + */ |
|
296 | + public function has_invoice() { |
|
297 | + return ! empty( $this->invoice ); |
|
298 | + } |
|
299 | 299 | |
300 | - /** |
|
301 | - * Returns the appropriate currency for the submission. |
|
302 | - * |
|
303 | - * @since 1.0.19 |
|
304 | - * @return string |
|
305 | - */ |
|
306 | - public function get_currency() { |
|
307 | - if ( $this->has_invoice() ) { |
|
308 | - return $this->invoice->get_currency(); |
|
309 | - } |
|
310 | - return wpinv_get_currency(); |
|
311 | - } |
|
312 | - |
|
313 | - /** |
|
314 | - * Returns the raw submission data. |
|
315 | - * |
|
316 | - * @since 1.0.19 |
|
317 | - * @return array |
|
318 | - */ |
|
319 | - public function get_data() { |
|
320 | - return $this->data; |
|
321 | - } |
|
322 | - |
|
323 | - /** |
|
324 | - * Checks if a required field is set. |
|
325 | - * |
|
326 | - * @since 1.0.19 |
|
327 | - */ |
|
328 | - public function is_required_field_set( $field ) { |
|
329 | - return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] ); |
|
330 | - } |
|
331 | - |
|
332 | - ///////// Items ////////////// |
|
333 | - |
|
334 | - /** |
|
335 | - * Adds an item to the submission. |
|
336 | - * |
|
337 | - * @since 1.0.19 |
|
338 | - * @param GetPaid_Form_Item $item |
|
339 | - */ |
|
340 | - public function add_item( $item ) { |
|
341 | - |
|
342 | - // Make sure that it is available for purchase. |
|
343 | - if ( ! $item->can_purchase() ) { |
|
344 | - return; |
|
345 | - } |
|
346 | - |
|
347 | - // Do we have a recurring item? |
|
348 | - if ( $item->is_recurring() ) { |
|
349 | - |
|
350 | - if ( $this->has_recurring ) { |
|
351 | - $this->last_error = __( 'You can only buy one recurring item at a time.', 'invoicing' ); |
|
352 | - } |
|
353 | - |
|
354 | - $this->has_recurring = true; |
|
355 | - |
|
356 | - } |
|
357 | - |
|
358 | - $this->items[ $item->get_id() ] = $item; |
|
359 | - |
|
360 | - $this->subtotal_amount += $item->get_sub_total(); |
|
361 | - |
|
362 | - $this->process_item_discount( $item ); |
|
363 | - |
|
364 | - $this->process_item_tax( $item ); |
|
365 | - } |
|
366 | - |
|
367 | - /** |
|
368 | - * Retrieves a specific item. |
|
369 | - * |
|
370 | - * @since 1.0.19 |
|
371 | - */ |
|
372 | - public function get_item( $item_id ) { |
|
373 | - return isset( $this->items[ $item_id ] ) ? $this->items[ $item_id ] : null; |
|
374 | - } |
|
375 | - |
|
376 | - /** |
|
377 | - * Returns all items. |
|
378 | - * |
|
379 | - * @since 1.0.19 |
|
380 | - * @return GetPaid_Form_Item[] |
|
381 | - */ |
|
382 | - public function get_items() { |
|
383 | - return $this->items; |
|
384 | - } |
|
385 | - |
|
386 | - ///////// TAXES ////////////// |
|
387 | - |
|
388 | - /** |
|
389 | - * Adds a tax to the submission. |
|
390 | - * |
|
391 | - * @since 1.0.19 |
|
392 | - */ |
|
393 | - public function add_tax( $name, $amount ) { |
|
394 | - $amount = (float) wpinv_sanitize_amount( $amount ); |
|
395 | - |
|
396 | - $this->total_tax_amount += $amount; |
|
397 | - |
|
398 | - if ( isset( $this->taxes[ $name ] ) ) { |
|
399 | - $this->taxes[ $name ] += $amount; |
|
400 | - } else { |
|
401 | - $this->taxes[ $name ] = $amount; |
|
402 | - } |
|
403 | - |
|
404 | - } |
|
405 | - |
|
406 | - /** |
|
407 | - * Whether or not we'll use taxes for the submission. |
|
408 | - * |
|
409 | - * @since 1.0.19 |
|
410 | - */ |
|
411 | - public function use_taxes() { |
|
412 | - |
|
413 | - $use_taxes = wpinv_use_taxes(); |
|
414 | - |
|
415 | - if ( $this->has_invoice() && $this->invoice->disable_taxes ) { |
|
416 | - $use_taxes = false; |
|
417 | - } |
|
418 | - |
|
419 | - return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this ); |
|
420 | - |
|
421 | - } |
|
422 | - |
|
423 | - /** |
|
424 | - * Maybe process tax. |
|
425 | - * |
|
426 | - * @since 1.0.19 |
|
427 | - * @param GetPaid_Form_Item $item |
|
428 | - */ |
|
429 | - public function process_item_tax( $item ) { |
|
430 | - |
|
431 | - // Abort early if we're not using taxes. |
|
432 | - if ( ! $this->use_taxes() ) { |
|
433 | - return; |
|
434 | - } |
|
435 | - |
|
436 | - $rate = wpinv_get_tax_rate( $this->country, $this->state, $item->get_id() ); |
|
437 | - $price = $item->get_sub_total(); |
|
438 | - |
|
439 | - if ( wpinv_prices_include_tax() ) { |
|
440 | - $item_tax = $price - ( $price - $price * $rate * 0.01 ); |
|
441 | - } else { |
|
442 | - $item_tax = $price * $rate * 0.01; |
|
443 | - } |
|
444 | - |
|
445 | - $this->add_tax( 'Tax', $item_tax ); |
|
446 | - |
|
447 | - } |
|
448 | - |
|
449 | - /** |
|
450 | - * Returns the total tax amount. |
|
451 | - * |
|
452 | - * @since 1.0.19 |
|
453 | - */ |
|
454 | - public function get_total_tax() { |
|
455 | - return $this->total_tax_amount; |
|
456 | - } |
|
457 | - |
|
458 | - /** |
|
459 | - * Retrieves a specific tax. |
|
460 | - * |
|
461 | - * @since 1.0.19 |
|
462 | - */ |
|
463 | - public function get_tax( $name ) { |
|
464 | - return isset( $this->taxes[ $name ] ) ? $this->taxes[ $name ] : 0; |
|
465 | - } |
|
466 | - |
|
467 | - /** |
|
468 | - * Returns all taxes. |
|
469 | - * |
|
470 | - * @since 1.0.19 |
|
471 | - */ |
|
472 | - public function get_taxes() { |
|
473 | - return $this->taxes; |
|
474 | - } |
|
475 | - |
|
476 | - ///////// DISCOUNTS ////////////// |
|
477 | - |
|
478 | - /** |
|
479 | - * Adds a discount to the submission. |
|
480 | - * |
|
481 | - * @since 1.0.19 |
|
482 | - */ |
|
483 | - public function add_discount( $name, $amount ) { |
|
484 | - $amount = wpinv_sanitize_amount( $amount ); |
|
485 | - |
|
486 | - $this->total_discount_amount += $amount; |
|
487 | - |
|
488 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
489 | - $this->discounts[ $name ] += $amount; |
|
490 | - } else { |
|
491 | - $this->discounts[ $name ] = $amount; |
|
492 | - } |
|
493 | - |
|
494 | - } |
|
495 | - |
|
496 | - /** |
|
497 | - * Removes a discount from the submission. |
|
498 | - * |
|
499 | - * @since 1.0.19 |
|
500 | - */ |
|
501 | - public function remove_discount( $name ) { |
|
502 | - |
|
503 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
504 | - $this->total_discount_amount -= $this->discounts[ $name ]; |
|
505 | - unset( $this->discounts[ $name ] ); |
|
506 | - } |
|
507 | - |
|
508 | - } |
|
509 | - |
|
510 | - /** |
|
511 | - * Checks whether there is a discount code associated with this submission. |
|
512 | - * |
|
513 | - * @since 1.0.19 |
|
514 | - * @return bool |
|
515 | - */ |
|
516 | - public function has_discount_code() { |
|
517 | - return ! empty( $this->discount ); |
|
518 | - } |
|
519 | - |
|
520 | - /** |
|
521 | - * Returns the discount code. |
|
522 | - * |
|
523 | - * @since 1.0.19 |
|
524 | - * @return bool |
|
525 | - */ |
|
526 | - public function get_discount_code() { |
|
527 | - return $this->has_discount_code() ? $this->discount->code : ''; |
|
528 | - } |
|
529 | - |
|
530 | - /** |
|
531 | - * Prepares an item discount. |
|
532 | - * |
|
533 | - * @since 1.0.19 |
|
534 | - */ |
|
535 | - public function maybe_prepare_discount() { |
|
536 | - |
|
537 | - // Do we have a discount? |
|
538 | - if ( empty( $this->data['discount'] ) ) { |
|
539 | - return; |
|
540 | - } |
|
541 | - |
|
542 | - // Fetch the discount. |
|
543 | - $discount = wpinv_get_discount_obj( $this->data['discount'] ); |
|
544 | - |
|
545 | - // Ensure it is active. |
|
300 | + /** |
|
301 | + * Returns the appropriate currency for the submission. |
|
302 | + * |
|
303 | + * @since 1.0.19 |
|
304 | + * @return string |
|
305 | + */ |
|
306 | + public function get_currency() { |
|
307 | + if ( $this->has_invoice() ) { |
|
308 | + return $this->invoice->get_currency(); |
|
309 | + } |
|
310 | + return wpinv_get_currency(); |
|
311 | + } |
|
312 | + |
|
313 | + /** |
|
314 | + * Returns the raw submission data. |
|
315 | + * |
|
316 | + * @since 1.0.19 |
|
317 | + * @return array |
|
318 | + */ |
|
319 | + public function get_data() { |
|
320 | + return $this->data; |
|
321 | + } |
|
322 | + |
|
323 | + /** |
|
324 | + * Checks if a required field is set. |
|
325 | + * |
|
326 | + * @since 1.0.19 |
|
327 | + */ |
|
328 | + public function is_required_field_set( $field ) { |
|
329 | + return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] ); |
|
330 | + } |
|
331 | + |
|
332 | + ///////// Items ////////////// |
|
333 | + |
|
334 | + /** |
|
335 | + * Adds an item to the submission. |
|
336 | + * |
|
337 | + * @since 1.0.19 |
|
338 | + * @param GetPaid_Form_Item $item |
|
339 | + */ |
|
340 | + public function add_item( $item ) { |
|
341 | + |
|
342 | + // Make sure that it is available for purchase. |
|
343 | + if ( ! $item->can_purchase() ) { |
|
344 | + return; |
|
345 | + } |
|
346 | + |
|
347 | + // Do we have a recurring item? |
|
348 | + if ( $item->is_recurring() ) { |
|
349 | + |
|
350 | + if ( $this->has_recurring ) { |
|
351 | + $this->last_error = __( 'You can only buy one recurring item at a time.', 'invoicing' ); |
|
352 | + } |
|
353 | + |
|
354 | + $this->has_recurring = true; |
|
355 | + |
|
356 | + } |
|
357 | + |
|
358 | + $this->items[ $item->get_id() ] = $item; |
|
359 | + |
|
360 | + $this->subtotal_amount += $item->get_sub_total(); |
|
361 | + |
|
362 | + $this->process_item_discount( $item ); |
|
363 | + |
|
364 | + $this->process_item_tax( $item ); |
|
365 | + } |
|
366 | + |
|
367 | + /** |
|
368 | + * Retrieves a specific item. |
|
369 | + * |
|
370 | + * @since 1.0.19 |
|
371 | + */ |
|
372 | + public function get_item( $item_id ) { |
|
373 | + return isset( $this->items[ $item_id ] ) ? $this->items[ $item_id ] : null; |
|
374 | + } |
|
375 | + |
|
376 | + /** |
|
377 | + * Returns all items. |
|
378 | + * |
|
379 | + * @since 1.0.19 |
|
380 | + * @return GetPaid_Form_Item[] |
|
381 | + */ |
|
382 | + public function get_items() { |
|
383 | + return $this->items; |
|
384 | + } |
|
385 | + |
|
386 | + ///////// TAXES ////////////// |
|
387 | + |
|
388 | + /** |
|
389 | + * Adds a tax to the submission. |
|
390 | + * |
|
391 | + * @since 1.0.19 |
|
392 | + */ |
|
393 | + public function add_tax( $name, $amount ) { |
|
394 | + $amount = (float) wpinv_sanitize_amount( $amount ); |
|
395 | + |
|
396 | + $this->total_tax_amount += $amount; |
|
397 | + |
|
398 | + if ( isset( $this->taxes[ $name ] ) ) { |
|
399 | + $this->taxes[ $name ] += $amount; |
|
400 | + } else { |
|
401 | + $this->taxes[ $name ] = $amount; |
|
402 | + } |
|
403 | + |
|
404 | + } |
|
405 | + |
|
406 | + /** |
|
407 | + * Whether or not we'll use taxes for the submission. |
|
408 | + * |
|
409 | + * @since 1.0.19 |
|
410 | + */ |
|
411 | + public function use_taxes() { |
|
412 | + |
|
413 | + $use_taxes = wpinv_use_taxes(); |
|
414 | + |
|
415 | + if ( $this->has_invoice() && $this->invoice->disable_taxes ) { |
|
416 | + $use_taxes = false; |
|
417 | + } |
|
418 | + |
|
419 | + return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this ); |
|
420 | + |
|
421 | + } |
|
422 | + |
|
423 | + /** |
|
424 | + * Maybe process tax. |
|
425 | + * |
|
426 | + * @since 1.0.19 |
|
427 | + * @param GetPaid_Form_Item $item |
|
428 | + */ |
|
429 | + public function process_item_tax( $item ) { |
|
430 | + |
|
431 | + // Abort early if we're not using taxes. |
|
432 | + if ( ! $this->use_taxes() ) { |
|
433 | + return; |
|
434 | + } |
|
435 | + |
|
436 | + $rate = wpinv_get_tax_rate( $this->country, $this->state, $item->get_id() ); |
|
437 | + $price = $item->get_sub_total(); |
|
438 | + |
|
439 | + if ( wpinv_prices_include_tax() ) { |
|
440 | + $item_tax = $price - ( $price - $price * $rate * 0.01 ); |
|
441 | + } else { |
|
442 | + $item_tax = $price * $rate * 0.01; |
|
443 | + } |
|
444 | + |
|
445 | + $this->add_tax( 'Tax', $item_tax ); |
|
446 | + |
|
447 | + } |
|
448 | + |
|
449 | + /** |
|
450 | + * Returns the total tax amount. |
|
451 | + * |
|
452 | + * @since 1.0.19 |
|
453 | + */ |
|
454 | + public function get_total_tax() { |
|
455 | + return $this->total_tax_amount; |
|
456 | + } |
|
457 | + |
|
458 | + /** |
|
459 | + * Retrieves a specific tax. |
|
460 | + * |
|
461 | + * @since 1.0.19 |
|
462 | + */ |
|
463 | + public function get_tax( $name ) { |
|
464 | + return isset( $this->taxes[ $name ] ) ? $this->taxes[ $name ] : 0; |
|
465 | + } |
|
466 | + |
|
467 | + /** |
|
468 | + * Returns all taxes. |
|
469 | + * |
|
470 | + * @since 1.0.19 |
|
471 | + */ |
|
472 | + public function get_taxes() { |
|
473 | + return $this->taxes; |
|
474 | + } |
|
475 | + |
|
476 | + ///////// DISCOUNTS ////////////// |
|
477 | + |
|
478 | + /** |
|
479 | + * Adds a discount to the submission. |
|
480 | + * |
|
481 | + * @since 1.0.19 |
|
482 | + */ |
|
483 | + public function add_discount( $name, $amount ) { |
|
484 | + $amount = wpinv_sanitize_amount( $amount ); |
|
485 | + |
|
486 | + $this->total_discount_amount += $amount; |
|
487 | + |
|
488 | + if ( isset( $this->discounts[ $name ] ) ) { |
|
489 | + $this->discounts[ $name ] += $amount; |
|
490 | + } else { |
|
491 | + $this->discounts[ $name ] = $amount; |
|
492 | + } |
|
493 | + |
|
494 | + } |
|
495 | + |
|
496 | + /** |
|
497 | + * Removes a discount from the submission. |
|
498 | + * |
|
499 | + * @since 1.0.19 |
|
500 | + */ |
|
501 | + public function remove_discount( $name ) { |
|
502 | + |
|
503 | + if ( isset( $this->discounts[ $name ] ) ) { |
|
504 | + $this->total_discount_amount -= $this->discounts[ $name ]; |
|
505 | + unset( $this->discounts[ $name ] ); |
|
506 | + } |
|
507 | + |
|
508 | + } |
|
509 | + |
|
510 | + /** |
|
511 | + * Checks whether there is a discount code associated with this submission. |
|
512 | + * |
|
513 | + * @since 1.0.19 |
|
514 | + * @return bool |
|
515 | + */ |
|
516 | + public function has_discount_code() { |
|
517 | + return ! empty( $this->discount ); |
|
518 | + } |
|
519 | + |
|
520 | + /** |
|
521 | + * Returns the discount code. |
|
522 | + * |
|
523 | + * @since 1.0.19 |
|
524 | + * @return bool |
|
525 | + */ |
|
526 | + public function get_discount_code() { |
|
527 | + return $this->has_discount_code() ? $this->discount->code : ''; |
|
528 | + } |
|
529 | + |
|
530 | + /** |
|
531 | + * Prepares an item discount. |
|
532 | + * |
|
533 | + * @since 1.0.19 |
|
534 | + */ |
|
535 | + public function maybe_prepare_discount() { |
|
536 | + |
|
537 | + // Do we have a discount? |
|
538 | + if ( empty( $this->data['discount'] ) ) { |
|
539 | + return; |
|
540 | + } |
|
541 | + |
|
542 | + // Fetch the discount. |
|
543 | + $discount = wpinv_get_discount_obj( $this->data['discount'] ); |
|
544 | + |
|
545 | + // Ensure it is active. |
|
546 | 546 | if ( ! $discount->exists() || ! $discount->is_active() || ! $discount->has_started() || $discount->is_expired() ) { |
547 | - $this->is_discount_valid = false; |
|
548 | - $this->last_error = __( 'Invalid or expired discount code', 'invoicing' ); |
|
549 | - return; |
|
550 | - } |
|
551 | - |
|
552 | - // For single use discounts... |
|
553 | - if ( $discount->is_single_use ) { |
|
554 | - |
|
555 | - if ( ! $this->has_billing_email() ) { |
|
556 | - $this->is_discount_valid = false; |
|
557 | - $this->last_error = __( 'You need to enter your billing email before applying this discount', 'invoicing' ); |
|
558 | - return; |
|
559 | - } |
|
560 | - |
|
561 | - if ( ! $discount->is_valid_for_user( $this->get_billing_email() ) ) { |
|
562 | - $this->is_discount_valid = false; |
|
563 | - $this->last_error = __( 'You have already used this discount', 'invoicing' ); |
|
564 | - return; |
|
565 | - } |
|
566 | - } |
|
567 | - |
|
568 | - // Set the discount. |
|
569 | - $this->discount = $discount; |
|
570 | - |
|
571 | - } |
|
572 | - |
|
573 | - /** |
|
574 | - * Removes an invalid discount code. |
|
575 | - * |
|
576 | - * @since 1.0.19 |
|
577 | - */ |
|
578 | - public function maybe_remove_discount() { |
|
579 | - |
|
580 | - // Do we have a discount? |
|
581 | - if ( empty( $this->has_discount_code() ) ) { |
|
582 | - return; |
|
583 | - } |
|
584 | - |
|
585 | - // Fetch the discount amount. |
|
586 | - $amount = $this->get_discount( 'Discount' ); |
|
587 | - |
|
588 | - // Abort early if this is a "zero" discount. |
|
589 | - if ( empty( $amount ) ) { |
|
590 | - return; |
|
591 | - } |
|
592 | - |
|
593 | - $total = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax(); |
|
594 | - |
|
595 | - if ( ! $this->discount->is_minimum_amount_met( $total ) ) { |
|
596 | - $this->is_discount_valid = false; |
|
547 | + $this->is_discount_valid = false; |
|
548 | + $this->last_error = __( 'Invalid or expired discount code', 'invoicing' ); |
|
549 | + return; |
|
550 | + } |
|
551 | + |
|
552 | + // For single use discounts... |
|
553 | + if ( $discount->is_single_use ) { |
|
554 | + |
|
555 | + if ( ! $this->has_billing_email() ) { |
|
556 | + $this->is_discount_valid = false; |
|
557 | + $this->last_error = __( 'You need to enter your billing email before applying this discount', 'invoicing' ); |
|
558 | + return; |
|
559 | + } |
|
560 | + |
|
561 | + if ( ! $discount->is_valid_for_user( $this->get_billing_email() ) ) { |
|
562 | + $this->is_discount_valid = false; |
|
563 | + $this->last_error = __( 'You have already used this discount', 'invoicing' ); |
|
564 | + return; |
|
565 | + } |
|
566 | + } |
|
567 | + |
|
568 | + // Set the discount. |
|
569 | + $this->discount = $discount; |
|
570 | + |
|
571 | + } |
|
572 | + |
|
573 | + /** |
|
574 | + * Removes an invalid discount code. |
|
575 | + * |
|
576 | + * @since 1.0.19 |
|
577 | + */ |
|
578 | + public function maybe_remove_discount() { |
|
579 | + |
|
580 | + // Do we have a discount? |
|
581 | + if ( empty( $this->has_discount_code() ) ) { |
|
582 | + return; |
|
583 | + } |
|
584 | + |
|
585 | + // Fetch the discount amount. |
|
586 | + $amount = $this->get_discount( 'Discount' ); |
|
587 | + |
|
588 | + // Abort early if this is a "zero" discount. |
|
589 | + if ( empty( $amount ) ) { |
|
590 | + return; |
|
591 | + } |
|
592 | + |
|
593 | + $total = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax(); |
|
594 | + |
|
595 | + if ( ! $this->discount->is_minimum_amount_met( $total ) ) { |
|
596 | + $this->is_discount_valid = false; |
|
597 | 597 | $min = wpinv_price( wpinv_format_amount( $$this->discount->min_total ) ); |
598 | - $this->last_error = sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ); |
|
598 | + $this->last_error = sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ); |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | if ( ! $$this->discount->is_maximum_amount_met( $total ) ) { |
602 | - $this->is_discount_valid = false; |
|
602 | + $this->is_discount_valid = false; |
|
603 | 603 | $max = wpinv_price( wpinv_format_amount( $$this->discount->max_total ) ); |
604 | - $this->last_error = sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ); |
|
605 | - } |
|
606 | - |
|
607 | - if ( ! $this->is_discount_valid ) { |
|
608 | - $this->discount = null; |
|
609 | - $this->remove_discount( 'Discount' ); |
|
610 | - } |
|
611 | - |
|
612 | - } |
|
613 | - |
|
614 | - /** |
|
615 | - * Maybe process discount. |
|
616 | - * |
|
617 | - * @since 1.0.19 |
|
618 | - * @param GetPaid_Form_Item $item |
|
619 | - */ |
|
620 | - public function process_item_discount( $item ) { |
|
621 | - |
|
622 | - // Abort early if there is no discount. |
|
623 | - if ( ! $this->has_discount_code() ) { |
|
624 | - return; |
|
625 | - } |
|
626 | - |
|
627 | - // Ensure that it is valid for this item. |
|
628 | - if ( ! $this->discount->is_valid_for_items( array( $item->get_id() ) ) ) { |
|
629 | - return; |
|
630 | - } |
|
631 | - |
|
632 | - // Fetch the discounted amount. |
|
633 | - $discount = $this->discount->get_discounted_amount( $item->get_price() * $item->get_quantity() ); |
|
634 | - |
|
635 | - $this->add_discount( 'Discount', $discount ); |
|
636 | - |
|
637 | - } |
|
638 | - |
|
639 | - /** |
|
640 | - * Returns the total discount amount. |
|
641 | - * |
|
642 | - * @since 1.0.19 |
|
643 | - */ |
|
644 | - public function get_total_discount() { |
|
645 | - return $this->total_discount_amount; |
|
646 | - } |
|
647 | - |
|
648 | - /** |
|
649 | - * Gets a specific discount. |
|
650 | - * |
|
651 | - * @since 1.0.19 |
|
652 | - */ |
|
653 | - public function get_discount( $name ) { |
|
654 | - return isset( $this->discounts[ $name ] ) ? $this->discounts[ $name ] : 0; |
|
655 | - } |
|
656 | - |
|
657 | - /** |
|
658 | - * Returns all discounts. |
|
659 | - * |
|
660 | - * @since 1.0.19 |
|
661 | - */ |
|
662 | - public function get_discounts() { |
|
663 | - return $this->discounts; |
|
664 | - } |
|
665 | - |
|
666 | - ///////// FEES ////////////// |
|
667 | - |
|
668 | - /** |
|
669 | - * Adds a fee to the submission. |
|
670 | - * |
|
671 | - * @since 1.0.19 |
|
672 | - */ |
|
673 | - public function add_fee( $name, $amount ) { |
|
674 | - $amount = wpinv_sanitize_amount( $amount ); |
|
675 | - |
|
676 | - $this->total_fees_amount += $amount; |
|
677 | - |
|
678 | - if ( isset( $this->fees[ $name ] ) ) { |
|
679 | - $this->fees[ $name ] += $amount; |
|
680 | - } else { |
|
681 | - $this->fees[ $name ] = $amount; |
|
682 | - } |
|
683 | - |
|
684 | - } |
|
685 | - |
|
686 | - /** |
|
687 | - * Returns the total fees amount. |
|
688 | - * |
|
689 | - * @since 1.0.19 |
|
690 | - */ |
|
691 | - public function get_total_fees() { |
|
692 | - return $this->total_fees_amount; |
|
693 | - } |
|
694 | - |
|
695 | - /** |
|
696 | - * Retrieves a specific fee. |
|
697 | - * |
|
698 | - * @since 1.0.19 |
|
699 | - */ |
|
700 | - public function get_fee( $name ) { |
|
701 | - return isset( $this->fees[ $name ] ) ? $this->fees[ $name ] : 0; |
|
702 | - } |
|
703 | - |
|
704 | - /** |
|
705 | - * Returns all fees. |
|
706 | - * |
|
707 | - * @since 1.0.19 |
|
708 | - */ |
|
709 | - public function get_fees() { |
|
710 | - return $this->fees; |
|
711 | - } |
|
712 | - |
|
713 | - // MISC // |
|
714 | - |
|
715 | - /** |
|
716 | - * Returns the total amount to collect for this submission. |
|
717 | - * |
|
718 | - * @since 1.0.19 |
|
719 | - */ |
|
720 | - public function get_total() { |
|
721 | - $total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax(); |
|
722 | - $total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this ); |
|
723 | - return wpinv_sanitize_amount( $total ); |
|
724 | - } |
|
725 | - |
|
726 | - /** |
|
727 | - * Whether payment details should be collected for this submission. |
|
728 | - * |
|
729 | - * @since 1.0.19 |
|
730 | - */ |
|
731 | - public function get_payment_details() { |
|
732 | - $collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax(); |
|
733 | - |
|
734 | - if ( $this->has_recurring ) { |
|
735 | - $collect = true; |
|
736 | - } |
|
737 | - |
|
738 | - $collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this ); |
|
739 | - return $collect; |
|
740 | - } |
|
741 | - |
|
742 | - /** |
|
743 | - * Returns the billing email of the user. |
|
744 | - * |
|
745 | - * @since 1.0.19 |
|
746 | - */ |
|
747 | - public function get_billing_email() { |
|
748 | - $billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email']; |
|
749 | - return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this ); |
|
750 | - } |
|
751 | - |
|
752 | - /** |
|
753 | - * Checks if the submitter has a billing email. |
|
754 | - * |
|
755 | - * @since 1.0.19 |
|
756 | - */ |
|
757 | - public function has_billing_email() { |
|
758 | - $billing_email = $this->get_billing_email(); |
|
759 | - return ! empty( $billing_email ); |
|
760 | - } |
|
604 | + $this->last_error = sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ); |
|
605 | + } |
|
606 | + |
|
607 | + if ( ! $this->is_discount_valid ) { |
|
608 | + $this->discount = null; |
|
609 | + $this->remove_discount( 'Discount' ); |
|
610 | + } |
|
611 | + |
|
612 | + } |
|
613 | + |
|
614 | + /** |
|
615 | + * Maybe process discount. |
|
616 | + * |
|
617 | + * @since 1.0.19 |
|
618 | + * @param GetPaid_Form_Item $item |
|
619 | + */ |
|
620 | + public function process_item_discount( $item ) { |
|
621 | + |
|
622 | + // Abort early if there is no discount. |
|
623 | + if ( ! $this->has_discount_code() ) { |
|
624 | + return; |
|
625 | + } |
|
626 | + |
|
627 | + // Ensure that it is valid for this item. |
|
628 | + if ( ! $this->discount->is_valid_for_items( array( $item->get_id() ) ) ) { |
|
629 | + return; |
|
630 | + } |
|
631 | + |
|
632 | + // Fetch the discounted amount. |
|
633 | + $discount = $this->discount->get_discounted_amount( $item->get_price() * $item->get_quantity() ); |
|
634 | + |
|
635 | + $this->add_discount( 'Discount', $discount ); |
|
636 | + |
|
637 | + } |
|
638 | + |
|
639 | + /** |
|
640 | + * Returns the total discount amount. |
|
641 | + * |
|
642 | + * @since 1.0.19 |
|
643 | + */ |
|
644 | + public function get_total_discount() { |
|
645 | + return $this->total_discount_amount; |
|
646 | + } |
|
647 | + |
|
648 | + /** |
|
649 | + * Gets a specific discount. |
|
650 | + * |
|
651 | + * @since 1.0.19 |
|
652 | + */ |
|
653 | + public function get_discount( $name ) { |
|
654 | + return isset( $this->discounts[ $name ] ) ? $this->discounts[ $name ] : 0; |
|
655 | + } |
|
656 | + |
|
657 | + /** |
|
658 | + * Returns all discounts. |
|
659 | + * |
|
660 | + * @since 1.0.19 |
|
661 | + */ |
|
662 | + public function get_discounts() { |
|
663 | + return $this->discounts; |
|
664 | + } |
|
665 | + |
|
666 | + ///////// FEES ////////////// |
|
667 | + |
|
668 | + /** |
|
669 | + * Adds a fee to the submission. |
|
670 | + * |
|
671 | + * @since 1.0.19 |
|
672 | + */ |
|
673 | + public function add_fee( $name, $amount ) { |
|
674 | + $amount = wpinv_sanitize_amount( $amount ); |
|
675 | + |
|
676 | + $this->total_fees_amount += $amount; |
|
677 | + |
|
678 | + if ( isset( $this->fees[ $name ] ) ) { |
|
679 | + $this->fees[ $name ] += $amount; |
|
680 | + } else { |
|
681 | + $this->fees[ $name ] = $amount; |
|
682 | + } |
|
683 | + |
|
684 | + } |
|
685 | + |
|
686 | + /** |
|
687 | + * Returns the total fees amount. |
|
688 | + * |
|
689 | + * @since 1.0.19 |
|
690 | + */ |
|
691 | + public function get_total_fees() { |
|
692 | + return $this->total_fees_amount; |
|
693 | + } |
|
694 | + |
|
695 | + /** |
|
696 | + * Retrieves a specific fee. |
|
697 | + * |
|
698 | + * @since 1.0.19 |
|
699 | + */ |
|
700 | + public function get_fee( $name ) { |
|
701 | + return isset( $this->fees[ $name ] ) ? $this->fees[ $name ] : 0; |
|
702 | + } |
|
703 | + |
|
704 | + /** |
|
705 | + * Returns all fees. |
|
706 | + * |
|
707 | + * @since 1.0.19 |
|
708 | + */ |
|
709 | + public function get_fees() { |
|
710 | + return $this->fees; |
|
711 | + } |
|
712 | + |
|
713 | + // MISC // |
|
714 | + |
|
715 | + /** |
|
716 | + * Returns the total amount to collect for this submission. |
|
717 | + * |
|
718 | + * @since 1.0.19 |
|
719 | + */ |
|
720 | + public function get_total() { |
|
721 | + $total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax(); |
|
722 | + $total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this ); |
|
723 | + return wpinv_sanitize_amount( $total ); |
|
724 | + } |
|
725 | + |
|
726 | + /** |
|
727 | + * Whether payment details should be collected for this submission. |
|
728 | + * |
|
729 | + * @since 1.0.19 |
|
730 | + */ |
|
731 | + public function get_payment_details() { |
|
732 | + $collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax(); |
|
733 | + |
|
734 | + if ( $this->has_recurring ) { |
|
735 | + $collect = true; |
|
736 | + } |
|
737 | + |
|
738 | + $collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this ); |
|
739 | + return $collect; |
|
740 | + } |
|
741 | + |
|
742 | + /** |
|
743 | + * Returns the billing email of the user. |
|
744 | + * |
|
745 | + * @since 1.0.19 |
|
746 | + */ |
|
747 | + public function get_billing_email() { |
|
748 | + $billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email']; |
|
749 | + return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this ); |
|
750 | + } |
|
751 | + |
|
752 | + /** |
|
753 | + * Checks if the submitter has a billing email. |
|
754 | + * |
|
755 | + * @since 1.0.19 |
|
756 | + */ |
|
757 | + public function has_billing_email() { |
|
758 | + $billing_email = $this->get_billing_email(); |
|
759 | + return ! empty( $billing_email ); |
|
760 | + } |
|
761 | 761 | |
762 | 762 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -10,55 +10,55 @@ discard block |
||
10 | 10 | class GetPaid_Payment_Form extends GetPaid_Data { |
11 | 11 | |
12 | 12 | /** |
13 | - * Which data store to load. |
|
14 | - * |
|
15 | - * @var string |
|
16 | - */ |
|
13 | + * Which data store to load. |
|
14 | + * |
|
15 | + * @var string |
|
16 | + */ |
|
17 | 17 | protected $data_store_name = 'payment_form'; |
18 | 18 | |
19 | 19 | /** |
20 | - * This is the name of this object type. |
|
21 | - * |
|
22 | - * @var string |
|
23 | - */ |
|
24 | - protected $object_type = 'payment_form'; |
|
20 | + * This is the name of this object type. |
|
21 | + * |
|
22 | + * @var string |
|
23 | + */ |
|
24 | + protected $object_type = 'payment_form'; |
|
25 | 25 | |
26 | 26 | /** |
27 | - * Form Data array. This is the core form data exposed in APIs. |
|
28 | - * |
|
29 | - * @since 1.0.19 |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - protected $data = array( |
|
33 | - 'status' => 'draft', |
|
34 | - 'version' => '', |
|
35 | - 'date_created' => null, |
|
27 | + * Form Data array. This is the core form data exposed in APIs. |
|
28 | + * |
|
29 | + * @since 1.0.19 |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + protected $data = array( |
|
33 | + 'status' => 'draft', |
|
34 | + 'version' => '', |
|
35 | + 'date_created' => null, |
|
36 | 36 | 'date_modified' => null, |
37 | 37 | 'name' => '', |
38 | 38 | 'author' => 1, |
39 | 39 | 'elements' => null, |
40 | - 'items' => null, |
|
41 | - 'earned' => 0, |
|
42 | - 'refunded' => 0, |
|
43 | - 'cancelled' => 0, |
|
44 | - 'failed' => 0, |
|
45 | - ); |
|
46 | - |
|
47 | - /** |
|
48 | - * Stores meta in cache for future reads. |
|
49 | - * |
|
50 | - * A group must be set to to enable caching. |
|
51 | - * |
|
52 | - * @var string |
|
53 | - */ |
|
54 | - protected $cache_group = 'getpaid_forms'; |
|
55 | - |
|
56 | - /** |
|
57 | - * Stores a reference to the invoice if the form is for an invoice.. |
|
58 | - * |
|
59 | - * @var WPInv_Invoice |
|
60 | - */ |
|
61 | - public $invoice = 0; |
|
40 | + 'items' => null, |
|
41 | + 'earned' => 0, |
|
42 | + 'refunded' => 0, |
|
43 | + 'cancelled' => 0, |
|
44 | + 'failed' => 0, |
|
45 | + ); |
|
46 | + |
|
47 | + /** |
|
48 | + * Stores meta in cache for future reads. |
|
49 | + * |
|
50 | + * A group must be set to to enable caching. |
|
51 | + * |
|
52 | + * @var string |
|
53 | + */ |
|
54 | + protected $cache_group = 'getpaid_forms'; |
|
55 | + |
|
56 | + /** |
|
57 | + * Stores a reference to the invoice if the form is for an invoice.. |
|
58 | + * |
|
59 | + * @var WPInv_Invoice |
|
60 | + */ |
|
61 | + public $invoice = 0; |
|
62 | 62 | |
63 | 63 | /** |
64 | 64 | * Stores a reference to the original WP_Post object |
@@ -68,35 +68,35 @@ discard block |
||
68 | 68 | protected $post = null; |
69 | 69 | |
70 | 70 | /** |
71 | - * Get the form if ID is passed, otherwise the form is new and empty. |
|
72 | - * |
|
73 | - * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
|
74 | - */ |
|
75 | - public function __construct( $form = 0 ) { |
|
76 | - parent::__construct( $form ); |
|
71 | + * Get the form if ID is passed, otherwise the form is new and empty. |
|
72 | + * |
|
73 | + * @param int|object|GetPaid_Payment_Form|WP_Post $form Form to read. |
|
74 | + */ |
|
75 | + public function __construct( $form = 0 ) { |
|
76 | + parent::__construct( $form ); |
|
77 | 77 | |
78 | - if ( is_numeric( $form ) && $form > 0 ) { |
|
79 | - $this->set_id( $form ); |
|
80 | - } elseif ( $form instanceof self ) { |
|
78 | + if ( is_numeric( $form ) && $form > 0 ) { |
|
79 | + $this->set_id( $form ); |
|
80 | + } elseif ( $form instanceof self ) { |
|
81 | 81 | |
82 | - $this->set_id( $form->get_id() ); |
|
83 | - $this->invoice = $form->invoice; |
|
82 | + $this->set_id( $form->get_id() ); |
|
83 | + $this->invoice = $form->invoice; |
|
84 | 84 | |
85 | - } elseif ( ! empty( $form->ID ) ) { |
|
86 | - $this->set_id( $form->ID ); |
|
87 | - } else { |
|
88 | - $this->set_object_read( true ); |
|
89 | - } |
|
85 | + } elseif ( ! empty( $form->ID ) ) { |
|
86 | + $this->set_id( $form->ID ); |
|
87 | + } else { |
|
88 | + $this->set_object_read( true ); |
|
89 | + } |
|
90 | 90 | |
91 | 91 | // Load the datastore. |
92 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
92 | + $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
93 | 93 | |
94 | - if ( $this->get_id() > 0 ) { |
|
94 | + if ( $this->get_id() > 0 ) { |
|
95 | 95 | $this->post = get_post( $this->get_id() ); |
96 | - $this->data_store->read( $this ); |
|
96 | + $this->data_store->read( $this ); |
|
97 | 97 | } |
98 | 98 | |
99 | - } |
|
99 | + } |
|
100 | 100 | |
101 | 101 | /* |
102 | 102 | |-------------------------------------------------------------------------- |
@@ -114,321 +114,321 @@ discard block |
||
114 | 114 | */ |
115 | 115 | |
116 | 116 | /** |
117 | - * Get plugin version when the form was created. |
|
118 | - * |
|
119 | - * @since 1.0.19 |
|
120 | - * @param string $context View or edit context. |
|
121 | - * @return string |
|
122 | - */ |
|
123 | - public function get_version( $context = 'view' ) { |
|
124 | - return $this->get_prop( 'version', $context ); |
|
117 | + * Get plugin version when the form was created. |
|
118 | + * |
|
119 | + * @since 1.0.19 |
|
120 | + * @param string $context View or edit context. |
|
121 | + * @return string |
|
122 | + */ |
|
123 | + public function get_version( $context = 'view' ) { |
|
124 | + return $this->get_prop( 'version', $context ); |
|
125 | 125 | } |
126 | 126 | |
127 | 127 | /** |
128 | - * Get date when the form was created. |
|
129 | - * |
|
130 | - * @since 1.0.19 |
|
131 | - * @param string $context View or edit context. |
|
132 | - * @return string |
|
133 | - */ |
|
134 | - public function get_date_created( $context = 'view' ) { |
|
135 | - return $this->get_prop( 'date_created', $context ); |
|
128 | + * Get date when the form was created. |
|
129 | + * |
|
130 | + * @since 1.0.19 |
|
131 | + * @param string $context View or edit context. |
|
132 | + * @return string |
|
133 | + */ |
|
134 | + public function get_date_created( $context = 'view' ) { |
|
135 | + return $this->get_prop( 'date_created', $context ); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | /** |
139 | - * Get GMT date when the form was created. |
|
140 | - * |
|
141 | - * @since 1.0.19 |
|
142 | - * @param string $context View or edit context. |
|
143 | - * @return string |
|
144 | - */ |
|
145 | - public function get_date_created_gmt( $context = 'view' ) { |
|
139 | + * Get GMT date when the form was created. |
|
140 | + * |
|
141 | + * @since 1.0.19 |
|
142 | + * @param string $context View or edit context. |
|
143 | + * @return string |
|
144 | + */ |
|
145 | + public function get_date_created_gmt( $context = 'view' ) { |
|
146 | 146 | $date = $this->get_date_created( $context ); |
147 | 147 | |
148 | 148 | if ( $date ) { |
149 | 149 | $date = get_gmt_from_date( $date ); |
150 | 150 | } |
151 | - return $date; |
|
151 | + return $date; |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
155 | - * Get date when the form was last modified. |
|
156 | - * |
|
157 | - * @since 1.0.19 |
|
158 | - * @param string $context View or edit context. |
|
159 | - * @return string |
|
160 | - */ |
|
161 | - public function get_date_modified( $context = 'view' ) { |
|
162 | - return $this->get_prop( 'date_modified', $context ); |
|
155 | + * Get date when the form was last modified. |
|
156 | + * |
|
157 | + * @since 1.0.19 |
|
158 | + * @param string $context View or edit context. |
|
159 | + * @return string |
|
160 | + */ |
|
161 | + public function get_date_modified( $context = 'view' ) { |
|
162 | + return $this->get_prop( 'date_modified', $context ); |
|
163 | 163 | } |
164 | 164 | |
165 | 165 | /** |
166 | - * Get GMT date when the form was last modified. |
|
167 | - * |
|
168 | - * @since 1.0.19 |
|
169 | - * @param string $context View or edit context. |
|
170 | - * @return string |
|
171 | - */ |
|
172 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
166 | + * Get GMT date when the form was last modified. |
|
167 | + * |
|
168 | + * @since 1.0.19 |
|
169 | + * @param string $context View or edit context. |
|
170 | + * @return string |
|
171 | + */ |
|
172 | + public function get_date_modified_gmt( $context = 'view' ) { |
|
173 | 173 | $date = $this->get_date_modified( $context ); |
174 | 174 | |
175 | 175 | if ( $date ) { |
176 | 176 | $date = get_gmt_from_date( $date ); |
177 | 177 | } |
178 | - return $date; |
|
178 | + return $date; |
|
179 | 179 | } |
180 | 180 | |
181 | 181 | /** |
182 | - * Get the form name. |
|
183 | - * |
|
184 | - * @since 1.0.19 |
|
185 | - * @param string $context View or edit context. |
|
186 | - * @return string |
|
187 | - */ |
|
188 | - public function get_name( $context = 'view' ) { |
|
189 | - return $this->get_prop( 'name', $context ); |
|
182 | + * Get the form name. |
|
183 | + * |
|
184 | + * @since 1.0.19 |
|
185 | + * @param string $context View or edit context. |
|
186 | + * @return string |
|
187 | + */ |
|
188 | + public function get_name( $context = 'view' ) { |
|
189 | + return $this->get_prop( 'name', $context ); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | /** |
193 | - * Alias of self::get_name(). |
|
194 | - * |
|
195 | - * @since 1.0.19 |
|
196 | - * @param string $context View or edit context. |
|
197 | - * @return string |
|
198 | - */ |
|
199 | - public function get_title( $context = 'view' ) { |
|
200 | - return $this->get_name( $context ); |
|
201 | - } |
|
193 | + * Alias of self::get_name(). |
|
194 | + * |
|
195 | + * @since 1.0.19 |
|
196 | + * @param string $context View or edit context. |
|
197 | + * @return string |
|
198 | + */ |
|
199 | + public function get_title( $context = 'view' ) { |
|
200 | + return $this->get_name( $context ); |
|
201 | + } |
|
202 | 202 | |
203 | 203 | /** |
204 | - * Get the owner of the form. |
|
205 | - * |
|
206 | - * @since 1.0.19 |
|
207 | - * @param string $context View or edit context. |
|
208 | - * @return int |
|
209 | - */ |
|
210 | - public function get_author( $context = 'view' ) { |
|
211 | - return (int) $this->get_prop( 'author', $context ); |
|
204 | + * Get the owner of the form. |
|
205 | + * |
|
206 | + * @since 1.0.19 |
|
207 | + * @param string $context View or edit context. |
|
208 | + * @return int |
|
209 | + */ |
|
210 | + public function get_author( $context = 'view' ) { |
|
211 | + return (int) $this->get_prop( 'author', $context ); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | /** |
215 | - * Get the elements that make up the form. |
|
216 | - * |
|
217 | - * @since 1.0.19 |
|
218 | - * @param string $context View or edit context. |
|
219 | - * @return array |
|
220 | - */ |
|
221 | - public function get_elements( $context = 'view' ) { |
|
222 | - $elements = $this->get_prop( 'elements', $context ); |
|
215 | + * Get the elements that make up the form. |
|
216 | + * |
|
217 | + * @since 1.0.19 |
|
218 | + * @param string $context View or edit context. |
|
219 | + * @return array |
|
220 | + */ |
|
221 | + public function get_elements( $context = 'view' ) { |
|
222 | + $elements = $this->get_prop( 'elements', $context ); |
|
223 | 223 | |
224 | - if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
224 | + if ( empty( $elements ) || ! is_array( $elements ) ) { |
|
225 | 225 | return wpinv_get_data( 'sample-payment-form' ); |
226 | - } |
|
226 | + } |
|
227 | 227 | |
228 | - // Ensure that all required elements exist. |
|
229 | - $_elements = array(); |
|
230 | - foreach ( $elements as $element ) { |
|
228 | + // Ensure that all required elements exist. |
|
229 | + $_elements = array(); |
|
230 | + foreach ( $elements as $element ) { |
|
231 | 231 | |
232 | - if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
232 | + if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) { |
|
233 | 233 | |
234 | - $_elements[] = array( |
|
235 | - 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
236 | - 'id' => 'gtscicd', |
|
237 | - 'name' => 'gtscicd', |
|
238 | - 'type' => 'gateway_select', |
|
239 | - 'premade' => true |
|
234 | + $_elements[] = array( |
|
235 | + 'text' => __( 'Select Payment Method', 'invoicing' ), |
|
236 | + 'id' => 'gtscicd', |
|
237 | + 'name' => 'gtscicd', |
|
238 | + 'type' => 'gateway_select', |
|
239 | + 'premade' => true |
|
240 | 240 | |
241 | - ); |
|
241 | + ); |
|
242 | 242 | |
243 | - } |
|
243 | + } |
|
244 | 244 | |
245 | - $_elements[] = $element; |
|
245 | + $_elements[] = $element; |
|
246 | 246 | |
247 | - } |
|
247 | + } |
|
248 | 248 | |
249 | 249 | return $_elements; |
250 | - } |
|
251 | - |
|
252 | - /** |
|
253 | - * Get the items sold via the form. |
|
254 | - * |
|
255 | - * @since 1.0.19 |
|
256 | - * @param string $context View or edit context. |
|
257 | - * @param string $return objects or arrays. |
|
258 | - * @return GetPaid_Form_Item[] |
|
259 | - */ |
|
260 | - public function get_items( $context = 'view', $return = 'objects' ) { |
|
261 | - $items = $this->get_prop( 'items', $context ); |
|
262 | - |
|
263 | - if ( empty( $items ) || ! is_array( $items ) ) { |
|
250 | + } |
|
251 | + |
|
252 | + /** |
|
253 | + * Get the items sold via the form. |
|
254 | + * |
|
255 | + * @since 1.0.19 |
|
256 | + * @param string $context View or edit context. |
|
257 | + * @param string $return objects or arrays. |
|
258 | + * @return GetPaid_Form_Item[] |
|
259 | + */ |
|
260 | + public function get_items( $context = 'view', $return = 'objects' ) { |
|
261 | + $items = $this->get_prop( 'items', $context ); |
|
262 | + |
|
263 | + if ( empty( $items ) || ! is_array( $items ) ) { |
|
264 | 264 | $items = wpinv_get_data( 'sample-payment-form-items' ); |
265 | - } |
|
265 | + } |
|
266 | 266 | |
267 | - // Convert the items. |
|
268 | - $prepared = array(); |
|
267 | + // Convert the items. |
|
268 | + $prepared = array(); |
|
269 | 269 | |
270 | - foreach ( $items as $key => $value ) { |
|
270 | + foreach ( $items as $key => $value ) { |
|
271 | 271 | |
272 | - if ( $value instanceof GetPaid_Form_Item ) { |
|
272 | + if ( $value instanceof GetPaid_Form_Item ) { |
|
273 | 273 | |
274 | - if ( $value->can_purchase() ) { |
|
275 | - $prepared[] = $value; |
|
276 | - } |
|
274 | + if ( $value->can_purchase() ) { |
|
275 | + $prepared[] = $value; |
|
276 | + } |
|
277 | 277 | |
278 | - continue; |
|
278 | + continue; |
|
279 | 279 | |
280 | - } |
|
280 | + } |
|
281 | 281 | |
282 | - // $item_id => $quantity |
|
283 | - if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
284 | - $item = new GetPaid_Form_Item( $key ); |
|
282 | + // $item_id => $quantity |
|
283 | + if ( is_numeric( $key ) && is_numeric( $value ) ) { |
|
284 | + $item = new GetPaid_Form_Item( $key ); |
|
285 | 285 | |
286 | - if ( $item->can_purchase() ) { |
|
287 | - $item->set_quantity( $value ); |
|
288 | - $prepared[] = $item; |
|
289 | - } |
|
286 | + if ( $item->can_purchase() ) { |
|
287 | + $item->set_quantity( $value ); |
|
288 | + $prepared[] = $item; |
|
289 | + } |
|
290 | 290 | |
291 | - continue; |
|
292 | - } |
|
291 | + continue; |
|
292 | + } |
|
293 | 293 | |
294 | - if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
294 | + if ( is_array( $value ) && isset( $value['id'] ) ) { |
|
295 | 295 | |
296 | - $item = new GetPaid_Form_Item( $value['id'] ); |
|
296 | + $item = new GetPaid_Form_Item( $value['id'] ); |
|
297 | 297 | |
298 | - if ( ! $item->can_purchase() ) { |
|
299 | - continue; |
|
300 | - } |
|
298 | + if ( ! $item->can_purchase() ) { |
|
299 | + continue; |
|
300 | + } |
|
301 | 301 | |
302 | - // Sub-total (Cart items). |
|
303 | - if ( isset( $value['subtotal'] ) ) { |
|
304 | - $item->set_price( $value['subtotal'] ); |
|
305 | - } |
|
302 | + // Sub-total (Cart items). |
|
303 | + if ( isset( $value['subtotal'] ) ) { |
|
304 | + $item->set_price( $value['subtotal'] ); |
|
305 | + } |
|
306 | 306 | |
307 | - if ( isset( $value['quantity'] ) ) { |
|
308 | - $item->set_quantity( $value['quantity'] ); |
|
309 | - } |
|
307 | + if ( isset( $value['quantity'] ) ) { |
|
308 | + $item->set_quantity( $value['quantity'] ); |
|
309 | + } |
|
310 | 310 | |
311 | - if ( isset( $value['allow_quantities'] ) ) { |
|
312 | - $item->set_allow_quantities( $value['allow_quantities'] ); |
|
313 | - } |
|
311 | + if ( isset( $value['allow_quantities'] ) ) { |
|
312 | + $item->set_allow_quantities( $value['allow_quantities'] ); |
|
313 | + } |
|
314 | 314 | |
315 | - if ( isset( $value['required'] ) ) { |
|
316 | - $item->set_is_required( $value['required'] ); |
|
317 | - } |
|
318 | - |
|
319 | - if ( isset( $value['description'] ) ) { |
|
320 | - $item->set_custom_description( $value['description'] ); |
|
321 | - } |
|
322 | - |
|
323 | - $prepared[] = $item; |
|
324 | - continue; |
|
325 | - |
|
326 | - } |
|
327 | - } |
|
328 | - |
|
329 | - if ( 'objects' == $return && 'view' == $context ) { |
|
330 | - return $prepared; |
|
331 | - } |
|
332 | - |
|
333 | - $items = array(); |
|
334 | - foreach ( $prepared as $item ) { |
|
335 | - $items[] = $item->prepare_data_for_use(); |
|
336 | - } |
|
337 | - |
|
338 | - return $items; |
|
339 | - } |
|
340 | - |
|
341 | - /** |
|
342 | - * Get a single item belonging to the form. |
|
343 | - * |
|
344 | - * @since 1.0.19 |
|
345 | - * @param int $item_id The item id to return. |
|
346 | - * @return GetPaid_Form_Item|bool |
|
347 | - */ |
|
348 | - public function get_item( $item_id ) { |
|
349 | - |
|
350 | - if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
351 | - return false; |
|
352 | - } |
|
353 | - |
|
354 | - foreach( $this->get_items() as $item ) { |
|
355 | - if ( $item->get_id() == (int) $item_id ) { |
|
356 | - return $item; |
|
357 | - } |
|
358 | - } |
|
359 | - |
|
360 | - return false; |
|
361 | - |
|
362 | - } |
|
363 | - |
|
364 | - /** |
|
365 | - * Gets a single element. |
|
366 | - * |
|
367 | - * @since 1.0.19 |
|
368 | - * @param string $element_type The element type to return. |
|
369 | - * @return array|bool |
|
370 | - */ |
|
371 | - public function get_element_type( $element_type ) { |
|
372 | - |
|
373 | - if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
374 | - return false; |
|
375 | - } |
|
376 | - |
|
377 | - foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
378 | - |
|
379 | - if ( $element['type'] == $element_type ) { |
|
380 | - return $element; |
|
381 | - } |
|
382 | - |
|
383 | - } |
|
384 | - |
|
385 | - return false; |
|
386 | - |
|
387 | - } |
|
388 | - |
|
389 | - /** |
|
390 | - * Get the total amount earned via this form. |
|
391 | - * |
|
392 | - * @since 1.0.19 |
|
393 | - * @param string $context View or edit context. |
|
394 | - * @return array |
|
395 | - */ |
|
396 | - public function get_earned( $context = 'view' ) { |
|
397 | - return $this->get_prop( 'earned', $context ); |
|
398 | - } |
|
399 | - |
|
400 | - /** |
|
401 | - * Get the total amount refunded via this form. |
|
402 | - * |
|
403 | - * @since 1.0.19 |
|
404 | - * @param string $context View or edit context. |
|
405 | - * @return array |
|
406 | - */ |
|
407 | - public function get_refunded( $context = 'view' ) { |
|
408 | - return $this->get_prop( 'refunded', $context ); |
|
409 | - } |
|
410 | - |
|
411 | - /** |
|
412 | - * Get the total amount cancelled via this form. |
|
413 | - * |
|
414 | - * @since 1.0.19 |
|
415 | - * @param string $context View or edit context. |
|
416 | - * @return array |
|
417 | - */ |
|
418 | - public function get_cancelled( $context = 'view' ) { |
|
419 | - return $this->get_prop( 'cancelled', $context ); |
|
420 | - } |
|
421 | - |
|
422 | - /** |
|
423 | - * Get the total amount failed via this form. |
|
424 | - * |
|
425 | - * @since 1.0.19 |
|
426 | - * @param string $context View or edit context. |
|
427 | - * @return array |
|
428 | - */ |
|
429 | - public function get_failed( $context = 'view' ) { |
|
430 | - return $this->get_prop( 'failed', $context ); |
|
431 | - } |
|
315 | + if ( isset( $value['required'] ) ) { |
|
316 | + $item->set_is_required( $value['required'] ); |
|
317 | + } |
|
318 | + |
|
319 | + if ( isset( $value['description'] ) ) { |
|
320 | + $item->set_custom_description( $value['description'] ); |
|
321 | + } |
|
322 | + |
|
323 | + $prepared[] = $item; |
|
324 | + continue; |
|
325 | + |
|
326 | + } |
|
327 | + } |
|
328 | + |
|
329 | + if ( 'objects' == $return && 'view' == $context ) { |
|
330 | + return $prepared; |
|
331 | + } |
|
332 | + |
|
333 | + $items = array(); |
|
334 | + foreach ( $prepared as $item ) { |
|
335 | + $items[] = $item->prepare_data_for_use(); |
|
336 | + } |
|
337 | + |
|
338 | + return $items; |
|
339 | + } |
|
340 | + |
|
341 | + /** |
|
342 | + * Get a single item belonging to the form. |
|
343 | + * |
|
344 | + * @since 1.0.19 |
|
345 | + * @param int $item_id The item id to return. |
|
346 | + * @return GetPaid_Form_Item|bool |
|
347 | + */ |
|
348 | + public function get_item( $item_id ) { |
|
349 | + |
|
350 | + if ( empty( $item_id ) || ! is_numeric( $item_id ) ) { |
|
351 | + return false; |
|
352 | + } |
|
353 | + |
|
354 | + foreach( $this->get_items() as $item ) { |
|
355 | + if ( $item->get_id() == (int) $item_id ) { |
|
356 | + return $item; |
|
357 | + } |
|
358 | + } |
|
359 | + |
|
360 | + return false; |
|
361 | + |
|
362 | + } |
|
363 | + |
|
364 | + /** |
|
365 | + * Gets a single element. |
|
366 | + * |
|
367 | + * @since 1.0.19 |
|
368 | + * @param string $element_type The element type to return. |
|
369 | + * @return array|bool |
|
370 | + */ |
|
371 | + public function get_element_type( $element_type ) { |
|
372 | + |
|
373 | + if ( empty( $element_type ) || ! is_scalar( $element_type ) ) { |
|
374 | + return false; |
|
375 | + } |
|
376 | + |
|
377 | + foreach ( $this->get_prop( 'elements' ) as $element ) { |
|
378 | + |
|
379 | + if ( $element['type'] == $element_type ) { |
|
380 | + return $element; |
|
381 | + } |
|
382 | + |
|
383 | + } |
|
384 | + |
|
385 | + return false; |
|
386 | + |
|
387 | + } |
|
388 | + |
|
389 | + /** |
|
390 | + * Get the total amount earned via this form. |
|
391 | + * |
|
392 | + * @since 1.0.19 |
|
393 | + * @param string $context View or edit context. |
|
394 | + * @return array |
|
395 | + */ |
|
396 | + public function get_earned( $context = 'view' ) { |
|
397 | + return $this->get_prop( 'earned', $context ); |
|
398 | + } |
|
399 | + |
|
400 | + /** |
|
401 | + * Get the total amount refunded via this form. |
|
402 | + * |
|
403 | + * @since 1.0.19 |
|
404 | + * @param string $context View or edit context. |
|
405 | + * @return array |
|
406 | + */ |
|
407 | + public function get_refunded( $context = 'view' ) { |
|
408 | + return $this->get_prop( 'refunded', $context ); |
|
409 | + } |
|
410 | + |
|
411 | + /** |
|
412 | + * Get the total amount cancelled via this form. |
|
413 | + * |
|
414 | + * @since 1.0.19 |
|
415 | + * @param string $context View or edit context. |
|
416 | + * @return array |
|
417 | + */ |
|
418 | + public function get_cancelled( $context = 'view' ) { |
|
419 | + return $this->get_prop( 'cancelled', $context ); |
|
420 | + } |
|
421 | + |
|
422 | + /** |
|
423 | + * Get the total amount failed via this form. |
|
424 | + * |
|
425 | + * @since 1.0.19 |
|
426 | + * @param string $context View or edit context. |
|
427 | + * @return array |
|
428 | + */ |
|
429 | + public function get_failed( $context = 'view' ) { |
|
430 | + return $this->get_prop( 'failed', $context ); |
|
431 | + } |
|
432 | 432 | |
433 | 433 | /* |
434 | 434 | |-------------------------------------------------------------------------- |
@@ -441,22 +441,22 @@ discard block |
||
441 | 441 | */ |
442 | 442 | |
443 | 443 | /** |
444 | - * Set plugin version when the item was created. |
|
445 | - * |
|
446 | - * @since 1.0.19 |
|
447 | - */ |
|
448 | - public function set_version( $value ) { |
|
449 | - $this->set_prop( 'version', $value ); |
|
444 | + * Set plugin version when the item was created. |
|
445 | + * |
|
446 | + * @since 1.0.19 |
|
447 | + */ |
|
448 | + public function set_version( $value ) { |
|
449 | + $this->set_prop( 'version', $value ); |
|
450 | 450 | } |
451 | 451 | |
452 | 452 | /** |
453 | - * Set date when the item was created. |
|
454 | - * |
|
455 | - * @since 1.0.19 |
|
456 | - * @param string $value Value to set. |
|
453 | + * Set date when the item was created. |
|
454 | + * |
|
455 | + * @since 1.0.19 |
|
456 | + * @param string $value Value to set. |
|
457 | 457 | * @return bool Whether or not the date was set. |
458 | - */ |
|
459 | - public function set_date_created( $value ) { |
|
458 | + */ |
|
459 | + public function set_date_created( $value ) { |
|
460 | 460 | $date = strtotime( $value ); |
461 | 461 | |
462 | 462 | if ( $date ) { |
@@ -469,13 +469,13 @@ discard block |
||
469 | 469 | } |
470 | 470 | |
471 | 471 | /** |
472 | - * Set date when the item was last modified. |
|
473 | - * |
|
474 | - * @since 1.0.19 |
|
475 | - * @param string $value Value to set. |
|
472 | + * Set date when the item was last modified. |
|
473 | + * |
|
474 | + * @since 1.0.19 |
|
475 | + * @param string $value Value to set. |
|
476 | 476 | * @return bool Whether or not the date was set. |
477 | - */ |
|
478 | - public function set_date_modified( $value ) { |
|
477 | + */ |
|
478 | + public function set_date_modified( $value ) { |
|
479 | 479 | $date = strtotime( $value ); |
480 | 480 | |
481 | 481 | if ( $date ) { |
@@ -488,118 +488,118 @@ discard block |
||
488 | 488 | } |
489 | 489 | |
490 | 490 | /** |
491 | - * Set the item name. |
|
492 | - * |
|
493 | - * @since 1.0.19 |
|
494 | - * @param string $value New name. |
|
495 | - */ |
|
496 | - public function set_name( $value ) { |
|
497 | - $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
498 | - } |
|
499 | - |
|
500 | - /** |
|
501 | - * Alias of self::set_name(). |
|
502 | - * |
|
503 | - * @since 1.0.19 |
|
504 | - * @param string $value New name. |
|
505 | - */ |
|
506 | - public function set_title( $value ) { |
|
507 | - $this->set_name( $value ); |
|
508 | - } |
|
509 | - |
|
510 | - /** |
|
511 | - * Set the owner of the item. |
|
512 | - * |
|
513 | - * @since 1.0.19 |
|
514 | - * @param int $value New author. |
|
515 | - */ |
|
516 | - public function set_author( $value ) { |
|
517 | - $this->set_prop( 'author', (int) $value ); |
|
518 | - } |
|
519 | - |
|
520 | - /** |
|
521 | - * Set the form elements. |
|
522 | - * |
|
523 | - * @since 1.0.19 |
|
524 | - * @param array $value Form elements. |
|
525 | - */ |
|
526 | - public function set_elements( $value ) { |
|
527 | - if ( is_array( $value ) ) { |
|
528 | - $this->set_prop( 'elements', $value ); |
|
529 | - } |
|
530 | - } |
|
531 | - |
|
532 | - /** |
|
533 | - * Set the form items. |
|
534 | - * |
|
535 | - * @since 1.0.19 |
|
536 | - * @param array $value Form elements. |
|
537 | - */ |
|
538 | - public function set_items( $value ) { |
|
539 | - if ( is_array( $value ) ) { |
|
540 | - $this->set_prop( 'items', $value ); |
|
541 | - } |
|
542 | - } |
|
543 | - |
|
544 | - /** |
|
545 | - * Set the total amount earned via this form. |
|
546 | - * |
|
547 | - * @since 1.0.19 |
|
548 | - * @param float $value Amount earned. |
|
549 | - * @return array |
|
550 | - */ |
|
551 | - public function set_earned( $value ) { |
|
552 | - return $this->set_prop( 'earned', (float) $value ); |
|
553 | - } |
|
554 | - |
|
555 | - /** |
|
556 | - * Set the total amount refunded via this form. |
|
557 | - * |
|
558 | - * @since 1.0.19 |
|
559 | - * @param float $value Amount refunded. |
|
560 | - * @return array |
|
561 | - */ |
|
562 | - public function set_refunded( $value ) { |
|
563 | - return $this->set_prop( 'refunded', (float) $value ); |
|
564 | - } |
|
565 | - |
|
566 | - /** |
|
567 | - * Set the total amount cancelled via this form. |
|
568 | - * |
|
569 | - * @since 1.0.19 |
|
570 | - * @param float $value Amount cancelled. |
|
571 | - * @return array |
|
572 | - */ |
|
573 | - public function set_cancelled( $value ) { |
|
574 | - return $this->set_prop( 'cancelled', (float) $value ); |
|
575 | - } |
|
576 | - |
|
577 | - /** |
|
578 | - * Set the total amount failed via this form. |
|
579 | - * |
|
580 | - * @since 1.0.19 |
|
581 | - * @param float $value Amount cancelled. |
|
582 | - * @return array |
|
583 | - */ |
|
584 | - public function set_failed( $value ) { |
|
585 | - return $this->set_prop( 'failed', (float) $value ); |
|
586 | - } |
|
491 | + * Set the item name. |
|
492 | + * |
|
493 | + * @since 1.0.19 |
|
494 | + * @param string $value New name. |
|
495 | + */ |
|
496 | + public function set_name( $value ) { |
|
497 | + $this->set_prop( 'name', sanitize_text_field( $value ) ); |
|
498 | + } |
|
499 | + |
|
500 | + /** |
|
501 | + * Alias of self::set_name(). |
|
502 | + * |
|
503 | + * @since 1.0.19 |
|
504 | + * @param string $value New name. |
|
505 | + */ |
|
506 | + public function set_title( $value ) { |
|
507 | + $this->set_name( $value ); |
|
508 | + } |
|
509 | + |
|
510 | + /** |
|
511 | + * Set the owner of the item. |
|
512 | + * |
|
513 | + * @since 1.0.19 |
|
514 | + * @param int $value New author. |
|
515 | + */ |
|
516 | + public function set_author( $value ) { |
|
517 | + $this->set_prop( 'author', (int) $value ); |
|
518 | + } |
|
519 | + |
|
520 | + /** |
|
521 | + * Set the form elements. |
|
522 | + * |
|
523 | + * @since 1.0.19 |
|
524 | + * @param array $value Form elements. |
|
525 | + */ |
|
526 | + public function set_elements( $value ) { |
|
527 | + if ( is_array( $value ) ) { |
|
528 | + $this->set_prop( 'elements', $value ); |
|
529 | + } |
|
530 | + } |
|
531 | + |
|
532 | + /** |
|
533 | + * Set the form items. |
|
534 | + * |
|
535 | + * @since 1.0.19 |
|
536 | + * @param array $value Form elements. |
|
537 | + */ |
|
538 | + public function set_items( $value ) { |
|
539 | + if ( is_array( $value ) ) { |
|
540 | + $this->set_prop( 'items', $value ); |
|
541 | + } |
|
542 | + } |
|
543 | + |
|
544 | + /** |
|
545 | + * Set the total amount earned via this form. |
|
546 | + * |
|
547 | + * @since 1.0.19 |
|
548 | + * @param float $value Amount earned. |
|
549 | + * @return array |
|
550 | + */ |
|
551 | + public function set_earned( $value ) { |
|
552 | + return $this->set_prop( 'earned', (float) $value ); |
|
553 | + } |
|
554 | + |
|
555 | + /** |
|
556 | + * Set the total amount refunded via this form. |
|
557 | + * |
|
558 | + * @since 1.0.19 |
|
559 | + * @param float $value Amount refunded. |
|
560 | + * @return array |
|
561 | + */ |
|
562 | + public function set_refunded( $value ) { |
|
563 | + return $this->set_prop( 'refunded', (float) $value ); |
|
564 | + } |
|
565 | + |
|
566 | + /** |
|
567 | + * Set the total amount cancelled via this form. |
|
568 | + * |
|
569 | + * @since 1.0.19 |
|
570 | + * @param float $value Amount cancelled. |
|
571 | + * @return array |
|
572 | + */ |
|
573 | + public function set_cancelled( $value ) { |
|
574 | + return $this->set_prop( 'cancelled', (float) $value ); |
|
575 | + } |
|
576 | + |
|
577 | + /** |
|
578 | + * Set the total amount failed via this form. |
|
579 | + * |
|
580 | + * @since 1.0.19 |
|
581 | + * @param float $value Amount cancelled. |
|
582 | + * @return array |
|
583 | + */ |
|
584 | + public function set_failed( $value ) { |
|
585 | + return $this->set_prop( 'failed', (float) $value ); |
|
586 | + } |
|
587 | 587 | |
588 | 588 | /** |
589 | 589 | * Create an item. For backwards compatibilty. |
590 | 590 | * |
591 | 591 | * @deprecated |
592 | - * @return int item id |
|
592 | + * @return int item id |
|
593 | 593 | */ |
594 | 594 | public function create( $data = array() ) { |
595 | 595 | |
596 | - // Set the properties. |
|
597 | - if ( is_array( $data ) ) { |
|
598 | - $this->set_props( $data ); |
|
599 | - } |
|
596 | + // Set the properties. |
|
597 | + if ( is_array( $data ) ) { |
|
598 | + $this->set_props( $data ); |
|
599 | + } |
|
600 | 600 | |
601 | - // Save the item. |
|
602 | - return $this->save(); |
|
601 | + // Save the item. |
|
602 | + return $this->save(); |
|
603 | 603 | |
604 | 604 | } |
605 | 605 | |
@@ -607,7 +607,7 @@ discard block |
||
607 | 607 | * Updates an item. For backwards compatibilty. |
608 | 608 | * |
609 | 609 | * @deprecated |
610 | - * @return int item id |
|
610 | + * @return int item id |
|
611 | 611 | */ |
612 | 612 | public function update( $data = array() ) { |
613 | 613 | return $this->create( $data ); |
@@ -623,22 +623,22 @@ discard block |
||
623 | 623 | */ |
624 | 624 | |
625 | 625 | /** |
626 | - * Checks whether this is the default payment form. |
|
627 | - * |
|
628 | - * @since 1.0.19 |
|
629 | - * @return bool |
|
630 | - */ |
|
626 | + * Checks whether this is the default payment form. |
|
627 | + * |
|
628 | + * @since 1.0.19 |
|
629 | + * @return bool |
|
630 | + */ |
|
631 | 631 | public function is_default() { |
632 | 632 | $is_default = $this->get_id() == wpinv_get_default_payment_form(); |
633 | 633 | return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this ); |
634 | - } |
|
634 | + } |
|
635 | 635 | |
636 | 636 | /** |
637 | - * Checks whether the form is active. |
|
638 | - * |
|
639 | - * @since 1.0.19 |
|
640 | - * @return bool |
|
641 | - */ |
|
637 | + * Checks whether the form is active. |
|
638 | + * |
|
639 | + * @since 1.0.19 |
|
640 | + * @return bool |
|
641 | + */ |
|
642 | 642 | public function is_active() { |
643 | 643 | $is_active = 0 !== (int) $this->get_id(); |
644 | 644 | |
@@ -647,70 +647,70 @@ discard block |
||
647 | 647 | } |
648 | 648 | |
649 | 649 | return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this ); |
650 | - } |
|
651 | - |
|
652 | - /** |
|
653 | - * Checks whether the form has a given item. |
|
654 | - * |
|
655 | - * @since 1.0.19 |
|
656 | - * @return bool |
|
657 | - */ |
|
650 | + } |
|
651 | + |
|
652 | + /** |
|
653 | + * Checks whether the form has a given item. |
|
654 | + * |
|
655 | + * @since 1.0.19 |
|
656 | + * @return bool |
|
657 | + */ |
|
658 | 658 | public function has_item( $item_id ) { |
659 | 659 | return false !== $this->get_item( $item_id ); |
660 | - } |
|
661 | - |
|
662 | - /** |
|
663 | - * Checks whether the form has a given element. |
|
664 | - * |
|
665 | - * @since 1.0.19 |
|
666 | - * @return bool |
|
667 | - */ |
|
660 | + } |
|
661 | + |
|
662 | + /** |
|
663 | + * Checks whether the form has a given element. |
|
664 | + * |
|
665 | + * @since 1.0.19 |
|
666 | + * @return bool |
|
667 | + */ |
|
668 | 668 | public function has_element_type( $element_type ) { |
669 | 669 | return false !== $this->get_element_type( $element_type ); |
670 | - } |
|
671 | - |
|
672 | - /** |
|
673 | - * Checks whether this form is recurring or not. |
|
674 | - * |
|
675 | - * @since 1.0.19 |
|
676 | - * @return bool |
|
677 | - */ |
|
670 | + } |
|
671 | + |
|
672 | + /** |
|
673 | + * Checks whether this form is recurring or not. |
|
674 | + * |
|
675 | + * @since 1.0.19 |
|
676 | + * @return bool |
|
677 | + */ |
|
678 | 678 | public function is_recurring() { |
679 | 679 | |
680 | - if ( ! empty( $this->invoice ) ) { |
|
681 | - return $this->invoice->is_recurring(); |
|
682 | - } |
|
680 | + if ( ! empty( $this->invoice ) ) { |
|
681 | + return $this->invoice->is_recurring(); |
|
682 | + } |
|
683 | 683 | |
684 | - foreach ( $this->get_items() as $item ) { |
|
684 | + foreach ( $this->get_items() as $item ) { |
|
685 | 685 | |
686 | - if ( $item->is_recurring() ) { |
|
687 | - return true; |
|
688 | - } |
|
686 | + if ( $item->is_recurring() ) { |
|
687 | + return true; |
|
688 | + } |
|
689 | 689 | |
690 | - } |
|
690 | + } |
|
691 | 691 | |
692 | 692 | return false; |
693 | - } |
|
693 | + } |
|
694 | 694 | |
695 | - /** |
|
696 | - * Retrieves the form's html. |
|
697 | - * |
|
698 | - * @since 1.0.19 |
|
699 | - */ |
|
695 | + /** |
|
696 | + * Retrieves the form's html. |
|
697 | + * |
|
698 | + * @since 1.0.19 |
|
699 | + */ |
|
700 | 700 | public function get_html() { |
701 | 701 | |
702 | - // Return the HTML. |
|
703 | - return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) ); |
|
702 | + // Return the HTML. |
|
703 | + return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) ); |
|
704 | 704 | |
705 | - } |
|
705 | + } |
|
706 | 706 | |
707 | - /** |
|
708 | - * Displays the payment form. |
|
709 | - * |
|
710 | - * @since 1.0.19 |
|
711 | - */ |
|
707 | + /** |
|
708 | + * Displays the payment form. |
|
709 | + * |
|
710 | + * @since 1.0.19 |
|
711 | + */ |
|
712 | 712 | public function display() { |
713 | - echo $this->get_html(); |
|
713 | + echo $this->get_html(); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | } |
@@ -129,26 +129,26 @@ discard block |
||
129 | 129 | |
130 | 130 | // Make variables available to the template. |
131 | 131 | if ( ! empty( $args ) && is_array( $args ) ) { |
132 | - extract( $args ); |
|
133 | - } |
|
132 | + extract( $args ); |
|
133 | + } |
|
134 | 134 | |
135 | 135 | // Locate the template. |
136 | - $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
136 | + $located = wpinv_locate_template( $template_name, $template_path, $default_path ); |
|
137 | 137 | |
138 | 138 | // Abort if the file does not exist. |
139 | - if ( ! file_exists( $located ) ) { |
|
139 | + if ( ! file_exists( $located ) ) { |
|
140 | 140 | _doing_it_wrong( __FUNCTION__, sprintf( '<code>%s</code> does not exist.', $located ), '2.1' ); |
141 | - return; |
|
142 | - } |
|
141 | + return; |
|
142 | + } |
|
143 | 143 | |
144 | 144 | // Fires before loading a template. |
145 | - do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
145 | + do_action( 'wpinv_before_template_part', $template_name, $template_path, $located, $args ); |
|
146 | 146 | |
147 | 147 | // Load the template. |
148 | - include( $located ); |
|
148 | + include( $located ); |
|
149 | 149 | |
150 | 150 | // Fires after loading a template. |
151 | - do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
151 | + do_action( 'wpinv_after_template_part', $template_name, $template_path, $located, $args ); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * @param string $default_path The root path to the default template. Defaults to invoicing/templates |
162 | 162 | */ |
163 | 163 | function wpinv_get_template_html( $template_name, $args = array(), $template_path = '', $default_path = '' ) { |
164 | - ob_start(); |
|
165 | - wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
166 | - return ob_get_clean(); |
|
164 | + ob_start(); |
|
165 | + wpinv_get_template( $template_name, $args, $template_path, $default_path ); |
|
166 | + return ob_get_clean(); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | /** |
@@ -181,7 +181,7 @@ discard block |
||
181 | 181 | * @return string |
182 | 182 | */ |
183 | 183 | function wpinv_get_theme_template_dir_name() { |
184 | - return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
184 | + return trailingslashit( apply_filters( 'wpinv_templates_dir', 'invoicing' ) ); |
|
185 | 185 | } |
186 | 186 | |
187 | 187 | /** |
@@ -214,122 +214,122 @@ discard block |
||
214 | 214 | } |
215 | 215 | |
216 | 216 | function wpinv_get_template_part( $slug, $name = null, $load = true ) { |
217 | - do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
217 | + do_action( 'get_template_part_' . $slug, $slug, $name ); |
|
218 | 218 | |
219 | - // Setup possible parts |
|
220 | - $templates = array(); |
|
221 | - if ( isset( $name ) ) |
|
222 | - $templates[] = $slug . '-' . $name . '.php'; |
|
223 | - $templates[] = $slug . '.php'; |
|
219 | + // Setup possible parts |
|
220 | + $templates = array(); |
|
221 | + if ( isset( $name ) ) |
|
222 | + $templates[] = $slug . '-' . $name . '.php'; |
|
223 | + $templates[] = $slug . '.php'; |
|
224 | 224 | |
225 | - // Allow template parts to be filtered |
|
226 | - $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
225 | + // Allow template parts to be filtered |
|
226 | + $templates = apply_filters( 'wpinv_get_template_part', $templates, $slug, $name ); |
|
227 | 227 | |
228 | - // Return the part that is found |
|
229 | - return wpinv_locate_tmpl( $templates, $load, false ); |
|
228 | + // Return the part that is found |
|
229 | + return wpinv_locate_tmpl( $templates, $load, false ); |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | function wpinv_locate_tmpl( $template_names, $load = false, $require_once = true ) { |
233 | - // No file found yet |
|
234 | - $located = false; |
|
233 | + // No file found yet |
|
234 | + $located = false; |
|
235 | 235 | |
236 | - // Try to find a template file |
|
237 | - foreach ( (array)$template_names as $template_name ) { |
|
236 | + // Try to find a template file |
|
237 | + foreach ( (array)$template_names as $template_name ) { |
|
238 | 238 | |
239 | - // Continue if template is empty |
|
240 | - if ( empty( $template_name ) ) |
|
241 | - continue; |
|
239 | + // Continue if template is empty |
|
240 | + if ( empty( $template_name ) ) |
|
241 | + continue; |
|
242 | 242 | |
243 | - // Trim off any slashes from the template name |
|
244 | - $template_name = ltrim( $template_name, '/' ); |
|
243 | + // Trim off any slashes from the template name |
|
244 | + $template_name = ltrim( $template_name, '/' ); |
|
245 | 245 | |
246 | - // try locating this template file by looping through the template paths |
|
247 | - foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
246 | + // try locating this template file by looping through the template paths |
|
247 | + foreach( wpinv_get_theme_template_paths() as $template_path ) { |
|
248 | 248 | |
249 | - if( file_exists( $template_path . $template_name ) ) { |
|
250 | - $located = $template_path . $template_name; |
|
251 | - break; |
|
252 | - } |
|
253 | - } |
|
249 | + if( file_exists( $template_path . $template_name ) ) { |
|
250 | + $located = $template_path . $template_name; |
|
251 | + break; |
|
252 | + } |
|
253 | + } |
|
254 | 254 | |
255 | - if( !empty( $located ) ) { |
|
256 | - break; |
|
257 | - } |
|
258 | - } |
|
255 | + if( !empty( $located ) ) { |
|
256 | + break; |
|
257 | + } |
|
258 | + } |
|
259 | 259 | |
260 | - if ( ( true == $load ) && ! empty( $located ) ) |
|
261 | - load_template( $located, $require_once ); |
|
260 | + if ( ( true == $load ) && ! empty( $located ) ) |
|
261 | + load_template( $located, $require_once ); |
|
262 | 262 | |
263 | - return $located; |
|
263 | + return $located; |
|
264 | 264 | } |
265 | 265 | |
266 | 266 | function wpinv_get_theme_template_paths() { |
267 | - $template_dir = wpinv_get_theme_template_dir_name(); |
|
267 | + $template_dir = wpinv_get_theme_template_dir_name(); |
|
268 | 268 | |
269 | - $file_paths = array( |
|
270 | - 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
271 | - 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
272 | - 100 => wpinv_get_templates_dir() |
|
273 | - ); |
|
269 | + $file_paths = array( |
|
270 | + 1 => trailingslashit( get_stylesheet_directory() ) . $template_dir, |
|
271 | + 10 => trailingslashit( get_template_directory() ) . $template_dir, |
|
272 | + 100 => wpinv_get_templates_dir() |
|
273 | + ); |
|
274 | 274 | |
275 | - $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
275 | + $file_paths = apply_filters( 'wpinv_template_paths', $file_paths ); |
|
276 | 276 | |
277 | - // sort the file paths based on priority |
|
278 | - ksort( $file_paths, SORT_NUMERIC ); |
|
277 | + // sort the file paths based on priority |
|
278 | + ksort( $file_paths, SORT_NUMERIC ); |
|
279 | 279 | |
280 | - return array_map( 'trailingslashit', $file_paths ); |
|
280 | + return array_map( 'trailingslashit', $file_paths ); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 | function wpinv_checkout_meta_tags() { |
284 | 284 | |
285 | - $pages = array(); |
|
286 | - $pages[] = wpinv_get_option( 'success_page' ); |
|
287 | - $pages[] = wpinv_get_option( 'failure_page' ); |
|
288 | - $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
289 | - $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
285 | + $pages = array(); |
|
286 | + $pages[] = wpinv_get_option( 'success_page' ); |
|
287 | + $pages[] = wpinv_get_option( 'failure_page' ); |
|
288 | + $pages[] = wpinv_get_option( 'invoice_history_page' ); |
|
289 | + $pages[] = wpinv_get_option( 'invoice_subscription_page' ); |
|
290 | 290 | |
291 | - if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
292 | - return; |
|
293 | - } |
|
291 | + if( !wpinv_is_checkout() && !is_page( $pages ) ) { |
|
292 | + return; |
|
293 | + } |
|
294 | 294 | |
295 | - echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
295 | + echo '<meta name="robots" content="noindex,nofollow" />' . "\n"; |
|
296 | 296 | } |
297 | 297 | add_action( 'wp_head', 'wpinv_checkout_meta_tags' ); |
298 | 298 | |
299 | 299 | function wpinv_add_body_classes( $class ) { |
300 | - $classes = (array)$class; |
|
300 | + $classes = (array)$class; |
|
301 | 301 | |
302 | - if( wpinv_is_checkout() ) { |
|
303 | - $classes[] = 'wpinv-checkout'; |
|
304 | - $classes[] = 'wpinv-page'; |
|
305 | - } |
|
302 | + if( wpinv_is_checkout() ) { |
|
303 | + $classes[] = 'wpinv-checkout'; |
|
304 | + $classes[] = 'wpinv-page'; |
|
305 | + } |
|
306 | 306 | |
307 | - if( wpinv_is_success_page() ) { |
|
308 | - $classes[] = 'wpinv-success'; |
|
309 | - $classes[] = 'wpinv-page'; |
|
310 | - } |
|
307 | + if( wpinv_is_success_page() ) { |
|
308 | + $classes[] = 'wpinv-success'; |
|
309 | + $classes[] = 'wpinv-page'; |
|
310 | + } |
|
311 | 311 | |
312 | - if( wpinv_is_failed_transaction_page() ) { |
|
313 | - $classes[] = 'wpinv-failed-transaction'; |
|
314 | - $classes[] = 'wpinv-page'; |
|
315 | - } |
|
312 | + if( wpinv_is_failed_transaction_page() ) { |
|
313 | + $classes[] = 'wpinv-failed-transaction'; |
|
314 | + $classes[] = 'wpinv-page'; |
|
315 | + } |
|
316 | 316 | |
317 | - if( wpinv_is_invoice_history_page() ) { |
|
318 | - $classes[] = 'wpinv-history'; |
|
319 | - $classes[] = 'wpinv-page'; |
|
320 | - } |
|
317 | + if( wpinv_is_invoice_history_page() ) { |
|
318 | + $classes[] = 'wpinv-history'; |
|
319 | + $classes[] = 'wpinv-page'; |
|
320 | + } |
|
321 | 321 | |
322 | - if( wpinv_is_subscriptions_history_page() ) { |
|
323 | - $classes[] = 'wpinv-subscription'; |
|
324 | - $classes[] = 'wpinv-page'; |
|
325 | - } |
|
322 | + if( wpinv_is_subscriptions_history_page() ) { |
|
323 | + $classes[] = 'wpinv-subscription'; |
|
324 | + $classes[] = 'wpinv-page'; |
|
325 | + } |
|
326 | 326 | |
327 | - if( wpinv_is_test_mode() ) { |
|
328 | - $classes[] = 'wpinv-test-mode'; |
|
329 | - $classes[] = 'wpinv-page'; |
|
330 | - } |
|
327 | + if( wpinv_is_test_mode() ) { |
|
328 | + $classes[] = 'wpinv-test-mode'; |
|
329 | + $classes[] = 'wpinv-page'; |
|
330 | + } |
|
331 | 331 | |
332 | - return array_unique( $classes ); |
|
332 | + return array_unique( $classes ); |
|
333 | 333 | } |
334 | 334 | add_filter( 'body_class', 'wpinv_add_body_classes' ); |
335 | 335 | |
@@ -1115,21 +1115,21 @@ discard block |
||
1115 | 1115 | |
1116 | 1116 | $formatted_address = str_ireplace( array_keys( $replacements ), $replacements, $format ); |
1117 | 1117 | |
1118 | - // Remove unavailable tags. |
|
1118 | + // Remove unavailable tags. |
|
1119 | 1119 | $formatted_address = preg_replace( "/\{\{\w+\}\}/", '', $formatted_address ); |
1120 | 1120 | |
1121 | 1121 | // Clean up white space. |
1122 | - $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
1122 | + $formatted_address = preg_replace( '/ +/', ' ', trim( $formatted_address ) ); |
|
1123 | 1123 | $formatted_address = preg_replace( '/\n\n+/', "\n", $formatted_address ); |
1124 | 1124 | |
1125 | 1125 | // Break newlines apart and remove empty lines/trim commas and white space. |
1126 | - $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
1126 | + $formatted_address = array_filter( array_map( 'wpinv_trim_formatted_address_line', explode( "\n", $formatted_address ) ) ); |
|
1127 | 1127 | |
1128 | 1128 | // Add html breaks. |
1129 | - $formatted_address = implode( $separator, $formatted_address ); |
|
1129 | + $formatted_address = implode( $separator, $formatted_address ); |
|
1130 | 1130 | |
1131 | - // We're done! |
|
1132 | - return $formatted_address; |
|
1131 | + // We're done! |
|
1132 | + return $formatted_address; |
|
1133 | 1133 | |
1134 | 1134 | } |
1135 | 1135 | |
@@ -1471,7 +1471,7 @@ discard block |
||
1471 | 1471 | add_action( 'wpinv_checkout_cart', 'wpinv_checkout_cart', 10 ); |
1472 | 1472 | |
1473 | 1473 | function wpinv_empty_cart_message() { |
1474 | - return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1474 | + return apply_filters( 'wpinv_empty_cart_message', '<span class="wpinv_empty_cart">' . __( 'Your cart is empty.', 'invoicing' ) . '</span>' ); |
|
1475 | 1475 | } |
1476 | 1476 | |
1477 | 1477 | /** |
@@ -2252,46 +2252,46 @@ discard block |
||
2252 | 2252 | global $invoicing; |
2253 | 2253 | |
2254 | 2254 | foreach ( array_keys( $items ) as $id ) { |
2255 | - if ( 'publish' != get_post_status( $id ) ) { |
|
2256 | - unset( $items[ $id ] ); |
|
2257 | - } |
|
2255 | + if ( 'publish' != get_post_status( $id ) ) { |
|
2256 | + unset( $items[ $id ] ); |
|
2257 | + } |
|
2258 | 2258 | } |
2259 | 2259 | |
2260 | 2260 | if ( empty( $items ) ) { |
2261 | - return aui()->alert( |
|
2262 | - array( |
|
2263 | - 'type' => 'warning', |
|
2264 | - 'content' => __( 'No published items found', 'invoicing' ), |
|
2265 | - ) |
|
2266 | - ); |
|
2261 | + return aui()->alert( |
|
2262 | + array( |
|
2263 | + 'type' => 'warning', |
|
2264 | + 'content' => __( 'No published items found', 'invoicing' ), |
|
2265 | + ) |
|
2266 | + ); |
|
2267 | 2267 | } |
2268 | 2268 | |
2269 | 2269 | $item_key = getpaid_convert_items_to_string( $items ); |
2270 | 2270 | |
2271 | 2271 | // Get the form elements and items. |
2272 | 2272 | $form = wpinv_get_default_payment_form(); |
2273 | - $elements = $invoicing->form_elements->get_form_elements( $form ); |
|
2274 | - $items = $invoicing->form_elements->convert_normal_items( $items ); |
|
2273 | + $elements = $invoicing->form_elements->get_form_elements( $form ); |
|
2274 | + $items = $invoicing->form_elements->convert_normal_items( $items ); |
|
2275 | 2275 | |
2276 | - ob_start(); |
|
2277 | - echo "<form class='wpinv_payment_form'>"; |
|
2278 | - do_action( 'wpinv_payment_form_top' ); |
|
2276 | + ob_start(); |
|
2277 | + echo "<form class='wpinv_payment_form'>"; |
|
2278 | + do_action( 'wpinv_payment_form_top' ); |
|
2279 | 2279 | echo "<input type='hidden' name='form_id' value='$form'/>"; |
2280 | 2280 | echo "<input type='hidden' name='form_items' value='$item_key'/>"; |
2281 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
2282 | - wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
2281 | + wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
2282 | + wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
2283 | 2283 | |
2284 | - foreach ( $elements as $element ) { |
|
2285 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form ); |
|
2286 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form ); |
|
2287 | - } |
|
2284 | + foreach ( $elements as $element ) { |
|
2285 | + do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form ); |
|
2286 | + do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form ); |
|
2287 | + } |
|
2288 | 2288 | |
2289 | - echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
|
2290 | - do_action( 'wpinv_payment_form_bottom' ); |
|
2291 | - echo '</form>'; |
|
2289 | + echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
|
2290 | + do_action( 'wpinv_payment_form_bottom' ); |
|
2291 | + echo '</form>'; |
|
2292 | 2292 | |
2293 | - $content = ob_get_clean(); |
|
2294 | - return str_replace( 'sr-only', '', $content ); |
|
2293 | + $content = ob_get_clean(); |
|
2294 | + return str_replace( 'sr-only', '', $content ); |
|
2295 | 2295 | } |
2296 | 2296 | |
2297 | 2297 | /** |
@@ -2303,47 +2303,47 @@ discard block |
||
2303 | 2303 | $invoice = wpinv_get_invoice( $invoice_id ); |
2304 | 2304 | |
2305 | 2305 | if ( empty( $invoice ) ) { |
2306 | - return aui()->alert( |
|
2307 | - array( |
|
2308 | - 'type' => 'warning', |
|
2309 | - 'content' => __( 'Invoice not found', 'invoicing' ), |
|
2310 | - ) |
|
2311 | - ); |
|
2306 | + return aui()->alert( |
|
2307 | + array( |
|
2308 | + 'type' => 'warning', |
|
2309 | + 'content' => __( 'Invoice not found', 'invoicing' ), |
|
2310 | + ) |
|
2311 | + ); |
|
2312 | 2312 | } |
2313 | 2313 | |
2314 | 2314 | if ( $invoice->is_paid() ) { |
2315 | - return aui()->alert( |
|
2316 | - array( |
|
2317 | - 'type' => 'warning', |
|
2318 | - 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
2319 | - ) |
|
2320 | - ); |
|
2315 | + return aui()->alert( |
|
2316 | + array( |
|
2317 | + 'type' => 'warning', |
|
2318 | + 'content' => __( 'Invoice has already been paid', 'invoicing' ), |
|
2319 | + ) |
|
2320 | + ); |
|
2321 | 2321 | } |
2322 | 2322 | |
2323 | 2323 | // Get the form elements and items. |
2324 | 2324 | $form = wpinv_get_default_payment_form(); |
2325 | - $elements = $invoicing->form_elements->get_form_elements( $form ); |
|
2326 | - $items = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice ); |
|
2325 | + $elements = $invoicing->form_elements->get_form_elements( $form ); |
|
2326 | + $items = $invoicing->form_elements->convert_checkout_items( $invoice->cart_details, $invoice ); |
|
2327 | 2327 | |
2328 | - ob_start(); |
|
2329 | - echo "<form class='wpinv_payment_form'>"; |
|
2330 | - do_action( 'wpinv_payment_form_top' ); |
|
2328 | + ob_start(); |
|
2329 | + echo "<form class='wpinv_payment_form'>"; |
|
2330 | + do_action( 'wpinv_payment_form_top' ); |
|
2331 | 2331 | echo "<input type='hidden' name='form_id' value='$form'/>"; |
2332 | 2332 | echo "<input type='hidden' name='invoice_id' value='$invoice_id'/>"; |
2333 | - wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
2334 | - wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
2333 | + wp_nonce_field( 'wpinv_payment_form', 'wpinv_payment_form' ); |
|
2334 | + wp_nonce_field( 'vat_validation', '_wpi_nonce' ); |
|
2335 | 2335 | |
2336 | - foreach ( $elements as $element ) { |
|
2337 | - do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form ); |
|
2338 | - do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form ); |
|
2339 | - } |
|
2336 | + foreach ( $elements as $element ) { |
|
2337 | + do_action( 'wpinv_frontend_render_payment_form_element', $element, $items, $form ); |
|
2338 | + do_action( "wpinv_frontend_render_payment_form_{$element['type']}", $element, $items, $form ); |
|
2339 | + } |
|
2340 | 2340 | |
2341 | - echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
|
2342 | - do_action( 'wpinv_payment_form_bottom' ); |
|
2343 | - echo '</form>'; |
|
2341 | + echo "<div class='wpinv_payment_form_errors alert alert-danger d-none'></div>"; |
|
2342 | + do_action( 'wpinv_payment_form_bottom' ); |
|
2343 | + echo '</form>'; |
|
2344 | 2344 | |
2345 | - $content = ob_get_clean(); |
|
2346 | - return str_replace( 'sr-only', '', $content ); |
|
2345 | + $content = ob_get_clean(); |
|
2346 | + return str_replace( 'sr-only', '', $content ); |
|
2347 | 2347 | } |
2348 | 2348 | |
2349 | 2349 | /** |
@@ -2398,7 +2398,7 @@ discard block |
||
2398 | 2398 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-form='$form'>$label</button>"; |
2399 | 2399 | } |
2400 | 2400 | |
2401 | - if ( ! empty( $items ) ) { |
|
2401 | + if ( ! empty( $items ) ) { |
|
2402 | 2402 | $items = esc_attr( $items ); |
2403 | 2403 | return "<button class='btn btn-primary getpaid-payment-button' type='button' data-nonce='$nonce' data-item='$items'>$label</button>"; |
2404 | 2404 | } |
@@ -45,17 +45,17 @@ |
||
45 | 45 | parent::__construct( $options ); |
46 | 46 | } |
47 | 47 | |
48 | - /** |
|
49 | - * The Super block output function. |
|
50 | - * |
|
51 | - * @param array $args |
|
52 | - * @param array $widget_args |
|
53 | - * @param string $content |
|
54 | - * |
|
55 | - * @return mixed|string|bool |
|
56 | - */ |
|
48 | + /** |
|
49 | + * The Super block output function. |
|
50 | + * |
|
51 | + * @param array $args |
|
52 | + * @param array $widget_args |
|
53 | + * @param string $content |
|
54 | + * |
|
55 | + * @return mixed|string|bool |
|
56 | + */ |
|
57 | 57 | public function output( $args = array(), $widget_args = array(), $content = '' ) { |
58 | - return wpinv_checkout_form(); |
|
58 | + return wpinv_checkout_form(); |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | } |