Passed
Push — master ( fd42df...51f4f8 )
by Brian
05:05
created
includes/gateways/class-getpaid-authorize-net-gateway.php 2 patches
Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -13,58 +13,58 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Authorize_Net_Gateway extends GetPaid_Authorize_Net_Legacy_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'authorizenet';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array( 'subscription', 'sandbox', 'tokens', 'addons' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34 34
     public $order = 4;
35 35
 
36 36
     /**
37
-	 * Endpoint for requests from Authorize.net.
38
-	 *
39
-	 * @var string
40
-	 */
41
-	protected $notify_url;
42
-
43
-	/**
44
-	 * Endpoint for requests to Authorize.net.
45
-	 *
46
-	 * @var string
47
-	 */
37
+     * Endpoint for requests from Authorize.net.
38
+     *
39
+     * @var string
40
+     */
41
+    protected $notify_url;
42
+
43
+    /**
44
+     * Endpoint for requests to Authorize.net.
45
+     *
46
+     * @var string
47
+     */
48 48
     protected $endpoint;
49 49
 
50 50
     /**
51
-	 * Currencies this gateway is allowed for.
52
-	 *
53
-	 * @var array
54
-	 */
55
-	public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' );
51
+     * Currencies this gateway is allowed for.
52
+     *
53
+     * @var array
54
+     */
55
+    public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' );
56 56
 
57 57
     /**
58
-	 * URL to view a transaction.
59
-	 *
60
-	 * @var string
61
-	 */
58
+     * URL to view a transaction.
59
+     *
60
+     * @var string
61
+     */
62 62
     public $view_transaction_url = 'https://{sandbox}authorize.net/ui/themes/sandbox/Transaction/TransactionReceipt.aspx?transid=%s';
63 63
 
64 64
     /**
65
-	 * Class constructor.
66
-	 */
67
-	public function __construct() {
65
+     * Class constructor.
66
+     */
67
+    public function __construct() {
68 68
 
69 69
         $this->title                = __( 'Credit Card / Debit Card', 'invoicing' );
70 70
         $this->method_title         = __( 'Authorize.Net', 'invoicing' );
@@ -76,11 +76,11 @@  discard block
 block discarded – undo
76 76
     }
77 77
 
78 78
     /**
79
-	 * Displays the payment method select field.
80
-	 *
81
-	 * @param int $invoice_id 0 or invoice id.
82
-	 * @param GetPaid_Payment_Form $form Current payment form.
83
-	 */
79
+     * Displays the payment method select field.
80
+     *
81
+     * @param int $invoice_id 0 or invoice id.
82
+     * @param GetPaid_Payment_Form $form Current payment form.
83
+     */
84 84
     public function payment_fields( $invoice_id, $form ) {
85 85
 
86 86
         // Let the user select a payment method.
@@ -91,16 +91,16 @@  discard block
 block discarded – undo
91 91
     }
92 92
 
93 93
     /**
94
-	 * Creates a customer profile.
95
-	 *
96
-	 *
97
-	 * @param WPInv_Invoice $invoice Invoice.
94
+     * Creates a customer profile.
95
+     *
96
+     *
97
+     * @param WPInv_Invoice $invoice Invoice.
98 98
      * @param array $submission_data Posted checkout fields.
99 99
      * @param bool $save Whether or not to save the payment as a token.
100 100
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
101
-	 * @return string|WP_Error Payment profile id.
102
-	 */
103
-	public function create_customer_profile( $invoice, $submission_data, $save = true ) {
101
+     * @return string|WP_Error Payment profile id.
102
+     */
103
+    public function create_customer_profile( $invoice, $submission_data, $save = true ) {
104 104
 
105 105
         // Remove non-digits from the number
106 106
         $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] );
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
     }
168 168
 
169 169
     /**
170
-	 * Retrieves a customer profile.
171
-	 *
172
-	 *
173
-	 * @param string $profile_id profile id.
174
-	 * @return string|WP_Error Profile id.
170
+     * Retrieves a customer profile.
171
+     *
172
+     *
173
+     * @param string $profile_id profile id.
174
+     * @return string|WP_Error Profile id.
175 175
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile
176
-	 */
177
-	public function get_customer_profile( $profile_id ) {
176
+     */
177
+    public function get_customer_profile( $profile_id ) {
178 178
 
179 179
         // Generate args.
180 180
         $args = array(
@@ -189,17 +189,17 @@  discard block
 block discarded – undo
189 189
     }
190 190
 
191 191
     /**
192
-	 * Creates a customer profile.
193
-	 *
194
-	 *
192
+     * Creates a customer profile.
193
+     *
194
+     *
195 195
      * @param string $profile_id profile id.
196
-	 * @param WPInv_Invoice $invoice Invoice.
196
+     * @param WPInv_Invoice $invoice Invoice.
197 197
      * @param array $submission_data Posted checkout fields.
198 198
      * @param bool $save Whether or not to save the payment as a token.
199 199
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
200
-	 * @return string|WP_Error Profile id.
201
-	 */
202
-	public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
200
+     * @return string|WP_Error Profile id.
201
+     */
202
+    public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
203 203
 
204 204
         // Remove non-digits from the number
205 205
         $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] );
@@ -259,15 +259,15 @@  discard block
 block discarded – undo
259 259
     }
260 260
 
261 261
     /**
262
-	 * Retrieves a customer payment profile.
263
-	 *
264
-	 *
265
-	 * @param string $customer_profile_id customer profile id.
262
+     * Retrieves a customer payment profile.
263
+     *
264
+     *
265
+     * @param string $customer_profile_id customer profile id.
266 266
      * @param string $payment_profile_id payment profile id.
267
-	 * @return string|WP_Error Profile id.
267
+     * @return string|WP_Error Profile id.
268 268
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile
269
-	 */
270
-	public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
269
+     */
270
+    public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
271 271
 
272 272
         // Generate args.
273 273
         $args = array(
@@ -283,15 +283,15 @@  discard block
 block discarded – undo
283 283
     }
284 284
 
285 285
     /**
286
-	 * Charges a customer payment profile.
287
-	 *
286
+     * Charges a customer payment profile.
287
+     *
288 288
      * @param string $customer_profile_id customer profile id.
289 289
      * @param string $payment_profile_id payment profile id.
290
-	 * @param WPInv_Invoice $invoice Invoice.
290
+     * @param WPInv_Invoice $invoice Invoice.
291 291
      * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile
292
-	 * @return WP_Error|object
293
-	 */
294
-	public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
292
+     * @return WP_Error|object
293
+     */
294
+    public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
295 295
 
296 296
         // Generate args.
297 297
         $args = array(
@@ -337,41 +337,41 @@  discard block
 block discarded – undo
337 337
     }
338 338
 
339 339
     /**
340
-	 * Processes a customer charge.
341
-	 *
340
+     * Processes a customer charge.
341
+     *
342 342
      * @param stdClass $result Api response.
343
-	 * @param WPInv_Invoice $invoice Invoice.
344
-	 */
345
-	public function process_charge_response( $result, $invoice ) {
343
+     * @param WPInv_Invoice $invoice Invoice.
344
+     */
345
+    public function process_charge_response( $result, $invoice ) {
346 346
 
347 347
         wpinv_clear_errors();
348
-		$response_code = (int) $result->transactionResponse->responseCode;
348
+        $response_code = (int) $result->transactionResponse->responseCode;
349 349
 
350
-		// Succeeded.
351
-		if ( 1 == $response_code || 4 == $response_code ) {
350
+        // Succeeded.
351
+        if ( 1 == $response_code || 4 == $response_code ) {
352 352
 
353
-			// Maybe set a transaction id.
354
-			if ( ! empty( $result->transactionResponse->transId ) ) {
355
-				$invoice->set_transaction_id( $result->transactionResponse->transId );
356
-			}
353
+            // Maybe set a transaction id.
354
+            if ( ! empty( $result->transactionResponse->transId ) ) {
355
+                $invoice->set_transaction_id( $result->transactionResponse->transId );
356
+            }
357 357
 
358
-			$invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true );
358
+            $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true );
359 359
 
360
-			if ( 1 == $response_code ) {
361
-				return $invoice->mark_paid();
362
-			}
360
+            if ( 1 == $response_code ) {
361
+                return $invoice->mark_paid();
362
+            }
363 363
 
364
-			$invoice->set_status( 'wpi-onhold' );
365
-        	$invoice->add_note(
364
+            $invoice->set_status( 'wpi-onhold' );
365
+            $invoice->add_note(
366 366
                 sprintf(
367 367
                     __( 'Held for review: %s', 'invoicing' ),
368 368
                     $result->transactionResponse->messages->message[0]->description
369 369
                 )
370
-			);
370
+            );
371 371
 
372
-			return $invoice->save();
372
+            return $invoice->save();
373 373
 
374
-		}
374
+        }
375 375
 
376 376
         wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) );
377 377
 
@@ -383,13 +383,13 @@  discard block
 block discarded – undo
383 383
     }
384 384
 
385 385
     /**
386
-	 * Returns payment information.
387
-	 *
388
-	 *
389
-	 * @param array $card Card details.
390
-	 * @return array
391
-	 */
392
-	public function get_payment_information( $card ) {
386
+     * Returns payment information.
387
+     *
388
+     *
389
+     * @param array $card Card details.
390
+     * @return array
391
+     */
392
+    public function get_payment_information( $card ) {
393 393
         return array(
394 394
 
395 395
             'creditCard'         => array (
@@ -402,25 +402,25 @@  discard block
 block discarded – undo
402 402
     }
403 403
 
404 404
     /**
405
-	 * Returns the customer profile meta name.
406
-	 *
407
-	 *
408
-	 * @param WPInv_Invoice $invoice Invoice.
409
-	 * @return string
410
-	 */
411
-	public function get_customer_profile_meta_name( $invoice ) {
405
+     * Returns the customer profile meta name.
406
+     *
407
+     *
408
+     * @param WPInv_Invoice $invoice Invoice.
409
+     * @return string
410
+     */
411
+    public function get_customer_profile_meta_name( $invoice ) {
412 412
         return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
413 413
     }
414 414
 
415 415
     /**
416
-	 * Validates the submitted data.
417
-	 *
418
-	 *
419
-	 * @param array $submission_data Posted checkout fields.
416
+     * Validates the submitted data.
417
+     *
418
+     *
419
+     * @param array $submission_data Posted checkout fields.
420 420
      * @param WPInv_Invoice $invoice
421
-	 * @return WP_Error|string The payment profile id
422
-	 */
423
-	public function validate_submission_data( $submission_data, $invoice ) {
421
+     * @return WP_Error|string The payment profile id
422
+     */
423
+    public function validate_submission_data( $submission_data, $invoice ) {
424 424
 
425 425
         // Validate authentication details.
426 426
         $auth = $this->get_auth_params();
@@ -452,13 +452,13 @@  discard block
 block discarded – undo
452 452
     }
453 453
 
454 454
     /**
455
-	 * Returns invoice line items.
456
-	 *
457
-	 *
458
-	 * @param WPInv_Invoice $invoice Invoice.
459
-	 * @return array
460
-	 */
461
-	public function get_line_items( $invoice ) {
455
+     * Returns invoice line items.
456
+     *
457
+     *
458
+     * @param WPInv_Invoice $invoice Invoice.
459
+     * @return array
460
+     */
461
+    public function get_line_items( $invoice ) {
462 462
         $items = array();
463 463
 
464 464
         foreach ( $invoice->get_items() as $item ) {
@@ -496,15 +496,15 @@  discard block
 block discarded – undo
496 496
     }
497 497
 
498 498
     /**
499
-	 * Process Payment.
500
-	 *
501
-	 *
502
-	 * @param WPInv_Invoice $invoice Invoice.
503
-	 * @param array $submission_data Posted checkout fields.
504
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
505
-	 * @return array
506
-	 */
507
-	public function process_payment( $invoice, $submission_data, $submission ) {
499
+     * Process Payment.
500
+     *
501
+     *
502
+     * @param WPInv_Invoice $invoice Invoice.
503
+     * @param array $submission_data Posted checkout fields.
504
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
505
+     * @return array
506
+     */
507
+    public function process_payment( $invoice, $submission_data, $submission ) {
508 508
 
509 509
         // Validate the submitted data.
510 510
         $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice );
@@ -537,69 +537,69 @@  discard block
 block discarded – undo
537 537
 
538 538
         exit;
539 539
 
540
-	}
540
+    }
541 541
 	
542
-	/**
543
-	 * Processes the initial payment.
544
-	 *
542
+    /**
543
+     * Processes the initial payment.
544
+     *
545 545
      * @param WPInv_Invoice $invoice Invoice.
546
-	 */
547
-	protected function process_initial_payment( $invoice ) {
546
+     */
547
+    protected function process_initial_payment( $invoice ) {
548 548
 
549
-		$payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
549
+        $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
550 550
         $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
551
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
551
+        $result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
552 552
 
553
-		// Do we have an error?
554
-		if ( is_wp_error( $result ) ) {
555
-			wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
556
-			wpinv_send_back_to_checkout();
557
-		}
553
+        // Do we have an error?
554
+        if ( is_wp_error( $result ) ) {
555
+            wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
556
+            wpinv_send_back_to_checkout();
557
+        }
558 558
 
559
-		// Process the response.
560
-		$this->process_charge_response( $result, $invoice );
559
+        // Process the response.
560
+        $this->process_charge_response( $result, $invoice );
561 561
 
562
-		if ( wpinv_get_errors() ) {
563
-			wpinv_send_back_to_checkout();
564
-		}
562
+        if ( wpinv_get_errors() ) {
563
+            wpinv_send_back_to_checkout();
564
+        }
565 565
 
566
-	}
566
+    }
567 567
 
568 568
     /**
569
-	 * Processes recurring payments.
570
-	 *
569
+     * Processes recurring payments.
570
+     *
571 571
      * @param WPInv_Invoice $invoice Invoice.
572 572
      * @param WPInv_Subscription $subscription Subscription.
573
-	 */
574
-	public function process_subscription( $invoice, $subscription ) {
573
+     */
574
+    public function process_subscription( $invoice, $subscription ) {
575 575
 
576 576
         // Check if there is an initial amount to charge.
577 577
         if ( (float) $invoice->get_total() > 0 ) {
578
-			$this->process_initial_payment( $invoice );
578
+            $this->process_initial_payment( $invoice );
579 579
         }
580 580
 
581 581
         // Activate the subscription.
582 582
         $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
583 583
         $expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
584 584
 
585
-		$subscription->set_next_renewal_date( $expiry );
586
-		$subscription->set_date_created( current_time( 'mysql' ) );
587
-		$subscription->set_profile_id( $invoice->generate_key() );
588
-		$subscription->activate();
585
+        $subscription->set_next_renewal_date( $expiry );
586
+        $subscription->set_date_created( current_time( 'mysql' ) );
587
+        $subscription->set_profile_id( $invoice->generate_key() );
588
+        $subscription->activate();
589 589
 
590
-		// Redirect to the success page.
590
+        // Redirect to the success page.
591 591
         wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
592 592
 
593 593
     }
594 594
 
595
-	/**
596
-	 * (Maybe) renews an authorize.net subscription profile.
597
-	 *
598
-	 *
599
-	 * @param bool $should_expire
595
+    /**
596
+     * (Maybe) renews an authorize.net subscription profile.
597
+     *
598
+     *
599
+     * @param bool $should_expire
600 600
      * @param WPInv_Subscription $subscription
601
-	 */
602
-	public function maybe_renew_subscription( $should_expire, $subscription ) {
601
+     */
602
+    public function maybe_renew_subscription( $should_expire, $subscription ) {
603 603
 
604 604
         // Ensure its our subscription && it's active.
605 605
         if ( $this->id != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) {
@@ -616,18 +616,18 @@  discard block
 block discarded – undo
616 616
 
617 617
         return false;
618 618
 
619
-	}
619
+    }
620 620
 
621 621
     /**
622
-	 * Renews a subscription.
623
-	 *
622
+     * Renews a subscription.
623
+     *
624 624
      * @param WPInv_Subscription $subscription
625
-	 */
626
-	public function renew_subscription( $subscription ) {
625
+     */
626
+    public function renew_subscription( $subscription ) {
627 627
 
628
-		// Generate the renewal invoice.
629
-		$new_invoice = $subscription->create_payment();
630
-		$old_invoice = $subscription->get_parent_payment();
628
+        // Generate the renewal invoice.
629
+        $new_invoice = $subscription->create_payment();
630
+        $old_invoice = $subscription->get_parent_payment();
631 631
 
632 632
         if ( empty( $new_invoice ) ) {
633 633
             $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false );
@@ -636,37 +636,37 @@  discard block
 block discarded – undo
636 636
         }
637 637
 
638 638
         // Charge the payment method.
639
-		$payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
640
-		$customer_profile   = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true );
641
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice );
642
-
643
-		// Do we have an error?
644
-		if ( is_wp_error( $result ) ) {
645
-
646
-			$old_invoice->add_note(
647
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
648
-				true,
649
-				false,
650
-				true
651
-			);
652
-			$subscription->failing();
653
-			return;
654
-
655
-		}
656
-
657
-		// Process the response.
658
-		$this->process_charge_response( $result, $new_invoice );
659
-
660
-		if ( wpinv_get_errors() ) {
661
-
662
-			$old_invoice->add_note(
663
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
664
-				true,
665
-				false,
666
-				true
667
-			);
668
-			$subscription->failing();
669
-			return;
639
+        $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
640
+        $customer_profile   = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true );
641
+        $result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice );
642
+
643
+        // Do we have an error?
644
+        if ( is_wp_error( $result ) ) {
645
+
646
+            $old_invoice->add_note(
647
+                sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
648
+                true,
649
+                false,
650
+                true
651
+            );
652
+            $subscription->failing();
653
+            return;
654
+
655
+        }
656
+
657
+        // Process the response.
658
+        $this->process_charge_response( $result, $new_invoice );
659
+
660
+        if ( wpinv_get_errors() ) {
661
+
662
+            $old_invoice->add_note(
663
+                sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
664
+                true,
665
+                false,
666
+                true
667
+            );
668
+            $subscription->failing();
669
+            return;
670 670
 
671 671
         }
672 672
 
@@ -675,13 +675,13 @@  discard block
 block discarded – undo
675 675
     }
676 676
 
677 677
     /**
678
-	 * Processes invoice addons.
679
-	 *
680
-	 * @param WPInv_Invoice $invoice
681
-	 * @param GetPaid_Form_Item[] $items
682
-	 * @return WPInv_Invoice
683
-	 */
684
-	public function process_addons( $invoice, $items ) {
678
+     * Processes invoice addons.
679
+     *
680
+     * @param WPInv_Invoice $invoice
681
+     * @param GetPaid_Form_Item[] $items
682
+     * @return WPInv_Invoice
683
+     */
684
+    public function process_addons( $invoice, $items ) {
685 685
 
686 686
         global $getpaid_authorize_addons;
687 687
 
@@ -701,7 +701,7 @@  discard block
 block discarded – undo
701 701
         $invoice->recalculate_total();
702 702
 
703 703
         $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
704
-		$customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
704
+        $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
705 705
 
706 706
         add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 );
707 707
         $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
@@ -716,11 +716,11 @@  discard block
 block discarded – undo
716 716
     }
717 717
 
718 718
     /**
719
-	 * Processes invoice addons.
720
-	 *
719
+     * Processes invoice addons.
720
+     *
721 721
      * @param array $args
722
-	 * @return array
723
-	 */
722
+     * @return array
723
+     */
724 724
     public function filter_addons_request( $args ) {
725 725
 
726 726
         global $getpaid_authorize_addons;
@@ -754,11 +754,11 @@  discard block
 block discarded – undo
754 754
     }
755 755
 
756 756
     /**
757
-	 * Filters the gateway settings.
758
-	 *
759
-	 * @param array $admin_settings
760
-	 */
761
-	public function admin_settings( $admin_settings ) {
757
+     * Filters the gateway settings.
758
+     *
759
+     * @param array $admin_settings
760
+     */
761
+    public function admin_settings( $admin_settings ) {
762 762
 
763 763
         $currencies = sprintf(
764 764
             __( 'Supported Currencies: %s', 'invoicing' ),
@@ -798,7 +798,7 @@  discard block
 block discarded – undo
798 798
             'readonly' => true,
799 799
         );
800 800
 
801
-		return $admin_settings;
802
-	}
801
+        return $admin_settings;
802
+    }
803 803
 
804 804
 }
Please login to merge, or discard this patch.
Spacing   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Authorize.net Payment Gateway class.
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
24 24
 	 *
25 25
 	 * @var array
26 26
 	 */
27
-    protected $supports = array( 'subscription', 'sandbox', 'tokens', 'addons' );
27
+    protected $supports = array('subscription', 'sandbox', 'tokens', 'addons');
28 28
 
29 29
     /**
30 30
 	 * Payment method order.
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
 	 *
53 53
 	 * @var array
54 54
 	 */
55
-	public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' );
55
+	public $currencies = array('USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD');
56 56
 
57 57
     /**
58 58
 	 * URL to view a transaction.
@@ -66,12 +66,12 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public function __construct() {
68 68
 
69
-        $this->title                = __( 'Credit Card / Debit Card', 'invoicing' );
70
-        $this->method_title         = __( 'Authorize.Net', 'invoicing' );
71
-        $this->notify_url           = wpinv_get_ipn_url( $this->id );
69
+        $this->title                = __('Credit Card / Debit Card', 'invoicing');
70
+        $this->method_title         = __('Authorize.Net', 'invoicing');
71
+        $this->notify_url           = wpinv_get_ipn_url($this->id);
72 72
 
73
-        add_filter( 'getpaid_daily_maintenance_should_expire_subscription', array( $this, 'maybe_renew_subscription' ), 10, 2 );
74
-        add_filter( 'getpaid_authorizenet_sandbox_notice', array( $this, 'sandbox_notice' ) );
73
+        add_filter('getpaid_daily_maintenance_should_expire_subscription', array($this, 'maybe_renew_subscription'), 10, 2);
74
+        add_filter('getpaid_authorizenet_sandbox_notice', array($this, 'sandbox_notice'));
75 75
         parent::__construct();
76 76
     }
77 77
 
@@ -81,13 +81,13 @@  discard block
 block discarded – undo
81 81
 	 * @param int $invoice_id 0 or invoice id.
82 82
 	 * @param GetPaid_Payment_Form $form Current payment form.
83 83
 	 */
84
-    public function payment_fields( $invoice_id, $form ) {
84
+    public function payment_fields($invoice_id, $form) {
85 85
 
86 86
         // Let the user select a payment method.
87 87
         echo $this->saved_payment_methods();
88 88
 
89 89
         // Show the credit card entry form.
90
-        echo $this->new_payment_method_entry( $this->get_cc_form( true ) );
90
+        echo $this->new_payment_method_entry($this->get_cc_form(true));
91 91
     }
92 92
 
93 93
     /**
@@ -100,64 +100,64 @@  discard block
 block discarded – undo
100 100
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
101 101
 	 * @return string|WP_Error Payment profile id.
102 102
 	 */
103
-	public function create_customer_profile( $invoice, $submission_data, $save = true ) {
103
+	public function create_customer_profile($invoice, $submission_data, $save = true) {
104 104
 
105 105
         // Remove non-digits from the number
106
-        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] );
106
+        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']);
107 107
 
108 108
         // Generate args.
109 109
         $args = array(
110 110
             'createCustomerProfileRequest' => array(
111 111
                 'merchantAuthentication'   => $this->get_auth_params(),
112 112
                 'profile'                  => array(
113
-                    'merchantCustomerId'   => getpaid_limit_length( $invoice->get_user_id(), 20 ),
114
-                    'description'          => getpaid_limit_length( $invoice->get_full_name(), 255 ),
115
-                    'email'                => getpaid_limit_length( $invoice->get_email(), 255 ),
113
+                    'merchantCustomerId'   => getpaid_limit_length($invoice->get_user_id(), 20),
114
+                    'description'          => getpaid_limit_length($invoice->get_full_name(), 255),
115
+                    'email'                => getpaid_limit_length($invoice->get_email(), 255),
116 116
                     'paymentProfiles'      => array(
117 117
                         'customerType'     => 'individual',
118 118
 
119 119
                         // Billing information.
120 120
                         'billTo'           => array(
121
-                            'firstName'    => getpaid_limit_length( $invoice->get_first_name(), 50 ),
122
-                            'lastName'     => getpaid_limit_length( $invoice->get_last_name(), 50 ),
123
-                            'address'      => getpaid_limit_length( $invoice->get_last_name(), 60 ),
124
-                            'city'         => getpaid_limit_length( $invoice->get_city(), 40 ),
125
-                            'state'        => getpaid_limit_length( $invoice->get_state(), 40 ),
126
-                            'zip'          => getpaid_limit_length( $invoice->get_zip(), 20 ),
127
-                            'country'      => getpaid_limit_length( $invoice->get_country(), 60 ),
121
+                            'firstName'    => getpaid_limit_length($invoice->get_first_name(), 50),
122
+                            'lastName'     => getpaid_limit_length($invoice->get_last_name(), 50),
123
+                            'address'      => getpaid_limit_length($invoice->get_last_name(), 60),
124
+                            'city'         => getpaid_limit_length($invoice->get_city(), 40),
125
+                            'state'        => getpaid_limit_length($invoice->get_state(), 40),
126
+                            'zip'          => getpaid_limit_length($invoice->get_zip(), 20),
127
+                            'country'      => getpaid_limit_length($invoice->get_country(), 60),
128 128
                         ),
129 129
 
130 130
                         // Payment information.
131
-                        'payment'          => $this->get_payment_information( $submission_data['authorizenet'] ),
131
+                        'payment'          => $this->get_payment_information($submission_data['authorizenet']),
132 132
                     )
133 133
                 ),
134
-                'validationMode'           => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode',
134
+                'validationMode'           => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode',
135 135
             )
136 136
         );
137 137
 
138
-        $response = $this->post( apply_filters( 'getpaid_authorizenet_customer_profile_args', $args, $invoice ), $invoice );
138
+        $response = $this->post(apply_filters('getpaid_authorizenet_customer_profile_args', $args, $invoice), $invoice);
139 139
 
140
-        if ( is_wp_error( $response ) ) {
140
+        if (is_wp_error($response)) {
141 141
             return $response;
142 142
         }
143 143
 
144
-        update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $response->customerProfileId );
144
+        update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $response->customerProfileId);
145 145
 
146 146
         // Save the payment token.
147
-        if ( $save ) {
147
+        if ($save) {
148 148
             $this->save_token(
149 149
                 array(
150 150
                     'id'      => $response->customerPaymentProfileIdList[0],
151
-                    'name'    => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . '····' . substr( $submission_data['authorizenet']['cc_number'], -4 ),
151
+                    'name'    => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . '····' . substr($submission_data['authorizenet']['cc_number'], -4),
152 152
                     'default' => true,
153
-                    'type'    => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live',
153
+                    'type'    => $this->is_sandbox($invoice) ? 'sandbox' : 'live',
154 154
                 )
155 155
             );
156 156
         }
157 157
 
158 158
         // Add a note about the validation response.
159 159
         $invoice->add_note(
160
-            sprintf( __( 'Created Authorize.NET customer profile: %s', 'invoicing' ), $response->validationDirectResponseList[0] ),
160
+            sprintf(__('Created Authorize.NET customer profile: %s', 'invoicing'), $response->validationDirectResponseList[0]),
161 161
             false,
162 162
             false,
163 163
             true
@@ -174,7 +174,7 @@  discard block
 block discarded – undo
174 174
 	 * @return string|WP_Error Profile id.
175 175
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile
176 176
 	 */
177
-	public function get_customer_profile( $profile_id ) {
177
+	public function get_customer_profile($profile_id) {
178 178
 
179 179
         // Generate args.
180 180
         $args = array(
@@ -184,7 +184,7 @@  discard block
 block discarded – undo
184 184
             )
185 185
         );
186 186
 
187
-        return $this->post( $args, false );
187
+        return $this->post($args, false);
188 188
 
189 189
     }
190 190
 
@@ -199,10 +199,10 @@  discard block
 block discarded – undo
199 199
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile
200 200
 	 * @return string|WP_Error Profile id.
201 201
 	 */
202
-	public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) {
202
+	public function create_customer_payment_profile($customer_profile, $invoice, $submission_data, $save) {
203 203
 
204 204
         // Remove non-digits from the number
205
-        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] );
205
+        $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']);
206 206
 
207 207
         // Generate args.
208 208
         $args = array(
@@ -213,34 +213,34 @@  discard block
 block discarded – undo
213 213
 
214 214
                     // Billing information.
215 215
                     'billTo'           => array(
216
-                        'firstName'    => getpaid_limit_length( $invoice->get_first_name(), 50 ),
217
-                        'lastName'     => getpaid_limit_length( $invoice->get_last_name(), 50 ),
218
-                        'address'      => getpaid_limit_length( $invoice->get_last_name(), 60 ),
219
-                        'city'         => getpaid_limit_length( $invoice->get_city(), 40 ),
220
-                        'state'        => getpaid_limit_length( $invoice->get_state(), 40 ),
221
-                        'zip'          => getpaid_limit_length( $invoice->get_zip(), 20 ),
222
-                        'country'      => getpaid_limit_length( $invoice->get_country(), 60 ),
216
+                        'firstName'    => getpaid_limit_length($invoice->get_first_name(), 50),
217
+                        'lastName'     => getpaid_limit_length($invoice->get_last_name(), 50),
218
+                        'address'      => getpaid_limit_length($invoice->get_last_name(), 60),
219
+                        'city'         => getpaid_limit_length($invoice->get_city(), 40),
220
+                        'state'        => getpaid_limit_length($invoice->get_state(), 40),
221
+                        'zip'          => getpaid_limit_length($invoice->get_zip(), 20),
222
+                        'country'      => getpaid_limit_length($invoice->get_country(), 60),
223 223
                     ),
224 224
 
225 225
                     // Payment information.
226
-                    'payment'          => $this->get_payment_information( $submission_data['authorizenet'] )
226
+                    'payment'          => $this->get_payment_information($submission_data['authorizenet'])
227 227
                 ),
228
-                'validationMode'       => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode',
228
+                'validationMode'       => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode',
229 229
             )
230 230
         );
231 231
 
232
-        $response = $this->post( apply_filters( 'getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice ), $invoice );
232
+        $response = $this->post(apply_filters('getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice), $invoice);
233 233
 
234
-        if ( is_wp_error( $response ) ) {
234
+        if (is_wp_error($response)) {
235 235
             return $response;
236 236
         }
237 237
 
238 238
         // Save the payment token.
239
-        if ( $save ) {
239
+        if ($save) {
240 240
             $this->save_token(
241 241
                 array(
242 242
                     'id'      => $response->customerPaymentProfileId,
243
-                    'name'    => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . ' ···· ' . substr( $submission_data['authorizenet']['cc_number'], -4 ),
243
+                    'name'    => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . ' ···· ' . substr($submission_data['authorizenet']['cc_number'], -4),
244 244
                     'default' => true
245 245
                 )
246 246
             );
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 
249 249
         // Add a note about the validation response.
250 250
         $invoice->add_note(
251
-            sprintf( __( 'Saved Authorize.NET payment profile: %s', 'invoicing' ), $response->validationDirectResponse ),
251
+            sprintf(__('Saved Authorize.NET payment profile: %s', 'invoicing'), $response->validationDirectResponse),
252 252
             false,
253 253
             false,
254 254
             true
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	 * @return string|WP_Error Profile id.
268 268
      * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile
269 269
 	 */
270
-	public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) {
270
+	public function get_customer_payment_profile($customer_profile_id, $payment_profile_id) {
271 271
 
272 272
         // Generate args.
273 273
         $args = array(
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
             )
279 279
         );
280 280
 
281
-        return $this->post( $args, false );
281
+        return $this->post($args, false);
282 282
 
283 283
     }
284 284
 
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
      * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile
292 292
 	 * @return WP_Error|object
293 293
 	 */
294
-	public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) {
294
+	public function charge_customer_payment_profile($customer_profile_id, $payment_profile_id, $invoice) {
295 295
 
296 296
         // Generate args.
297 297
         $args = array(
@@ -311,28 +311,28 @@  discard block
 block discarded – undo
311 311
                         )
312 312
                     ),
313 313
                     'order'                    => array(
314
-                        'invoiceNumber'        => getpaid_limit_length( $invoice->get_number(), 20 ),
314
+                        'invoiceNumber'        => getpaid_limit_length($invoice->get_number(), 20),
315 315
                     ),
316
-                    'lineItems'                => array( 'lineItem' => $this->get_line_items( $invoice ) ),
316
+                    'lineItems'                => array('lineItem' => $this->get_line_items($invoice)),
317 317
                     'tax'                      => array(
318 318
                         'amount'               => $invoice->get_total_tax(),
319
-                        'name'                 => __( 'TAX', 'invoicing' ),
319
+                        'name'                 => __('TAX', 'invoicing'),
320 320
                     ),
321
-                    'poNumber'                 => getpaid_limit_length( $invoice->get_number(), 25 ),
321
+                    'poNumber'                 => getpaid_limit_length($invoice->get_number(), 25),
322 322
                     'customer'                 => array(
323
-                        'id'                   => getpaid_limit_length( $invoice->get_user_id(), 25 ),
324
-                        'email'                => getpaid_limit_length( $invoice->get_email(), 25 ),
323
+                        'id'                   => getpaid_limit_length($invoice->get_user_id(), 25),
324
+                        'email'                => getpaid_limit_length($invoice->get_email(), 25),
325 325
                     ),
326 326
                     'customerIP'               => $invoice->get_ip(),
327 327
                 )
328 328
             )
329 329
         );
330 330
 
331
-        if ( 0 == $invoice->get_total_tax() ) {
332
-            unset( $args['createTransactionRequest']['transactionRequest']['tax'] );
331
+        if (0 == $invoice->get_total_tax()) {
332
+            unset($args['createTransactionRequest']['transactionRequest']['tax']);
333 333
         }
334 334
 
335
-        return $this->post( apply_filters( 'getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice ), $invoice );
335
+        return $this->post(apply_filters('getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice), $invoice);
336 336
 
337 337
     }
338 338
 
@@ -342,29 +342,29 @@  discard block
 block discarded – undo
342 342
      * @param stdClass $result Api response.
343 343
 	 * @param WPInv_Invoice $invoice Invoice.
344 344
 	 */
345
-	public function process_charge_response( $result, $invoice ) {
345
+	public function process_charge_response($result, $invoice) {
346 346
 
347 347
         wpinv_clear_errors();
348 348
 		$response_code = (int) $result->transactionResponse->responseCode;
349 349
 
350 350
 		// Succeeded.
351
-		if ( 1 == $response_code || 4 == $response_code ) {
351
+		if (1 == $response_code || 4 == $response_code) {
352 352
 
353 353
 			// Maybe set a transaction id.
354
-			if ( ! empty( $result->transactionResponse->transId ) ) {
355
-				$invoice->set_transaction_id( $result->transactionResponse->transId );
354
+			if (!empty($result->transactionResponse->transId)) {
355
+				$invoice->set_transaction_id($result->transactionResponse->transId);
356 356
 			}
357 357
 
358
-			$invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true );
358
+			$invoice->add_note(sprintf(__('Authentication code: %s (%s).', 'invoicing'), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber), false, false, true);
359 359
 
360
-			if ( 1 == $response_code ) {
360
+			if (1 == $response_code) {
361 361
 				return $invoice->mark_paid();
362 362
 			}
363 363
 
364
-			$invoice->set_status( 'wpi-onhold' );
364
+			$invoice->set_status('wpi-onhold');
365 365
         	$invoice->add_note(
366 366
                 sprintf(
367
-                    __( 'Held for review: %s', 'invoicing' ),
367
+                    __('Held for review: %s', 'invoicing'),
368 368
                     $result->transactionResponse->messages->message[0]->description
369 369
                 )
370 370
 			);
@@ -373,11 +373,11 @@  discard block
 block discarded – undo
373 373
 
374 374
 		}
375 375
 
376
-        wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) );
376
+        wpinv_set_error('card_declined', __('Credit card declined.', 'invoicing'));
377 377
 
378
-        if ( ! empty( $result->transactionResponse->errors ) ) {
378
+        if (!empty($result->transactionResponse->errors)) {
379 379
             $errors = (object) $result->transactionResponse->errors;
380
-            wpinv_set_error( $errors->error[0]->errorCode, esc_html( $errors->error[0]->errorText ) );
380
+            wpinv_set_error($errors->error[0]->errorCode, esc_html($errors->error[0]->errorText));
381 381
         }
382 382
 
383 383
     }
@@ -389,10 +389,10 @@  discard block
 block discarded – undo
389 389
 	 * @param array $card Card details.
390 390
 	 * @return array
391 391
 	 */
392
-	public function get_payment_information( $card ) {
392
+	public function get_payment_information($card) {
393 393
         return array(
394 394
 
395
-            'creditCard'         => array (
395
+            'creditCard'         => array(
396 396
                 'cardNumber'     => $card['cc_number'],
397 397
                 'expirationDate' => $card['cc_expire_year'] . '-' . $card['cc_expire_month'],
398 398
                 'cardCode'       => $card['cc_cvv2'],
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 	 * @param WPInv_Invoice $invoice Invoice.
409 409
 	 * @return string
410 410
 	 */
411
-	public function get_customer_profile_meta_name( $invoice ) {
412
-        return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
411
+	public function get_customer_profile_meta_name($invoice) {
412
+        return $this->is_sandbox($invoice) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id';
413 413
     }
414 414
 
415 415
     /**
@@ -420,34 +420,34 @@  discard block
 block discarded – undo
420 420
      * @param WPInv_Invoice $invoice
421 421
 	 * @return WP_Error|string The payment profile id
422 422
 	 */
423
-	public function validate_submission_data( $submission_data, $invoice ) {
423
+	public function validate_submission_data($submission_data, $invoice) {
424 424
 
425 425
         // Validate authentication details.
426 426
         $auth = $this->get_auth_params();
427 427
 
428
-        if ( empty( $auth['name'] ) || empty( $auth['transactionKey'] ) ) {
429
-            return new WP_Error( 'invalid_settings', __( 'Please set-up your login id and transaction key before using this gateway.', 'invoicing') );
428
+        if (empty($auth['name']) || empty($auth['transactionKey'])) {
429
+            return new WP_Error('invalid_settings', __('Please set-up your login id and transaction key before using this gateway.', 'invoicing'));
430 430
         }
431 431
 
432 432
         // Validate the payment method.
433
-        if ( empty( $submission_data['getpaid-authorizenet-payment-method'] ) ) {
434
-            return new WP_Error( 'invalid_payment_method', __( 'Please select a different payment method or add a new card.', 'invoicing') );
433
+        if (empty($submission_data['getpaid-authorizenet-payment-method'])) {
434
+            return new WP_Error('invalid_payment_method', __('Please select a different payment method or add a new card.', 'invoicing'));
435 435
         }
436 436
 
437 437
         // Are we adding a new payment method?
438
-        if ( 'new' != $submission_data['getpaid-authorizenet-payment-method'] ) {
438
+        if ('new' != $submission_data['getpaid-authorizenet-payment-method']) {
439 439
             return $submission_data['getpaid-authorizenet-payment-method'];
440 440
         }
441 441
 
442 442
         // Retrieve the customer profile id.
443
-        $profile_id = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
443
+        $profile_id = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
444 444
 
445 445
         // Create payment method.
446
-        if ( empty( $profile_id ) ) {
447
-            return $this->create_customer_profile( $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) );
446
+        if (empty($profile_id)) {
447
+            return $this->create_customer_profile($invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method']));
448 448
         }
449 449
 
450
-        return $this->create_customer_payment_profile( $profile_id, $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) );
450
+        return $this->create_customer_payment_profile($profile_id, $invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method']));
451 451
 
452 452
     }
453 453
 
@@ -458,16 +458,16 @@  discard block
 block discarded – undo
458 458
 	 * @param WPInv_Invoice $invoice Invoice.
459 459
 	 * @return array
460 460
 	 */
461
-	public function get_line_items( $invoice ) {
461
+	public function get_line_items($invoice) {
462 462
         $items = array();
463 463
 
464
-        foreach ( $invoice->get_items() as $item ) {
464
+        foreach ($invoice->get_items() as $item) {
465 465
 
466 466
             $amount  = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price();
467 467
             $items[] = array(
468
-                'itemId'      => getpaid_limit_length( $item->get_id(), 31 ),
469
-                'name'        => getpaid_limit_length( $item->get_raw_name(), 31 ),
470
-                'description' => getpaid_limit_length( $item->get_description(), 255 ),
468
+                'itemId'      => getpaid_limit_length($item->get_id(), 31),
469
+                'name'        => getpaid_limit_length($item->get_raw_name(), 31),
470
+                'description' => getpaid_limit_length($item->get_description(), 255),
471 471
                 'quantity'    => (string) $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(),
472 472
                 'unitPrice'   => (float) $amount,
473 473
                 'taxable'     => wpinv_use_taxes() && $invoice->is_taxable() && 'tax-exempt' != $item->get_vat_rule(),
@@ -475,15 +475,15 @@  discard block
 block discarded – undo
475 475
 
476 476
         }
477 477
 
478
-        foreach ( $invoice->get_fees() as $fee_name => $fee ) {
478
+        foreach ($invoice->get_fees() as $fee_name => $fee) {
479 479
 
480
-            $amount  = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee'];
480
+            $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee'];
481 481
 
482
-            if ( $amount > 0 ) {
482
+            if ($amount > 0) {
483 483
                 $items[] = array(
484
-                    'itemId'      => getpaid_limit_length( $fee_name, 31 ),
485
-                    'name'        => getpaid_limit_length( $fee_name, 31 ),
486
-                    'description' => getpaid_limit_length( $fee_name, 255 ),
484
+                    'itemId'      => getpaid_limit_length($fee_name, 31),
485
+                    'name'        => getpaid_limit_length($fee_name, 31),
486
+                    'description' => getpaid_limit_length($fee_name, 255),
487 487
                     'quantity'    => '1',
488 488
                     'unitPrice'   => (float) $amount,
489 489
                     'taxable'     => false,
@@ -504,36 +504,36 @@  discard block
 block discarded – undo
504 504
 	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
505 505
 	 * @return array
506 506
 	 */
507
-	public function process_payment( $invoice, $submission_data, $submission ) {
507
+	public function process_payment($invoice, $submission_data, $submission) {
508 508
 
509 509
         // Validate the submitted data.
510
-        $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice );
510
+        $payment_profile_id = $this->validate_submission_data($submission_data, $invoice);
511 511
 
512 512
         // Do we have an error?
513
-        if ( is_wp_error( $payment_profile_id ) ) {
514
-            wpinv_set_error( $payment_profile_id->get_error_code(), $payment_profile_id->get_error_message() );
513
+        if (is_wp_error($payment_profile_id)) {
514
+            wpinv_set_error($payment_profile_id->get_error_code(), $payment_profile_id->get_error_message());
515 515
             wpinv_send_back_to_checkout();
516 516
         }
517 517
 
518 518
         // Save the payment method to the order.
519
-        update_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id );
519
+        update_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id);
520 520
 
521 521
         // Check if this is a subscription or not.
522
-        $subscription = getpaid_get_invoice_subscription( $invoice );
523
-        if ( ! empty( $subscription ) ) {
524
-            $this->process_subscription( $invoice, $subscription );
522
+        $subscription = getpaid_get_invoice_subscription($invoice);
523
+        if (!empty($subscription)) {
524
+            $this->process_subscription($invoice, $subscription);
525 525
         }
526 526
 
527 527
         // If it is free, send to the success page.
528
-        if ( ! $invoice->needs_payment() ) {
528
+        if (!$invoice->needs_payment()) {
529 529
             $invoice->mark_paid();
530
-            wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
530
+            wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
531 531
         }
532 532
 
533 533
         // Charge the payment profile.
534
-        $this->process_initial_payment( $invoice );
534
+        $this->process_initial_payment($invoice);
535 535
 
536
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
536
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
537 537
 
538 538
         exit;
539 539
 
@@ -544,22 +544,22 @@  discard block
 block discarded – undo
544 544
 	 *
545 545
      * @param WPInv_Invoice $invoice Invoice.
546 546
 	 */
547
-	protected function process_initial_payment( $invoice ) {
547
+	protected function process_initial_payment($invoice) {
548 548
 
549
-		$payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
550
-        $customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
551
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
549
+		$payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
550
+        $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
551
+		$result             = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice);
552 552
 
553 553
 		// Do we have an error?
554
-		if ( is_wp_error( $result ) ) {
555
-			wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
554
+		if (is_wp_error($result)) {
555
+			wpinv_set_error($result->get_error_code(), $result->get_error_message());
556 556
 			wpinv_send_back_to_checkout();
557 557
 		}
558 558
 
559 559
 		// Process the response.
560
-		$this->process_charge_response( $result, $invoice );
560
+		$this->process_charge_response($result, $invoice);
561 561
 
562
-		if ( wpinv_get_errors() ) {
562
+		if (wpinv_get_errors()) {
563 563
 			wpinv_send_back_to_checkout();
564 564
 		}
565 565
 
@@ -571,24 +571,24 @@  discard block
 block discarded – undo
571 571
      * @param WPInv_Invoice $invoice Invoice.
572 572
      * @param WPInv_Subscription $subscription Subscription.
573 573
 	 */
574
-	public function process_subscription( $invoice, $subscription ) {
574
+	public function process_subscription($invoice, $subscription) {
575 575
 
576 576
         // Check if there is an initial amount to charge.
577
-        if ( (float) $invoice->get_total() > 0 ) {
578
-			$this->process_initial_payment( $invoice );
577
+        if ((float) $invoice->get_total() > 0) {
578
+			$this->process_initial_payment($invoice);
579 579
         }
580 580
 
581 581
         // Activate the subscription.
582
-        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
583
-        $expiry   = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) );
582
+        $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
583
+        $expiry   = date('Y-m-d H:i:s', (current_time('timestamp') + $duration));
584 584
 
585
-		$subscription->set_next_renewal_date( $expiry );
586
-		$subscription->set_date_created( current_time( 'mysql' ) );
587
-		$subscription->set_profile_id( $invoice->generate_key() );
585
+		$subscription->set_next_renewal_date($expiry);
586
+		$subscription->set_date_created(current_time('mysql'));
587
+		$subscription->set_profile_id($invoice->generate_key());
588 588
 		$subscription->activate();
589 589
 
590 590
 		// Redirect to the success page.
591
-        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
591
+        wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
592 592
 
593 593
     }
594 594
 
@@ -599,20 +599,20 @@  discard block
 block discarded – undo
599 599
 	 * @param bool $should_expire
600 600
      * @param WPInv_Subscription $subscription
601 601
 	 */
602
-	public function maybe_renew_subscription( $should_expire, $subscription ) {
602
+	public function maybe_renew_subscription($should_expire, $subscription) {
603 603
 
604 604
         // Ensure its our subscription && it's active.
605
-        if ( $this->id != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) {
605
+        if ($this->id != $subscription->get_gateway() || !$subscription->has_status('active trialling')) {
606 606
             return $should_expire;
607 607
         }
608 608
 
609 609
         // If this is the last renewal, complete the subscription.
610
-        if ( $subscription->is_last_renewal() ) {
610
+        if ($subscription->is_last_renewal()) {
611 611
             $subscription->complete();
612 612
             return false;
613 613
         }
614 614
 
615
-        $this->renew_subscription( $subscription );
615
+        $this->renew_subscription($subscription);
616 616
 
617 617
         return false;
618 618
 
@@ -623,28 +623,28 @@  discard block
 block discarded – undo
623 623
 	 *
624 624
      * @param WPInv_Subscription $subscription
625 625
 	 */
626
-	public function renew_subscription( $subscription ) {
626
+	public function renew_subscription($subscription) {
627 627
 
628 628
 		// Generate the renewal invoice.
629 629
 		$new_invoice = $subscription->create_payment();
630 630
 		$old_invoice = $subscription->get_parent_payment();
631 631
 
632
-        if ( empty( $new_invoice ) ) {
633
-            $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false );
632
+        if (empty($new_invoice)) {
633
+            $old_invoice->add_note(__('Error generating a renewal invoice.', 'invoicing'), false, false, false);
634 634
             $subscription->failing();
635 635
             return;
636 636
         }
637 637
 
638 638
         // Charge the payment method.
639
-		$payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
640
-		$customer_profile   = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true );
641
-		$result             = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice );
639
+		$payment_profile_id = get_post_meta($old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
640
+		$customer_profile   = get_user_meta($old_invoice->get_user_id(), $this->get_customer_profile_meta_name($old_invoice), true);
641
+		$result             = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $new_invoice);
642 642
 
643 643
 		// Do we have an error?
644
-		if ( is_wp_error( $result ) ) {
644
+		if (is_wp_error($result)) {
645 645
 
646 646
 			$old_invoice->add_note(
647
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ),
647
+				sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), $result->get_error_message()),
648 648
 				true,
649 649
 				false,
650 650
 				true
@@ -655,12 +655,12 @@  discard block
 block discarded – undo
655 655
 		}
656 656
 
657 657
 		// Process the response.
658
-		$this->process_charge_response( $result, $new_invoice );
658
+		$this->process_charge_response($result, $new_invoice);
659 659
 
660
-		if ( wpinv_get_errors() ) {
660
+		if (wpinv_get_errors()) {
661 661
 
662 662
 			$old_invoice->add_note(
663
-				sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ),
663
+				sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), getpaid_get_errors_html()),
664 664
 				true,
665 665
 				false,
666 666
 				true
@@ -670,7 +670,7 @@  discard block
 block discarded – undo
670 670
 
671 671
         }
672 672
 
673
-        $subscription->add_payment( array(), $new_invoice );
673
+        $subscription->add_payment(array(), $new_invoice);
674 674
         $subscription->renew();
675 675
     }
676 676
 
@@ -681,34 +681,34 @@  discard block
 block discarded – undo
681 681
 	 * @param GetPaid_Form_Item[] $items
682 682
 	 * @return WPInv_Invoice
683 683
 	 */
684
-	public function process_addons( $invoice, $items ) {
684
+	public function process_addons($invoice, $items) {
685 685
 
686 686
         global $getpaid_authorize_addons;
687 687
 
688 688
         $getpaid_authorize_addons = array();
689
-        foreach ( $items as $item ) {
689
+        foreach ($items as $item) {
690 690
 
691
-            if ( is_null( $invoice->get_item( $item->get_id() ) ) && ! is_wp_error( $invoice->add_item( $item ) ) ) {
691
+            if (is_null($invoice->get_item($item->get_id())) && !is_wp_error($invoice->add_item($item))) {
692 692
                 $getpaid_authorize_addons[] = $item;
693 693
             }
694 694
 
695 695
         }
696 696
 
697
-        if ( empty( $getpaid_authorize_addons ) ) {
697
+        if (empty($getpaid_authorize_addons)) {
698 698
             return;
699 699
         }
700 700
 
701 701
         $invoice->recalculate_total();
702 702
 
703
-        $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true );
704
-		$customer_profile   = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true );
703
+        $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true);
704
+		$customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true);
705 705
 
706
-        add_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ), 10, 2 );
707
-        $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice );
708
-        remove_filter( 'getpaid_authorizenet_charge_customer_payment_profile_args', array( $this, 'filter_addons_request' ) );
706
+        add_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'), 10, 2);
707
+        $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice);
708
+        remove_filter('getpaid_authorizenet_charge_customer_payment_profile_args', array($this, 'filter_addons_request'));
709 709
 
710
-        if ( is_wp_error( $result ) ) {
711
-            wpinv_set_error( $result->get_error_code(), $result->get_error_message() );
710
+        if (is_wp_error($result)) {
711
+            wpinv_set_error($result->get_error_code(), $result->get_error_message());
712 712
             return;
713 713
         }
714 714
 
@@ -721,19 +721,19 @@  discard block
 block discarded – undo
721 721
      * @param array $args
722 722
 	 * @return array
723 723
 	 */
724
-    public function filter_addons_request( $args ) {
724
+    public function filter_addons_request($args) {
725 725
 
726 726
         global $getpaid_authorize_addons;
727 727
         $total = 0;
728 728
 
729
-        foreach ( $getpaid_authorize_addons as $addon ) {
729
+        foreach ($getpaid_authorize_addons as $addon) {
730 730
             $total += $addon->get_sub_total();
731 731
         }
732 732
 
733 733
         $args['createTransactionRequest']['transactionRequest']['amount'] = $total;
734 734
 
735
-        if ( isset( $args['createTransactionRequest']['transactionRequest']['tax'] ) ) {
736
-            unset( $args['createTransactionRequest']['transactionRequest']['tax'] );
735
+        if (isset($args['createTransactionRequest']['transactionRequest']['tax'])) {
736
+            unset($args['createTransactionRequest']['transactionRequest']['tax']);
737 737
         }
738 738
 
739 739
         return $args;
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
     public function sandbox_notice() {
747 747
 
748 748
         return sprintf(
749
-            __( 'SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing' ),
749
+            __('SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing'),
750 750
             '<a href="https://developer.authorize.net/hello_world/testing_guide.html">',
751 751
             '</a>'
752 752
         );
@@ -758,42 +758,42 @@  discard block
 block discarded – undo
758 758
 	 *
759 759
 	 * @param array $admin_settings
760 760
 	 */
761
-	public function admin_settings( $admin_settings ) {
761
+	public function admin_settings($admin_settings) {
762 762
 
763 763
         $currencies = sprintf(
764
-            __( 'Supported Currencies: %s', 'invoicing' ),
765
-            implode( ', ', $this->currencies )
764
+            __('Supported Currencies: %s', 'invoicing'),
765
+            implode(', ', $this->currencies)
766 766
         );
767 767
 
768 768
         $admin_settings['authorizenet_active']['desc'] .= " ($currencies)";
769
-        $admin_settings['authorizenet_desc']['std']     = __( 'Pay securely using your credit or debit card.', 'invoicing' );
769
+        $admin_settings['authorizenet_desc']['std']     = __('Pay securely using your credit or debit card.', 'invoicing');
770 770
 
771 771
         $admin_settings['authorizenet_login_id'] = array(
772 772
             'type' => 'text',
773 773
             'id'   => 'authorizenet_login_id',
774
-            'name' => __( 'API Login ID', 'invoicing' ),
775
-            'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __( 'How do I obtain my API Login ID and Transaction Key?', 'invoicing' ) . '</em></a>',
774
+            'name' => __('API Login ID', 'invoicing'),
775
+            'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __('How do I obtain my API Login ID and Transaction Key?', 'invoicing') . '</em></a>',
776 776
         );
777 777
 
778 778
         $admin_settings['authorizenet_transaction_key'] = array(
779 779
             'type' => 'text',
780 780
             'id'   => 'authorizenet_transaction_key',
781
-            'name' => __( 'Transaction Key', 'invoicing' ),
781
+            'name' => __('Transaction Key', 'invoicing'),
782 782
         );
783 783
 
784 784
         $admin_settings['authorizenet_signature_key'] = array(
785 785
             'type' => 'text',
786 786
             'id'   => 'authorizenet_signature_key',
787
-            'name' => __( 'Signature Key', 'invoicing' ),
788
-            'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
787
+            'name' => __('Signature Key', 'invoicing'),
788
+            'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
789 789
         );
790 790
 
791 791
         $admin_settings['authorizenet_ipn_url'] = array(
792 792
             'type'     => 'ipn_url',
793 793
             'id'       => 'authorizenet_ipn_url',
794
-            'name'     => __( 'Webhook URL', 'invoicing' ),
794
+            'name'     => __('Webhook URL', 'invoicing'),
795 795
             'std'      => $this->notify_url,
796
-            'desc'     => __( 'Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing' ) . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>',
796
+            'desc'     => __('Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing') . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __('Learn more.', 'invoicing') . '</em></a>',
797 797
             'custom'   => 'authorizenet',
798 798
             'readonly' => true,
799 799
         );
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 2 patches
Indentation   +2362 added lines, -2362 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'            => 0,
38
-		'status'               => 'wpi-pending',
39
-		'version'              => '',
40
-		'date_created'         => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'            => 0,
38
+        'status'               => 'wpi-pending',
39
+        'version'              => '',
40
+        'date_created'         => null,
41 41
         'date_modified'        => null,
42 42
         'due_date'             => null,
43 43
         'completed_date'       => null,
@@ -79,22 +79,22 @@  discard block
 block discarded – undo
79 79
         'transaction_id'       => '',
80 80
         'currency'             => '',
81 81
         'disable_taxes'        => false,
82
-		'subscription_id'      => null,
83
-		'remote_subscription_id' => null,
84
-		'is_viewed'            => false,
85
-		'email_cc'             => '',
86
-		'template'             => 'quantity', // hours, amount only
87
-		'created_via'          => null,
82
+        'subscription_id'      => null,
83
+        'remote_subscription_id' => null,
84
+        'is_viewed'            => false,
85
+        'email_cc'             => '',
86
+        'template'             => 'quantity', // hours, amount only
87
+        'created_via'          => null,
88 88
     );
89 89
 
90 90
     /**
91
-	 * Stores meta in cache for future reads.
92
-	 *
93
-	 * A group must be set to to enable caching.
94
-	 *
95
-	 * @var string
96
-	 */
97
-	protected $cache_group = 'getpaid_invoices';
91
+     * Stores meta in cache for future reads.
92
+     *
93
+     * A group must be set to to enable caching.
94
+     *
95
+     * @var string
96
+     */
97
+    protected $cache_group = 'getpaid_invoices';
98 98
 
99 99
     /**
100 100
      * Stores a reference to the original WP_Post object
@@ -108,104 +108,104 @@  discard block
 block discarded – undo
108 108
      *
109 109
      * @var int
110 110
      */
111
-	protected $recurring_item = null;
111
+    protected $recurring_item = null;
112 112
 
113
-	/**
113
+    /**
114 114
      * Stores an array of item totals.
115
-	 *
116
-	 * e.g $totals['discount'] = array(
117
-	 * 		'initial'   => 10,
118
-	 * 		'recurring' => 10,
119
-	 * )
115
+     *
116
+     * e.g $totals['discount'] = array(
117
+     * 		'initial'   => 10,
118
+     * 		'recurring' => 10,
119
+     * )
120 120
      *
121 121
      * @var array
122 122
      */
123
-	protected $totals = array();
123
+    protected $totals = array();
124 124
 
125
-	/**
126
-	 * Stores the status transition information.
127
-	 *
128
-	 * @since 1.0.19
129
-	 * @var bool|array
130
-	 */
131
-	protected $status_transition = false;
125
+    /**
126
+     * Stores the status transition information.
127
+     *
128
+     * @since 1.0.19
129
+     * @var bool|array
130
+     */
131
+    protected $status_transition = false;
132 132
 
133 133
     /**
134
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
135
-	 *
136
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
137
-	 */
134
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
135
+     *
136
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
137
+     */
138 138
     public function __construct( $invoice = 0 ) {
139 139
 
140 140
         parent::__construct( $invoice );
141 141
 
142
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
143
-			$this->set_id( (int) $invoice );
144
-		} elseif ( $invoice instanceof self ) {
145
-			$this->set_id( $invoice->get_id() );
146
-		} elseif ( ! empty( $invoice->ID ) ) {
147
-			$this->set_id( $invoice->ID );
148
-		} elseif ( is_array( $invoice ) ) {
149
-			$this->set_props( $invoice );
150
-
151
-			if ( isset( $invoice['ID'] ) ) {
152
-				$this->set_id( $invoice['ID'] );
153
-			}
154
-
155
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
156
-			$this->set_id( $invoice_id );
157
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
158
-			$this->set_id( $invoice_id );
159
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
160
-			$this->set_id( $invoice_id );
161
-		}else {
162
-			$this->set_object_read( true );
163
-		}
142
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
143
+            $this->set_id( (int) $invoice );
144
+        } elseif ( $invoice instanceof self ) {
145
+            $this->set_id( $invoice->get_id() );
146
+        } elseif ( ! empty( $invoice->ID ) ) {
147
+            $this->set_id( $invoice->ID );
148
+        } elseif ( is_array( $invoice ) ) {
149
+            $this->set_props( $invoice );
150
+
151
+            if ( isset( $invoice['ID'] ) ) {
152
+                $this->set_id( $invoice['ID'] );
153
+            }
154
+
155
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
156
+            $this->set_id( $invoice_id );
157
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
158
+            $this->set_id( $invoice_id );
159
+        } elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
160
+            $this->set_id( $invoice_id );
161
+        }else {
162
+            $this->set_object_read( true );
163
+        }
164 164
 
165 165
         // Load the datastore.
166
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
166
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
167 167
 
168
-		if ( $this->get_id() > 0 ) {
168
+        if ( $this->get_id() > 0 ) {
169 169
             $this->post = get_post( $this->get_id() );
170 170
             $this->ID   = $this->get_id();
171
-			$this->data_store->read( $this );
171
+            $this->data_store->read( $this );
172 172
         }
173 173
 
174 174
     }
175 175
 
176 176
     /**
177
-	 * Given an invoice key/number, it returns its id.
178
-	 *
179
-	 *
180
-	 * @static
181
-	 * @param string $value The invoice key or number
182
-	 * @param string $field Either key, transaction_id or number.
183
-	 * @since 1.0.15
184
-	 * @return int
185
-	 */
186
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
177
+     * Given an invoice key/number, it returns its id.
178
+     *
179
+     *
180
+     * @static
181
+     * @param string $value The invoice key or number
182
+     * @param string $field Either key, transaction_id or number.
183
+     * @since 1.0.15
184
+     * @return int
185
+     */
186
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
187 187
         global $wpdb;
188 188
 
189
-		// Trim the value.
190
-		$value = trim( $value );
189
+        // Trim the value.
190
+        $value = trim( $value );
191 191
 
192
-		if ( empty( $value ) ) {
193
-			return 0;
194
-		}
192
+        if ( empty( $value ) ) {
193
+            return 0;
194
+        }
195 195
 
196 196
         // Valid fields.
197 197
         $fields = array( 'key', 'number', 'transaction_id' );
198 198
 
199
-		// Ensure a field has been passed.
200
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
201
-			return 0;
202
-		}
199
+        // Ensure a field has been passed.
200
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
201
+            return 0;
202
+        }
203 203
 
204
-		// Maybe retrieve from the cache.
205
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
206
-		if ( false !== $invoice_id ) {
207
-			return $invoice_id;
208
-		}
204
+        // Maybe retrieve from the cache.
205
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
206
+        if ( false !== $invoice_id ) {
207
+            return $invoice_id;
208
+        }
209 209
 
210 210
         // Fetch from the db.
211 211
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -213,10 +213,10 @@  discard block
 block discarded – undo
213 213
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
214 214
         );
215 215
 
216
-		// Update the cache with our data
217
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
+        // Update the cache with our data
217
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
218 218
 
219
-		return $invoice_id;
219
+        return $invoice_id;
220 220
     }
221 221
 
222 222
     /**
@@ -242,72 +242,72 @@  discard block
 block discarded – undo
242 242
     */
243 243
 
244 244
     /**
245
-	 * Get parent invoice ID.
246
-	 *
247
-	 * @since 1.0.19
248
-	 * @param  string $context View or edit context.
249
-	 * @return int
250
-	 */
251
-	public function get_parent_id( $context = 'view' ) {
252
-		return (int) $this->get_prop( 'parent_id', $context );
245
+     * Get parent invoice ID.
246
+     *
247
+     * @since 1.0.19
248
+     * @param  string $context View or edit context.
249
+     * @return int
250
+     */
251
+    public function get_parent_id( $context = 'view' ) {
252
+        return (int) $this->get_prop( 'parent_id', $context );
253 253
     }
254 254
 
255 255
     /**
256
-	 * Get parent invoice.
257
-	 *
258
-	 * @since 1.0.19
259
-	 * @return WPInv_Invoice
260
-	 */
256
+     * Get parent invoice.
257
+     *
258
+     * @since 1.0.19
259
+     * @return WPInv_Invoice
260
+     */
261 261
     public function get_parent_payment() {
262 262
         return new WPInv_Invoice( $this->get_parent_id() );
263 263
     }
264 264
 
265 265
     /**
266
-	 * Alias for self::get_parent_payment().
267
-	 *
268
-	 * @since 1.0.19
269
-	 * @return WPInv_Invoice
270
-	 */
266
+     * Alias for self::get_parent_payment().
267
+     *
268
+     * @since 1.0.19
269
+     * @return WPInv_Invoice
270
+     */
271 271
     public function get_parent() {
272 272
         return $this->get_parent_payment();
273 273
     }
274 274
 
275 275
     /**
276
-	 * Get invoice status.
277
-	 *
278
-	 * @since 1.0.19
279
-	 * @param  string $context View or edit context.
280
-	 * @return string
281
-	 */
282
-	public function get_status( $context = 'view' ) {
283
-		return $this->get_prop( 'status', $context );
284
-	}
276
+     * Get invoice status.
277
+     *
278
+     * @since 1.0.19
279
+     * @param  string $context View or edit context.
280
+     * @return string
281
+     */
282
+    public function get_status( $context = 'view' ) {
283
+        return $this->get_prop( 'status', $context );
284
+    }
285 285
 	
286
-	/**
287
-	 * Retrieves an array of possible invoice statuses.
288
-	 *
289
-	 * @since 1.0.19
290
-	 * @return array
291
-	 */
292
-	public function get_all_statuses() {
293
-		return wpinv_get_invoice_statuses( true, true, $this );
294
-    }
295
-
296
-    /**
297
-	 * Get invoice status nice name.
298
-	 *
299
-	 * @since 1.0.19
300
-	 * @return string
301
-	 */
286
+    /**
287
+     * Retrieves an array of possible invoice statuses.
288
+     *
289
+     * @since 1.0.19
290
+     * @return array
291
+     */
292
+    public function get_all_statuses() {
293
+        return wpinv_get_invoice_statuses( true, true, $this );
294
+    }
295
+
296
+    /**
297
+     * Get invoice status nice name.
298
+     *
299
+     * @since 1.0.19
300
+     * @return string
301
+     */
302 302
     public function get_status_nicename() {
303
-		$statuses = $this->get_all_statuses();
303
+        $statuses = $this->get_all_statuses();
304 304
 
305 305
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
306 306
 
307 307
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
308 308
     }
309 309
 
310
-	/**
310
+    /**
311 311
      * Retrieves the invoice status label html
312 312
      *
313 313
      * @since  1.0.0
@@ -315,262 +315,262 @@  discard block
 block discarded – undo
315 315
      */
316 316
     public function get_status_label_html() {
317 317
 
318
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
319
-		$status       = sanitize_html_class( $this->get_status() );
318
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
319
+        $status       = sanitize_html_class( $this->get_status() );
320 320
 
321
-		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
322
-	}
321
+        return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
322
+    }
323 323
 
324 324
     /**
325
-	 * Get plugin version when the invoice was created.
326
-	 *
327
-	 * @since 1.0.19
328
-	 * @param  string $context View or edit context.
329
-	 * @return string
330
-	 */
331
-	public function get_version( $context = 'view' ) {
332
-		return $this->get_prop( 'version', $context );
333
-	}
325
+     * Get plugin version when the invoice was created.
326
+     *
327
+     * @since 1.0.19
328
+     * @param  string $context View or edit context.
329
+     * @return string
330
+     */
331
+    public function get_version( $context = 'view' ) {
332
+        return $this->get_prop( 'version', $context );
333
+    }
334 334
 
335
-	/**
336
-	 * @deprecated
337
-	 */
338
-	public function get_invoice_date( $format = true ) {
339
-		$date      = getpaid_format_date( $this->get_date_completed() );
340
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
341
-		$formatted = getpaid_format_date( $date );
335
+    /**
336
+     * @deprecated
337
+     */
338
+    public function get_invoice_date( $format = true ) {
339
+        $date      = getpaid_format_date( $this->get_date_completed() );
340
+        $date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
341
+        $formatted = getpaid_format_date( $date );
342 342
 
343
-		if ( $format ) {
344
-			return $formatted;
345
-		}
343
+        if ( $format ) {
344
+            return $formatted;
345
+        }
346 346
 
347
-		return empty( $formatted ) ? '' : $date;
347
+        return empty( $formatted ) ? '' : $date;
348 348
 
349 349
     }
350 350
 
351 351
     /**
352
-	 * Get date when the invoice was created.
353
-	 *
354
-	 * @since 1.0.19
355
-	 * @param  string $context View or edit context.
356
-	 * @return string
357
-	 */
358
-	public function get_date_created( $context = 'view' ) {
359
-		return $this->get_prop( 'date_created', $context );
360
-	}
352
+     * Get date when the invoice was created.
353
+     *
354
+     * @since 1.0.19
355
+     * @param  string $context View or edit context.
356
+     * @return string
357
+     */
358
+    public function get_date_created( $context = 'view' ) {
359
+        return $this->get_prop( 'date_created', $context );
360
+    }
361 361
 	
362
-	/**
363
-	 * Alias for self::get_date_created().
364
-	 *
365
-	 * @since 1.0.19
366
-	 * @param  string $context View or edit context.
367
-	 * @return string
368
-	 */
369
-	public function get_created_date( $context = 'view' ) {
370
-		return $this->get_date_created( $context );
371
-    }
372
-
373
-    /**
374
-	 * Get GMT date when the invoice was created.
375
-	 *
376
-	 * @since 1.0.19
377
-	 * @param  string $context View or edit context.
378
-	 * @return string
379
-	 */
380
-	public function get_date_created_gmt( $context = 'view' ) {
362
+    /**
363
+     * Alias for self::get_date_created().
364
+     *
365
+     * @since 1.0.19
366
+     * @param  string $context View or edit context.
367
+     * @return string
368
+     */
369
+    public function get_created_date( $context = 'view' ) {
370
+        return $this->get_date_created( $context );
371
+    }
372
+
373
+    /**
374
+     * Get GMT date when the invoice was created.
375
+     *
376
+     * @since 1.0.19
377
+     * @param  string $context View or edit context.
378
+     * @return string
379
+     */
380
+    public function get_date_created_gmt( $context = 'view' ) {
381 381
         $date = $this->get_date_created( $context );
382 382
 
383 383
         if ( $date ) {
384 384
             $date = get_gmt_from_date( $date );
385 385
         }
386
-		return $date;
386
+        return $date;
387 387
     }
388 388
 
389 389
     /**
390
-	 * Get date when the invoice was last modified.
391
-	 *
392
-	 * @since 1.0.19
393
-	 * @param  string $context View or edit context.
394
-	 * @return string
395
-	 */
396
-	public function get_date_modified( $context = 'view' ) {
397
-		return $this->get_prop( 'date_modified', $context );
398
-	}
390
+     * Get date when the invoice was last modified.
391
+     *
392
+     * @since 1.0.19
393
+     * @param  string $context View or edit context.
394
+     * @return string
395
+     */
396
+    public function get_date_modified( $context = 'view' ) {
397
+        return $this->get_prop( 'date_modified', $context );
398
+    }
399 399
 
400
-	/**
401
-	 * Alias for self::get_date_modified().
402
-	 *
403
-	 * @since 1.0.19
404
-	 * @param  string $context View or edit context.
405
-	 * @return string
406
-	 */
407
-	public function get_modified_date( $context = 'view' ) {
408
-		return $this->get_date_modified( $context );
400
+    /**
401
+     * Alias for self::get_date_modified().
402
+     *
403
+     * @since 1.0.19
404
+     * @param  string $context View or edit context.
405
+     * @return string
406
+     */
407
+    public function get_modified_date( $context = 'view' ) {
408
+        return $this->get_date_modified( $context );
409 409
     }
410 410
 
411 411
     /**
412
-	 * Get GMT date when the invoice was last modified.
413
-	 *
414
-	 * @since 1.0.19
415
-	 * @param  string $context View or edit context.
416
-	 * @return string
417
-	 */
418
-	public function get_date_modified_gmt( $context = 'view' ) {
412
+     * Get GMT date when the invoice was last modified.
413
+     *
414
+     * @since 1.0.19
415
+     * @param  string $context View or edit context.
416
+     * @return string
417
+     */
418
+    public function get_date_modified_gmt( $context = 'view' ) {
419 419
         $date = $this->get_date_modified( $context );
420 420
 
421 421
         if ( $date ) {
422 422
             $date = get_gmt_from_date( $date );
423 423
         }
424
-		return $date;
424
+        return $date;
425 425
     }
426 426
 
427 427
     /**
428
-	 * Get the invoice due date.
429
-	 *
430
-	 * @since 1.0.19
431
-	 * @param  string $context View or edit context.
432
-	 * @return string
433
-	 */
434
-	public function get_due_date( $context = 'view' ) {
435
-		return $this->get_prop( 'due_date', $context );
428
+     * Get the invoice due date.
429
+     *
430
+     * @since 1.0.19
431
+     * @param  string $context View or edit context.
432
+     * @return string
433
+     */
434
+    public function get_due_date( $context = 'view' ) {
435
+        return $this->get_prop( 'due_date', $context );
436 436
     }
437 437
 
438 438
     /**
439
-	 * Alias for self::get_due_date().
440
-	 *
441
-	 * @since 1.0.19
442
-	 * @param  string $context View or edit context.
443
-	 * @return string
444
-	 */
445
-	public function get_date_due( $context = 'view' ) {
446
-		return $this->get_due_date( $context );
439
+     * Alias for self::get_due_date().
440
+     *
441
+     * @since 1.0.19
442
+     * @param  string $context View or edit context.
443
+     * @return string
444
+     */
445
+    public function get_date_due( $context = 'view' ) {
446
+        return $this->get_due_date( $context );
447 447
     }
448 448
 
449 449
     /**
450
-	 * Get the invoice GMT due date.
451
-	 *
452
-	 * @since 1.0.19
453
-	 * @param  string $context View or edit context.
454
-	 * @return string
455
-	 */
456
-	public function get_due_date_gmt( $context = 'view' ) {
450
+     * Get the invoice GMT due date.
451
+     *
452
+     * @since 1.0.19
453
+     * @param  string $context View or edit context.
454
+     * @return string
455
+     */
456
+    public function get_due_date_gmt( $context = 'view' ) {
457 457
         $date = $this->get_due_date( $context );
458 458
 
459 459
         if ( $date ) {
460 460
             $date = get_gmt_from_date( $date );
461 461
         }
462
-		return $date;
462
+        return $date;
463 463
     }
464 464
 
465 465
     /**
466
-	 * Alias for self::get_due_date_gmt().
467
-	 *
468
-	 * @since 1.0.19
469
-	 * @param  string $context View or edit context.
470
-	 * @return string
471
-	 */
472
-	public function get_gmt_date_due( $context = 'view' ) {
473
-		return $this->get_due_date_gmt( $context );
466
+     * Alias for self::get_due_date_gmt().
467
+     *
468
+     * @since 1.0.19
469
+     * @param  string $context View or edit context.
470
+     * @return string
471
+     */
472
+    public function get_gmt_date_due( $context = 'view' ) {
473
+        return $this->get_due_date_gmt( $context );
474 474
     }
475 475
 
476 476
     /**
477
-	 * Get date when the invoice was completed.
478
-	 *
479
-	 * @since 1.0.19
480
-	 * @param  string $context View or edit context.
481
-	 * @return string
482
-	 */
483
-	public function get_completed_date( $context = 'view' ) {
484
-		return $this->get_prop( 'completed_date', $context );
477
+     * Get date when the invoice was completed.
478
+     *
479
+     * @since 1.0.19
480
+     * @param  string $context View or edit context.
481
+     * @return string
482
+     */
483
+    public function get_completed_date( $context = 'view' ) {
484
+        return $this->get_prop( 'completed_date', $context );
485 485
     }
486 486
 
487 487
     /**
488
-	 * Alias for self::get_completed_date().
489
-	 *
490
-	 * @since 1.0.19
491
-	 * @param  string $context View or edit context.
492
-	 * @return string
493
-	 */
494
-	public function get_date_completed( $context = 'view' ) {
495
-		return $this->get_completed_date( $context );
488
+     * Alias for self::get_completed_date().
489
+     *
490
+     * @since 1.0.19
491
+     * @param  string $context View or edit context.
492
+     * @return string
493
+     */
494
+    public function get_date_completed( $context = 'view' ) {
495
+        return $this->get_completed_date( $context );
496 496
     }
497 497
 
498 498
     /**
499
-	 * Get GMT date when the invoice was was completed.
500
-	 *
501
-	 * @since 1.0.19
502
-	 * @param  string $context View or edit context.
503
-	 * @return string
504
-	 */
505
-	public function get_completed_date_gmt( $context = 'view' ) {
499
+     * Get GMT date when the invoice was was completed.
500
+     *
501
+     * @since 1.0.19
502
+     * @param  string $context View or edit context.
503
+     * @return string
504
+     */
505
+    public function get_completed_date_gmt( $context = 'view' ) {
506 506
         $date = $this->get_completed_date( $context );
507 507
 
508 508
         if ( $date ) {
509 509
             $date = get_gmt_from_date( $date );
510 510
         }
511
-		return $date;
511
+        return $date;
512 512
     }
513 513
 
514 514
     /**
515
-	 * Alias for self::get_completed_date_gmt().
516
-	 *
517
-	 * @since 1.0.19
518
-	 * @param  string $context View or edit context.
519
-	 * @return string
520
-	 */
521
-	public function get_gmt_completed_date( $context = 'view' ) {
522
-		return $this->get_completed_date_gmt( $context );
515
+     * Alias for self::get_completed_date_gmt().
516
+     *
517
+     * @since 1.0.19
518
+     * @param  string $context View or edit context.
519
+     * @return string
520
+     */
521
+    public function get_gmt_completed_date( $context = 'view' ) {
522
+        return $this->get_completed_date_gmt( $context );
523 523
     }
524 524
 
525 525
     /**
526
-	 * Get the invoice number.
527
-	 *
528
-	 * @since 1.0.19
529
-	 * @param  string $context View or edit context.
530
-	 * @return string
531
-	 */
532
-	public function get_number( $context = 'view' ) {
533
-		$number = $this->get_prop( 'number', $context );
526
+     * Get the invoice number.
527
+     *
528
+     * @since 1.0.19
529
+     * @param  string $context View or edit context.
530
+     * @return string
531
+     */
532
+    public function get_number( $context = 'view' ) {
533
+        $number = $this->get_prop( 'number', $context );
534 534
 
535
-		if ( empty( $number ) ) {
536
-			$number = $this->generate_number();
537
-			$this->set_number( $this->generate_number() );
538
-		}
535
+        if ( empty( $number ) ) {
536
+            $number = $this->generate_number();
537
+            $this->set_number( $this->generate_number() );
538
+        }
539 539
 
540
-		return $number;
540
+        return $number;
541 541
     }
542 542
 
543
-	/**
544
-	 * Set the invoice number.
545
-	 *
546
-	 * @since 1.0.19
547
-	 */
548
-	public function maybe_set_number() {
543
+    /**
544
+     * Set the invoice number.
545
+     *
546
+     * @since 1.0.19
547
+     */
548
+    public function maybe_set_number() {
549 549
         $number = $this->get_number();
550 550
 
551 551
         if ( empty( $number ) || $this->get_id() == $number ) {
552
-			$this->set_number( $this->generate_number() );
552
+            $this->set_number( $this->generate_number() );
553 553
         }
554 554
 
555
-	}
555
+    }
556 556
 
557 557
     /**
558
-	 * Get the invoice key.
559
-	 *
560
-	 * @since 1.0.19
561
-	 * @param  string $context View or edit context.
562
-	 * @return string
563
-	 */
564
-	public function get_key( $context = 'view' ) {
558
+     * Get the invoice key.
559
+     *
560
+     * @since 1.0.19
561
+     * @param  string $context View or edit context.
562
+     * @return string
563
+     */
564
+    public function get_key( $context = 'view' ) {
565 565
         return $this->get_prop( 'key', $context );
566
-	}
567
-
568
-	/**
569
-	 * Set the invoice key.
570
-	 *
571
-	 * @since 1.0.19
572
-	 */
573
-	public function maybe_set_key() {
566
+    }
567
+
568
+    /**
569
+     * Set the invoice key.
570
+     *
571
+     * @since 1.0.19
572
+     */
573
+    public function maybe_set_key() {
574 574
         $key = $this->get_key();
575 575
 
576 576
         if ( empty( $key ) ) {
@@ -581,129 +581,129 @@  discard block
 block discarded – undo
581 581
     }
582 582
 
583 583
     /**
584
-	 * Get the invoice type.
585
-	 *
586
-	 * @since 1.0.19
587
-	 * @param  string $context View or edit context.
588
-	 * @return string
589
-	 */
590
-	public function get_type( $context = 'view' ) {
584
+     * Get the invoice type.
585
+     *
586
+     * @since 1.0.19
587
+     * @param  string $context View or edit context.
588
+     * @return string
589
+     */
590
+    public function get_type( $context = 'view' ) {
591 591
         return $this->get_prop( 'type', $context );
592
-	}
593
-
594
-	/**
595
-	 * Returns the post type name.
596
-	 *
597
-	 * @since 1.0.19
598
-	 * @return string
599
-	 */
600
-	public function get_invoice_quote_type() {
592
+    }
593
+
594
+    /**
595
+     * Returns the post type name.
596
+     *
597
+     * @since 1.0.19
598
+     * @return string
599
+     */
600
+    public function get_invoice_quote_type() {
601 601
         return getpaid_get_post_type_label( $this->get_post_type(), false );
602 602
     }
603 603
 
604 604
     /**
605
-	 * Get the invoice post type.
606
-	 *
607
-	 * @since 1.0.19
608
-	 * @param  string $context View or edit context.
609
-	 * @return string
610
-	 */
611
-	public function get_post_type( $context = 'view' ) {
605
+     * Get the invoice post type.
606
+     *
607
+     * @since 1.0.19
608
+     * @param  string $context View or edit context.
609
+     * @return string
610
+     */
611
+    public function get_post_type( $context = 'view' ) {
612 612
         return $this->get_prop( 'post_type', $context );
613 613
     }
614 614
 
615 615
     /**
616
-	 * Get the invoice mode.
617
-	 *
618
-	 * @since 1.0.19
619
-	 * @param  string $context View or edit context.
620
-	 * @return string
621
-	 */
622
-	public function get_mode( $context = 'view' ) {
616
+     * Get the invoice mode.
617
+     *
618
+     * @since 1.0.19
619
+     * @param  string $context View or edit context.
620
+     * @return string
621
+     */
622
+    public function get_mode( $context = 'view' ) {
623 623
         return $this->get_prop( 'mode', $context );
624 624
     }
625 625
 
626 626
     /**
627
-	 * Get the invoice path.
628
-	 *
629
-	 * @since 1.0.19
630
-	 * @param  string $context View or edit context.
631
-	 * @return string
632
-	 */
633
-	public function get_path( $context = 'view' ) {
627
+     * Get the invoice path.
628
+     *
629
+     * @since 1.0.19
630
+     * @param  string $context View or edit context.
631
+     * @return string
632
+     */
633
+    public function get_path( $context = 'view' ) {
634 634
         $path   = $this->get_prop( 'path', $context );
635
-		$prefix = $this->get_type();
635
+        $prefix = $this->get_type();
636 636
 
637
-		if ( 0 !== strpos( $path, $prefix ) ) {
638
-			$path = sanitize_title(  $prefix . '-' . $this->get_id()  );
639
-			$this->set_path( $path );
640
-		}
637
+        if ( 0 !== strpos( $path, $prefix ) ) {
638
+            $path = sanitize_title(  $prefix . '-' . $this->get_id()  );
639
+            $this->set_path( $path );
640
+        }
641 641
 
642
-		return $path;
642
+        return $path;
643 643
     }
644 644
 
645 645
     /**
646
-	 * Get the invoice name/title.
647
-	 *
648
-	 * @since 1.0.19
649
-	 * @param  string $context View or edit context.
650
-	 * @return string
651
-	 */
652
-	public function get_name( $context = 'view' ) {
646
+     * Get the invoice name/title.
647
+     *
648
+     * @since 1.0.19
649
+     * @param  string $context View or edit context.
650
+     * @return string
651
+     */
652
+    public function get_name( $context = 'view' ) {
653 653
         return $this->get_prop( 'title', $context );
654 654
     }
655 655
 
656 656
     /**
657
-	 * Alias of self::get_name().
658
-	 *
659
-	 * @since 1.0.19
660
-	 * @param  string $context View or edit context.
661
-	 * @return string
662
-	 */
663
-	public function get_title( $context = 'view' ) {
664
-		return $this->get_name( $context );
657
+     * Alias of self::get_name().
658
+     *
659
+     * @since 1.0.19
660
+     * @param  string $context View or edit context.
661
+     * @return string
662
+     */
663
+    public function get_title( $context = 'view' ) {
664
+        return $this->get_name( $context );
665 665
     }
666 666
 
667 667
     /**
668
-	 * Get the invoice description.
669
-	 *
670
-	 * @since 1.0.19
671
-	 * @param  string $context View or edit context.
672
-	 * @return string
673
-	 */
674
-	public function get_description( $context = 'view' ) {
675
-		return $this->get_prop( 'description', $context );
668
+     * Get the invoice description.
669
+     *
670
+     * @since 1.0.19
671
+     * @param  string $context View or edit context.
672
+     * @return string
673
+     */
674
+    public function get_description( $context = 'view' ) {
675
+        return $this->get_prop( 'description', $context );
676 676
     }
677 677
 
678 678
     /**
679
-	 * Alias of self::get_description().
680
-	 *
681
-	 * @since 1.0.19
682
-	 * @param  string $context View or edit context.
683
-	 * @return string
684
-	 */
685
-	public function get_excerpt( $context = 'view' ) {
686
-		return $this->get_description( $context );
679
+     * Alias of self::get_description().
680
+     *
681
+     * @since 1.0.19
682
+     * @param  string $context View or edit context.
683
+     * @return string
684
+     */
685
+    public function get_excerpt( $context = 'view' ) {
686
+        return $this->get_description( $context );
687 687
     }
688 688
 
689 689
     /**
690
-	 * Alias of self::get_description().
691
-	 *
692
-	 * @since 1.0.19
693
-	 * @param  string $context View or edit context.
694
-	 * @return string
695
-	 */
696
-	public function get_summary( $context = 'view' ) {
697
-		return $this->get_description( $context );
690
+     * Alias of self::get_description().
691
+     *
692
+     * @since 1.0.19
693
+     * @param  string $context View or edit context.
694
+     * @return string
695
+     */
696
+    public function get_summary( $context = 'view' ) {
697
+        return $this->get_description( $context );
698 698
     }
699 699
 
700 700
     /**
701
-	 * Returns the user info.
702
-	 *
703
-	 * @since 1.0.19
701
+     * Returns the user info.
702
+     *
703
+     * @since 1.0.19
704 704
      * @param  string $context View or edit context.
705
-	 * @return array
706
-	 */
705
+     * @return array
706
+     */
707 707
     public function get_user_info( $context = 'view' ) {
708 708
 
709 709
         $user_info = array(
@@ -720,616 +720,616 @@  discard block
 block discarded – undo
720 720
             'company'    => $this->get_company( $context ),
721 721
             'vat_number' => $this->get_vat_number( $context ),
722 722
             'discount'   => $this->get_discount_code( $context ),
723
-		);
723
+        );
724
+
725
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
726
+
727
+    }
728
+
729
+    /**
730
+     * Get the customer id.
731
+     *
732
+     * @since 1.0.19
733
+     * @param  string $context View or edit context.
734
+     * @return int
735
+     */
736
+    public function get_author( $context = 'view' ) {
737
+        return (int) $this->get_prop( 'author', $context );
738
+    }
739
+
740
+    /**
741
+     * Alias of self::get_author().
742
+     *
743
+     * @since 1.0.19
744
+     * @param  string $context View or edit context.
745
+     * @return int
746
+     */
747
+    public function get_user_id( $context = 'view' ) {
748
+        return $this->get_author( $context );
749
+    }
750
+
751
+        /**
752
+         * Alias of self::get_author().
753
+         *
754
+         * @since 1.0.19
755
+         * @param  string $context View or edit context.
756
+         * @return int
757
+         */
758
+    public function get_customer_id( $context = 'view' ) {
759
+        return $this->get_author( $context );
760
+    }
761
+
762
+    /**
763
+     * Get the customer's ip.
764
+     *
765
+     * @since 1.0.19
766
+     * @param  string $context View or edit context.
767
+     * @return string
768
+     */
769
+    public function get_ip( $context = 'view' ) {
770
+        return $this->get_prop( 'user_ip', $context );
771
+    }
772
+
773
+    /**
774
+     * Alias of self::get_ip().
775
+     *
776
+     * @since 1.0.19
777
+     * @param  string $context View or edit context.
778
+     * @return string
779
+     */
780
+    public function get_user_ip( $context = 'view' ) {
781
+        return $this->get_ip( $context );
782
+    }
724 783
 
725
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
784
+        /**
785
+         * Alias of self::get_ip().
786
+         *
787
+         * @since 1.0.19
788
+         * @param  string $context View or edit context.
789
+         * @return string
790
+         */
791
+    public function get_customer_ip( $context = 'view' ) {
792
+        return $this->get_ip( $context );
793
+    }
726 794
 
795
+    /**
796
+     * Get the customer's first name.
797
+     *
798
+     * @since 1.0.19
799
+     * @param  string $context View or edit context.
800
+     * @return string
801
+     */
802
+    public function get_first_name( $context = 'view' ) {
803
+        return $this->get_prop( 'first_name', $context );
727 804
     }
728 805
 
729 806
     /**
730
-	 * Get the customer id.
731
-	 *
732
-	 * @since 1.0.19
733
-	 * @param  string $context View or edit context.
734
-	 * @return int
735
-	 */
736
-	public function get_author( $context = 'view' ) {
737
-		return (int) $this->get_prop( 'author', $context );
807
+     * Alias of self::get_first_name().
808
+     *
809
+     * @since 1.0.19
810
+     * @param  string $context View or edit context.
811
+     * @return string
812
+     */
813
+    public function get_user_first_name( $context = 'view' ) {
814
+        return $this->get_first_name( $context );
815
+    }
816
+
817
+        /**
818
+         * Alias of self::get_first_name().
819
+         *
820
+         * @since 1.0.19
821
+         * @param  string $context View or edit context.
822
+         * @return string
823
+         */
824
+    public function get_customer_first_name( $context = 'view' ) {
825
+        return $this->get_first_name( $context );
738 826
     }
739 827
 
740 828
     /**
741
-	 * Alias of self::get_author().
742
-	 *
743
-	 * @since 1.0.19
744
-	 * @param  string $context View or edit context.
745
-	 * @return int
746
-	 */
747
-	public function get_user_id( $context = 'view' ) {
748
-		return $this->get_author( $context );
829
+     * Get the customer's last name.
830
+     *
831
+     * @since 1.0.19
832
+     * @param  string $context View or edit context.
833
+     * @return string
834
+     */
835
+    public function get_last_name( $context = 'view' ) {
836
+        return $this->get_prop( 'last_name', $context );
749 837
     }
750 838
 
751
-     /**
752
-	 * Alias of self::get_author().
753
-	 *
754
-	 * @since 1.0.19
755
-	 * @param  string $context View or edit context.
756
-	 * @return int
757
-	 */
758
-	public function get_customer_id( $context = 'view' ) {
759
-		return $this->get_author( $context );
839
+    /**
840
+     * Alias of self::get_last_name().
841
+     *
842
+     * @since 1.0.19
843
+     * @param  string $context View or edit context.
844
+     * @return string
845
+     */
846
+    public function get_user_last_name( $context = 'view' ) {
847
+        return $this->get_last_name( $context );
760 848
     }
761 849
 
762 850
     /**
763
-	 * Get the customer's ip.
764
-	 *
765
-	 * @since 1.0.19
766
-	 * @param  string $context View or edit context.
767
-	 * @return string
768
-	 */
769
-	public function get_ip( $context = 'view' ) {
770
-		return $this->get_prop( 'user_ip', $context );
851
+     * Alias of self::get_last_name().
852
+     *
853
+     * @since 1.0.19
854
+     * @param  string $context View or edit context.
855
+     * @return string
856
+     */
857
+    public function get_customer_last_name( $context = 'view' ) {
858
+        return $this->get_last_name( $context );
771 859
     }
772 860
 
773 861
     /**
774
-	 * Alias of self::get_ip().
775
-	 *
776
-	 * @since 1.0.19
777
-	 * @param  string $context View or edit context.
778
-	 * @return string
779
-	 */
780
-	public function get_user_ip( $context = 'view' ) {
781
-		return $this->get_ip( $context );
862
+     * Get the customer's full name.
863
+     *
864
+     * @since 1.0.19
865
+     * @param  string $context View or edit context.
866
+     * @return string
867
+     */
868
+    public function get_full_name( $context = 'view' ) {
869
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
782 870
     }
783 871
 
784
-     /**
785
-	 * Alias of self::get_ip().
786
-	 *
787
-	 * @since 1.0.19
788
-	 * @param  string $context View or edit context.
789
-	 * @return string
790
-	 */
791
-	public function get_customer_ip( $context = 'view' ) {
792
-		return $this->get_ip( $context );
872
+    /**
873
+     * Alias of self::get_full_name().
874
+     *
875
+     * @since 1.0.19
876
+     * @param  string $context View or edit context.
877
+     * @return string
878
+     */
879
+    public function get_user_full_name( $context = 'view' ) {
880
+        return $this->get_full_name( $context );
793 881
     }
794 882
 
795 883
     /**
796
-	 * Get the customer's first name.
797
-	 *
798
-	 * @since 1.0.19
799
-	 * @param  string $context View or edit context.
800
-	 * @return string
801
-	 */
802
-	public function get_first_name( $context = 'view' ) {
803
-		return $this->get_prop( 'first_name', $context );
884
+     * Alias of self::get_full_name().
885
+     *
886
+     * @since 1.0.19
887
+     * @param  string $context View or edit context.
888
+     * @return string
889
+     */
890
+    public function get_customer_full_name( $context = 'view' ) {
891
+        return $this->get_full_name( $context );
804 892
     }
805 893
 
806 894
     /**
807
-	 * Alias of self::get_first_name().
808
-	 *
809
-	 * @since 1.0.19
810
-	 * @param  string $context View or edit context.
811
-	 * @return string
812
-	 */
813
-	public function get_user_first_name( $context = 'view' ) {
814
-		return $this->get_first_name( $context );
895
+     * Get the customer's phone number.
896
+     *
897
+     * @since 1.0.19
898
+     * @param  string $context View or edit context.
899
+     * @return string
900
+     */
901
+    public function get_phone( $context = 'view' ) {
902
+        return $this->get_prop( 'phone', $context );
815 903
     }
816 904
 
817
-     /**
818
-	 * Alias of self::get_first_name().
819
-	 *
820
-	 * @since 1.0.19
821
-	 * @param  string $context View or edit context.
822
-	 * @return string
823
-	 */
824
-	public function get_customer_first_name( $context = 'view' ) {
825
-		return $this->get_first_name( $context );
905
+    /**
906
+     * Alias of self::get_phone().
907
+     *
908
+     * @since 1.0.19
909
+     * @param  string $context View or edit context.
910
+     * @return string
911
+     */
912
+    public function get_phone_number( $context = 'view' ) {
913
+        return $this->get_phone( $context );
826 914
     }
827 915
 
828 916
     /**
829
-	 * Get the customer's last name.
830
-	 *
831
-	 * @since 1.0.19
832
-	 * @param  string $context View or edit context.
833
-	 * @return string
834
-	 */
835
-	public function get_last_name( $context = 'view' ) {
836
-		return $this->get_prop( 'last_name', $context );
917
+     * Alias of self::get_phone().
918
+     *
919
+     * @since 1.0.19
920
+     * @param  string $context View or edit context.
921
+     * @return string
922
+     */
923
+    public function get_user_phone( $context = 'view' ) {
924
+        return $this->get_phone( $context );
837 925
     }
838 926
 
839 927
     /**
840
-	 * Alias of self::get_last_name().
841
-	 *
842
-	 * @since 1.0.19
843
-	 * @param  string $context View or edit context.
844
-	 * @return string
845
-	 */
846
-	public function get_user_last_name( $context = 'view' ) {
847
-		return $this->get_last_name( $context );
928
+     * Alias of self::get_phone().
929
+     *
930
+     * @since 1.0.19
931
+     * @param  string $context View or edit context.
932
+     * @return string
933
+     */
934
+    public function get_customer_phone( $context = 'view' ) {
935
+        return $this->get_phone( $context );
848 936
     }
849 937
 
850 938
     /**
851
-	 * Alias of self::get_last_name().
852
-	 *
853
-	 * @since 1.0.19
854
-	 * @param  string $context View or edit context.
855
-	 * @return string
856
-	 */
857
-	public function get_customer_last_name( $context = 'view' ) {
858
-		return $this->get_last_name( $context );
939
+     * Get the customer's email address.
940
+     *
941
+     * @since 1.0.19
942
+     * @param  string $context View or edit context.
943
+     * @return string
944
+     */
945
+    public function get_email( $context = 'view' ) {
946
+        return $this->get_prop( 'email', $context );
859 947
     }
860 948
 
861 949
     /**
862
-	 * Get the customer's full name.
863
-	 *
864
-	 * @since 1.0.19
865
-	 * @param  string $context View or edit context.
866
-	 * @return string
867
-	 */
868
-	public function get_full_name( $context = 'view' ) {
869
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
950
+     * Alias of self::get_email().
951
+     *
952
+     * @since 1.0.19
953
+     * @param  string $context View or edit context.
954
+     * @return string
955
+     */
956
+    public function get_email_address( $context = 'view' ) {
957
+        return $this->get_email( $context );
870 958
     }
871 959
 
872 960
     /**
873
-	 * Alias of self::get_full_name().
874
-	 *
875
-	 * @since 1.0.19
876
-	 * @param  string $context View or edit context.
877
-	 * @return string
878
-	 */
879
-	public function get_user_full_name( $context = 'view' ) {
880
-		return $this->get_full_name( $context );
961
+     * Alias of self::get_email().
962
+     *
963
+     * @since 1.0.19
964
+     * @param  string $context View or edit context.
965
+     * @return string
966
+     */
967
+    public function get_user_email( $context = 'view' ) {
968
+        return $this->get_email( $context );
881 969
     }
882 970
 
883 971
     /**
884
-	 * Alias of self::get_full_name().
885
-	 *
886
-	 * @since 1.0.19
887
-	 * @param  string $context View or edit context.
888
-	 * @return string
889
-	 */
890
-	public function get_customer_full_name( $context = 'view' ) {
891
-		return $this->get_full_name( $context );
972
+     * Alias of self::get_email().
973
+     *
974
+     * @since 1.0.19
975
+     * @param  string $context View or edit context.
976
+     * @return string
977
+     */
978
+    public function get_customer_email( $context = 'view' ) {
979
+        return $this->get_email( $context );
892 980
     }
893 981
 
894 982
     /**
895
-	 * Get the customer's phone number.
896
-	 *
897
-	 * @since 1.0.19
898
-	 * @param  string $context View or edit context.
899
-	 * @return string
900
-	 */
901
-	public function get_phone( $context = 'view' ) {
902
-		return $this->get_prop( 'phone', $context );
983
+     * Get the customer's country.
984
+     *
985
+     * @since 1.0.19
986
+     * @param  string $context View or edit context.
987
+     * @return string
988
+     */
989
+    public function get_country( $context = 'view' ) {
990
+        $country = $this->get_prop( 'country', $context );
991
+        return empty( $country ) ? wpinv_get_default_country() : $country;
903 992
     }
904 993
 
905 994
     /**
906
-	 * Alias of self::get_phone().
907
-	 *
908
-	 * @since 1.0.19
909
-	 * @param  string $context View or edit context.
910
-	 * @return string
911
-	 */
912
-	public function get_phone_number( $context = 'view' ) {
913
-		return $this->get_phone( $context );
995
+     * Alias of self::get_country().
996
+     *
997
+     * @since 1.0.19
998
+     * @param  string $context View or edit context.
999
+     * @return string
1000
+     */
1001
+    public function get_user_country( $context = 'view' ) {
1002
+        return $this->get_country( $context );
914 1003
     }
915 1004
 
916 1005
     /**
917
-	 * Alias of self::get_phone().
918
-	 *
919
-	 * @since 1.0.19
920
-	 * @param  string $context View or edit context.
921
-	 * @return string
922
-	 */
923
-	public function get_user_phone( $context = 'view' ) {
924
-		return $this->get_phone( $context );
1006
+     * Alias of self::get_country().
1007
+     *
1008
+     * @since 1.0.19
1009
+     * @param  string $context View or edit context.
1010
+     * @return string
1011
+     */
1012
+    public function get_customer_country( $context = 'view' ) {
1013
+        return $this->get_country( $context );
925 1014
     }
926 1015
 
927 1016
     /**
928
-	 * Alias of self::get_phone().
929
-	 *
930
-	 * @since 1.0.19
931
-	 * @param  string $context View or edit context.
932
-	 * @return string
933
-	 */
934
-	public function get_customer_phone( $context = 'view' ) {
935
-		return $this->get_phone( $context );
1017
+     * Get the customer's state.
1018
+     *
1019
+     * @since 1.0.19
1020
+     * @param  string $context View or edit context.
1021
+     * @return string
1022
+     */
1023
+    public function get_state( $context = 'view' ) {
1024
+        $state = $this->get_prop( 'state', $context );
1025
+        return empty( $state ) ? wpinv_get_default_state() : $state;
936 1026
     }
937 1027
 
938 1028
     /**
939
-	 * Get the customer's email address.
940
-	 *
941
-	 * @since 1.0.19
942
-	 * @param  string $context View or edit context.
943
-	 * @return string
944
-	 */
945
-	public function get_email( $context = 'view' ) {
946
-		return $this->get_prop( 'email', $context );
1029
+     * Alias of self::get_state().
1030
+     *
1031
+     * @since 1.0.19
1032
+     * @param  string $context View or edit context.
1033
+     * @return string
1034
+     */
1035
+    public function get_user_state( $context = 'view' ) {
1036
+        return $this->get_state( $context );
947 1037
     }
948 1038
 
949 1039
     /**
950
-	 * Alias of self::get_email().
951
-	 *
952
-	 * @since 1.0.19
953
-	 * @param  string $context View or edit context.
954
-	 * @return string
955
-	 */
956
-	public function get_email_address( $context = 'view' ) {
957
-		return $this->get_email( $context );
1040
+     * Alias of self::get_state().
1041
+     *
1042
+     * @since 1.0.19
1043
+     * @param  string $context View or edit context.
1044
+     * @return string
1045
+     */
1046
+    public function get_customer_state( $context = 'view' ) {
1047
+        return $this->get_state( $context );
958 1048
     }
959 1049
 
960 1050
     /**
961
-	 * Alias of self::get_email().
962
-	 *
963
-	 * @since 1.0.19
964
-	 * @param  string $context View or edit context.
965
-	 * @return string
966
-	 */
967
-	public function get_user_email( $context = 'view' ) {
968
-		return $this->get_email( $context );
1051
+     * Get the customer's city.
1052
+     *
1053
+     * @since 1.0.19
1054
+     * @param  string $context View or edit context.
1055
+     * @return string
1056
+     */
1057
+    public function get_city( $context = 'view' ) {
1058
+        return $this->get_prop( 'city', $context );
969 1059
     }
970 1060
 
971 1061
     /**
972
-	 * Alias of self::get_email().
973
-	 *
974
-	 * @since 1.0.19
975
-	 * @param  string $context View or edit context.
976
-	 * @return string
977
-	 */
978
-	public function get_customer_email( $context = 'view' ) {
979
-		return $this->get_email( $context );
1062
+     * Alias of self::get_city().
1063
+     *
1064
+     * @since 1.0.19
1065
+     * @param  string $context View or edit context.
1066
+     * @return string
1067
+     */
1068
+    public function get_user_city( $context = 'view' ) {
1069
+        return $this->get_city( $context );
980 1070
     }
981 1071
 
982 1072
     /**
983
-	 * Get the customer's country.
984
-	 *
985
-	 * @since 1.0.19
986
-	 * @param  string $context View or edit context.
987
-	 * @return string
988
-	 */
989
-	public function get_country( $context = 'view' ) {
990
-		$country = $this->get_prop( 'country', $context );
991
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1073
+     * Alias of self::get_city().
1074
+     *
1075
+     * @since 1.0.19
1076
+     * @param  string $context View or edit context.
1077
+     * @return string
1078
+     */
1079
+    public function get_customer_city( $context = 'view' ) {
1080
+        return $this->get_city( $context );
992 1081
     }
993 1082
 
994 1083
     /**
995
-	 * Alias of self::get_country().
996
-	 *
997
-	 * @since 1.0.19
998
-	 * @param  string $context View or edit context.
999
-	 * @return string
1000
-	 */
1001
-	public function get_user_country( $context = 'view' ) {
1002
-		return $this->get_country( $context );
1084
+     * Get the customer's zip.
1085
+     *
1086
+     * @since 1.0.19
1087
+     * @param  string $context View or edit context.
1088
+     * @return string
1089
+     */
1090
+    public function get_zip( $context = 'view' ) {
1091
+        return $this->get_prop( 'zip', $context );
1092
+    }
1093
+
1094
+    /**
1095
+     * Alias of self::get_zip().
1096
+     *
1097
+     * @since 1.0.19
1098
+     * @param  string $context View or edit context.
1099
+     * @return string
1100
+     */
1101
+    public function get_user_zip( $context = 'view' ) {
1102
+        return $this->get_zip( $context );
1103
+    }
1104
+
1105
+    /**
1106
+     * Alias of self::get_zip().
1107
+     *
1108
+     * @since 1.0.19
1109
+     * @param  string $context View or edit context.
1110
+     * @return string
1111
+     */
1112
+    public function get_customer_zip( $context = 'view' ) {
1113
+        return $this->get_zip( $context );
1114
+    }
1115
+
1116
+    /**
1117
+     * Get the customer's company.
1118
+     *
1119
+     * @since 1.0.19
1120
+     * @param  string $context View or edit context.
1121
+     * @return string
1122
+     */
1123
+    public function get_company( $context = 'view' ) {
1124
+        return $this->get_prop( 'company', $context );
1125
+    }
1126
+
1127
+    /**
1128
+     * Alias of self::get_company().
1129
+     *
1130
+     * @since 1.0.19
1131
+     * @param  string $context View or edit context.
1132
+     * @return string
1133
+     */
1134
+    public function get_user_company( $context = 'view' ) {
1135
+        return $this->get_company( $context );
1003 1136
     }
1004 1137
 
1005 1138
     /**
1006
-	 * Alias of self::get_country().
1007
-	 *
1008
-	 * @since 1.0.19
1009
-	 * @param  string $context View or edit context.
1010
-	 * @return string
1011
-	 */
1012
-	public function get_customer_country( $context = 'view' ) {
1013
-		return $this->get_country( $context );
1139
+     * Alias of self::get_company().
1140
+     *
1141
+     * @since 1.0.19
1142
+     * @param  string $context View or edit context.
1143
+     * @return string
1144
+     */
1145
+    public function get_customer_company( $context = 'view' ) {
1146
+        return $this->get_company( $context );
1014 1147
     }
1015 1148
 
1016 1149
     /**
1017
-	 * Get the customer's state.
1018
-	 *
1019
-	 * @since 1.0.19
1020
-	 * @param  string $context View or edit context.
1021
-	 * @return string
1022
-	 */
1023
-	public function get_state( $context = 'view' ) {
1024
-		$state = $this->get_prop( 'state', $context );
1025
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1150
+     * Get the customer's vat number.
1151
+     *
1152
+     * @since 1.0.19
1153
+     * @param  string $context View or edit context.
1154
+     * @return string
1155
+     */
1156
+    public function get_vat_number( $context = 'view' ) {
1157
+        return $this->get_prop( 'vat_number', $context );
1026 1158
     }
1027 1159
 
1028 1160
     /**
1029
-	 * Alias of self::get_state().
1030
-	 *
1031
-	 * @since 1.0.19
1032
-	 * @param  string $context View or edit context.
1033
-	 * @return string
1034
-	 */
1035
-	public function get_user_state( $context = 'view' ) {
1036
-		return $this->get_state( $context );
1161
+     * Alias of self::get_vat_number().
1162
+     *
1163
+     * @since 1.0.19
1164
+     * @param  string $context View or edit context.
1165
+     * @return string
1166
+     */
1167
+    public function get_user_vat_number( $context = 'view' ) {
1168
+        return $this->get_vat_number( $context );
1037 1169
     }
1038 1170
 
1039 1171
     /**
1040
-	 * Alias of self::get_state().
1041
-	 *
1042
-	 * @since 1.0.19
1043
-	 * @param  string $context View or edit context.
1044
-	 * @return string
1045
-	 */
1046
-	public function get_customer_state( $context = 'view' ) {
1047
-		return $this->get_state( $context );
1172
+     * Alias of self::get_vat_number().
1173
+     *
1174
+     * @since 1.0.19
1175
+     * @param  string $context View or edit context.
1176
+     * @return string
1177
+     */
1178
+    public function get_customer_vat_number( $context = 'view' ) {
1179
+        return $this->get_vat_number( $context );
1048 1180
     }
1049 1181
 
1050 1182
     /**
1051
-	 * Get the customer's city.
1052
-	 *
1053
-	 * @since 1.0.19
1054
-	 * @param  string $context View or edit context.
1055
-	 * @return string
1056
-	 */
1057
-	public function get_city( $context = 'view' ) {
1058
-		return $this->get_prop( 'city', $context );
1183
+     * Get the customer's vat rate.
1184
+     *
1185
+     * @since 1.0.19
1186
+     * @param  string $context View or edit context.
1187
+     * @return string
1188
+     */
1189
+    public function get_vat_rate( $context = 'view' ) {
1190
+        return $this->get_prop( 'vat_rate', $context );
1191
+    }
1192
+
1193
+    /**
1194
+     * Alias of self::get_vat_rate().
1195
+     *
1196
+     * @since 1.0.19
1197
+     * @param  string $context View or edit context.
1198
+     * @return string
1199
+     */
1200
+    public function get_user_vat_rate( $context = 'view' ) {
1201
+        return $this->get_vat_rate( $context );
1059 1202
     }
1060 1203
 
1061 1204
     /**
1062
-	 * Alias of self::get_city().
1063
-	 *
1064
-	 * @since 1.0.19
1065
-	 * @param  string $context View or edit context.
1066
-	 * @return string
1067
-	 */
1068
-	public function get_user_city( $context = 'view' ) {
1069
-		return $this->get_city( $context );
1205
+     * Alias of self::get_vat_rate().
1206
+     *
1207
+     * @since 1.0.19
1208
+     * @param  string $context View or edit context.
1209
+     * @return string
1210
+     */
1211
+    public function get_customer_vat_rate( $context = 'view' ) {
1212
+        return $this->get_vat_rate( $context );
1070 1213
     }
1071 1214
 
1072 1215
     /**
1073
-	 * Alias of self::get_city().
1074
-	 *
1075
-	 * @since 1.0.19
1076
-	 * @param  string $context View or edit context.
1077
-	 * @return string
1078
-	 */
1079
-	public function get_customer_city( $context = 'view' ) {
1080
-		return $this->get_city( $context );
1216
+     * Get the customer's address.
1217
+     *
1218
+     * @since 1.0.19
1219
+     * @param  string $context View or edit context.
1220
+     * @return string
1221
+     */
1222
+    public function get_address( $context = 'view' ) {
1223
+        return $this->get_prop( 'address', $context );
1081 1224
     }
1082 1225
 
1083 1226
     /**
1084
-	 * Get the customer's zip.
1085
-	 *
1086
-	 * @since 1.0.19
1087
-	 * @param  string $context View or edit context.
1088
-	 * @return string
1089
-	 */
1090
-	public function get_zip( $context = 'view' ) {
1091
-		return $this->get_prop( 'zip', $context );
1227
+     * Alias of self::get_address().
1228
+     *
1229
+     * @since 1.0.19
1230
+     * @param  string $context View or edit context.
1231
+     * @return string
1232
+     */
1233
+    public function get_user_address( $context = 'view' ) {
1234
+        return $this->get_address( $context );
1092 1235
     }
1093 1236
 
1094 1237
     /**
1095
-	 * Alias of self::get_zip().
1096
-	 *
1097
-	 * @since 1.0.19
1098
-	 * @param  string $context View or edit context.
1099
-	 * @return string
1100
-	 */
1101
-	public function get_user_zip( $context = 'view' ) {
1102
-		return $this->get_zip( $context );
1238
+     * Alias of self::get_address().
1239
+     *
1240
+     * @since 1.0.19
1241
+     * @param  string $context View or edit context.
1242
+     * @return string
1243
+     */
1244
+    public function get_customer_address( $context = 'view' ) {
1245
+        return $this->get_address( $context );
1103 1246
     }
1104 1247
 
1105 1248
     /**
1106
-	 * Alias of self::get_zip().
1107
-	 *
1108
-	 * @since 1.0.19
1109
-	 * @param  string $context View or edit context.
1110
-	 * @return string
1111
-	 */
1112
-	public function get_customer_zip( $context = 'view' ) {
1113
-		return $this->get_zip( $context );
1249
+     * Get whether the customer has viewed the invoice or not.
1250
+     *
1251
+     * @since 1.0.19
1252
+     * @param  string $context View or edit context.
1253
+     * @return bool
1254
+     */
1255
+    public function get_is_viewed( $context = 'view' ) {
1256
+        return (bool) $this->get_prop( 'is_viewed', $context );
1114 1257
     }
1115 1258
 
1116 1259
     /**
1117
-	 * Get the customer's company.
1118
-	 *
1119
-	 * @since 1.0.19
1120
-	 * @param  string $context View or edit context.
1121
-	 * @return string
1122
-	 */
1123
-	public function get_company( $context = 'view' ) {
1124
-		return $this->get_prop( 'company', $context );
1260
+     * Get other recipients for invoice communications.
1261
+     *
1262
+     * @since 1.0.19
1263
+     * @param  string $context View or edit context.
1264
+     * @return bool
1265
+     */
1266
+    public function get_email_cc( $context = 'view' ) {
1267
+        return $this->get_prop( 'email_cc', $context );
1125 1268
     }
1126 1269
 
1127 1270
     /**
1128
-	 * Alias of self::get_company().
1129
-	 *
1130
-	 * @since 1.0.19
1131
-	 * @param  string $context View or edit context.
1132
-	 * @return string
1133
-	 */
1134
-	public function get_user_company( $context = 'view' ) {
1135
-		return $this->get_company( $context );
1271
+     * Get invoice template.
1272
+     *
1273
+     * @since 1.0.19
1274
+     * @param  string $context View or edit context.
1275
+     * @return bool
1276
+     */
1277
+    public function get_template( $context = 'view' ) {
1278
+        return $this->get_prop( 'template', $context );
1136 1279
     }
1137 1280
 
1138 1281
     /**
1139
-	 * Alias of self::get_company().
1140
-	 *
1141
-	 * @since 1.0.19
1142
-	 * @param  string $context View or edit context.
1143
-	 * @return string
1144
-	 */
1145
-	public function get_customer_company( $context = 'view' ) {
1146
-		return $this->get_company( $context );
1282
+     * Get invoice source.
1283
+     *
1284
+     * @since 1.0.19
1285
+     * @param  string $context View or edit context.
1286
+     * @return bool
1287
+     */
1288
+    public function get_created_via( $context = 'view' ) {
1289
+        return $this->get_prop( 'created_via', $context );
1147 1290
     }
1148 1291
 
1149 1292
     /**
1150
-	 * Get the customer's vat number.
1151
-	 *
1152
-	 * @since 1.0.19
1153
-	 * @param  string $context View or edit context.
1154
-	 * @return string
1155
-	 */
1156
-	public function get_vat_number( $context = 'view' ) {
1157
-		return $this->get_prop( 'vat_number', $context );
1293
+     * Get whether the customer has confirmed their address.
1294
+     *
1295
+     * @since 1.0.19
1296
+     * @param  string $context View or edit context.
1297
+     * @return bool
1298
+     */
1299
+    public function get_address_confirmed( $context = 'view' ) {
1300
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1158 1301
     }
1159 1302
 
1160 1303
     /**
1161
-	 * Alias of self::get_vat_number().
1162
-	 *
1163
-	 * @since 1.0.19
1164
-	 * @param  string $context View or edit context.
1165
-	 * @return string
1166
-	 */
1167
-	public function get_user_vat_number( $context = 'view' ) {
1168
-		return $this->get_vat_number( $context );
1304
+     * Alias of self::get_address_confirmed().
1305
+     *
1306
+     * @since 1.0.19
1307
+     * @param  string $context View or edit context.
1308
+     * @return bool
1309
+     */
1310
+    public function get_user_address_confirmed( $context = 'view' ) {
1311
+        return $this->get_address_confirmed( $context );
1169 1312
     }
1170 1313
 
1171 1314
     /**
1172
-	 * Alias of self::get_vat_number().
1173
-	 *
1174
-	 * @since 1.0.19
1175
-	 * @param  string $context View or edit context.
1176
-	 * @return string
1177
-	 */
1178
-	public function get_customer_vat_number( $context = 'view' ) {
1179
-		return $this->get_vat_number( $context );
1315
+     * Alias of self::get_address().
1316
+     *
1317
+     * @since 1.0.19
1318
+     * @param  string $context View or edit context.
1319
+     * @return bool
1320
+     */
1321
+    public function get_customer_address_confirmed( $context = 'view' ) {
1322
+        return $this->get_address_confirmed( $context );
1180 1323
     }
1181 1324
 
1182 1325
     /**
1183
-	 * Get the customer's vat rate.
1184
-	 *
1185
-	 * @since 1.0.19
1186
-	 * @param  string $context View or edit context.
1187
-	 * @return string
1188
-	 */
1189
-	public function get_vat_rate( $context = 'view' ) {
1190
-		return $this->get_prop( 'vat_rate', $context );
1191
-    }
1192
-
1193
-    /**
1194
-	 * Alias of self::get_vat_rate().
1195
-	 *
1196
-	 * @since 1.0.19
1197
-	 * @param  string $context View or edit context.
1198
-	 * @return string
1199
-	 */
1200
-	public function get_user_vat_rate( $context = 'view' ) {
1201
-		return $this->get_vat_rate( $context );
1202
-    }
1203
-
1204
-    /**
1205
-	 * Alias of self::get_vat_rate().
1206
-	 *
1207
-	 * @since 1.0.19
1208
-	 * @param  string $context View or edit context.
1209
-	 * @return string
1210
-	 */
1211
-	public function get_customer_vat_rate( $context = 'view' ) {
1212
-		return $this->get_vat_rate( $context );
1213
-    }
1214
-
1215
-    /**
1216
-	 * Get the customer's address.
1217
-	 *
1218
-	 * @since 1.0.19
1219
-	 * @param  string $context View or edit context.
1220
-	 * @return string
1221
-	 */
1222
-	public function get_address( $context = 'view' ) {
1223
-		return $this->get_prop( 'address', $context );
1224
-    }
1225
-
1226
-    /**
1227
-	 * Alias of self::get_address().
1228
-	 *
1229
-	 * @since 1.0.19
1230
-	 * @param  string $context View or edit context.
1231
-	 * @return string
1232
-	 */
1233
-	public function get_user_address( $context = 'view' ) {
1234
-		return $this->get_address( $context );
1235
-    }
1236
-
1237
-    /**
1238
-	 * Alias of self::get_address().
1239
-	 *
1240
-	 * @since 1.0.19
1241
-	 * @param  string $context View or edit context.
1242
-	 * @return string
1243
-	 */
1244
-	public function get_customer_address( $context = 'view' ) {
1245
-		return $this->get_address( $context );
1246
-    }
1247
-
1248
-    /**
1249
-	 * Get whether the customer has viewed the invoice or not.
1250
-	 *
1251
-	 * @since 1.0.19
1252
-	 * @param  string $context View or edit context.
1253
-	 * @return bool
1254
-	 */
1255
-	public function get_is_viewed( $context = 'view' ) {
1256
-		return (bool) $this->get_prop( 'is_viewed', $context );
1257
-	}
1258
-
1259
-	/**
1260
-	 * Get other recipients for invoice communications.
1261
-	 *
1262
-	 * @since 1.0.19
1263
-	 * @param  string $context View or edit context.
1264
-	 * @return bool
1265
-	 */
1266
-	public function get_email_cc( $context = 'view' ) {
1267
-		return $this->get_prop( 'email_cc', $context );
1268
-	}
1269
-
1270
-	/**
1271
-	 * Get invoice template.
1272
-	 *
1273
-	 * @since 1.0.19
1274
-	 * @param  string $context View or edit context.
1275
-	 * @return bool
1276
-	 */
1277
-	public function get_template( $context = 'view' ) {
1278
-		return $this->get_prop( 'template', $context );
1279
-	}
1280
-
1281
-	/**
1282
-	 * Get invoice source.
1283
-	 *
1284
-	 * @since 1.0.19
1285
-	 * @param  string $context View or edit context.
1286
-	 * @return bool
1287
-	 */
1288
-	public function get_created_via( $context = 'view' ) {
1289
-		return $this->get_prop( 'created_via', $context );
1290
-	}
1291
-
1292
-	/**
1293
-	 * Get whether the customer has confirmed their address.
1294
-	 *
1295
-	 * @since 1.0.19
1296
-	 * @param  string $context View or edit context.
1297
-	 * @return bool
1298
-	 */
1299
-	public function get_address_confirmed( $context = 'view' ) {
1300
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1301
-    }
1302
-
1303
-    /**
1304
-	 * Alias of self::get_address_confirmed().
1305
-	 *
1306
-	 * @since 1.0.19
1307
-	 * @param  string $context View or edit context.
1308
-	 * @return bool
1309
-	 */
1310
-	public function get_user_address_confirmed( $context = 'view' ) {
1311
-		return $this->get_address_confirmed( $context );
1312
-    }
1313
-
1314
-    /**
1315
-	 * Alias of self::get_address().
1316
-	 *
1317
-	 * @since 1.0.19
1318
-	 * @param  string $context View or edit context.
1319
-	 * @return bool
1320
-	 */
1321
-	public function get_customer_address_confirmed( $context = 'view' ) {
1322
-		return $this->get_address_confirmed( $context );
1323
-    }
1324
-
1325
-    /**
1326
-	 * Get the invoice subtotal.
1327
-	 *
1328
-	 * @since 1.0.19
1329
-	 * @param  string $context View or edit context.
1330
-	 * @return float
1331
-	 */
1332
-	public function get_subtotal( $context = 'view' ) {
1326
+     * Get the invoice subtotal.
1327
+     *
1328
+     * @since 1.0.19
1329
+     * @param  string $context View or edit context.
1330
+     * @return float
1331
+     */
1332
+    public function get_subtotal( $context = 'view' ) {
1333 1333
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1334 1334
 
1335 1335
         // Backwards compatibility.
@@ -1341,167 +1341,167 @@  discard block
 block discarded – undo
1341 1341
     }
1342 1342
 
1343 1343
     /**
1344
-	 * Get the invoice discount total.
1345
-	 *
1346
-	 * @since 1.0.19
1347
-	 * @param  string $context View or edit context.
1348
-	 * @return float
1349
-	 */
1350
-	public function get_total_discount( $context = 'view' ) {
1351
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1344
+     * Get the invoice discount total.
1345
+     *
1346
+     * @since 1.0.19
1347
+     * @param  string $context View or edit context.
1348
+     * @return float
1349
+     */
1350
+    public function get_total_discount( $context = 'view' ) {
1351
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1352 1352
     }
1353 1353
 
1354 1354
     /**
1355
-	 * Get the invoice tax total.
1356
-	 *
1357
-	 * @since 1.0.19
1358
-	 * @param  string $context View or edit context.
1359
-	 * @return float
1360
-	 */
1361
-	public function get_total_tax( $context = 'view' ) {
1362
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1363
-	}
1355
+     * Get the invoice tax total.
1356
+     *
1357
+     * @since 1.0.19
1358
+     * @param  string $context View or edit context.
1359
+     * @return float
1360
+     */
1361
+    public function get_total_tax( $context = 'view' ) {
1362
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1363
+    }
1364 1364
 
1365
-	/**
1366
-	 * @deprecated
1367
-	 */
1368
-	public function get_final_tax( $currency = false ) {
1369
-		$tax = $this->get_total_tax();
1365
+    /**
1366
+     * @deprecated
1367
+     */
1368
+    public function get_final_tax( $currency = false ) {
1369
+        $tax = $this->get_total_tax();
1370 1370
 
1371 1371
         if ( $currency ) {
1372
-			return wpinv_price( $tax, $this->get_currency() );
1372
+            return wpinv_price( $tax, $this->get_currency() );
1373 1373
         }
1374 1374
 
1375 1375
         return $tax;
1376 1376
     }
1377 1377
 
1378 1378
     /**
1379
-	 * Get the invoice fees total.
1380
-	 *
1381
-	 * @since 1.0.19
1382
-	 * @param  string $context View or edit context.
1383
-	 * @return float
1384
-	 */
1385
-	public function get_total_fees( $context = 'view' ) {
1386
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1379
+     * Get the invoice fees total.
1380
+     *
1381
+     * @since 1.0.19
1382
+     * @param  string $context View or edit context.
1383
+     * @return float
1384
+     */
1385
+    public function get_total_fees( $context = 'view' ) {
1386
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1387 1387
     }
1388 1388
 
1389 1389
     /**
1390
-	 * Alias for self::get_total_fees().
1391
-	 *
1392
-	 * @since 1.0.19
1393
-	 * @param  string $context View or edit context.
1394
-	 * @return float
1395
-	 */
1396
-	public function get_fees_total( $context = 'view' ) {
1397
-		return $this->get_total_fees( $context );
1390
+     * Alias for self::get_total_fees().
1391
+     *
1392
+     * @since 1.0.19
1393
+     * @param  string $context View or edit context.
1394
+     * @return float
1395
+     */
1396
+    public function get_fees_total( $context = 'view' ) {
1397
+        return $this->get_total_fees( $context );
1398 1398
     }
1399 1399
 
1400 1400
     /**
1401
-	 * Get the invoice total.
1402
-	 *
1403
-	 * @since 1.0.19
1401
+     * Get the invoice total.
1402
+     *
1403
+     * @since 1.0.19
1404 1404
      * @return float
1405
-	 */
1406
-	public function get_total() {
1407
-		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1408
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1409
-	}
1405
+     */
1406
+    public function get_total() {
1407
+        $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1408
+        return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1409
+    }
1410 1410
 	
1411
-	/**
1412
-	 * Get the invoice totals.
1413
-	 *
1414
-	 * @since 1.0.19
1411
+    /**
1412
+     * Get the invoice totals.
1413
+     *
1414
+     * @since 1.0.19
1415 1415
      * @return array
1416
-	 */
1417
-	public function get_totals() {
1418
-		return $this->totals;
1416
+     */
1417
+    public function get_totals() {
1418
+        return $this->totals;
1419 1419
     }
1420 1420
 
1421 1421
     /**
1422
-	 * Get the initial invoice total.
1423
-	 *
1424
-	 * @since 1.0.19
1422
+     * Get the initial invoice total.
1423
+     *
1424
+     * @since 1.0.19
1425 1425
      * @param  string $context View or edit context.
1426 1426
      * @return float
1427
-	 */
1427
+     */
1428 1428
     public function get_initial_total() {
1429 1429
 
1430
-		if ( empty( $this->totals ) ) {
1431
-			$this->recalculate_total();
1432
-		}
1430
+        if ( empty( $this->totals ) ) {
1431
+            $this->recalculate_total();
1432
+        }
1433 1433
 
1434
-		$tax      = $this->totals['tax']['initial'];
1435
-		$fee      = $this->totals['fee']['initial'];
1436
-		$discount = $this->totals['discount']['initial'];
1437
-		$subtotal = $this->totals['subtotal']['initial'];
1438
-		$total    = $tax + $fee - $discount + $subtotal;
1434
+        $tax      = $this->totals['tax']['initial'];
1435
+        $fee      = $this->totals['fee']['initial'];
1436
+        $discount = $this->totals['discount']['initial'];
1437
+        $subtotal = $this->totals['subtotal']['initial'];
1438
+        $total    = $tax + $fee - $discount + $subtotal;
1439 1439
 
1440
-		if ( 0 > $total ) {
1441
-			$total = 0;
1442
-		}
1440
+        if ( 0 > $total ) {
1441
+            $total = 0;
1442
+        }
1443 1443
 
1444
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1444
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1445 1445
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1446
-	}
1446
+    }
1447 1447
 
1448
-	/**
1449
-	 * Get the recurring invoice total.
1450
-	 *
1451
-	 * @since 1.0.19
1448
+    /**
1449
+     * Get the recurring invoice total.
1450
+     *
1451
+     * @since 1.0.19
1452 1452
      * @param  string $context View or edit context.
1453 1453
      * @return float
1454
-	 */
1454
+     */
1455 1455
     public function get_recurring_total() {
1456 1456
 
1457
-		if ( empty( $this->totals ) ) {
1458
-			$this->recalculate_total();
1459
-		}
1457
+        if ( empty( $this->totals ) ) {
1458
+            $this->recalculate_total();
1459
+        }
1460 1460
 
1461
-		$tax      = $this->totals['tax']['recurring'];
1462
-		$fee      = $this->totals['fee']['recurring'];
1463
-		$discount = $this->totals['discount']['recurring'];
1464
-		$subtotal = $this->totals['subtotal']['recurring'];
1465
-		$total    = $tax + $fee - $discount + $subtotal;
1461
+        $tax      = $this->totals['tax']['recurring'];
1462
+        $fee      = $this->totals['fee']['recurring'];
1463
+        $discount = $this->totals['discount']['recurring'];
1464
+        $subtotal = $this->totals['subtotal']['recurring'];
1465
+        $total    = $tax + $fee - $discount + $subtotal;
1466 1466
 
1467
-		if ( 0 > $total ) {
1468
-			$total = 0;
1469
-		}
1467
+        if ( 0 > $total ) {
1468
+            $total = 0;
1469
+        }
1470 1470
 
1471
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1471
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1472 1472
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1473
-	}
1473
+    }
1474 1474
 
1475
-	/**
1476
-	 * Returns recurring payment details.
1477
-	 *
1478
-	 * @since 1.0.19
1475
+    /**
1476
+     * Returns recurring payment details.
1477
+     *
1478
+     * @since 1.0.19
1479 1479
      * @param  string $field Optionally provide a field to return.
1480
-	 * @param string $currency Whether to include the currency.
1480
+     * @param string $currency Whether to include the currency.
1481 1481
      * @return float|string
1482
-	 */
1482
+     */
1483 1483
     public function get_recurring_details( $field = '', $currency = false ) {
1484 1484
 
1485
-		// Maybe recalculate totals.
1486
-		if ( empty( $this->totals ) ) {
1487
-			$this->recalculate_total();
1488
-		}
1485
+        // Maybe recalculate totals.
1486
+        if ( empty( $this->totals ) ) {
1487
+            $this->recalculate_total();
1488
+        }
1489 1489
 
1490
-		// Prepare recurring totals.
1490
+        // Prepare recurring totals.
1491 1491
         $data = apply_filters(
1492
-			'wpinv_get_invoice_recurring_details',
1493
-			array(
1494
-				'cart_details' => $this->get_cart_details(),
1495
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1496
-				'discount'     => $this->totals['discount']['recurring'],
1497
-				'tax'          => $this->totals['tax']['recurring'],
1498
-				'fee'          => $this->totals['fee']['recurring'],
1499
-				'total'        => $this->get_recurring_total(),
1500
-			),
1501
-			$this,
1502
-			$field,
1503
-			$currency
1504
-		);
1492
+            'wpinv_get_invoice_recurring_details',
1493
+            array(
1494
+                'cart_details' => $this->get_cart_details(),
1495
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1496
+                'discount'     => $this->totals['discount']['recurring'],
1497
+                'tax'          => $this->totals['tax']['recurring'],
1498
+                'fee'          => $this->totals['fee']['recurring'],
1499
+                'total'        => $this->get_recurring_total(),
1500
+            ),
1501
+            $this,
1502
+            $field,
1503
+            $currency
1504
+        );
1505 1505
 
1506 1506
         if ( isset( $data[$field] ) ) {
1507 1507
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1511,166 +1511,166 @@  discard block
 block discarded – undo
1511 1511
     }
1512 1512
 
1513 1513
     /**
1514
-	 * Get the invoice fees.
1515
-	 *
1516
-	 * @since 1.0.19
1517
-	 * @param  string $context View or edit context.
1518
-	 * @return array
1519
-	 */
1520
-	public function get_fees( $context = 'view' ) {
1521
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1514
+     * Get the invoice fees.
1515
+     *
1516
+     * @since 1.0.19
1517
+     * @param  string $context View or edit context.
1518
+     * @return array
1519
+     */
1520
+    public function get_fees( $context = 'view' ) {
1521
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1522 1522
     }
1523 1523
 
1524 1524
     /**
1525
-	 * Get the invoice discounts.
1526
-	 *
1527
-	 * @since 1.0.19
1528
-	 * @param  string $context View or edit context.
1529
-	 * @return array
1530
-	 */
1531
-	public function get_discounts( $context = 'view' ) {
1532
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1525
+     * Get the invoice discounts.
1526
+     *
1527
+     * @since 1.0.19
1528
+     * @param  string $context View or edit context.
1529
+     * @return array
1530
+     */
1531
+    public function get_discounts( $context = 'view' ) {
1532
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1533 1533
     }
1534 1534
 
1535 1535
     /**
1536
-	 * Get the invoice taxes.
1537
-	 *
1538
-	 * @since 1.0.19
1539
-	 * @param  string $context View or edit context.
1540
-	 * @return array
1541
-	 */
1542
-	public function get_taxes( $context = 'view' ) {
1543
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1536
+     * Get the invoice taxes.
1537
+     *
1538
+     * @since 1.0.19
1539
+     * @param  string $context View or edit context.
1540
+     * @return array
1541
+     */
1542
+    public function get_taxes( $context = 'view' ) {
1543
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1544 1544
     }
1545 1545
 
1546 1546
     /**
1547
-	 * Get the invoice items.
1548
-	 *
1549
-	 * @since 1.0.19
1550
-	 * @param  string $context View or edit context.
1551
-	 * @return GetPaid_Form_Item[]
1552
-	 */
1553
-	public function get_items( $context = 'view' ) {
1547
+     * Get the invoice items.
1548
+     *
1549
+     * @since 1.0.19
1550
+     * @param  string $context View or edit context.
1551
+     * @return GetPaid_Form_Item[]
1552
+     */
1553
+    public function get_items( $context = 'view' ) {
1554 1554
         return $this->get_prop( 'items', $context );
1555
-	}
1555
+    }
1556 1556
 	
1557
-	/**
1558
-	 * Get the invoice item ids.
1559
-	 *
1560
-	 * @since 1.0.19
1561
-	 * @return string
1562
-	 */
1563
-	public function get_item_ids() {
1564
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1557
+    /**
1558
+     * Get the invoice item ids.
1559
+     *
1560
+     * @since 1.0.19
1561
+     * @return string
1562
+     */
1563
+    public function get_item_ids() {
1564
+        return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1565 1565
     }
1566 1566
 
1567 1567
     /**
1568
-	 * Get the invoice's payment form.
1569
-	 *
1570
-	 * @since 1.0.19
1571
-	 * @param  string $context View or edit context.
1572
-	 * @return int
1573
-	 */
1574
-	public function get_payment_form( $context = 'view' ) {
1575
-		return intval( $this->get_prop( 'payment_form', $context ) );
1568
+     * Get the invoice's payment form.
1569
+     *
1570
+     * @since 1.0.19
1571
+     * @param  string $context View or edit context.
1572
+     * @return int
1573
+     */
1574
+    public function get_payment_form( $context = 'view' ) {
1575
+        return intval( $this->get_prop( 'payment_form', $context ) );
1576 1576
     }
1577 1577
 
1578 1578
     /**
1579
-	 * Get the invoice's submission id.
1580
-	 *
1581
-	 * @since 1.0.19
1582
-	 * @param  string $context View or edit context.
1583
-	 * @return string
1584
-	 */
1585
-	public function get_submission_id( $context = 'view' ) {
1586
-		return $this->get_prop( 'submission_id', $context );
1579
+     * Get the invoice's submission id.
1580
+     *
1581
+     * @since 1.0.19
1582
+     * @param  string $context View or edit context.
1583
+     * @return string
1584
+     */
1585
+    public function get_submission_id( $context = 'view' ) {
1586
+        return $this->get_prop( 'submission_id', $context );
1587 1587
     }
1588 1588
 
1589 1589
     /**
1590
-	 * Get the invoice's discount code.
1591
-	 *
1592
-	 * @since 1.0.19
1593
-	 * @param  string $context View or edit context.
1594
-	 * @return string
1595
-	 */
1596
-	public function get_discount_code( $context = 'view' ) {
1597
-		return $this->get_prop( 'discount_code', $context );
1590
+     * Get the invoice's discount code.
1591
+     *
1592
+     * @since 1.0.19
1593
+     * @param  string $context View or edit context.
1594
+     * @return string
1595
+     */
1596
+    public function get_discount_code( $context = 'view' ) {
1597
+        return $this->get_prop( 'discount_code', $context );
1598 1598
     }
1599 1599
 
1600 1600
     /**
1601
-	 * Get the invoice's gateway.
1602
-	 *
1603
-	 * @since 1.0.19
1604
-	 * @param  string $context View or edit context.
1605
-	 * @return string
1606
-	 */
1607
-	public function get_gateway( $context = 'view' ) {
1608
-		return $this->get_prop( 'gateway', $context );
1601
+     * Get the invoice's gateway.
1602
+     *
1603
+     * @since 1.0.19
1604
+     * @param  string $context View or edit context.
1605
+     * @return string
1606
+     */
1607
+    public function get_gateway( $context = 'view' ) {
1608
+        return $this->get_prop( 'gateway', $context );
1609 1609
     }
1610 1610
 
1611 1611
     /**
1612
-	 * Get the invoice's gateway display title.
1613
-	 *
1614
-	 * @since 1.0.19
1615
-	 * @return string
1616
-	 */
1612
+     * Get the invoice's gateway display title.
1613
+     *
1614
+     * @since 1.0.19
1615
+     * @return string
1616
+     */
1617 1617
     public function get_gateway_title() {
1618 1618
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1619 1619
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1620 1620
     }
1621 1621
 
1622 1622
     /**
1623
-	 * Get the invoice's transaction id.
1624
-	 *
1625
-	 * @since 1.0.19
1626
-	 * @param  string $context View or edit context.
1627
-	 * @return string
1628
-	 */
1629
-	public function get_transaction_id( $context = 'view' ) {
1630
-		return $this->get_prop( 'transaction_id', $context );
1623
+     * Get the invoice's transaction id.
1624
+     *
1625
+     * @since 1.0.19
1626
+     * @param  string $context View or edit context.
1627
+     * @return string
1628
+     */
1629
+    public function get_transaction_id( $context = 'view' ) {
1630
+        return $this->get_prop( 'transaction_id', $context );
1631 1631
     }
1632 1632
 
1633 1633
     /**
1634
-	 * Get the invoice's currency.
1635
-	 *
1636
-	 * @since 1.0.19
1637
-	 * @param  string $context View or edit context.
1638
-	 * @return string
1639
-	 */
1640
-	public function get_currency( $context = 'view' ) {
1634
+     * Get the invoice's currency.
1635
+     *
1636
+     * @since 1.0.19
1637
+     * @param  string $context View or edit context.
1638
+     * @return string
1639
+     */
1640
+    public function get_currency( $context = 'view' ) {
1641 1641
         $currency = $this->get_prop( 'currency', $context );
1642 1642
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1643 1643
     }
1644 1644
 
1645 1645
     /**
1646
-	 * Checks if we are charging taxes for this invoice.
1647
-	 *
1648
-	 * @since 1.0.19
1649
-	 * @param  string $context View or edit context.
1650
-	 * @return bool
1651
-	 */
1652
-	public function get_disable_taxes( $context = 'view' ) {
1646
+     * Checks if we are charging taxes for this invoice.
1647
+     *
1648
+     * @since 1.0.19
1649
+     * @param  string $context View or edit context.
1650
+     * @return bool
1651
+     */
1652
+    public function get_disable_taxes( $context = 'view' ) {
1653 1653
         return (bool) $this->get_prop( 'disable_taxes', $context );
1654 1654
     }
1655 1655
 
1656 1656
     /**
1657
-	 * Retrieves the subscription id for an invoice.
1658
-	 *
1659
-	 * @since 1.0.19
1660
-	 * @param  string $context View or edit context.
1661
-	 * @return int
1662
-	 */
1657
+     * Retrieves the subscription id for an invoice.
1658
+     *
1659
+     * @since 1.0.19
1660
+     * @param  string $context View or edit context.
1661
+     * @return int
1662
+     */
1663 1663
     public function get_subscription_id( $context = 'view' ) {
1664
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1665
-	}
1666
-
1667
-	/**
1668
-	 * Retrieves the remote subscription id for an invoice.
1669
-	 *
1670
-	 * @since 1.0.19
1671
-	 * @param  string $context View or edit context.
1672
-	 * @return int
1673
-	 */
1664
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1665
+    }
1666
+
1667
+    /**
1668
+     * Retrieves the remote subscription id for an invoice.
1669
+     *
1670
+     * @since 1.0.19
1671
+     * @param  string $context View or edit context.
1672
+     * @return int
1673
+     */
1674 1674
     public function get_remote_subscription_id( $context = 'view' ) {
1675 1675
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1676 1676
 
@@ -1683,12 +1683,12 @@  discard block
 block discarded – undo
1683 1683
     }
1684 1684
 
1685 1685
     /**
1686
-	 * Retrieves the payment meta for an invoice.
1687
-	 *
1688
-	 * @since 1.0.19
1689
-	 * @param  string $context View or edit context.
1690
-	 * @return array
1691
-	 */
1686
+     * Retrieves the payment meta for an invoice.
1687
+     *
1688
+     * @since 1.0.19
1689
+     * @param  string $context View or edit context.
1690
+     * @return array
1691
+     */
1692 1692
     public function get_payment_meta( $context = 'view' ) {
1693 1693
 
1694 1694
         return array(
@@ -1708,31 +1708,31 @@  discard block
 block discarded – undo
1708 1708
     }
1709 1709
 
1710 1710
     /**
1711
-	 * Retrieves the cart details for an invoice.
1712
-	 *
1713
-	 * @since 1.0.19
1714
-	 * @return array
1715
-	 */
1711
+     * Retrieves the cart details for an invoice.
1712
+     *
1713
+     * @since 1.0.19
1714
+     * @return array
1715
+     */
1716 1716
     public function get_cart_details() {
1717 1717
         $items        = $this->get_items();
1718 1718
         $cart_details = array();
1719 1719
 
1720 1720
         foreach ( $items as $item ) {
1721
-			$item->invoice_id = $this->get_id();
1721
+            $item->invoice_id = $this->get_id();
1722 1722
             $cart_details[]   = $item->prepare_data_for_saving();
1723 1723
         }
1724 1724
 
1725 1725
         return $cart_details;
1726
-	}
1726
+    }
1727 1727
 
1728
-	/**
1729
-	 * Retrieves the recurring item.
1730
-	 *
1731
-	 * @return null|GetPaid_Form_Item|int
1732
-	 */
1733
-	public function get_recurring( $object = false ) {
1728
+    /**
1729
+     * Retrieves the recurring item.
1730
+     *
1731
+     * @return null|GetPaid_Form_Item|int
1732
+     */
1733
+    public function get_recurring( $object = false ) {
1734 1734
 
1735
-		// Are we returning an object?
1735
+        // Are we returning an object?
1736 1736
         if ( $object ) {
1737 1737
             return $this->get_item( $this->recurring_item );
1738 1738
         }
@@ -1740,114 +1740,114 @@  discard block
 block discarded – undo
1740 1740
         return $this->recurring_item;
1741 1741
     }
1742 1742
 
1743
-	/**
1744
-	 * Retrieves the subscription name.
1745
-	 *
1746
-	 * @since 1.0.19
1747
-	 * @return string
1748
-	 */
1749
-	public function get_subscription_name() {
1743
+    /**
1744
+     * Retrieves the subscription name.
1745
+     *
1746
+     * @since 1.0.19
1747
+     * @return string
1748
+     */
1749
+    public function get_subscription_name() {
1750 1750
 
1751
-		// Retrieve the recurring name
1751
+        // Retrieve the recurring name
1752 1752
         $item = $this->get_recurring( true );
1753 1753
 
1754
-		// Abort if it does not exist.
1754
+        // Abort if it does not exist.
1755 1755
         if ( empty( $item ) ) {
1756 1756
             return '';
1757 1757
         }
1758 1758
 
1759
-		// Return the item name.
1759
+        // Return the item name.
1760 1760
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1761
-	}
1762
-
1763
-	/**
1764
-	 * Retrieves the view url.
1765
-	 *
1766
-	 * @since 1.0.19
1767
-	 * @return string
1768
-	 */
1769
-	public function get_view_url() {
1761
+    }
1762
+
1763
+    /**
1764
+     * Retrieves the view url.
1765
+     *
1766
+     * @since 1.0.19
1767
+     * @return string
1768
+     */
1769
+    public function get_view_url() {
1770 1770
         $invoice_url = get_permalink( $this->get_id() );
1771
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1771
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1772 1772
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1773
-	}
1773
+    }
1774 1774
 
1775
-	/**
1776
-	 * Retrieves the payment url.
1777
-	 *
1778
-	 * @since 1.0.19
1779
-	 * @return string
1780
-	 */
1781
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1775
+    /**
1776
+     * Retrieves the payment url.
1777
+     *
1778
+     * @since 1.0.19
1779
+     * @return string
1780
+     */
1781
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1782 1782
 
1783
-		// Retrieve the checkout url.
1783
+        // Retrieve the checkout url.
1784 1784
         $pay_url = wpinv_get_checkout_uri();
1785 1785
 
1786
-		// Maybe force ssl.
1786
+        // Maybe force ssl.
1787 1787
         if ( is_ssl() ) {
1788 1788
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1789 1789
         }
1790 1790
 
1791
-		// Add the invoice key.
1792
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1791
+        // Add the invoice key.
1792
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1793 1793
 
1794
-		// (Maybe?) add a secret
1794
+        // (Maybe?) add a secret
1795 1795
         if ( $secret ) {
1796 1796
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1797 1797
         }
1798 1798
 
1799 1799
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1800
-	}
1800
+    }
1801 1801
 	
1802
-	/**
1803
-	 * Retrieves the receipt url.
1804
-	 *
1805
-	 * @since 1.0.19
1806
-	 * @return string
1807
-	 */
1808
-	public function get_receipt_url() {
1809
-
1810
-		// Retrieve the checkout url.
1802
+    /**
1803
+     * Retrieves the receipt url.
1804
+     *
1805
+     * @since 1.0.19
1806
+     * @return string
1807
+     */
1808
+    public function get_receipt_url() {
1809
+
1810
+        // Retrieve the checkout url.
1811 1811
         $receipt_url = wpinv_get_success_page_uri();
1812 1812
 
1813
-		// Maybe force ssl.
1813
+        // Maybe force ssl.
1814 1814
         if ( is_ssl() ) {
1815 1815
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1816 1816
         }
1817 1817
 
1818
-		// Add the invoice key.
1819
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1818
+        // Add the invoice key.
1819
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1820 1820
 
1821 1821
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1822
-	}
1822
+    }
1823 1823
 	
1824
-	/**
1825
-	 * Retrieves the default status.
1826
-	 *
1827
-	 * @since 1.0.19
1828
-	 * @return string
1829
-	 */
1830
-	public function get_default_status() {
1831
-
1832
-		$type   = $this->get_type();
1833
-		$status = "wpi-$type-pending";
1834
-		return str_replace( '-invoice', '', $status );
1835
-
1836
-	}
1837
-
1838
-    /**
1839
-	 * Magic method for accessing invoice properties.
1840
-	 *
1841
-	 * @since 1.0.15
1842
-	 * @access public
1843
-	 *
1844
-	 * @param string $key Discount data to retrieve
1845
-	 * @param  string $context View or edit context.
1846
-	 * @return mixed Value of the given invoice property (if set).
1847
-	 */
1848
-	public function get( $key, $context = 'view' ) {
1824
+    /**
1825
+     * Retrieves the default status.
1826
+     *
1827
+     * @since 1.0.19
1828
+     * @return string
1829
+     */
1830
+    public function get_default_status() {
1831
+
1832
+        $type   = $this->get_type();
1833
+        $status = "wpi-$type-pending";
1834
+        return str_replace( '-invoice', '', $status );
1835
+
1836
+    }
1837
+
1838
+    /**
1839
+     * Magic method for accessing invoice properties.
1840
+     *
1841
+     * @since 1.0.15
1842
+     * @access public
1843
+     *
1844
+     * @param string $key Discount data to retrieve
1845
+     * @param  string $context View or edit context.
1846
+     * @return mixed Value of the given invoice property (if set).
1847
+     */
1848
+    public function get( $key, $context = 'view' ) {
1849 1849
         return $this->get_prop( $key, $context );
1850
-	}
1850
+    }
1851 1851
 
1852 1852
     /*
1853 1853
 	|--------------------------------------------------------------------------
@@ -1860,130 +1860,130 @@  discard block
 block discarded – undo
1860 1860
     */
1861 1861
 
1862 1862
     /**
1863
-	 * Magic method for setting invoice properties.
1864
-	 *
1865
-	 * @since 1.0.19
1866
-	 * @access public
1867
-	 *
1868
-	 * @param string $key Discount data to retrieve
1869
-	 * @param  mixed $value new value.
1870
-	 * @return mixed Value of the given invoice property (if set).
1871
-	 */
1872
-	public function set( $key, $value ) {
1863
+     * Magic method for setting invoice properties.
1864
+     *
1865
+     * @since 1.0.19
1866
+     * @access public
1867
+     *
1868
+     * @param string $key Discount data to retrieve
1869
+     * @param  mixed $value new value.
1870
+     * @return mixed Value of the given invoice property (if set).
1871
+     */
1872
+    public function set( $key, $value ) {
1873 1873
 
1874 1874
         $setter = "set_$key";
1875 1875
         if ( is_callable( array( $this, $setter ) ) ) {
1876 1876
             $this->{$setter}( $value );
1877 1877
         }
1878 1878
 
1879
-	}
1879
+    }
1880 1880
 
1881
-	/**
1882
-	 * Sets item status.
1883
-	 *
1884
-	 * @since 1.0.19
1885
-	 * @param string $new_status    New status.
1886
-	 * @param string $note          Optional note to add.
1887
-	 * @param bool   $manual_update Is this a manual status change?.
1888
-	 * @return array details of change.
1889
-	 */
1890
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1891
-		$old_status = $this->get_status();
1881
+    /**
1882
+     * Sets item status.
1883
+     *
1884
+     * @since 1.0.19
1885
+     * @param string $new_status    New status.
1886
+     * @param string $note          Optional note to add.
1887
+     * @param bool   $manual_update Is this a manual status change?.
1888
+     * @return array details of change.
1889
+     */
1890
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1891
+        $old_status = $this->get_status();
1892 1892
 
1893
-		$statuses = $this->get_all_statuses();
1893
+        $statuses = $this->get_all_statuses();
1894 1894
 
1895
-		if ( isset( $statuses[ 'draft' ] ) ) {
1896
-			unset( $statuses[ 'draft' ] );
1897
-		}
1895
+        if ( isset( $statuses[ 'draft' ] ) ) {
1896
+            unset( $statuses[ 'draft' ] );
1897
+        }
1898 1898
 
1899
-		$this->set_prop( 'status', $new_status );
1899
+        $this->set_prop( 'status', $new_status );
1900 1900
 
1901
-		// If setting the status, ensure it's set to a valid status.
1902
-		if ( true === $this->object_read ) {
1901
+        // If setting the status, ensure it's set to a valid status.
1902
+        if ( true === $this->object_read ) {
1903 1903
 
1904
-			// Only allow valid new status.
1905
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1906
-				$new_status = $this->get_default_status();
1907
-			}
1904
+            // Only allow valid new status.
1905
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1906
+                $new_status = $this->get_default_status();
1907
+            }
1908 1908
 
1909
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1910
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1911
-				$old_status = $this->get_default_status();
1912
-			}
1909
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1910
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1911
+                $old_status = $this->get_default_status();
1912
+            }
1913 1913
 
1914
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1915
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1916
-				$old_status = 'wpi-pending';
1917
-			}
1914
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1915
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1916
+                $old_status = 'wpi-pending';
1917
+            }
1918 1918
 
1919
-		}
1919
+        }
1920 1920
 
1921
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1922
-			$this->status_transition = array(
1923
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1924
-				'to'     => $new_status,
1925
-				'note'   => $note,
1926
-				'manual' => (bool) $manual_update,
1927
-			);
1921
+        if ( true === $this->object_read && $old_status !== $new_status ) {
1922
+            $this->status_transition = array(
1923
+                'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1924
+                'to'     => $new_status,
1925
+                'note'   => $note,
1926
+                'manual' => (bool) $manual_update,
1927
+            );
1928 1928
 
1929
-			if ( $manual_update ) {
1930
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1931
-			}
1929
+            if ( $manual_update ) {
1930
+                do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1931
+            }
1932 1932
 
1933
-			$this->maybe_set_date_paid();
1933
+            $this->maybe_set_date_paid();
1934 1934
 
1935
-		}
1935
+        }
1936 1936
 
1937
-		return array(
1938
-			'from' => $old_status,
1939
-			'to'   => $new_status,
1940
-		);
1941
-	}
1937
+        return array(
1938
+            'from' => $old_status,
1939
+            'to'   => $new_status,
1940
+        );
1941
+    }
1942 1942
 
1943
-	/**
1944
-	 * Maybe set date paid.
1945
-	 *
1946
-	 * Sets the date paid variable when transitioning to the payment complete
1947
-	 * order status.
1948
-	 *
1949
-	 * @since 1.0.19
1950
-	 */
1951
-	public function maybe_set_date_paid() {
1943
+    /**
1944
+     * Maybe set date paid.
1945
+     *
1946
+     * Sets the date paid variable when transitioning to the payment complete
1947
+     * order status.
1948
+     *
1949
+     * @since 1.0.19
1950
+     */
1951
+    public function maybe_set_date_paid() {
1952 1952
 
1953
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1954
-			$this->set_date_completed( current_time( 'mysql' ) );
1955
-		}
1956
-	}
1953
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1954
+            $this->set_date_completed( current_time( 'mysql' ) );
1955
+        }
1956
+    }
1957 1957
 
1958 1958
     /**
1959
-	 * Set parent invoice ID.
1960
-	 *
1961
-	 * @since 1.0.19
1962
-	 */
1963
-	public function set_parent_id( $value ) {
1964
-		if ( $value && ( $value === $this->get_id() ) ) {
1965
-			return;
1966
-		}
1967
-		$this->set_prop( 'parent_id', absint( $value ) );
1959
+     * Set parent invoice ID.
1960
+     *
1961
+     * @since 1.0.19
1962
+     */
1963
+    public function set_parent_id( $value ) {
1964
+        if ( $value && ( $value === $this->get_id() ) ) {
1965
+            return;
1966
+        }
1967
+        $this->set_prop( 'parent_id', absint( $value ) );
1968 1968
     }
1969 1969
 
1970 1970
     /**
1971
-	 * Set plugin version when the invoice was created.
1972
-	 *
1973
-	 * @since 1.0.19
1974
-	 */
1975
-	public function set_version( $value ) {
1976
-		$this->set_prop( 'version', $value );
1971
+     * Set plugin version when the invoice was created.
1972
+     *
1973
+     * @since 1.0.19
1974
+     */
1975
+    public function set_version( $value ) {
1976
+        $this->set_prop( 'version', $value );
1977 1977
     }
1978
-
1979
-    /**
1980
-	 * Set date when the invoice was created.
1981
-	 *
1982
-	 * @since 1.0.19
1983
-	 * @param string $value Value to set.
1978
+
1979
+    /**
1980
+     * Set date when the invoice was created.
1981
+     *
1982
+     * @since 1.0.19
1983
+     * @param string $value Value to set.
1984 1984
      * @return bool Whether or not the date was set.
1985
-	 */
1986
-	public function set_date_created( $value ) {
1985
+     */
1986
+    public function set_date_created( $value ) {
1987 1987
         $date = strtotime( $value );
1988 1988
 
1989 1989
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1991,19 +1991,19 @@  discard block
 block discarded – undo
1991 1991
             return true;
1992 1992
         }
1993 1993
 
1994
-		$this->set_prop( 'date_created', '' );
1995
-		return false;
1994
+        $this->set_prop( 'date_created', '' );
1995
+        return false;
1996 1996
 
1997 1997
     }
1998 1998
 
1999 1999
     /**
2000
-	 * Set date invoice due date.
2001
-	 *
2002
-	 * @since 1.0.19
2003
-	 * @param string $value Value to set.
2000
+     * Set date invoice due date.
2001
+     *
2002
+     * @since 1.0.19
2003
+     * @param string $value Value to set.
2004 2004
      * @return bool Whether or not the date was set.
2005
-	 */
2006
-	public function set_due_date( $value ) {
2005
+     */
2006
+    public function set_due_date( $value ) {
2007 2007
         $date = strtotime( $value );
2008 2008
 
2009 2009
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2011,29 +2011,29 @@  discard block
 block discarded – undo
2011 2011
             return true;
2012 2012
         }
2013 2013
 
2014
-		$this->set_prop( 'due_date', '' );
2014
+        $this->set_prop( 'due_date', '' );
2015 2015
         return false;
2016 2016
 
2017 2017
     }
2018 2018
 
2019 2019
     /**
2020
-	 * Alias of self::set_due_date().
2021
-	 *
2022
-	 * @since 1.0.19
2023
-	 * @param  string $value New name.
2024
-	 */
2025
-	public function set_date_due( $value ) {
2026
-		$this->set_due_date( $value );
2020
+     * Alias of self::set_due_date().
2021
+     *
2022
+     * @since 1.0.19
2023
+     * @param  string $value New name.
2024
+     */
2025
+    public function set_date_due( $value ) {
2026
+        $this->set_due_date( $value );
2027 2027
     }
2028 2028
 
2029 2029
     /**
2030
-	 * Set date invoice was completed.
2031
-	 *
2032
-	 * @since 1.0.19
2033
-	 * @param string $value Value to set.
2030
+     * Set date invoice was completed.
2031
+     *
2032
+     * @since 1.0.19
2033
+     * @param string $value Value to set.
2034 2034
      * @return bool Whether or not the date was set.
2035
-	 */
2036
-	public function set_completed_date( $value ) {
2035
+     */
2036
+    public function set_completed_date( $value ) {
2037 2037
         $date = strtotime( $value );
2038 2038
 
2039 2039
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -2041,29 +2041,29 @@  discard block
 block discarded – undo
2041 2041
             return true;
2042 2042
         }
2043 2043
 
2044
-		$this->set_prop( 'completed_date', '' );
2044
+        $this->set_prop( 'completed_date', '' );
2045 2045
         return false;
2046 2046
 
2047 2047
     }
2048 2048
 
2049 2049
     /**
2050
-	 * Alias of self::set_completed_date().
2051
-	 *
2052
-	 * @since 1.0.19
2053
-	 * @param  string $value New name.
2054
-	 */
2055
-	public function set_date_completed( $value ) {
2056
-		$this->set_completed_date( $value );
2050
+     * Alias of self::set_completed_date().
2051
+     *
2052
+     * @since 1.0.19
2053
+     * @param  string $value New name.
2054
+     */
2055
+    public function set_date_completed( $value ) {
2056
+        $this->set_completed_date( $value );
2057 2057
     }
2058 2058
 
2059 2059
     /**
2060
-	 * Set date when the invoice was last modified.
2061
-	 *
2062
-	 * @since 1.0.19
2063
-	 * @param string $value Value to set.
2060
+     * Set date when the invoice was last modified.
2061
+     *
2062
+     * @since 1.0.19
2063
+     * @param string $value Value to set.
2064 2064
      * @return bool Whether or not the date was set.
2065
-	 */
2066
-	public function set_date_modified( $value ) {
2065
+     */
2066
+    public function set_date_modified( $value ) {
2067 2067
         $date = strtotime( $value );
2068 2068
 
2069 2069
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2071,763 +2071,763 @@  discard block
 block discarded – undo
2071 2071
             return true;
2072 2072
         }
2073 2073
 
2074
-		$this->set_prop( 'date_modified', '' );
2074
+        $this->set_prop( 'date_modified', '' );
2075 2075
         return false;
2076 2076
 
2077 2077
     }
2078 2078
 
2079 2079
     /**
2080
-	 * Set the invoice number.
2081
-	 *
2082
-	 * @since 1.0.19
2083
-	 * @param  string $value New number.
2084
-	 */
2085
-	public function set_number( $value ) {
2080
+     * Set the invoice number.
2081
+     *
2082
+     * @since 1.0.19
2083
+     * @param  string $value New number.
2084
+     */
2085
+    public function set_number( $value ) {
2086 2086
         $number = sanitize_text_field( $value );
2087
-		$this->set_prop( 'number', $number );
2087
+        $this->set_prop( 'number', $number );
2088 2088
     }
2089 2089
 
2090 2090
     /**
2091
-	 * Set the invoice type.
2092
-	 *
2093
-	 * @since 1.0.19
2094
-	 * @param  string $value Type.
2095
-	 */
2096
-	public function set_type( $value ) {
2091
+     * Set the invoice type.
2092
+     *
2093
+     * @since 1.0.19
2094
+     * @param  string $value Type.
2095
+     */
2096
+    public function set_type( $value ) {
2097 2097
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2098
-		$this->set_prop( 'type', $type );
2099
-	}
2098
+        $this->set_prop( 'type', $type );
2099
+    }
2100 2100
 
2101 2101
     /**
2102
-	 * Set the invoice post type.
2103
-	 *
2104
-	 * @since 1.0.19
2105
-	 * @param  string $value Post type.
2106
-	 */
2107
-	public function set_post_type( $value ) {
2102
+     * Set the invoice post type.
2103
+     *
2104
+     * @since 1.0.19
2105
+     * @param  string $value Post type.
2106
+     */
2107
+    public function set_post_type( $value ) {
2108 2108
         if ( getpaid_is_invoice_post_type( $value ) ) {
2109
-			$this->set_type( $value );
2109
+            $this->set_type( $value );
2110 2110
             $this->set_prop( 'post_type', $value );
2111 2111
         }
2112 2112
     }
2113 2113
 
2114 2114
     /**
2115
-	 * Set the invoice key.
2116
-	 *
2117
-	 * @since 1.0.19
2118
-	 * @param  string $value New key.
2119
-	 */
2120
-	public function set_key( $value ) {
2115
+     * Set the invoice key.
2116
+     *
2117
+     * @since 1.0.19
2118
+     * @param  string $value New key.
2119
+     */
2120
+    public function set_key( $value ) {
2121 2121
         $key = sanitize_text_field( $value );
2122
-		$this->set_prop( 'key', $key );
2122
+        $this->set_prop( 'key', $key );
2123 2123
     }
2124 2124
 
2125 2125
     /**
2126
-	 * Set the invoice mode.
2127
-	 *
2128
-	 * @since 1.0.19
2129
-	 * @param  string $value mode.
2130
-	 */
2131
-	public function set_mode( $value ) {
2126
+     * Set the invoice mode.
2127
+     *
2128
+     * @since 1.0.19
2129
+     * @param  string $value mode.
2130
+     */
2131
+    public function set_mode( $value ) {
2132 2132
         if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2133 2133
             $this->set_prop( 'value', $value );
2134 2134
         }
2135 2135
     }
2136 2136
 
2137 2137
     /**
2138
-	 * Set the invoice path.
2139
-	 *
2140
-	 * @since 1.0.19
2141
-	 * @param  string $value path.
2142
-	 */
2143
-	public function set_path( $value ) {
2138
+     * Set the invoice path.
2139
+     *
2140
+     * @since 1.0.19
2141
+     * @param  string $value path.
2142
+     */
2143
+    public function set_path( $value ) {
2144 2144
         $this->set_prop( 'path', $value );
2145 2145
     }
2146 2146
 
2147 2147
     /**
2148
-	 * Set the invoice name.
2149
-	 *
2150
-	 * @since 1.0.19
2151
-	 * @param  string $value New name.
2152
-	 */
2153
-	public function set_name( $value ) {
2148
+     * Set the invoice name.
2149
+     *
2150
+     * @since 1.0.19
2151
+     * @param  string $value New name.
2152
+     */
2153
+    public function set_name( $value ) {
2154 2154
         $name = sanitize_text_field( $value );
2155
-		$this->set_prop( 'name', $name );
2155
+        $this->set_prop( 'name', $name );
2156 2156
     }
2157 2157
 
2158 2158
     /**
2159
-	 * Alias of self::set_name().
2160
-	 *
2161
-	 * @since 1.0.19
2162
-	 * @param  string $value New name.
2163
-	 */
2164
-	public function set_title( $value ) {
2165
-		$this->set_name( $value );
2159
+     * Alias of self::set_name().
2160
+     *
2161
+     * @since 1.0.19
2162
+     * @param  string $value New name.
2163
+     */
2164
+    public function set_title( $value ) {
2165
+        $this->set_name( $value );
2166 2166
     }
2167 2167
 
2168 2168
     /**
2169
-	 * Set the invoice description.
2170
-	 *
2171
-	 * @since 1.0.19
2172
-	 * @param  string $value New description.
2173
-	 */
2174
-	public function set_description( $value ) {
2169
+     * Set the invoice description.
2170
+     *
2171
+     * @since 1.0.19
2172
+     * @param  string $value New description.
2173
+     */
2174
+    public function set_description( $value ) {
2175 2175
         $description = wp_kses_post( $value );
2176
-		$this->set_prop( 'description', $description );
2176
+        $this->set_prop( 'description', $description );
2177
+    }
2178
+
2179
+    /**
2180
+     * Alias of self::set_description().
2181
+     *
2182
+     * @since 1.0.19
2183
+     * @param  string $value New description.
2184
+     */
2185
+    public function set_excerpt( $value ) {
2186
+        $this->set_description( $value );
2187
+    }
2188
+
2189
+    /**
2190
+     * Alias of self::set_description().
2191
+     *
2192
+     * @since 1.0.19
2193
+     * @param  string $value New description.
2194
+     */
2195
+    public function set_summary( $value ) {
2196
+        $this->set_description( $value );
2177 2197
     }
2178 2198
 
2179 2199
     /**
2180
-	 * Alias of self::set_description().
2181
-	 *
2182
-	 * @since 1.0.19
2183
-	 * @param  string $value New description.
2184
-	 */
2185
-	public function set_excerpt( $value ) {
2186
-		$this->set_description( $value );
2200
+     * Set the receiver of the invoice.
2201
+     *
2202
+     * @since 1.0.19
2203
+     * @param  int $value New author.
2204
+     */
2205
+    public function set_author( $value ) {
2206
+        $user = get_user_by( 'id', (int) $value );
2207
+
2208
+        if ( $user && $user->ID ) {
2209
+            $this->set_prop( 'author', $user->ID );
2210
+            $this->set_prop( 'email', $user->user_email );
2211
+        }
2212
+
2187 2213
     }
2188 2214
 
2189 2215
     /**
2190
-	 * Alias of self::set_description().
2191
-	 *
2192
-	 * @since 1.0.19
2193
-	 * @param  string $value New description.
2194
-	 */
2195
-	public function set_summary( $value ) {
2196
-		$this->set_description( $value );
2216
+     * Alias of self::set_author().
2217
+     *
2218
+     * @since 1.0.19
2219
+     * @param  int $value New user id.
2220
+     */
2221
+    public function set_user_id( $value ) {
2222
+        $this->set_author( $value );
2197 2223
     }
2198 2224
 
2199 2225
     /**
2200
-	 * Set the receiver of the invoice.
2201
-	 *
2202
-	 * @since 1.0.19
2203
-	 * @param  int $value New author.
2204
-	 */
2205
-	public function set_author( $value ) {
2206
-		$user = get_user_by( 'id', (int) $value );
2226
+     * Alias of self::set_author().
2227
+     *
2228
+     * @since 1.0.19
2229
+     * @param  int $value New user id.
2230
+     */
2231
+    public function set_customer_id( $value ) {
2232
+        $this->set_author( $value );
2233
+    }
2207 2234
 
2208
-		if ( $user && $user->ID ) {
2209
-			$this->set_prop( 'author', $user->ID );
2210
-			$this->set_prop( 'email', $user->user_email );
2211
-		}
2235
+    /**
2236
+     * Set the customer's ip.
2237
+     *
2238
+     * @since 1.0.19
2239
+     * @param  string $value ip address.
2240
+     */
2241
+    public function set_ip( $value ) {
2242
+        $this->set_prop( 'ip', $value );
2243
+    }
2212 2244
 
2245
+    /**
2246
+     * Alias of self::set_ip().
2247
+     *
2248
+     * @since 1.0.19
2249
+     * @param  string $value ip address.
2250
+     */
2251
+    public function set_user_ip( $value ) {
2252
+        $this->set_ip( $value );
2213 2253
     }
2214 2254
 
2215 2255
     /**
2216
-	 * Alias of self::set_author().
2217
-	 *
2218
-	 * @since 1.0.19
2219
-	 * @param  int $value New user id.
2220
-	 */
2221
-	public function set_user_id( $value ) {
2222
-		$this->set_author( $value );
2256
+     * Set the customer's first name.
2257
+     *
2258
+     * @since 1.0.19
2259
+     * @param  string $value first name.
2260
+     */
2261
+    public function set_first_name( $value ) {
2262
+        $this->set_prop( 'first_name', $value );
2223 2263
     }
2224 2264
 
2225 2265
     /**
2226
-	 * Alias of self::set_author().
2227
-	 *
2228
-	 * @since 1.0.19
2229
-	 * @param  int $value New user id.
2230
-	 */
2231
-	public function set_customer_id( $value ) {
2232
-		$this->set_author( $value );
2266
+     * Alias of self::set_first_name().
2267
+     *
2268
+     * @since 1.0.19
2269
+     * @param  string $value first name.
2270
+     */
2271
+    public function set_user_first_name( $value ) {
2272
+        $this->set_first_name( $value );
2233 2273
     }
2234 2274
 
2235 2275
     /**
2236
-	 * Set the customer's ip.
2237
-	 *
2238
-	 * @since 1.0.19
2239
-	 * @param  string $value ip address.
2240
-	 */
2241
-	public function set_ip( $value ) {
2242
-		$this->set_prop( 'ip', $value );
2276
+     * Alias of self::set_first_name().
2277
+     *
2278
+     * @since 1.0.19
2279
+     * @param  string $value first name.
2280
+     */
2281
+    public function set_customer_first_name( $value ) {
2282
+        $this->set_first_name( $value );
2243 2283
     }
2244 2284
 
2245 2285
     /**
2246
-	 * Alias of self::set_ip().
2247
-	 *
2248
-	 * @since 1.0.19
2249
-	 * @param  string $value ip address.
2250
-	 */
2251
-	public function set_user_ip( $value ) {
2252
-		$this->set_ip( $value );
2286
+     * Set the customer's last name.
2287
+     *
2288
+     * @since 1.0.19
2289
+     * @param  string $value last name.
2290
+     */
2291
+    public function set_last_name( $value ) {
2292
+        $this->set_prop( 'last_name', $value );
2253 2293
     }
2254 2294
 
2255 2295
     /**
2256
-	 * Set the customer's first name.
2257
-	 *
2258
-	 * @since 1.0.19
2259
-	 * @param  string $value first name.
2260
-	 */
2261
-	public function set_first_name( $value ) {
2262
-		$this->set_prop( 'first_name', $value );
2296
+     * Alias of self::set_last_name().
2297
+     *
2298
+     * @since 1.0.19
2299
+     * @param  string $value last name.
2300
+     */
2301
+    public function set_user_last_name( $value ) {
2302
+        $this->set_last_name( $value );
2263 2303
     }
2264 2304
 
2265 2305
     /**
2266
-	 * Alias of self::set_first_name().
2267
-	 *
2268
-	 * @since 1.0.19
2269
-	 * @param  string $value first name.
2270
-	 */
2271
-	public function set_user_first_name( $value ) {
2272
-		$this->set_first_name( $value );
2306
+     * Alias of self::set_last_name().
2307
+     *
2308
+     * @since 1.0.19
2309
+     * @param  string $value last name.
2310
+     */
2311
+    public function set_customer_last_name( $value ) {
2312
+        $this->set_last_name( $value );
2273 2313
     }
2274 2314
 
2275 2315
     /**
2276
-	 * Alias of self::set_first_name().
2277
-	 *
2278
-	 * @since 1.0.19
2279
-	 * @param  string $value first name.
2280
-	 */
2281
-	public function set_customer_first_name( $value ) {
2282
-		$this->set_first_name( $value );
2316
+     * Set the customer's phone number.
2317
+     *
2318
+     * @since 1.0.19
2319
+     * @param  string $value phone.
2320
+     */
2321
+    public function set_phone( $value ) {
2322
+        $this->set_prop( 'phone', $value );
2283 2323
     }
2284 2324
 
2285 2325
     /**
2286
-	 * Set the customer's last name.
2287
-	 *
2288
-	 * @since 1.0.19
2289
-	 * @param  string $value last name.
2290
-	 */
2291
-	public function set_last_name( $value ) {
2292
-		$this->set_prop( 'last_name', $value );
2326
+     * Alias of self::set_phone().
2327
+     *
2328
+     * @since 1.0.19
2329
+     * @param  string $value phone.
2330
+     */
2331
+    public function set_user_phone( $value ) {
2332
+        $this->set_phone( $value );
2293 2333
     }
2294 2334
 
2295 2335
     /**
2296
-	 * Alias of self::set_last_name().
2297
-	 *
2298
-	 * @since 1.0.19
2299
-	 * @param  string $value last name.
2300
-	 */
2301
-	public function set_user_last_name( $value ) {
2302
-		$this->set_last_name( $value );
2336
+     * Alias of self::set_phone().
2337
+     *
2338
+     * @since 1.0.19
2339
+     * @param  string $value phone.
2340
+     */
2341
+    public function set_customer_phone( $value ) {
2342
+        $this->set_phone( $value );
2303 2343
     }
2304 2344
 
2305 2345
     /**
2306
-	 * Alias of self::set_last_name().
2307
-	 *
2308
-	 * @since 1.0.19
2309
-	 * @param  string $value last name.
2310
-	 */
2311
-	public function set_customer_last_name( $value ) {
2312
-		$this->set_last_name( $value );
2346
+     * Alias of self::set_phone().
2347
+     *
2348
+     * @since 1.0.19
2349
+     * @param  string $value phone.
2350
+     */
2351
+    public function set_phone_number( $value ) {
2352
+        $this->set_phone( $value );
2313 2353
     }
2314 2354
 
2315 2355
     /**
2316
-	 * Set the customer's phone number.
2317
-	 *
2318
-	 * @since 1.0.19
2319
-	 * @param  string $value phone.
2320
-	 */
2321
-	public function set_phone( $value ) {
2322
-		$this->set_prop( 'phone', $value );
2356
+     * Set the customer's email address.
2357
+     *
2358
+     * @since 1.0.19
2359
+     * @param  string $value email address.
2360
+     */
2361
+    public function set_email( $value ) {
2362
+        $this->set_prop( 'email', $value );
2323 2363
     }
2324 2364
 
2325 2365
     /**
2326
-	 * Alias of self::set_phone().
2327
-	 *
2328
-	 * @since 1.0.19
2329
-	 * @param  string $value phone.
2330
-	 */
2331
-	public function set_user_phone( $value ) {
2332
-		$this->set_phone( $value );
2366
+     * Alias of self::set_email().
2367
+     *
2368
+     * @since 1.0.19
2369
+     * @param  string $value email address.
2370
+     */
2371
+    public function set_user_email( $value ) {
2372
+        $this->set_email( $value );
2333 2373
     }
2334 2374
 
2335 2375
     /**
2336
-	 * Alias of self::set_phone().
2337
-	 *
2338
-	 * @since 1.0.19
2339
-	 * @param  string $value phone.
2340
-	 */
2341
-	public function set_customer_phone( $value ) {
2342
-		$this->set_phone( $value );
2376
+     * Alias of self::set_email().
2377
+     *
2378
+     * @since 1.0.19
2379
+     * @param  string $value email address.
2380
+     */
2381
+    public function set_email_address( $value ) {
2382
+        $this->set_email( $value );
2343 2383
     }
2344 2384
 
2345 2385
     /**
2346
-	 * Alias of self::set_phone().
2347
-	 *
2348
-	 * @since 1.0.19
2349
-	 * @param  string $value phone.
2350
-	 */
2351
-	public function set_phone_number( $value ) {
2352
-		$this->set_phone( $value );
2386
+     * Alias of self::set_email().
2387
+     *
2388
+     * @since 1.0.19
2389
+     * @param  string $value email address.
2390
+     */
2391
+    public function set_customer_email( $value ) {
2392
+        $this->set_email( $value );
2353 2393
     }
2354 2394
 
2355 2395
     /**
2356
-	 * Set the customer's email address.
2357
-	 *
2358
-	 * @since 1.0.19
2359
-	 * @param  string $value email address.
2360
-	 */
2361
-	public function set_email( $value ) {
2362
-		$this->set_prop( 'email', $value );
2396
+     * Set the customer's country.
2397
+     *
2398
+     * @since 1.0.19
2399
+     * @param  string $value country.
2400
+     */
2401
+    public function set_country( $value ) {
2402
+        $this->set_prop( 'country', $value );
2363 2403
     }
2364 2404
 
2365 2405
     /**
2366
-	 * Alias of self::set_email().
2367
-	 *
2368
-	 * @since 1.0.19
2369
-	 * @param  string $value email address.
2370
-	 */
2371
-	public function set_user_email( $value ) {
2372
-		$this->set_email( $value );
2406
+     * Alias of self::set_country().
2407
+     *
2408
+     * @since 1.0.19
2409
+     * @param  string $value country.
2410
+     */
2411
+    public function set_user_country( $value ) {
2412
+        $this->set_country( $value );
2373 2413
     }
2374 2414
 
2375 2415
     /**
2376
-	 * Alias of self::set_email().
2377
-	 *
2378
-	 * @since 1.0.19
2379
-	 * @param  string $value email address.
2380
-	 */
2381
-	public function set_email_address( $value ) {
2382
-		$this->set_email( $value );
2416
+     * Alias of self::set_country().
2417
+     *
2418
+     * @since 1.0.19
2419
+     * @param  string $value country.
2420
+     */
2421
+    public function set_customer_country( $value ) {
2422
+        $this->set_country( $value );
2383 2423
     }
2384 2424
 
2385 2425
     /**
2386
-	 * Alias of self::set_email().
2387
-	 *
2388
-	 * @since 1.0.19
2389
-	 * @param  string $value email address.
2390
-	 */
2391
-	public function set_customer_email( $value ) {
2392
-		$this->set_email( $value );
2426
+     * Set the customer's state.
2427
+     *
2428
+     * @since 1.0.19
2429
+     * @param  string $value state.
2430
+     */
2431
+    public function set_state( $value ) {
2432
+        $this->set_prop( 'state', $value );
2393 2433
     }
2394 2434
 
2395 2435
     /**
2396
-	 * Set the customer's country.
2397
-	 *
2398
-	 * @since 1.0.19
2399
-	 * @param  string $value country.
2400
-	 */
2401
-	public function set_country( $value ) {
2402
-		$this->set_prop( 'country', $value );
2436
+     * Alias of self::set_state().
2437
+     *
2438
+     * @since 1.0.19
2439
+     * @param  string $value state.
2440
+     */
2441
+    public function set_user_state( $value ) {
2442
+        $this->set_state( $value );
2403 2443
     }
2404 2444
 
2405 2445
     /**
2406
-	 * Alias of self::set_country().
2407
-	 *
2408
-	 * @since 1.0.19
2409
-	 * @param  string $value country.
2410
-	 */
2411
-	public function set_user_country( $value ) {
2412
-		$this->set_country( $value );
2446
+     * Alias of self::set_state().
2447
+     *
2448
+     * @since 1.0.19
2449
+     * @param  string $value state.
2450
+     */
2451
+    public function set_customer_state( $value ) {
2452
+        $this->set_state( $value );
2413 2453
     }
2414 2454
 
2415 2455
     /**
2416
-	 * Alias of self::set_country().
2417
-	 *
2418
-	 * @since 1.0.19
2419
-	 * @param  string $value country.
2420
-	 */
2421
-	public function set_customer_country( $value ) {
2422
-		$this->set_country( $value );
2456
+     * Set the customer's city.
2457
+     *
2458
+     * @since 1.0.19
2459
+     * @param  string $value city.
2460
+     */
2461
+    public function set_city( $value ) {
2462
+        $this->set_prop( 'city', $value );
2423 2463
     }
2424 2464
 
2425 2465
     /**
2426
-	 * Set the customer's state.
2427
-	 *
2428
-	 * @since 1.0.19
2429
-	 * @param  string $value state.
2430
-	 */
2431
-	public function set_state( $value ) {
2432
-		$this->set_prop( 'state', $value );
2466
+     * Alias of self::set_city().
2467
+     *
2468
+     * @since 1.0.19
2469
+     * @param  string $value city.
2470
+     */
2471
+    public function set_user_city( $value ) {
2472
+        $this->set_city( $value );
2433 2473
     }
2434 2474
 
2435 2475
     /**
2436
-	 * Alias of self::set_state().
2437
-	 *
2438
-	 * @since 1.0.19
2439
-	 * @param  string $value state.
2440
-	 */
2441
-	public function set_user_state( $value ) {
2442
-		$this->set_state( $value );
2476
+     * Alias of self::set_city().
2477
+     *
2478
+     * @since 1.0.19
2479
+     * @param  string $value city.
2480
+     */
2481
+    public function set_customer_city( $value ) {
2482
+        $this->set_city( $value );
2443 2483
     }
2444 2484
 
2445 2485
     /**
2446
-	 * Alias of self::set_state().
2447
-	 *
2448
-	 * @since 1.0.19
2449
-	 * @param  string $value state.
2450
-	 */
2451
-	public function set_customer_state( $value ) {
2452
-		$this->set_state( $value );
2486
+     * Set the customer's zip code.
2487
+     *
2488
+     * @since 1.0.19
2489
+     * @param  string $value zip.
2490
+     */
2491
+    public function set_zip( $value ) {
2492
+        $this->set_prop( 'zip', $value );
2453 2493
     }
2454 2494
 
2455 2495
     /**
2456
-	 * Set the customer's city.
2457
-	 *
2458
-	 * @since 1.0.19
2459
-	 * @param  string $value city.
2460
-	 */
2461
-	public function set_city( $value ) {
2462
-		$this->set_prop( 'city', $value );
2496
+     * Alias of self::set_zip().
2497
+     *
2498
+     * @since 1.0.19
2499
+     * @param  string $value zip.
2500
+     */
2501
+    public function set_user_zip( $value ) {
2502
+        $this->set_zip( $value );
2463 2503
     }
2464 2504
 
2465 2505
     /**
2466
-	 * Alias of self::set_city().
2467
-	 *
2468
-	 * @since 1.0.19
2469
-	 * @param  string $value city.
2470
-	 */
2471
-	public function set_user_city( $value ) {
2472
-		$this->set_city( $value );
2506
+     * Alias of self::set_zip().
2507
+     *
2508
+     * @since 1.0.19
2509
+     * @param  string $value zip.
2510
+     */
2511
+    public function set_customer_zip( $value ) {
2512
+        $this->set_zip( $value );
2473 2513
     }
2474 2514
 
2475 2515
     /**
2476
-	 * Alias of self::set_city().
2477
-	 *
2478
-	 * @since 1.0.19
2479
-	 * @param  string $value city.
2480
-	 */
2481
-	public function set_customer_city( $value ) {
2482
-		$this->set_city( $value );
2516
+     * Set the customer's company.
2517
+     *
2518
+     * @since 1.0.19
2519
+     * @param  string $value company.
2520
+     */
2521
+    public function set_company( $value ) {
2522
+        $this->set_prop( 'company', $value );
2483 2523
     }
2484 2524
 
2485 2525
     /**
2486
-	 * Set the customer's zip code.
2487
-	 *
2488
-	 * @since 1.0.19
2489
-	 * @param  string $value zip.
2490
-	 */
2491
-	public function set_zip( $value ) {
2492
-		$this->set_prop( 'zip', $value );
2526
+     * Alias of self::set_company().
2527
+     *
2528
+     * @since 1.0.19
2529
+     * @param  string $value company.
2530
+     */
2531
+    public function set_user_company( $value ) {
2532
+        $this->set_company( $value );
2493 2533
     }
2494 2534
 
2495 2535
     /**
2496
-	 * Alias of self::set_zip().
2497
-	 *
2498
-	 * @since 1.0.19
2499
-	 * @param  string $value zip.
2500
-	 */
2501
-	public function set_user_zip( $value ) {
2502
-		$this->set_zip( $value );
2536
+     * Alias of self::set_company().
2537
+     *
2538
+     * @since 1.0.19
2539
+     * @param  string $value company.
2540
+     */
2541
+    public function set_customer_company( $value ) {
2542
+        $this->set_company( $value );
2503 2543
     }
2504 2544
 
2505 2545
     /**
2506
-	 * Alias of self::set_zip().
2507
-	 *
2508
-	 * @since 1.0.19
2509
-	 * @param  string $value zip.
2510
-	 */
2511
-	public function set_customer_zip( $value ) {
2512
-		$this->set_zip( $value );
2546
+     * Set the customer's var number.
2547
+     *
2548
+     * @since 1.0.19
2549
+     * @param  string $value var number.
2550
+     */
2551
+    public function set_vat_number( $value ) {
2552
+        $this->set_prop( 'vat_number', $value );
2513 2553
     }
2514 2554
 
2515 2555
     /**
2516
-	 * Set the customer's company.
2517
-	 *
2518
-	 * @since 1.0.19
2519
-	 * @param  string $value company.
2520
-	 */
2521
-	public function set_company( $value ) {
2522
-		$this->set_prop( 'company', $value );
2556
+     * Alias of self::set_vat_number().
2557
+     *
2558
+     * @since 1.0.19
2559
+     * @param  string $value var number.
2560
+     */
2561
+    public function set_user_vat_number( $value ) {
2562
+        $this->set_vat_number( $value );
2523 2563
     }
2524 2564
 
2525 2565
     /**
2526
-	 * Alias of self::set_company().
2527
-	 *
2528
-	 * @since 1.0.19
2529
-	 * @param  string $value company.
2530
-	 */
2531
-	public function set_user_company( $value ) {
2532
-		$this->set_company( $value );
2566
+     * Alias of self::set_vat_number().
2567
+     *
2568
+     * @since 1.0.19
2569
+     * @param  string $value var number.
2570
+     */
2571
+    public function set_customer_vat_number( $value ) {
2572
+        $this->set_vat_number( $value );
2533 2573
     }
2534 2574
 
2535 2575
     /**
2536
-	 * Alias of self::set_company().
2537
-	 *
2538
-	 * @since 1.0.19
2539
-	 * @param  string $value company.
2540
-	 */
2541
-	public function set_customer_company( $value ) {
2542
-		$this->set_company( $value );
2576
+     * Set the customer's vat rate.
2577
+     *
2578
+     * @since 1.0.19
2579
+     * @param  string $value var rate.
2580
+     */
2581
+    public function set_vat_rate( $value ) {
2582
+        $this->set_prop( 'vat_rate', $value );
2543 2583
     }
2544 2584
 
2545 2585
     /**
2546
-	 * Set the customer's var number.
2547
-	 *
2548
-	 * @since 1.0.19
2549
-	 * @param  string $value var number.
2550
-	 */
2551
-	public function set_vat_number( $value ) {
2552
-		$this->set_prop( 'vat_number', $value );
2586
+     * Alias of self::set_vat_rate().
2587
+     *
2588
+     * @since 1.0.19
2589
+     * @param  string $value var number.
2590
+     */
2591
+    public function set_user_vat_rate( $value ) {
2592
+        $this->set_vat_rate( $value );
2553 2593
     }
2554 2594
 
2555 2595
     /**
2556
-	 * Alias of self::set_vat_number().
2557
-	 *
2558
-	 * @since 1.0.19
2559
-	 * @param  string $value var number.
2560
-	 */
2561
-	public function set_user_vat_number( $value ) {
2562
-		$this->set_vat_number( $value );
2596
+     * Alias of self::set_vat_rate().
2597
+     *
2598
+     * @since 1.0.19
2599
+     * @param  string $value var number.
2600
+     */
2601
+    public function set_customer_vat_rate( $value ) {
2602
+        $this->set_vat_rate( $value );
2563 2603
     }
2564 2604
 
2565 2605
     /**
2566
-	 * Alias of self::set_vat_number().
2567
-	 *
2568
-	 * @since 1.0.19
2569
-	 * @param  string $value var number.
2570
-	 */
2571
-	public function set_customer_vat_number( $value ) {
2572
-		$this->set_vat_number( $value );
2606
+     * Set the customer's address.
2607
+     *
2608
+     * @since 1.0.19
2609
+     * @param  string $value address.
2610
+     */
2611
+    public function set_address( $value ) {
2612
+        $this->set_prop( 'address', $value );
2573 2613
     }
2574 2614
 
2575 2615
     /**
2576
-	 * Set the customer's vat rate.
2577
-	 *
2578
-	 * @since 1.0.19
2579
-	 * @param  string $value var rate.
2580
-	 */
2581
-	public function set_vat_rate( $value ) {
2582
-		$this->set_prop( 'vat_rate', $value );
2616
+     * Alias of self::set_address().
2617
+     *
2618
+     * @since 1.0.19
2619
+     * @param  string $value address.
2620
+     */
2621
+    public function set_user_address( $value ) {
2622
+        $this->set_address( $value );
2583 2623
     }
2584 2624
 
2585 2625
     /**
2586
-	 * Alias of self::set_vat_rate().
2587
-	 *
2588
-	 * @since 1.0.19
2589
-	 * @param  string $value var number.
2590
-	 */
2591
-	public function set_user_vat_rate( $value ) {
2592
-		$this->set_vat_rate( $value );
2626
+     * Alias of self::set_address().
2627
+     *
2628
+     * @since 1.0.19
2629
+     * @param  string $value address.
2630
+     */
2631
+    public function set_customer_address( $value ) {
2632
+        $this->set_address( $value );
2593 2633
     }
2594 2634
 
2595 2635
     /**
2596
-	 * Alias of self::set_vat_rate().
2597
-	 *
2598
-	 * @since 1.0.19
2599
-	 * @param  string $value var number.
2600
-	 */
2601
-	public function set_customer_vat_rate( $value ) {
2602
-		$this->set_vat_rate( $value );
2636
+     * Set whether the customer has viewed the invoice or not.
2637
+     *
2638
+     * @since 1.0.19
2639
+     * @param  int|bool $value confirmed.
2640
+     */
2641
+    public function set_is_viewed( $value ) {
2642
+        $this->set_prop( 'is_viewed', $value );
2603 2643
     }
2604 2644
 
2605 2645
     /**
2606
-	 * Set the customer's address.
2607
-	 *
2608
-	 * @since 1.0.19
2609
-	 * @param  string $value address.
2610
-	 */
2611
-	public function set_address( $value ) {
2612
-		$this->set_prop( 'address', $value );
2646
+     * Set extra email recipients.
2647
+     *
2648
+     * @since 1.0.19
2649
+     * @param  string $value email recipients.
2650
+     */
2651
+    public function set_email_cc( $value ) {
2652
+        $this->set_prop( 'email_cc', $value );
2613 2653
     }
2614 2654
 
2615 2655
     /**
2616
-	 * Alias of self::set_address().
2617
-	 *
2618
-	 * @since 1.0.19
2619
-	 * @param  string $value address.
2620
-	 */
2621
-	public function set_user_address( $value ) {
2622
-		$this->set_address( $value );
2656
+     * Set the invoice template.
2657
+     *
2658
+     * @since 1.0.19
2659
+     * @param  string $value template.
2660
+     */
2661
+    public function set_template( $value ) {
2662
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2663
+            $this->set_prop( 'template', $value );
2664
+        }
2623 2665
     }
2624 2666
 
2625 2667
     /**
2626
-	 * Alias of self::set_address().
2627
-	 *
2628
-	 * @since 1.0.19
2629
-	 * @param  string $value address.
2630
-	 */
2631
-	public function set_customer_address( $value ) {
2632
-		$this->set_address( $value );
2668
+     * Set the invoice source.
2669
+     *
2670
+     * @since 1.0.19
2671
+     * @param  string $value email recipients.
2672
+     */
2673
+    public function created_via( $value ) {
2674
+        $this->set_prop( 'created_via', sanitize_text_field( $value ) );
2633 2675
     }
2634 2676
 
2635 2677
     /**
2636
-	 * Set whether the customer has viewed the invoice or not.
2637
-	 *
2638
-	 * @since 1.0.19
2639
-	 * @param  int|bool $value confirmed.
2640
-	 */
2641
-	public function set_is_viewed( $value ) {
2642
-		$this->set_prop( 'is_viewed', $value );
2643
-	}
2644
-
2645
-	/**
2646
-	 * Set extra email recipients.
2647
-	 *
2648
-	 * @since 1.0.19
2649
-	 * @param  string $value email recipients.
2650
-	 */
2651
-	public function set_email_cc( $value ) {
2652
-		$this->set_prop( 'email_cc', $value );
2653
-	}
2654
-
2655
-	/**
2656
-	 * Set the invoice template.
2657
-	 *
2658
-	 * @since 1.0.19
2659
-	 * @param  string $value template.
2660
-	 */
2661
-	public function set_template( $value ) {
2662
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2663
-			$this->set_prop( 'template', $value );
2664
-		}
2665
-	}
2666
-
2667
-	/**
2668
-	 * Set the invoice source.
2669
-	 *
2670
-	 * @since 1.0.19
2671
-	 * @param  string $value email recipients.
2672
-	 */
2673
-	public function created_via( $value ) {
2674
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2675
-	}
2676
-
2677
-	/**
2678
-	 * Set the customer's address confirmed status.
2679
-	 *
2680
-	 * @since 1.0.19
2681
-	 * @param  int|bool $value confirmed.
2682
-	 */
2683
-	public function set_address_confirmed( $value ) {
2684
-		$this->set_prop( 'address_confirmed', $value );
2678
+     * Set the customer's address confirmed status.
2679
+     *
2680
+     * @since 1.0.19
2681
+     * @param  int|bool $value confirmed.
2682
+     */
2683
+    public function set_address_confirmed( $value ) {
2684
+        $this->set_prop( 'address_confirmed', $value );
2685 2685
     }
2686 2686
 
2687 2687
     /**
2688
-	 * Alias of self::set_address_confirmed().
2689
-	 *
2690
-	 * @since 1.0.19
2691
-	 * @param  int|bool $value confirmed.
2692
-	 */
2693
-	public function set_user_address_confirmed( $value ) {
2694
-		$this->set_address_confirmed( $value );
2688
+     * Alias of self::set_address_confirmed().
2689
+     *
2690
+     * @since 1.0.19
2691
+     * @param  int|bool $value confirmed.
2692
+     */
2693
+    public function set_user_address_confirmed( $value ) {
2694
+        $this->set_address_confirmed( $value );
2695 2695
     }
2696 2696
 
2697 2697
     /**
2698
-	 * Alias of self::set_address_confirmed().
2699
-	 *
2700
-	 * @since 1.0.19
2701
-	 * @param  int|bool $value confirmed.
2702
-	 */
2703
-	public function set_customer_address_confirmed( $value ) {
2704
-		$this->set_address_confirmed( $value );
2698
+     * Alias of self::set_address_confirmed().
2699
+     *
2700
+     * @since 1.0.19
2701
+     * @param  int|bool $value confirmed.
2702
+     */
2703
+    public function set_customer_address_confirmed( $value ) {
2704
+        $this->set_address_confirmed( $value );
2705 2705
     }
2706 2706
 
2707 2707
     /**
2708
-	 * Set the invoice sub total.
2709
-	 *
2710
-	 * @since 1.0.19
2711
-	 * @param  float $value sub total.
2712
-	 */
2713
-	public function set_subtotal( $value ) {
2714
-		$this->set_prop( 'subtotal', $value );
2708
+     * Set the invoice sub total.
2709
+     *
2710
+     * @since 1.0.19
2711
+     * @param  float $value sub total.
2712
+     */
2713
+    public function set_subtotal( $value ) {
2714
+        $this->set_prop( 'subtotal', $value );
2715 2715
     }
2716 2716
 
2717 2717
     /**
2718
-	 * Set the invoice discount amount.
2719
-	 *
2720
-	 * @since 1.0.19
2721
-	 * @param  float $value discount total.
2722
-	 */
2723
-	public function set_total_discount( $value ) {
2724
-		$this->set_prop( 'total_discount', $value );
2718
+     * Set the invoice discount amount.
2719
+     *
2720
+     * @since 1.0.19
2721
+     * @param  float $value discount total.
2722
+     */
2723
+    public function set_total_discount( $value ) {
2724
+        $this->set_prop( 'total_discount', $value );
2725 2725
     }
2726 2726
 
2727 2727
     /**
2728
-	 * Alias of self::set_total_discount().
2729
-	 *
2730
-	 * @since 1.0.19
2731
-	 * @param  float $value discount total.
2732
-	 */
2733
-	public function set_discount( $value ) {
2734
-		$this->set_total_discount( $value );
2728
+     * Alias of self::set_total_discount().
2729
+     *
2730
+     * @since 1.0.19
2731
+     * @param  float $value discount total.
2732
+     */
2733
+    public function set_discount( $value ) {
2734
+        $this->set_total_discount( $value );
2735 2735
     }
2736 2736
 
2737 2737
     /**
2738
-	 * Set the invoice tax amount.
2739
-	 *
2740
-	 * @since 1.0.19
2741
-	 * @param  float $value tax total.
2742
-	 */
2743
-	public function set_total_tax( $value ) {
2744
-		$this->set_prop( 'total_tax', $value );
2738
+     * Set the invoice tax amount.
2739
+     *
2740
+     * @since 1.0.19
2741
+     * @param  float $value tax total.
2742
+     */
2743
+    public function set_total_tax( $value ) {
2744
+        $this->set_prop( 'total_tax', $value );
2745 2745
     }
2746 2746
 
2747 2747
     /**
2748
-	 * Alias of self::set_total_tax().
2749
-	 *
2750
-	 * @since 1.0.19
2751
-	 * @param  float $value tax total.
2752
-	 */
2753
-	public function set_tax_total( $value ) {
2754
-		$this->set_total_tax( $value );
2748
+     * Alias of self::set_total_tax().
2749
+     *
2750
+     * @since 1.0.19
2751
+     * @param  float $value tax total.
2752
+     */
2753
+    public function set_tax_total( $value ) {
2754
+        $this->set_total_tax( $value );
2755 2755
     }
2756 2756
 
2757 2757
     /**
2758
-	 * Set the invoice fees amount.
2759
-	 *
2760
-	 * @since 1.0.19
2761
-	 * @param  float $value fees total.
2762
-	 */
2763
-	public function set_total_fees( $value ) {
2764
-		$this->set_prop( 'total_fees', $value );
2758
+     * Set the invoice fees amount.
2759
+     *
2760
+     * @since 1.0.19
2761
+     * @param  float $value fees total.
2762
+     */
2763
+    public function set_total_fees( $value ) {
2764
+        $this->set_prop( 'total_fees', $value );
2765 2765
     }
2766 2766
 
2767 2767
     /**
2768
-	 * Alias of self::set_total_fees().
2769
-	 *
2770
-	 * @since 1.0.19
2771
-	 * @param  float $value fees total.
2772
-	 */
2773
-	public function set_fees_total( $value ) {
2774
-		$this->set_total_fees( $value );
2768
+     * Alias of self::set_total_fees().
2769
+     *
2770
+     * @since 1.0.19
2771
+     * @param  float $value fees total.
2772
+     */
2773
+    public function set_fees_total( $value ) {
2774
+        $this->set_total_fees( $value );
2775 2775
     }
2776 2776
 
2777 2777
     /**
2778
-	 * Set the invoice fees.
2779
-	 *
2780
-	 * @since 1.0.19
2781
-	 * @param  array $value fees.
2782
-	 */
2783
-	public function set_fees( $value ) {
2778
+     * Set the invoice fees.
2779
+     *
2780
+     * @since 1.0.19
2781
+     * @param  array $value fees.
2782
+     */
2783
+    public function set_fees( $value ) {
2784 2784
 
2785
-		if ( ! is_array( $value ) ) {
2786
-			$value = array();
2787
-		}
2785
+        if ( ! is_array( $value ) ) {
2786
+            $value = array();
2787
+        }
2788 2788
 
2789
-		$this->set_prop( 'fees', $value );
2789
+        $this->set_prop( 'fees', $value );
2790 2790
 
2791 2791
     }
2792 2792
 
2793 2793
     /**
2794
-	 * Set the invoice taxes.
2795
-	 *
2796
-	 * @since 1.0.19
2797
-	 * @param  array $value taxes.
2798
-	 */
2799
-	public function set_taxes( $value ) {
2794
+     * Set the invoice taxes.
2795
+     *
2796
+     * @since 1.0.19
2797
+     * @param  array $value taxes.
2798
+     */
2799
+    public function set_taxes( $value ) {
2800 2800
 
2801
-		if ( ! is_array( $value ) ) {
2802
-			$value = array();
2803
-		}
2801
+        if ( ! is_array( $value ) ) {
2802
+            $value = array();
2803
+        }
2804 2804
 
2805
-		$this->set_prop( 'taxes', $value );
2805
+        $this->set_prop( 'taxes', $value );
2806 2806
 
2807 2807
     }
2808 2808
 
2809 2809
     /**
2810
-	 * Set the invoice discounts.
2811
-	 *
2812
-	 * @since 1.0.19
2813
-	 * @param  array $value discounts.
2814
-	 */
2815
-	public function set_discounts( $value ) {
2810
+     * Set the invoice discounts.
2811
+     *
2812
+     * @since 1.0.19
2813
+     * @param  array $value discounts.
2814
+     */
2815
+    public function set_discounts( $value ) {
2816 2816
 
2817
-		if ( ! is_array( $value ) ) {
2818
-			$value = array();
2819
-		}
2817
+        if ( ! is_array( $value ) ) {
2818
+            $value = array();
2819
+        }
2820 2820
 
2821
-		$this->set_prop( 'discounts', $value );
2821
+        $this->set_prop( 'discounts', $value );
2822 2822
     }
2823 2823
 
2824 2824
     /**
2825
-	 * Set the invoice items.
2826
-	 *
2827
-	 * @since 1.0.19
2828
-	 * @param  GetPaid_Form_Item[] $value items.
2829
-	 */
2830
-	public function set_items( $value ) {
2825
+     * Set the invoice items.
2826
+     *
2827
+     * @since 1.0.19
2828
+     * @param  GetPaid_Form_Item[] $value items.
2829
+     */
2830
+    public function set_items( $value ) {
2831 2831
 
2832 2832
         // Remove existing items.
2833 2833
         $this->set_prop( 'items', array() );
@@ -2844,95 +2844,95 @@  discard block
 block discarded – undo
2844 2844
     }
2845 2845
 
2846 2846
     /**
2847
-	 * Set the payment form.
2848
-	 *
2849
-	 * @since 1.0.19
2850
-	 * @param  int $value payment form.
2851
-	 */
2852
-	public function set_payment_form( $value ) {
2853
-		$this->set_prop( 'payment_form', $value );
2847
+     * Set the payment form.
2848
+     *
2849
+     * @since 1.0.19
2850
+     * @param  int $value payment form.
2851
+     */
2852
+    public function set_payment_form( $value ) {
2853
+        $this->set_prop( 'payment_form', $value );
2854 2854
     }
2855 2855
 
2856 2856
     /**
2857
-	 * Set the submission id.
2858
-	 *
2859
-	 * @since 1.0.19
2860
-	 * @param  string $value submission id.
2861
-	 */
2862
-	public function set_submission_id( $value ) {
2863
-		$this->set_prop( 'submission_id', $value );
2857
+     * Set the submission id.
2858
+     *
2859
+     * @since 1.0.19
2860
+     * @param  string $value submission id.
2861
+     */
2862
+    public function set_submission_id( $value ) {
2863
+        $this->set_prop( 'submission_id', $value );
2864 2864
     }
2865 2865
 
2866 2866
     /**
2867
-	 * Set the discount code.
2868
-	 *
2869
-	 * @since 1.0.19
2870
-	 * @param  string $value discount code.
2871
-	 */
2872
-	public function set_discount_code( $value ) {
2873
-		$this->set_prop( 'discount_code', $value );
2867
+     * Set the discount code.
2868
+     *
2869
+     * @since 1.0.19
2870
+     * @param  string $value discount code.
2871
+     */
2872
+    public function set_discount_code( $value ) {
2873
+        $this->set_prop( 'discount_code', $value );
2874 2874
     }
2875 2875
 
2876 2876
     /**
2877
-	 * Set the gateway.
2878
-	 *
2879
-	 * @since 1.0.19
2880
-	 * @param  string $value gateway.
2881
-	 */
2882
-	public function set_gateway( $value ) {
2883
-		$this->set_prop( 'gateway', $value );
2877
+     * Set the gateway.
2878
+     *
2879
+     * @since 1.0.19
2880
+     * @param  string $value gateway.
2881
+     */
2882
+    public function set_gateway( $value ) {
2883
+        $this->set_prop( 'gateway', $value );
2884 2884
     }
2885 2885
 
2886 2886
     /**
2887
-	 * Set the transaction id.
2888
-	 *
2889
-	 * @since 1.0.19
2890
-	 * @param  string $value transaction id.
2891
-	 */
2892
-	public function set_transaction_id( $value ) {
2893
-		if ( ! empty( $value ) ) {
2894
-			$this->set_prop( 'transaction_id', $value );
2895
-		}
2887
+     * Set the transaction id.
2888
+     *
2889
+     * @since 1.0.19
2890
+     * @param  string $value transaction id.
2891
+     */
2892
+    public function set_transaction_id( $value ) {
2893
+        if ( ! empty( $value ) ) {
2894
+            $this->set_prop( 'transaction_id', $value );
2895
+        }
2896 2896
     }
2897 2897
 
2898 2898
     /**
2899
-	 * Set the currency id.
2900
-	 *
2901
-	 * @since 1.0.19
2902
-	 * @param  string $value currency id.
2903
-	 */
2904
-	public function set_currency( $value ) {
2905
-		$this->set_prop( 'currency', $value );
2899
+     * Set the currency id.
2900
+     *
2901
+     * @since 1.0.19
2902
+     * @param  string $value currency id.
2903
+     */
2904
+    public function set_currency( $value ) {
2905
+        $this->set_prop( 'currency', $value );
2906 2906
     }
2907 2907
 
2908
-	/**
2909
-	 * Set whether to disable taxes.
2910
-	 *
2911
-	 * @since 1.0.19
2912
-	 * @param  bool $value value.
2913
-	 */
2914
-	public function set_disable_taxes( $value ) {
2915
-		$this->set_prop( 'disable_taxes', (bool) $value );
2916
-	}
2908
+    /**
2909
+     * Set whether to disable taxes.
2910
+     *
2911
+     * @since 1.0.19
2912
+     * @param  bool $value value.
2913
+     */
2914
+    public function set_disable_taxes( $value ) {
2915
+        $this->set_prop( 'disable_taxes', (bool) $value );
2916
+    }
2917 2917
 
2918 2918
     /**
2919
-	 * Set the subscription id.
2920
-	 *
2921
-	 * @since 1.0.19
2922
-	 * @param  string $value subscription id.
2923
-	 */
2924
-	public function set_subscription_id( $value ) {
2925
-		$this->set_prop( 'subscription_id', $value );
2926
-	}
2919
+     * Set the subscription id.
2920
+     *
2921
+     * @since 1.0.19
2922
+     * @param  string $value subscription id.
2923
+     */
2924
+    public function set_subscription_id( $value ) {
2925
+        $this->set_prop( 'subscription_id', $value );
2926
+    }
2927 2927
 	
2928
-	/**
2929
-	 * Set the remote subscription id.
2930
-	 *
2931
-	 * @since 1.0.19
2932
-	 * @param  string $value subscription id.
2933
-	 */
2934
-	public function set_remote_subscription_id( $value ) {
2935
-		$this->set_prop( 'remote_subscription_id', $value );
2928
+    /**
2929
+     * Set the remote subscription id.
2930
+     *
2931
+     * @since 1.0.19
2932
+     * @param  string $value subscription id.
2933
+     */
2934
+    public function set_remote_subscription_id( $value ) {
2935
+        $this->set_prop( 'remote_subscription_id', $value );
2936 2936
     }
2937 2937
 
2938 2938
     /*
@@ -2971,24 +2971,24 @@  discard block
 block discarded – undo
2971 2971
      */
2972 2972
     public function is_taxable() {
2973 2973
         return ! $this->get_disable_taxes();
2974
-	}
2974
+    }
2975 2975
 
2976
-	/**
2977
-	 * @deprecated
2978
-	 */
2979
-	public function has_vat() {
2976
+    /**
2977
+     * @deprecated
2978
+     */
2979
+    public function has_vat() {
2980 2980
         return $this->is_taxable();
2981
-	}
2981
+    }
2982 2982
 
2983
-	/**
2984
-	 * Checks to see if the invoice requires payment.
2985
-	 */
2986
-	public function is_free() {
2983
+    /**
2984
+     * Checks to see if the invoice requires payment.
2985
+     */
2986
+    public function is_free() {
2987 2987
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2988 2988
 
2989
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2990
-			$is_free = false;
2991
-		}
2989
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2990
+            $is_free = false;
2991
+        }
2992 2992
 
2993 2993
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2994 2994
     }
@@ -2999,46 +2999,46 @@  discard block
 block discarded – undo
2999 2999
     public function is_paid() {
3000 3000
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3001 3001
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3002
-	}
3002
+    }
3003 3003
 
3004
-	/**
3004
+    /**
3005 3005
      * Checks if the invoice needs payment.
3006 3006
      */
3007
-	public function needs_payment() {
3008
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3007
+    public function needs_payment() {
3008
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3009 3009
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3010 3010
     }
3011 3011
   
3012
-	/**
3012
+    /**
3013 3013
      * Checks if the invoice is refunded.
3014 3014
      */
3015
-	public function is_refunded() {
3015
+    public function is_refunded() {
3016 3016
         $is_refunded = $this->has_status( 'wpi-refunded' );
3017 3017
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3018
-	}
3018
+    }
3019 3019
 
3020
-	/**
3020
+    /**
3021 3021
      * Checks if the invoice is held.
3022 3022
      */
3023
-	public function is_held() {
3023
+    public function is_held() {
3024 3024
         $is_held = $this->has_status( 'wpi-onhold' );
3025 3025
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3026
-	}
3026
+    }
3027 3027
 
3028
-	/**
3028
+    /**
3029 3029
      * Checks if the invoice is due.
3030 3030
      */
3031
-	public function is_due() {
3032
-		$due_date = $this->get_due_date();
3033
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3034
-	}
3031
+    public function is_due() {
3032
+        $due_date = $this->get_due_date();
3033
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3034
+    }
3035 3035
 
3036
-	/**
3036
+    /**
3037 3037
      * Checks if the invoice is draft.
3038 3038
      */
3039
-	public function is_draft() {
3039
+    public function is_draft() {
3040 3040
         return $this->has_status( 'draft, auto-draft' );
3041
-	}
3041
+    }
3042 3042
 
3043 3043
     /**
3044 3044
      * Checks if the invoice has a given status.
@@ -3046,9 +3046,9 @@  discard block
 block discarded – undo
3046 3046
     public function has_status( $status ) {
3047 3047
         $status = wpinv_parse_list( $status );
3048 3048
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3049
-	}
3049
+    }
3050 3050
 
3051
-	/**
3051
+    /**
3052 3052
      * Checks if the invoice is of a given type.
3053 3053
      */
3054 3054
     public function is_type( $type ) {
@@ -3071,25 +3071,25 @@  discard block
 block discarded – undo
3071 3071
      */
3072 3072
     public function has_free_trial() {
3073 3073
         return $this->is_recurring() && 0 == $this->get_initial_total();
3074
-	}
3074
+    }
3075 3075
 
3076
-	/**
3076
+    /**
3077 3077
      * @deprecated
3078 3078
      */
3079 3079
     public function is_free_trial() {
3080 3080
         $this->has_free_trial();
3081 3081
     }
3082 3082
 
3083
-	/**
3083
+    /**
3084 3084
      * Check if the initial payment if 0.
3085 3085
      *
3086 3086
      */
3087
-	public function is_initial_free() {
3087
+    public function is_initial_free() {
3088 3088
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3089 3089
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3090 3090
     }
3091 3091
 	
3092
-	/**
3092
+    /**
3093 3093
      * Check if the recurring item has a free trial.
3094 3094
      *
3095 3095
      */
@@ -3102,21 +3102,21 @@  discard block
 block discarded – undo
3102 3102
 
3103 3103
         $item = $this->get_recurring( true );
3104 3104
         return $item->has_free_trial();
3105
-	}
3105
+    }
3106 3106
 
3107
-	/**
3107
+    /**
3108 3108
      * Check if the free trial is a result of a discount.
3109 3109
      */
3110 3110
     public function is_free_trial_from_discount() {
3111
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3112
-	}
3111
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3112
+    }
3113 3113
 	
3114
-	/**
3114
+    /**
3115 3115
      * @deprecated
3116 3116
      */
3117 3117
     public function discount_first_payment_only() {
3118 3118
 
3119
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3119
+        $discount = wpinv_get_discount_obj( $this->get_discount_code() );
3120 3120
         if ( ! $discount->exists() || ! $this->is_recurring() ) {
3121 3121
             return true;
3122 3122
         }
@@ -3141,28 +3141,28 @@  discard block
 block discarded – undo
3141 3141
      */
3142 3142
     public function add_item( $item ) {
3143 3143
 
3144
-		if ( is_array( $item ) ) {
3145
-			$item = $this->process_array_item( $item );
3146
-		}
3144
+        if ( is_array( $item ) ) {
3145
+            $item = $this->process_array_item( $item );
3146
+        }
3147 3147
 
3148
-		if ( is_numeric( $item ) ) {
3149
-			$item = new GetPaid_Form_Item( $item );
3150
-		}
3148
+        if ( is_numeric( $item ) ) {
3149
+            $item = new GetPaid_Form_Item( $item );
3150
+        }
3151 3151
 
3152 3152
         // Make sure that it is available for purchase.
3153
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3154
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3153
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3154
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3155 3155
         }
3156 3156
 
3157 3157
         // Do we have a recurring item?
3158
-		if ( $item->is_recurring() ) {
3158
+        if ( $item->is_recurring() ) {
3159 3159
 
3160
-			// An invoice can only contain one recurring item.
3161
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3162
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3163
-			}
3160
+            // An invoice can only contain one recurring item.
3161
+            if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3162
+                return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3163
+            }
3164 3164
 
3165
-			$this->recurring_item = $item->get_id();
3165
+            $this->recurring_item = $item->get_id();
3166 3166
         }
3167 3167
 
3168 3168
         // Invoice id.
@@ -3173,60 +3173,60 @@  discard block
 block discarded – undo
3173 3173
         $items[ (int) $item->get_id() ] = $item;
3174 3174
 
3175 3175
         $this->set_prop( 'items', $items );
3176
-		return true;
3177
-	}
3176
+        return true;
3177
+    }
3178 3178
 
3179
-	/**
3180
-	 * Converts an array to an item.
3181
-	 *
3182
-	 * @since 1.0.19
3183
-	 * @return GetPaid_Form_Item
3184
-	 */
3185
-	protected function process_array_item( $array ) {
3179
+    /**
3180
+     * Converts an array to an item.
3181
+     *
3182
+     * @since 1.0.19
3183
+     * @return GetPaid_Form_Item
3184
+     */
3185
+    protected function process_array_item( $array ) {
3186 3186
 
3187
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3188
-		$item    = new GetPaid_Form_Item( $item_id );
3187
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3188
+        $item    = new GetPaid_Form_Item( $item_id );
3189 3189
 
3190
-		// Set item data.
3191
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3192
-			if ( isset( $array[ "item_$key" ] ) ) {
3193
-				$method = "set_$key";
3194
-				$item->$method( $array[ "item_$key" ] );
3195
-			}
3196
-		}
3190
+        // Set item data.
3191
+        foreach ( array( 'name', 'price', 'description' ) as $key ) {
3192
+            if ( isset( $array[ "item_$key" ] ) ) {
3193
+                $method = "set_$key";
3194
+                $item->$method( $array[ "item_$key" ] );
3195
+            }
3196
+        }
3197 3197
 
3198
-		if ( isset( $array['quantity'] ) ) {
3199
-			$item->set_quantity( $array['quantity'] );
3200
-		}
3198
+        if ( isset( $array['quantity'] ) ) {
3199
+            $item->set_quantity( $array['quantity'] );
3200
+        }
3201 3201
 
3202
-		// Set item meta.
3203
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3204
-			$item->set_item_meta( $array['meta'] );
3205
-		}
3202
+        // Set item meta.
3203
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3204
+            $item->set_item_meta( $array['meta'] );
3205
+        }
3206 3206
 
3207
-		return $item;
3207
+        return $item;
3208 3208
 
3209
-	}
3209
+    }
3210 3210
 
3211 3211
     /**
3212
-	 * Retrieves a specific item.
3213
-	 *
3214
-	 * @since 1.0.19
3215
-	 */
3216
-	public function get_item( $item_id ) {
3217
-		$items   = $this->get_items();
3218
-		$item_id = (int) $item_id;
3219
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3212
+     * Retrieves a specific item.
3213
+     *
3214
+     * @since 1.0.19
3215
+     */
3216
+    public function get_item( $item_id ) {
3217
+        $items   = $this->get_items();
3218
+        $item_id = (int) $item_id;
3219
+        return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3220 3220
     }
3221 3221
 
3222 3222
     /**
3223
-	 * Removes a specific item.
3224
-	 *
3225
-	 * @since 1.0.19
3226
-	 */
3227
-	public function remove_item( $item_id ) {
3228
-		$items   = $this->get_items();
3229
-		$item_id = (int) $item_id;
3223
+     * Removes a specific item.
3224
+     *
3225
+     * @since 1.0.19
3226
+     */
3227
+    public function remove_item( $item_id ) {
3228
+        $items   = $this->get_items();
3229
+        $item_id = (int) $item_id;
3230 3230
 
3231 3231
         if ( $item_id == $this->recurring_item ) {
3232 3232
             $this->recurring_item = null;
@@ -3239,35 +3239,35 @@  discard block
 block discarded – undo
3239 3239
     }
3240 3240
 
3241 3241
     /**
3242
-	 * Adds a fee to the invoice.
3243
-	 *
3244
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3245
-	 * @since 1.0.19
3246
-	 */
3242
+     * Adds a fee to the invoice.
3243
+     *
3244
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3245
+     * @since 1.0.19
3246
+     */
3247 3247
     public function add_fee( $fee ) {
3248 3248
 
3249
-		$fees                 = $this->get_fees();
3250
-		$fees[ $fee['name'] ] = $fee;
3251
-		$this->set_prop( 'fees', $fees );
3249
+        $fees                 = $this->get_fees();
3250
+        $fees[ $fee['name'] ] = $fee;
3251
+        $this->set_prop( 'fees', $fees );
3252 3252
 
3253 3253
     }
3254 3254
 
3255 3255
     /**
3256
-	 * Retrieves a specific fee.
3257
-	 *
3258
-	 * @since 1.0.19
3259
-	 */
3260
-	public function get_fee( $fee ) {
3256
+     * Retrieves a specific fee.
3257
+     *
3258
+     * @since 1.0.19
3259
+     */
3260
+    public function get_fee( $fee ) {
3261 3261
         $fees = $this->get_fees();
3262
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3262
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3263 3263
     }
3264 3264
 
3265 3265
     /**
3266
-	 * Removes a specific fee.
3267
-	 *
3268
-	 * @since 1.0.19
3269
-	 */
3270
-	public function remove_fee( $fee ) {
3266
+     * Removes a specific fee.
3267
+     *
3268
+     * @since 1.0.19
3269
+     */
3270
+    public function remove_fee( $fee ) {
3271 3271
         $fees = $this->get_fees();
3272 3272
         if ( isset( $fees[ $fee ] ) ) {
3273 3273
             unset( $fees[ $fee ] );
@@ -3275,43 +3275,43 @@  discard block
 block discarded – undo
3275 3275
         }
3276 3276
     }
3277 3277
 
3278
-	/**
3279
-	 * Adds a discount to the invoice.
3280
-	 *
3281
-	 * @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.
3282
-	 * @since 1.0.19
3283
-	 */
3284
-	public function add_discount( $discount ) {
3278
+    /**
3279
+     * Adds a discount to the invoice.
3280
+     *
3281
+     * @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.
3282
+     * @since 1.0.19
3283
+     */
3284
+    public function add_discount( $discount ) {
3285 3285
 
3286
-		$discounts = $this->get_discounts();
3287
-		$discounts[ $discount['name'] ] = $discount;
3288
-		$this->set_prop( 'discounts', $discounts );
3286
+        $discounts = $this->get_discounts();
3287
+        $discounts[ $discount['name'] ] = $discount;
3288
+        $this->set_prop( 'discounts', $discounts );
3289 3289
 
3290
-	}
3290
+    }
3291 3291
 
3292 3292
     /**
3293
-	 * Retrieves a specific discount.
3294
-	 *
3295
-	 * @since 1.0.19
3296
-	 * @return float
3297
-	 */
3298
-	public function get_discount( $discount = false ) {
3293
+     * Retrieves a specific discount.
3294
+     *
3295
+     * @since 1.0.19
3296
+     * @return float
3297
+     */
3298
+    public function get_discount( $discount = false ) {
3299 3299
 
3300
-		// Backwards compatibilty.
3301
-		if ( empty( $discount ) ) {
3302
-			return $this->get_total_discount();
3303
-		}
3300
+        // Backwards compatibilty.
3301
+        if ( empty( $discount ) ) {
3302
+            return $this->get_total_discount();
3303
+        }
3304 3304
 
3305 3305
         $discounts = $this->get_discounts();
3306
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3306
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3307 3307
     }
3308 3308
 
3309 3309
     /**
3310
-	 * Removes a specific discount.
3311
-	 *
3312
-	 * @since 1.0.19
3313
-	 */
3314
-	public function remove_discount( $discount ) {
3310
+     * Removes a specific discount.
3311
+     *
3312
+     * @since 1.0.19
3313
+     */
3314
+    public function remove_discount( $discount ) {
3315 3315
         $discounts = $this->get_discounts();
3316 3316
         if ( isset( $discounts[ $discount ] ) ) {
3317 3317
             unset( $discounts[ $discount ] );
@@ -3328,34 +3328,34 @@  discard block
 block discarded – undo
3328 3328
         if ( $this->is_taxable() ) {
3329 3329
 
3330 3330
             $taxes                 = $this->get_taxes();
3331
-			$taxes[ $tax['name'] ] = $tax;
3332
-			$this->set_prop( 'taxes', $tax );
3331
+            $taxes[ $tax['name'] ] = $tax;
3332
+            $this->set_prop( 'taxes', $tax );
3333 3333
 
3334 3334
         }
3335 3335
     }
3336 3336
 
3337 3337
     /**
3338
-	 * Retrieves a specific tax.
3339
-	 *
3340
-	 * @since 1.0.19
3341
-	 */
3342
-	public function get_tax( $tax = null ) {
3338
+     * Retrieves a specific tax.
3339
+     *
3340
+     * @since 1.0.19
3341
+     */
3342
+    public function get_tax( $tax = null ) {
3343 3343
 
3344
-		// Backwards compatility.
3345
-		if ( empty( $tax ) ) {
3346
-			return $this->get_total_tax();
3347
-		}
3344
+        // Backwards compatility.
3345
+        if ( empty( $tax ) ) {
3346
+            return $this->get_total_tax();
3347
+        }
3348 3348
 
3349 3349
         $taxes = $this->get_taxes();
3350
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3350
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3351 3351
     }
3352 3352
 
3353 3353
     /**
3354
-	 * Removes a specific tax.
3355
-	 *
3356
-	 * @since 1.0.19
3357
-	 */
3358
-	public function remove_tax( $tax ) {
3354
+     * Removes a specific tax.
3355
+     *
3356
+     * @since 1.0.19
3357
+     */
3358
+    public function remove_tax( $tax ) {
3359 3359
         $taxes = $this->get_taxes();
3360 3360
         if ( isset( $taxes[ $tax ] ) ) {
3361 3361
             unset( $taxes[ $tax ] );
@@ -3364,134 +3364,134 @@  discard block
 block discarded – undo
3364 3364
     }
3365 3365
 
3366 3366
     /**
3367
-	 * Recalculates the invoice subtotal.
3368
-	 *
3369
-	 * @since 1.0.19
3370
-	 * @return float The recalculated subtotal
3371
-	 */
3372
-	public function recalculate_subtotal() {
3367
+     * Recalculates the invoice subtotal.
3368
+     *
3369
+     * @since 1.0.19
3370
+     * @return float The recalculated subtotal
3371
+     */
3372
+    public function recalculate_subtotal() {
3373 3373
         $items     = $this->get_items();
3374
-		$subtotal  = 0;
3375
-		$recurring = 0;
3374
+        $subtotal  = 0;
3375
+        $recurring = 0;
3376 3376
 
3377 3377
         foreach ( $items as $item ) {
3378
-			$subtotal  += $item->get_sub_total();
3379
-			$recurring += $item->get_recurring_sub_total();
3378
+            $subtotal  += $item->get_sub_total();
3379
+            $recurring += $item->get_recurring_sub_total();
3380 3380
         }
3381 3381
 
3382
-		$current = $this->is_renewal() ? $recurring : $subtotal;
3383
-		$this->set_subtotal( $current );
3382
+        $current = $this->is_renewal() ? $recurring : $subtotal;
3383
+        $this->set_subtotal( $current );
3384 3384
 
3385
-		$this->totals['subtotal'] = array(
3386
-			'initial'   => $subtotal,
3387
-			'recurring' => $recurring,
3388
-		);
3385
+        $this->totals['subtotal'] = array(
3386
+            'initial'   => $subtotal,
3387
+            'recurring' => $recurring,
3388
+        );
3389 3389
 
3390 3390
         return $current;
3391 3391
     }
3392 3392
 
3393 3393
     /**
3394
-	 * Recalculates the invoice discount total.
3395
-	 *
3396
-	 * @since 1.0.19
3397
-	 * @return float The recalculated discount
3398
-	 */
3399
-	public function recalculate_total_discount() {
3394
+     * Recalculates the invoice discount total.
3395
+     *
3396
+     * @since 1.0.19
3397
+     * @return float The recalculated discount
3398
+     */
3399
+    public function recalculate_total_discount() {
3400 3400
         $discounts = $this->get_discounts();
3401
-		$discount  = 0;
3402
-		$recurring = 0;
3401
+        $discount  = 0;
3402
+        $recurring = 0;
3403 3403
 
3404 3404
         foreach ( $discounts as $data ) {
3405
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3406
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3407
-		}
3405
+            $discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3406
+            $recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3407
+        }
3408 3408
 
3409
-		$current = $this->is_renewal() ? $recurring : $discount;
3409
+        $current = $this->is_renewal() ? $recurring : $discount;
3410 3410
 
3411
-		$this->set_total_discount( $current );
3411
+        $this->set_total_discount( $current );
3412 3412
 
3413
-		$this->totals['discount'] = array(
3414
-			'initial'   => $discount,
3415
-			'recurring' => $recurring,
3416
-		);
3413
+        $this->totals['discount'] = array(
3414
+            'initial'   => $discount,
3415
+            'recurring' => $recurring,
3416
+        );
3417 3417
 
3418
-		return $current;
3418
+        return $current;
3419 3419
 
3420 3420
     }
3421 3421
 
3422 3422
     /**
3423
-	 * Recalculates the invoice tax total.
3424
-	 *
3425
-	 * @since 1.0.19
3426
-	 * @return float The recalculated tax
3427
-	 */
3428
-	public function recalculate_total_tax() {
3423
+     * Recalculates the invoice tax total.
3424
+     *
3425
+     * @since 1.0.19
3426
+     * @return float The recalculated tax
3427
+     */
3428
+    public function recalculate_total_tax() {
3429 3429
         $taxes     = $this->get_taxes();
3430
-		$tax       = 0;
3431
-		$recurring = 0;
3430
+        $tax       = 0;
3431
+        $recurring = 0;
3432 3432
 
3433 3433
         foreach ( $taxes as $data ) {
3434
-			$tax       += wpinv_sanitize_amount( $data['initial_tax'] );
3435
-			$recurring += wpinv_sanitize_amount( $data['recurring_tax'] );
3436
-		}
3434
+            $tax       += wpinv_sanitize_amount( $data['initial_tax'] );
3435
+            $recurring += wpinv_sanitize_amount( $data['recurring_tax'] );
3436
+        }
3437 3437
 
3438
-		$current = $this->is_renewal() ? $recurring : $tax;
3439
-		$this->set_total_tax( $current );
3438
+        $current = $this->is_renewal() ? $recurring : $tax;
3439
+        $this->set_total_tax( $current );
3440 3440
 
3441
-		$this->totals['tax'] = array(
3442
-			'initial'   => $tax,
3443
-			'recurring' => $recurring,
3444
-		);
3441
+        $this->totals['tax'] = array(
3442
+            'initial'   => $tax,
3443
+            'recurring' => $recurring,
3444
+        );
3445 3445
 
3446
-		return $current;
3446
+        return $current;
3447 3447
 
3448 3448
     }
3449 3449
 
3450 3450
     /**
3451
-	 * Recalculates the invoice fees total.
3452
-	 *
3453
-	 * @since 1.0.19
3454
-	 * @return float The recalculated fee
3455
-	 */
3456
-	public function recalculate_total_fees() {
3457
-		$fees      = $this->get_fees();
3458
-		$fee       = 0;
3459
-		$recurring = 0;
3451
+     * Recalculates the invoice fees total.
3452
+     *
3453
+     * @since 1.0.19
3454
+     * @return float The recalculated fee
3455
+     */
3456
+    public function recalculate_total_fees() {
3457
+        $fees      = $this->get_fees();
3458
+        $fee       = 0;
3459
+        $recurring = 0;
3460 3460
 
3461 3461
         foreach ( $fees as $data ) {
3462
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3463
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3464
-		}
3462
+            $fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3463
+            $recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3464
+        }
3465 3465
 
3466
-		$current = $this->is_renewal() ? $recurring : $fee;
3467
-		$this->set_total_fees( $current );
3466
+        $current = $this->is_renewal() ? $recurring : $fee;
3467
+        $this->set_total_fees( $current );
3468 3468
 
3469
-		$this->totals['fee'] = array(
3470
-			'initial'   => $fee,
3471
-			'recurring' => $recurring,
3472
-		);
3469
+        $this->totals['fee'] = array(
3470
+            'initial'   => $fee,
3471
+            'recurring' => $recurring,
3472
+        );
3473 3473
 
3474 3474
         $this->set_total_fees( $fee );
3475 3475
         return $current;
3476 3476
     }
3477 3477
 
3478 3478
     /**
3479
-	 * Recalculates the invoice total.
3480
-	 *
3481
-	 * @since 1.0.19
3479
+     * Recalculates the invoice total.
3480
+     *
3481
+     * @since 1.0.19
3482 3482
      * @return float The invoice total
3483
-	 */
3484
-	public function recalculate_total() {
3483
+     */
3484
+    public function recalculate_total() {
3485 3485
         $this->recalculate_subtotal();
3486 3486
         $this->recalculate_total_fees();
3487 3487
         $this->recalculate_total_discount();
3488 3488
         $this->recalculate_total_tax();
3489
-		return $this->get_total();
3490
-	}
3489
+        return $this->get_total();
3490
+    }
3491 3491
 
3492
-	/**
3493
-	 * @deprecated
3494
-	 */
3492
+    /**
3493
+     * @deprecated
3494
+     */
3495 3495
     public function recalculate_totals() {
3496 3496
         $this->recalculate_total();
3497 3497
         $this->save( true );
@@ -3509,7 +3509,7 @@  discard block
 block discarded – undo
3509 3509
      * Adds a note to an invoice.
3510 3510
      *
3511 3511
      * @param string $note The note being added.
3512
-	 * @return int|false The new note's ID on success, false on failure.
3512
+     * @return int|false The new note's ID on success, false on failure.
3513 3513
      *
3514 3514
      */
3515 3515
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3519,21 +3519,21 @@  discard block
 block discarded – undo
3519 3519
             return false;
3520 3520
         }
3521 3521
 
3522
-		$author       = 'System';
3523
-		$author_email = '[email protected]';
3522
+        $author       = 'System';
3523
+        $author_email = '[email protected]';
3524 3524
 
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() );
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() );
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 3539
     public function generate_key( $string = '' ) {
@@ -3553,113 +3553,113 @@  discard block
 block discarded – undo
3553 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() );
3557
-
3558
-	}
3559
-
3560
-	/**
3561
-	 * Handle the status transition.
3562
-	 */
3563
-	protected function status_transition() {
3564
-		$status_transition = $this->status_transition;
3565
-
3566
-		// Reset status transition variable.
3567
-		$this->status_transition = false;
3568
-
3569
-		if ( $status_transition ) {
3570
-			try {
3556
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3571 3557
 
3572
-				// Fire a hook for the status change.
3573
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3574
-
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'] );
3577
-
3578
-				if ( ! empty( $status_transition['from'] ) ) {
3579
-
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'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3582
-
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'] );
3586
-
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'] );
3589
-
3590
-					// Note the transition occurred.
3591
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3592
-
3593
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
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 )
3597
-					) {
3598
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3599
-					}
3600
-
3601
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
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 )
3605
-					) {
3606
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3607
-					}
3608
-				} else {
3609
-					/* translators: %s: new invoice status */
3610
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3611
-
3612
-					// Note the transition occurred.
3613
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3558
+    }
3614 3559
 
3615
-				}
3616
-			} catch ( Exception $e ) {
3617
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3618
-			}
3619
-		}
3620
-	}
3560
+    /**
3561
+     * Handle the status transition.
3562
+     */
3563
+    protected function status_transition() {
3564
+        $status_transition = $this->status_transition;
3565
+
3566
+        // Reset status transition variable.
3567
+        $this->status_transition = false;
3568
+
3569
+        if ( $status_transition ) {
3570
+            try {
3571
+
3572
+                // Fire a hook for the status change.
3573
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3574
+
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'] );
3577
+
3578
+                if ( ! empty( $status_transition['from'] ) ) {
3579
+
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'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3582
+
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'] );
3586
+
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'] );
3589
+
3590
+                    // Note the transition occurred.
3591
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3592
+
3593
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
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 )
3597
+                    ) {
3598
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3599
+                    }
3600
+
3601
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
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 )
3605
+                    ) {
3606
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3607
+                    }
3608
+                } else {
3609
+                    /* translators: %s: new invoice status */
3610
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3611
+
3612
+                    // Note the transition occurred.
3613
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3614
+
3615
+                }
3616
+            } catch ( Exception $e ) {
3617
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3618
+            }
3619
+        }
3620
+    }
3621 3621
 
3622
-	/**
3623
-	 * Updates an invoice status.
3624
-	 */
3625
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3622
+    /**
3623
+     * Updates an invoice status.
3624
+     */
3625
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3626 3626
 
3627
-		// Fires before updating a status.
3628
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3627
+        // Fires before updating a status.
3628
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3629 3629
 
3630
-		// Update the status.
3631
-		$this->set_status( $new_status, $note, $manual );
3630
+        // Update the status.
3631
+        $this->set_status( $new_status, $note, $manual );
3632 3632
 
3633
-		// Save the order.
3634
-		return $this->save();
3633
+        // Save the order.
3634
+        return $this->save();
3635 3635
 
3636
-	}
3636
+    }
3637 3637
 
3638
-	/**
3639
-	 * @deprecated
3640
-	 */
3641
-	public function refresh_item_ids() {
3638
+    /**
3639
+     * @deprecated
3640
+     */
3641
+    public function refresh_item_ids() {
3642 3642
         $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3643 3643
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3644
-	}
3644
+    }
3645 3645
 
3646
-	/**
3647
-	 * @deprecated
3648
-	 */
3649
-	public function update_items( $temp = false ) {
3646
+    /**
3647
+     * @deprecated
3648
+     */
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 ) {
3654
-			$this->save();
3655
-		}
3653
+        if ( ! $temp ) {
3654
+            $this->save();
3655
+        }
3656 3656
 
3657 3657
         return $this;
3658
-	}
3658
+    }
3659 3659
 
3660
-	/**
3661
-	 * @deprecated
3662
-	 */
3660
+    /**
3661
+     * @deprecated
3662
+     */
3663 3663
     public function validate_discount() {
3664 3664
 
3665 3665
         $discount_code = $this->get_discount_code();
@@ -3675,97 +3675,97 @@  discard block
 block discarded – undo
3675 3675
 
3676 3676
     }
3677 3677
 
3678
-	/**
3679
-	 * Refunds an invoice.
3680
-	 */
3678
+    /**
3679
+     * Refunds an invoice.
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
 
3686
-	/**
3687
-	 * Marks an invoice as paid.
3688
-	 * 
3689
-	 * @param string $transaction_id
3690
-	 */
3686
+    /**
3687
+     * Marks an invoice as paid.
3688
+     * 
3689
+     * @param string $transaction_id
3690
+     */
3691 3691
     public function mark_paid( $transaction_id = null, $note = '' ) {
3692 3692
 
3693
-		// Set the transaction id.
3694
-		if ( empty( $transaction_id ) ) {
3695
-			$transaction_id = $this->generate_key('trans_');
3696
-		}
3693
+        // Set the transaction id.
3694
+        if ( empty( $transaction_id ) ) {
3695
+            $transaction_id = $this->generate_key('trans_');
3696
+        }
3697 3697
 
3698
-		if ( ! $this->get_transaction_id() ) {
3699
-			$this->set_transaction_id( $transaction_id );
3700
-		}
3698
+        if ( ! $this->get_transaction_id() ) {
3699
+            $this->set_transaction_id( $transaction_id );
3700
+        }
3701 3701
 
3702
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3703
-			return $this->save();
3704
-		}
3702
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3703
+            return $this->save();
3704
+        }
3705 3705
 
3706
-		// Set the completed date.
3707
-		$this->set_date_completed( current_time( 'mysql' ) );
3706
+        // Set the completed date.
3707
+        $this->set_date_completed( current_time( 'mysql' ) );
3708 3708
 
3709
-		// Set the new status.
3710
-		if ( $this->is_renewal() ) {
3709
+        // Set the new status.
3710
+        if ( $this->is_renewal() ) {
3711 3711
 
3712
-			$_note = sprintf(
3713
-				__( 'Renewed via %s', 'invoicing' ),
3714
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3715
-			);
3712
+            $_note = sprintf(
3713
+                __( 'Renewed via %s', 'invoicing' ),
3714
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3715
+            );
3716 3716
 
3717
-			if ( 'none' == $this->get_gateway() ) {
3718
-				$_note = $note;
3719
-			}
3717
+            if ( 'none' == $this->get_gateway() ) {
3718
+                $_note = $note;
3719
+            }
3720 3720
 
3721
-			$this->set_status( 'wpi-renewal', $_note );
3721
+            $this->set_status( 'wpi-renewal', $_note );
3722 3722
 
3723
-		} else {
3723
+        } else {
3724 3724
 
3725
-			$_note = sprintf(
3726
-				__( 'Paid via %s', 'invoicing' ),
3727
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3728
-			);
3725
+            $_note = sprintf(
3726
+                __( 'Paid via %s', 'invoicing' ),
3727
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3728
+            );
3729 3729
 
3730
-			if ( 'none' == $this->get_gateway() ) {
3731
-				$_note = $note;
3732
-			}
3730
+            if ( 'none' == $this->get_gateway() ) {
3731
+                $_note = $note;
3732
+            }
3733 3733
 
3734
-			$this->set_status( 'publish',$_note );
3734
+            $this->set_status( 'publish',$_note );
3735 3735
 
3736
-		}
3736
+        }
3737 3737
 
3738
-		// Set checkout mode.
3739
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3740
-		$this->set_mode( $mode );
3738
+        // Set checkout mode.
3739
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3740
+        $this->set_mode( $mode );
3741 3741
 
3742
-		// Save the invoice.
3742
+        // Save the invoice.
3743 3743
         $this->save();
3744
-	}
3745
-
3746
-
3747
-	/**
3748
-	 * Save data to the database.
3749
-	 *
3750
-	 * @since 1.0.19
3751
-	 * @return int invoice ID
3752
-	 */
3753
-	public function save() {
3754
-		$this->maybe_set_date_paid();
3755
-		$this->maybe_set_key();
3756
-		parent::save();
3757
-		$this->clear_cache();
3758
-		$this->status_transition();
3759
-		return $this->get_id();
3760
-	}
3761
-
3762
-	/**
3744
+    }
3745
+
3746
+
3747
+    /**
3748
+     * Save data to the database.
3749
+     *
3750
+     * @since 1.0.19
3751
+     * @return int invoice ID
3752
+     */
3753
+    public function save() {
3754
+        $this->maybe_set_date_paid();
3755
+        $this->maybe_set_key();
3756
+        parent::save();
3757
+        $this->clear_cache();
3758
+        $this->status_transition();
3759
+        return $this->get_id();
3760
+    }
3761
+
3762
+    /**
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' );
3769
-	}
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
+    }
3770 3770
 
3771 3771
 }
Please login to merge, or discard this patch.
Spacing   +741 added lines, -741 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Invoice class.
@@ -135,40 +135,40 @@  discard block
 block discarded – undo
135 135
 	 *
136 136
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
137 137
 	 */
138
-    public function __construct( $invoice = 0 ) {
138
+    public function __construct($invoice = 0) {
139 139
 
140
-        parent::__construct( $invoice );
140
+        parent::__construct($invoice);
141 141
 
142
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
143
-			$this->set_id( (int) $invoice );
144
-		} elseif ( $invoice instanceof self ) {
145
-			$this->set_id( $invoice->get_id() );
146
-		} elseif ( ! empty( $invoice->ID ) ) {
147
-			$this->set_id( $invoice->ID );
148
-		} elseif ( is_array( $invoice ) ) {
149
-			$this->set_props( $invoice );
142
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) {
143
+			$this->set_id((int) $invoice);
144
+		} elseif ($invoice instanceof self) {
145
+			$this->set_id($invoice->get_id());
146
+		} elseif (!empty($invoice->ID)) {
147
+			$this->set_id($invoice->ID);
148
+		} elseif (is_array($invoice)) {
149
+			$this->set_props($invoice);
150 150
 
151
-			if ( isset( $invoice['ID'] ) ) {
152
-				$this->set_id( $invoice['ID'] );
151
+			if (isset($invoice['ID'])) {
152
+				$this->set_id($invoice['ID']);
153 153
 			}
154 154
 
155
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
156
-			$this->set_id( $invoice_id );
157
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
158
-			$this->set_id( $invoice_id );
159
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
160
-			$this->set_id( $invoice_id );
161
-		}else {
162
-			$this->set_object_read( true );
155
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
156
+			$this->set_id($invoice_id);
157
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
158
+			$this->set_id($invoice_id);
159
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
160
+			$this->set_id($invoice_id);
161
+		} else {
162
+			$this->set_object_read(true);
163 163
 		}
164 164
 
165 165
         // Load the datastore.
166
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
166
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
167 167
 
168
-		if ( $this->get_id() > 0 ) {
169
-            $this->post = get_post( $this->get_id() );
168
+		if ($this->get_id() > 0) {
169
+            $this->post = get_post($this->get_id());
170 170
             $this->ID   = $this->get_id();
171
-			$this->data_store->read( $this );
171
+			$this->data_store->read($this);
172 172
         }
173 173
 
174 174
     }
@@ -183,38 +183,38 @@  discard block
 block discarded – undo
183 183
 	 * @since 1.0.15
184 184
 	 * @return int
185 185
 	 */
186
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
186
+	public static function get_invoice_id_by_field($value, $field = 'key') {
187 187
         global $wpdb;
188 188
 
189 189
 		// Trim the value.
190
-		$value = trim( $value );
190
+		$value = trim($value);
191 191
 
192
-		if ( empty( $value ) ) {
192
+		if (empty($value)) {
193 193
 			return 0;
194 194
 		}
195 195
 
196 196
         // Valid fields.
197
-        $fields = array( 'key', 'number', 'transaction_id' );
197
+        $fields = array('key', 'number', 'transaction_id');
198 198
 
199 199
 		// Ensure a field has been passed.
200
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
200
+		if (empty($field) || !in_array($field, $fields)) {
201 201
 			return 0;
202 202
 		}
203 203
 
204 204
 		// Maybe retrieve from the cache.
205
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
206
-		if ( false !== $invoice_id ) {
205
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
206
+		if (false !== $invoice_id) {
207 207
 			return $invoice_id;
208 208
 		}
209 209
 
210 210
         // Fetch from the db.
211 211
         $table       = $wpdb->prefix . 'getpaid_invoices';
212 212
         $invoice_id  = (int) $wpdb->get_var(
213
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
213
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
214 214
         );
215 215
 
216 216
 		// Update the cache with our data
217
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
217
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
218 218
 
219 219
 		return $invoice_id;
220 220
     }
@@ -222,8 +222,8 @@  discard block
 block discarded – undo
222 222
     /**
223 223
      * Checks if an invoice key is set.
224 224
      */
225
-    public function _isset( $key ) {
226
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
225
+    public function _isset($key) {
226
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
227 227
     }
228 228
 
229 229
     /*
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param  string $context View or edit context.
249 249
 	 * @return int
250 250
 	 */
251
-	public function get_parent_id( $context = 'view' ) {
252
-		return (int) $this->get_prop( 'parent_id', $context );
251
+	public function get_parent_id($context = 'view') {
252
+		return (int) $this->get_prop('parent_id', $context);
253 253
     }
254 254
 
255 255
     /**
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
 	 * @return WPInv_Invoice
260 260
 	 */
261 261
     public function get_parent_payment() {
262
-        return new WPInv_Invoice( $this->get_parent_id() );
262
+        return new WPInv_Invoice($this->get_parent_id());
263 263
     }
264 264
 
265 265
     /**
@@ -279,8 +279,8 @@  discard block
 block discarded – undo
279 279
 	 * @param  string $context View or edit context.
280 280
 	 * @return string
281 281
 	 */
282
-	public function get_status( $context = 'view' ) {
283
-		return $this->get_prop( 'status', $context );
282
+	public function get_status($context = 'view') {
283
+		return $this->get_prop('status', $context);
284 284
 	}
285 285
 	
286 286
 	/**
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
 	 * @return array
291 291
 	 */
292 292
 	public function get_all_statuses() {
293
-		return wpinv_get_invoice_statuses( true, true, $this );
293
+		return wpinv_get_invoice_statuses(true, true, $this);
294 294
     }
295 295
 
296 296
     /**
@@ -302,9 +302,9 @@  discard block
 block discarded – undo
302 302
     public function get_status_nicename() {
303 303
 		$statuses = $this->get_all_statuses();
304 304
 
305
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
305
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
306 306
 
307
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
307
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
308 308
     }
309 309
 
310 310
 	/**
@@ -315,8 +315,8 @@  discard block
 block discarded – undo
315 315
      */
316 316
     public function get_status_label_html() {
317 317
 
318
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
319
-		$status       = sanitize_html_class( $this->get_status() );
318
+		$status_label = sanitize_text_field($this->get_status_nicename());
319
+		$status       = sanitize_html_class($this->get_status());
320 320
 
321 321
 		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
322 322
 	}
@@ -328,23 +328,23 @@  discard block
 block discarded – undo
328 328
 	 * @param  string $context View or edit context.
329 329
 	 * @return string
330 330
 	 */
331
-	public function get_version( $context = 'view' ) {
332
-		return $this->get_prop( 'version', $context );
331
+	public function get_version($context = 'view') {
332
+		return $this->get_prop('version', $context);
333 333
 	}
334 334
 
335 335
 	/**
336 336
 	 * @deprecated
337 337
 	 */
338
-	public function get_invoice_date( $format = true ) {
339
-		$date      = getpaid_format_date( $this->get_date_completed() );
340
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
341
-		$formatted = getpaid_format_date( $date );
338
+	public function get_invoice_date($format = true) {
339
+		$date      = getpaid_format_date($this->get_date_completed());
340
+		$date      = empty($date) ? $this->get_date_created() : $this->get_date_completed();
341
+		$formatted = getpaid_format_date($date);
342 342
 
343
-		if ( $format ) {
343
+		if ($format) {
344 344
 			return $formatted;
345 345
 		}
346 346
 
347
-		return empty( $formatted ) ? '' : $date;
347
+		return empty($formatted) ? '' : $date;
348 348
 
349 349
     }
350 350
 
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 	 * @param  string $context View or edit context.
356 356
 	 * @return string
357 357
 	 */
358
-	public function get_date_created( $context = 'view' ) {
359
-		return $this->get_prop( 'date_created', $context );
358
+	public function get_date_created($context = 'view') {
359
+		return $this->get_prop('date_created', $context);
360 360
 	}
361 361
 	
362 362
 	/**
@@ -366,8 +366,8 @@  discard block
 block discarded – undo
366 366
 	 * @param  string $context View or edit context.
367 367
 	 * @return string
368 368
 	 */
369
-	public function get_created_date( $context = 'view' ) {
370
-		return $this->get_date_created( $context );
369
+	public function get_created_date($context = 'view') {
370
+		return $this->get_date_created($context);
371 371
     }
372 372
 
373 373
     /**
@@ -377,11 +377,11 @@  discard block
 block discarded – undo
377 377
 	 * @param  string $context View or edit context.
378 378
 	 * @return string
379 379
 	 */
380
-	public function get_date_created_gmt( $context = 'view' ) {
381
-        $date = $this->get_date_created( $context );
380
+	public function get_date_created_gmt($context = 'view') {
381
+        $date = $this->get_date_created($context);
382 382
 
383
-        if ( $date ) {
384
-            $date = get_gmt_from_date( $date );
383
+        if ($date) {
384
+            $date = get_gmt_from_date($date);
385 385
         }
386 386
 		return $date;
387 387
     }
@@ -393,8 +393,8 @@  discard block
 block discarded – undo
393 393
 	 * @param  string $context View or edit context.
394 394
 	 * @return string
395 395
 	 */
396
-	public function get_date_modified( $context = 'view' ) {
397
-		return $this->get_prop( 'date_modified', $context );
396
+	public function get_date_modified($context = 'view') {
397
+		return $this->get_prop('date_modified', $context);
398 398
 	}
399 399
 
400 400
 	/**
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 	 * @param  string $context View or edit context.
405 405
 	 * @return string
406 406
 	 */
407
-	public function get_modified_date( $context = 'view' ) {
408
-		return $this->get_date_modified( $context );
407
+	public function get_modified_date($context = 'view') {
408
+		return $this->get_date_modified($context);
409 409
     }
410 410
 
411 411
     /**
@@ -415,11 +415,11 @@  discard block
 block discarded – undo
415 415
 	 * @param  string $context View or edit context.
416 416
 	 * @return string
417 417
 	 */
418
-	public function get_date_modified_gmt( $context = 'view' ) {
419
-        $date = $this->get_date_modified( $context );
418
+	public function get_date_modified_gmt($context = 'view') {
419
+        $date = $this->get_date_modified($context);
420 420
 
421
-        if ( $date ) {
422
-            $date = get_gmt_from_date( $date );
421
+        if ($date) {
422
+            $date = get_gmt_from_date($date);
423 423
         }
424 424
 		return $date;
425 425
     }
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @param  string $context View or edit context.
432 432
 	 * @return string
433 433
 	 */
434
-	public function get_due_date( $context = 'view' ) {
435
-		return $this->get_prop( 'due_date', $context );
434
+	public function get_due_date($context = 'view') {
435
+		return $this->get_prop('due_date', $context);
436 436
     }
437 437
 
438 438
     /**
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 	 * @param  string $context View or edit context.
443 443
 	 * @return string
444 444
 	 */
445
-	public function get_date_due( $context = 'view' ) {
446
-		return $this->get_due_date( $context );
445
+	public function get_date_due($context = 'view') {
446
+		return $this->get_due_date($context);
447 447
     }
448 448
 
449 449
     /**
@@ -453,11 +453,11 @@  discard block
 block discarded – undo
453 453
 	 * @param  string $context View or edit context.
454 454
 	 * @return string
455 455
 	 */
456
-	public function get_due_date_gmt( $context = 'view' ) {
457
-        $date = $this->get_due_date( $context );
456
+	public function get_due_date_gmt($context = 'view') {
457
+        $date = $this->get_due_date($context);
458 458
 
459
-        if ( $date ) {
460
-            $date = get_gmt_from_date( $date );
459
+        if ($date) {
460
+            $date = get_gmt_from_date($date);
461 461
         }
462 462
 		return $date;
463 463
     }
@@ -469,8 +469,8 @@  discard block
 block discarded – undo
469 469
 	 * @param  string $context View or edit context.
470 470
 	 * @return string
471 471
 	 */
472
-	public function get_gmt_date_due( $context = 'view' ) {
473
-		return $this->get_due_date_gmt( $context );
472
+	public function get_gmt_date_due($context = 'view') {
473
+		return $this->get_due_date_gmt($context);
474 474
     }
475 475
 
476 476
     /**
@@ -480,8 +480,8 @@  discard block
 block discarded – undo
480 480
 	 * @param  string $context View or edit context.
481 481
 	 * @return string
482 482
 	 */
483
-	public function get_completed_date( $context = 'view' ) {
484
-		return $this->get_prop( 'completed_date', $context );
483
+	public function get_completed_date($context = 'view') {
484
+		return $this->get_prop('completed_date', $context);
485 485
     }
486 486
 
487 487
     /**
@@ -491,8 +491,8 @@  discard block
 block discarded – undo
491 491
 	 * @param  string $context View or edit context.
492 492
 	 * @return string
493 493
 	 */
494
-	public function get_date_completed( $context = 'view' ) {
495
-		return $this->get_completed_date( $context );
494
+	public function get_date_completed($context = 'view') {
495
+		return $this->get_completed_date($context);
496 496
     }
497 497
 
498 498
     /**
@@ -502,11 +502,11 @@  discard block
 block discarded – undo
502 502
 	 * @param  string $context View or edit context.
503 503
 	 * @return string
504 504
 	 */
505
-	public function get_completed_date_gmt( $context = 'view' ) {
506
-        $date = $this->get_completed_date( $context );
505
+	public function get_completed_date_gmt($context = 'view') {
506
+        $date = $this->get_completed_date($context);
507 507
 
508
-        if ( $date ) {
509
-            $date = get_gmt_from_date( $date );
508
+        if ($date) {
509
+            $date = get_gmt_from_date($date);
510 510
         }
511 511
 		return $date;
512 512
     }
@@ -518,8 +518,8 @@  discard block
 block discarded – undo
518 518
 	 * @param  string $context View or edit context.
519 519
 	 * @return string
520 520
 	 */
521
-	public function get_gmt_completed_date( $context = 'view' ) {
522
-		return $this->get_completed_date_gmt( $context );
521
+	public function get_gmt_completed_date($context = 'view') {
522
+		return $this->get_completed_date_gmt($context);
523 523
     }
524 524
 
525 525
     /**
@@ -529,12 +529,12 @@  discard block
 block discarded – undo
529 529
 	 * @param  string $context View or edit context.
530 530
 	 * @return string
531 531
 	 */
532
-	public function get_number( $context = 'view' ) {
533
-		$number = $this->get_prop( 'number', $context );
532
+	public function get_number($context = 'view') {
533
+		$number = $this->get_prop('number', $context);
534 534
 
535
-		if ( empty( $number ) ) {
535
+		if (empty($number)) {
536 536
 			$number = $this->generate_number();
537
-			$this->set_number( $this->generate_number() );
537
+			$this->set_number($this->generate_number());
538 538
 		}
539 539
 
540 540
 		return $number;
@@ -548,8 +548,8 @@  discard block
 block discarded – undo
548 548
 	public function maybe_set_number() {
549 549
         $number = $this->get_number();
550 550
 
551
-        if ( empty( $number ) || $this->get_id() == $number ) {
552
-			$this->set_number( $this->generate_number() );
551
+        if (empty($number) || $this->get_id() == $number) {
552
+			$this->set_number($this->generate_number());
553 553
         }
554 554
 
555 555
 	}
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 	 * @param  string $context View or edit context.
562 562
 	 * @return string
563 563
 	 */
564
-	public function get_key( $context = 'view' ) {
565
-        return $this->get_prop( 'key', $context );
564
+	public function get_key($context = 'view') {
565
+        return $this->get_prop('key', $context);
566 566
 	}
567 567
 
568 568
 	/**
@@ -573,9 +573,9 @@  discard block
 block discarded – undo
573 573
 	public function maybe_set_key() {
574 574
         $key = $this->get_key();
575 575
 
576
-        if ( empty( $key ) ) {
577
-            $key = $this->generate_key( $this->get_type() . '_' );
578
-            $this->set_key( $key );
576
+        if (empty($key)) {
577
+            $key = $this->generate_key($this->get_type() . '_');
578
+            $this->set_key($key);
579 579
         }
580 580
 
581 581
     }
@@ -587,8 +587,8 @@  discard block
 block discarded – undo
587 587
 	 * @param  string $context View or edit context.
588 588
 	 * @return string
589 589
 	 */
590
-	public function get_type( $context = 'view' ) {
591
-        return $this->get_prop( 'type', $context );
590
+	public function get_type($context = 'view') {
591
+        return $this->get_prop('type', $context);
592 592
 	}
593 593
 
594 594
 	/**
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 	 * @return string
599 599
 	 */
600 600
 	public function get_invoice_quote_type() {
601
-        return getpaid_get_post_type_label( $this->get_post_type(), false );
601
+        return getpaid_get_post_type_label($this->get_post_type(), false);
602 602
     }
603 603
 
604 604
     /**
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
 	 * @param  string $context View or edit context.
609 609
 	 * @return string
610 610
 	 */
611
-	public function get_post_type( $context = 'view' ) {
612
-        return $this->get_prop( 'post_type', $context );
611
+	public function get_post_type($context = 'view') {
612
+        return $this->get_prop('post_type', $context);
613 613
     }
614 614
 
615 615
     /**
@@ -619,8 +619,8 @@  discard block
 block discarded – undo
619 619
 	 * @param  string $context View or edit context.
620 620
 	 * @return string
621 621
 	 */
622
-	public function get_mode( $context = 'view' ) {
623
-        return $this->get_prop( 'mode', $context );
622
+	public function get_mode($context = 'view') {
623
+        return $this->get_prop('mode', $context);
624 624
     }
625 625
 
626 626
     /**
@@ -630,13 +630,13 @@  discard block
 block discarded – undo
630 630
 	 * @param  string $context View or edit context.
631 631
 	 * @return string
632 632
 	 */
633
-	public function get_path( $context = 'view' ) {
634
-        $path   = $this->get_prop( 'path', $context );
633
+	public function get_path($context = 'view') {
634
+        $path = $this->get_prop('path', $context);
635 635
 		$prefix = $this->get_type();
636 636
 
637
-		if ( 0 !== strpos( $path, $prefix ) ) {
638
-			$path = sanitize_title(  $prefix . '-' . $this->get_id()  );
639
-			$this->set_path( $path );
637
+		if (0 !== strpos($path, $prefix)) {
638
+			$path = sanitize_title($prefix . '-' . $this->get_id());
639
+			$this->set_path($path);
640 640
 		}
641 641
 
642 642
 		return $path;
@@ -649,8 +649,8 @@  discard block
 block discarded – undo
649 649
 	 * @param  string $context View or edit context.
650 650
 	 * @return string
651 651
 	 */
652
-	public function get_name( $context = 'view' ) {
653
-        return $this->get_prop( 'title', $context );
652
+	public function get_name($context = 'view') {
653
+        return $this->get_prop('title', $context);
654 654
     }
655 655
 
656 656
     /**
@@ -660,8 +660,8 @@  discard block
 block discarded – undo
660 660
 	 * @param  string $context View or edit context.
661 661
 	 * @return string
662 662
 	 */
663
-	public function get_title( $context = 'view' ) {
664
-		return $this->get_name( $context );
663
+	public function get_title($context = 'view') {
664
+		return $this->get_name($context);
665 665
     }
666 666
 
667 667
     /**
@@ -671,8 +671,8 @@  discard block
 block discarded – undo
671 671
 	 * @param  string $context View or edit context.
672 672
 	 * @return string
673 673
 	 */
674
-	public function get_description( $context = 'view' ) {
675
-		return $this->get_prop( 'description', $context );
674
+	public function get_description($context = 'view') {
675
+		return $this->get_prop('description', $context);
676 676
     }
677 677
 
678 678
     /**
@@ -682,8 +682,8 @@  discard block
 block discarded – undo
682 682
 	 * @param  string $context View or edit context.
683 683
 	 * @return string
684 684
 	 */
685
-	public function get_excerpt( $context = 'view' ) {
686
-		return $this->get_description( $context );
685
+	public function get_excerpt($context = 'view') {
686
+		return $this->get_description($context);
687 687
     }
688 688
 
689 689
     /**
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
 	 * @param  string $context View or edit context.
694 694
 	 * @return string
695 695
 	 */
696
-	public function get_summary( $context = 'view' ) {
697
-		return $this->get_description( $context );
696
+	public function get_summary($context = 'view') {
697
+		return $this->get_description($context);
698 698
     }
699 699
 
700 700
     /**
@@ -704,25 +704,25 @@  discard block
 block discarded – undo
704 704
      * @param  string $context View or edit context.
705 705
 	 * @return array
706 706
 	 */
707
-    public function get_user_info( $context = 'view' ) {
707
+    public function get_user_info($context = 'view') {
708 708
 
709 709
         $user_info = array(
710
-            'user_id'    => $this->get_user_id( $context ),
711
-            'email'      => $this->get_email( $context ),
712
-            'first_name' => $this->get_first_name( $context ),
713
-            'last_name'  => $this->get_last_name( $context ),
714
-            'address'    => $this->get_address( $context ),
715
-            'phone'      => $this->get_phone( $context ),
716
-            'city'       => $this->get_city( $context ),
717
-            'country'    => $this->get_country( $context ),
718
-            'state'      => $this->get_state( $context ),
719
-            'zip'        => $this->get_zip( $context ),
720
-            'company'    => $this->get_company( $context ),
721
-            'vat_number' => $this->get_vat_number( $context ),
722
-            'discount'   => $this->get_discount_code( $context ),
710
+            'user_id'    => $this->get_user_id($context),
711
+            'email'      => $this->get_email($context),
712
+            'first_name' => $this->get_first_name($context),
713
+            'last_name'  => $this->get_last_name($context),
714
+            'address'    => $this->get_address($context),
715
+            'phone'      => $this->get_phone($context),
716
+            'city'       => $this->get_city($context),
717
+            'country'    => $this->get_country($context),
718
+            'state'      => $this->get_state($context),
719
+            'zip'        => $this->get_zip($context),
720
+            'company'    => $this->get_company($context),
721
+            'vat_number' => $this->get_vat_number($context),
722
+            'discount'   => $this->get_discount_code($context),
723 723
 		);
724 724
 
725
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
725
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
726 726
 
727 727
     }
728 728
 
@@ -733,8 +733,8 @@  discard block
 block discarded – undo
733 733
 	 * @param  string $context View or edit context.
734 734
 	 * @return int
735 735
 	 */
736
-	public function get_author( $context = 'view' ) {
737
-		return (int) $this->get_prop( 'author', $context );
736
+	public function get_author($context = 'view') {
737
+		return (int) $this->get_prop('author', $context);
738 738
     }
739 739
 
740 740
     /**
@@ -744,8 +744,8 @@  discard block
 block discarded – undo
744 744
 	 * @param  string $context View or edit context.
745 745
 	 * @return int
746 746
 	 */
747
-	public function get_user_id( $context = 'view' ) {
748
-		return $this->get_author( $context );
747
+	public function get_user_id($context = 'view') {
748
+		return $this->get_author($context);
749 749
     }
750 750
 
751 751
      /**
@@ -755,8 +755,8 @@  discard block
 block discarded – undo
755 755
 	 * @param  string $context View or edit context.
756 756
 	 * @return int
757 757
 	 */
758
-	public function get_customer_id( $context = 'view' ) {
759
-		return $this->get_author( $context );
758
+	public function get_customer_id($context = 'view') {
759
+		return $this->get_author($context);
760 760
     }
761 761
 
762 762
     /**
@@ -766,8 +766,8 @@  discard block
 block discarded – undo
766 766
 	 * @param  string $context View or edit context.
767 767
 	 * @return string
768 768
 	 */
769
-	public function get_ip( $context = 'view' ) {
770
-		return $this->get_prop( 'user_ip', $context );
769
+	public function get_ip($context = 'view') {
770
+		return $this->get_prop('user_ip', $context);
771 771
     }
772 772
 
773 773
     /**
@@ -777,8 +777,8 @@  discard block
 block discarded – undo
777 777
 	 * @param  string $context View or edit context.
778 778
 	 * @return string
779 779
 	 */
780
-	public function get_user_ip( $context = 'view' ) {
781
-		return $this->get_ip( $context );
780
+	public function get_user_ip($context = 'view') {
781
+		return $this->get_ip($context);
782 782
     }
783 783
 
784 784
      /**
@@ -788,8 +788,8 @@  discard block
 block discarded – undo
788 788
 	 * @param  string $context View or edit context.
789 789
 	 * @return string
790 790
 	 */
791
-	public function get_customer_ip( $context = 'view' ) {
792
-		return $this->get_ip( $context );
791
+	public function get_customer_ip($context = 'view') {
792
+		return $this->get_ip($context);
793 793
     }
794 794
 
795 795
     /**
@@ -799,8 +799,8 @@  discard block
 block discarded – undo
799 799
 	 * @param  string $context View or edit context.
800 800
 	 * @return string
801 801
 	 */
802
-	public function get_first_name( $context = 'view' ) {
803
-		return $this->get_prop( 'first_name', $context );
802
+	public function get_first_name($context = 'view') {
803
+		return $this->get_prop('first_name', $context);
804 804
     }
805 805
 
806 806
     /**
@@ -810,8 +810,8 @@  discard block
 block discarded – undo
810 810
 	 * @param  string $context View or edit context.
811 811
 	 * @return string
812 812
 	 */
813
-	public function get_user_first_name( $context = 'view' ) {
814
-		return $this->get_first_name( $context );
813
+	public function get_user_first_name($context = 'view') {
814
+		return $this->get_first_name($context);
815 815
     }
816 816
 
817 817
      /**
@@ -821,8 +821,8 @@  discard block
 block discarded – undo
821 821
 	 * @param  string $context View or edit context.
822 822
 	 * @return string
823 823
 	 */
824
-	public function get_customer_first_name( $context = 'view' ) {
825
-		return $this->get_first_name( $context );
824
+	public function get_customer_first_name($context = 'view') {
825
+		return $this->get_first_name($context);
826 826
     }
827 827
 
828 828
     /**
@@ -832,8 +832,8 @@  discard block
 block discarded – undo
832 832
 	 * @param  string $context View or edit context.
833 833
 	 * @return string
834 834
 	 */
835
-	public function get_last_name( $context = 'view' ) {
836
-		return $this->get_prop( 'last_name', $context );
835
+	public function get_last_name($context = 'view') {
836
+		return $this->get_prop('last_name', $context);
837 837
     }
838 838
 
839 839
     /**
@@ -843,8 +843,8 @@  discard block
 block discarded – undo
843 843
 	 * @param  string $context View or edit context.
844 844
 	 * @return string
845 845
 	 */
846
-	public function get_user_last_name( $context = 'view' ) {
847
-		return $this->get_last_name( $context );
846
+	public function get_user_last_name($context = 'view') {
847
+		return $this->get_last_name($context);
848 848
     }
849 849
 
850 850
     /**
@@ -854,8 +854,8 @@  discard block
 block discarded – undo
854 854
 	 * @param  string $context View or edit context.
855 855
 	 * @return string
856 856
 	 */
857
-	public function get_customer_last_name( $context = 'view' ) {
858
-		return $this->get_last_name( $context );
857
+	public function get_customer_last_name($context = 'view') {
858
+		return $this->get_last_name($context);
859 859
     }
860 860
 
861 861
     /**
@@ -865,8 +865,8 @@  discard block
 block discarded – undo
865 865
 	 * @param  string $context View or edit context.
866 866
 	 * @return string
867 867
 	 */
868
-	public function get_full_name( $context = 'view' ) {
869
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
868
+	public function get_full_name($context = 'view') {
869
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
870 870
     }
871 871
 
872 872
     /**
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
 	 * @param  string $context View or edit context.
877 877
 	 * @return string
878 878
 	 */
879
-	public function get_user_full_name( $context = 'view' ) {
880
-		return $this->get_full_name( $context );
879
+	public function get_user_full_name($context = 'view') {
880
+		return $this->get_full_name($context);
881 881
     }
882 882
 
883 883
     /**
@@ -887,8 +887,8 @@  discard block
 block discarded – undo
887 887
 	 * @param  string $context View or edit context.
888 888
 	 * @return string
889 889
 	 */
890
-	public function get_customer_full_name( $context = 'view' ) {
891
-		return $this->get_full_name( $context );
890
+	public function get_customer_full_name($context = 'view') {
891
+		return $this->get_full_name($context);
892 892
     }
893 893
 
894 894
     /**
@@ -898,8 +898,8 @@  discard block
 block discarded – undo
898 898
 	 * @param  string $context View or edit context.
899 899
 	 * @return string
900 900
 	 */
901
-	public function get_phone( $context = 'view' ) {
902
-		return $this->get_prop( 'phone', $context );
901
+	public function get_phone($context = 'view') {
902
+		return $this->get_prop('phone', $context);
903 903
     }
904 904
 
905 905
     /**
@@ -909,8 +909,8 @@  discard block
 block discarded – undo
909 909
 	 * @param  string $context View or edit context.
910 910
 	 * @return string
911 911
 	 */
912
-	public function get_phone_number( $context = 'view' ) {
913
-		return $this->get_phone( $context );
912
+	public function get_phone_number($context = 'view') {
913
+		return $this->get_phone($context);
914 914
     }
915 915
 
916 916
     /**
@@ -920,8 +920,8 @@  discard block
 block discarded – undo
920 920
 	 * @param  string $context View or edit context.
921 921
 	 * @return string
922 922
 	 */
923
-	public function get_user_phone( $context = 'view' ) {
924
-		return $this->get_phone( $context );
923
+	public function get_user_phone($context = 'view') {
924
+		return $this->get_phone($context);
925 925
     }
926 926
 
927 927
     /**
@@ -931,8 +931,8 @@  discard block
 block discarded – undo
931 931
 	 * @param  string $context View or edit context.
932 932
 	 * @return string
933 933
 	 */
934
-	public function get_customer_phone( $context = 'view' ) {
935
-		return $this->get_phone( $context );
934
+	public function get_customer_phone($context = 'view') {
935
+		return $this->get_phone($context);
936 936
     }
937 937
 
938 938
     /**
@@ -942,8 +942,8 @@  discard block
 block discarded – undo
942 942
 	 * @param  string $context View or edit context.
943 943
 	 * @return string
944 944
 	 */
945
-	public function get_email( $context = 'view' ) {
946
-		return $this->get_prop( 'email', $context );
945
+	public function get_email($context = 'view') {
946
+		return $this->get_prop('email', $context);
947 947
     }
948 948
 
949 949
     /**
@@ -953,8 +953,8 @@  discard block
 block discarded – undo
953 953
 	 * @param  string $context View or edit context.
954 954
 	 * @return string
955 955
 	 */
956
-	public function get_email_address( $context = 'view' ) {
957
-		return $this->get_email( $context );
956
+	public function get_email_address($context = 'view') {
957
+		return $this->get_email($context);
958 958
     }
959 959
 
960 960
     /**
@@ -964,8 +964,8 @@  discard block
 block discarded – undo
964 964
 	 * @param  string $context View or edit context.
965 965
 	 * @return string
966 966
 	 */
967
-	public function get_user_email( $context = 'view' ) {
968
-		return $this->get_email( $context );
967
+	public function get_user_email($context = 'view') {
968
+		return $this->get_email($context);
969 969
     }
970 970
 
971 971
     /**
@@ -975,8 +975,8 @@  discard block
 block discarded – undo
975 975
 	 * @param  string $context View or edit context.
976 976
 	 * @return string
977 977
 	 */
978
-	public function get_customer_email( $context = 'view' ) {
979
-		return $this->get_email( $context );
978
+	public function get_customer_email($context = 'view') {
979
+		return $this->get_email($context);
980 980
     }
981 981
 
982 982
     /**
@@ -986,9 +986,9 @@  discard block
 block discarded – undo
986 986
 	 * @param  string $context View or edit context.
987 987
 	 * @return string
988 988
 	 */
989
-	public function get_country( $context = 'view' ) {
990
-		$country = $this->get_prop( 'country', $context );
991
-		return empty( $country ) ? wpinv_get_default_country() : $country;
989
+	public function get_country($context = 'view') {
990
+		$country = $this->get_prop('country', $context);
991
+		return empty($country) ? wpinv_get_default_country() : $country;
992 992
     }
993 993
 
994 994
     /**
@@ -998,8 +998,8 @@  discard block
 block discarded – undo
998 998
 	 * @param  string $context View or edit context.
999 999
 	 * @return string
1000 1000
 	 */
1001
-	public function get_user_country( $context = 'view' ) {
1002
-		return $this->get_country( $context );
1001
+	public function get_user_country($context = 'view') {
1002
+		return $this->get_country($context);
1003 1003
     }
1004 1004
 
1005 1005
     /**
@@ -1009,8 +1009,8 @@  discard block
 block discarded – undo
1009 1009
 	 * @param  string $context View or edit context.
1010 1010
 	 * @return string
1011 1011
 	 */
1012
-	public function get_customer_country( $context = 'view' ) {
1013
-		return $this->get_country( $context );
1012
+	public function get_customer_country($context = 'view') {
1013
+		return $this->get_country($context);
1014 1014
     }
1015 1015
 
1016 1016
     /**
@@ -1020,9 +1020,9 @@  discard block
 block discarded – undo
1020 1020
 	 * @param  string $context View or edit context.
1021 1021
 	 * @return string
1022 1022
 	 */
1023
-	public function get_state( $context = 'view' ) {
1024
-		$state = $this->get_prop( 'state', $context );
1025
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1023
+	public function get_state($context = 'view') {
1024
+		$state = $this->get_prop('state', $context);
1025
+		return empty($state) ? wpinv_get_default_state() : $state;
1026 1026
     }
1027 1027
 
1028 1028
     /**
@@ -1032,8 +1032,8 @@  discard block
 block discarded – undo
1032 1032
 	 * @param  string $context View or edit context.
1033 1033
 	 * @return string
1034 1034
 	 */
1035
-	public function get_user_state( $context = 'view' ) {
1036
-		return $this->get_state( $context );
1035
+	public function get_user_state($context = 'view') {
1036
+		return $this->get_state($context);
1037 1037
     }
1038 1038
 
1039 1039
     /**
@@ -1043,8 +1043,8 @@  discard block
 block discarded – undo
1043 1043
 	 * @param  string $context View or edit context.
1044 1044
 	 * @return string
1045 1045
 	 */
1046
-	public function get_customer_state( $context = 'view' ) {
1047
-		return $this->get_state( $context );
1046
+	public function get_customer_state($context = 'view') {
1047
+		return $this->get_state($context);
1048 1048
     }
1049 1049
 
1050 1050
     /**
@@ -1054,8 +1054,8 @@  discard block
 block discarded – undo
1054 1054
 	 * @param  string $context View or edit context.
1055 1055
 	 * @return string
1056 1056
 	 */
1057
-	public function get_city( $context = 'view' ) {
1058
-		return $this->get_prop( 'city', $context );
1057
+	public function get_city($context = 'view') {
1058
+		return $this->get_prop('city', $context);
1059 1059
     }
1060 1060
 
1061 1061
     /**
@@ -1065,8 +1065,8 @@  discard block
 block discarded – undo
1065 1065
 	 * @param  string $context View or edit context.
1066 1066
 	 * @return string
1067 1067
 	 */
1068
-	public function get_user_city( $context = 'view' ) {
1069
-		return $this->get_city( $context );
1068
+	public function get_user_city($context = 'view') {
1069
+		return $this->get_city($context);
1070 1070
     }
1071 1071
 
1072 1072
     /**
@@ -1076,8 +1076,8 @@  discard block
 block discarded – undo
1076 1076
 	 * @param  string $context View or edit context.
1077 1077
 	 * @return string
1078 1078
 	 */
1079
-	public function get_customer_city( $context = 'view' ) {
1080
-		return $this->get_city( $context );
1079
+	public function get_customer_city($context = 'view') {
1080
+		return $this->get_city($context);
1081 1081
     }
1082 1082
 
1083 1083
     /**
@@ -1087,8 +1087,8 @@  discard block
 block discarded – undo
1087 1087
 	 * @param  string $context View or edit context.
1088 1088
 	 * @return string
1089 1089
 	 */
1090
-	public function get_zip( $context = 'view' ) {
1091
-		return $this->get_prop( 'zip', $context );
1090
+	public function get_zip($context = 'view') {
1091
+		return $this->get_prop('zip', $context);
1092 1092
     }
1093 1093
 
1094 1094
     /**
@@ -1098,8 +1098,8 @@  discard block
 block discarded – undo
1098 1098
 	 * @param  string $context View or edit context.
1099 1099
 	 * @return string
1100 1100
 	 */
1101
-	public function get_user_zip( $context = 'view' ) {
1102
-		return $this->get_zip( $context );
1101
+	public function get_user_zip($context = 'view') {
1102
+		return $this->get_zip($context);
1103 1103
     }
1104 1104
 
1105 1105
     /**
@@ -1109,8 +1109,8 @@  discard block
 block discarded – undo
1109 1109
 	 * @param  string $context View or edit context.
1110 1110
 	 * @return string
1111 1111
 	 */
1112
-	public function get_customer_zip( $context = 'view' ) {
1113
-		return $this->get_zip( $context );
1112
+	public function get_customer_zip($context = 'view') {
1113
+		return $this->get_zip($context);
1114 1114
     }
1115 1115
 
1116 1116
     /**
@@ -1120,8 +1120,8 @@  discard block
 block discarded – undo
1120 1120
 	 * @param  string $context View or edit context.
1121 1121
 	 * @return string
1122 1122
 	 */
1123
-	public function get_company( $context = 'view' ) {
1124
-		return $this->get_prop( 'company', $context );
1123
+	public function get_company($context = 'view') {
1124
+		return $this->get_prop('company', $context);
1125 1125
     }
1126 1126
 
1127 1127
     /**
@@ -1131,8 +1131,8 @@  discard block
 block discarded – undo
1131 1131
 	 * @param  string $context View or edit context.
1132 1132
 	 * @return string
1133 1133
 	 */
1134
-	public function get_user_company( $context = 'view' ) {
1135
-		return $this->get_company( $context );
1134
+	public function get_user_company($context = 'view') {
1135
+		return $this->get_company($context);
1136 1136
     }
1137 1137
 
1138 1138
     /**
@@ -1142,8 +1142,8 @@  discard block
 block discarded – undo
1142 1142
 	 * @param  string $context View or edit context.
1143 1143
 	 * @return string
1144 1144
 	 */
1145
-	public function get_customer_company( $context = 'view' ) {
1146
-		return $this->get_company( $context );
1145
+	public function get_customer_company($context = 'view') {
1146
+		return $this->get_company($context);
1147 1147
     }
1148 1148
 
1149 1149
     /**
@@ -1153,8 +1153,8 @@  discard block
 block discarded – undo
1153 1153
 	 * @param  string $context View or edit context.
1154 1154
 	 * @return string
1155 1155
 	 */
1156
-	public function get_vat_number( $context = 'view' ) {
1157
-		return $this->get_prop( 'vat_number', $context );
1156
+	public function get_vat_number($context = 'view') {
1157
+		return $this->get_prop('vat_number', $context);
1158 1158
     }
1159 1159
 
1160 1160
     /**
@@ -1164,8 +1164,8 @@  discard block
 block discarded – undo
1164 1164
 	 * @param  string $context View or edit context.
1165 1165
 	 * @return string
1166 1166
 	 */
1167
-	public function get_user_vat_number( $context = 'view' ) {
1168
-		return $this->get_vat_number( $context );
1167
+	public function get_user_vat_number($context = 'view') {
1168
+		return $this->get_vat_number($context);
1169 1169
     }
1170 1170
 
1171 1171
     /**
@@ -1175,8 +1175,8 @@  discard block
 block discarded – undo
1175 1175
 	 * @param  string $context View or edit context.
1176 1176
 	 * @return string
1177 1177
 	 */
1178
-	public function get_customer_vat_number( $context = 'view' ) {
1179
-		return $this->get_vat_number( $context );
1178
+	public function get_customer_vat_number($context = 'view') {
1179
+		return $this->get_vat_number($context);
1180 1180
     }
1181 1181
 
1182 1182
     /**
@@ -1186,8 +1186,8 @@  discard block
 block discarded – undo
1186 1186
 	 * @param  string $context View or edit context.
1187 1187
 	 * @return string
1188 1188
 	 */
1189
-	public function get_vat_rate( $context = 'view' ) {
1190
-		return $this->get_prop( 'vat_rate', $context );
1189
+	public function get_vat_rate($context = 'view') {
1190
+		return $this->get_prop('vat_rate', $context);
1191 1191
     }
1192 1192
 
1193 1193
     /**
@@ -1197,8 +1197,8 @@  discard block
 block discarded – undo
1197 1197
 	 * @param  string $context View or edit context.
1198 1198
 	 * @return string
1199 1199
 	 */
1200
-	public function get_user_vat_rate( $context = 'view' ) {
1201
-		return $this->get_vat_rate( $context );
1200
+	public function get_user_vat_rate($context = 'view') {
1201
+		return $this->get_vat_rate($context);
1202 1202
     }
1203 1203
 
1204 1204
     /**
@@ -1208,8 +1208,8 @@  discard block
 block discarded – undo
1208 1208
 	 * @param  string $context View or edit context.
1209 1209
 	 * @return string
1210 1210
 	 */
1211
-	public function get_customer_vat_rate( $context = 'view' ) {
1212
-		return $this->get_vat_rate( $context );
1211
+	public function get_customer_vat_rate($context = 'view') {
1212
+		return $this->get_vat_rate($context);
1213 1213
     }
1214 1214
 
1215 1215
     /**
@@ -1219,8 +1219,8 @@  discard block
 block discarded – undo
1219 1219
 	 * @param  string $context View or edit context.
1220 1220
 	 * @return string
1221 1221
 	 */
1222
-	public function get_address( $context = 'view' ) {
1223
-		return $this->get_prop( 'address', $context );
1222
+	public function get_address($context = 'view') {
1223
+		return $this->get_prop('address', $context);
1224 1224
     }
1225 1225
 
1226 1226
     /**
@@ -1230,8 +1230,8 @@  discard block
 block discarded – undo
1230 1230
 	 * @param  string $context View or edit context.
1231 1231
 	 * @return string
1232 1232
 	 */
1233
-	public function get_user_address( $context = 'view' ) {
1234
-		return $this->get_address( $context );
1233
+	public function get_user_address($context = 'view') {
1234
+		return $this->get_address($context);
1235 1235
     }
1236 1236
 
1237 1237
     /**
@@ -1241,8 +1241,8 @@  discard block
 block discarded – undo
1241 1241
 	 * @param  string $context View or edit context.
1242 1242
 	 * @return string
1243 1243
 	 */
1244
-	public function get_customer_address( $context = 'view' ) {
1245
-		return $this->get_address( $context );
1244
+	public function get_customer_address($context = 'view') {
1245
+		return $this->get_address($context);
1246 1246
     }
1247 1247
 
1248 1248
     /**
@@ -1252,8 +1252,8 @@  discard block
 block discarded – undo
1252 1252
 	 * @param  string $context View or edit context.
1253 1253
 	 * @return bool
1254 1254
 	 */
1255
-	public function get_is_viewed( $context = 'view' ) {
1256
-		return (bool) $this->get_prop( 'is_viewed', $context );
1255
+	public function get_is_viewed($context = 'view') {
1256
+		return (bool) $this->get_prop('is_viewed', $context);
1257 1257
 	}
1258 1258
 
1259 1259
 	/**
@@ -1263,8 +1263,8 @@  discard block
 block discarded – undo
1263 1263
 	 * @param  string $context View or edit context.
1264 1264
 	 * @return bool
1265 1265
 	 */
1266
-	public function get_email_cc( $context = 'view' ) {
1267
-		return $this->get_prop( 'email_cc', $context );
1266
+	public function get_email_cc($context = 'view') {
1267
+		return $this->get_prop('email_cc', $context);
1268 1268
 	}
1269 1269
 
1270 1270
 	/**
@@ -1274,8 +1274,8 @@  discard block
 block discarded – undo
1274 1274
 	 * @param  string $context View or edit context.
1275 1275
 	 * @return bool
1276 1276
 	 */
1277
-	public function get_template( $context = 'view' ) {
1278
-		return $this->get_prop( 'template', $context );
1277
+	public function get_template($context = 'view') {
1278
+		return $this->get_prop('template', $context);
1279 1279
 	}
1280 1280
 
1281 1281
 	/**
@@ -1285,8 +1285,8 @@  discard block
 block discarded – undo
1285 1285
 	 * @param  string $context View or edit context.
1286 1286
 	 * @return bool
1287 1287
 	 */
1288
-	public function get_created_via( $context = 'view' ) {
1289
-		return $this->get_prop( 'created_via', $context );
1288
+	public function get_created_via($context = 'view') {
1289
+		return $this->get_prop('created_via', $context);
1290 1290
 	}
1291 1291
 
1292 1292
 	/**
@@ -1296,8 +1296,8 @@  discard block
 block discarded – undo
1296 1296
 	 * @param  string $context View or edit context.
1297 1297
 	 * @return bool
1298 1298
 	 */
1299
-	public function get_address_confirmed( $context = 'view' ) {
1300
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1299
+	public function get_address_confirmed($context = 'view') {
1300
+		return (bool) $this->get_prop('address_confirmed', $context);
1301 1301
     }
1302 1302
 
1303 1303
     /**
@@ -1307,8 +1307,8 @@  discard block
 block discarded – undo
1307 1307
 	 * @param  string $context View or edit context.
1308 1308
 	 * @return bool
1309 1309
 	 */
1310
-	public function get_user_address_confirmed( $context = 'view' ) {
1311
-		return $this->get_address_confirmed( $context );
1310
+	public function get_user_address_confirmed($context = 'view') {
1311
+		return $this->get_address_confirmed($context);
1312 1312
     }
1313 1313
 
1314 1314
     /**
@@ -1318,8 +1318,8 @@  discard block
 block discarded – undo
1318 1318
 	 * @param  string $context View or edit context.
1319 1319
 	 * @return bool
1320 1320
 	 */
1321
-	public function get_customer_address_confirmed( $context = 'view' ) {
1322
-		return $this->get_address_confirmed( $context );
1321
+	public function get_customer_address_confirmed($context = 'view') {
1322
+		return $this->get_address_confirmed($context);
1323 1323
     }
1324 1324
 
1325 1325
     /**
@@ -1329,12 +1329,12 @@  discard block
 block discarded – undo
1329 1329
 	 * @param  string $context View or edit context.
1330 1330
 	 * @return float
1331 1331
 	 */
1332
-	public function get_subtotal( $context = 'view' ) {
1333
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1332
+	public function get_subtotal($context = 'view') {
1333
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1334 1334
 
1335 1335
         // Backwards compatibility.
1336
-        if ( is_bool( $context ) && $context ) {
1337
-            return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() );
1336
+        if (is_bool($context) && $context) {
1337
+            return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency());
1338 1338
         }
1339 1339
 
1340 1340
         return $subtotal;
@@ -1347,8 +1347,8 @@  discard block
 block discarded – undo
1347 1347
 	 * @param  string $context View or edit context.
1348 1348
 	 * @return float
1349 1349
 	 */
1350
-	public function get_total_discount( $context = 'view' ) {
1351
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1350
+	public function get_total_discount($context = 'view') {
1351
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context)));
1352 1352
     }
1353 1353
 
1354 1354
     /**
@@ -1358,18 +1358,18 @@  discard block
 block discarded – undo
1358 1358
 	 * @param  string $context View or edit context.
1359 1359
 	 * @return float
1360 1360
 	 */
1361
-	public function get_total_tax( $context = 'view' ) {
1362
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1361
+	public function get_total_tax($context = 'view') {
1362
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context)));
1363 1363
 	}
1364 1364
 
1365 1365
 	/**
1366 1366
 	 * @deprecated
1367 1367
 	 */
1368
-	public function get_final_tax( $currency = false ) {
1368
+	public function get_final_tax($currency = false) {
1369 1369
 		$tax = $this->get_total_tax();
1370 1370
 
1371
-        if ( $currency ) {
1372
-			return wpinv_price( $tax, $this->get_currency() );
1371
+        if ($currency) {
1372
+			return wpinv_price($tax, $this->get_currency());
1373 1373
         }
1374 1374
 
1375 1375
         return $tax;
@@ -1382,8 +1382,8 @@  discard block
 block discarded – undo
1382 1382
 	 * @param  string $context View or edit context.
1383 1383
 	 * @return float
1384 1384
 	 */
1385
-	public function get_total_fees( $context = 'view' ) {
1386
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1385
+	public function get_total_fees($context = 'view') {
1386
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context)));
1387 1387
     }
1388 1388
 
1389 1389
     /**
@@ -1393,8 +1393,8 @@  discard block
 block discarded – undo
1393 1393
 	 * @param  string $context View or edit context.
1394 1394
 	 * @return float
1395 1395
 	 */
1396
-	public function get_fees_total( $context = 'view' ) {
1397
-		return $this->get_total_fees( $context );
1396
+	public function get_fees_total($context = 'view') {
1397
+		return $this->get_total_fees($context);
1398 1398
     }
1399 1399
 
1400 1400
     /**
@@ -1405,7 +1405,7 @@  discard block
 block discarded – undo
1405 1405
 	 */
1406 1406
 	public function get_total() {
1407 1407
 		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1408
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1408
+		return apply_filters('getpaid_get_invoice_total_amount', $total, $this);
1409 1409
 	}
1410 1410
 	
1411 1411
 	/**
@@ -1427,7 +1427,7 @@  discard block
 block discarded – undo
1427 1427
 	 */
1428 1428
     public function get_initial_total() {
1429 1429
 
1430
-		if ( empty( $this->totals ) ) {
1430
+		if (empty($this->totals)) {
1431 1431
 			$this->recalculate_total();
1432 1432
 		}
1433 1433
 
@@ -1437,12 +1437,12 @@  discard block
 block discarded – undo
1437 1437
 		$subtotal = $this->totals['subtotal']['initial'];
1438 1438
 		$total    = $tax + $fee - $discount + $subtotal;
1439 1439
 
1440
-		if ( 0 > $total ) {
1440
+		if (0 > $total) {
1441 1441
 			$total = 0;
1442 1442
 		}
1443 1443
 
1444
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1445
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1444
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1445
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1446 1446
 	}
1447 1447
 
1448 1448
 	/**
@@ -1454,7 +1454,7 @@  discard block
 block discarded – undo
1454 1454
 	 */
1455 1455
     public function get_recurring_total() {
1456 1456
 
1457
-		if ( empty( $this->totals ) ) {
1457
+		if (empty($this->totals)) {
1458 1458
 			$this->recalculate_total();
1459 1459
 		}
1460 1460
 
@@ -1464,12 +1464,12 @@  discard block
 block discarded – undo
1464 1464
 		$subtotal = $this->totals['subtotal']['recurring'];
1465 1465
 		$total    = $tax + $fee - $discount + $subtotal;
1466 1466
 
1467
-		if ( 0 > $total ) {
1467
+		if (0 > $total) {
1468 1468
 			$total = 0;
1469 1469
 		}
1470 1470
 
1471
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1472
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1471
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1472
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1473 1473
 	}
1474 1474
 
1475 1475
 	/**
@@ -1480,10 +1480,10 @@  discard block
 block discarded – undo
1480 1480
 	 * @param string $currency Whether to include the currency.
1481 1481
      * @return float|string
1482 1482
 	 */
1483
-    public function get_recurring_details( $field = '', $currency = false ) {
1483
+    public function get_recurring_details($field = '', $currency = false) {
1484 1484
 
1485 1485
 		// Maybe recalculate totals.
1486
-		if ( empty( $this->totals ) ) {
1486
+		if (empty($this->totals)) {
1487 1487
 			$this->recalculate_total();
1488 1488
 		}
1489 1489
 
@@ -1503,8 +1503,8 @@  discard block
 block discarded – undo
1503 1503
 			$currency
1504 1504
 		);
1505 1505
 
1506
-        if ( isset( $data[$field] ) ) {
1507
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1506
+        if (isset($data[$field])) {
1507
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1508 1508
         }
1509 1509
 
1510 1510
         return $data;
@@ -1517,8 +1517,8 @@  discard block
 block discarded – undo
1517 1517
 	 * @param  string $context View or edit context.
1518 1518
 	 * @return array
1519 1519
 	 */
1520
-	public function get_fees( $context = 'view' ) {
1521
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1520
+	public function get_fees($context = 'view') {
1521
+		return wpinv_parse_list($this->get_prop('fees', $context));
1522 1522
     }
1523 1523
 
1524 1524
     /**
@@ -1528,8 +1528,8 @@  discard block
 block discarded – undo
1528 1528
 	 * @param  string $context View or edit context.
1529 1529
 	 * @return array
1530 1530
 	 */
1531
-	public function get_discounts( $context = 'view' ) {
1532
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1531
+	public function get_discounts($context = 'view') {
1532
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1533 1533
     }
1534 1534
 
1535 1535
     /**
@@ -1539,8 +1539,8 @@  discard block
 block discarded – undo
1539 1539
 	 * @param  string $context View or edit context.
1540 1540
 	 * @return array
1541 1541
 	 */
1542
-	public function get_taxes( $context = 'view' ) {
1543
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1542
+	public function get_taxes($context = 'view') {
1543
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1544 1544
     }
1545 1545
 
1546 1546
     /**
@@ -1550,8 +1550,8 @@  discard block
 block discarded – undo
1550 1550
 	 * @param  string $context View or edit context.
1551 1551
 	 * @return GetPaid_Form_Item[]
1552 1552
 	 */
1553
-	public function get_items( $context = 'view' ) {
1554
-        return $this->get_prop( 'items', $context );
1553
+	public function get_items($context = 'view') {
1554
+        return $this->get_prop('items', $context);
1555 1555
 	}
1556 1556
 	
1557 1557
 	/**
@@ -1561,7 +1561,7 @@  discard block
 block discarded – undo
1561 1561
 	 * @return string
1562 1562
 	 */
1563 1563
 	public function get_item_ids() {
1564
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1564
+		return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id'));
1565 1565
     }
1566 1566
 
1567 1567
     /**
@@ -1571,8 +1571,8 @@  discard block
 block discarded – undo
1571 1571
 	 * @param  string $context View or edit context.
1572 1572
 	 * @return int
1573 1573
 	 */
1574
-	public function get_payment_form( $context = 'view' ) {
1575
-		return intval( $this->get_prop( 'payment_form', $context ) );
1574
+	public function get_payment_form($context = 'view') {
1575
+		return intval($this->get_prop('payment_form', $context));
1576 1576
     }
1577 1577
 
1578 1578
     /**
@@ -1582,8 +1582,8 @@  discard block
 block discarded – undo
1582 1582
 	 * @param  string $context View or edit context.
1583 1583
 	 * @return string
1584 1584
 	 */
1585
-	public function get_submission_id( $context = 'view' ) {
1586
-		return $this->get_prop( 'submission_id', $context );
1585
+	public function get_submission_id($context = 'view') {
1586
+		return $this->get_prop('submission_id', $context);
1587 1587
     }
1588 1588
 
1589 1589
     /**
@@ -1593,8 +1593,8 @@  discard block
 block discarded – undo
1593 1593
 	 * @param  string $context View or edit context.
1594 1594
 	 * @return string
1595 1595
 	 */
1596
-	public function get_discount_code( $context = 'view' ) {
1597
-		return $this->get_prop( 'discount_code', $context );
1596
+	public function get_discount_code($context = 'view') {
1597
+		return $this->get_prop('discount_code', $context);
1598 1598
     }
1599 1599
 
1600 1600
     /**
@@ -1604,8 +1604,8 @@  discard block
 block discarded – undo
1604 1604
 	 * @param  string $context View or edit context.
1605 1605
 	 * @return string
1606 1606
 	 */
1607
-	public function get_gateway( $context = 'view' ) {
1608
-		return $this->get_prop( 'gateway', $context );
1607
+	public function get_gateway($context = 'view') {
1608
+		return $this->get_prop('gateway', $context);
1609 1609
     }
1610 1610
 
1611 1611
     /**
@@ -1615,8 +1615,8 @@  discard block
 block discarded – undo
1615 1615
 	 * @return string
1616 1616
 	 */
1617 1617
     public function get_gateway_title() {
1618
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1619
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1618
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1619
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1620 1620
     }
1621 1621
 
1622 1622
     /**
@@ -1626,8 +1626,8 @@  discard block
 block discarded – undo
1626 1626
 	 * @param  string $context View or edit context.
1627 1627
 	 * @return string
1628 1628
 	 */
1629
-	public function get_transaction_id( $context = 'view' ) {
1630
-		return $this->get_prop( 'transaction_id', $context );
1629
+	public function get_transaction_id($context = 'view') {
1630
+		return $this->get_prop('transaction_id', $context);
1631 1631
     }
1632 1632
 
1633 1633
     /**
@@ -1637,9 +1637,9 @@  discard block
 block discarded – undo
1637 1637
 	 * @param  string $context View or edit context.
1638 1638
 	 * @return string
1639 1639
 	 */
1640
-	public function get_currency( $context = 'view' ) {
1641
-        $currency = $this->get_prop( 'currency', $context );
1642
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1640
+	public function get_currency($context = 'view') {
1641
+        $currency = $this->get_prop('currency', $context);
1642
+        return empty($currency) ? wpinv_get_currency() : $currency;
1643 1643
     }
1644 1644
 
1645 1645
     /**
@@ -1649,8 +1649,8 @@  discard block
 block discarded – undo
1649 1649
 	 * @param  string $context View or edit context.
1650 1650
 	 * @return bool
1651 1651
 	 */
1652
-	public function get_disable_taxes( $context = 'view' ) {
1653
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1652
+	public function get_disable_taxes($context = 'view') {
1653
+        return (bool) $this->get_prop('disable_taxes', $context);
1654 1654
     }
1655 1655
 
1656 1656
     /**
@@ -1660,8 +1660,8 @@  discard block
 block discarded – undo
1660 1660
 	 * @param  string $context View or edit context.
1661 1661
 	 * @return int
1662 1662
 	 */
1663
-    public function get_subscription_id( $context = 'view' ) {
1664
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1663
+    public function get_subscription_id($context = 'view') {
1664
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1665 1665
 	}
1666 1666
 
1667 1667
 	/**
@@ -1671,12 +1671,12 @@  discard block
 block discarded – undo
1671 1671
 	 * @param  string $context View or edit context.
1672 1672
 	 * @return int
1673 1673
 	 */
1674
-    public function get_remote_subscription_id( $context = 'view' ) {
1675
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1674
+    public function get_remote_subscription_id($context = 'view') {
1675
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1676 1676
 
1677
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1677
+        if (empty($subscription_id) && $this->is_renewal()) {
1678 1678
             $parent = $this->get_parent();
1679
-            return $parent->get_subscription_id( $context );
1679
+            return $parent->get_subscription_id($context);
1680 1680
         }
1681 1681
 
1682 1682
         return $subscription_id;
@@ -1689,20 +1689,20 @@  discard block
 block discarded – undo
1689 1689
 	 * @param  string $context View or edit context.
1690 1690
 	 * @return array
1691 1691
 	 */
1692
-    public function get_payment_meta( $context = 'view' ) {
1692
+    public function get_payment_meta($context = 'view') {
1693 1693
 
1694 1694
         return array(
1695
-            'price'        => $this->get_total( $context ),
1696
-            'date'         => $this->get_date_created( $context ),
1697
-            'user_email'   => $this->get_email( $context ),
1698
-            'invoice_key'  => $this->get_key( $context ),
1699
-            'currency'     => $this->get_currency( $context ),
1700
-            'items'        => $this->get_items( $context ),
1701
-            'user_info'    => $this->get_user_info( $context ),
1695
+            'price'        => $this->get_total($context),
1696
+            'date'         => $this->get_date_created($context),
1697
+            'user_email'   => $this->get_email($context),
1698
+            'invoice_key'  => $this->get_key($context),
1699
+            'currency'     => $this->get_currency($context),
1700
+            'items'        => $this->get_items($context),
1701
+            'user_info'    => $this->get_user_info($context),
1702 1702
             'cart_details' => $this->get_cart_details(),
1703
-            'status'       => $this->get_status( $context ),
1704
-            'fees'         => $this->get_fees( $context ),
1705
-            'taxes'        => $this->get_taxes( $context ),
1703
+            'status'       => $this->get_status($context),
1704
+            'fees'         => $this->get_fees($context),
1705
+            'taxes'        => $this->get_taxes($context),
1706 1706
         );
1707 1707
 
1708 1708
     }
@@ -1717,9 +1717,9 @@  discard block
 block discarded – undo
1717 1717
         $items        = $this->get_items();
1718 1718
         $cart_details = array();
1719 1719
 
1720
-        foreach ( $items as $item ) {
1720
+        foreach ($items as $item) {
1721 1721
 			$item->invoice_id = $this->get_id();
1722
-            $cart_details[]   = $item->prepare_data_for_saving();
1722
+            $cart_details[] = $item->prepare_data_for_saving();
1723 1723
         }
1724 1724
 
1725 1725
         return $cart_details;
@@ -1730,11 +1730,11 @@  discard block
 block discarded – undo
1730 1730
 	 *
1731 1731
 	 * @return null|GetPaid_Form_Item|int
1732 1732
 	 */
1733
-	public function get_recurring( $object = false ) {
1733
+	public function get_recurring($object = false) {
1734 1734
 
1735 1735
 		// Are we returning an object?
1736
-        if ( $object ) {
1737
-            return $this->get_item( $this->recurring_item );
1736
+        if ($object) {
1737
+            return $this->get_item($this->recurring_item);
1738 1738
         }
1739 1739
 
1740 1740
         return $this->recurring_item;
@@ -1749,15 +1749,15 @@  discard block
 block discarded – undo
1749 1749
 	public function get_subscription_name() {
1750 1750
 
1751 1751
 		// Retrieve the recurring name
1752
-        $item = $this->get_recurring( true );
1752
+        $item = $this->get_recurring(true);
1753 1753
 
1754 1754
 		// Abort if it does not exist.
1755
-        if ( empty( $item ) ) {
1755
+        if (empty($item)) {
1756 1756
             return '';
1757 1757
         }
1758 1758
 
1759 1759
 		// Return the item name.
1760
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1760
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1761 1761
 	}
1762 1762
 
1763 1763
 	/**
@@ -1767,9 +1767,9 @@  discard block
 block discarded – undo
1767 1767
 	 * @return string
1768 1768
 	 */
1769 1769
 	public function get_view_url() {
1770
-        $invoice_url = get_permalink( $this->get_id() );
1771
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1772
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1770
+        $invoice_url = get_permalink($this->get_id());
1771
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1772
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1773 1773
 	}
1774 1774
 
1775 1775
 	/**
@@ -1778,25 +1778,25 @@  discard block
 block discarded – undo
1778 1778
 	 * @since 1.0.19
1779 1779
 	 * @return string
1780 1780
 	 */
1781
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1781
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1782 1782
 
1783 1783
 		// Retrieve the checkout url.
1784 1784
         $pay_url = wpinv_get_checkout_uri();
1785 1785
 
1786 1786
 		// Maybe force ssl.
1787
-        if ( is_ssl() ) {
1788
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1787
+        if (is_ssl()) {
1788
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1789 1789
         }
1790 1790
 
1791 1791
 		// Add the invoice key.
1792
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1792
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1793 1793
 
1794 1794
 		// (Maybe?) add a secret
1795
-        if ( $secret ) {
1796
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1795
+        if ($secret) {
1796
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1797 1797
         }
1798 1798
 
1799
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1799
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1800 1800
 	}
1801 1801
 	
1802 1802
 	/**
@@ -1811,14 +1811,14 @@  discard block
 block discarded – undo
1811 1811
         $receipt_url = wpinv_get_success_page_uri();
1812 1812
 
1813 1813
 		// Maybe force ssl.
1814
-        if ( is_ssl() ) {
1815
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1814
+        if (is_ssl()) {
1815
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1816 1816
         }
1817 1817
 
1818 1818
 		// Add the invoice key.
1819
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1819
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1820 1820
 
1821
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1821
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1822 1822
 	}
1823 1823
 	
1824 1824
 	/**
@@ -1831,7 +1831,7 @@  discard block
 block discarded – undo
1831 1831
 
1832 1832
 		$type   = $this->get_type();
1833 1833
 		$status = "wpi-$type-pending";
1834
-		return str_replace( '-invoice', '', $status );
1834
+		return str_replace('-invoice', '', $status);
1835 1835
 
1836 1836
 	}
1837 1837
 
@@ -1845,8 +1845,8 @@  discard block
 block discarded – undo
1845 1845
 	 * @param  string $context View or edit context.
1846 1846
 	 * @return mixed Value of the given invoice property (if set).
1847 1847
 	 */
1848
-	public function get( $key, $context = 'view' ) {
1849
-        return $this->get_prop( $key, $context );
1848
+	public function get($key, $context = 'view') {
1849
+        return $this->get_prop($key, $context);
1850 1850
 	}
1851 1851
 
1852 1852
     /*
@@ -1869,11 +1869,11 @@  discard block
 block discarded – undo
1869 1869
 	 * @param  mixed $value new value.
1870 1870
 	 * @return mixed Value of the given invoice property (if set).
1871 1871
 	 */
1872
-	public function set( $key, $value ) {
1872
+	public function set($key, $value) {
1873 1873
 
1874 1874
         $setter = "set_$key";
1875
-        if ( is_callable( array( $this, $setter ) ) ) {
1876
-            $this->{$setter}( $value );
1875
+        if (is_callable(array($this, $setter))) {
1876
+            $this->{$setter}($value);
1877 1877
         }
1878 1878
 
1879 1879
 	}
@@ -1887,47 +1887,47 @@  discard block
 block discarded – undo
1887 1887
 	 * @param bool   $manual_update Is this a manual status change?.
1888 1888
 	 * @return array details of change.
1889 1889
 	 */
1890
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1890
+	public function set_status($new_status, $note = '', $manual_update = false) {
1891 1891
 		$old_status = $this->get_status();
1892 1892
 
1893 1893
 		$statuses = $this->get_all_statuses();
1894 1894
 
1895
-		if ( isset( $statuses[ 'draft' ] ) ) {
1896
-			unset( $statuses[ 'draft' ] );
1895
+		if (isset($statuses['draft'])) {
1896
+			unset($statuses['draft']);
1897 1897
 		}
1898 1898
 
1899
-		$this->set_prop( 'status', $new_status );
1899
+		$this->set_prop('status', $new_status);
1900 1900
 
1901 1901
 		// If setting the status, ensure it's set to a valid status.
1902
-		if ( true === $this->object_read ) {
1902
+		if (true === $this->object_read) {
1903 1903
 
1904 1904
 			// Only allow valid new status.
1905
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1905
+			if (!array_key_exists($new_status, $statuses)) {
1906 1906
 				$new_status = $this->get_default_status();
1907 1907
 			}
1908 1908
 
1909 1909
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1910
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1910
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
1911 1911
 				$old_status = $this->get_default_status();
1912 1912
 			}
1913 1913
 
1914 1914
 			// Paid - Renewal (i.e when duplicating a parent invoice )
1915
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1915
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
1916 1916
 				$old_status = 'wpi-pending';
1917 1917
 			}
1918 1918
 
1919 1919
 		}
1920 1920
 
1921
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1921
+		if (true === $this->object_read && $old_status !== $new_status) {
1922 1922
 			$this->status_transition = array(
1923
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1923
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
1924 1924
 				'to'     => $new_status,
1925 1925
 				'note'   => $note,
1926 1926
 				'manual' => (bool) $manual_update,
1927 1927
 			);
1928 1928
 
1929
-			if ( $manual_update ) {
1930
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1929
+			if ($manual_update) {
1930
+				do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
1931 1931
 			}
1932 1932
 
1933 1933
 			$this->maybe_set_date_paid();
@@ -1950,8 +1950,8 @@  discard block
 block discarded – undo
1950 1950
 	 */
1951 1951
 	public function maybe_set_date_paid() {
1952 1952
 
1953
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1954
-			$this->set_date_completed( current_time( 'mysql' ) );
1953
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
1954
+			$this->set_date_completed(current_time('mysql'));
1955 1955
 		}
1956 1956
 	}
1957 1957
 
@@ -1960,11 +1960,11 @@  discard block
 block discarded – undo
1960 1960
 	 *
1961 1961
 	 * @since 1.0.19
1962 1962
 	 */
1963
-	public function set_parent_id( $value ) {
1964
-		if ( $value && ( $value === $this->get_id() ) ) {
1963
+	public function set_parent_id($value) {
1964
+		if ($value && ($value === $this->get_id())) {
1965 1965
 			return;
1966 1966
 		}
1967
-		$this->set_prop( 'parent_id', absint( $value ) );
1967
+		$this->set_prop('parent_id', absint($value));
1968 1968
     }
1969 1969
 
1970 1970
     /**
@@ -1972,8 +1972,8 @@  discard block
 block discarded – undo
1972 1972
 	 *
1973 1973
 	 * @since 1.0.19
1974 1974
 	 */
1975
-	public function set_version( $value ) {
1976
-		$this->set_prop( 'version', $value );
1975
+	public function set_version($value) {
1976
+		$this->set_prop('version', $value);
1977 1977
     }
1978 1978
 
1979 1979
     /**
@@ -1983,15 +1983,15 @@  discard block
 block discarded – undo
1983 1983
 	 * @param string $value Value to set.
1984 1984
      * @return bool Whether or not the date was set.
1985 1985
 	 */
1986
-	public function set_date_created( $value ) {
1987
-        $date = strtotime( $value );
1986
+	public function set_date_created($value) {
1987
+        $date = strtotime($value);
1988 1988
 
1989
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1990
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
1989
+        if ($date && $value !== '0000-00-00 00:00:00') {
1990
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
1991 1991
             return true;
1992 1992
         }
1993 1993
 
1994
-		$this->set_prop( 'date_created', '' );
1994
+		$this->set_prop('date_created', '');
1995 1995
 		return false;
1996 1996
 
1997 1997
     }
@@ -2003,15 +2003,15 @@  discard block
 block discarded – undo
2003 2003
 	 * @param string $value Value to set.
2004 2004
      * @return bool Whether or not the date was set.
2005 2005
 	 */
2006
-	public function set_due_date( $value ) {
2007
-        $date = strtotime( $value );
2006
+	public function set_due_date($value) {
2007
+        $date = strtotime($value);
2008 2008
 
2009
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2010
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
2009
+        if ($date && $value !== '0000-00-00 00:00:00') {
2010
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
2011 2011
             return true;
2012 2012
         }
2013 2013
 
2014
-		$this->set_prop( 'due_date', '' );
2014
+		$this->set_prop('due_date', '');
2015 2015
         return false;
2016 2016
 
2017 2017
     }
@@ -2022,8 +2022,8 @@  discard block
 block discarded – undo
2022 2022
 	 * @since 1.0.19
2023 2023
 	 * @param  string $value New name.
2024 2024
 	 */
2025
-	public function set_date_due( $value ) {
2026
-		$this->set_due_date( $value );
2025
+	public function set_date_due($value) {
2026
+		$this->set_due_date($value);
2027 2027
     }
2028 2028
 
2029 2029
     /**
@@ -2033,15 +2033,15 @@  discard block
 block discarded – undo
2033 2033
 	 * @param string $value Value to set.
2034 2034
      * @return bool Whether or not the date was set.
2035 2035
 	 */
2036
-	public function set_completed_date( $value ) {
2037
-        $date = strtotime( $value );
2036
+	public function set_completed_date($value) {
2037
+        $date = strtotime($value);
2038 2038
 
2039
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
2040
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2039
+        if ($date && $value !== '0000-00-00 00:00:00') {
2040
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2041 2041
             return true;
2042 2042
         }
2043 2043
 
2044
-		$this->set_prop( 'completed_date', '' );
2044
+		$this->set_prop('completed_date', '');
2045 2045
         return false;
2046 2046
 
2047 2047
     }
@@ -2052,8 +2052,8 @@  discard block
 block discarded – undo
2052 2052
 	 * @since 1.0.19
2053 2053
 	 * @param  string $value New name.
2054 2054
 	 */
2055
-	public function set_date_completed( $value ) {
2056
-		$this->set_completed_date( $value );
2055
+	public function set_date_completed($value) {
2056
+		$this->set_completed_date($value);
2057 2057
     }
2058 2058
 
2059 2059
     /**
@@ -2063,15 +2063,15 @@  discard block
 block discarded – undo
2063 2063
 	 * @param string $value Value to set.
2064 2064
      * @return bool Whether or not the date was set.
2065 2065
 	 */
2066
-	public function set_date_modified( $value ) {
2067
-        $date = strtotime( $value );
2066
+	public function set_date_modified($value) {
2067
+        $date = strtotime($value);
2068 2068
 
2069
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2070
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2069
+        if ($date && $value !== '0000-00-00 00:00:00') {
2070
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2071 2071
             return true;
2072 2072
         }
2073 2073
 
2074
-		$this->set_prop( 'date_modified', '' );
2074
+		$this->set_prop('date_modified', '');
2075 2075
         return false;
2076 2076
 
2077 2077
     }
@@ -2082,9 +2082,9 @@  discard block
 block discarded – undo
2082 2082
 	 * @since 1.0.19
2083 2083
 	 * @param  string $value New number.
2084 2084
 	 */
2085
-	public function set_number( $value ) {
2086
-        $number = sanitize_text_field( $value );
2087
-		$this->set_prop( 'number', $number );
2085
+	public function set_number($value) {
2086
+        $number = sanitize_text_field($value);
2087
+		$this->set_prop('number', $number);
2088 2088
     }
2089 2089
 
2090 2090
     /**
@@ -2093,9 +2093,9 @@  discard block
 block discarded – undo
2093 2093
 	 * @since 1.0.19
2094 2094
 	 * @param  string $value Type.
2095 2095
 	 */
2096
-	public function set_type( $value ) {
2097
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2098
-		$this->set_prop( 'type', $type );
2096
+	public function set_type($value) {
2097
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2098
+		$this->set_prop('type', $type);
2099 2099
 	}
2100 2100
 
2101 2101
     /**
@@ -2104,10 +2104,10 @@  discard block
 block discarded – undo
2104 2104
 	 * @since 1.0.19
2105 2105
 	 * @param  string $value Post type.
2106 2106
 	 */
2107
-	public function set_post_type( $value ) {
2108
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2109
-			$this->set_type( $value );
2110
-            $this->set_prop( 'post_type', $value );
2107
+	public function set_post_type($value) {
2108
+        if (getpaid_is_invoice_post_type($value)) {
2109
+			$this->set_type($value);
2110
+            $this->set_prop('post_type', $value);
2111 2111
         }
2112 2112
     }
2113 2113
 
@@ -2117,9 +2117,9 @@  discard block
 block discarded – undo
2117 2117
 	 * @since 1.0.19
2118 2118
 	 * @param  string $value New key.
2119 2119
 	 */
2120
-	public function set_key( $value ) {
2121
-        $key = sanitize_text_field( $value );
2122
-		$this->set_prop( 'key', $key );
2120
+	public function set_key($value) {
2121
+        $key = sanitize_text_field($value);
2122
+		$this->set_prop('key', $key);
2123 2123
     }
2124 2124
 
2125 2125
     /**
@@ -2128,9 +2128,9 @@  discard block
 block discarded – undo
2128 2128
 	 * @since 1.0.19
2129 2129
 	 * @param  string $value mode.
2130 2130
 	 */
2131
-	public function set_mode( $value ) {
2132
-        if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2133
-            $this->set_prop( 'value', $value );
2131
+	public function set_mode($value) {
2132
+        if (!in_array($value, array('live', 'test'))) {
2133
+            $this->set_prop('value', $value);
2134 2134
         }
2135 2135
     }
2136 2136
 
@@ -2140,8 +2140,8 @@  discard block
 block discarded – undo
2140 2140
 	 * @since 1.0.19
2141 2141
 	 * @param  string $value path.
2142 2142
 	 */
2143
-	public function set_path( $value ) {
2144
-        $this->set_prop( 'path', $value );
2143
+	public function set_path($value) {
2144
+        $this->set_prop('path', $value);
2145 2145
     }
2146 2146
 
2147 2147
     /**
@@ -2150,9 +2150,9 @@  discard block
 block discarded – undo
2150 2150
 	 * @since 1.0.19
2151 2151
 	 * @param  string $value New name.
2152 2152
 	 */
2153
-	public function set_name( $value ) {
2154
-        $name = sanitize_text_field( $value );
2155
-		$this->set_prop( 'name', $name );
2153
+	public function set_name($value) {
2154
+        $name = sanitize_text_field($value);
2155
+		$this->set_prop('name', $name);
2156 2156
     }
2157 2157
 
2158 2158
     /**
@@ -2161,8 +2161,8 @@  discard block
 block discarded – undo
2161 2161
 	 * @since 1.0.19
2162 2162
 	 * @param  string $value New name.
2163 2163
 	 */
2164
-	public function set_title( $value ) {
2165
-		$this->set_name( $value );
2164
+	public function set_title($value) {
2165
+		$this->set_name($value);
2166 2166
     }
2167 2167
 
2168 2168
     /**
@@ -2171,9 +2171,9 @@  discard block
 block discarded – undo
2171 2171
 	 * @since 1.0.19
2172 2172
 	 * @param  string $value New description.
2173 2173
 	 */
2174
-	public function set_description( $value ) {
2175
-        $description = wp_kses_post( $value );
2176
-		$this->set_prop( 'description', $description );
2174
+	public function set_description($value) {
2175
+        $description = wp_kses_post($value);
2176
+		$this->set_prop('description', $description);
2177 2177
     }
2178 2178
 
2179 2179
     /**
@@ -2182,8 +2182,8 @@  discard block
 block discarded – undo
2182 2182
 	 * @since 1.0.19
2183 2183
 	 * @param  string $value New description.
2184 2184
 	 */
2185
-	public function set_excerpt( $value ) {
2186
-		$this->set_description( $value );
2185
+	public function set_excerpt($value) {
2186
+		$this->set_description($value);
2187 2187
     }
2188 2188
 
2189 2189
     /**
@@ -2192,8 +2192,8 @@  discard block
 block discarded – undo
2192 2192
 	 * @since 1.0.19
2193 2193
 	 * @param  string $value New description.
2194 2194
 	 */
2195
-	public function set_summary( $value ) {
2196
-		$this->set_description( $value );
2195
+	public function set_summary($value) {
2196
+		$this->set_description($value);
2197 2197
     }
2198 2198
 
2199 2199
     /**
@@ -2202,12 +2202,12 @@  discard block
 block discarded – undo
2202 2202
 	 * @since 1.0.19
2203 2203
 	 * @param  int $value New author.
2204 2204
 	 */
2205
-	public function set_author( $value ) {
2206
-		$user = get_user_by( 'id', (int) $value );
2205
+	public function set_author($value) {
2206
+		$user = get_user_by('id', (int) $value);
2207 2207
 
2208
-		if ( $user && $user->ID ) {
2209
-			$this->set_prop( 'author', $user->ID );
2210
-			$this->set_prop( 'email', $user->user_email );
2208
+		if ($user && $user->ID) {
2209
+			$this->set_prop('author', $user->ID);
2210
+			$this->set_prop('email', $user->user_email);
2211 2211
 		}
2212 2212
 
2213 2213
     }
@@ -2218,8 +2218,8 @@  discard block
 block discarded – undo
2218 2218
 	 * @since 1.0.19
2219 2219
 	 * @param  int $value New user id.
2220 2220
 	 */
2221
-	public function set_user_id( $value ) {
2222
-		$this->set_author( $value );
2221
+	public function set_user_id($value) {
2222
+		$this->set_author($value);
2223 2223
     }
2224 2224
 
2225 2225
     /**
@@ -2228,8 +2228,8 @@  discard block
 block discarded – undo
2228 2228
 	 * @since 1.0.19
2229 2229
 	 * @param  int $value New user id.
2230 2230
 	 */
2231
-	public function set_customer_id( $value ) {
2232
-		$this->set_author( $value );
2231
+	public function set_customer_id($value) {
2232
+		$this->set_author($value);
2233 2233
     }
2234 2234
 
2235 2235
     /**
@@ -2238,8 +2238,8 @@  discard block
 block discarded – undo
2238 2238
 	 * @since 1.0.19
2239 2239
 	 * @param  string $value ip address.
2240 2240
 	 */
2241
-	public function set_ip( $value ) {
2242
-		$this->set_prop( 'ip', $value );
2241
+	public function set_ip($value) {
2242
+		$this->set_prop('ip', $value);
2243 2243
     }
2244 2244
 
2245 2245
     /**
@@ -2248,8 +2248,8 @@  discard block
 block discarded – undo
2248 2248
 	 * @since 1.0.19
2249 2249
 	 * @param  string $value ip address.
2250 2250
 	 */
2251
-	public function set_user_ip( $value ) {
2252
-		$this->set_ip( $value );
2251
+	public function set_user_ip($value) {
2252
+		$this->set_ip($value);
2253 2253
     }
2254 2254
 
2255 2255
     /**
@@ -2258,8 +2258,8 @@  discard block
 block discarded – undo
2258 2258
 	 * @since 1.0.19
2259 2259
 	 * @param  string $value first name.
2260 2260
 	 */
2261
-	public function set_first_name( $value ) {
2262
-		$this->set_prop( 'first_name', $value );
2261
+	public function set_first_name($value) {
2262
+		$this->set_prop('first_name', $value);
2263 2263
     }
2264 2264
 
2265 2265
     /**
@@ -2268,8 +2268,8 @@  discard block
 block discarded – undo
2268 2268
 	 * @since 1.0.19
2269 2269
 	 * @param  string $value first name.
2270 2270
 	 */
2271
-	public function set_user_first_name( $value ) {
2272
-		$this->set_first_name( $value );
2271
+	public function set_user_first_name($value) {
2272
+		$this->set_first_name($value);
2273 2273
     }
2274 2274
 
2275 2275
     /**
@@ -2278,8 +2278,8 @@  discard block
 block discarded – undo
2278 2278
 	 * @since 1.0.19
2279 2279
 	 * @param  string $value first name.
2280 2280
 	 */
2281
-	public function set_customer_first_name( $value ) {
2282
-		$this->set_first_name( $value );
2281
+	public function set_customer_first_name($value) {
2282
+		$this->set_first_name($value);
2283 2283
     }
2284 2284
 
2285 2285
     /**
@@ -2288,8 +2288,8 @@  discard block
 block discarded – undo
2288 2288
 	 * @since 1.0.19
2289 2289
 	 * @param  string $value last name.
2290 2290
 	 */
2291
-	public function set_last_name( $value ) {
2292
-		$this->set_prop( 'last_name', $value );
2291
+	public function set_last_name($value) {
2292
+		$this->set_prop('last_name', $value);
2293 2293
     }
2294 2294
 
2295 2295
     /**
@@ -2298,8 +2298,8 @@  discard block
 block discarded – undo
2298 2298
 	 * @since 1.0.19
2299 2299
 	 * @param  string $value last name.
2300 2300
 	 */
2301
-	public function set_user_last_name( $value ) {
2302
-		$this->set_last_name( $value );
2301
+	public function set_user_last_name($value) {
2302
+		$this->set_last_name($value);
2303 2303
     }
2304 2304
 
2305 2305
     /**
@@ -2308,8 +2308,8 @@  discard block
 block discarded – undo
2308 2308
 	 * @since 1.0.19
2309 2309
 	 * @param  string $value last name.
2310 2310
 	 */
2311
-	public function set_customer_last_name( $value ) {
2312
-		$this->set_last_name( $value );
2311
+	public function set_customer_last_name($value) {
2312
+		$this->set_last_name($value);
2313 2313
     }
2314 2314
 
2315 2315
     /**
@@ -2318,8 +2318,8 @@  discard block
 block discarded – undo
2318 2318
 	 * @since 1.0.19
2319 2319
 	 * @param  string $value phone.
2320 2320
 	 */
2321
-	public function set_phone( $value ) {
2322
-		$this->set_prop( 'phone', $value );
2321
+	public function set_phone($value) {
2322
+		$this->set_prop('phone', $value);
2323 2323
     }
2324 2324
 
2325 2325
     /**
@@ -2328,8 +2328,8 @@  discard block
 block discarded – undo
2328 2328
 	 * @since 1.0.19
2329 2329
 	 * @param  string $value phone.
2330 2330
 	 */
2331
-	public function set_user_phone( $value ) {
2332
-		$this->set_phone( $value );
2331
+	public function set_user_phone($value) {
2332
+		$this->set_phone($value);
2333 2333
     }
2334 2334
 
2335 2335
     /**
@@ -2338,8 +2338,8 @@  discard block
 block discarded – undo
2338 2338
 	 * @since 1.0.19
2339 2339
 	 * @param  string $value phone.
2340 2340
 	 */
2341
-	public function set_customer_phone( $value ) {
2342
-		$this->set_phone( $value );
2341
+	public function set_customer_phone($value) {
2342
+		$this->set_phone($value);
2343 2343
     }
2344 2344
 
2345 2345
     /**
@@ -2348,8 +2348,8 @@  discard block
 block discarded – undo
2348 2348
 	 * @since 1.0.19
2349 2349
 	 * @param  string $value phone.
2350 2350
 	 */
2351
-	public function set_phone_number( $value ) {
2352
-		$this->set_phone( $value );
2351
+	public function set_phone_number($value) {
2352
+		$this->set_phone($value);
2353 2353
     }
2354 2354
 
2355 2355
     /**
@@ -2358,8 +2358,8 @@  discard block
 block discarded – undo
2358 2358
 	 * @since 1.0.19
2359 2359
 	 * @param  string $value email address.
2360 2360
 	 */
2361
-	public function set_email( $value ) {
2362
-		$this->set_prop( 'email', $value );
2361
+	public function set_email($value) {
2362
+		$this->set_prop('email', $value);
2363 2363
     }
2364 2364
 
2365 2365
     /**
@@ -2368,8 +2368,8 @@  discard block
 block discarded – undo
2368 2368
 	 * @since 1.0.19
2369 2369
 	 * @param  string $value email address.
2370 2370
 	 */
2371
-	public function set_user_email( $value ) {
2372
-		$this->set_email( $value );
2371
+	public function set_user_email($value) {
2372
+		$this->set_email($value);
2373 2373
     }
2374 2374
 
2375 2375
     /**
@@ -2378,8 +2378,8 @@  discard block
 block discarded – undo
2378 2378
 	 * @since 1.0.19
2379 2379
 	 * @param  string $value email address.
2380 2380
 	 */
2381
-	public function set_email_address( $value ) {
2382
-		$this->set_email( $value );
2381
+	public function set_email_address($value) {
2382
+		$this->set_email($value);
2383 2383
     }
2384 2384
 
2385 2385
     /**
@@ -2388,8 +2388,8 @@  discard block
 block discarded – undo
2388 2388
 	 * @since 1.0.19
2389 2389
 	 * @param  string $value email address.
2390 2390
 	 */
2391
-	public function set_customer_email( $value ) {
2392
-		$this->set_email( $value );
2391
+	public function set_customer_email($value) {
2392
+		$this->set_email($value);
2393 2393
     }
2394 2394
 
2395 2395
     /**
@@ -2398,8 +2398,8 @@  discard block
 block discarded – undo
2398 2398
 	 * @since 1.0.19
2399 2399
 	 * @param  string $value country.
2400 2400
 	 */
2401
-	public function set_country( $value ) {
2402
-		$this->set_prop( 'country', $value );
2401
+	public function set_country($value) {
2402
+		$this->set_prop('country', $value);
2403 2403
     }
2404 2404
 
2405 2405
     /**
@@ -2408,8 +2408,8 @@  discard block
 block discarded – undo
2408 2408
 	 * @since 1.0.19
2409 2409
 	 * @param  string $value country.
2410 2410
 	 */
2411
-	public function set_user_country( $value ) {
2412
-		$this->set_country( $value );
2411
+	public function set_user_country($value) {
2412
+		$this->set_country($value);
2413 2413
     }
2414 2414
 
2415 2415
     /**
@@ -2418,8 +2418,8 @@  discard block
 block discarded – undo
2418 2418
 	 * @since 1.0.19
2419 2419
 	 * @param  string $value country.
2420 2420
 	 */
2421
-	public function set_customer_country( $value ) {
2422
-		$this->set_country( $value );
2421
+	public function set_customer_country($value) {
2422
+		$this->set_country($value);
2423 2423
     }
2424 2424
 
2425 2425
     /**
@@ -2428,8 +2428,8 @@  discard block
 block discarded – undo
2428 2428
 	 * @since 1.0.19
2429 2429
 	 * @param  string $value state.
2430 2430
 	 */
2431
-	public function set_state( $value ) {
2432
-		$this->set_prop( 'state', $value );
2431
+	public function set_state($value) {
2432
+		$this->set_prop('state', $value);
2433 2433
     }
2434 2434
 
2435 2435
     /**
@@ -2438,8 +2438,8 @@  discard block
 block discarded – undo
2438 2438
 	 * @since 1.0.19
2439 2439
 	 * @param  string $value state.
2440 2440
 	 */
2441
-	public function set_user_state( $value ) {
2442
-		$this->set_state( $value );
2441
+	public function set_user_state($value) {
2442
+		$this->set_state($value);
2443 2443
     }
2444 2444
 
2445 2445
     /**
@@ -2448,8 +2448,8 @@  discard block
 block discarded – undo
2448 2448
 	 * @since 1.0.19
2449 2449
 	 * @param  string $value state.
2450 2450
 	 */
2451
-	public function set_customer_state( $value ) {
2452
-		$this->set_state( $value );
2451
+	public function set_customer_state($value) {
2452
+		$this->set_state($value);
2453 2453
     }
2454 2454
 
2455 2455
     /**
@@ -2458,8 +2458,8 @@  discard block
 block discarded – undo
2458 2458
 	 * @since 1.0.19
2459 2459
 	 * @param  string $value city.
2460 2460
 	 */
2461
-	public function set_city( $value ) {
2462
-		$this->set_prop( 'city', $value );
2461
+	public function set_city($value) {
2462
+		$this->set_prop('city', $value);
2463 2463
     }
2464 2464
 
2465 2465
     /**
@@ -2468,8 +2468,8 @@  discard block
 block discarded – undo
2468 2468
 	 * @since 1.0.19
2469 2469
 	 * @param  string $value city.
2470 2470
 	 */
2471
-	public function set_user_city( $value ) {
2472
-		$this->set_city( $value );
2471
+	public function set_user_city($value) {
2472
+		$this->set_city($value);
2473 2473
     }
2474 2474
 
2475 2475
     /**
@@ -2478,8 +2478,8 @@  discard block
 block discarded – undo
2478 2478
 	 * @since 1.0.19
2479 2479
 	 * @param  string $value city.
2480 2480
 	 */
2481
-	public function set_customer_city( $value ) {
2482
-		$this->set_city( $value );
2481
+	public function set_customer_city($value) {
2482
+		$this->set_city($value);
2483 2483
     }
2484 2484
 
2485 2485
     /**
@@ -2488,8 +2488,8 @@  discard block
 block discarded – undo
2488 2488
 	 * @since 1.0.19
2489 2489
 	 * @param  string $value zip.
2490 2490
 	 */
2491
-	public function set_zip( $value ) {
2492
-		$this->set_prop( 'zip', $value );
2491
+	public function set_zip($value) {
2492
+		$this->set_prop('zip', $value);
2493 2493
     }
2494 2494
 
2495 2495
     /**
@@ -2498,8 +2498,8 @@  discard block
 block discarded – undo
2498 2498
 	 * @since 1.0.19
2499 2499
 	 * @param  string $value zip.
2500 2500
 	 */
2501
-	public function set_user_zip( $value ) {
2502
-		$this->set_zip( $value );
2501
+	public function set_user_zip($value) {
2502
+		$this->set_zip($value);
2503 2503
     }
2504 2504
 
2505 2505
     /**
@@ -2508,8 +2508,8 @@  discard block
 block discarded – undo
2508 2508
 	 * @since 1.0.19
2509 2509
 	 * @param  string $value zip.
2510 2510
 	 */
2511
-	public function set_customer_zip( $value ) {
2512
-		$this->set_zip( $value );
2511
+	public function set_customer_zip($value) {
2512
+		$this->set_zip($value);
2513 2513
     }
2514 2514
 
2515 2515
     /**
@@ -2518,8 +2518,8 @@  discard block
 block discarded – undo
2518 2518
 	 * @since 1.0.19
2519 2519
 	 * @param  string $value company.
2520 2520
 	 */
2521
-	public function set_company( $value ) {
2522
-		$this->set_prop( 'company', $value );
2521
+	public function set_company($value) {
2522
+		$this->set_prop('company', $value);
2523 2523
     }
2524 2524
 
2525 2525
     /**
@@ -2528,8 +2528,8 @@  discard block
 block discarded – undo
2528 2528
 	 * @since 1.0.19
2529 2529
 	 * @param  string $value company.
2530 2530
 	 */
2531
-	public function set_user_company( $value ) {
2532
-		$this->set_company( $value );
2531
+	public function set_user_company($value) {
2532
+		$this->set_company($value);
2533 2533
     }
2534 2534
 
2535 2535
     /**
@@ -2538,8 +2538,8 @@  discard block
 block discarded – undo
2538 2538
 	 * @since 1.0.19
2539 2539
 	 * @param  string $value company.
2540 2540
 	 */
2541
-	public function set_customer_company( $value ) {
2542
-		$this->set_company( $value );
2541
+	public function set_customer_company($value) {
2542
+		$this->set_company($value);
2543 2543
     }
2544 2544
 
2545 2545
     /**
@@ -2548,8 +2548,8 @@  discard block
 block discarded – undo
2548 2548
 	 * @since 1.0.19
2549 2549
 	 * @param  string $value var number.
2550 2550
 	 */
2551
-	public function set_vat_number( $value ) {
2552
-		$this->set_prop( 'vat_number', $value );
2551
+	public function set_vat_number($value) {
2552
+		$this->set_prop('vat_number', $value);
2553 2553
     }
2554 2554
 
2555 2555
     /**
@@ -2558,8 +2558,8 @@  discard block
 block discarded – undo
2558 2558
 	 * @since 1.0.19
2559 2559
 	 * @param  string $value var number.
2560 2560
 	 */
2561
-	public function set_user_vat_number( $value ) {
2562
-		$this->set_vat_number( $value );
2561
+	public function set_user_vat_number($value) {
2562
+		$this->set_vat_number($value);
2563 2563
     }
2564 2564
 
2565 2565
     /**
@@ -2568,8 +2568,8 @@  discard block
 block discarded – undo
2568 2568
 	 * @since 1.0.19
2569 2569
 	 * @param  string $value var number.
2570 2570
 	 */
2571
-	public function set_customer_vat_number( $value ) {
2572
-		$this->set_vat_number( $value );
2571
+	public function set_customer_vat_number($value) {
2572
+		$this->set_vat_number($value);
2573 2573
     }
2574 2574
 
2575 2575
     /**
@@ -2578,8 +2578,8 @@  discard block
 block discarded – undo
2578 2578
 	 * @since 1.0.19
2579 2579
 	 * @param  string $value var rate.
2580 2580
 	 */
2581
-	public function set_vat_rate( $value ) {
2582
-		$this->set_prop( 'vat_rate', $value );
2581
+	public function set_vat_rate($value) {
2582
+		$this->set_prop('vat_rate', $value);
2583 2583
     }
2584 2584
 
2585 2585
     /**
@@ -2588,8 +2588,8 @@  discard block
 block discarded – undo
2588 2588
 	 * @since 1.0.19
2589 2589
 	 * @param  string $value var number.
2590 2590
 	 */
2591
-	public function set_user_vat_rate( $value ) {
2592
-		$this->set_vat_rate( $value );
2591
+	public function set_user_vat_rate($value) {
2592
+		$this->set_vat_rate($value);
2593 2593
     }
2594 2594
 
2595 2595
     /**
@@ -2598,8 +2598,8 @@  discard block
 block discarded – undo
2598 2598
 	 * @since 1.0.19
2599 2599
 	 * @param  string $value var number.
2600 2600
 	 */
2601
-	public function set_customer_vat_rate( $value ) {
2602
-		$this->set_vat_rate( $value );
2601
+	public function set_customer_vat_rate($value) {
2602
+		$this->set_vat_rate($value);
2603 2603
     }
2604 2604
 
2605 2605
     /**
@@ -2608,8 +2608,8 @@  discard block
 block discarded – undo
2608 2608
 	 * @since 1.0.19
2609 2609
 	 * @param  string $value address.
2610 2610
 	 */
2611
-	public function set_address( $value ) {
2612
-		$this->set_prop( 'address', $value );
2611
+	public function set_address($value) {
2612
+		$this->set_prop('address', $value);
2613 2613
     }
2614 2614
 
2615 2615
     /**
@@ -2618,8 +2618,8 @@  discard block
 block discarded – undo
2618 2618
 	 * @since 1.0.19
2619 2619
 	 * @param  string $value address.
2620 2620
 	 */
2621
-	public function set_user_address( $value ) {
2622
-		$this->set_address( $value );
2621
+	public function set_user_address($value) {
2622
+		$this->set_address($value);
2623 2623
     }
2624 2624
 
2625 2625
     /**
@@ -2628,8 +2628,8 @@  discard block
 block discarded – undo
2628 2628
 	 * @since 1.0.19
2629 2629
 	 * @param  string $value address.
2630 2630
 	 */
2631
-	public function set_customer_address( $value ) {
2632
-		$this->set_address( $value );
2631
+	public function set_customer_address($value) {
2632
+		$this->set_address($value);
2633 2633
     }
2634 2634
 
2635 2635
     /**
@@ -2638,8 +2638,8 @@  discard block
 block discarded – undo
2638 2638
 	 * @since 1.0.19
2639 2639
 	 * @param  int|bool $value confirmed.
2640 2640
 	 */
2641
-	public function set_is_viewed( $value ) {
2642
-		$this->set_prop( 'is_viewed', $value );
2641
+	public function set_is_viewed($value) {
2642
+		$this->set_prop('is_viewed', $value);
2643 2643
 	}
2644 2644
 
2645 2645
 	/**
@@ -2648,8 +2648,8 @@  discard block
 block discarded – undo
2648 2648
 	 * @since 1.0.19
2649 2649
 	 * @param  string $value email recipients.
2650 2650
 	 */
2651
-	public function set_email_cc( $value ) {
2652
-		$this->set_prop( 'email_cc', $value );
2651
+	public function set_email_cc($value) {
2652
+		$this->set_prop('email_cc', $value);
2653 2653
 	}
2654 2654
 
2655 2655
 	/**
@@ -2658,9 +2658,9 @@  discard block
 block discarded – undo
2658 2658
 	 * @since 1.0.19
2659 2659
 	 * @param  string $value template.
2660 2660
 	 */
2661
-	public function set_template( $value ) {
2662
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2663
-			$this->set_prop( 'template', $value );
2661
+	public function set_template($value) {
2662
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2663
+			$this->set_prop('template', $value);
2664 2664
 		}
2665 2665
 	}
2666 2666
 
@@ -2670,8 +2670,8 @@  discard block
 block discarded – undo
2670 2670
 	 * @since 1.0.19
2671 2671
 	 * @param  string $value email recipients.
2672 2672
 	 */
2673
-	public function created_via( $value ) {
2674
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2673
+	public function created_via($value) {
2674
+		$this->set_prop('created_via', sanitize_text_field($value));
2675 2675
 	}
2676 2676
 
2677 2677
 	/**
@@ -2680,8 +2680,8 @@  discard block
 block discarded – undo
2680 2680
 	 * @since 1.0.19
2681 2681
 	 * @param  int|bool $value confirmed.
2682 2682
 	 */
2683
-	public function set_address_confirmed( $value ) {
2684
-		$this->set_prop( 'address_confirmed', $value );
2683
+	public function set_address_confirmed($value) {
2684
+		$this->set_prop('address_confirmed', $value);
2685 2685
     }
2686 2686
 
2687 2687
     /**
@@ -2690,8 +2690,8 @@  discard block
 block discarded – undo
2690 2690
 	 * @since 1.0.19
2691 2691
 	 * @param  int|bool $value confirmed.
2692 2692
 	 */
2693
-	public function set_user_address_confirmed( $value ) {
2694
-		$this->set_address_confirmed( $value );
2693
+	public function set_user_address_confirmed($value) {
2694
+		$this->set_address_confirmed($value);
2695 2695
     }
2696 2696
 
2697 2697
     /**
@@ -2700,8 +2700,8 @@  discard block
 block discarded – undo
2700 2700
 	 * @since 1.0.19
2701 2701
 	 * @param  int|bool $value confirmed.
2702 2702
 	 */
2703
-	public function set_customer_address_confirmed( $value ) {
2704
-		$this->set_address_confirmed( $value );
2703
+	public function set_customer_address_confirmed($value) {
2704
+		$this->set_address_confirmed($value);
2705 2705
     }
2706 2706
 
2707 2707
     /**
@@ -2710,8 +2710,8 @@  discard block
 block discarded – undo
2710 2710
 	 * @since 1.0.19
2711 2711
 	 * @param  float $value sub total.
2712 2712
 	 */
2713
-	public function set_subtotal( $value ) {
2714
-		$this->set_prop( 'subtotal', $value );
2713
+	public function set_subtotal($value) {
2714
+		$this->set_prop('subtotal', $value);
2715 2715
     }
2716 2716
 
2717 2717
     /**
@@ -2720,8 +2720,8 @@  discard block
 block discarded – undo
2720 2720
 	 * @since 1.0.19
2721 2721
 	 * @param  float $value discount total.
2722 2722
 	 */
2723
-	public function set_total_discount( $value ) {
2724
-		$this->set_prop( 'total_discount', $value );
2723
+	public function set_total_discount($value) {
2724
+		$this->set_prop('total_discount', $value);
2725 2725
     }
2726 2726
 
2727 2727
     /**
@@ -2730,8 +2730,8 @@  discard block
 block discarded – undo
2730 2730
 	 * @since 1.0.19
2731 2731
 	 * @param  float $value discount total.
2732 2732
 	 */
2733
-	public function set_discount( $value ) {
2734
-		$this->set_total_discount( $value );
2733
+	public function set_discount($value) {
2734
+		$this->set_total_discount($value);
2735 2735
     }
2736 2736
 
2737 2737
     /**
@@ -2740,8 +2740,8 @@  discard block
 block discarded – undo
2740 2740
 	 * @since 1.0.19
2741 2741
 	 * @param  float $value tax total.
2742 2742
 	 */
2743
-	public function set_total_tax( $value ) {
2744
-		$this->set_prop( 'total_tax', $value );
2743
+	public function set_total_tax($value) {
2744
+		$this->set_prop('total_tax', $value);
2745 2745
     }
2746 2746
 
2747 2747
     /**
@@ -2750,8 +2750,8 @@  discard block
 block discarded – undo
2750 2750
 	 * @since 1.0.19
2751 2751
 	 * @param  float $value tax total.
2752 2752
 	 */
2753
-	public function set_tax_total( $value ) {
2754
-		$this->set_total_tax( $value );
2753
+	public function set_tax_total($value) {
2754
+		$this->set_total_tax($value);
2755 2755
     }
2756 2756
 
2757 2757
     /**
@@ -2760,8 +2760,8 @@  discard block
 block discarded – undo
2760 2760
 	 * @since 1.0.19
2761 2761
 	 * @param  float $value fees total.
2762 2762
 	 */
2763
-	public function set_total_fees( $value ) {
2764
-		$this->set_prop( 'total_fees', $value );
2763
+	public function set_total_fees($value) {
2764
+		$this->set_prop('total_fees', $value);
2765 2765
     }
2766 2766
 
2767 2767
     /**
@@ -2770,8 +2770,8 @@  discard block
 block discarded – undo
2770 2770
 	 * @since 1.0.19
2771 2771
 	 * @param  float $value fees total.
2772 2772
 	 */
2773
-	public function set_fees_total( $value ) {
2774
-		$this->set_total_fees( $value );
2773
+	public function set_fees_total($value) {
2774
+		$this->set_total_fees($value);
2775 2775
     }
2776 2776
 
2777 2777
     /**
@@ -2780,13 +2780,13 @@  discard block
 block discarded – undo
2780 2780
 	 * @since 1.0.19
2781 2781
 	 * @param  array $value fees.
2782 2782
 	 */
2783
-	public function set_fees( $value ) {
2783
+	public function set_fees($value) {
2784 2784
 
2785
-		if ( ! is_array( $value ) ) {
2785
+		if (!is_array($value)) {
2786 2786
 			$value = array();
2787 2787
 		}
2788 2788
 
2789
-		$this->set_prop( 'fees', $value );
2789
+		$this->set_prop('fees', $value);
2790 2790
 
2791 2791
     }
2792 2792
 
@@ -2796,13 +2796,13 @@  discard block
 block discarded – undo
2796 2796
 	 * @since 1.0.19
2797 2797
 	 * @param  array $value taxes.
2798 2798
 	 */
2799
-	public function set_taxes( $value ) {
2799
+	public function set_taxes($value) {
2800 2800
 
2801
-		if ( ! is_array( $value ) ) {
2801
+		if (!is_array($value)) {
2802 2802
 			$value = array();
2803 2803
 		}
2804 2804
 
2805
-		$this->set_prop( 'taxes', $value );
2805
+		$this->set_prop('taxes', $value);
2806 2806
 
2807 2807
     }
2808 2808
 
@@ -2812,13 +2812,13 @@  discard block
 block discarded – undo
2812 2812
 	 * @since 1.0.19
2813 2813
 	 * @param  array $value discounts.
2814 2814
 	 */
2815
-	public function set_discounts( $value ) {
2815
+	public function set_discounts($value) {
2816 2816
 
2817
-		if ( ! is_array( $value ) ) {
2817
+		if (!is_array($value)) {
2818 2818
 			$value = array();
2819 2819
 		}
2820 2820
 
2821
-		$this->set_prop( 'discounts', $value );
2821
+		$this->set_prop('discounts', $value);
2822 2822
     }
2823 2823
 
2824 2824
     /**
@@ -2827,18 +2827,18 @@  discard block
 block discarded – undo
2827 2827
 	 * @since 1.0.19
2828 2828
 	 * @param  GetPaid_Form_Item[] $value items.
2829 2829
 	 */
2830
-	public function set_items( $value ) {
2830
+	public function set_items($value) {
2831 2831
 
2832 2832
         // Remove existing items.
2833
-        $this->set_prop( 'items', array() );
2833
+        $this->set_prop('items', array());
2834 2834
 
2835 2835
         // Ensure that we have an array.
2836
-        if ( ! is_array( $value ) ) {
2836
+        if (!is_array($value)) {
2837 2837
             return;
2838 2838
         }
2839 2839
 
2840
-        foreach ( $value as $item ) {
2841
-            $this->add_item( $item );
2840
+        foreach ($value as $item) {
2841
+            $this->add_item($item);
2842 2842
         }
2843 2843
 
2844 2844
     }
@@ -2849,8 +2849,8 @@  discard block
 block discarded – undo
2849 2849
 	 * @since 1.0.19
2850 2850
 	 * @param  int $value payment form.
2851 2851
 	 */
2852
-	public function set_payment_form( $value ) {
2853
-		$this->set_prop( 'payment_form', $value );
2852
+	public function set_payment_form($value) {
2853
+		$this->set_prop('payment_form', $value);
2854 2854
     }
2855 2855
 
2856 2856
     /**
@@ -2859,8 +2859,8 @@  discard block
 block discarded – undo
2859 2859
 	 * @since 1.0.19
2860 2860
 	 * @param  string $value submission id.
2861 2861
 	 */
2862
-	public function set_submission_id( $value ) {
2863
-		$this->set_prop( 'submission_id', $value );
2862
+	public function set_submission_id($value) {
2863
+		$this->set_prop('submission_id', $value);
2864 2864
     }
2865 2865
 
2866 2866
     /**
@@ -2869,8 +2869,8 @@  discard block
 block discarded – undo
2869 2869
 	 * @since 1.0.19
2870 2870
 	 * @param  string $value discount code.
2871 2871
 	 */
2872
-	public function set_discount_code( $value ) {
2873
-		$this->set_prop( 'discount_code', $value );
2872
+	public function set_discount_code($value) {
2873
+		$this->set_prop('discount_code', $value);
2874 2874
     }
2875 2875
 
2876 2876
     /**
@@ -2879,8 +2879,8 @@  discard block
 block discarded – undo
2879 2879
 	 * @since 1.0.19
2880 2880
 	 * @param  string $value gateway.
2881 2881
 	 */
2882
-	public function set_gateway( $value ) {
2883
-		$this->set_prop( 'gateway', $value );
2882
+	public function set_gateway($value) {
2883
+		$this->set_prop('gateway', $value);
2884 2884
     }
2885 2885
 
2886 2886
     /**
@@ -2889,9 +2889,9 @@  discard block
 block discarded – undo
2889 2889
 	 * @since 1.0.19
2890 2890
 	 * @param  string $value transaction id.
2891 2891
 	 */
2892
-	public function set_transaction_id( $value ) {
2893
-		if ( ! empty( $value ) ) {
2894
-			$this->set_prop( 'transaction_id', $value );
2892
+	public function set_transaction_id($value) {
2893
+		if (!empty($value)) {
2894
+			$this->set_prop('transaction_id', $value);
2895 2895
 		}
2896 2896
     }
2897 2897
 
@@ -2901,8 +2901,8 @@  discard block
 block discarded – undo
2901 2901
 	 * @since 1.0.19
2902 2902
 	 * @param  string $value currency id.
2903 2903
 	 */
2904
-	public function set_currency( $value ) {
2905
-		$this->set_prop( 'currency', $value );
2904
+	public function set_currency($value) {
2905
+		$this->set_prop('currency', $value);
2906 2906
     }
2907 2907
 
2908 2908
 	/**
@@ -2911,8 +2911,8 @@  discard block
 block discarded – undo
2911 2911
 	 * @since 1.0.19
2912 2912
 	 * @param  bool $value value.
2913 2913
 	 */
2914
-	public function set_disable_taxes( $value ) {
2915
-		$this->set_prop( 'disable_taxes', (bool) $value );
2914
+	public function set_disable_taxes($value) {
2915
+		$this->set_prop('disable_taxes', (bool) $value);
2916 2916
 	}
2917 2917
 
2918 2918
     /**
@@ -2921,8 +2921,8 @@  discard block
 block discarded – undo
2921 2921
 	 * @since 1.0.19
2922 2922
 	 * @param  string $value subscription id.
2923 2923
 	 */
2924
-	public function set_subscription_id( $value ) {
2925
-		$this->set_prop( 'subscription_id', $value );
2924
+	public function set_subscription_id($value) {
2925
+		$this->set_prop('subscription_id', $value);
2926 2926
 	}
2927 2927
 	
2928 2928
 	/**
@@ -2931,8 +2931,8 @@  discard block
 block discarded – undo
2931 2931
 	 * @since 1.0.19
2932 2932
 	 * @param  string $value subscription id.
2933 2933
 	 */
2934
-	public function set_remote_subscription_id( $value ) {
2935
-		$this->set_prop( 'remote_subscription_id', $value );
2934
+	public function set_remote_subscription_id($value) {
2935
+		$this->set_prop('remote_subscription_id', $value);
2936 2936
     }
2937 2937
 
2938 2938
     /*
@@ -2949,28 +2949,28 @@  discard block
 block discarded – undo
2949 2949
      */
2950 2950
     public function is_parent() {
2951 2951
         $parent = $this->get_parent_id();
2952
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
2952
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
2953 2953
     }
2954 2954
 
2955 2955
     /**
2956 2956
      * Checks if this is a renewal invoice.
2957 2957
      */
2958 2958
     public function is_renewal() {
2959
-        return ! $this->is_parent();
2959
+        return !$this->is_parent();
2960 2960
     }
2961 2961
 
2962 2962
     /**
2963 2963
      * Checks if this is a recurring invoice.
2964 2964
      */
2965 2965
     public function is_recurring() {
2966
-        return $this->is_renewal() || ! empty( $this->recurring_item );
2966
+        return $this->is_renewal() || !empty($this->recurring_item);
2967 2967
     }
2968 2968
 
2969 2969
     /**
2970 2970
      * Checks if this is a taxable invoice.
2971 2971
      */
2972 2972
     public function is_taxable() {
2973
-        return ! $this->get_disable_taxes();
2973
+        return !$this->get_disable_taxes();
2974 2974
 	}
2975 2975
 
2976 2976
 	/**
@@ -2984,45 +2984,45 @@  discard block
 block discarded – undo
2984 2984
 	 * Checks to see if the invoice requires payment.
2985 2985
 	 */
2986 2986
 	public function is_free() {
2987
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2987
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
2988 2988
 
2989
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2989
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
2990 2990
 			$is_free = false;
2991 2991
 		}
2992 2992
 
2993
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2993
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2994 2994
     }
2995 2995
 
2996 2996
     /**
2997 2997
      * Checks if the invoice is paid.
2998 2998
      */
2999 2999
     public function is_paid() {
3000
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3001
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3000
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
3001
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
3002 3002
 	}
3003 3003
 
3004 3004
 	/**
3005 3005
      * Checks if the invoice needs payment.
3006 3006
      */
3007 3007
 	public function needs_payment() {
3008
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3009
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3008
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
3009
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
3010 3010
     }
3011 3011
   
3012 3012
 	/**
3013 3013
      * Checks if the invoice is refunded.
3014 3014
      */
3015 3015
 	public function is_refunded() {
3016
-        $is_refunded = $this->has_status( 'wpi-refunded' );
3017
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3016
+        $is_refunded = $this->has_status('wpi-refunded');
3017
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
3018 3018
 	}
3019 3019
 
3020 3020
 	/**
3021 3021
      * Checks if the invoice is held.
3022 3022
      */
3023 3023
 	public function is_held() {
3024
-        $is_held = $this->has_status( 'wpi-onhold' );
3025
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3024
+        $is_held = $this->has_status('wpi-onhold');
3025
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
3026 3026
 	}
3027 3027
 
3028 3028
 	/**
@@ -3030,30 +3030,30 @@  discard block
 block discarded – undo
3030 3030
      */
3031 3031
 	public function is_due() {
3032 3032
 		$due_date = $this->get_due_date();
3033
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3033
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3034 3034
 	}
3035 3035
 
3036 3036
 	/**
3037 3037
      * Checks if the invoice is draft.
3038 3038
      */
3039 3039
 	public function is_draft() {
3040
-        return $this->has_status( 'draft, auto-draft' );
3040
+        return $this->has_status('draft, auto-draft');
3041 3041
 	}
3042 3042
 
3043 3043
     /**
3044 3044
      * Checks if the invoice has a given status.
3045 3045
      */
3046
-    public function has_status( $status ) {
3047
-        $status = wpinv_parse_list( $status );
3048
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3046
+    public function has_status($status) {
3047
+        $status = wpinv_parse_list($status);
3048
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3049 3049
 	}
3050 3050
 
3051 3051
 	/**
3052 3052
      * Checks if the invoice is of a given type.
3053 3053
      */
3054
-    public function is_type( $type ) {
3055
-        $type = wpinv_parse_list( $type );
3056
-        return in_array( $this->get_type(), $type );
3054
+    public function is_type($type) {
3055
+        $type = wpinv_parse_list($type);
3056
+        return in_array($this->get_type(), $type);
3057 3057
     }
3058 3058
 
3059 3059
     /**
@@ -3085,8 +3085,8 @@  discard block
 block discarded – undo
3085 3085
      *
3086 3086
      */
3087 3087
 	public function is_initial_free() {
3088
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3089
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3088
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3089
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3090 3090
     }
3091 3091
 	
3092 3092
 	/**
@@ -3096,11 +3096,11 @@  discard block
 block discarded – undo
3096 3096
     public function item_has_free_trial() {
3097 3097
 
3098 3098
         // Ensure we have a recurring item.
3099
-        if ( ! $this->is_recurring() ) {
3099
+        if (!$this->is_recurring()) {
3100 3100
             return false;
3101 3101
         }
3102 3102
 
3103
-        $item = $this->get_recurring( true );
3103
+        $item = $this->get_recurring(true);
3104 3104
         return $item->has_free_trial();
3105 3105
 	}
3106 3106
 
@@ -3108,7 +3108,7 @@  discard block
 block discarded – undo
3108 3108
      * Check if the free trial is a result of a discount.
3109 3109
      */
3110 3110
     public function is_free_trial_from_discount() {
3111
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3111
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3112 3112
 	}
3113 3113
 	
3114 3114
 	/**
@@ -3116,12 +3116,12 @@  discard block
 block discarded – undo
3116 3116
      */
3117 3117
     public function discount_first_payment_only() {
3118 3118
 
3119
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3120
-        if ( ! $discount->exists() || ! $this->is_recurring() ) {
3119
+		$discount = wpinv_get_discount_obj($this->get_discount_code());
3120
+        if (!$discount->exists() || !$this->is_recurring()) {
3121 3121
             return true;
3122 3122
         }
3123 3123
 
3124
-        return ! $discount->get_is_recurring();
3124
+        return !$discount->get_is_recurring();
3125 3125
     }
3126 3126
 
3127 3127
     /*
@@ -3139,27 +3139,27 @@  discard block
 block discarded – undo
3139 3139
      * @param GetPaid_Form_Item|array $item
3140 3140
      * @return WP_Error|Bool
3141 3141
      */
3142
-    public function add_item( $item ) {
3142
+    public function add_item($item) {
3143 3143
 
3144
-		if ( is_array( $item ) ) {
3145
-			$item = $this->process_array_item( $item );
3144
+		if (is_array($item)) {
3145
+			$item = $this->process_array_item($item);
3146 3146
 		}
3147 3147
 
3148
-		if ( is_numeric( $item ) ) {
3149
-			$item = new GetPaid_Form_Item( $item );
3148
+		if (is_numeric($item)) {
3149
+			$item = new GetPaid_Form_Item($item);
3150 3150
 		}
3151 3151
 
3152 3152
         // Make sure that it is available for purchase.
3153
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3154
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3153
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3154
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3155 3155
         }
3156 3156
 
3157 3157
         // Do we have a recurring item?
3158
-		if ( $item->is_recurring() ) {
3158
+		if ($item->is_recurring()) {
3159 3159
 
3160 3160
 			// An invoice can only contain one recurring item.
3161
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3162
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3161
+			if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) {
3162
+				return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing'));
3163 3163
 			}
3164 3164
 
3165 3165
 			$this->recurring_item = $item->get_id();
@@ -3170,9 +3170,9 @@  discard block
 block discarded – undo
3170 3170
 
3171 3171
         // Retrieve all items.
3172 3172
         $items = $this->get_items();
3173
-        $items[ (int) $item->get_id() ] = $item;
3173
+        $items[(int) $item->get_id()] = $item;
3174 3174
 
3175
-        $this->set_prop( 'items', $items );
3175
+        $this->set_prop('items', $items);
3176 3176
 		return true;
3177 3177
 	}
3178 3178
 
@@ -3182,26 +3182,26 @@  discard block
 block discarded – undo
3182 3182
 	 * @since 1.0.19
3183 3183
 	 * @return GetPaid_Form_Item
3184 3184
 	 */
3185
-	protected function process_array_item( $array ) {
3185
+	protected function process_array_item($array) {
3186 3186
 
3187
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3188
-		$item    = new GetPaid_Form_Item( $item_id );
3187
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3188
+		$item    = new GetPaid_Form_Item($item_id);
3189 3189
 
3190 3190
 		// Set item data.
3191
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3192
-			if ( isset( $array[ "item_$key" ] ) ) {
3191
+		foreach (array('name', 'price', 'description') as $key) {
3192
+			if (isset($array["item_$key"])) {
3193 3193
 				$method = "set_$key";
3194
-				$item->$method( $array[ "item_$key" ] );
3194
+				$item->$method($array["item_$key"]);
3195 3195
 			}
3196 3196
 		}
3197 3197
 
3198
-		if ( isset( $array['quantity'] ) ) {
3199
-			$item->set_quantity( $array['quantity'] );
3198
+		if (isset($array['quantity'])) {
3199
+			$item->set_quantity($array['quantity']);
3200 3200
 		}
3201 3201
 
3202 3202
 		// Set item meta.
3203
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3204
-			$item->set_item_meta( $array['meta'] );
3203
+		if (isset($array['meta']) && is_array($array['meta'])) {
3204
+			$item->set_item_meta($array['meta']);
3205 3205
 		}
3206 3206
 
3207 3207
 		return $item;
@@ -3213,10 +3213,10 @@  discard block
 block discarded – undo
3213 3213
 	 *
3214 3214
 	 * @since 1.0.19
3215 3215
 	 */
3216
-	public function get_item( $item_id ) {
3216
+	public function get_item($item_id) {
3217 3217
 		$items   = $this->get_items();
3218 3218
 		$item_id = (int) $item_id;
3219
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3219
+		return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null;
3220 3220
     }
3221 3221
 
3222 3222
     /**
@@ -3224,17 +3224,17 @@  discard block
 block discarded – undo
3224 3224
 	 *
3225 3225
 	 * @since 1.0.19
3226 3226
 	 */
3227
-	public function remove_item( $item_id ) {
3227
+	public function remove_item($item_id) {
3228 3228
 		$items   = $this->get_items();
3229 3229
 		$item_id = (int) $item_id;
3230 3230
 
3231
-        if ( $item_id == $this->recurring_item ) {
3231
+        if ($item_id == $this->recurring_item) {
3232 3232
             $this->recurring_item = null;
3233 3233
         }
3234 3234
 
3235
-        if ( isset( $items[ $item_id ] ) ) {
3236
-            unset( $items[ $item_id ] );
3237
-            $this->set_prop( 'items', $items );
3235
+        if (isset($items[$item_id])) {
3236
+            unset($items[$item_id]);
3237
+            $this->set_prop('items', $items);
3238 3238
         }
3239 3239
     }
3240 3240
 
@@ -3244,11 +3244,11 @@  discard block
 block discarded – undo
3244 3244
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3245 3245
 	 * @since 1.0.19
3246 3246
 	 */
3247
-    public function add_fee( $fee ) {
3247
+    public function add_fee($fee) {
3248 3248
 
3249 3249
 		$fees                 = $this->get_fees();
3250
-		$fees[ $fee['name'] ] = $fee;
3251
-		$this->set_prop( 'fees', $fees );
3250
+		$fees[$fee['name']] = $fee;
3251
+		$this->set_prop('fees', $fees);
3252 3252
 
3253 3253
     }
3254 3254
 
@@ -3257,9 +3257,9 @@  discard block
 block discarded – undo
3257 3257
 	 *
3258 3258
 	 * @since 1.0.19
3259 3259
 	 */
3260
-	public function get_fee( $fee ) {
3260
+	public function get_fee($fee) {
3261 3261
         $fees = $this->get_fees();
3262
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3262
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3263 3263
     }
3264 3264
 
3265 3265
     /**
@@ -3267,11 +3267,11 @@  discard block
 block discarded – undo
3267 3267
 	 *
3268 3268
 	 * @since 1.0.19
3269 3269
 	 */
3270
-	public function remove_fee( $fee ) {
3270
+	public function remove_fee($fee) {
3271 3271
         $fees = $this->get_fees();
3272
-        if ( isset( $fees[ $fee ] ) ) {
3273
-            unset( $fees[ $fee ] );
3274
-            $this->set_prop( 'fees', $fees );
3272
+        if (isset($fees[$fee])) {
3273
+            unset($fees[$fee]);
3274
+            $this->set_prop('fees', $fees);
3275 3275
         }
3276 3276
     }
3277 3277
 
@@ -3281,11 +3281,11 @@  discard block
 block discarded – undo
3281 3281
 	 * @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.
3282 3282
 	 * @since 1.0.19
3283 3283
 	 */
3284
-	public function add_discount( $discount ) {
3284
+	public function add_discount($discount) {
3285 3285
 
3286 3286
 		$discounts = $this->get_discounts();
3287
-		$discounts[ $discount['name'] ] = $discount;
3288
-		$this->set_prop( 'discounts', $discounts );
3287
+		$discounts[$discount['name']] = $discount;
3288
+		$this->set_prop('discounts', $discounts);
3289 3289
 
3290 3290
 	}
3291 3291
 
@@ -3295,15 +3295,15 @@  discard block
 block discarded – undo
3295 3295
 	 * @since 1.0.19
3296 3296
 	 * @return float
3297 3297
 	 */
3298
-	public function get_discount( $discount = false ) {
3298
+	public function get_discount($discount = false) {
3299 3299
 
3300 3300
 		// Backwards compatibilty.
3301
-		if ( empty( $discount ) ) {
3301
+		if (empty($discount)) {
3302 3302
 			return $this->get_total_discount();
3303 3303
 		}
3304 3304
 
3305 3305
         $discounts = $this->get_discounts();
3306
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3306
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3307 3307
     }
3308 3308
 
3309 3309
     /**
@@ -3311,11 +3311,11 @@  discard block
 block discarded – undo
3311 3311
 	 *
3312 3312
 	 * @since 1.0.19
3313 3313
 	 */
3314
-	public function remove_discount( $discount ) {
3314
+	public function remove_discount($discount) {
3315 3315
         $discounts = $this->get_discounts();
3316
-        if ( isset( $discounts[ $discount ] ) ) {
3317
-            unset( $discounts[ $discount ] );
3318
-            $this->set_prop( 'discounts', $discounts );
3316
+        if (isset($discounts[$discount])) {
3317
+            unset($discounts[$discount]);
3318
+            $this->set_prop('discounts', $discounts);
3319 3319
         }
3320 3320
     }
3321 3321
 
@@ -3324,12 +3324,12 @@  discard block
 block discarded – undo
3324 3324
      *
3325 3325
      * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
3326 3326
      */
3327
-    public function add_tax( $tax ) {
3328
-        if ( $this->is_taxable() ) {
3327
+    public function add_tax($tax) {
3328
+        if ($this->is_taxable()) {
3329 3329
 
3330
-            $taxes                 = $this->get_taxes();
3331
-			$taxes[ $tax['name'] ] = $tax;
3332
-			$this->set_prop( 'taxes', $tax );
3330
+            $taxes = $this->get_taxes();
3331
+			$taxes[$tax['name']] = $tax;
3332
+			$this->set_prop('taxes', $tax);
3333 3333
 
3334 3334
         }
3335 3335
     }
@@ -3339,15 +3339,15 @@  discard block
 block discarded – undo
3339 3339
 	 *
3340 3340
 	 * @since 1.0.19
3341 3341
 	 */
3342
-	public function get_tax( $tax = null ) {
3342
+	public function get_tax($tax = null) {
3343 3343
 
3344 3344
 		// Backwards compatility.
3345
-		if ( empty( $tax ) ) {
3345
+		if (empty($tax)) {
3346 3346
 			return $this->get_total_tax();
3347 3347
 		}
3348 3348
 
3349 3349
         $taxes = $this->get_taxes();
3350
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3350
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3351 3351
     }
3352 3352
 
3353 3353
     /**
@@ -3355,11 +3355,11 @@  discard block
 block discarded – undo
3355 3355
 	 *
3356 3356
 	 * @since 1.0.19
3357 3357
 	 */
3358
-	public function remove_tax( $tax ) {
3358
+	public function remove_tax($tax) {
3359 3359
         $taxes = $this->get_taxes();
3360
-        if ( isset( $taxes[ $tax ] ) ) {
3361
-            unset( $taxes[ $tax ] );
3362
-            $this->set_prop( 'taxes', $taxes );
3360
+        if (isset($taxes[$tax])) {
3361
+            unset($taxes[$tax]);
3362
+            $this->set_prop('taxes', $taxes);
3363 3363
         }
3364 3364
     }
3365 3365
 
@@ -3370,17 +3370,17 @@  discard block
 block discarded – undo
3370 3370
 	 * @return float The recalculated subtotal
3371 3371
 	 */
3372 3372
 	public function recalculate_subtotal() {
3373
-        $items     = $this->get_items();
3373
+        $items = $this->get_items();
3374 3374
 		$subtotal  = 0;
3375 3375
 		$recurring = 0;
3376 3376
 
3377
-        foreach ( $items as $item ) {
3377
+        foreach ($items as $item) {
3378 3378
 			$subtotal  += $item->get_sub_total();
3379 3379
 			$recurring += $item->get_recurring_sub_total();
3380 3380
         }
3381 3381
 
3382 3382
 		$current = $this->is_renewal() ? $recurring : $subtotal;
3383
-		$this->set_subtotal( $current );
3383
+		$this->set_subtotal($current);
3384 3384
 
3385 3385
 		$this->totals['subtotal'] = array(
3386 3386
 			'initial'   => $subtotal,
@@ -3401,14 +3401,14 @@  discard block
 block discarded – undo
3401 3401
 		$discount  = 0;
3402 3402
 		$recurring = 0;
3403 3403
 
3404
-        foreach ( $discounts as $data ) {
3405
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3406
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3404
+        foreach ($discounts as $data) {
3405
+			$discount  += wpinv_sanitize_amount($data['initial_discount']);
3406
+			$recurring += wpinv_sanitize_amount($data['recurring_discount']);
3407 3407
 		}
3408 3408
 
3409 3409
 		$current = $this->is_renewal() ? $recurring : $discount;
3410 3410
 
3411
-		$this->set_total_discount( $current );
3411
+		$this->set_total_discount($current);
3412 3412
 
3413 3413
 		$this->totals['discount'] = array(
3414 3414
 			'initial'   => $discount,
@@ -3426,17 +3426,17 @@  discard block
 block discarded – undo
3426 3426
 	 * @return float The recalculated tax
3427 3427
 	 */
3428 3428
 	public function recalculate_total_tax() {
3429
-        $taxes     = $this->get_taxes();
3429
+        $taxes = $this->get_taxes();
3430 3430
 		$tax       = 0;
3431 3431
 		$recurring = 0;
3432 3432
 
3433
-        foreach ( $taxes as $data ) {
3434
-			$tax       += wpinv_sanitize_amount( $data['initial_tax'] );
3435
-			$recurring += wpinv_sanitize_amount( $data['recurring_tax'] );
3433
+        foreach ($taxes as $data) {
3434
+			$tax       += wpinv_sanitize_amount($data['initial_tax']);
3435
+			$recurring += wpinv_sanitize_amount($data['recurring_tax']);
3436 3436
 		}
3437 3437
 
3438 3438
 		$current = $this->is_renewal() ? $recurring : $tax;
3439
-		$this->set_total_tax( $current );
3439
+		$this->set_total_tax($current);
3440 3440
 
3441 3441
 		$this->totals['tax'] = array(
3442 3442
 			'initial'   => $tax,
@@ -3458,20 +3458,20 @@  discard block
 block discarded – undo
3458 3458
 		$fee       = 0;
3459 3459
 		$recurring = 0;
3460 3460
 
3461
-        foreach ( $fees as $data ) {
3462
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3463
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3461
+        foreach ($fees as $data) {
3462
+			$fee       += wpinv_sanitize_amount($data['initial_fee']);
3463
+			$recurring += wpinv_sanitize_amount($data['recurring_fee']);
3464 3464
 		}
3465 3465
 
3466 3466
 		$current = $this->is_renewal() ? $recurring : $fee;
3467
-		$this->set_total_fees( $current );
3467
+		$this->set_total_fees($current);
3468 3468
 
3469 3469
 		$this->totals['fee'] = array(
3470 3470
 			'initial'   => $fee,
3471 3471
 			'recurring' => $recurring,
3472 3472
 		);
3473 3473
 
3474
-        $this->set_total_fees( $fee );
3474
+        $this->set_total_fees($fee);
3475 3475
         return $current;
3476 3476
     }
3477 3477
 
@@ -3494,7 +3494,7 @@  discard block
 block discarded – undo
3494 3494
 	 */
3495 3495
     public function recalculate_totals() {
3496 3496
         $this->recalculate_total();
3497
-        $this->save( true );
3497
+        $this->save(true);
3498 3498
         return $this;
3499 3499
     }
3500 3500
 
@@ -3512,10 +3512,10 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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'], $this ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3581
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from'], $this), wpinv_status_nicename($status_transition['to'], $this));
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 ), false, $status_transition['manual'] );
3591
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $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'], $this  ) );
3610
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this));
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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_title() . empty( $note ) ? '' : " ($note)"
3726
+				__('Paid via %s', 'invoicing'),
3727
+				$this->get_gateway_title() . 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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.