@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Invoice class. |
@@ -134,40 +134,40 @@ discard block |
||
134 | 134 | * |
135 | 135 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read. |
136 | 136 | */ |
137 | - public function __construct( $invoice = false ) { |
|
137 | + public function __construct($invoice = false) { |
|
138 | 138 | |
139 | - parent::__construct( $invoice ); |
|
139 | + parent::__construct($invoice); |
|
140 | 140 | |
141 | - if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) { |
|
142 | - $this->set_id( $invoice ); |
|
143 | - } elseif ( $invoice instanceof self ) { |
|
144 | - $this->set_id( $invoice->get_id() ); |
|
145 | - } elseif ( ! empty( $invoice->ID ) ) { |
|
146 | - $this->set_id( $invoice->ID ); |
|
147 | - } elseif ( is_array( $invoice ) ) { |
|
148 | - $this->set_props( $invoice ); |
|
141 | + if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) { |
|
142 | + $this->set_id($invoice); |
|
143 | + } elseif ($invoice instanceof self) { |
|
144 | + $this->set_id($invoice->get_id()); |
|
145 | + } elseif (!empty($invoice->ID)) { |
|
146 | + $this->set_id($invoice->ID); |
|
147 | + } elseif (is_array($invoice)) { |
|
148 | + $this->set_props($invoice); |
|
149 | 149 | |
150 | - if ( isset( $invoice['ID'] ) ) { |
|
151 | - $this->set_id( $invoice['ID'] ); |
|
150 | + if (isset($invoice['ID'])) { |
|
151 | + $this->set_id($invoice['ID']); |
|
152 | 152 | } |
153 | 153 | |
154 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) { |
|
155 | - $this->set_id( $invoice_id ); |
|
156 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) { |
|
157 | - $this->set_id( $invoice_id ); |
|
158 | - } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) { |
|
159 | - $this->set_id( $invoice_id ); |
|
160 | - }else { |
|
161 | - $this->set_object_read( true ); |
|
154 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) { |
|
155 | + $this->set_id($invoice_id); |
|
156 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) { |
|
157 | + $this->set_id($invoice_id); |
|
158 | + } elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) { |
|
159 | + $this->set_id($invoice_id); |
|
160 | + } else { |
|
161 | + $this->set_object_read(true); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | // Load the datastore. |
165 | - $this->data_store = GetPaid_Data_Store::load( $this->data_store_name ); |
|
165 | + $this->data_store = GetPaid_Data_Store::load($this->data_store_name); |
|
166 | 166 | |
167 | - if ( $this->get_id() > 0 ) { |
|
168 | - $this->post = get_post( $this->get_id() ); |
|
167 | + if ($this->get_id() > 0) { |
|
168 | + $this->post = get_post($this->get_id()); |
|
169 | 169 | $this->ID = $this->get_id(); |
170 | - $this->data_store->read( $this ); |
|
170 | + $this->data_store->read($this); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | } |
@@ -182,38 +182,38 @@ discard block |
||
182 | 182 | * @since 1.0.15 |
183 | 183 | * @return int |
184 | 184 | */ |
185 | - public static function get_invoice_id_by_field( $value, $field = 'key' ) { |
|
185 | + public static function get_invoice_id_by_field($value, $field = 'key') { |
|
186 | 186 | global $wpdb; |
187 | 187 | |
188 | 188 | // Trim the value. |
189 | - $value = trim( $value ); |
|
189 | + $value = trim($value); |
|
190 | 190 | |
191 | - if ( empty( $value ) ) { |
|
191 | + if (empty($value)) { |
|
192 | 192 | return 0; |
193 | 193 | } |
194 | 194 | |
195 | 195 | // Valid fields. |
196 | - $fields = array( 'key', 'number', 'transaction_id' ); |
|
196 | + $fields = array('key', 'number', 'transaction_id'); |
|
197 | 197 | |
198 | 198 | // Ensure a field has been passed. |
199 | - if ( empty( $field ) || ! in_array( $field, $fields ) ) { |
|
199 | + if (empty($field) || !in_array($field, $fields)) { |
|
200 | 200 | return 0; |
201 | 201 | } |
202 | 202 | |
203 | 203 | // Maybe retrieve from the cache. |
204 | - $invoice_id = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
205 | - if ( false !== $invoice_id ) { |
|
204 | + $invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
205 | + if (false !== $invoice_id) { |
|
206 | 206 | return $invoice_id; |
207 | 207 | } |
208 | 208 | |
209 | 209 | // Fetch from the db. |
210 | 210 | $table = $wpdb->prefix . 'getpaid_invoices'; |
211 | 211 | $invoice_id = (int) $wpdb->get_var( |
212 | - $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value ) |
|
212 | + $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value) |
|
213 | 213 | ); |
214 | 214 | |
215 | 215 | // Update the cache with our data |
216 | - wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" ); |
|
216 | + wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids"); |
|
217 | 217 | |
218 | 218 | return $invoice_id; |
219 | 219 | } |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | /** |
222 | 222 | * Checks if an invoice key is set. |
223 | 223 | */ |
224 | - public function _isset( $key ) { |
|
225 | - return isset( $this->data[$key] ) || method_exists( $this, "get_$key" ); |
|
224 | + public function _isset($key) { |
|
225 | + return isset($this->data[$key]) || method_exists($this, "get_$key"); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /* |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | * @param string $context View or edit context. |
248 | 248 | * @return int |
249 | 249 | */ |
250 | - public function get_parent_id( $context = 'view' ) { |
|
251 | - return (int) $this->get_prop( 'parent_id', $context ); |
|
250 | + public function get_parent_id($context = 'view') { |
|
251 | + return (int) $this->get_prop('parent_id', $context); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -258,7 +258,7 @@ discard block |
||
258 | 258 | * @return WPInv_Invoice |
259 | 259 | */ |
260 | 260 | public function get_parent_payment() { |
261 | - return new WPInv_Invoice( $this->get_parent_id() ); |
|
261 | + return new WPInv_Invoice($this->get_parent_id()); |
|
262 | 262 | } |
263 | 263 | |
264 | 264 | /** |
@@ -278,8 +278,8 @@ discard block |
||
278 | 278 | * @param string $context View or edit context. |
279 | 279 | * @return string |
280 | 280 | */ |
281 | - public function get_status( $context = 'view' ) { |
|
282 | - return $this->get_prop( 'status', $context ); |
|
281 | + public function get_status($context = 'view') { |
|
282 | + return $this->get_prop('status', $context); |
|
283 | 283 | } |
284 | 284 | |
285 | 285 | /** |
@@ -290,10 +290,10 @@ discard block |
||
290 | 290 | */ |
291 | 291 | public function get_all_statuses() { |
292 | 292 | |
293 | - $statuses = wpinv_get_invoice_statuses( true, true, $this ); |
|
293 | + $statuses = wpinv_get_invoice_statuses(true, true, $this); |
|
294 | 294 | |
295 | 295 | // For backwards compatibility. |
296 | - if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) { |
|
296 | + if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) { |
|
297 | 297 | $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses(); |
298 | 298 | } |
299 | 299 | |
@@ -309,9 +309,9 @@ discard block |
||
309 | 309 | public function get_status_nicename() { |
310 | 310 | $statuses = $this->get_all_statuses(); |
311 | 311 | |
312 | - $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status(); |
|
312 | + $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status(); |
|
313 | 313 | |
314 | - return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this ); |
|
314 | + return apply_filters('wpinv_get_invoice_status_nicename', $status, $this); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | /** |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | */ |
323 | 323 | public function get_status_label_html() { |
324 | 324 | |
325 | - $status_label = sanitize_text_field( $this->get_status_nicename() ); |
|
326 | - $status = sanitize_html_class( $this->get_status() ); |
|
325 | + $status_label = sanitize_text_field($this->get_status_nicename()); |
|
326 | + $status = sanitize_html_class($this->get_status()); |
|
327 | 327 | |
328 | 328 | return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>"; |
329 | 329 | } |
@@ -335,23 +335,23 @@ discard block |
||
335 | 335 | * @param string $context View or edit context. |
336 | 336 | * @return string |
337 | 337 | */ |
338 | - public function get_version( $context = 'view' ) { |
|
339 | - return $this->get_prop( 'version', $context ); |
|
338 | + public function get_version($context = 'view') { |
|
339 | + return $this->get_prop('version', $context); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | /** |
343 | 343 | * @deprecated |
344 | 344 | */ |
345 | - public function get_invoice_date( $format = true ) { |
|
346 | - $date = getpaid_format_date( $this->get_date_completed() ); |
|
347 | - $date = empty( $date ) ? $this->get_date_created() : $this->get_date_completed(); |
|
348 | - $formatted = getpaid_format_date( $date ); |
|
345 | + public function get_invoice_date($format = true) { |
|
346 | + $date = getpaid_format_date($this->get_date_completed()); |
|
347 | + $date = empty($date) ? $this->get_date_created() : $this->get_date_completed(); |
|
348 | + $formatted = getpaid_format_date($date); |
|
349 | 349 | |
350 | - if ( $format ) { |
|
350 | + if ($format) { |
|
351 | 351 | return $formatted; |
352 | 352 | } |
353 | 353 | |
354 | - return empty( $formatted ) ? '' : $date; |
|
354 | + return empty($formatted) ? '' : $date; |
|
355 | 355 | |
356 | 356 | } |
357 | 357 | |
@@ -362,8 +362,8 @@ discard block |
||
362 | 362 | * @param string $context View or edit context. |
363 | 363 | * @return string |
364 | 364 | */ |
365 | - public function get_date_created( $context = 'view' ) { |
|
366 | - return $this->get_prop( 'date_created', $context ); |
|
365 | + public function get_date_created($context = 'view') { |
|
366 | + return $this->get_prop('date_created', $context); |
|
367 | 367 | } |
368 | 368 | |
369 | 369 | /** |
@@ -373,8 +373,8 @@ discard block |
||
373 | 373 | * @param string $context View or edit context. |
374 | 374 | * @return string |
375 | 375 | */ |
376 | - public function get_created_date( $context = 'view' ) { |
|
377 | - return $this->get_date_created( $context ); |
|
376 | + public function get_created_date($context = 'view') { |
|
377 | + return $this->get_date_created($context); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | /** |
@@ -384,11 +384,11 @@ discard block |
||
384 | 384 | * @param string $context View or edit context. |
385 | 385 | * @return string |
386 | 386 | */ |
387 | - public function get_date_created_gmt( $context = 'view' ) { |
|
388 | - $date = $this->get_date_created( $context ); |
|
387 | + public function get_date_created_gmt($context = 'view') { |
|
388 | + $date = $this->get_date_created($context); |
|
389 | 389 | |
390 | - if ( $date ) { |
|
391 | - $date = get_gmt_from_date( $date ); |
|
390 | + if ($date) { |
|
391 | + $date = get_gmt_from_date($date); |
|
392 | 392 | } |
393 | 393 | return $date; |
394 | 394 | } |
@@ -400,8 +400,8 @@ discard block |
||
400 | 400 | * @param string $context View or edit context. |
401 | 401 | * @return string |
402 | 402 | */ |
403 | - public function get_date_modified( $context = 'view' ) { |
|
404 | - return $this->get_prop( 'date_modified', $context ); |
|
403 | + public function get_date_modified($context = 'view') { |
|
404 | + return $this->get_prop('date_modified', $context); |
|
405 | 405 | } |
406 | 406 | |
407 | 407 | /** |
@@ -411,8 +411,8 @@ discard block |
||
411 | 411 | * @param string $context View or edit context. |
412 | 412 | * @return string |
413 | 413 | */ |
414 | - public function get_modified_date( $context = 'view' ) { |
|
415 | - return $this->get_date_modified( $context ); |
|
414 | + public function get_modified_date($context = 'view') { |
|
415 | + return $this->get_date_modified($context); |
|
416 | 416 | } |
417 | 417 | |
418 | 418 | /** |
@@ -422,11 +422,11 @@ discard block |
||
422 | 422 | * @param string $context View or edit context. |
423 | 423 | * @return string |
424 | 424 | */ |
425 | - public function get_date_modified_gmt( $context = 'view' ) { |
|
426 | - $date = $this->get_date_modified( $context ); |
|
425 | + public function get_date_modified_gmt($context = 'view') { |
|
426 | + $date = $this->get_date_modified($context); |
|
427 | 427 | |
428 | - if ( $date ) { |
|
429 | - $date = get_gmt_from_date( $date ); |
|
428 | + if ($date) { |
|
429 | + $date = get_gmt_from_date($date); |
|
430 | 430 | } |
431 | 431 | return $date; |
432 | 432 | } |
@@ -438,8 +438,8 @@ discard block |
||
438 | 438 | * @param string $context View or edit context. |
439 | 439 | * @return string |
440 | 440 | */ |
441 | - public function get_due_date( $context = 'view' ) { |
|
442 | - return $this->get_prop( 'due_date', $context ); |
|
441 | + public function get_due_date($context = 'view') { |
|
442 | + return $this->get_prop('due_date', $context); |
|
443 | 443 | } |
444 | 444 | |
445 | 445 | /** |
@@ -449,8 +449,8 @@ discard block |
||
449 | 449 | * @param string $context View or edit context. |
450 | 450 | * @return string |
451 | 451 | */ |
452 | - public function get_date_due( $context = 'view' ) { |
|
453 | - return $this->get_due_date( $context ); |
|
452 | + public function get_date_due($context = 'view') { |
|
453 | + return $this->get_due_date($context); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | /** |
@@ -460,11 +460,11 @@ discard block |
||
460 | 460 | * @param string $context View or edit context. |
461 | 461 | * @return string |
462 | 462 | */ |
463 | - public function get_due_date_gmt( $context = 'view' ) { |
|
464 | - $date = $this->get_due_date( $context ); |
|
463 | + public function get_due_date_gmt($context = 'view') { |
|
464 | + $date = $this->get_due_date($context); |
|
465 | 465 | |
466 | - if ( $date ) { |
|
467 | - $date = get_gmt_from_date( $date ); |
|
466 | + if ($date) { |
|
467 | + $date = get_gmt_from_date($date); |
|
468 | 468 | } |
469 | 469 | return $date; |
470 | 470 | } |
@@ -476,8 +476,8 @@ discard block |
||
476 | 476 | * @param string $context View or edit context. |
477 | 477 | * @return string |
478 | 478 | */ |
479 | - public function get_gmt_date_due( $context = 'view' ) { |
|
480 | - return $this->get_due_date_gmt( $context ); |
|
479 | + public function get_gmt_date_due($context = 'view') { |
|
480 | + return $this->get_due_date_gmt($context); |
|
481 | 481 | } |
482 | 482 | |
483 | 483 | /** |
@@ -487,8 +487,8 @@ discard block |
||
487 | 487 | * @param string $context View or edit context. |
488 | 488 | * @return string |
489 | 489 | */ |
490 | - public function get_completed_date( $context = 'view' ) { |
|
491 | - return $this->get_prop( 'completed_date', $context ); |
|
490 | + public function get_completed_date($context = 'view') { |
|
491 | + return $this->get_prop('completed_date', $context); |
|
492 | 492 | } |
493 | 493 | |
494 | 494 | /** |
@@ -498,8 +498,8 @@ discard block |
||
498 | 498 | * @param string $context View or edit context. |
499 | 499 | * @return string |
500 | 500 | */ |
501 | - public function get_date_completed( $context = 'view' ) { |
|
502 | - return $this->get_completed_date( $context ); |
|
501 | + public function get_date_completed($context = 'view') { |
|
502 | + return $this->get_completed_date($context); |
|
503 | 503 | } |
504 | 504 | |
505 | 505 | /** |
@@ -509,11 +509,11 @@ discard block |
||
509 | 509 | * @param string $context View or edit context. |
510 | 510 | * @return string |
511 | 511 | */ |
512 | - public function get_completed_date_gmt( $context = 'view' ) { |
|
513 | - $date = $this->get_completed_date( $context ); |
|
512 | + public function get_completed_date_gmt($context = 'view') { |
|
513 | + $date = $this->get_completed_date($context); |
|
514 | 514 | |
515 | - if ( $date ) { |
|
516 | - $date = get_gmt_from_date( $date ); |
|
515 | + if ($date) { |
|
516 | + $date = get_gmt_from_date($date); |
|
517 | 517 | } |
518 | 518 | return $date; |
519 | 519 | } |
@@ -525,8 +525,8 @@ discard block |
||
525 | 525 | * @param string $context View or edit context. |
526 | 526 | * @return string |
527 | 527 | */ |
528 | - public function get_gmt_completed_date( $context = 'view' ) { |
|
529 | - return $this->get_completed_date_gmt( $context ); |
|
528 | + public function get_gmt_completed_date($context = 'view') { |
|
529 | + return $this->get_completed_date_gmt($context); |
|
530 | 530 | } |
531 | 531 | |
532 | 532 | /** |
@@ -536,12 +536,12 @@ discard block |
||
536 | 536 | * @param string $context View or edit context. |
537 | 537 | * @return string |
538 | 538 | */ |
539 | - public function get_number( $context = 'view' ) { |
|
540 | - $number = $this->get_prop( 'number', $context ); |
|
539 | + public function get_number($context = 'view') { |
|
540 | + $number = $this->get_prop('number', $context); |
|
541 | 541 | |
542 | - if ( empty( $number ) ) { |
|
542 | + if (empty($number)) { |
|
543 | 543 | $number = $this->generate_number(); |
544 | - $this->set_number( $this->generate_number() ); |
|
544 | + $this->set_number($this->generate_number()); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | return $number; |
@@ -555,8 +555,8 @@ discard block |
||
555 | 555 | public function maybe_set_number() { |
556 | 556 | $number = $this->get_number(); |
557 | 557 | |
558 | - if ( empty( $number ) || $this->get_id() == $number ) { |
|
559 | - $this->set_number( $this->generate_number() ); |
|
558 | + if (empty($number) || $this->get_id() == $number) { |
|
559 | + $this->set_number($this->generate_number()); |
|
560 | 560 | } |
561 | 561 | |
562 | 562 | } |
@@ -568,8 +568,8 @@ discard block |
||
568 | 568 | * @param string $context View or edit context. |
569 | 569 | * @return string |
570 | 570 | */ |
571 | - public function get_key( $context = 'view' ) { |
|
572 | - return $this->get_prop( 'key', $context ); |
|
571 | + public function get_key($context = 'view') { |
|
572 | + return $this->get_prop('key', $context); |
|
573 | 573 | } |
574 | 574 | |
575 | 575 | /** |
@@ -580,9 +580,9 @@ discard block |
||
580 | 580 | public function maybe_set_key() { |
581 | 581 | $key = $this->get_key(); |
582 | 582 | |
583 | - if ( empty( $key ) ) { |
|
584 | - $key = $this->generate_key( $this->get_type() . '_' ); |
|
585 | - $this->set_key( $key ); |
|
583 | + if (empty($key)) { |
|
584 | + $key = $this->generate_key($this->get_type() . '_'); |
|
585 | + $this->set_key($key); |
|
586 | 586 | } |
587 | 587 | |
588 | 588 | } |
@@ -594,15 +594,15 @@ discard block |
||
594 | 594 | * @param string $context View or edit context. |
595 | 595 | * @return string |
596 | 596 | */ |
597 | - public function get_type( $context = 'view' ) { |
|
598 | - return $this->get_prop( 'type', $context ); |
|
597 | + public function get_type($context = 'view') { |
|
598 | + return $this->get_prop('type', $context); |
|
599 | 599 | } |
600 | 600 | |
601 | 601 | /** |
602 | 602 | * @deprecated |
603 | 603 | */ |
604 | 604 | public function get_invoice_quote_type() { |
605 | - ucfirst( $this->get_type() ); |
|
605 | + ucfirst($this->get_type()); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
@@ -612,8 +612,8 @@ discard block |
||
612 | 612 | * @param string $context View or edit context. |
613 | 613 | * @return string |
614 | 614 | */ |
615 | - public function get_post_type( $context = 'view' ) { |
|
616 | - return $this->get_prop( 'post_type', $context ); |
|
615 | + public function get_post_type($context = 'view') { |
|
616 | + return $this->get_prop('post_type', $context); |
|
617 | 617 | } |
618 | 618 | |
619 | 619 | /** |
@@ -623,8 +623,8 @@ discard block |
||
623 | 623 | * @param string $context View or edit context. |
624 | 624 | * @return string |
625 | 625 | */ |
626 | - public function get_mode( $context = 'view' ) { |
|
627 | - return $this->get_prop( 'mode', $context ); |
|
626 | + public function get_mode($context = 'view') { |
|
627 | + return $this->get_prop('mode', $context); |
|
628 | 628 | } |
629 | 629 | |
630 | 630 | /** |
@@ -634,13 +634,13 @@ discard block |
||
634 | 634 | * @param string $context View or edit context. |
635 | 635 | * @return string |
636 | 636 | */ |
637 | - public function get_path( $context = 'view' ) { |
|
638 | - $path = $this->get_prop( 'path', $context ); |
|
639 | - $prefix = wpinv_post_name_prefix( $this->get_post_type() ); |
|
637 | + public function get_path($context = 'view') { |
|
638 | + $path = $this->get_prop('path', $context); |
|
639 | + $prefix = wpinv_post_name_prefix($this->get_post_type()); |
|
640 | 640 | |
641 | - if ( 0 !== strpos( $path, $prefix ) ) { |
|
642 | - $path = sanitize_title( $prefix . $this->get_id() ); |
|
643 | - $this->set_path( $path ); |
|
641 | + if (0 !== strpos($path, $prefix)) { |
|
642 | + $path = sanitize_title($prefix . $this->get_id()); |
|
643 | + $this->set_path($path); |
|
644 | 644 | } |
645 | 645 | |
646 | 646 | return $path; |
@@ -653,8 +653,8 @@ discard block |
||
653 | 653 | * @param string $context View or edit context. |
654 | 654 | * @return string |
655 | 655 | */ |
656 | - public function get_name( $context = 'view' ) { |
|
657 | - return $this->get_prop( 'title', $context ); |
|
656 | + public function get_name($context = 'view') { |
|
657 | + return $this->get_prop('title', $context); |
|
658 | 658 | } |
659 | 659 | |
660 | 660 | /** |
@@ -664,8 +664,8 @@ discard block |
||
664 | 664 | * @param string $context View or edit context. |
665 | 665 | * @return string |
666 | 666 | */ |
667 | - public function get_title( $context = 'view' ) { |
|
668 | - return $this->get_name( $context ); |
|
667 | + public function get_title($context = 'view') { |
|
668 | + return $this->get_name($context); |
|
669 | 669 | } |
670 | 670 | |
671 | 671 | /** |
@@ -675,8 +675,8 @@ discard block |
||
675 | 675 | * @param string $context View or edit context. |
676 | 676 | * @return string |
677 | 677 | */ |
678 | - public function get_description( $context = 'view' ) { |
|
679 | - return $this->get_prop( 'description', $context ); |
|
678 | + public function get_description($context = 'view') { |
|
679 | + return $this->get_prop('description', $context); |
|
680 | 680 | } |
681 | 681 | |
682 | 682 | /** |
@@ -686,8 +686,8 @@ discard block |
||
686 | 686 | * @param string $context View or edit context. |
687 | 687 | * @return string |
688 | 688 | */ |
689 | - public function get_excerpt( $context = 'view' ) { |
|
690 | - return $this->get_description( $context ); |
|
689 | + public function get_excerpt($context = 'view') { |
|
690 | + return $this->get_description($context); |
|
691 | 691 | } |
692 | 692 | |
693 | 693 | /** |
@@ -697,8 +697,8 @@ discard block |
||
697 | 697 | * @param string $context View or edit context. |
698 | 698 | * @return string |
699 | 699 | */ |
700 | - public function get_summary( $context = 'view' ) { |
|
701 | - return $this->get_description( $context ); |
|
700 | + public function get_summary($context = 'view') { |
|
701 | + return $this->get_description($context); |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | /** |
@@ -708,25 +708,25 @@ discard block |
||
708 | 708 | * @param string $context View or edit context. |
709 | 709 | * @return array |
710 | 710 | */ |
711 | - public function get_user_info( $context = 'view' ) { |
|
711 | + public function get_user_info($context = 'view') { |
|
712 | 712 | |
713 | 713 | $user_info = array( |
714 | - 'user_id' => $this->get_user_id( $context ), |
|
715 | - 'email' => $this->get_email( $context ), |
|
716 | - 'first_name' => $this->get_first_name( $context ), |
|
717 | - 'last_name' => $this->get_last_name( $context ), |
|
718 | - 'address' => $this->get_address( $context ), |
|
719 | - 'phone' => $this->get_phone( $context ), |
|
720 | - 'city' => $this->get_city( $context ), |
|
721 | - 'country' => $this->get_country( $context ), |
|
722 | - 'state' => $this->get_state( $context ), |
|
723 | - 'zip' => $this->get_zip( $context ), |
|
724 | - 'company' => $this->get_company( $context ), |
|
725 | - 'vat_number' => $this->get_vat_number( $context ), |
|
726 | - 'discount' => $this->get_discount_code( $context ), |
|
714 | + 'user_id' => $this->get_user_id($context), |
|
715 | + 'email' => $this->get_email($context), |
|
716 | + 'first_name' => $this->get_first_name($context), |
|
717 | + 'last_name' => $this->get_last_name($context), |
|
718 | + 'address' => $this->get_address($context), |
|
719 | + 'phone' => $this->get_phone($context), |
|
720 | + 'city' => $this->get_city($context), |
|
721 | + 'country' => $this->get_country($context), |
|
722 | + 'state' => $this->get_state($context), |
|
723 | + 'zip' => $this->get_zip($context), |
|
724 | + 'company' => $this->get_company($context), |
|
725 | + 'vat_number' => $this->get_vat_number($context), |
|
726 | + 'discount' => $this->get_discount_code($context), |
|
727 | 727 | ); |
728 | 728 | |
729 | - return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this ); |
|
729 | + return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this); |
|
730 | 730 | |
731 | 731 | } |
732 | 732 | |
@@ -737,8 +737,8 @@ discard block |
||
737 | 737 | * @param string $context View or edit context. |
738 | 738 | * @return int |
739 | 739 | */ |
740 | - public function get_author( $context = 'view' ) { |
|
741 | - return (int) $this->get_prop( 'author', $context ); |
|
740 | + public function get_author($context = 'view') { |
|
741 | + return (int) $this->get_prop('author', $context); |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | /** |
@@ -748,8 +748,8 @@ discard block |
||
748 | 748 | * @param string $context View or edit context. |
749 | 749 | * @return int |
750 | 750 | */ |
751 | - public function get_user_id( $context = 'view' ) { |
|
752 | - return $this->get_author( $context ); |
|
751 | + public function get_user_id($context = 'view') { |
|
752 | + return $this->get_author($context); |
|
753 | 753 | } |
754 | 754 | |
755 | 755 | /** |
@@ -759,8 +759,8 @@ discard block |
||
759 | 759 | * @param string $context View or edit context. |
760 | 760 | * @return int |
761 | 761 | */ |
762 | - public function get_customer_id( $context = 'view' ) { |
|
763 | - return $this->get_author( $context ); |
|
762 | + public function get_customer_id($context = 'view') { |
|
763 | + return $this->get_author($context); |
|
764 | 764 | } |
765 | 765 | |
766 | 766 | /** |
@@ -770,8 +770,8 @@ discard block |
||
770 | 770 | * @param string $context View or edit context. |
771 | 771 | * @return string |
772 | 772 | */ |
773 | - public function get_ip( $context = 'view' ) { |
|
774 | - return $this->get_prop( 'user_ip', $context ); |
|
773 | + public function get_ip($context = 'view') { |
|
774 | + return $this->get_prop('user_ip', $context); |
|
775 | 775 | } |
776 | 776 | |
777 | 777 | /** |
@@ -781,8 +781,8 @@ discard block |
||
781 | 781 | * @param string $context View or edit context. |
782 | 782 | * @return string |
783 | 783 | */ |
784 | - public function get_user_ip( $context = 'view' ) { |
|
785 | - return $this->get_ip( $context ); |
|
784 | + public function get_user_ip($context = 'view') { |
|
785 | + return $this->get_ip($context); |
|
786 | 786 | } |
787 | 787 | |
788 | 788 | /** |
@@ -792,8 +792,8 @@ discard block |
||
792 | 792 | * @param string $context View or edit context. |
793 | 793 | * @return string |
794 | 794 | */ |
795 | - public function get_customer_ip( $context = 'view' ) { |
|
796 | - return $this->get_ip( $context ); |
|
795 | + public function get_customer_ip($context = 'view') { |
|
796 | + return $this->get_ip($context); |
|
797 | 797 | } |
798 | 798 | |
799 | 799 | /** |
@@ -803,8 +803,8 @@ discard block |
||
803 | 803 | * @param string $context View or edit context. |
804 | 804 | * @return string |
805 | 805 | */ |
806 | - public function get_first_name( $context = 'view' ) { |
|
807 | - return $this->get_prop( 'first_name', $context ); |
|
806 | + public function get_first_name($context = 'view') { |
|
807 | + return $this->get_prop('first_name', $context); |
|
808 | 808 | } |
809 | 809 | |
810 | 810 | /** |
@@ -814,8 +814,8 @@ discard block |
||
814 | 814 | * @param string $context View or edit context. |
815 | 815 | * @return int |
816 | 816 | */ |
817 | - public function get_user_first_name( $context = 'view' ) { |
|
818 | - return $this->get_first_name( $context ); |
|
817 | + public function get_user_first_name($context = 'view') { |
|
818 | + return $this->get_first_name($context); |
|
819 | 819 | } |
820 | 820 | |
821 | 821 | /** |
@@ -825,8 +825,8 @@ discard block |
||
825 | 825 | * @param string $context View or edit context. |
826 | 826 | * @return int |
827 | 827 | */ |
828 | - public function get_customer_first_name( $context = 'view' ) { |
|
829 | - return $this->get_first_name( $context ); |
|
828 | + public function get_customer_first_name($context = 'view') { |
|
829 | + return $this->get_first_name($context); |
|
830 | 830 | } |
831 | 831 | |
832 | 832 | /** |
@@ -836,8 +836,8 @@ discard block |
||
836 | 836 | * @param string $context View or edit context. |
837 | 837 | * @return string |
838 | 838 | */ |
839 | - public function get_last_name( $context = 'view' ) { |
|
840 | - return $this->get_prop( 'last_name', $context ); |
|
839 | + public function get_last_name($context = 'view') { |
|
840 | + return $this->get_prop('last_name', $context); |
|
841 | 841 | } |
842 | 842 | |
843 | 843 | /** |
@@ -847,8 +847,8 @@ discard block |
||
847 | 847 | * @param string $context View or edit context. |
848 | 848 | * @return int |
849 | 849 | */ |
850 | - public function get_user_last_name( $context = 'view' ) { |
|
851 | - return $this->get_last_name( $context ); |
|
850 | + public function get_user_last_name($context = 'view') { |
|
851 | + return $this->get_last_name($context); |
|
852 | 852 | } |
853 | 853 | |
854 | 854 | /** |
@@ -858,8 +858,8 @@ discard block |
||
858 | 858 | * @param string $context View or edit context. |
859 | 859 | * @return int |
860 | 860 | */ |
861 | - public function get_customer_last_name( $context = 'view' ) { |
|
862 | - return $this->get_last_name( $context ); |
|
861 | + public function get_customer_last_name($context = 'view') { |
|
862 | + return $this->get_last_name($context); |
|
863 | 863 | } |
864 | 864 | |
865 | 865 | /** |
@@ -869,8 +869,8 @@ discard block |
||
869 | 869 | * @param string $context View or edit context. |
870 | 870 | * @return string |
871 | 871 | */ |
872 | - public function get_full_name( $context = 'view' ) { |
|
873 | - return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) ); |
|
872 | + public function get_full_name($context = 'view') { |
|
873 | + return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context)); |
|
874 | 874 | } |
875 | 875 | |
876 | 876 | /** |
@@ -880,8 +880,8 @@ discard block |
||
880 | 880 | * @param string $context View or edit context. |
881 | 881 | * @return int |
882 | 882 | */ |
883 | - public function get_user_full_name( $context = 'view' ) { |
|
884 | - return $this->get_full_name( $context ); |
|
883 | + public function get_user_full_name($context = 'view') { |
|
884 | + return $this->get_full_name($context); |
|
885 | 885 | } |
886 | 886 | |
887 | 887 | /** |
@@ -891,8 +891,8 @@ discard block |
||
891 | 891 | * @param string $context View or edit context. |
892 | 892 | * @return int |
893 | 893 | */ |
894 | - public function get_customer_full_name( $context = 'view' ) { |
|
895 | - return $this->get_full_name( $context ); |
|
894 | + public function get_customer_full_name($context = 'view') { |
|
895 | + return $this->get_full_name($context); |
|
896 | 896 | } |
897 | 897 | |
898 | 898 | /** |
@@ -902,8 +902,8 @@ discard block |
||
902 | 902 | * @param string $context View or edit context. |
903 | 903 | * @return string |
904 | 904 | */ |
905 | - public function get_phone( $context = 'view' ) { |
|
906 | - return $this->get_prop( 'phone', $context ); |
|
905 | + public function get_phone($context = 'view') { |
|
906 | + return $this->get_prop('phone', $context); |
|
907 | 907 | } |
908 | 908 | |
909 | 909 | /** |
@@ -913,8 +913,8 @@ discard block |
||
913 | 913 | * @param string $context View or edit context. |
914 | 914 | * @return int |
915 | 915 | */ |
916 | - public function get_phone_number( $context = 'view' ) { |
|
917 | - return $this->get_phone( $context ); |
|
916 | + public function get_phone_number($context = 'view') { |
|
917 | + return $this->get_phone($context); |
|
918 | 918 | } |
919 | 919 | |
920 | 920 | /** |
@@ -924,8 +924,8 @@ discard block |
||
924 | 924 | * @param string $context View or edit context. |
925 | 925 | * @return int |
926 | 926 | */ |
927 | - public function get_user_phone( $context = 'view' ) { |
|
928 | - return $this->get_phone( $context ); |
|
927 | + public function get_user_phone($context = 'view') { |
|
928 | + return $this->get_phone($context); |
|
929 | 929 | } |
930 | 930 | |
931 | 931 | /** |
@@ -935,8 +935,8 @@ discard block |
||
935 | 935 | * @param string $context View or edit context. |
936 | 936 | * @return int |
937 | 937 | */ |
938 | - public function get_customer_phone( $context = 'view' ) { |
|
939 | - return $this->get_phone( $context ); |
|
938 | + public function get_customer_phone($context = 'view') { |
|
939 | + return $this->get_phone($context); |
|
940 | 940 | } |
941 | 941 | |
942 | 942 | /** |
@@ -946,8 +946,8 @@ discard block |
||
946 | 946 | * @param string $context View or edit context. |
947 | 947 | * @return string |
948 | 948 | */ |
949 | - public function get_email( $context = 'view' ) { |
|
950 | - return $this->get_prop( 'email', $context ); |
|
949 | + public function get_email($context = 'view') { |
|
950 | + return $this->get_prop('email', $context); |
|
951 | 951 | } |
952 | 952 | |
953 | 953 | /** |
@@ -957,8 +957,8 @@ discard block |
||
957 | 957 | * @param string $context View or edit context. |
958 | 958 | * @return string |
959 | 959 | */ |
960 | - public function get_email_address( $context = 'view' ) { |
|
961 | - return $this->get_email( $context ); |
|
960 | + public function get_email_address($context = 'view') { |
|
961 | + return $this->get_email($context); |
|
962 | 962 | } |
963 | 963 | |
964 | 964 | /** |
@@ -968,8 +968,8 @@ discard block |
||
968 | 968 | * @param string $context View or edit context. |
969 | 969 | * @return int |
970 | 970 | */ |
971 | - public function get_user_email( $context = 'view' ) { |
|
972 | - return $this->get_email( $context ); |
|
971 | + public function get_user_email($context = 'view') { |
|
972 | + return $this->get_email($context); |
|
973 | 973 | } |
974 | 974 | |
975 | 975 | /** |
@@ -979,8 +979,8 @@ discard block |
||
979 | 979 | * @param string $context View or edit context. |
980 | 980 | * @return int |
981 | 981 | */ |
982 | - public function get_customer_email( $context = 'view' ) { |
|
983 | - return $this->get_email( $context ); |
|
982 | + public function get_customer_email($context = 'view') { |
|
983 | + return $this->get_email($context); |
|
984 | 984 | } |
985 | 985 | |
986 | 986 | /** |
@@ -990,9 +990,9 @@ discard block |
||
990 | 990 | * @param string $context View or edit context. |
991 | 991 | * @return string |
992 | 992 | */ |
993 | - public function get_country( $context = 'view' ) { |
|
994 | - $country = $this->get_prop( 'country', $context ); |
|
995 | - return empty( $country ) ? wpinv_get_default_country() : $country; |
|
993 | + public function get_country($context = 'view') { |
|
994 | + $country = $this->get_prop('country', $context); |
|
995 | + return empty($country) ? wpinv_get_default_country() : $country; |
|
996 | 996 | } |
997 | 997 | |
998 | 998 | /** |
@@ -1002,8 +1002,8 @@ discard block |
||
1002 | 1002 | * @param string $context View or edit context. |
1003 | 1003 | * @return int |
1004 | 1004 | */ |
1005 | - public function get_user_country( $context = 'view' ) { |
|
1006 | - return $this->get_country( $context ); |
|
1005 | + public function get_user_country($context = 'view') { |
|
1006 | + return $this->get_country($context); |
|
1007 | 1007 | } |
1008 | 1008 | |
1009 | 1009 | /** |
@@ -1013,8 +1013,8 @@ discard block |
||
1013 | 1013 | * @param string $context View or edit context. |
1014 | 1014 | * @return int |
1015 | 1015 | */ |
1016 | - public function get_customer_country( $context = 'view' ) { |
|
1017 | - return $this->get_country( $context ); |
|
1016 | + public function get_customer_country($context = 'view') { |
|
1017 | + return $this->get_country($context); |
|
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | /** |
@@ -1024,9 +1024,9 @@ discard block |
||
1024 | 1024 | * @param string $context View or edit context. |
1025 | 1025 | * @return string |
1026 | 1026 | */ |
1027 | - public function get_state( $context = 'view' ) { |
|
1028 | - $state = $this->get_prop( 'state', $context ); |
|
1029 | - return empty( $state ) ? wpinv_get_default_state() : $state; |
|
1027 | + public function get_state($context = 'view') { |
|
1028 | + $state = $this->get_prop('state', $context); |
|
1029 | + return empty($state) ? wpinv_get_default_state() : $state; |
|
1030 | 1030 | } |
1031 | 1031 | |
1032 | 1032 | /** |
@@ -1036,8 +1036,8 @@ discard block |
||
1036 | 1036 | * @param string $context View or edit context. |
1037 | 1037 | * @return int |
1038 | 1038 | */ |
1039 | - public function get_user_state( $context = 'view' ) { |
|
1040 | - return $this->get_state( $context ); |
|
1039 | + public function get_user_state($context = 'view') { |
|
1040 | + return $this->get_state($context); |
|
1041 | 1041 | } |
1042 | 1042 | |
1043 | 1043 | /** |
@@ -1047,8 +1047,8 @@ discard block |
||
1047 | 1047 | * @param string $context View or edit context. |
1048 | 1048 | * @return int |
1049 | 1049 | */ |
1050 | - public function get_customer_state( $context = 'view' ) { |
|
1051 | - return $this->get_state( $context ); |
|
1050 | + public function get_customer_state($context = 'view') { |
|
1051 | + return $this->get_state($context); |
|
1052 | 1052 | } |
1053 | 1053 | |
1054 | 1054 | /** |
@@ -1058,8 +1058,8 @@ discard block |
||
1058 | 1058 | * @param string $context View or edit context. |
1059 | 1059 | * @return string |
1060 | 1060 | */ |
1061 | - public function get_city( $context = 'view' ) { |
|
1062 | - return $this->get_prop( 'city', $context ); |
|
1061 | + public function get_city($context = 'view') { |
|
1062 | + return $this->get_prop('city', $context); |
|
1063 | 1063 | } |
1064 | 1064 | |
1065 | 1065 | /** |
@@ -1069,8 +1069,8 @@ discard block |
||
1069 | 1069 | * @param string $context View or edit context. |
1070 | 1070 | * @return string |
1071 | 1071 | */ |
1072 | - public function get_user_city( $context = 'view' ) { |
|
1073 | - return $this->get_city( $context ); |
|
1072 | + public function get_user_city($context = 'view') { |
|
1073 | + return $this->get_city($context); |
|
1074 | 1074 | } |
1075 | 1075 | |
1076 | 1076 | /** |
@@ -1080,8 +1080,8 @@ discard block |
||
1080 | 1080 | * @param string $context View or edit context. |
1081 | 1081 | * @return string |
1082 | 1082 | */ |
1083 | - public function get_customer_city( $context = 'view' ) { |
|
1084 | - return $this->get_city( $context ); |
|
1083 | + public function get_customer_city($context = 'view') { |
|
1084 | + return $this->get_city($context); |
|
1085 | 1085 | } |
1086 | 1086 | |
1087 | 1087 | /** |
@@ -1091,8 +1091,8 @@ discard block |
||
1091 | 1091 | * @param string $context View or edit context. |
1092 | 1092 | * @return string |
1093 | 1093 | */ |
1094 | - public function get_zip( $context = 'view' ) { |
|
1095 | - return $this->get_prop( 'zip', $context ); |
|
1094 | + public function get_zip($context = 'view') { |
|
1095 | + return $this->get_prop('zip', $context); |
|
1096 | 1096 | } |
1097 | 1097 | |
1098 | 1098 | /** |
@@ -1102,8 +1102,8 @@ discard block |
||
1102 | 1102 | * @param string $context View or edit context. |
1103 | 1103 | * @return string |
1104 | 1104 | */ |
1105 | - public function get_user_zip( $context = 'view' ) { |
|
1106 | - return $this->get_zip( $context ); |
|
1105 | + public function get_user_zip($context = 'view') { |
|
1106 | + return $this->get_zip($context); |
|
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | /** |
@@ -1113,8 +1113,8 @@ discard block |
||
1113 | 1113 | * @param string $context View or edit context. |
1114 | 1114 | * @return string |
1115 | 1115 | */ |
1116 | - public function get_customer_zip( $context = 'view' ) { |
|
1117 | - return $this->get_zip( $context ); |
|
1116 | + public function get_customer_zip($context = 'view') { |
|
1117 | + return $this->get_zip($context); |
|
1118 | 1118 | } |
1119 | 1119 | |
1120 | 1120 | /** |
@@ -1124,8 +1124,8 @@ discard block |
||
1124 | 1124 | * @param string $context View or edit context. |
1125 | 1125 | * @return string |
1126 | 1126 | */ |
1127 | - public function get_company( $context = 'view' ) { |
|
1128 | - return $this->get_prop( 'company', $context ); |
|
1127 | + public function get_company($context = 'view') { |
|
1128 | + return $this->get_prop('company', $context); |
|
1129 | 1129 | } |
1130 | 1130 | |
1131 | 1131 | /** |
@@ -1135,8 +1135,8 @@ discard block |
||
1135 | 1135 | * @param string $context View or edit context. |
1136 | 1136 | * @return string |
1137 | 1137 | */ |
1138 | - public function get_user_company( $context = 'view' ) { |
|
1139 | - return $this->get_company( $context ); |
|
1138 | + public function get_user_company($context = 'view') { |
|
1139 | + return $this->get_company($context); |
|
1140 | 1140 | } |
1141 | 1141 | |
1142 | 1142 | /** |
@@ -1146,8 +1146,8 @@ discard block |
||
1146 | 1146 | * @param string $context View or edit context. |
1147 | 1147 | * @return string |
1148 | 1148 | */ |
1149 | - public function get_customer_company( $context = 'view' ) { |
|
1150 | - return $this->get_company( $context ); |
|
1149 | + public function get_customer_company($context = 'view') { |
|
1150 | + return $this->get_company($context); |
|
1151 | 1151 | } |
1152 | 1152 | |
1153 | 1153 | /** |
@@ -1157,8 +1157,8 @@ discard block |
||
1157 | 1157 | * @param string $context View or edit context. |
1158 | 1158 | * @return string |
1159 | 1159 | */ |
1160 | - public function get_vat_number( $context = 'view' ) { |
|
1161 | - return $this->get_prop( 'vat_number', $context ); |
|
1160 | + public function get_vat_number($context = 'view') { |
|
1161 | + return $this->get_prop('vat_number', $context); |
|
1162 | 1162 | } |
1163 | 1163 | |
1164 | 1164 | /** |
@@ -1168,8 +1168,8 @@ discard block |
||
1168 | 1168 | * @param string $context View or edit context. |
1169 | 1169 | * @return string |
1170 | 1170 | */ |
1171 | - public function get_user_vat_number( $context = 'view' ) { |
|
1172 | - return $this->get_vat_number( $context ); |
|
1171 | + public function get_user_vat_number($context = 'view') { |
|
1172 | + return $this->get_vat_number($context); |
|
1173 | 1173 | } |
1174 | 1174 | |
1175 | 1175 | /** |
@@ -1179,8 +1179,8 @@ discard block |
||
1179 | 1179 | * @param string $context View or edit context. |
1180 | 1180 | * @return string |
1181 | 1181 | */ |
1182 | - public function get_customer_vat_number( $context = 'view' ) { |
|
1183 | - return $this->get_vat_number( $context ); |
|
1182 | + public function get_customer_vat_number($context = 'view') { |
|
1183 | + return $this->get_vat_number($context); |
|
1184 | 1184 | } |
1185 | 1185 | |
1186 | 1186 | /** |
@@ -1190,8 +1190,8 @@ discard block |
||
1190 | 1190 | * @param string $context View or edit context. |
1191 | 1191 | * @return string |
1192 | 1192 | */ |
1193 | - public function get_vat_rate( $context = 'view' ) { |
|
1194 | - return $this->get_prop( 'vat_rate', $context ); |
|
1193 | + public function get_vat_rate($context = 'view') { |
|
1194 | + return $this->get_prop('vat_rate', $context); |
|
1195 | 1195 | } |
1196 | 1196 | |
1197 | 1197 | /** |
@@ -1201,8 +1201,8 @@ discard block |
||
1201 | 1201 | * @param string $context View or edit context. |
1202 | 1202 | * @return string |
1203 | 1203 | */ |
1204 | - public function get_user_vat_rate( $context = 'view' ) { |
|
1205 | - return $this->get_vat_rate( $context ); |
|
1204 | + public function get_user_vat_rate($context = 'view') { |
|
1205 | + return $this->get_vat_rate($context); |
|
1206 | 1206 | } |
1207 | 1207 | |
1208 | 1208 | /** |
@@ -1212,8 +1212,8 @@ discard block |
||
1212 | 1212 | * @param string $context View or edit context. |
1213 | 1213 | * @return string |
1214 | 1214 | */ |
1215 | - public function get_customer_vat_rate( $context = 'view' ) { |
|
1216 | - return $this->get_vat_rate( $context ); |
|
1215 | + public function get_customer_vat_rate($context = 'view') { |
|
1216 | + return $this->get_vat_rate($context); |
|
1217 | 1217 | } |
1218 | 1218 | |
1219 | 1219 | /** |
@@ -1223,8 +1223,8 @@ discard block |
||
1223 | 1223 | * @param string $context View or edit context. |
1224 | 1224 | * @return string |
1225 | 1225 | */ |
1226 | - public function get_address( $context = 'view' ) { |
|
1227 | - return $this->get_prop( 'address', $context ); |
|
1226 | + public function get_address($context = 'view') { |
|
1227 | + return $this->get_prop('address', $context); |
|
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | /** |
@@ -1234,8 +1234,8 @@ discard block |
||
1234 | 1234 | * @param string $context View or edit context. |
1235 | 1235 | * @return string |
1236 | 1236 | */ |
1237 | - public function get_user_address( $context = 'view' ) { |
|
1238 | - return $this->get_address( $context ); |
|
1237 | + public function get_user_address($context = 'view') { |
|
1238 | + return $this->get_address($context); |
|
1239 | 1239 | } |
1240 | 1240 | |
1241 | 1241 | /** |
@@ -1245,8 +1245,8 @@ discard block |
||
1245 | 1245 | * @param string $context View or edit context. |
1246 | 1246 | * @return string |
1247 | 1247 | */ |
1248 | - public function get_customer_address( $context = 'view' ) { |
|
1249 | - return $this->get_address( $context ); |
|
1248 | + public function get_customer_address($context = 'view') { |
|
1249 | + return $this->get_address($context); |
|
1250 | 1250 | } |
1251 | 1251 | |
1252 | 1252 | /** |
@@ -1256,8 +1256,8 @@ discard block |
||
1256 | 1256 | * @param string $context View or edit context. |
1257 | 1257 | * @return bool |
1258 | 1258 | */ |
1259 | - public function get_is_viewed( $context = 'view' ) { |
|
1260 | - return (bool) $this->get_prop( 'is_viewed', $context ); |
|
1259 | + public function get_is_viewed($context = 'view') { |
|
1260 | + return (bool) $this->get_prop('is_viewed', $context); |
|
1261 | 1261 | } |
1262 | 1262 | |
1263 | 1263 | /** |
@@ -1267,8 +1267,8 @@ discard block |
||
1267 | 1267 | * @param string $context View or edit context. |
1268 | 1268 | * @return bool |
1269 | 1269 | */ |
1270 | - public function get_email_cc( $context = 'view' ) { |
|
1271 | - return $this->get_prop( 'email_cc', $context ); |
|
1270 | + public function get_email_cc($context = 'view') { |
|
1271 | + return $this->get_prop('email_cc', $context); |
|
1272 | 1272 | } |
1273 | 1273 | |
1274 | 1274 | /** |
@@ -1278,8 +1278,8 @@ discard block |
||
1278 | 1278 | * @param string $context View or edit context. |
1279 | 1279 | * @return bool |
1280 | 1280 | */ |
1281 | - public function get_template( $context = 'view' ) { |
|
1282 | - return $this->get_prop( 'template', $context ); |
|
1281 | + public function get_template($context = 'view') { |
|
1282 | + return $this->get_prop('template', $context); |
|
1283 | 1283 | } |
1284 | 1284 | |
1285 | 1285 | /** |
@@ -1289,8 +1289,8 @@ discard block |
||
1289 | 1289 | * @param string $context View or edit context. |
1290 | 1290 | * @return bool |
1291 | 1291 | */ |
1292 | - public function get_address_confirmed( $context = 'view' ) { |
|
1293 | - return (bool) $this->get_prop( 'address_confirmed', $context ); |
|
1292 | + public function get_address_confirmed($context = 'view') { |
|
1293 | + return (bool) $this->get_prop('address_confirmed', $context); |
|
1294 | 1294 | } |
1295 | 1295 | |
1296 | 1296 | /** |
@@ -1300,8 +1300,8 @@ discard block |
||
1300 | 1300 | * @param string $context View or edit context. |
1301 | 1301 | * @return bool |
1302 | 1302 | */ |
1303 | - public function get_user_address_confirmed( $context = 'view' ) { |
|
1304 | - return $this->get_address_confirmed( $context ); |
|
1303 | + public function get_user_address_confirmed($context = 'view') { |
|
1304 | + return $this->get_address_confirmed($context); |
|
1305 | 1305 | } |
1306 | 1306 | |
1307 | 1307 | /** |
@@ -1311,8 +1311,8 @@ discard block |
||
1311 | 1311 | * @param string $context View or edit context. |
1312 | 1312 | * @return bool |
1313 | 1313 | */ |
1314 | - public function get_customer_address_confirmed( $context = 'view' ) { |
|
1315 | - return $this->get_address_confirmed( $context ); |
|
1314 | + public function get_customer_address_confirmed($context = 'view') { |
|
1315 | + return $this->get_address_confirmed($context); |
|
1316 | 1316 | } |
1317 | 1317 | |
1318 | 1318 | /** |
@@ -1322,12 +1322,12 @@ discard block |
||
1322 | 1322 | * @param string $context View or edit context. |
1323 | 1323 | * @return float |
1324 | 1324 | */ |
1325 | - public function get_subtotal( $context = 'view' ) { |
|
1326 | - $subtotal = (float) $this->get_prop( 'subtotal', $context ); |
|
1325 | + public function get_subtotal($context = 'view') { |
|
1326 | + $subtotal = (float) $this->get_prop('subtotal', $context); |
|
1327 | 1327 | |
1328 | 1328 | // Backwards compatibility. |
1329 | - if ( is_bool( $context ) && $context ) { |
|
1330 | - return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() ); |
|
1329 | + if (is_bool($context) && $context) { |
|
1330 | + return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency()); |
|
1331 | 1331 | } |
1332 | 1332 | |
1333 | 1333 | return $subtotal; |
@@ -1340,8 +1340,8 @@ discard block |
||
1340 | 1340 | * @param string $context View or edit context. |
1341 | 1341 | * @return float |
1342 | 1342 | */ |
1343 | - public function get_total_discount( $context = 'view' ) { |
|
1344 | - return (float) $this->get_prop( 'total_discount', $context ); |
|
1343 | + public function get_total_discount($context = 'view') { |
|
1344 | + return (float) $this->get_prop('total_discount', $context); |
|
1345 | 1345 | } |
1346 | 1346 | |
1347 | 1347 | /** |
@@ -1351,18 +1351,18 @@ discard block |
||
1351 | 1351 | * @param string $context View or edit context. |
1352 | 1352 | * @return float |
1353 | 1353 | */ |
1354 | - public function get_total_tax( $context = 'view' ) { |
|
1355 | - return (float) $this->get_prop( 'total_tax', $context ); |
|
1354 | + public function get_total_tax($context = 'view') { |
|
1355 | + return (float) $this->get_prop('total_tax', $context); |
|
1356 | 1356 | } |
1357 | 1357 | |
1358 | 1358 | /** |
1359 | 1359 | * @deprecated |
1360 | 1360 | */ |
1361 | - public function get_final_tax( $currency = false ) { |
|
1361 | + public function get_final_tax($currency = false) { |
|
1362 | 1362 | $tax = $this->get_total_tax(); |
1363 | 1363 | |
1364 | - if ( $currency ) { |
|
1365 | - return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() ); |
|
1364 | + if ($currency) { |
|
1365 | + return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency()); |
|
1366 | 1366 | } |
1367 | 1367 | |
1368 | 1368 | return $tax; |
@@ -1375,8 +1375,8 @@ discard block |
||
1375 | 1375 | * @param string $context View or edit context. |
1376 | 1376 | * @return float |
1377 | 1377 | */ |
1378 | - public function get_total_fees( $context = 'view' ) { |
|
1379 | - return (float) $this->get_prop( 'total_fees', $context ); |
|
1378 | + public function get_total_fees($context = 'view') { |
|
1379 | + return (float) $this->get_prop('total_fees', $context); |
|
1380 | 1380 | } |
1381 | 1381 | |
1382 | 1382 | /** |
@@ -1386,8 +1386,8 @@ discard block |
||
1386 | 1386 | * @param string $context View or edit context. |
1387 | 1387 | * @return float |
1388 | 1388 | */ |
1389 | - public function get_fees_total( $context = 'view' ) { |
|
1390 | - return $this->get_total_fees( $context ); |
|
1389 | + public function get_fees_total($context = 'view') { |
|
1390 | + return $this->get_total_fees($context); |
|
1391 | 1391 | } |
1392 | 1392 | |
1393 | 1393 | /** |
@@ -1398,7 +1398,7 @@ discard block |
||
1398 | 1398 | */ |
1399 | 1399 | public function get_total() { |
1400 | 1400 | $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total(); |
1401 | - return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this ); |
|
1401 | + return apply_filters('getpaid_get_invoice_total_amount', $total, $this); |
|
1402 | 1402 | } |
1403 | 1403 | |
1404 | 1404 | /** |
@@ -1420,7 +1420,7 @@ discard block |
||
1420 | 1420 | */ |
1421 | 1421 | public function get_initial_total() { |
1422 | 1422 | |
1423 | - if ( empty( $this->totals ) ) { |
|
1423 | + if (empty($this->totals)) { |
|
1424 | 1424 | $this->recalculate_total(); |
1425 | 1425 | } |
1426 | 1426 | |
@@ -1430,11 +1430,11 @@ discard block |
||
1430 | 1430 | $subtotal = $this->totals['subtotal']['initial']; |
1431 | 1431 | $total = $tax + $fee - $discount + $subtotal; |
1432 | 1432 | |
1433 | - if ( 0 > $total ) { |
|
1433 | + if (0 > $total) { |
|
1434 | 1434 | $total = 0; |
1435 | 1435 | } |
1436 | 1436 | |
1437 | - return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this ); |
|
1437 | + return apply_filters('wpinv_get_initial_invoice_total', $total, $this); |
|
1438 | 1438 | } |
1439 | 1439 | |
1440 | 1440 | /** |
@@ -1446,7 +1446,7 @@ discard block |
||
1446 | 1446 | */ |
1447 | 1447 | public function get_recurring_total() { |
1448 | 1448 | |
1449 | - if ( empty( $this->totals ) ) { |
|
1449 | + if (empty($this->totals)) { |
|
1450 | 1450 | $this->recalculate_total(); |
1451 | 1451 | } |
1452 | 1452 | |
@@ -1456,11 +1456,11 @@ discard block |
||
1456 | 1456 | $subtotal = $this->totals['subtotal']['recurring']; |
1457 | 1457 | $total = $tax + $fee - $discount + $subtotal; |
1458 | 1458 | |
1459 | - if ( 0 > $total ) { |
|
1459 | + if (0 > $total) { |
|
1460 | 1460 | $total = 0; |
1461 | 1461 | } |
1462 | 1462 | |
1463 | - return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this ); |
|
1463 | + return apply_filters('wpinv_get_recurring_invoice_total', $total, $this); |
|
1464 | 1464 | } |
1465 | 1465 | |
1466 | 1466 | /** |
@@ -1471,10 +1471,10 @@ discard block |
||
1471 | 1471 | * @param string $currency Whether to include the currency. |
1472 | 1472 | * @return float |
1473 | 1473 | */ |
1474 | - public function get_recurring_details( $field = '', $currency = false ) { |
|
1474 | + public function get_recurring_details($field = '', $currency = false) { |
|
1475 | 1475 | |
1476 | 1476 | // Maybe recalculate totals. |
1477 | - if ( empty( $this->totals ) ) { |
|
1477 | + if (empty($this->totals)) { |
|
1478 | 1478 | $this->recalculate_total(); |
1479 | 1479 | } |
1480 | 1480 | |
@@ -1494,8 +1494,8 @@ discard block |
||
1494 | 1494 | $currency |
1495 | 1495 | ); |
1496 | 1496 | |
1497 | - if ( isset( $data[$field] ) ) { |
|
1498 | - return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] ); |
|
1497 | + if (isset($data[$field])) { |
|
1498 | + return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]); |
|
1499 | 1499 | } |
1500 | 1500 | |
1501 | 1501 | return $data; |
@@ -1508,8 +1508,8 @@ discard block |
||
1508 | 1508 | * @param string $context View or edit context. |
1509 | 1509 | * @return array |
1510 | 1510 | */ |
1511 | - public function get_fees( $context = 'view' ) { |
|
1512 | - return wpinv_parse_list( $this->get_prop( 'fees', $context ) ); |
|
1511 | + public function get_fees($context = 'view') { |
|
1512 | + return wpinv_parse_list($this->get_prop('fees', $context)); |
|
1513 | 1513 | } |
1514 | 1514 | |
1515 | 1515 | /** |
@@ -1519,8 +1519,8 @@ discard block |
||
1519 | 1519 | * @param string $context View or edit context. |
1520 | 1520 | * @return array |
1521 | 1521 | */ |
1522 | - public function get_discounts( $context = 'view' ) { |
|
1523 | - return wpinv_parse_list( $this->get_prop( 'discounts', $context ) ); |
|
1522 | + public function get_discounts($context = 'view') { |
|
1523 | + return wpinv_parse_list($this->get_prop('discounts', $context)); |
|
1524 | 1524 | } |
1525 | 1525 | |
1526 | 1526 | /** |
@@ -1530,8 +1530,8 @@ discard block |
||
1530 | 1530 | * @param string $context View or edit context. |
1531 | 1531 | * @return array |
1532 | 1532 | */ |
1533 | - public function get_taxes( $context = 'view' ) { |
|
1534 | - return wpinv_parse_list( $this->get_prop( 'taxes', $context ) ); |
|
1533 | + public function get_taxes($context = 'view') { |
|
1534 | + return wpinv_parse_list($this->get_prop('taxes', $context)); |
|
1535 | 1535 | } |
1536 | 1536 | |
1537 | 1537 | /** |
@@ -1541,8 +1541,8 @@ discard block |
||
1541 | 1541 | * @param string $context View or edit context. |
1542 | 1542 | * @return GetPaid_Form_Item[] |
1543 | 1543 | */ |
1544 | - public function get_items( $context = 'view' ) { |
|
1545 | - return $this->get_prop( 'items', $context ); |
|
1544 | + public function get_items($context = 'view') { |
|
1545 | + return $this->get_prop('items', $context); |
|
1546 | 1546 | } |
1547 | 1547 | |
1548 | 1548 | /** |
@@ -1552,8 +1552,8 @@ discard block |
||
1552 | 1552 | * @param string $context View or edit context. |
1553 | 1553 | * @return int |
1554 | 1554 | */ |
1555 | - public function get_payment_form( $context = 'view' ) { |
|
1556 | - return intval( $this->get_prop( 'payment_form', $context ) ); |
|
1555 | + public function get_payment_form($context = 'view') { |
|
1556 | + return intval($this->get_prop('payment_form', $context)); |
|
1557 | 1557 | } |
1558 | 1558 | |
1559 | 1559 | /** |
@@ -1563,8 +1563,8 @@ discard block |
||
1563 | 1563 | * @param string $context View or edit context. |
1564 | 1564 | * @return string |
1565 | 1565 | */ |
1566 | - public function get_submission_id( $context = 'view' ) { |
|
1567 | - return $this->get_prop( 'submission_id', $context ); |
|
1566 | + public function get_submission_id($context = 'view') { |
|
1567 | + return $this->get_prop('submission_id', $context); |
|
1568 | 1568 | } |
1569 | 1569 | |
1570 | 1570 | /** |
@@ -1574,8 +1574,8 @@ discard block |
||
1574 | 1574 | * @param string $context View or edit context. |
1575 | 1575 | * @return string |
1576 | 1576 | */ |
1577 | - public function get_discount_code( $context = 'view' ) { |
|
1578 | - return $this->get_prop( 'discount_code', $context ); |
|
1577 | + public function get_discount_code($context = 'view') { |
|
1578 | + return $this->get_prop('discount_code', $context); |
|
1579 | 1579 | } |
1580 | 1580 | |
1581 | 1581 | /** |
@@ -1585,8 +1585,8 @@ discard block |
||
1585 | 1585 | * @param string $context View or edit context. |
1586 | 1586 | * @return string |
1587 | 1587 | */ |
1588 | - public function get_gateway( $context = 'view' ) { |
|
1589 | - return $this->get_prop( 'gateway', $context ); |
|
1588 | + public function get_gateway($context = 'view') { |
|
1589 | + return $this->get_prop('gateway', $context); |
|
1590 | 1590 | } |
1591 | 1591 | |
1592 | 1592 | /** |
@@ -1596,8 +1596,8 @@ discard block |
||
1596 | 1596 | * @return string |
1597 | 1597 | */ |
1598 | 1598 | public function get_gateway_title() { |
1599 | - $title = wpinv_get_gateway_checkout_label( $this->get_gateway() ); |
|
1600 | - return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this ); |
|
1599 | + $title = wpinv_get_gateway_checkout_label($this->get_gateway()); |
|
1600 | + return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this); |
|
1601 | 1601 | } |
1602 | 1602 | |
1603 | 1603 | /** |
@@ -1607,8 +1607,8 @@ discard block |
||
1607 | 1607 | * @param string $context View or edit context. |
1608 | 1608 | * @return string |
1609 | 1609 | */ |
1610 | - public function get_transaction_id( $context = 'view' ) { |
|
1611 | - return $this->get_prop( 'transaction_id', $context ); |
|
1610 | + public function get_transaction_id($context = 'view') { |
|
1611 | + return $this->get_prop('transaction_id', $context); |
|
1612 | 1612 | } |
1613 | 1613 | |
1614 | 1614 | /** |
@@ -1618,9 +1618,9 @@ discard block |
||
1618 | 1618 | * @param string $context View or edit context. |
1619 | 1619 | * @return string |
1620 | 1620 | */ |
1621 | - public function get_currency( $context = 'view' ) { |
|
1622 | - $currency = $this->get_prop( 'currency', $context ); |
|
1623 | - return empty( $currency ) ? wpinv_get_currency() : $currency; |
|
1621 | + public function get_currency($context = 'view') { |
|
1622 | + $currency = $this->get_prop('currency', $context); |
|
1623 | + return empty($currency) ? wpinv_get_currency() : $currency; |
|
1624 | 1624 | } |
1625 | 1625 | |
1626 | 1626 | /** |
@@ -1630,8 +1630,8 @@ discard block |
||
1630 | 1630 | * @param string $context View or edit context. |
1631 | 1631 | * @return bool |
1632 | 1632 | */ |
1633 | - public function get_disable_taxes( $context = 'view' ) { |
|
1634 | - return (bool) $this->get_prop( 'disable_taxes', $context ); |
|
1633 | + public function get_disable_taxes($context = 'view') { |
|
1634 | + return (bool) $this->get_prop('disable_taxes', $context); |
|
1635 | 1635 | } |
1636 | 1636 | |
1637 | 1637 | /** |
@@ -1641,8 +1641,8 @@ discard block |
||
1641 | 1641 | * @param string $context View or edit context. |
1642 | 1642 | * @return int |
1643 | 1643 | */ |
1644 | - public function get_subscription_id( $context = 'view' ) { |
|
1645 | - return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context ); |
|
1644 | + public function get_subscription_id($context = 'view') { |
|
1645 | + return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context); |
|
1646 | 1646 | } |
1647 | 1647 | |
1648 | 1648 | /** |
@@ -1652,12 +1652,12 @@ discard block |
||
1652 | 1652 | * @param string $context View or edit context. |
1653 | 1653 | * @return int |
1654 | 1654 | */ |
1655 | - public function get_remote_subscription_id( $context = 'view' ) { |
|
1656 | - $subscription_id = $this->get_prop( 'remote_subscription_id', $context ); |
|
1655 | + public function get_remote_subscription_id($context = 'view') { |
|
1656 | + $subscription_id = $this->get_prop('remote_subscription_id', $context); |
|
1657 | 1657 | |
1658 | - if ( empty( $subscription_id ) && $this->is_renewal() ) { |
|
1658 | + if (empty($subscription_id) && $this->is_renewal()) { |
|
1659 | 1659 | $parent = $this->get_parent(); |
1660 | - return $parent->get_subscription_id( $context ); |
|
1660 | + return $parent->get_subscription_id($context); |
|
1661 | 1661 | } |
1662 | 1662 | |
1663 | 1663 | return $subscription_id; |
@@ -1670,20 +1670,20 @@ discard block |
||
1670 | 1670 | * @param string $context View or edit context. |
1671 | 1671 | * @return array |
1672 | 1672 | */ |
1673 | - public function get_payment_meta( $context = 'view' ) { |
|
1673 | + public function get_payment_meta($context = 'view') { |
|
1674 | 1674 | |
1675 | 1675 | return array( |
1676 | - 'price' => $this->get_total( $context ), |
|
1677 | - 'date' => $this->get_date_created( $context ), |
|
1678 | - 'user_email' => $this->get_email( $context ), |
|
1679 | - 'invoice_key' => $this->get_key( $context ), |
|
1680 | - 'currency' => $this->get_currency( $context ), |
|
1681 | - 'items' => $this->get_items( $context ), |
|
1682 | - 'user_info' => $this->get_user_info( $context ), |
|
1676 | + 'price' => $this->get_total($context), |
|
1677 | + 'date' => $this->get_date_created($context), |
|
1678 | + 'user_email' => $this->get_email($context), |
|
1679 | + 'invoice_key' => $this->get_key($context), |
|
1680 | + 'currency' => $this->get_currency($context), |
|
1681 | + 'items' => $this->get_items($context), |
|
1682 | + 'user_info' => $this->get_user_info($context), |
|
1683 | 1683 | 'cart_details' => $this->get_cart_details(), |
1684 | - 'status' => $this->get_status( $context ), |
|
1685 | - 'fees' => $this->get_fees( $context ), |
|
1686 | - 'taxes' => $this->get_taxes( $context ), |
|
1684 | + 'status' => $this->get_status($context), |
|
1685 | + 'fees' => $this->get_fees($context), |
|
1686 | + 'taxes' => $this->get_taxes($context), |
|
1687 | 1687 | ); |
1688 | 1688 | |
1689 | 1689 | } |
@@ -1698,9 +1698,9 @@ discard block |
||
1698 | 1698 | $items = $this->get_items(); |
1699 | 1699 | $cart_details = array(); |
1700 | 1700 | |
1701 | - foreach ( $items as $item_id => $item ) { |
|
1701 | + foreach ($items as $item_id => $item) { |
|
1702 | 1702 | $item->invoice_id = $this->get_id(); |
1703 | - $cart_details[] = $item->prepare_data_for_saving(); |
|
1703 | + $cart_details[] = $item->prepare_data_for_saving(); |
|
1704 | 1704 | } |
1705 | 1705 | |
1706 | 1706 | return $cart_details; |
@@ -1711,11 +1711,11 @@ discard block |
||
1711 | 1711 | * |
1712 | 1712 | * @return null|GetPaid_Form_Item|int |
1713 | 1713 | */ |
1714 | - public function get_recurring( $object = false ) { |
|
1714 | + public function get_recurring($object = false) { |
|
1715 | 1715 | |
1716 | 1716 | // Are we returning an object? |
1717 | - if ( $object ) { |
|
1718 | - return $this->get_item( $this->recurring_item ); |
|
1717 | + if ($object) { |
|
1718 | + return $this->get_item($this->recurring_item); |
|
1719 | 1719 | } |
1720 | 1720 | |
1721 | 1721 | return $this->recurring_item; |
@@ -1730,15 +1730,15 @@ discard block |
||
1730 | 1730 | public function get_subscription_name() { |
1731 | 1731 | |
1732 | 1732 | // Retrieve the recurring name |
1733 | - $item = $this->get_recurring( true ); |
|
1733 | + $item = $this->get_recurring(true); |
|
1734 | 1734 | |
1735 | 1735 | // Abort if it does not exist. |
1736 | - if ( empty( $item ) ) { |
|
1736 | + if (empty($item)) { |
|
1737 | 1737 | return ''; |
1738 | 1738 | } |
1739 | 1739 | |
1740 | 1740 | // Return the item name. |
1741 | - return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this ); |
|
1741 | + return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this); |
|
1742 | 1742 | } |
1743 | 1743 | |
1744 | 1744 | /** |
@@ -1748,9 +1748,9 @@ discard block |
||
1748 | 1748 | * @return string |
1749 | 1749 | */ |
1750 | 1750 | public function get_view_url() { |
1751 | - $invoice_url = get_permalink( $this->get_id() ); |
|
1752 | - $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url ); |
|
1753 | - return apply_filters( 'wpinv_get_view_url', $invoice_url, $this ); |
|
1751 | + $invoice_url = get_permalink($this->get_id()); |
|
1752 | + $invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url); |
|
1753 | + return apply_filters('wpinv_get_view_url', $invoice_url, $this); |
|
1754 | 1754 | } |
1755 | 1755 | |
1756 | 1756 | /** |
@@ -1759,25 +1759,25 @@ discard block |
||
1759 | 1759 | * @since 1.0.19 |
1760 | 1760 | * @return string |
1761 | 1761 | */ |
1762 | - public function get_checkout_payment_url( $deprecated = false, $secret = false ) { |
|
1762 | + public function get_checkout_payment_url($deprecated = false, $secret = false) { |
|
1763 | 1763 | |
1764 | 1764 | // Retrieve the checkout url. |
1765 | 1765 | $pay_url = wpinv_get_checkout_uri(); |
1766 | 1766 | |
1767 | 1767 | // Maybe force ssl. |
1768 | - if ( is_ssl() ) { |
|
1769 | - $pay_url = str_replace( 'http:', 'https:', $pay_url ); |
|
1768 | + if (is_ssl()) { |
|
1769 | + $pay_url = str_replace('http:', 'https:', $pay_url); |
|
1770 | 1770 | } |
1771 | 1771 | |
1772 | 1772 | // Add the invoice key. |
1773 | - $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url ); |
|
1773 | + $pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url); |
|
1774 | 1774 | |
1775 | 1775 | // (Maybe?) add a secret |
1776 | - if ( $secret ) { |
|
1777 | - $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url ); |
|
1776 | + if ($secret) { |
|
1777 | + $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url); |
|
1778 | 1778 | } |
1779 | 1779 | |
1780 | - return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret ); |
|
1780 | + return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret); |
|
1781 | 1781 | } |
1782 | 1782 | |
1783 | 1783 | /** |
@@ -1792,14 +1792,14 @@ discard block |
||
1792 | 1792 | $receipt_url = wpinv_get_success_page_uri(); |
1793 | 1793 | |
1794 | 1794 | // Maybe force ssl. |
1795 | - if ( is_ssl() ) { |
|
1796 | - $receipt_url = str_replace( 'http:', 'https:', $receipt_url ); |
|
1795 | + if (is_ssl()) { |
|
1796 | + $receipt_url = str_replace('http:', 'https:', $receipt_url); |
|
1797 | 1797 | } |
1798 | 1798 | |
1799 | 1799 | // Add the invoice key. |
1800 | - $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url ); |
|
1800 | + $receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url); |
|
1801 | 1801 | |
1802 | - return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this ); |
|
1802 | + return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this); |
|
1803 | 1803 | } |
1804 | 1804 | |
1805 | 1805 | /** |
@@ -1812,8 +1812,8 @@ discard block |
||
1812 | 1812 | * @param string $context View or edit context. |
1813 | 1813 | * @return mixed Value of the given invoice property (if set). |
1814 | 1814 | */ |
1815 | - public function get( $key, $context = 'view' ) { |
|
1816 | - return $this->get_prop( $key, $context ); |
|
1815 | + public function get($key, $context = 'view') { |
|
1816 | + return $this->get_prop($key, $context); |
|
1817 | 1817 | } |
1818 | 1818 | |
1819 | 1819 | /* |
@@ -1836,11 +1836,11 @@ discard block |
||
1836 | 1836 | * @param mixed $value new value. |
1837 | 1837 | * @return mixed Value of the given invoice property (if set). |
1838 | 1838 | */ |
1839 | - public function set( $key, $value ) { |
|
1839 | + public function set($key, $value) { |
|
1840 | 1840 | |
1841 | 1841 | $setter = "set_$key"; |
1842 | - if ( is_callable( array( $this, $setter ) ) ) { |
|
1843 | - $this->{$setter}( $value ); |
|
1842 | + if (is_callable(array($this, $setter))) { |
|
1843 | + $this->{$setter}($value); |
|
1844 | 1844 | } |
1845 | 1845 | |
1846 | 1846 | } |
@@ -1854,47 +1854,47 @@ discard block |
||
1854 | 1854 | * @param bool $manual_update Is this a manual status change?. |
1855 | 1855 | * @return array details of change. |
1856 | 1856 | */ |
1857 | - public function set_status( $new_status, $note = '', $manual_update = false ) { |
|
1857 | + public function set_status($new_status, $note = '', $manual_update = false) { |
|
1858 | 1858 | $old_status = $this->get_status(); |
1859 | 1859 | |
1860 | 1860 | $statuses = $this->get_all_statuses(); |
1861 | 1861 | |
1862 | - if ( isset( $statuses[ 'draft' ] ) ) { |
|
1863 | - unset( $statuses[ 'draft' ] ); |
|
1862 | + if (isset($statuses['draft'])) { |
|
1863 | + unset($statuses['draft']); |
|
1864 | 1864 | } |
1865 | 1865 | |
1866 | - $this->set_prop( 'status', $new_status ); |
|
1866 | + $this->set_prop('status', $new_status); |
|
1867 | 1867 | |
1868 | 1868 | // If setting the status, ensure it's set to a valid status. |
1869 | - if ( true === $this->object_read ) { |
|
1869 | + if (true === $this->object_read) { |
|
1870 | 1870 | |
1871 | 1871 | // Only allow valid new status. |
1872 | - if ( ! array_key_exists( $new_status, $statuses ) ) { |
|
1872 | + if (!array_key_exists($new_status, $statuses)) { |
|
1873 | 1873 | $new_status = 'wpi-pending'; |
1874 | 1874 | } |
1875 | 1875 | |
1876 | 1876 | // If the old status is set but unknown (e.g. draft) assume its pending for action usage. |
1877 | - if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) { |
|
1877 | + if ($old_status && !array_key_exists($new_status, $statuses)) { |
|
1878 | 1878 | $old_status = 'wpi-pending'; |
1879 | 1879 | } |
1880 | 1880 | |
1881 | 1881 | // Paid - Renewal (i.e when duplicating a parent invoice ) |
1882 | - if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) { |
|
1882 | + if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) { |
|
1883 | 1883 | $old_status = 'wpi-pending'; |
1884 | 1884 | } |
1885 | 1885 | |
1886 | 1886 | } |
1887 | 1887 | |
1888 | - if ( true === $this->object_read && $old_status !== $new_status ) { |
|
1888 | + if (true === $this->object_read && $old_status !== $new_status) { |
|
1889 | 1889 | $this->status_transition = array( |
1890 | - 'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status, |
|
1890 | + 'from' => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status, |
|
1891 | 1891 | 'to' => $new_status, |
1892 | 1892 | 'note' => $note, |
1893 | 1893 | 'manual' => (bool) $manual_update, |
1894 | 1894 | ); |
1895 | 1895 | |
1896 | - if ( $manual_update ) { |
|
1897 | - do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status ); |
|
1896 | + if ($manual_update) { |
|
1897 | + do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status); |
|
1898 | 1898 | } |
1899 | 1899 | |
1900 | 1900 | $this->maybe_set_date_paid(); |
@@ -1917,8 +1917,8 @@ discard block |
||
1917 | 1917 | */ |
1918 | 1918 | public function maybe_set_date_paid() { |
1919 | 1919 | |
1920 | - if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) { |
|
1921 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
1920 | + if (!$this->get_date_completed('edit') && $this->is_paid()) { |
|
1921 | + $this->set_date_completed(current_time('mysql')); |
|
1922 | 1922 | } |
1923 | 1923 | } |
1924 | 1924 | |
@@ -1927,11 +1927,11 @@ discard block |
||
1927 | 1927 | * |
1928 | 1928 | * @since 1.0.19 |
1929 | 1929 | */ |
1930 | - public function set_parent_id( $value ) { |
|
1931 | - if ( $value && ( $value === $this->get_id() ) ) { |
|
1930 | + public function set_parent_id($value) { |
|
1931 | + if ($value && ($value === $this->get_id())) { |
|
1932 | 1932 | return; |
1933 | 1933 | } |
1934 | - $this->set_prop( 'parent_id', absint( $value ) ); |
|
1934 | + $this->set_prop('parent_id', absint($value)); |
|
1935 | 1935 | } |
1936 | 1936 | |
1937 | 1937 | /** |
@@ -1939,8 +1939,8 @@ discard block |
||
1939 | 1939 | * |
1940 | 1940 | * @since 1.0.19 |
1941 | 1941 | */ |
1942 | - public function set_version( $value ) { |
|
1943 | - $this->set_prop( 'version', $value ); |
|
1942 | + public function set_version($value) { |
|
1943 | + $this->set_prop('version', $value); |
|
1944 | 1944 | } |
1945 | 1945 | |
1946 | 1946 | /** |
@@ -1950,15 +1950,15 @@ discard block |
||
1950 | 1950 | * @param string $value Value to set. |
1951 | 1951 | * @return bool Whether or not the date was set. |
1952 | 1952 | */ |
1953 | - public function set_date_created( $value ) { |
|
1954 | - $date = strtotime( $value ); |
|
1953 | + public function set_date_created($value) { |
|
1954 | + $date = strtotime($value); |
|
1955 | 1955 | |
1956 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
1957 | - $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) ); |
|
1956 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
1957 | + $this->set_prop('date_created', date('Y-m-d H:i:s', $date)); |
|
1958 | 1958 | return true; |
1959 | 1959 | } |
1960 | 1960 | |
1961 | - return $this->set_prop( 'date_created', '' ); |
|
1961 | + return $this->set_prop('date_created', ''); |
|
1962 | 1962 | |
1963 | 1963 | } |
1964 | 1964 | |
@@ -1969,15 +1969,15 @@ discard block |
||
1969 | 1969 | * @param string $value Value to set. |
1970 | 1970 | * @return bool Whether or not the date was set. |
1971 | 1971 | */ |
1972 | - public function set_due_date( $value ) { |
|
1973 | - $date = strtotime( $value ); |
|
1972 | + public function set_due_date($value) { |
|
1973 | + $date = strtotime($value); |
|
1974 | 1974 | |
1975 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
1976 | - $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) ); |
|
1975 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
1976 | + $this->set_prop('due_date', date('Y-m-d H:i:s', $date)); |
|
1977 | 1977 | return true; |
1978 | 1978 | } |
1979 | 1979 | |
1980 | - $this->set_prop( 'due_date', '' ); |
|
1980 | + $this->set_prop('due_date', ''); |
|
1981 | 1981 | return false; |
1982 | 1982 | |
1983 | 1983 | } |
@@ -1988,8 +1988,8 @@ discard block |
||
1988 | 1988 | * @since 1.0.19 |
1989 | 1989 | * @param string $value New name. |
1990 | 1990 | */ |
1991 | - public function set_date_due( $value ) { |
|
1992 | - $this->set_due_date( $value ); |
|
1991 | + public function set_date_due($value) { |
|
1992 | + $this->set_due_date($value); |
|
1993 | 1993 | } |
1994 | 1994 | |
1995 | 1995 | /** |
@@ -1999,15 +1999,15 @@ discard block |
||
1999 | 1999 | * @param string $value Value to set. |
2000 | 2000 | * @return bool Whether or not the date was set. |
2001 | 2001 | */ |
2002 | - public function set_completed_date( $value ) { |
|
2003 | - $date = strtotime( $value ); |
|
2002 | + public function set_completed_date($value) { |
|
2003 | + $date = strtotime($value); |
|
2004 | 2004 | |
2005 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2006 | - $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) ); |
|
2005 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2006 | + $this->set_prop('completed_date', date('Y-m-d H:i:s', $date)); |
|
2007 | 2007 | return true; |
2008 | 2008 | } |
2009 | 2009 | |
2010 | - $this->set_prop( 'completed_date', '' ); |
|
2010 | + $this->set_prop('completed_date', ''); |
|
2011 | 2011 | return false; |
2012 | 2012 | |
2013 | 2013 | } |
@@ -2018,8 +2018,8 @@ discard block |
||
2018 | 2018 | * @since 1.0.19 |
2019 | 2019 | * @param string $value New name. |
2020 | 2020 | */ |
2021 | - public function set_date_completed( $value ) { |
|
2022 | - $this->set_completed_date( $value ); |
|
2021 | + public function set_date_completed($value) { |
|
2022 | + $this->set_completed_date($value); |
|
2023 | 2023 | } |
2024 | 2024 | |
2025 | 2025 | /** |
@@ -2029,15 +2029,15 @@ discard block |
||
2029 | 2029 | * @param string $value Value to set. |
2030 | 2030 | * @return bool Whether or not the date was set. |
2031 | 2031 | */ |
2032 | - public function set_date_modified( $value ) { |
|
2033 | - $date = strtotime( $value ); |
|
2032 | + public function set_date_modified($value) { |
|
2033 | + $date = strtotime($value); |
|
2034 | 2034 | |
2035 | - if ( $date && $value !== '0000-00-00 00:00:00' ) { |
|
2036 | - $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) ); |
|
2035 | + if ($date && $value !== '0000-00-00 00:00:00') { |
|
2036 | + $this->set_prop('date_modified', date('Y-m-d H:i:s', $date)); |
|
2037 | 2037 | return true; |
2038 | 2038 | } |
2039 | 2039 | |
2040 | - $this->set_prop( 'date_modified', '' ); |
|
2040 | + $this->set_prop('date_modified', ''); |
|
2041 | 2041 | return false; |
2042 | 2042 | |
2043 | 2043 | } |
@@ -2048,9 +2048,9 @@ discard block |
||
2048 | 2048 | * @since 1.0.19 |
2049 | 2049 | * @param string $value New number. |
2050 | 2050 | */ |
2051 | - public function set_number( $value ) { |
|
2052 | - $number = sanitize_text_field( $value ); |
|
2053 | - $this->set_prop( 'number', $number ); |
|
2051 | + public function set_number($value) { |
|
2052 | + $number = sanitize_text_field($value); |
|
2053 | + $this->set_prop('number', $number); |
|
2054 | 2054 | } |
2055 | 2055 | |
2056 | 2056 | /** |
@@ -2059,9 +2059,9 @@ discard block |
||
2059 | 2059 | * @since 1.0.19 |
2060 | 2060 | * @param string $value Type. |
2061 | 2061 | */ |
2062 | - public function set_type( $value ) { |
|
2063 | - $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) ); |
|
2064 | - $this->set_prop( 'type', $type ); |
|
2062 | + public function set_type($value) { |
|
2063 | + $type = sanitize_text_field(str_replace('wpi_', '', $value)); |
|
2064 | + $this->set_prop('type', $type); |
|
2065 | 2065 | } |
2066 | 2066 | |
2067 | 2067 | /** |
@@ -2070,10 +2070,10 @@ discard block |
||
2070 | 2070 | * @since 1.0.19 |
2071 | 2071 | * @param string $value Post type. |
2072 | 2072 | */ |
2073 | - public function set_post_type( $value ) { |
|
2074 | - if ( getpaid_is_invoice_post_type( $value ) ) { |
|
2075 | - $this->set_type( $value ); |
|
2076 | - $this->set_prop( 'post_type', $value ); |
|
2073 | + public function set_post_type($value) { |
|
2074 | + if (getpaid_is_invoice_post_type($value)) { |
|
2075 | + $this->set_type($value); |
|
2076 | + $this->set_prop('post_type', $value); |
|
2077 | 2077 | } |
2078 | 2078 | } |
2079 | 2079 | |
@@ -2083,9 +2083,9 @@ discard block |
||
2083 | 2083 | * @since 1.0.19 |
2084 | 2084 | * @param string $value New key. |
2085 | 2085 | */ |
2086 | - public function set_key( $value ) { |
|
2087 | - $key = sanitize_text_field( $value ); |
|
2088 | - $this->set_prop( 'key', $key ); |
|
2086 | + public function set_key($value) { |
|
2087 | + $key = sanitize_text_field($value); |
|
2088 | + $this->set_prop('key', $key); |
|
2089 | 2089 | } |
2090 | 2090 | |
2091 | 2091 | /** |
@@ -2094,9 +2094,9 @@ discard block |
||
2094 | 2094 | * @since 1.0.19 |
2095 | 2095 | * @param string $value mode. |
2096 | 2096 | */ |
2097 | - public function set_mode( $value ) { |
|
2098 | - if ( ! in_array( $value, array( 'live', 'test' ) ) ) { |
|
2099 | - $this->set_prop( 'value', $value ); |
|
2097 | + public function set_mode($value) { |
|
2098 | + if (!in_array($value, array('live', 'test'))) { |
|
2099 | + $this->set_prop('value', $value); |
|
2100 | 2100 | } |
2101 | 2101 | } |
2102 | 2102 | |
@@ -2106,8 +2106,8 @@ discard block |
||
2106 | 2106 | * @since 1.0.19 |
2107 | 2107 | * @param string $value path. |
2108 | 2108 | */ |
2109 | - public function set_path( $value ) { |
|
2110 | - $this->set_prop( 'path', $value ); |
|
2109 | + public function set_path($value) { |
|
2110 | + $this->set_prop('path', $value); |
|
2111 | 2111 | } |
2112 | 2112 | |
2113 | 2113 | /** |
@@ -2116,9 +2116,9 @@ discard block |
||
2116 | 2116 | * @since 1.0.19 |
2117 | 2117 | * @param string $value New name. |
2118 | 2118 | */ |
2119 | - public function set_name( $value ) { |
|
2120 | - $name = sanitize_text_field( $value ); |
|
2121 | - $this->set_prop( 'name', $name ); |
|
2119 | + public function set_name($value) { |
|
2120 | + $name = sanitize_text_field($value); |
|
2121 | + $this->set_prop('name', $name); |
|
2122 | 2122 | } |
2123 | 2123 | |
2124 | 2124 | /** |
@@ -2127,8 +2127,8 @@ discard block |
||
2127 | 2127 | * @since 1.0.19 |
2128 | 2128 | * @param string $value New name. |
2129 | 2129 | */ |
2130 | - public function set_title( $value ) { |
|
2131 | - $this->set_name( $value ); |
|
2130 | + public function set_title($value) { |
|
2131 | + $this->set_name($value); |
|
2132 | 2132 | } |
2133 | 2133 | |
2134 | 2134 | /** |
@@ -2137,9 +2137,9 @@ discard block |
||
2137 | 2137 | * @since 1.0.19 |
2138 | 2138 | * @param string $value New description. |
2139 | 2139 | */ |
2140 | - public function set_description( $value ) { |
|
2141 | - $description = wp_kses_post( $value ); |
|
2142 | - return $this->set_prop( 'description', $description ); |
|
2140 | + public function set_description($value) { |
|
2141 | + $description = wp_kses_post($value); |
|
2142 | + return $this->set_prop('description', $description); |
|
2143 | 2143 | } |
2144 | 2144 | |
2145 | 2145 | /** |
@@ -2148,8 +2148,8 @@ discard block |
||
2148 | 2148 | * @since 1.0.19 |
2149 | 2149 | * @param string $value New description. |
2150 | 2150 | */ |
2151 | - public function set_excerpt( $value ) { |
|
2152 | - $this->set_description( $value ); |
|
2151 | + public function set_excerpt($value) { |
|
2152 | + $this->set_description($value); |
|
2153 | 2153 | } |
2154 | 2154 | |
2155 | 2155 | /** |
@@ -2158,8 +2158,8 @@ discard block |
||
2158 | 2158 | * @since 1.0.19 |
2159 | 2159 | * @param string $value New description. |
2160 | 2160 | */ |
2161 | - public function set_summary( $value ) { |
|
2162 | - $this->set_description( $value ); |
|
2161 | + public function set_summary($value) { |
|
2162 | + $this->set_description($value); |
|
2163 | 2163 | } |
2164 | 2164 | |
2165 | 2165 | /** |
@@ -2168,12 +2168,12 @@ discard block |
||
2168 | 2168 | * @since 1.0.19 |
2169 | 2169 | * @param int $value New author. |
2170 | 2170 | */ |
2171 | - public function set_author( $value ) { |
|
2172 | - $user = get_user_by( 'id', (int) $value ); |
|
2171 | + public function set_author($value) { |
|
2172 | + $user = get_user_by('id', (int) $value); |
|
2173 | 2173 | |
2174 | - if ( $user && $user->ID ) { |
|
2175 | - $this->set_prop( 'author', $user->ID ); |
|
2176 | - $this->set_prop( 'email', $user->user_email ); |
|
2174 | + if ($user && $user->ID) { |
|
2175 | + $this->set_prop('author', $user->ID); |
|
2176 | + $this->set_prop('email', $user->user_email); |
|
2177 | 2177 | } |
2178 | 2178 | |
2179 | 2179 | } |
@@ -2184,8 +2184,8 @@ discard block |
||
2184 | 2184 | * @since 1.0.19 |
2185 | 2185 | * @param int $value New user id. |
2186 | 2186 | */ |
2187 | - public function set_user_id( $value ) { |
|
2188 | - $this->set_author( $value ); |
|
2187 | + public function set_user_id($value) { |
|
2188 | + $this->set_author($value); |
|
2189 | 2189 | } |
2190 | 2190 | |
2191 | 2191 | /** |
@@ -2194,8 +2194,8 @@ discard block |
||
2194 | 2194 | * @since 1.0.19 |
2195 | 2195 | * @param int $value New user id. |
2196 | 2196 | */ |
2197 | - public function set_customer_id( $value ) { |
|
2198 | - $this->set_author( $value ); |
|
2197 | + public function set_customer_id($value) { |
|
2198 | + $this->set_author($value); |
|
2199 | 2199 | } |
2200 | 2200 | |
2201 | 2201 | /** |
@@ -2204,8 +2204,8 @@ discard block |
||
2204 | 2204 | * @since 1.0.19 |
2205 | 2205 | * @param string $value ip address. |
2206 | 2206 | */ |
2207 | - public function set_ip( $value ) { |
|
2208 | - $this->set_prop( 'ip', $value ); |
|
2207 | + public function set_ip($value) { |
|
2208 | + $this->set_prop('ip', $value); |
|
2209 | 2209 | } |
2210 | 2210 | |
2211 | 2211 | /** |
@@ -2214,8 +2214,8 @@ discard block |
||
2214 | 2214 | * @since 1.0.19 |
2215 | 2215 | * @param string $value ip address. |
2216 | 2216 | */ |
2217 | - public function set_user_ip( $value ) { |
|
2218 | - $this->set_ip( $value ); |
|
2217 | + public function set_user_ip($value) { |
|
2218 | + $this->set_ip($value); |
|
2219 | 2219 | } |
2220 | 2220 | |
2221 | 2221 | /** |
@@ -2224,8 +2224,8 @@ discard block |
||
2224 | 2224 | * @since 1.0.19 |
2225 | 2225 | * @param string $value first name. |
2226 | 2226 | */ |
2227 | - public function set_first_name( $value ) { |
|
2228 | - $this->set_prop( 'first_name', $value ); |
|
2227 | + public function set_first_name($value) { |
|
2228 | + $this->set_prop('first_name', $value); |
|
2229 | 2229 | } |
2230 | 2230 | |
2231 | 2231 | /** |
@@ -2234,8 +2234,8 @@ discard block |
||
2234 | 2234 | * @since 1.0.19 |
2235 | 2235 | * @param string $value first name. |
2236 | 2236 | */ |
2237 | - public function set_user_first_name( $value ) { |
|
2238 | - $this->set_first_name( $value ); |
|
2237 | + public function set_user_first_name($value) { |
|
2238 | + $this->set_first_name($value); |
|
2239 | 2239 | } |
2240 | 2240 | |
2241 | 2241 | /** |
@@ -2244,8 +2244,8 @@ discard block |
||
2244 | 2244 | * @since 1.0.19 |
2245 | 2245 | * @param string $value first name. |
2246 | 2246 | */ |
2247 | - public function set_customer_first_name( $value ) { |
|
2248 | - $this->set_first_name( $value ); |
|
2247 | + public function set_customer_first_name($value) { |
|
2248 | + $this->set_first_name($value); |
|
2249 | 2249 | } |
2250 | 2250 | |
2251 | 2251 | /** |
@@ -2254,8 +2254,8 @@ discard block |
||
2254 | 2254 | * @since 1.0.19 |
2255 | 2255 | * @param string $value last name. |
2256 | 2256 | */ |
2257 | - public function set_last_name( $value ) { |
|
2258 | - $this->set_prop( 'last_name', $value ); |
|
2257 | + public function set_last_name($value) { |
|
2258 | + $this->set_prop('last_name', $value); |
|
2259 | 2259 | } |
2260 | 2260 | |
2261 | 2261 | /** |
@@ -2264,8 +2264,8 @@ discard block |
||
2264 | 2264 | * @since 1.0.19 |
2265 | 2265 | * @param string $value last name. |
2266 | 2266 | */ |
2267 | - public function set_user_last_name( $value ) { |
|
2268 | - $this->set_last_name( $value ); |
|
2267 | + public function set_user_last_name($value) { |
|
2268 | + $this->set_last_name($value); |
|
2269 | 2269 | } |
2270 | 2270 | |
2271 | 2271 | /** |
@@ -2274,8 +2274,8 @@ discard block |
||
2274 | 2274 | * @since 1.0.19 |
2275 | 2275 | * @param string $value last name. |
2276 | 2276 | */ |
2277 | - public function set_customer_last_name( $value ) { |
|
2278 | - $this->set_last_name( $value ); |
|
2277 | + public function set_customer_last_name($value) { |
|
2278 | + $this->set_last_name($value); |
|
2279 | 2279 | } |
2280 | 2280 | |
2281 | 2281 | /** |
@@ -2284,8 +2284,8 @@ discard block |
||
2284 | 2284 | * @since 1.0.19 |
2285 | 2285 | * @param string $value phone. |
2286 | 2286 | */ |
2287 | - public function set_phone( $value ) { |
|
2288 | - $this->set_prop( 'phone', $value ); |
|
2287 | + public function set_phone($value) { |
|
2288 | + $this->set_prop('phone', $value); |
|
2289 | 2289 | } |
2290 | 2290 | |
2291 | 2291 | /** |
@@ -2294,8 +2294,8 @@ discard block |
||
2294 | 2294 | * @since 1.0.19 |
2295 | 2295 | * @param string $value phone. |
2296 | 2296 | */ |
2297 | - public function set_user_phone( $value ) { |
|
2298 | - $this->set_phone( $value ); |
|
2297 | + public function set_user_phone($value) { |
|
2298 | + $this->set_phone($value); |
|
2299 | 2299 | } |
2300 | 2300 | |
2301 | 2301 | /** |
@@ -2304,8 +2304,8 @@ discard block |
||
2304 | 2304 | * @since 1.0.19 |
2305 | 2305 | * @param string $value phone. |
2306 | 2306 | */ |
2307 | - public function set_customer_phone( $value ) { |
|
2308 | - $this->set_phone( $value ); |
|
2307 | + public function set_customer_phone($value) { |
|
2308 | + $this->set_phone($value); |
|
2309 | 2309 | } |
2310 | 2310 | |
2311 | 2311 | /** |
@@ -2314,8 +2314,8 @@ discard block |
||
2314 | 2314 | * @since 1.0.19 |
2315 | 2315 | * @param string $value phone. |
2316 | 2316 | */ |
2317 | - public function set_phone_number( $value ) { |
|
2318 | - $this->set_phone( $value ); |
|
2317 | + public function set_phone_number($value) { |
|
2318 | + $this->set_phone($value); |
|
2319 | 2319 | } |
2320 | 2320 | |
2321 | 2321 | /** |
@@ -2324,8 +2324,8 @@ discard block |
||
2324 | 2324 | * @since 1.0.19 |
2325 | 2325 | * @param string $value email address. |
2326 | 2326 | */ |
2327 | - public function set_email( $value ) { |
|
2328 | - $this->set_prop( 'email', $value ); |
|
2327 | + public function set_email($value) { |
|
2328 | + $this->set_prop('email', $value); |
|
2329 | 2329 | } |
2330 | 2330 | |
2331 | 2331 | /** |
@@ -2334,8 +2334,8 @@ discard block |
||
2334 | 2334 | * @since 1.0.19 |
2335 | 2335 | * @param string $value email address. |
2336 | 2336 | */ |
2337 | - public function set_user_email( $value ) { |
|
2338 | - $this->set_email( $value ); |
|
2337 | + public function set_user_email($value) { |
|
2338 | + $this->set_email($value); |
|
2339 | 2339 | } |
2340 | 2340 | |
2341 | 2341 | /** |
@@ -2344,8 +2344,8 @@ discard block |
||
2344 | 2344 | * @since 1.0.19 |
2345 | 2345 | * @param string $value email address. |
2346 | 2346 | */ |
2347 | - public function set_email_address( $value ) { |
|
2348 | - $this->set_email( $value ); |
|
2347 | + public function set_email_address($value) { |
|
2348 | + $this->set_email($value); |
|
2349 | 2349 | } |
2350 | 2350 | |
2351 | 2351 | /** |
@@ -2354,8 +2354,8 @@ discard block |
||
2354 | 2354 | * @since 1.0.19 |
2355 | 2355 | * @param string $value email address. |
2356 | 2356 | */ |
2357 | - public function set_customer_email( $value ) { |
|
2358 | - $this->set_email( $value ); |
|
2357 | + public function set_customer_email($value) { |
|
2358 | + $this->set_email($value); |
|
2359 | 2359 | } |
2360 | 2360 | |
2361 | 2361 | /** |
@@ -2364,8 +2364,8 @@ discard block |
||
2364 | 2364 | * @since 1.0.19 |
2365 | 2365 | * @param string $value country. |
2366 | 2366 | */ |
2367 | - public function set_country( $value ) { |
|
2368 | - $this->set_prop( 'country', $value ); |
|
2367 | + public function set_country($value) { |
|
2368 | + $this->set_prop('country', $value); |
|
2369 | 2369 | } |
2370 | 2370 | |
2371 | 2371 | /** |
@@ -2374,8 +2374,8 @@ discard block |
||
2374 | 2374 | * @since 1.0.19 |
2375 | 2375 | * @param string $value country. |
2376 | 2376 | */ |
2377 | - public function set_user_country( $value ) { |
|
2378 | - $this->set_country( $value ); |
|
2377 | + public function set_user_country($value) { |
|
2378 | + $this->set_country($value); |
|
2379 | 2379 | } |
2380 | 2380 | |
2381 | 2381 | /** |
@@ -2384,8 +2384,8 @@ discard block |
||
2384 | 2384 | * @since 1.0.19 |
2385 | 2385 | * @param string $value country. |
2386 | 2386 | */ |
2387 | - public function set_customer_country( $value ) { |
|
2388 | - $this->set_country( $value ); |
|
2387 | + public function set_customer_country($value) { |
|
2388 | + $this->set_country($value); |
|
2389 | 2389 | } |
2390 | 2390 | |
2391 | 2391 | /** |
@@ -2394,8 +2394,8 @@ discard block |
||
2394 | 2394 | * @since 1.0.19 |
2395 | 2395 | * @param string $value state. |
2396 | 2396 | */ |
2397 | - public function set_state( $value ) { |
|
2398 | - $this->set_prop( 'state', $value ); |
|
2397 | + public function set_state($value) { |
|
2398 | + $this->set_prop('state', $value); |
|
2399 | 2399 | } |
2400 | 2400 | |
2401 | 2401 | /** |
@@ -2404,8 +2404,8 @@ discard block |
||
2404 | 2404 | * @since 1.0.19 |
2405 | 2405 | * @param string $value state. |
2406 | 2406 | */ |
2407 | - public function set_user_state( $value ) { |
|
2408 | - $this->set_state( $value ); |
|
2407 | + public function set_user_state($value) { |
|
2408 | + $this->set_state($value); |
|
2409 | 2409 | } |
2410 | 2410 | |
2411 | 2411 | /** |
@@ -2414,8 +2414,8 @@ discard block |
||
2414 | 2414 | * @since 1.0.19 |
2415 | 2415 | * @param string $value state. |
2416 | 2416 | */ |
2417 | - public function set_customer_state( $value ) { |
|
2418 | - $this->set_state( $value ); |
|
2417 | + public function set_customer_state($value) { |
|
2418 | + $this->set_state($value); |
|
2419 | 2419 | } |
2420 | 2420 | |
2421 | 2421 | /** |
@@ -2424,8 +2424,8 @@ discard block |
||
2424 | 2424 | * @since 1.0.19 |
2425 | 2425 | * @param string $value city. |
2426 | 2426 | */ |
2427 | - public function set_city( $value ) { |
|
2428 | - $this->set_prop( 'city', $value ); |
|
2427 | + public function set_city($value) { |
|
2428 | + $this->set_prop('city', $value); |
|
2429 | 2429 | } |
2430 | 2430 | |
2431 | 2431 | /** |
@@ -2434,8 +2434,8 @@ discard block |
||
2434 | 2434 | * @since 1.0.19 |
2435 | 2435 | * @param string $value city. |
2436 | 2436 | */ |
2437 | - public function set_user_city( $value ) { |
|
2438 | - $this->set_city( $value ); |
|
2437 | + public function set_user_city($value) { |
|
2438 | + $this->set_city($value); |
|
2439 | 2439 | } |
2440 | 2440 | |
2441 | 2441 | /** |
@@ -2444,8 +2444,8 @@ discard block |
||
2444 | 2444 | * @since 1.0.19 |
2445 | 2445 | * @param string $value city. |
2446 | 2446 | */ |
2447 | - public function set_customer_city( $value ) { |
|
2448 | - $this->set_city( $value ); |
|
2447 | + public function set_customer_city($value) { |
|
2448 | + $this->set_city($value); |
|
2449 | 2449 | } |
2450 | 2450 | |
2451 | 2451 | /** |
@@ -2454,8 +2454,8 @@ discard block |
||
2454 | 2454 | * @since 1.0.19 |
2455 | 2455 | * @param string $value zip. |
2456 | 2456 | */ |
2457 | - public function set_zip( $value ) { |
|
2458 | - $this->set_prop( 'zip', $value ); |
|
2457 | + public function set_zip($value) { |
|
2458 | + $this->set_prop('zip', $value); |
|
2459 | 2459 | } |
2460 | 2460 | |
2461 | 2461 | /** |
@@ -2464,8 +2464,8 @@ discard block |
||
2464 | 2464 | * @since 1.0.19 |
2465 | 2465 | * @param string $value zip. |
2466 | 2466 | */ |
2467 | - public function set_user_zip( $value ) { |
|
2468 | - $this->set_zip( $value ); |
|
2467 | + public function set_user_zip($value) { |
|
2468 | + $this->set_zip($value); |
|
2469 | 2469 | } |
2470 | 2470 | |
2471 | 2471 | /** |
@@ -2474,8 +2474,8 @@ discard block |
||
2474 | 2474 | * @since 1.0.19 |
2475 | 2475 | * @param string $value zip. |
2476 | 2476 | */ |
2477 | - public function set_customer_zip( $value ) { |
|
2478 | - $this->set_zip( $value ); |
|
2477 | + public function set_customer_zip($value) { |
|
2478 | + $this->set_zip($value); |
|
2479 | 2479 | } |
2480 | 2480 | |
2481 | 2481 | /** |
@@ -2484,8 +2484,8 @@ discard block |
||
2484 | 2484 | * @since 1.0.19 |
2485 | 2485 | * @param string $value company. |
2486 | 2486 | */ |
2487 | - public function set_company( $value ) { |
|
2488 | - $this->set_prop( 'company', $value ); |
|
2487 | + public function set_company($value) { |
|
2488 | + $this->set_prop('company', $value); |
|
2489 | 2489 | } |
2490 | 2490 | |
2491 | 2491 | /** |
@@ -2494,8 +2494,8 @@ discard block |
||
2494 | 2494 | * @since 1.0.19 |
2495 | 2495 | * @param string $value company. |
2496 | 2496 | */ |
2497 | - public function set_user_company( $value ) { |
|
2498 | - $this->set_company( $value ); |
|
2497 | + public function set_user_company($value) { |
|
2498 | + $this->set_company($value); |
|
2499 | 2499 | } |
2500 | 2500 | |
2501 | 2501 | /** |
@@ -2504,8 +2504,8 @@ discard block |
||
2504 | 2504 | * @since 1.0.19 |
2505 | 2505 | * @param string $value company. |
2506 | 2506 | */ |
2507 | - public function set_customer_company( $value ) { |
|
2508 | - $this->set_company( $value ); |
|
2507 | + public function set_customer_company($value) { |
|
2508 | + $this->set_company($value); |
|
2509 | 2509 | } |
2510 | 2510 | |
2511 | 2511 | /** |
@@ -2514,8 +2514,8 @@ discard block |
||
2514 | 2514 | * @since 1.0.19 |
2515 | 2515 | * @param string $value var number. |
2516 | 2516 | */ |
2517 | - public function set_vat_number( $value ) { |
|
2518 | - $this->set_prop( 'vat_number', $value ); |
|
2517 | + public function set_vat_number($value) { |
|
2518 | + $this->set_prop('vat_number', $value); |
|
2519 | 2519 | } |
2520 | 2520 | |
2521 | 2521 | /** |
@@ -2524,8 +2524,8 @@ discard block |
||
2524 | 2524 | * @since 1.0.19 |
2525 | 2525 | * @param string $value var number. |
2526 | 2526 | */ |
2527 | - public function set_user_vat_number( $value ) { |
|
2528 | - $this->set_vat_number( $value ); |
|
2527 | + public function set_user_vat_number($value) { |
|
2528 | + $this->set_vat_number($value); |
|
2529 | 2529 | } |
2530 | 2530 | |
2531 | 2531 | /** |
@@ -2534,8 +2534,8 @@ discard block |
||
2534 | 2534 | * @since 1.0.19 |
2535 | 2535 | * @param string $value var number. |
2536 | 2536 | */ |
2537 | - public function set_customer_vat_number( $value ) { |
|
2538 | - $this->set_vat_number( $value ); |
|
2537 | + public function set_customer_vat_number($value) { |
|
2538 | + $this->set_vat_number($value); |
|
2539 | 2539 | } |
2540 | 2540 | |
2541 | 2541 | /** |
@@ -2544,8 +2544,8 @@ discard block |
||
2544 | 2544 | * @since 1.0.19 |
2545 | 2545 | * @param string $value var rate. |
2546 | 2546 | */ |
2547 | - public function set_vat_rate( $value ) { |
|
2548 | - $this->set_prop( 'vat_rate', $value ); |
|
2547 | + public function set_vat_rate($value) { |
|
2548 | + $this->set_prop('vat_rate', $value); |
|
2549 | 2549 | } |
2550 | 2550 | |
2551 | 2551 | /** |
@@ -2554,8 +2554,8 @@ discard block |
||
2554 | 2554 | * @since 1.0.19 |
2555 | 2555 | * @param string $value var number. |
2556 | 2556 | */ |
2557 | - public function set_user_vat_rate( $value ) { |
|
2558 | - $this->set_vat_rate( $value ); |
|
2557 | + public function set_user_vat_rate($value) { |
|
2558 | + $this->set_vat_rate($value); |
|
2559 | 2559 | } |
2560 | 2560 | |
2561 | 2561 | /** |
@@ -2564,8 +2564,8 @@ discard block |
||
2564 | 2564 | * @since 1.0.19 |
2565 | 2565 | * @param string $value var number. |
2566 | 2566 | */ |
2567 | - public function set_customer_vat_rate( $value ) { |
|
2568 | - $this->set_vat_rate( $value ); |
|
2567 | + public function set_customer_vat_rate($value) { |
|
2568 | + $this->set_vat_rate($value); |
|
2569 | 2569 | } |
2570 | 2570 | |
2571 | 2571 | /** |
@@ -2574,8 +2574,8 @@ discard block |
||
2574 | 2574 | * @since 1.0.19 |
2575 | 2575 | * @param string $value address. |
2576 | 2576 | */ |
2577 | - public function set_address( $value ) { |
|
2578 | - $this->set_prop( 'address', $value ); |
|
2577 | + public function set_address($value) { |
|
2578 | + $this->set_prop('address', $value); |
|
2579 | 2579 | } |
2580 | 2580 | |
2581 | 2581 | /** |
@@ -2584,8 +2584,8 @@ discard block |
||
2584 | 2584 | * @since 1.0.19 |
2585 | 2585 | * @param string $value address. |
2586 | 2586 | */ |
2587 | - public function set_user_address( $value ) { |
|
2588 | - $this->set_address( $value ); |
|
2587 | + public function set_user_address($value) { |
|
2588 | + $this->set_address($value); |
|
2589 | 2589 | } |
2590 | 2590 | |
2591 | 2591 | /** |
@@ -2594,8 +2594,8 @@ discard block |
||
2594 | 2594 | * @since 1.0.19 |
2595 | 2595 | * @param string $value address. |
2596 | 2596 | */ |
2597 | - public function set_customer_address( $value ) { |
|
2598 | - $this->set_address( $value ); |
|
2597 | + public function set_customer_address($value) { |
|
2598 | + $this->set_address($value); |
|
2599 | 2599 | } |
2600 | 2600 | |
2601 | 2601 | /** |
@@ -2604,8 +2604,8 @@ discard block |
||
2604 | 2604 | * @since 1.0.19 |
2605 | 2605 | * @param int|bool $value confirmed. |
2606 | 2606 | */ |
2607 | - public function set_is_viewed( $value ) { |
|
2608 | - $this->set_prop( 'is_viewed', $value ); |
|
2607 | + public function set_is_viewed($value) { |
|
2608 | + $this->set_prop('is_viewed', $value); |
|
2609 | 2609 | } |
2610 | 2610 | |
2611 | 2611 | /** |
@@ -2614,8 +2614,8 @@ discard block |
||
2614 | 2614 | * @since 1.0.19 |
2615 | 2615 | * @param string $value email recipients. |
2616 | 2616 | */ |
2617 | - public function set_email_cc( $value ) { |
|
2618 | - $this->set_prop( 'email_cc', $value ); |
|
2617 | + public function set_email_cc($value) { |
|
2618 | + $this->set_prop('email_cc', $value); |
|
2619 | 2619 | } |
2620 | 2620 | |
2621 | 2621 | /** |
@@ -2624,9 +2624,9 @@ discard block |
||
2624 | 2624 | * @since 1.0.19 |
2625 | 2625 | * @param string $value email recipients. |
2626 | 2626 | */ |
2627 | - public function set_template( $value ) { |
|
2628 | - if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) { |
|
2629 | - $this->set_prop( 'template', $value ); |
|
2627 | + public function set_template($value) { |
|
2628 | + if (in_array($value, array('quantity', 'hours', 'amount'))) { |
|
2629 | + $this->set_prop('template', $value); |
|
2630 | 2630 | } |
2631 | 2631 | } |
2632 | 2632 | |
@@ -2636,8 +2636,8 @@ discard block |
||
2636 | 2636 | * @since 1.0.19 |
2637 | 2637 | * @param int|bool $value confirmed. |
2638 | 2638 | */ |
2639 | - public function set_address_confirmed( $value ) { |
|
2640 | - $this->set_prop( 'address_confirmed', $value ); |
|
2639 | + public function set_address_confirmed($value) { |
|
2640 | + $this->set_prop('address_confirmed', $value); |
|
2641 | 2641 | } |
2642 | 2642 | |
2643 | 2643 | /** |
@@ -2646,8 +2646,8 @@ discard block |
||
2646 | 2646 | * @since 1.0.19 |
2647 | 2647 | * @param int|bool $value confirmed. |
2648 | 2648 | */ |
2649 | - public function set_user_address_confirmed( $value ) { |
|
2650 | - $this->set_address_confirmed( $value ); |
|
2649 | + public function set_user_address_confirmed($value) { |
|
2650 | + $this->set_address_confirmed($value); |
|
2651 | 2651 | } |
2652 | 2652 | |
2653 | 2653 | /** |
@@ -2656,8 +2656,8 @@ discard block |
||
2656 | 2656 | * @since 1.0.19 |
2657 | 2657 | * @param int|bool $value confirmed. |
2658 | 2658 | */ |
2659 | - public function set_customer_address_confirmed( $value ) { |
|
2660 | - $this->set_address_confirmed( $value ); |
|
2659 | + public function set_customer_address_confirmed($value) { |
|
2660 | + $this->set_address_confirmed($value); |
|
2661 | 2661 | } |
2662 | 2662 | |
2663 | 2663 | /** |
@@ -2666,8 +2666,8 @@ discard block |
||
2666 | 2666 | * @since 1.0.19 |
2667 | 2667 | * @param float $value sub total. |
2668 | 2668 | */ |
2669 | - public function set_subtotal( $value ) { |
|
2670 | - $this->set_prop( 'subtotal', $value ); |
|
2669 | + public function set_subtotal($value) { |
|
2670 | + $this->set_prop('subtotal', $value); |
|
2671 | 2671 | } |
2672 | 2672 | |
2673 | 2673 | /** |
@@ -2676,8 +2676,8 @@ discard block |
||
2676 | 2676 | * @since 1.0.19 |
2677 | 2677 | * @param float $value discount total. |
2678 | 2678 | */ |
2679 | - public function set_total_discount( $value ) { |
|
2680 | - $this->set_prop( 'total_discount', $value ); |
|
2679 | + public function set_total_discount($value) { |
|
2680 | + $this->set_prop('total_discount', $value); |
|
2681 | 2681 | } |
2682 | 2682 | |
2683 | 2683 | /** |
@@ -2686,8 +2686,8 @@ discard block |
||
2686 | 2686 | * @since 1.0.19 |
2687 | 2687 | * @param float $value discount total. |
2688 | 2688 | */ |
2689 | - public function set_discount( $value ) { |
|
2690 | - $this->set_total_discount( $value ); |
|
2689 | + public function set_discount($value) { |
|
2690 | + $this->set_total_discount($value); |
|
2691 | 2691 | } |
2692 | 2692 | |
2693 | 2693 | /** |
@@ -2696,8 +2696,8 @@ discard block |
||
2696 | 2696 | * @since 1.0.19 |
2697 | 2697 | * @param float $value tax total. |
2698 | 2698 | */ |
2699 | - public function set_total_tax( $value ) { |
|
2700 | - $this->set_prop( 'total_tax', $value ); |
|
2699 | + public function set_total_tax($value) { |
|
2700 | + $this->set_prop('total_tax', $value); |
|
2701 | 2701 | } |
2702 | 2702 | |
2703 | 2703 | /** |
@@ -2706,8 +2706,8 @@ discard block |
||
2706 | 2706 | * @since 1.0.19 |
2707 | 2707 | * @param float $value tax total. |
2708 | 2708 | */ |
2709 | - public function set_tax_total( $value ) { |
|
2710 | - $this->set_total_tax( $value ); |
|
2709 | + public function set_tax_total($value) { |
|
2710 | + $this->set_total_tax($value); |
|
2711 | 2711 | } |
2712 | 2712 | |
2713 | 2713 | /** |
@@ -2716,8 +2716,8 @@ discard block |
||
2716 | 2716 | * @since 1.0.19 |
2717 | 2717 | * @param float $value fees total. |
2718 | 2718 | */ |
2719 | - public function set_total_fees( $value ) { |
|
2720 | - $this->set_prop( 'total_fees', $value ); |
|
2719 | + public function set_total_fees($value) { |
|
2720 | + $this->set_prop('total_fees', $value); |
|
2721 | 2721 | } |
2722 | 2722 | |
2723 | 2723 | /** |
@@ -2726,8 +2726,8 @@ discard block |
||
2726 | 2726 | * @since 1.0.19 |
2727 | 2727 | * @param float $value fees total. |
2728 | 2728 | */ |
2729 | - public function set_fees_total( $value ) { |
|
2730 | - $this->set_total_fees( $value ); |
|
2729 | + public function set_fees_total($value) { |
|
2730 | + $this->set_total_fees($value); |
|
2731 | 2731 | } |
2732 | 2732 | |
2733 | 2733 | /** |
@@ -2736,13 +2736,13 @@ discard block |
||
2736 | 2736 | * @since 1.0.19 |
2737 | 2737 | * @param array $value fees. |
2738 | 2738 | */ |
2739 | - public function set_fees( $value ) { |
|
2739 | + public function set_fees($value) { |
|
2740 | 2740 | |
2741 | - if ( ! is_array( $value ) ) { |
|
2741 | + if (!is_array($value)) { |
|
2742 | 2742 | $value = array(); |
2743 | 2743 | } |
2744 | 2744 | |
2745 | - $this->set_prop( 'fees', $value ); |
|
2745 | + $this->set_prop('fees', $value); |
|
2746 | 2746 | |
2747 | 2747 | } |
2748 | 2748 | |
@@ -2752,13 +2752,13 @@ discard block |
||
2752 | 2752 | * @since 1.0.19 |
2753 | 2753 | * @param array $value taxes. |
2754 | 2754 | */ |
2755 | - public function set_taxes( $value ) { |
|
2755 | + public function set_taxes($value) { |
|
2756 | 2756 | |
2757 | - if ( ! is_array( $value ) ) { |
|
2757 | + if (!is_array($value)) { |
|
2758 | 2758 | $value = array(); |
2759 | 2759 | } |
2760 | 2760 | |
2761 | - $this->set_prop( 'taxes', $value ); |
|
2761 | + $this->set_prop('taxes', $value); |
|
2762 | 2762 | |
2763 | 2763 | } |
2764 | 2764 | |
@@ -2768,13 +2768,13 @@ discard block |
||
2768 | 2768 | * @since 1.0.19 |
2769 | 2769 | * @param array $value discounts. |
2770 | 2770 | */ |
2771 | - public function set_discounts( $value ) { |
|
2771 | + public function set_discounts($value) { |
|
2772 | 2772 | |
2773 | - if ( ! is_array( $value ) ) { |
|
2773 | + if (!is_array($value)) { |
|
2774 | 2774 | $value = array(); |
2775 | 2775 | } |
2776 | 2776 | |
2777 | - $this->set_prop( 'discounts', $value ); |
|
2777 | + $this->set_prop('discounts', $value); |
|
2778 | 2778 | } |
2779 | 2779 | |
2780 | 2780 | /** |
@@ -2783,18 +2783,18 @@ discard block |
||
2783 | 2783 | * @since 1.0.19 |
2784 | 2784 | * @param GetPaid_Form_Item[] $value items. |
2785 | 2785 | */ |
2786 | - public function set_items( $value ) { |
|
2786 | + public function set_items($value) { |
|
2787 | 2787 | |
2788 | 2788 | // Remove existing items. |
2789 | - $this->set_prop( 'items', array() ); |
|
2789 | + $this->set_prop('items', array()); |
|
2790 | 2790 | |
2791 | 2791 | // Ensure that we have an array. |
2792 | - if ( ! is_array( $value ) ) { |
|
2792 | + if (!is_array($value)) { |
|
2793 | 2793 | return; |
2794 | 2794 | } |
2795 | 2795 | |
2796 | - foreach ( $value as $item ) { |
|
2797 | - $this->add_item( $item ); |
|
2796 | + foreach ($value as $item) { |
|
2797 | + $this->add_item($item); |
|
2798 | 2798 | } |
2799 | 2799 | |
2800 | 2800 | } |
@@ -2805,8 +2805,8 @@ discard block |
||
2805 | 2805 | * @since 1.0.19 |
2806 | 2806 | * @param int $value payment form. |
2807 | 2807 | */ |
2808 | - public function set_payment_form( $value ) { |
|
2809 | - $this->set_prop( 'payment_form', $value ); |
|
2808 | + public function set_payment_form($value) { |
|
2809 | + $this->set_prop('payment_form', $value); |
|
2810 | 2810 | } |
2811 | 2811 | |
2812 | 2812 | /** |
@@ -2815,8 +2815,8 @@ discard block |
||
2815 | 2815 | * @since 1.0.19 |
2816 | 2816 | * @param string $value submission id. |
2817 | 2817 | */ |
2818 | - public function set_submission_id( $value ) { |
|
2819 | - $this->set_prop( 'submission_id', $value ); |
|
2818 | + public function set_submission_id($value) { |
|
2819 | + $this->set_prop('submission_id', $value); |
|
2820 | 2820 | } |
2821 | 2821 | |
2822 | 2822 | /** |
@@ -2825,8 +2825,8 @@ discard block |
||
2825 | 2825 | * @since 1.0.19 |
2826 | 2826 | * @param string $value discount code. |
2827 | 2827 | */ |
2828 | - public function set_discount_code( $value ) { |
|
2829 | - $this->set_prop( 'discount_code', $value ); |
|
2828 | + public function set_discount_code($value) { |
|
2829 | + $this->set_prop('discount_code', $value); |
|
2830 | 2830 | } |
2831 | 2831 | |
2832 | 2832 | /** |
@@ -2835,8 +2835,8 @@ discard block |
||
2835 | 2835 | * @since 1.0.19 |
2836 | 2836 | * @param string $value gateway. |
2837 | 2837 | */ |
2838 | - public function set_gateway( $value ) { |
|
2839 | - $this->set_prop( 'gateway', $value ); |
|
2838 | + public function set_gateway($value) { |
|
2839 | + $this->set_prop('gateway', $value); |
|
2840 | 2840 | } |
2841 | 2841 | |
2842 | 2842 | /** |
@@ -2845,9 +2845,9 @@ discard block |
||
2845 | 2845 | * @since 1.0.19 |
2846 | 2846 | * @param string $value transaction id. |
2847 | 2847 | */ |
2848 | - public function set_transaction_id( $value ) { |
|
2849 | - if ( ! empty( $value ) ) { |
|
2850 | - $this->set_prop( 'transaction_id', $value ); |
|
2848 | + public function set_transaction_id($value) { |
|
2849 | + if (!empty($value)) { |
|
2850 | + $this->set_prop('transaction_id', $value); |
|
2851 | 2851 | } |
2852 | 2852 | } |
2853 | 2853 | |
@@ -2857,8 +2857,8 @@ discard block |
||
2857 | 2857 | * @since 1.0.19 |
2858 | 2858 | * @param string $value currency id. |
2859 | 2859 | */ |
2860 | - public function set_currency( $value ) { |
|
2861 | - $this->set_prop( 'currency', $value ); |
|
2860 | + public function set_currency($value) { |
|
2861 | + $this->set_prop('currency', $value); |
|
2862 | 2862 | } |
2863 | 2863 | |
2864 | 2864 | /** |
@@ -2867,8 +2867,8 @@ discard block |
||
2867 | 2867 | * @since 1.0.19 |
2868 | 2868 | * @param bool $value value. |
2869 | 2869 | */ |
2870 | - public function set_disable_taxes( $value ) { |
|
2871 | - $this->set_prop( 'disable_taxes', (bool) $value ); |
|
2870 | + public function set_disable_taxes($value) { |
|
2871 | + $this->set_prop('disable_taxes', (bool) $value); |
|
2872 | 2872 | } |
2873 | 2873 | |
2874 | 2874 | /** |
@@ -2877,8 +2877,8 @@ discard block |
||
2877 | 2877 | * @since 1.0.19 |
2878 | 2878 | * @param string $value subscription id. |
2879 | 2879 | */ |
2880 | - public function set_subscription_id( $value ) { |
|
2881 | - $this->set_prop( 'subscription_id', $value ); |
|
2880 | + public function set_subscription_id($value) { |
|
2881 | + $this->set_prop('subscription_id', $value); |
|
2882 | 2882 | } |
2883 | 2883 | |
2884 | 2884 | /** |
@@ -2887,8 +2887,8 @@ discard block |
||
2887 | 2887 | * @since 1.0.19 |
2888 | 2888 | * @param string $value subscription id. |
2889 | 2889 | */ |
2890 | - public function set_remote_subscription_id( $value ) { |
|
2891 | - $this->set_prop( 'remote_subscription_id', $value ); |
|
2890 | + public function set_remote_subscription_id($value) { |
|
2891 | + $this->set_prop('remote_subscription_id', $value); |
|
2892 | 2892 | } |
2893 | 2893 | |
2894 | 2894 | /* |
@@ -2905,28 +2905,28 @@ discard block |
||
2905 | 2905 | */ |
2906 | 2906 | public function is_parent() { |
2907 | 2907 | $parent = $this->get_parent_id(); |
2908 | - return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this ); |
|
2908 | + return apply_filters('wpinv_invoice_is_parent', empty($parent), $this); |
|
2909 | 2909 | } |
2910 | 2910 | |
2911 | 2911 | /** |
2912 | 2912 | * Checks if this is a renewal invoice. |
2913 | 2913 | */ |
2914 | 2914 | public function is_renewal() { |
2915 | - return ! $this->is_parent(); |
|
2915 | + return !$this->is_parent(); |
|
2916 | 2916 | } |
2917 | 2917 | |
2918 | 2918 | /** |
2919 | 2919 | * Checks if this is a recurring invoice. |
2920 | 2920 | */ |
2921 | 2921 | public function is_recurring() { |
2922 | - return $this->is_renewal() || ! empty( $this->recurring_item ); |
|
2922 | + return $this->is_renewal() || !empty($this->recurring_item); |
|
2923 | 2923 | } |
2924 | 2924 | |
2925 | 2925 | /** |
2926 | 2926 | * Checks if this is a taxable invoice. |
2927 | 2927 | */ |
2928 | 2928 | public function is_taxable() { |
2929 | - return ! $this->get_disable_taxes(); |
|
2929 | + return !$this->get_disable_taxes(); |
|
2930 | 2930 | } |
2931 | 2931 | |
2932 | 2932 | /** |
@@ -2937,57 +2937,57 @@ discard block |
||
2937 | 2937 | |
2938 | 2938 | $requires_vat = false; |
2939 | 2939 | |
2940 | - if ( $this->country ) { |
|
2940 | + if ($this->country) { |
|
2941 | 2941 | $wpi_country = $this->country; |
2942 | - $requires_vat = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) ); |
|
2942 | + $requires_vat = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this)); |
|
2943 | 2943 | } |
2944 | 2944 | |
2945 | - return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this ); |
|
2945 | + return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this); |
|
2946 | 2946 | } |
2947 | 2947 | |
2948 | 2948 | /** |
2949 | 2949 | * Checks to see if the invoice requires payment. |
2950 | 2950 | */ |
2951 | 2951 | public function is_free() { |
2952 | - $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 ); |
|
2952 | + $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0); |
|
2953 | 2953 | |
2954 | - if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) { |
|
2954 | + if ($this->is_recurring() && $this->get_recurring_total() > 0) { |
|
2955 | 2955 | $is_free = false; |
2956 | 2956 | } |
2957 | 2957 | |
2958 | - return apply_filters( 'wpinv_invoice_is_free', $is_free, $this ); |
|
2958 | + return apply_filters('wpinv_invoice_is_free', $is_free, $this); |
|
2959 | 2959 | } |
2960 | 2960 | |
2961 | 2961 | /** |
2962 | 2962 | * Checks if the invoice is paid. |
2963 | 2963 | */ |
2964 | 2964 | public function is_paid() { |
2965 | - $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) ); |
|
2966 | - return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this ); |
|
2965 | + $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal')); |
|
2966 | + return apply_filters('wpinv_invoice_is_paid', $is_paid, $this); |
|
2967 | 2967 | } |
2968 | 2968 | |
2969 | 2969 | /** |
2970 | 2970 | * Checks if the invoice needs payment. |
2971 | 2971 | */ |
2972 | 2972 | public function needs_payment() { |
2973 | - $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free(); |
|
2974 | - return apply_filters( 'wpinv_needs_payment', $needs_payment, $this ); |
|
2973 | + $needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free(); |
|
2974 | + return apply_filters('wpinv_needs_payment', $needs_payment, $this); |
|
2975 | 2975 | } |
2976 | 2976 | |
2977 | 2977 | /** |
2978 | 2978 | * Checks if the invoice is refunded. |
2979 | 2979 | */ |
2980 | 2980 | public function is_refunded() { |
2981 | - $is_refunded = $this->has_status( 'wpi-refunded' ); |
|
2982 | - return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this ); |
|
2981 | + $is_refunded = $this->has_status('wpi-refunded'); |
|
2982 | + return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this); |
|
2983 | 2983 | } |
2984 | 2984 | |
2985 | 2985 | /** |
2986 | 2986 | * Checks if the invoice is held. |
2987 | 2987 | */ |
2988 | 2988 | public function is_held() { |
2989 | - $is_held = $this->has_status( 'wpi-onhold' ); |
|
2990 | - return apply_filters( 'wpinv_invoice_is_held', $is_held, $this ); |
|
2989 | + $is_held = $this->has_status('wpi-onhold'); |
|
2990 | + return apply_filters('wpinv_invoice_is_held', $is_held, $this); |
|
2991 | 2991 | } |
2992 | 2992 | |
2993 | 2993 | /** |
@@ -2995,30 +2995,30 @@ discard block |
||
2995 | 2995 | */ |
2996 | 2996 | public function is_due() { |
2997 | 2997 | $due_date = $this->get_due_date(); |
2998 | - return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date ); |
|
2998 | + return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date); |
|
2999 | 2999 | } |
3000 | 3000 | |
3001 | 3001 | /** |
3002 | 3002 | * Checks if the invoice is draft. |
3003 | 3003 | */ |
3004 | 3004 | public function is_draft() { |
3005 | - return $this->has_status( 'draft, auto-draft' ); |
|
3005 | + return $this->has_status('draft, auto-draft'); |
|
3006 | 3006 | } |
3007 | 3007 | |
3008 | 3008 | /** |
3009 | 3009 | * Checks if the invoice has a given status. |
3010 | 3010 | */ |
3011 | - public function has_status( $status ) { |
|
3012 | - $status = wpinv_parse_list( $status ); |
|
3013 | - return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status ); |
|
3011 | + public function has_status($status) { |
|
3012 | + $status = wpinv_parse_list($status); |
|
3013 | + return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status); |
|
3014 | 3014 | } |
3015 | 3015 | |
3016 | 3016 | /** |
3017 | 3017 | * Checks if the invoice is of a given type. |
3018 | 3018 | */ |
3019 | - public function is_type( $type ) { |
|
3020 | - $type = wpinv_parse_list( $type ); |
|
3021 | - return in_array( $this->get_type(), $type ); |
|
3019 | + public function is_type($type) { |
|
3020 | + $type = wpinv_parse_list($type); |
|
3021 | + return in_array($this->get_type(), $type); |
|
3022 | 3022 | } |
3023 | 3023 | |
3024 | 3024 | /** |
@@ -3050,8 +3050,8 @@ discard block |
||
3050 | 3050 | * |
3051 | 3051 | */ |
3052 | 3052 | public function is_initial_free() { |
3053 | - $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 ); |
|
3054 | - return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this ); |
|
3053 | + $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0); |
|
3054 | + return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this); |
|
3055 | 3055 | } |
3056 | 3056 | |
3057 | 3057 | /** |
@@ -3061,11 +3061,11 @@ discard block |
||
3061 | 3061 | public function item_has_free_trial() { |
3062 | 3062 | |
3063 | 3063 | // Ensure we have a recurring item. |
3064 | - if ( ! $this->is_recurring() ) { |
|
3064 | + if (!$this->is_recurring()) { |
|
3065 | 3065 | return false; |
3066 | 3066 | } |
3067 | 3067 | |
3068 | - $item = $this->get_recurring( true ); |
|
3068 | + $item = $this->get_recurring(true); |
|
3069 | 3069 | return $item->has_free_trial(); |
3070 | 3070 | } |
3071 | 3071 | |
@@ -3073,7 +3073,7 @@ discard block |
||
3073 | 3073 | * Check if the free trial is a result of a discount. |
3074 | 3074 | */ |
3075 | 3075 | public function is_free_trial_from_discount() { |
3076 | - return $this->has_free_trial() && ! $this->item_has_free_trial(); |
|
3076 | + return $this->has_free_trial() && !$this->item_has_free_trial(); |
|
3077 | 3077 | } |
3078 | 3078 | |
3079 | 3079 | /** |
@@ -3082,17 +3082,17 @@ discard block |
||
3082 | 3082 | public function discount_first_payment_only() { |
3083 | 3083 | |
3084 | 3084 | $discount_code = $this->get_discount_code(); |
3085 | - if ( empty( $this->discount_code ) || ! $this->is_recurring() ) { |
|
3085 | + if (empty($this->discount_code) || !$this->is_recurring()) { |
|
3086 | 3086 | return true; |
3087 | 3087 | } |
3088 | 3088 | |
3089 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3089 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3090 | 3090 | |
3091 | - if ( ! $discount || ! $discount->exists() ) { |
|
3091 | + if (!$discount || !$discount->exists()) { |
|
3092 | 3092 | return true; |
3093 | 3093 | } |
3094 | 3094 | |
3095 | - return ! $discount->get_is_recurring(); |
|
3095 | + return !$discount->get_is_recurring(); |
|
3096 | 3096 | } |
3097 | 3097 | |
3098 | 3098 | /* |
@@ -3110,27 +3110,27 @@ discard block |
||
3110 | 3110 | * @param GetPaid_Form_Item|array $item |
3111 | 3111 | * @return WP_Error|Bool |
3112 | 3112 | */ |
3113 | - public function add_item( $item ) { |
|
3113 | + public function add_item($item) { |
|
3114 | 3114 | |
3115 | - if ( is_array( $item ) ) { |
|
3116 | - $item = $this->process_array_item( $item ); |
|
3115 | + if (is_array($item)) { |
|
3116 | + $item = $this->process_array_item($item); |
|
3117 | 3117 | } |
3118 | 3118 | |
3119 | - if ( is_numeric( $item ) ) { |
|
3120 | - $item = new GetPaid_Form_Item( $item ); |
|
3119 | + if (is_numeric($item)) { |
|
3120 | + $item = new GetPaid_Form_Item($item); |
|
3121 | 3121 | } |
3122 | 3122 | |
3123 | 3123 | // Make sure that it is available for purchase. |
3124 | - if ( $item->get_id() > 0 && ! $item->can_purchase() ) { |
|
3125 | - return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) ); |
|
3124 | + if ($item->get_id() > 0 && !$item->can_purchase()) { |
|
3125 | + return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing')); |
|
3126 | 3126 | } |
3127 | 3127 | |
3128 | 3128 | // Do we have a recurring item? |
3129 | - if ( $item->is_recurring() ) { |
|
3129 | + if ($item->is_recurring()) { |
|
3130 | 3130 | |
3131 | 3131 | // An invoice can only contain one recurring item. |
3132 | - if ( ! empty( $this->recurring_item && $this->recurring_item != (int) $item->get_id() ) ) { |
|
3133 | - return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) ); |
|
3132 | + if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) { |
|
3133 | + return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing')); |
|
3134 | 3134 | } |
3135 | 3135 | |
3136 | 3136 | $this->recurring_item = $item->get_id(); |
@@ -3141,9 +3141,9 @@ discard block |
||
3141 | 3141 | |
3142 | 3142 | // Retrieve all items. |
3143 | 3143 | $items = $this->get_items(); |
3144 | - $items[ (int) $item->get_id() ] = $item; |
|
3144 | + $items[(int) $item->get_id()] = $item; |
|
3145 | 3145 | |
3146 | - $this->set_prop( 'items', $items ); |
|
3146 | + $this->set_prop('items', $items); |
|
3147 | 3147 | return true; |
3148 | 3148 | } |
3149 | 3149 | |
@@ -3153,26 +3153,26 @@ discard block |
||
3153 | 3153 | * @since 1.0.19 |
3154 | 3154 | * @return GetPaid_Form_Item |
3155 | 3155 | */ |
3156 | - protected function process_array_item( $array ) { |
|
3156 | + protected function process_array_item($array) { |
|
3157 | 3157 | |
3158 | - $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0; |
|
3159 | - $item = new GetPaid_Form_Item( $item_id ); |
|
3158 | + $item_id = isset($array['item_id']) ? $array['item_id'] : 0; |
|
3159 | + $item = new GetPaid_Form_Item($item_id); |
|
3160 | 3160 | |
3161 | 3161 | // Set item data. |
3162 | - foreach( array( 'name', 'price', 'description' ) as $key ) { |
|
3163 | - if ( isset( $array[ "item_$key" ] ) ) { |
|
3162 | + foreach (array('name', 'price', 'description') as $key) { |
|
3163 | + if (isset($array["item_$key"])) { |
|
3164 | 3164 | $method = "set_$key"; |
3165 | - $item->$method( $array[ "item_$key" ] ); |
|
3165 | + $item->$method($array["item_$key"]); |
|
3166 | 3166 | } |
3167 | 3167 | } |
3168 | 3168 | |
3169 | - if ( isset( $array['quantity'] ) ) { |
|
3170 | - $item->set_quantity( $array['quantity'] ); |
|
3169 | + if (isset($array['quantity'])) { |
|
3170 | + $item->set_quantity($array['quantity']); |
|
3171 | 3171 | } |
3172 | 3172 | |
3173 | 3173 | // Set item meta. |
3174 | - if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) { |
|
3175 | - $item->set_item_meta( $array['meta'] ); |
|
3174 | + if (isset($array['meta']) && is_array($array['meta'])) { |
|
3175 | + $item->set_item_meta($array['meta']); |
|
3176 | 3176 | } |
3177 | 3177 | |
3178 | 3178 | return $item; |
@@ -3184,10 +3184,10 @@ discard block |
||
3184 | 3184 | * |
3185 | 3185 | * @since 1.0.19 |
3186 | 3186 | */ |
3187 | - public function get_item( $item_id ) { |
|
3187 | + public function get_item($item_id) { |
|
3188 | 3188 | $items = $this->get_items(); |
3189 | 3189 | $item_id = (int) $item_id; |
3190 | - return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null; |
|
3190 | + return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null; |
|
3191 | 3191 | } |
3192 | 3192 | |
3193 | 3193 | /** |
@@ -3195,17 +3195,17 @@ discard block |
||
3195 | 3195 | * |
3196 | 3196 | * @since 1.0.19 |
3197 | 3197 | */ |
3198 | - public function remove_item( $item_id ) { |
|
3198 | + public function remove_item($item_id) { |
|
3199 | 3199 | $items = $this->get_items(); |
3200 | 3200 | $item_id = (int) $item_id; |
3201 | 3201 | |
3202 | - if ( $item_id == $this->recurring_item ) { |
|
3202 | + if ($item_id == $this->recurring_item) { |
|
3203 | 3203 | $this->recurring_item = null; |
3204 | 3204 | } |
3205 | 3205 | |
3206 | - if ( isset( $items[ $item_id ] ) ) { |
|
3207 | - unset( $items[ $item_id ] ); |
|
3208 | - $this->set_prop( 'items', $items ); |
|
3206 | + if (isset($items[$item_id])) { |
|
3207 | + unset($items[$item_id]); |
|
3208 | + $this->set_prop('items', $items); |
|
3209 | 3209 | } |
3210 | 3210 | } |
3211 | 3211 | |
@@ -3215,11 +3215,11 @@ discard block |
||
3215 | 3215 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
3216 | 3216 | * @since 1.0.19 |
3217 | 3217 | */ |
3218 | - public function add_fee( $fee ) { |
|
3218 | + public function add_fee($fee) { |
|
3219 | 3219 | |
3220 | 3220 | $fees = $this->get_fees(); |
3221 | - $fees[ $fee['name'] ] = $fee; |
|
3222 | - $this->set_prop( 'fees', $fees ); |
|
3221 | + $fees[$fee['name']] = $fee; |
|
3222 | + $this->set_prop('fees', $fees); |
|
3223 | 3223 | |
3224 | 3224 | } |
3225 | 3225 | |
@@ -3228,9 +3228,9 @@ discard block |
||
3228 | 3228 | * |
3229 | 3229 | * @since 1.0.19 |
3230 | 3230 | */ |
3231 | - public function get_fee( $fee ) { |
|
3231 | + public function get_fee($fee) { |
|
3232 | 3232 | $fees = $this->get_fees(); |
3233 | - return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null; |
|
3233 | + return isset($fees[$fee]) ? $fees[$fee] : null; |
|
3234 | 3234 | } |
3235 | 3235 | |
3236 | 3236 | /** |
@@ -3238,11 +3238,11 @@ discard block |
||
3238 | 3238 | * |
3239 | 3239 | * @since 1.0.19 |
3240 | 3240 | */ |
3241 | - public function remove_fee( $fee ) { |
|
3241 | + public function remove_fee($fee) { |
|
3242 | 3242 | $fees = $this->get_fees(); |
3243 | - if ( isset( $fees[ $fee ] ) ) { |
|
3244 | - unset( $fees[ $fee ] ); |
|
3245 | - $this->set_prop( 'fees', $fees ); |
|
3243 | + if (isset($fees[$fee])) { |
|
3244 | + unset($fees[$fee]); |
|
3245 | + $this->set_prop('fees', $fees); |
|
3246 | 3246 | } |
3247 | 3247 | } |
3248 | 3248 | |
@@ -3252,11 +3252,11 @@ discard block |
||
3252 | 3252 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
3253 | 3253 | * @since 1.0.19 |
3254 | 3254 | */ |
3255 | - public function add_discount( $discount ) { |
|
3255 | + public function add_discount($discount) { |
|
3256 | 3256 | |
3257 | 3257 | $discounts = $this->get_discounts(); |
3258 | - $discounts[ $discount['name'] ] = $discount; |
|
3259 | - $this->set_prop( 'discounts', $discounts ); |
|
3258 | + $discounts[$discount['name']] = $discount; |
|
3259 | + $this->set_prop('discounts', $discounts); |
|
3260 | 3260 | |
3261 | 3261 | } |
3262 | 3262 | |
@@ -3266,15 +3266,15 @@ discard block |
||
3266 | 3266 | * @since 1.0.19 |
3267 | 3267 | * @return float |
3268 | 3268 | */ |
3269 | - public function get_discount( $discount = false ) { |
|
3269 | + public function get_discount($discount = false) { |
|
3270 | 3270 | |
3271 | 3271 | // Backwards compatibilty. |
3272 | - if ( empty( $discount ) ) { |
|
3272 | + if (empty($discount)) { |
|
3273 | 3273 | return $this->get_total_discount(); |
3274 | 3274 | } |
3275 | 3275 | |
3276 | 3276 | $discounts = $this->get_discounts(); |
3277 | - return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null; |
|
3277 | + return isset($discounts[$discount]) ? $discounts[$discount] : null; |
|
3278 | 3278 | } |
3279 | 3279 | |
3280 | 3280 | /** |
@@ -3282,11 +3282,11 @@ discard block |
||
3282 | 3282 | * |
3283 | 3283 | * @since 1.0.19 |
3284 | 3284 | */ |
3285 | - public function remove_discount( $discount ) { |
|
3285 | + public function remove_discount($discount) { |
|
3286 | 3286 | $discounts = $this->get_discounts(); |
3287 | - if ( isset( $discounts[ $discount ] ) ) { |
|
3288 | - unset( $discounts[ $discount ] ); |
|
3289 | - $this->set_prop( 'discounts', $discounts ); |
|
3287 | + if (isset($discounts[$discount])) { |
|
3288 | + unset($discounts[$discount]); |
|
3289 | + $this->set_prop('discounts', $discounts); |
|
3290 | 3290 | } |
3291 | 3291 | } |
3292 | 3292 | |
@@ -3296,13 +3296,13 @@ discard block |
||
3296 | 3296 | * @param string $tax |
3297 | 3297 | * @param float $value |
3298 | 3298 | */ |
3299 | - public function add_tax( $tax, $value, $recurring = true ) { |
|
3299 | + public function add_tax($tax, $value, $recurring = true) { |
|
3300 | 3300 | |
3301 | - if ( $this->is_taxable() ) { |
|
3301 | + if ($this->is_taxable()) { |
|
3302 | 3302 | |
3303 | - $taxes = $this->get_taxes(); |
|
3304 | - $taxes[ $tax['name'] ] = $tax; |
|
3305 | - $this->set_prop( 'taxes', $tax ); |
|
3303 | + $taxes = $this->get_taxes(); |
|
3304 | + $taxes[$tax['name']] = $tax; |
|
3305 | + $this->set_prop('taxes', $tax); |
|
3306 | 3306 | |
3307 | 3307 | } |
3308 | 3308 | |
@@ -3313,15 +3313,15 @@ discard block |
||
3313 | 3313 | * |
3314 | 3314 | * @since 1.0.19 |
3315 | 3315 | */ |
3316 | - public function get_tax( $tax = null ) { |
|
3316 | + public function get_tax($tax = null) { |
|
3317 | 3317 | |
3318 | 3318 | // Backwards compatility. |
3319 | - if ( empty( $tax ) ) { |
|
3319 | + if (empty($tax)) { |
|
3320 | 3320 | return $this->get_total_tax(); |
3321 | 3321 | } |
3322 | 3322 | |
3323 | 3323 | $taxes = $this->get_taxes(); |
3324 | - return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null; |
|
3324 | + return isset($taxes[$tax]) ? $taxes[$tax] : null; |
|
3325 | 3325 | } |
3326 | 3326 | |
3327 | 3327 | /** |
@@ -3329,11 +3329,11 @@ discard block |
||
3329 | 3329 | * |
3330 | 3330 | * @since 1.0.19 |
3331 | 3331 | */ |
3332 | - public function remove_tax( $tax ) { |
|
3332 | + public function remove_tax($tax) { |
|
3333 | 3333 | $taxes = $this->get_taxes(); |
3334 | - if ( isset( $taxes[ $tax ] ) ) { |
|
3335 | - unset( $taxes[ $tax ] ); |
|
3336 | - $this->set_prop( 'taxes', $taxes ); |
|
3334 | + if (isset($taxes[$tax])) { |
|
3335 | + unset($taxes[$tax]); |
|
3336 | + $this->set_prop('taxes', $taxes); |
|
3337 | 3337 | } |
3338 | 3338 | } |
3339 | 3339 | |
@@ -3344,19 +3344,19 @@ discard block |
||
3344 | 3344 | * @return float The recalculated subtotal |
3345 | 3345 | */ |
3346 | 3346 | public function recalculate_subtotal() { |
3347 | - $items = $this->get_items(); |
|
3347 | + $items = $this->get_items(); |
|
3348 | 3348 | $subtotal = 0; |
3349 | 3349 | $recurring = 0; |
3350 | 3350 | |
3351 | - foreach ( $items as $item ) { |
|
3351 | + foreach ($items as $item) { |
|
3352 | 3352 | $subtotal += $item->get_sub_total(); |
3353 | 3353 | $recurring += $item->get_recurring_sub_total(); |
3354 | 3354 | } |
3355 | 3355 | |
3356 | - if ( $this->is_renewal() ) { |
|
3357 | - $this->set_subtotal( $recurring ); |
|
3356 | + if ($this->is_renewal()) { |
|
3357 | + $this->set_subtotal($recurring); |
|
3358 | 3358 | } else { |
3359 | - $this->set_subtotal( $subtotal ); |
|
3359 | + $this->set_subtotal($subtotal); |
|
3360 | 3360 | } |
3361 | 3361 | |
3362 | 3362 | $this->totals['subtotal'] = array( |
@@ -3378,9 +3378,9 @@ discard block |
||
3378 | 3378 | $discount = 0; |
3379 | 3379 | $recurring = 0; |
3380 | 3380 | |
3381 | - foreach ( $discounts as $data ) { |
|
3381 | + foreach ($discounts as $data) { |
|
3382 | 3382 | |
3383 | - if ( $data['recurring'] ) { |
|
3383 | + if ($data['recurring']) { |
|
3384 | 3384 | $recurring += $data['amount']; |
3385 | 3385 | } else { |
3386 | 3386 | $discount += $data['amount']; |
@@ -3388,10 +3388,10 @@ discard block |
||
3388 | 3388 | |
3389 | 3389 | } |
3390 | 3390 | |
3391 | - if ( $this->is_renewal() ) { |
|
3392 | - $this->set_total_discount( $recurring ); |
|
3391 | + if ($this->is_renewal()) { |
|
3392 | + $this->set_total_discount($recurring); |
|
3393 | 3393 | } else { |
3394 | - $this->set_total_discount( $discount ); |
|
3394 | + $this->set_total_discount($discount); |
|
3395 | 3395 | } |
3396 | 3396 | |
3397 | 3397 | $this->totals['discount'] = array( |
@@ -3410,13 +3410,13 @@ discard block |
||
3410 | 3410 | * @return float The recalculated tax |
3411 | 3411 | */ |
3412 | 3412 | public function recalculate_total_tax() { |
3413 | - $taxes = $this->get_taxes(); |
|
3413 | + $taxes = $this->get_taxes(); |
|
3414 | 3414 | $tax = 0; |
3415 | 3415 | $recurring = 0; |
3416 | 3416 | |
3417 | - foreach ( $taxes as $data ) { |
|
3417 | + foreach ($taxes as $data) { |
|
3418 | 3418 | |
3419 | - if ( $data['recurring'] ) { |
|
3419 | + if ($data['recurring']) { |
|
3420 | 3420 | $recurring += $data['amount']; |
3421 | 3421 | } else { |
3422 | 3422 | $tax += $data['amount']; |
@@ -3424,10 +3424,10 @@ discard block |
||
3424 | 3424 | |
3425 | 3425 | } |
3426 | 3426 | |
3427 | - if ( $this->is_renewal() ) { |
|
3428 | - $this->set_total_tax( $recurring ); |
|
3427 | + if ($this->is_renewal()) { |
|
3428 | + $this->set_total_tax($recurring); |
|
3429 | 3429 | } else { |
3430 | - $this->set_total_tax( $tax ); |
|
3430 | + $this->set_total_tax($tax); |
|
3431 | 3431 | } |
3432 | 3432 | |
3433 | 3433 | $this->totals['tax'] = array( |
@@ -3450,9 +3450,9 @@ discard block |
||
3450 | 3450 | $fee = 0; |
3451 | 3451 | $recurring = 0; |
3452 | 3452 | |
3453 | - foreach ( $fees as $data ) { |
|
3453 | + foreach ($fees as $data) { |
|
3454 | 3454 | |
3455 | - if ( $data['recurring'] ) { |
|
3455 | + if ($data['recurring']) { |
|
3456 | 3456 | $recurring += $data['amount']; |
3457 | 3457 | } else { |
3458 | 3458 | $fee += $data['amount']; |
@@ -3460,10 +3460,10 @@ discard block |
||
3460 | 3460 | |
3461 | 3461 | } |
3462 | 3462 | |
3463 | - if ( $this->is_renewal() ) { |
|
3464 | - $this->set_total_fees( $recurring ); |
|
3463 | + if ($this->is_renewal()) { |
|
3464 | + $this->set_total_fees($recurring); |
|
3465 | 3465 | } else { |
3466 | - $this->set_total_fees( $fee ); |
|
3466 | + $this->set_total_fees($fee); |
|
3467 | 3467 | } |
3468 | 3468 | |
3469 | 3469 | $this->totals['fee'] = array( |
@@ -3471,7 +3471,7 @@ discard block |
||
3471 | 3471 | 'recurring' => $recurring, |
3472 | 3472 | ); |
3473 | 3473 | |
3474 | - $this->set_total_fees( $fee ); |
|
3474 | + $this->set_total_fees($fee); |
|
3475 | 3475 | return $this->is_renewal() ? $recurring : $fee; |
3476 | 3476 | } |
3477 | 3477 | |
@@ -3492,9 +3492,9 @@ discard block |
||
3492 | 3492 | /** |
3493 | 3493 | * @deprecated |
3494 | 3494 | */ |
3495 | - public function recalculate_totals( $temp = false ) { |
|
3496 | - $this->update_items( $temp ); |
|
3497 | - $this->save( true ); |
|
3495 | + public function recalculate_totals($temp = false) { |
|
3496 | + $this->update_items($temp); |
|
3497 | + $this->save(true); |
|
3498 | 3498 | return $this; |
3499 | 3499 | } |
3500 | 3500 | |
@@ -3512,10 +3512,10 @@ discard block |
||
3512 | 3512 | * @return int|false The new note's ID on success, false on failure. |
3513 | 3513 | * |
3514 | 3514 | */ |
3515 | - public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) { |
|
3515 | + public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) { |
|
3516 | 3516 | |
3517 | 3517 | // Bail if no note specified or this invoice is not yet saved. |
3518 | - if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) { |
|
3518 | + if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) { |
|
3519 | 3519 | return false; |
3520 | 3520 | } |
3521 | 3521 | |
@@ -3523,23 +3523,23 @@ discard block |
||
3523 | 3523 | $author_email = '[email protected]'; |
3524 | 3524 | |
3525 | 3525 | // If this is an admin comment or it has been added by the user. |
3526 | - if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) { |
|
3527 | - $user = get_user_by( 'id', get_current_user_id() ); |
|
3526 | + if (is_user_logged_in() && (!$system || $added_by_user)) { |
|
3527 | + $user = get_user_by('id', get_current_user_id()); |
|
3528 | 3528 | $author = $user->display_name; |
3529 | 3529 | $author_email = $user->user_email; |
3530 | 3530 | } |
3531 | 3531 | |
3532 | - return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type ); |
|
3532 | + return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type); |
|
3533 | 3533 | |
3534 | 3534 | } |
3535 | 3535 | |
3536 | 3536 | /** |
3537 | 3537 | * Generates a unique key for the invoice. |
3538 | 3538 | */ |
3539 | - public function generate_key( $string = '' ) { |
|
3540 | - $auth_key = defined( 'AUTH_KEY' ) ? AUTH_KEY : ''; |
|
3539 | + public function generate_key($string = '') { |
|
3540 | + $auth_key = defined('AUTH_KEY') ? AUTH_KEY : ''; |
|
3541 | 3541 | return strtolower( |
3542 | - $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) ) |
|
3542 | + $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true)) |
|
3543 | 3543 | ); |
3544 | 3544 | } |
3545 | 3545 | |
@@ -3549,11 +3549,11 @@ discard block |
||
3549 | 3549 | public function generate_number() { |
3550 | 3550 | $number = $this->get_id(); |
3551 | 3551 | |
3552 | - if ( wpinv_sequential_number_active( $this->get_post_type() ) ) { |
|
3553 | - $number = wpinv_get_next_invoice_number( $this->get_post_type() ); |
|
3552 | + if (wpinv_sequential_number_active($this->get_post_type())) { |
|
3553 | + $number = wpinv_get_next_invoice_number($this->get_post_type()); |
|
3554 | 3554 | } |
3555 | 3555 | |
3556 | - return wpinv_format_invoice_number( $number, $this->get_post_type() ); |
|
3556 | + return wpinv_format_invoice_number($number, $this->get_post_type()); |
|
3557 | 3557 | |
3558 | 3558 | } |
3559 | 3559 | |
@@ -3566,55 +3566,55 @@ discard block |
||
3566 | 3566 | // Reset status transition variable. |
3567 | 3567 | $this->status_transition = false; |
3568 | 3568 | |
3569 | - if ( $status_transition ) { |
|
3569 | + if ($status_transition) { |
|
3570 | 3570 | try { |
3571 | 3571 | |
3572 | 3572 | // Fire a hook for the status change. |
3573 | - do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition ); |
|
3573 | + do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition); |
|
3574 | 3574 | |
3575 | 3575 | // @deprecated this is deprecated and will be removed in the future. |
3576 | - do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3576 | + do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3577 | 3577 | |
3578 | - if ( ! empty( $status_transition['from'] ) ) { |
|
3578 | + if (!empty($status_transition['from'])) { |
|
3579 | 3579 | |
3580 | 3580 | /* translators: 1: old invoice status 2: new invoice status */ |
3581 | - $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
3581 | + $transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to'])); |
|
3582 | 3582 | |
3583 | 3583 | // Fire another hook. |
3584 | - do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this ); |
|
3585 | - do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] ); |
|
3584 | + do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this); |
|
3585 | + do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']); |
|
3586 | 3586 | |
3587 | 3587 | // @deprecated this is deprecated and will be removed in the future. |
3588 | - do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] ); |
|
3588 | + do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']); |
|
3589 | 3589 | |
3590 | 3590 | // Note the transition occurred. |
3591 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3591 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
3592 | 3592 | |
3593 | 3593 | // Work out if this was for a payment, and trigger a payment_status hook instead. |
3594 | 3594 | if ( |
3595 | - in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3596 | - && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3595 | + in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3596 | + && in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3597 | 3597 | ) { |
3598 | - do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition ); |
|
3598 | + do_action('getpaid_invoice_payment_status_changed', $this, $status_transition); |
|
3599 | 3599 | } |
3600 | 3600 | |
3601 | 3601 | // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead. |
3602 | 3602 | if ( |
3603 | - in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true ) |
|
3604 | - && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true ) |
|
3603 | + in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true) |
|
3604 | + && in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true) |
|
3605 | 3605 | ) { |
3606 | - do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition ); |
|
3606 | + do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition); |
|
3607 | 3607 | } |
3608 | 3608 | } else { |
3609 | 3609 | /* translators: %s: new invoice status */ |
3610 | - $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) ); |
|
3610 | + $transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'])); |
|
3611 | 3611 | |
3612 | 3612 | // Note the transition occurred. |
3613 | - $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] ); |
|
3613 | + $this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']); |
|
3614 | 3614 | |
3615 | 3615 | } |
3616 | - } catch ( Exception $e ) { |
|
3617 | - $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() ); |
|
3616 | + } catch (Exception $e) { |
|
3617 | + $this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage()); |
|
3618 | 3618 | } |
3619 | 3619 | } |
3620 | 3620 | } |
@@ -3622,13 +3622,13 @@ discard block |
||
3622 | 3622 | /** |
3623 | 3623 | * Updates an invoice status. |
3624 | 3624 | */ |
3625 | - public function update_status( $new_status = false, $note = '', $manual = false ) { |
|
3625 | + public function update_status($new_status = false, $note = '', $manual = false) { |
|
3626 | 3626 | |
3627 | 3627 | // Fires before updating a status. |
3628 | - do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) ); |
|
3628 | + do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit')); |
|
3629 | 3629 | |
3630 | 3630 | // Update the status. |
3631 | - $this->set_status( $new_status, $note, $manual ); |
|
3631 | + $this->set_status($new_status, $note, $manual); |
|
3632 | 3632 | |
3633 | 3633 | // Save the order. |
3634 | 3634 | return $this->save(); |
@@ -3639,18 +3639,18 @@ discard block |
||
3639 | 3639 | * @deprecated |
3640 | 3640 | */ |
3641 | 3641 | public function refresh_item_ids() { |
3642 | - $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) ); |
|
3643 | - update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids ); |
|
3642 | + $item_ids = implode(',', array_unique(array_keys($this->get_items()))); |
|
3643 | + update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids); |
|
3644 | 3644 | } |
3645 | 3645 | |
3646 | 3646 | /** |
3647 | 3647 | * @deprecated |
3648 | 3648 | */ |
3649 | - public function update_items( $temp = false ) { |
|
3649 | + public function update_items($temp = false) { |
|
3650 | 3650 | |
3651 | - $this->set_items( $this->get_items() ); |
|
3651 | + $this->set_items($this->get_items()); |
|
3652 | 3652 | |
3653 | - if ( ! $temp ) { |
|
3653 | + if (!$temp) { |
|
3654 | 3654 | $this->save(); |
3655 | 3655 | } |
3656 | 3656 | |
@@ -3664,11 +3664,11 @@ discard block |
||
3664 | 3664 | |
3665 | 3665 | $discount_code = $this->get_discount_code(); |
3666 | 3666 | |
3667 | - if ( empty( $discount_code ) ) { |
|
3667 | + if (empty($discount_code)) { |
|
3668 | 3668 | return false; |
3669 | 3669 | } |
3670 | 3670 | |
3671 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
3671 | + $discount = wpinv_get_discount_obj($discount_code); |
|
3672 | 3672 | |
3673 | 3673 | // Ensure it is active. |
3674 | 3674 | return $discount->exists(); |
@@ -3679,7 +3679,7 @@ discard block |
||
3679 | 3679 | * Refunds an invoice. |
3680 | 3680 | */ |
3681 | 3681 | public function refund() { |
3682 | - $this->set_status( 'wpi-refunded' ); |
|
3682 | + $this->set_status('wpi-refunded'); |
|
3683 | 3683 | $this->save(); |
3684 | 3684 | } |
3685 | 3685 | |
@@ -3688,56 +3688,56 @@ discard block |
||
3688 | 3688 | * |
3689 | 3689 | * @param string $transaction_id |
3690 | 3690 | */ |
3691 | - public function mark_paid( $transaction_id = null, $note = '' ) { |
|
3691 | + public function mark_paid($transaction_id = null, $note = '') { |
|
3692 | 3692 | |
3693 | 3693 | // Set the transaction id. |
3694 | - if ( empty( $transaction_id ) ) { |
|
3694 | + if (empty($transaction_id)) { |
|
3695 | 3695 | $transaction_id = $this->generate_key('trans_'); |
3696 | 3696 | } |
3697 | 3697 | |
3698 | - if ( ! $this->get_transaction_id() ) { |
|
3699 | - $this->set_transaction_id( $transaction_id ); |
|
3698 | + if (!$this->get_transaction_id()) { |
|
3699 | + $this->set_transaction_id($transaction_id); |
|
3700 | 3700 | } |
3701 | 3701 | |
3702 | - if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) { |
|
3702 | + if ($this->is_paid() && 'wpi-processing' != $this->get_status()) { |
|
3703 | 3703 | return $this->save(); |
3704 | 3704 | } |
3705 | 3705 | |
3706 | 3706 | // Set the completed date. |
3707 | - $this->set_date_completed( current_time( 'mysql' ) ); |
|
3707 | + $this->set_date_completed(current_time('mysql')); |
|
3708 | 3708 | |
3709 | 3709 | // Set the new status. |
3710 | - if ( $this->is_renewal() ) { |
|
3710 | + if ($this->is_renewal()) { |
|
3711 | 3711 | |
3712 | 3712 | $_note = sprintf( |
3713 | - __( 'Renewed via %s', 'invoicing' ), |
|
3714 | - $this->get_gateway_title() . empty( $note ) ? '' : " ($note)" |
|
3713 | + __('Renewed via %s', 'invoicing'), |
|
3714 | + $this->get_gateway_title() . empty($note) ? '' : " ($note)" |
|
3715 | 3715 | ); |
3716 | 3716 | |
3717 | - if ( 'none' == $this->get_gateway() ) { |
|
3717 | + if ('none' == $this->get_gateway()) { |
|
3718 | 3718 | $_note = $note; |
3719 | 3719 | } |
3720 | 3720 | |
3721 | - $this->set_status( 'wpi-renewal', $_note ); |
|
3721 | + $this->set_status('wpi-renewal', $_note); |
|
3722 | 3722 | |
3723 | 3723 | } else { |
3724 | 3724 | |
3725 | 3725 | $_note = sprintf( |
3726 | - __( 'Paid via %s', 'invoicing' ), |
|
3727 | - $this->get_gateway() . empty( $note ) ? '' : " ($note)" |
|
3726 | + __('Paid via %s', 'invoicing'), |
|
3727 | + $this->get_gateway() . empty($note) ? '' : " ($note)" |
|
3728 | 3728 | ); |
3729 | 3729 | |
3730 | - if ( 'none' == $this->get_gateway() ) { |
|
3730 | + if ('none' == $this->get_gateway()) { |
|
3731 | 3731 | $_note = $note; |
3732 | 3732 | } |
3733 | 3733 | |
3734 | - $this->set_status( 'publish',$_note ); |
|
3734 | + $this->set_status('publish', $_note); |
|
3735 | 3735 | |
3736 | 3736 | } |
3737 | 3737 | |
3738 | 3738 | // Set checkout mode. |
3739 | - $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live'; |
|
3740 | - $this->set_mode( $mode ); |
|
3739 | + $mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live'; |
|
3740 | + $this->set_mode($mode); |
|
3741 | 3741 | |
3742 | 3742 | // Save the invoice. |
3743 | 3743 | $this->save(); |
@@ -3763,9 +3763,9 @@ discard block |
||
3763 | 3763 | * Clears the subscription's cache. |
3764 | 3764 | */ |
3765 | 3765 | public function clear_cache() { |
3766 | - wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' ); |
|
3767 | - wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' ); |
|
3768 | - wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' ); |
|
3766 | + wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids'); |
|
3767 | + wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids'); |
|
3768 | + wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids'); |
|
3769 | 3769 | } |
3770 | 3770 | |
3771 | 3771 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Payment form submission fees class |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @param GetPaid_Payment_Form_Submission $submission |
31 | 31 | */ |
32 | - public function __construct( $submission ) { |
|
32 | + public function __construct($submission) { |
|
33 | 33 | |
34 | 34 | // Process any existing invoice fees. |
35 | - if ( $submission->has_invoice() ) { |
|
35 | + if ($submission->has_invoice()) { |
|
36 | 36 | $this->fees = $submission->get_invoice()->get_fees(); |
37 | 37 | } |
38 | 38 | |
@@ -40,14 +40,14 @@ discard block |
||
40 | 40 | $data = $submission->get_data(); |
41 | 41 | $payment_form = $submission->get_payment_form(); |
42 | 42 | |
43 | - foreach ( $payment_form->get_elements() as $element ) { |
|
43 | + foreach ($payment_form->get_elements() as $element) { |
|
44 | 44 | |
45 | - if ( 'price_input' == $element['type'] ) { |
|
46 | - $this->process_price_input( $element, $data ); |
|
45 | + if ('price_input' == $element['type']) { |
|
46 | + $this->process_price_input($element, $data); |
|
47 | 47 | } |
48 | 48 | |
49 | - if ( 'price_select' == $element['type'] ) { |
|
50 | - $this->process_price_select( $element, $data ); |
|
49 | + if ('price_select' == $element['type']) { |
|
50 | + $this->process_price_select($element, $data); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
@@ -60,21 +60,21 @@ discard block |
||
60 | 60 | * @param array $element |
61 | 61 | * @param array $data |
62 | 62 | */ |
63 | - public function process_price_input( $element, $data ) { |
|
63 | + public function process_price_input($element, $data) { |
|
64 | 64 | |
65 | 65 | // Abort if not passed. |
66 | - if ( empty( $data[ $element['id'] ] ) ) { |
|
66 | + if (empty($data[$element['id']])) { |
|
67 | 67 | return; |
68 | 68 | } |
69 | 69 | |
70 | - $amount = (float) wpinv_sanitize_amount( $data[ $element['id'] ] ); |
|
71 | - $minimum = (float) wpinv_sanitize_amount( $element['minimum'] ); |
|
70 | + $amount = (float) wpinv_sanitize_amount($data[$element['id']]); |
|
71 | + $minimum = (float) wpinv_sanitize_amount($element['minimum']); |
|
72 | 72 | |
73 | - if ( $amount < $minimum ) { |
|
74 | - return $this->set_error( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), $minimum ) ); |
|
73 | + if ($amount < $minimum) { |
|
74 | + return $this->set_error(sprintf(__('The minimum allowed amount is %s', 'invoicing'), $minimum)); |
|
75 | 75 | } |
76 | 76 | |
77 | - $this['fees'][ $element['label'] ] = array( |
|
77 | + $this['fees'][$element['label']] = array( |
|
78 | 78 | 'name' => $element['label'], |
79 | 79 | 'initial_fee' => $amount, |
80 | 80 | 'recurring_fee' => 0, |
@@ -88,27 +88,27 @@ discard block |
||
88 | 88 | * @param array $element |
89 | 89 | * @param array $data |
90 | 90 | */ |
91 | - public function process_price_select( $element, $data ) { |
|
91 | + public function process_price_select($element, $data) { |
|
92 | 92 | |
93 | 93 | // Abort if not passed. |
94 | - if ( empty( $data[ $element['id'] ] ) ) { |
|
94 | + if (empty($data[$element['id']])) { |
|
95 | 95 | return; |
96 | 96 | } |
97 | 97 | |
98 | - $options = getpaid_convert_price_string_to_options( $element['options'] ); |
|
99 | - $selected = wpinv_parse_list( $data[ $element['id'] ] ); |
|
98 | + $options = getpaid_convert_price_string_to_options($element['options']); |
|
99 | + $selected = wpinv_parse_list($data[$element['id']]); |
|
100 | 100 | $total = 0; |
101 | 101 | |
102 | - foreach ( $selected as $price ) { |
|
102 | + foreach ($selected as $price) { |
|
103 | 103 | |
104 | - if ( ! isset( $options[ $price ] ) ) { |
|
105 | - return $this->set_error( __( 'You have selected an invalid amount', 'invoicing' ) ); |
|
104 | + if (!isset($options[$price])) { |
|
105 | + return $this->set_error(__('You have selected an invalid amount', 'invoicing')); |
|
106 | 106 | } |
107 | 107 | |
108 | - $total += (float) wpinv_sanitize_amount( $price ); |
|
108 | + $total += (float) wpinv_sanitize_amount($price); |
|
109 | 109 | } |
110 | 110 | |
111 | - $this['fees'][ $element['label'] ] = array( |
|
111 | + $this['fees'][$element['label']] = array( |
|
112 | 112 | 'name' => $element['label'], |
113 | 113 | 'initial_fee' => $total, |
114 | 114 | 'recurring_fee' => 0, |
@@ -121,9 +121,9 @@ discard block |
||
121 | 121 | * |
122 | 122 | * @param string $error |
123 | 123 | */ |
124 | - public function set_error( $error ) { |
|
125 | - if ( empty( $this->fee_error ) ) { |
|
126 | - $this->fee_error = $error; |
|
124 | + public function set_error($error) { |
|
125 | + if (empty($this->fee_error)) { |
|
126 | + $this->fee_error = $error; |
|
127 | 127 | } |
128 | 128 | } |
129 | 129 |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Payment form submission taxes class |
@@ -41,22 +41,22 @@ discard block |
||
41 | 41 | * |
42 | 42 | * @param GetPaid_Payment_Form_Submission $submission |
43 | 43 | */ |
44 | - public function __construct( $submission ) { |
|
44 | + public function __construct($submission) { |
|
45 | 45 | |
46 | 46 | // Make sure that taxes are enabled. |
47 | - if ( ! $submission->use_taxes() ) { |
|
47 | + if (!$submission->use_taxes()) { |
|
48 | 48 | return; |
49 | 49 | } |
50 | 50 | |
51 | 51 | // Validate VAT number. |
52 | - $this->validate_vat( $submission ); |
|
52 | + $this->validate_vat($submission); |
|
53 | 53 | |
54 | - foreach ( $submission->get_items() as $item ) { |
|
55 | - $this->process_item_tax( $item, $submission ); |
|
54 | + foreach ($submission->get_items() as $item) { |
|
55 | + $this->process_item_tax($item, $submission); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | // Process any existing invoice taxes. |
59 | - if ( $submission->has_invoice() ) { |
|
59 | + if ($submission->has_invoice()) { |
|
60 | 60 | $this->taxes = $submission->get_invoice()->get_taxes(); |
61 | 61 | } |
62 | 62 | |
@@ -76,24 +76,24 @@ discard block |
||
76 | 76 | * @param GetPaid_Form_Item $item |
77 | 77 | * @param GetPaid_Payment_Form_Submission $submission |
78 | 78 | */ |
79 | - public function process_item_tax( $item, $submission ) { |
|
79 | + public function process_item_tax($item, $submission) { |
|
80 | 80 | |
81 | 81 | // Abort early if an error occurred. |
82 | - if ( ! empty( $this->tax_error ) ) { |
|
82 | + if (!empty($this->tax_error)) { |
|
83 | 83 | return; |
84 | 84 | } |
85 | 85 | |
86 | - $rate = wpinv_get_tax_rate( $submission->country, $submission->state, $item->get_id() ); |
|
86 | + $rate = wpinv_get_tax_rate($submission->country, $submission->state, $item->get_id()); |
|
87 | 87 | $price = $item->get_sub_total(); |
88 | 88 | $item_tax = $price * $rate * 0.01; |
89 | 89 | |
90 | - if ( wpinv_prices_include_tax() ) { |
|
91 | - $item_tax = $price - ( $price - $price * $rate * 0.01 ); |
|
90 | + if (wpinv_prices_include_tax()) { |
|
91 | + $item_tax = $price - ($price - $price * $rate * 0.01); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | $this->initial_tax += $item_tax; |
95 | 95 | |
96 | - if ( $item->is_recurring() ) { |
|
96 | + if ($item->is_recurring()) { |
|
97 | 97 | $this->recurring_tax += $item_tax; |
98 | 98 | } |
99 | 99 | |
@@ -104,8 +104,8 @@ discard block |
||
104 | 104 | * |
105 | 105 | * @param string $error |
106 | 106 | */ |
107 | - public function set_error( $error ) { |
|
108 | - if ( empty( $this->tax_error ) ) { |
|
107 | + public function set_error($error) { |
|
108 | + if (empty($this->tax_error)) { |
|
109 | 109 | $this->tax_error = $error; |
110 | 110 | } |
111 | 111 | } |
@@ -117,11 +117,11 @@ discard block |
||
117 | 117 | * @since 1.0.19 |
118 | 118 | * @return bool |
119 | 119 | */ |
120 | - public function has_digital_item( $submission ) { |
|
120 | + public function has_digital_item($submission) { |
|
121 | 121 | |
122 | - foreach ( $submission->get_items() as $item ) { |
|
122 | + foreach ($submission->get_items() as $item) { |
|
123 | 123 | |
124 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
124 | + if ('digital' == $item->get_vat_rule()) { |
|
125 | 125 | return true; |
126 | 126 | break; |
127 | 127 | } |
@@ -139,15 +139,15 @@ discard block |
||
139 | 139 | * @since 1.0.19 |
140 | 140 | * @return bool |
141 | 141 | */ |
142 | - public function is_eu_transaction( $submission, $has_digital ) { |
|
142 | + public function is_eu_transaction($submission, $has_digital) { |
|
143 | 143 | |
144 | 144 | // Both from EU. |
145 | - if ( getpaid_is_eu_state( $submission->country ) && ( getpaid_is_eu_state( wpinv_get_default_country() ) || $has_digital ) ) { |
|
145 | + if (getpaid_is_eu_state($submission->country) && (getpaid_is_eu_state(wpinv_get_default_country()) || $has_digital)) { |
|
146 | 146 | return true; |
147 | 147 | } |
148 | 148 | |
149 | 149 | // Both from GST. |
150 | - if ( getpaid_is_gst_country( $submission->country ) && getpaid_is_gst_country( wpinv_get_default_country() ) ) { |
|
150 | + if (getpaid_is_gst_country($submission->country) && getpaid_is_gst_country(wpinv_get_default_country())) { |
|
151 | 151 | return true; |
152 | 152 | } |
153 | 153 | |
@@ -161,13 +161,13 @@ discard block |
||
161 | 161 | * @since 1.0.19 |
162 | 162 | * @return string |
163 | 163 | */ |
164 | - public function get_vat_number( $submission ) { |
|
164 | + public function get_vat_number($submission) { |
|
165 | 165 | |
166 | 166 | $data = $submission->get_data(); |
167 | 167 | |
168 | 168 | // Retrieve from the posted number. |
169 | - if ( ! empty( $data['wpinv_vat_number'] ) ) { |
|
170 | - return wpinv_clean( $data['wpinv_vat_number'] ); |
|
169 | + if (!empty($data['wpinv_vat_number'])) { |
|
170 | + return wpinv_clean($data['wpinv_vat_number']); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | // Retrieve from the invoice. |
@@ -181,13 +181,13 @@ discard block |
||
181 | 181 | * @since 1.0.19 |
182 | 182 | * @return string |
183 | 183 | */ |
184 | - public function get_company( $submission ) { |
|
184 | + public function get_company($submission) { |
|
185 | 185 | |
186 | 186 | $data = $submission->get_data(); |
187 | 187 | |
188 | 188 | // Retrieve from the posted data. |
189 | - if ( ! empty( $data['wpinv_company'] ) ) { |
|
190 | - return wpinv_clean( $data['wpinv_company'] ); |
|
189 | + if (!empty($data['wpinv_company'])) { |
|
190 | + return wpinv_clean($data['wpinv_company']); |
|
191 | 191 | } |
192 | 192 | |
193 | 193 | // Retrieve from the invoice. |
@@ -202,10 +202,10 @@ discard block |
||
202 | 202 | * @since 1.0.19 |
203 | 203 | * @return string |
204 | 204 | */ |
205 | - public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
205 | + public function requires_vat($ip_in_eu, $country_in_eu) { |
|
206 | 206 | |
207 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
208 | - $prevent_b2c = ! empty( $prevent_b2c ); |
|
207 | + $prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase'); |
|
208 | + $prevent_b2c = !empty($prevent_b2c); |
|
209 | 209 | $is_eu = $ip_in_eu || $country_in_eu; |
210 | 210 | |
211 | 211 | return $prevent_b2c && $is_eu; |
@@ -217,30 +217,30 @@ discard block |
||
217 | 217 | * @param GetPaid_Payment_Form_Submission $submission |
218 | 218 | * @since 1.0.19 |
219 | 219 | */ |
220 | - public function validate_vat( $submission ) { |
|
220 | + public function validate_vat($submission) { |
|
221 | 221 | |
222 | - $has_digital = $this->has_digital_item( $submission ); |
|
223 | - $in_eu = $this->is_eu_transaction( $submission, $has_digital ); |
|
222 | + $has_digital = $this->has_digital_item($submission); |
|
223 | + $in_eu = $this->is_eu_transaction($submission, $has_digital); |
|
224 | 224 | |
225 | 225 | // Abort if we are not validating vat numbers. |
226 | - if ( ! $has_digital && ! $in_eu ) { |
|
226 | + if (!$has_digital && !$in_eu) { |
|
227 | 227 | return; |
228 | 228 | } |
229 | 229 | |
230 | 230 | // Prepare variables. |
231 | - $vat_number = $this->get_vat_number( $submission ); |
|
232 | - $company = $this->get_company( $submission ); |
|
231 | + $vat_number = $this->get_vat_number($submission); |
|
232 | + $company = $this->get_company($submission); |
|
233 | 233 | $ip_country = WPInv_EUVat::get_country_by_ip(); |
234 | - $is_eu = getpaid_is_eu_state( $submission->country ); |
|
235 | - $is_ip_eu = getpaid_is_eu_state( $ip_country ); |
|
234 | + $is_eu = getpaid_is_eu_state($submission->country); |
|
235 | + $is_ip_eu = getpaid_is_eu_state($ip_country); |
|
236 | 236 | |
237 | 237 | // If we're preventing business to consumer purchases, ensure |
238 | - if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
238 | + if ($this->requires_vat($is_ip_eu, $is_eu) && empty($vat_number)) { |
|
239 | 239 | |
240 | 240 | // Ensure that a vat number has been specified. |
241 | 241 | return $this->set_error( |
242 | 242 | wp_sprintf( |
243 | - __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ), |
|
243 | + __('Please enter your %s number to verify your purchase is by an EU business.', 'invoicing'), |
|
244 | 244 | getpaid_vat_name() |
245 | 245 | ) |
246 | 246 | ); |
@@ -248,14 +248,14 @@ discard block |
||
248 | 248 | } |
249 | 249 | |
250 | 250 | // Abort if we are not validating vat (vat number should exist, user should be in eu and business too). |
251 | - if ( ! $is_eu || ! $in_eu || empty( $vat_number ) ) { |
|
251 | + if (!$is_eu || !$in_eu || empty($vat_number)) { |
|
252 | 252 | return; |
253 | 253 | } |
254 | 254 | |
255 | - $is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $submission->country ); |
|
255 | + $is_valid = WPInv_EUVat::validate_vat_number($vat_number, $company, $submission->country); |
|
256 | 256 | |
257 | - if ( is_string( $is_valid ) ) { |
|
258 | - $this->set_error( $is_valid ); |
|
257 | + if (is_string($is_valid)) { |
|
258 | + $this->set_error($is_valid); |
|
259 | 259 | } |
260 | 260 | |
261 | 261 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -161,8 +161,8 @@ discard block |
||
161 | 161 | $this->state = wpinv_get_default_state(); |
162 | 162 | |
163 | 163 | // Do we have an actual submission? |
164 | - if ( isset( $_POST['getpaid_payment_form_submission'] ) ) { |
|
165 | - $this->load_data( $_POST ); |
|
164 | + if (isset($_POST['getpaid_payment_form_submission'])) { |
|
165 | + $this->load_data($_POST); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | } |
@@ -172,29 +172,29 @@ discard block |
||
172 | 172 | * |
173 | 173 | * @param array $data |
174 | 174 | */ |
175 | - public function load_data( $data ) { |
|
175 | + public function load_data($data) { |
|
176 | 176 | |
177 | 177 | // Prepare submitted data... |
178 | - $data = wp_unslash( $data ); |
|
178 | + $data = wp_unslash($data); |
|
179 | 179 | |
180 | 180 | // Filter the data. |
181 | - $data = apply_filters( 'getpaid_submission_data', $data, $this ); |
|
181 | + $data = apply_filters('getpaid_submission_data', $data, $this); |
|
182 | 182 | |
183 | 183 | $this->data = $data; |
184 | 184 | |
185 | - $this->id = md5( wp_json_encode( $data ) ); |
|
185 | + $this->id = md5(wp_json_encode($data)); |
|
186 | 186 | |
187 | 187 | // Every submission needs an active payment form. |
188 | - if ( empty( $data['form_id'] ) ) { |
|
189 | - $this->last_error = __( 'Missing payment form', 'invoicing' ); |
|
188 | + if (empty($data['form_id'])) { |
|
189 | + $this->last_error = __('Missing payment form', 'invoicing'); |
|
190 | 190 | return; |
191 | 191 | } |
192 | 192 | |
193 | 193 | // Fetch the payment form. |
194 | - $form = new GetPaid_Payment_Form( $data['form_id'] ); |
|
194 | + $form = new GetPaid_Payment_Form($data['form_id']); |
|
195 | 195 | |
196 | - if ( ! $form->is_active() ) { |
|
197 | - $this->last_error = __( 'Payment form not active', 'invoicing' ); |
|
196 | + if (!$form->is_active()) { |
|
197 | + $this->last_error = __('Payment form not active', 'invoicing'); |
|
198 | 198 | return; |
199 | 199 | } |
200 | 200 | |
@@ -202,83 +202,83 @@ discard block |
||
202 | 202 | $this->payment_form = $form; |
203 | 203 | |
204 | 204 | // For existing invoices, make sure that it is valid. |
205 | - if ( ! empty( $data['invoice_id'] ) ) { |
|
206 | - $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
|
205 | + if (!empty($data['invoice_id'])) { |
|
206 | + $invoice = wpinv_get_invoice($data['invoice_id']); |
|
207 | 207 | |
208 | - if ( empty( $invoice ) ) { |
|
209 | - $this->last_error = __( 'Invalid invoice', 'invoicing' ); |
|
208 | + if (empty($invoice)) { |
|
209 | + $this->last_error = __('Invalid invoice', 'invoicing'); |
|
210 | 210 | return; |
211 | 211 | } |
212 | 212 | |
213 | - if ( $invoice->is_paid() ) { |
|
214 | - $this->last_error = __( 'This invoice is already paid for.', 'invoicing' ); |
|
213 | + if ($invoice->is_paid()) { |
|
214 | + $this->last_error = __('This invoice is already paid for.', 'invoicing'); |
|
215 | 215 | return; |
216 | 216 | } |
217 | 217 | |
218 | - $this->payment_form->set_items( $invoice->get_items() ); |
|
218 | + $this->payment_form->set_items($invoice->get_items()); |
|
219 | 219 | |
220 | 220 | $this->country = $invoice->get_country(); |
221 | 221 | $this->state = $invoice->get_state(); |
222 | 222 | $this->invoice = $invoice; |
223 | 223 | |
224 | 224 | // Default forms do not have items. |
225 | - } else if ( $form->is_default() && isset( $data['getpaid-items'] ) ) { |
|
226 | - $this->payment_form->set_items( wpinv_clean( $data['getpaid-items'] ) ); |
|
225 | + } else if ($form->is_default() && isset($data['getpaid-items'])) { |
|
226 | + $this->payment_form->set_items(wpinv_clean($data['getpaid-items'])); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | // User's country. |
230 | - if ( ! empty( $data['wpinv_country'] ) ) { |
|
230 | + if (!empty($data['wpinv_country'])) { |
|
231 | 231 | $this->country = $data['wpinv_country']; |
232 | 232 | } |
233 | 233 | |
234 | 234 | // User's state. |
235 | - if ( ! empty( $data['wpinv_state'] ) ) { |
|
235 | + if (!empty($data['wpinv_state'])) { |
|
236 | 236 | $this->country = $data['wpinv_state']; |
237 | 237 | } |
238 | 238 | |
239 | 239 | // Handle items. |
240 | 240 | $selected_items = array(); |
241 | - if ( ! empty( $data['getpaid-items'] ) ) { |
|
242 | - $selected_items = wpinv_clean( $data['getpaid-items'] ); |
|
241 | + if (!empty($data['getpaid-items'])) { |
|
242 | + $selected_items = wpinv_clean($data['getpaid-items']); |
|
243 | 243 | } |
244 | 244 | |
245 | - foreach ( $this->payment_form->get_items() as $item ) { |
|
245 | + foreach ($this->payment_form->get_items() as $item) { |
|
246 | 246 | |
247 | 247 | // Continue if this is an optional item and it has not been selected. |
248 | - if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) { |
|
248 | + if (!$item->is_required() && !isset($selected_items[$item->get_id()])) { |
|
249 | 249 | continue; |
250 | 250 | } |
251 | 251 | |
252 | 252 | // (maybe) let customers change the quantities and prices. |
253 | - if ( isset( $selected_items[ $item->get_id() ] ) ) { |
|
253 | + if (isset($selected_items[$item->get_id()])) { |
|
254 | 254 | |
255 | 255 | // Maybe change the quantities. |
256 | - if ( $item->allows_quantities() && is_numeric( $selected_items[ $item->get_id() ]['quantity'] ) ) { |
|
257 | - $item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] ); |
|
256 | + if ($item->allows_quantities() && is_numeric($selected_items[$item->get_id()]['quantity'])) { |
|
257 | + $item->set_quantity((int) $selected_items[$item->get_id()]['quantity']); |
|
258 | 258 | } |
259 | 259 | |
260 | 260 | // Maybe change the price. |
261 | - if ( $item->user_can_set_their_price() ) { |
|
262 | - $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] ); |
|
261 | + if ($item->user_can_set_their_price()) { |
|
262 | + $price = (float) wpinv_sanitize_amount($selected_items[$item->get_id()]['price']); |
|
263 | 263 | |
264 | 264 | // But don't get lower than the minimum price. |
265 | - if ( $price < $item->get_minimum_price() ) { |
|
265 | + if ($price < $item->get_minimum_price()) { |
|
266 | 266 | $price = $item->get_minimum_price(); |
267 | 267 | } |
268 | 268 | |
269 | - $item->set_price( $price ); |
|
269 | + $item->set_price($price); |
|
270 | 270 | |
271 | 271 | } |
272 | 272 | |
273 | 273 | } |
274 | 274 | |
275 | 275 | // Add the item to the form. |
276 | - $this->add_item( $item ); |
|
276 | + $this->add_item($item); |
|
277 | 277 | |
278 | 278 | } |
279 | 279 | |
280 | 280 | // Fired when we are done processing a submission. |
281 | - do_action_ref_array( 'getpaid_process_submission', array( &$this ) ); |
|
281 | + do_action_ref_array('getpaid_process_submission', array(&$this)); |
|
282 | 282 | |
283 | 283 | // Handle discounts. |
284 | 284 | $this->process_discount(); |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | * @return bool |
313 | 313 | */ |
314 | 314 | public function has_invoice() { |
315 | - return ! empty( $this->invoice ); |
|
315 | + return !empty($this->invoice); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -322,7 +322,7 @@ discard block |
||
322 | 322 | * @return string |
323 | 323 | */ |
324 | 324 | public function get_currency() { |
325 | - if ( $this->has_invoice() ) { |
|
325 | + if ($this->has_invoice()) { |
|
326 | 326 | return $this->invoice->get_currency(); |
327 | 327 | } |
328 | 328 | return wpinv_get_currency(); |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | * |
344 | 344 | * @since 1.0.19 |
345 | 345 | */ |
346 | - public function is_required_field_set( $field ) { |
|
347 | - return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] ); |
|
346 | + public function is_required_field_set($field) { |
|
347 | + return empty($field['required']) || !empty($this->data[$field['id']]); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | ///////// Items ////////////// |
@@ -355,25 +355,25 @@ discard block |
||
355 | 355 | * @since 1.0.19 |
356 | 356 | * @param GetPaid_Form_Item $item |
357 | 357 | */ |
358 | - public function add_item( $item ) { |
|
358 | + public function add_item($item) { |
|
359 | 359 | |
360 | 360 | // Make sure that it is available for purchase. |
361 | - if ( ! $item->can_purchase() ) { |
|
361 | + if (!$item->can_purchase()) { |
|
362 | 362 | return; |
363 | 363 | } |
364 | 364 | |
365 | 365 | // Do we have a recurring item? |
366 | - if ( $item->is_recurring() ) { |
|
366 | + if ($item->is_recurring()) { |
|
367 | 367 | |
368 | - if ( $this->has_recurring ) { |
|
369 | - $this->last_error = __( 'You can only buy one recurring item at a time.', 'invoicing' ); |
|
368 | + if ($this->has_recurring) { |
|
369 | + $this->last_error = __('You can only buy one recurring item at a time.', 'invoicing'); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | $this->has_recurring = true; |
373 | 373 | |
374 | 374 | } |
375 | 375 | |
376 | - $this->items[ $item->get_id() ] = $item; |
|
376 | + $this->items[$item->get_id()] = $item; |
|
377 | 377 | |
378 | 378 | $this->subtotal_amount += $item->get_sub_total(); |
379 | 379 | |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | * |
385 | 385 | * @since 1.0.19 |
386 | 386 | */ |
387 | - public function get_item( $item_id ) { |
|
388 | - return isset( $this->items[ $item_id ] ) ? $this->items[ $item_id ] : null; |
|
387 | + public function get_item($item_id) { |
|
388 | + return isset($this->items[$item_id]) ? $this->items[$item_id] : null; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | /** |
@@ -414,18 +414,18 @@ discard block |
||
414 | 414 | */ |
415 | 415 | public function process_taxes() { |
416 | 416 | |
417 | - $tax_processor = new GetPaid_Payment_Form_Submission_Taxes( $this ); |
|
417 | + $tax_processor = new GetPaid_Payment_Form_Submission_Taxes($this); |
|
418 | 418 | |
419 | - if ( ! empty( $tax_processor->tax_error) ) { |
|
419 | + if (!empty($tax_processor->tax_error)) { |
|
420 | 420 | $this->last_error = $tax_processor->tax_error; |
421 | 421 | return; |
422 | 422 | } |
423 | 423 | |
424 | - foreach ( $tax_processor->taxes as $tax ) { |
|
425 | - $this->add_tax( $tax ); |
|
424 | + foreach ($tax_processor->taxes as $tax) { |
|
425 | + $this->add_tax($tax); |
|
426 | 426 | } |
427 | 427 | |
428 | - do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) ); |
|
428 | + do_action_ref_array('getpaid_submissions_process_taxes', array(&$this)); |
|
429 | 429 | } |
430 | 430 | |
431 | 431 | /** |
@@ -434,11 +434,11 @@ discard block |
||
434 | 434 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
435 | 435 | * @since 1.0.19 |
436 | 436 | */ |
437 | - public function add_tax( $tax ) { |
|
437 | + public function add_tax($tax) { |
|
438 | 438 | |
439 | - $this->total_tax_amount += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
440 | - $this->total_recurring_tax_amount += wpinv_sanitize_amount( $tax['recurring_tax'] ); |
|
441 | - $this->taxes[ $tax['name'] ] = $tax; |
|
439 | + $this->total_tax_amount += wpinv_sanitize_amount($tax['initial_tax']); |
|
440 | + $this->total_recurring_tax_amount += wpinv_sanitize_amount($tax['recurring_tax']); |
|
441 | + $this->taxes[$tax['name']] = $tax; |
|
442 | 442 | |
443 | 443 | } |
444 | 444 | |
@@ -451,11 +451,11 @@ discard block |
||
451 | 451 | |
452 | 452 | $use_taxes = wpinv_use_taxes(); |
453 | 453 | |
454 | - if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) { |
|
454 | + if ($this->has_invoice() && !$this->invoice->is_taxable()) { |
|
455 | 455 | $use_taxes = false; |
456 | 456 | } |
457 | 457 | |
458 | - return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this ); |
|
458 | + return apply_filters('getpaid_submission_use_taxes', $use_taxes, $this); |
|
459 | 459 | |
460 | 460 | } |
461 | 461 | |
@@ -503,28 +503,28 @@ discard block |
||
503 | 503 | public function process_discount() { |
504 | 504 | |
505 | 505 | $total = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax(); |
506 | - $discount_handler = new GetPaid_Payment_Form_Submission_Discount( $this, $total ); |
|
506 | + $discount_handler = new GetPaid_Payment_Form_Submission_Discount($this, $total); |
|
507 | 507 | |
508 | - if ( ! $discount_handler->is_discount_valid ) { |
|
508 | + if (!$discount_handler->is_discount_valid) { |
|
509 | 509 | $this->last_error = $discount_handler->discount_error; |
510 | 510 | return; |
511 | 511 | } |
512 | 512 | |
513 | 513 | // Process any existing invoice discounts. |
514 | - if ( $this->has_invoice() ) { |
|
514 | + if ($this->has_invoice()) { |
|
515 | 515 | $discounts = $this->get_invoice()->get_discounts(); |
516 | 516 | |
517 | - foreach ( $discounts as $discount ) { |
|
518 | - $this->add_discount( $discount ); |
|
517 | + foreach ($discounts as $discount) { |
|
518 | + $this->add_discount($discount); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | } |
522 | 522 | |
523 | - if ( $discount_handler->has_discount ) { |
|
524 | - $this->add_discount( $discount_handler->calculate_discount( $this ) ); |
|
523 | + if ($discount_handler->has_discount) { |
|
524 | + $this->add_discount($discount_handler->calculate_discount($this)); |
|
525 | 525 | } |
526 | 526 | |
527 | - do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) ); |
|
527 | + do_action_ref_array('getpaid_submissions_process_discounts', array(&$this)); |
|
528 | 528 | } |
529 | 529 | |
530 | 530 | /** |
@@ -533,11 +533,11 @@ discard block |
||
533 | 533 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
534 | 534 | * @since 1.0.19 |
535 | 535 | */ |
536 | - public function add_discount( $discount ) { |
|
536 | + public function add_discount($discount) { |
|
537 | 537 | |
538 | - $this->total_discount_amount += wpinv_sanitize_amount( $discount['initial_discount'] ); |
|
539 | - $this->total_recurring_discount_amount += wpinv_sanitize_amount( $discount['recurring_discount'] ); |
|
540 | - $this->discounts[ $discount['name'] ] = $discount; |
|
538 | + $this->total_discount_amount += wpinv_sanitize_amount($discount['initial_discount']); |
|
539 | + $this->total_recurring_discount_amount += wpinv_sanitize_amount($discount['recurring_discount']); |
|
540 | + $this->discounts[$discount['name']] = $discount; |
|
541 | 541 | |
542 | 542 | } |
543 | 543 | |
@@ -546,13 +546,13 @@ discard block |
||
546 | 546 | * |
547 | 547 | * @since 1.0.19 |
548 | 548 | */ |
549 | - public function remove_discount( $name ) { |
|
549 | + public function remove_discount($name) { |
|
550 | 550 | |
551 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
552 | - $discount = $this->discounts[ $name ]; |
|
551 | + if (isset($this->discounts[$name])) { |
|
552 | + $discount = $this->discounts[$name]; |
|
553 | 553 | $this->total_discount_amount -= $discount['initial_discount']; |
554 | 554 | $this->total_recurring_discount_amount -= $discount['recurring_discount']; |
555 | - unset( $this->discounts[ $name ] ); |
|
555 | + unset($this->discounts[$name]); |
|
556 | 556 | } |
557 | 557 | |
558 | 558 | } |
@@ -564,7 +564,7 @@ discard block |
||
564 | 564 | * @return bool |
565 | 565 | */ |
566 | 566 | public function has_discount_code() { |
567 | - return ! empty( $this->discounts['discount_code'] ); |
|
567 | + return !empty($this->discounts['discount_code']); |
|
568 | 568 | } |
569 | 569 | |
570 | 570 | /** |
@@ -621,18 +621,18 @@ discard block |
||
621 | 621 | */ |
622 | 622 | public function process_fees() { |
623 | 623 | |
624 | - $fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this ); |
|
624 | + $fees_processor = new GetPaid_Payment_Form_Submission_Fees($this); |
|
625 | 625 | |
626 | - if ( ! empty( $fees_processor->fee_error) ) { |
|
626 | + if (!empty($fees_processor->fee_error)) { |
|
627 | 627 | $this->last_error = $fees_processor->fee_error; |
628 | 628 | return; |
629 | 629 | } |
630 | 630 | |
631 | - foreach ( $fees_processor->fees as $fee ) { |
|
632 | - $this->add_fee( $fee ); |
|
631 | + foreach ($fees_processor->fees as $fee) { |
|
632 | + $this->add_fee($fee); |
|
633 | 633 | } |
634 | 634 | |
635 | - do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) ); |
|
635 | + do_action_ref_array('getpaid_submissions_process_fees', array(&$this)); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | /** |
@@ -641,11 +641,11 @@ discard block |
||
641 | 641 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
642 | 642 | * @since 1.0.19 |
643 | 643 | */ |
644 | - public function add_fee( $fee ) { |
|
644 | + public function add_fee($fee) { |
|
645 | 645 | |
646 | - $this->total_fees_amount += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
647 | - $this->total_recurring_fees_amount += wpinv_sanitize_amount( $fee['recurring_fee'] ); |
|
648 | - $this->fees[ $fee['name'] ] = $fee; |
|
646 | + $this->total_fees_amount += wpinv_sanitize_amount($fee['initial_fee']); |
|
647 | + $this->total_recurring_fees_amount += wpinv_sanitize_amount($fee['recurring_fee']); |
|
648 | + $this->fees[$fee['name']] = $fee; |
|
649 | 649 | |
650 | 650 | } |
651 | 651 | |
@@ -654,13 +654,13 @@ discard block |
||
654 | 654 | * |
655 | 655 | * @since 1.0.19 |
656 | 656 | */ |
657 | - public function remove_fee( $name ) { |
|
657 | + public function remove_fee($name) { |
|
658 | 658 | |
659 | - if ( isset( $this->fees[ $name ] ) ) { |
|
660 | - $fee = $this->fees[ $name ]; |
|
659 | + if (isset($this->fees[$name])) { |
|
660 | + $fee = $this->fees[$name]; |
|
661 | 661 | $this->total_fees_amount -= $fee['initial_fee']; |
662 | 662 | $this->total_recurring_fees_amount -= $fee['recurring_fee']; |
663 | - unset( $this->fees[ $name ] ); |
|
663 | + unset($this->fees[$name]); |
|
664 | 664 | } |
665 | 665 | |
666 | 666 | } |
@@ -701,8 +701,8 @@ discard block |
||
701 | 701 | */ |
702 | 702 | public function get_total() { |
703 | 703 | $total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax(); |
704 | - $total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this ); |
|
705 | - return wpinv_sanitize_amount( $total ); |
|
704 | + $total = apply_filters('getpaid_get_submission_total_amount', $total, $this); |
|
705 | + return wpinv_sanitize_amount($total); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | /** |
@@ -713,11 +713,11 @@ discard block |
||
713 | 713 | public function get_payment_details() { |
714 | 714 | $collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax(); |
715 | 715 | |
716 | - if ( $this->has_recurring ) { |
|
716 | + if ($this->has_recurring) { |
|
717 | 717 | $collect = true; |
718 | 718 | } |
719 | 719 | |
720 | - $collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this ); |
|
720 | + $collect = apply_filters('getpaid_submission_collect_payment_details', $collect, $this); |
|
721 | 721 | return $collect; |
722 | 722 | } |
723 | 723 | |
@@ -727,8 +727,8 @@ discard block |
||
727 | 727 | * @since 1.0.19 |
728 | 728 | */ |
729 | 729 | public function get_billing_email() { |
730 | - $billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email']; |
|
731 | - return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this ); |
|
730 | + $billing_email = empty($this->data['billing_email']) ? '' : $this->data['billing_email']; |
|
731 | + return apply_filters('getpaid_get_submission_billing_email', $billing_email, $this); |
|
732 | 732 | } |
733 | 733 | |
734 | 734 | /** |
@@ -738,7 +738,7 @@ discard block |
||
738 | 738 | */ |
739 | 739 | public function has_billing_email() { |
740 | 740 | $billing_email = $this->get_billing_email(); |
741 | - return ! empty( $billing_email ); |
|
741 | + return !empty($billing_email); |
|
742 | 742 | } |
743 | 743 | |
744 | 744 | } |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Payment form submission discount class |
@@ -42,13 +42,13 @@ discard block |
||
42 | 42 | * @param GetPaid_Payment_Form_Submission $submission |
43 | 43 | * @param float $amount |
44 | 44 | */ |
45 | - public function __construct( $submission, $amount ) { |
|
45 | + public function __construct($submission, $amount) { |
|
46 | 46 | |
47 | 47 | // Do we have a discount? |
48 | 48 | $submission_data = $submission->get_data(); |
49 | - if ( ! empty( $submission_data['discount'] ) ) { |
|
49 | + if (!empty($submission_data['discount'])) { |
|
50 | 50 | $this->has_discount = true; |
51 | - $this->pre_process_discount( $submission, $submission_data['discount'], $amount ); |
|
51 | + $this->pre_process_discount($submission, $submission_data['discount'], $amount); |
|
52 | 52 | } |
53 | 53 | |
54 | 54 | } |
@@ -60,26 +60,26 @@ discard block |
||
60 | 60 | * @param string $discount |
61 | 61 | * @param float $amount |
62 | 62 | */ |
63 | - public function pre_process_discount( $submission, $discount, $amount ) { |
|
63 | + public function pre_process_discount($submission, $discount, $amount) { |
|
64 | 64 | |
65 | 65 | // Fetch the discount. |
66 | - $this->discount = new WPInv_Discount( $discount ); |
|
66 | + $this->discount = new WPInv_Discount($discount); |
|
67 | 67 | |
68 | 68 | // Ensure it is active. |
69 | - if ( ! $this->is_discount_active( $this->discount ) ) { |
|
70 | - return $this->set_error( __( 'Invalid or expired discount code', 'invoicing' ) ); |
|
69 | + if (!$this->is_discount_active($this->discount)) { |
|
70 | + return $this->set_error(__('Invalid or expired discount code', 'invoicing')); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | // Exceeded limit. |
74 | - if ( $this->discount->has_exceeded_limit() ) { |
|
75 | - return $this->set_error( __( 'This discount code has been used up', 'invoicing' ) ); |
|
74 | + if ($this->discount->has_exceeded_limit()) { |
|
75 | + return $this->set_error(__('This discount code has been used up', 'invoicing')); |
|
76 | 76 | } |
77 | 77 | |
78 | 78 | // Validate usages. |
79 | - $this->validate_single_use_discount( $submission, $this->discount ); |
|
79 | + $this->validate_single_use_discount($submission, $this->discount); |
|
80 | 80 | |
81 | 81 | // Validate amount. |
82 | - $this->validate_discount_amount( $submission, $this->discount, $amount ); |
|
82 | + $this->validate_discount_amount($submission, $this->discount, $amount); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -88,8 +88,8 @@ discard block |
||
88 | 88 | * @param WPInv_Discount $discount |
89 | 89 | * @return bool |
90 | 90 | */ |
91 | - public function is_discount_active( $discount ) { |
|
92 | - return $discount->exists() && $discount->is_active() && $discount->has_started() && ! $discount->is_expired(); |
|
91 | + public function is_discount_active($discount) { |
|
92 | + return $discount->exists() && $discount->is_active() && $discount->has_started() && !$discount->is_expired(); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | * |
98 | 98 | * @param string $error |
99 | 99 | */ |
100 | - public function set_error( $error ) { |
|
101 | - if ( $this->is_discount_valid ) { |
|
100 | + public function set_error($error) { |
|
101 | + if ($this->is_discount_valid) { |
|
102 | 102 | $this->is_discount_valid = false; |
103 | 103 | $this->discount_error = $error; |
104 | 104 | } |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | * @param string $email |
111 | 111 | * @return int|string|false |
112 | 112 | */ |
113 | - public function get_user_id_or_email( $email ) { |
|
113 | + public function get_user_id_or_email($email) { |
|
114 | 114 | |
115 | - if ( is_user_logged_in() ) { |
|
115 | + if (is_user_logged_in()) { |
|
116 | 116 | return get_current_user_id(); |
117 | 117 | } |
118 | 118 | |
119 | - return empty( $email ) ? false : sanitize_email( $email ); |
|
119 | + return empty($email) ? false : sanitize_email($email); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -125,22 +125,22 @@ discard block |
||
125 | 125 | * @param GetPaid_Payment_Form_Submission $submission |
126 | 126 | * @param WPInv_Discount $discount |
127 | 127 | */ |
128 | - public function validate_single_use_discount( $submission, $discount ) { |
|
128 | + public function validate_single_use_discount($submission, $discount) { |
|
129 | 129 | |
130 | 130 | // Abort if it is not a single use discount. |
131 | - if ( ! $discount->is_single_use() ) { |
|
131 | + if (!$discount->is_single_use()) { |
|
132 | 132 | return; |
133 | 133 | } |
134 | 134 | |
135 | 135 | // Ensure there is a valid billing email. |
136 | - $user = $this->get_user_id_or_email( $submission->get_billing_email() ); |
|
137 | - if ( ! empty( $user ) ) { |
|
138 | - $this->set_error( __( 'You need to either log in or enter your billing email before applying this discount', 'invoicing' ) ); |
|
136 | + $user = $this->get_user_id_or_email($submission->get_billing_email()); |
|
137 | + if (!empty($user)) { |
|
138 | + $this->set_error(__('You need to either log in or enter your billing email before applying this discount', 'invoicing')); |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | // Has the user used this discount code before? |
142 | - if ( ! $discount->is_valid_for_user( $user ) ) { |
|
143 | - return $this->set_error( __( 'You have already used this discount', 'invoicing' ) ); |
|
142 | + if (!$discount->is_valid_for_user($user)) { |
|
143 | + return $this->set_error(__('You have already used this discount', 'invoicing')); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | } |
@@ -152,18 +152,18 @@ discard block |
||
152 | 152 | * @param WPInv_Discount $discount |
153 | 153 | * @param float $amount |
154 | 154 | */ |
155 | - public function validate_discount_amount( $submission, $discount, $amount ) { |
|
155 | + public function validate_discount_amount($submission, $discount, $amount) { |
|
156 | 156 | |
157 | 157 | // Validate minimum amount. |
158 | - if ( ! $discount->is_minimum_amount_met( $amount ) ) { |
|
159 | - $min = wpinv_price( $discount->get_minimum_total(), $submission->get_currency() ); |
|
160 | - return $this->set_error( sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ) ); |
|
158 | + if (!$discount->is_minimum_amount_met($amount)) { |
|
159 | + $min = wpinv_price($discount->get_minimum_total(), $submission->get_currency()); |
|
160 | + return $this->set_error(sprintf(__('The minimum total for using this discount is %s', 'invoicing'), $min)); |
|
161 | 161 | } |
162 | 162 | |
163 | 163 | // Validate the maximum amount. |
164 | - if ( ! $discount->is_maximum_amount_met( $amount ) ) { |
|
165 | - $max = wpinv_price( $discount->get_maximum_total(), $submission->get_currency() ); |
|
166 | - return $this->set_error( sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ) ); |
|
164 | + if (!$discount->is_maximum_amount_met($amount)) { |
|
165 | + $max = wpinv_price($discount->get_maximum_total(), $submission->get_currency()); |
|
166 | + return $this->set_error(sprintf(__('The maximum total for using this discount is %s', 'invoicing'), $max)); |
|
167 | 167 | } |
168 | 168 | |
169 | 169 | } |
@@ -176,24 +176,24 @@ discard block |
||
176 | 176 | * @param GetPaid_Payment_Form_Submission $submission |
177 | 177 | * @return array |
178 | 178 | */ |
179 | - public function calculate_discount( $submission ) { |
|
179 | + public function calculate_discount($submission) { |
|
180 | 180 | |
181 | 181 | $initial_discount = 0; |
182 | 182 | $recurring_discount = 0; |
183 | 183 | |
184 | - foreach ( $submission->get_items() as $item ) { |
|
184 | + foreach ($submission->get_items() as $item) { |
|
185 | 185 | |
186 | 186 | // Abort if it is not valid for this item. |
187 | - if ( ! $this->discount->is_valid_for_items( array( $item->get_id() ) ) ) { |
|
187 | + if (!$this->discount->is_valid_for_items(array($item->get_id()))) { |
|
188 | 188 | continue; |
189 | 189 | } |
190 | 190 | |
191 | 191 | // Calculate the initial amount... |
192 | - $initial_discount += $this->discount->get_discounted_amount( $item->get_initial_price() * $item->get_quantity() ); |
|
192 | + $initial_discount += $this->discount->get_discounted_amount($item->get_initial_price() * $item->get_quantity()); |
|
193 | 193 | |
194 | 194 | // ... and maybe the recurring amount. |
195 | - if ( $item->is_recurring() && $this->discount->is_recurring() ) { |
|
196 | - $recurring_discount += $this->discount->get_discounted_amount( $item->get_recurring_price() * $item->get_quantity() ); |
|
195 | + if ($item->is_recurring() && $this->discount->is_recurring()) { |
|
196 | + $recurring_discount += $this->discount->get_discounted_amount($item->get_recurring_price() * $item->get_quantity()); |
|
197 | 197 | } |
198 | 198 | |
199 | 199 | } |