Passed
Push — master ( 68e600...883b53 )
by Brian
04:15
created
includes/libraries/wpinv-euvat/class-wpinv-euvat.php 1 patch
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -80,29 +80,29 @@
 block discarded – undo
80 80
     public static function vat_rates_settings() {}
81 81
 
82 82
     /**
83
-	 *
84
-	 * @deprecated
85
-	 */
83
+     *
84
+     * @deprecated
85
+     */
86 86
     public static function vat_settings() {}
87 87
 
88 88
     /**
89
-	 *
90
-	 * @deprecated
91
-	 */
89
+     *
90
+     * @deprecated
91
+     */
92 92
     public static function maxmind_folder() {
93 93
         return false;
94 94
     }
95 95
 
96 96
     /**
97
-	 *
98
-	 * @deprecated
99
-	 */
97
+     *
98
+     * @deprecated
99
+     */
100 100
     public static function geoip2_download_database() {}
101 101
 
102 102
     /**
103
-	 *
104
-	 * @deprecated
105
-	 */
103
+     *
104
+     * @deprecated
105
+     */
106 106
     public static function geoip2_download_file() {}
107 107
 
108 108
     /**
Please login to merge, or discard this patch.
includes/admin/register-settings.php 1 patch
Indentation   +310 added lines, -310 removed lines patch added patch discarded remove patch
@@ -196,11 +196,11 @@  discard block
 block discarded – undo
196 196
     $cb      = "wpinv_{$option['type']}_callback";
197 197
     $section = "wpinv_settings_{$tab}_$section";
198 198
 
199
-	if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
-		$tip   = esc_attr( $option['desc'] );
201
-		$name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
-		unset( $option['desc'] );
203
-	}
199
+    if ( isset( $option['desc'] ) && ! empty( $option['help-tip'] ) ) {
200
+        $tip   = esc_attr( $option['desc'] );
201
+        $name .= "<span class='dashicons dashicons-editor-help wpi-help-tip' title='$tip'></span>";
202
+        unset( $option['desc'] );
203
+    }
204 204
 
205 205
     // Loop through all tabs.
206 206
     add_settings_field(
@@ -279,10 +279,10 @@  discard block
 block discarded – undo
279 279
         }
280 280
 
281 281
         // General filter
282
-		$input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
282
+        $input[ $key ] = apply_filters( 'wpinv_settings_sanitize', $input[ $key ], $key );
283 283
 
284
-		// Key specific filter.
285
-		$input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
284
+        // Key specific filter.
285
+        $input[ $key ] = apply_filters( "wpinv_settings_sanitize_$key", $input[ $key ] );
286 286
     }
287 287
 
288 288
     // Loop through the whitelist and unset any that are empty for the tab being saved
@@ -338,14 +338,14 @@  discard block
 block discarded – undo
338 338
 
339 339
     foreach ( $new_rates as $rate ) {
340 340
 
341
-		$rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
342
-		$rate['name']    = sanitize_text_field( $rate['name'] );
343
-		$rate['state']   = sanitize_text_field( $rate['state'] );
344
-		$rate['country'] = sanitize_text_field( $rate['country'] );
345
-		$rate['global']  = empty( $rate['state'] );
346
-		$tax_rates[]     = $rate;
341
+        $rate['rate']    = wpinv_sanitize_amount( $rate['rate'] );
342
+        $rate['name']    = sanitize_text_field( $rate['name'] );
343
+        $rate['state']   = sanitize_text_field( $rate['state'] );
344
+        $rate['country'] = sanitize_text_field( $rate['country'] );
345
+        $rate['global']  = empty( $rate['state'] );
346
+        $tax_rates[]     = $rate;
347 347
 
348
-	}
348
+    }
349 349
 
350 350
     update_option( 'wpinv_tax_rates', $tax_rates );
351 351
 
@@ -402,8 +402,8 @@  discard block
 block discarded – undo
402 402
         ) ),
403 403
         'taxes' => apply_filters( 'wpinv_settings_sections_taxes', array(
404 404
             'main'  => __( 'Tax Settings', 'invoicing' ),
405
-			'rates' => __( 'Tax Rates', 'invoicing' ),
406
-			'vat'   => __( 'EU VAT Settings', 'invoicing' )
405
+            'rates' => __( 'Tax Rates', 'invoicing' ),
406
+            'vat'   => __( 'EU VAT Settings', 'invoicing' )
407 407
         ) ),
408 408
         'emails' => apply_filters( 'wpinv_settings_sections_emails', array(
409 409
             'main' => __( 'Email Settings', 'invoicing' ),
@@ -426,51 +426,51 @@  discard block
 block discarded – undo
426 426
 }
427 427
 
428 428
 function wpinv_get_pages( $with_slug = false, $default_label = NULL ) {
429
-	$pages_options = array();
429
+    $pages_options = array();
430 430
 
431
-	if( $default_label !== NULL && $default_label !== false ) {
432
-		$pages_options = array( '' => $default_label ); // Blank option
433
-	}
431
+    if( $default_label !== NULL && $default_label !== false ) {
432
+        $pages_options = array( '' => $default_label ); // Blank option
433
+    }
434 434
 
435
-	$pages = get_pages();
436
-	if ( $pages ) {
437
-		foreach ( $pages as $page ) {
438
-			$title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
435
+    $pages = get_pages();
436
+    if ( $pages ) {
437
+        foreach ( $pages as $page ) {
438
+            $title = $with_slug ? $page->post_title . ' (' . $page->post_name . ')' : $page->post_title;
439 439
             $pages_options[ $page->ID ] = $title;
440
-		}
441
-	}
440
+        }
441
+    }
442 442
 
443
-	return $pages_options;
443
+    return $pages_options;
444 444
 }
445 445
 
446 446
 function wpinv_header_callback( $args ) {
447
-	if ( !empty( $args['desc'] ) ) {
447
+    if ( !empty( $args['desc'] ) ) {
448 448
         echo $args['desc'];
449 449
     }
450 450
 }
451 451
 
452 452
 function wpinv_hidden_callback( $args ) {
453
-	global $wpinv_options;
454
-
455
-	if ( isset( $args['set_value'] ) ) {
456
-		$value = $args['set_value'];
457
-	} elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
458
-		$value = $wpinv_options[ $args['id'] ];
459
-	} else {
460
-		$value = isset( $args['std'] ) ? $args['std'] : '';
461
-	}
462
-
463
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
464
-		$args['readonly'] = true;
465
-		$value = isset( $args['std'] ) ? $args['std'] : '';
466
-		$name  = '';
467
-	} else {
468
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
469
-	}
470
-
471
-	$html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
453
+    global $wpinv_options;
454
+
455
+    if ( isset( $args['set_value'] ) ) {
456
+        $value = $args['set_value'];
457
+    } elseif ( isset( $wpinv_options[ $args['id'] ] ) ) {
458
+        $value = $wpinv_options[ $args['id'] ];
459
+    } else {
460
+        $value = isset( $args['std'] ) ? $args['std'] : '';
461
+    }
462
+
463
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
464
+        $args['readonly'] = true;
465
+        $value = isset( $args['std'] ) ? $args['std'] : '';
466
+        $name  = '';
467
+    } else {
468
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
469
+    }
470
+
471
+    $html = '<input type="hidden" id="wpinv_settings[' . wpinv_sanitize_key( $args['id'] ) . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '" />';
472 472
     
473
-	echo $html;
473
+    echo $html;
474 474
 }
475 475
 
476 476
 /**
@@ -478,12 +478,12 @@  discard block
 block discarded – undo
478 478
  */
479 479
 function wpinv_checkbox_callback( $args ) {
480 480
 
481
-	$std = isset( $args['std'] ) ? $args['std'] : '';
482
-	$std = wpinv_get_option( $args['id'], $std );
483
-	$id  = esc_attr( $args['id'] );
481
+    $std = isset( $args['std'] ) ? $args['std'] : '';
482
+    $std = wpinv_get_option( $args['id'], $std );
483
+    $id  = esc_attr( $args['id'] );
484 484
 
485
-	getpaid_hidden_field( "wpinv_settings[$id]", '0' );
486
-	?>
485
+    getpaid_hidden_field( "wpinv_settings[$id]", '0' );
486
+    ?>
487 487
 		<fieldset>
488 488
 			<label>
489 489
 				<input id="wpinv-settings-<?php echo $id; ?>" name="wpinv_settings[<?php echo $id; ?>]" <?php checked( empty( $std ), false ); ?> value="1" type="checkbox">
@@ -495,77 +495,77 @@  discard block
 block discarded – undo
495 495
 
496 496
 function wpinv_multicheck_callback( $args ) {
497 497
 	
498
-	global $wpinv_options;
498
+    global $wpinv_options;
499 499
 
500
-	$sanitize_id = wpinv_sanitize_key( $args['id'] );
501
-	$class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
500
+    $sanitize_id = wpinv_sanitize_key( $args['id'] );
501
+    $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
502 502
 
503
-	if ( ! empty( $args['options'] ) ) {
503
+    if ( ! empty( $args['options'] ) ) {
504 504
 
505
-		$std     = isset( $args['std'] ) ? $args['std'] : array();
506
-		$value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
505
+        $std     = isset( $args['std'] ) ? $args['std'] : array();
506
+        $value   = isset( $wpinv_options[ $args['id'] ] ) ? $wpinv_options[ $args['id'] ] : $std;
507 507
 
508
-		echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
508
+        echo '<div class="wpi-mcheck-rows wpi-mcheck-' . $sanitize_id . $class . '">';
509 509
         foreach( $args['options'] as $key => $option ):
510
-			$sanitize_key = wpinv_sanitize_key( $key );
511
-			if ( in_array( $sanitize_key, $value ) ) { 
512
-				$enabled = $sanitize_key;
513
-			} else { 
514
-				$enabled = NULL; 
515
-			}
516
-			echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
517
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
518
-		endforeach;
519
-		echo '</div>';
520
-		echo '<p class="description">' . $args['desc'] . '</p>';
521
-	}
510
+            $sanitize_key = wpinv_sanitize_key( $key );
511
+            if ( in_array( $sanitize_key, $value ) ) { 
512
+                $enabled = $sanitize_key;
513
+            } else { 
514
+                $enabled = NULL; 
515
+            }
516
+            echo '<div class="wpi-mcheck-row"><input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $sanitize_key ) . '" ' . checked( $sanitize_key, $enabled, false ) . '/>&nbsp;';
517
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . wp_kses_post( $option ) . '</label></div>';
518
+        endforeach;
519
+        echo '</div>';
520
+        echo '<p class="description">' . $args['desc'] . '</p>';
521
+    }
522 522
 }
523 523
 
524 524
 function wpinv_payment_icons_callback( $args ) {
525
-	global $wpinv_options;
525
+    global $wpinv_options;
526 526
     
527 527
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
528 528
 
529
-	if ( ! empty( $args['options'] ) ) {
530
-		foreach( $args['options'] as $key => $option ) {
529
+    if ( ! empty( $args['options'] ) ) {
530
+        foreach( $args['options'] as $key => $option ) {
531 531
             $sanitize_key = wpinv_sanitize_key( $key );
532 532
             
533
-			if( isset( $wpinv_options[$args['id']][$key] ) ) {
534
-				$enabled = $option;
535
-			} else {
536
-				$enabled = NULL;
537
-			}
538
-
539
-			echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
540
-
541
-				echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
542
-
543
-				if ( wpinv_string_is_image_url( $key ) ) {
544
-					echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
545
-				} else {
546
-					$card = strtolower( str_replace( ' ', '', $option ) );
547
-
548
-					if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
549
-						$image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
550
-					} else {
551
-						$image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
552
-						$content_dir = WP_CONTENT_DIR;
553
-
554
-						if ( function_exists( 'wp_normalize_path' ) ) {
555
-							// Replaces backslashes with forward slashes for Windows systems
556
-							$image = wp_normalize_path( $image );
557
-							$content_dir = wp_normalize_path( $content_dir );
558
-						}
559
-
560
-						$image = str_replace( $content_dir, content_url(), $image );
561
-					}
562
-
563
-					echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
564
-				}
565
-			echo $option . '</label>';
566
-		}
567
-		echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
568
-	}
533
+            if( isset( $wpinv_options[$args['id']][$key] ) ) {
534
+                $enabled = $option;
535
+            } else {
536
+                $enabled = NULL;
537
+            }
538
+
539
+            echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" style="margin-right:10px;line-height:16px;height:16px;display:inline-block;">';
540
+
541
+                echo '<input name="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="' . esc_attr( $option ) . '" ' . checked( $option, $enabled, false ) . '/>&nbsp;';
542
+
543
+                if ( wpinv_string_is_image_url( $key ) ) {
544
+                    echo '<img class="payment-icon" src="' . esc_url( $key ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
545
+                } else {
546
+                    $card = strtolower( str_replace( ' ', '', $option ) );
547
+
548
+                    if ( has_filter( 'wpinv_accepted_payment_' . $card . '_image' ) ) {
549
+                        $image = apply_filters( 'wpinv_accepted_payment_' . $card . '_image', '' );
550
+                    } else {
551
+                        $image       = wpinv_locate_template( 'images' . DIRECTORY_SEPARATOR . 'icons' . DIRECTORY_SEPARATOR . $card . '.gif', false );
552
+                        $content_dir = WP_CONTENT_DIR;
553
+
554
+                        if ( function_exists( 'wp_normalize_path' ) ) {
555
+                            // Replaces backslashes with forward slashes for Windows systems
556
+                            $image = wp_normalize_path( $image );
557
+                            $content_dir = wp_normalize_path( $content_dir );
558
+                        }
559
+
560
+                        $image = str_replace( $content_dir, content_url(), $image );
561
+                    }
562
+
563
+                    echo '<img class="payment-icon" src="' . esc_url( $image ) . '" style="width:32px;height:24px;position:relative;top:6px;margin-right:5px;"/>';
564
+                }
565
+            echo $option . '</label>';
566
+        }
567
+        echo '<p class="description" style="margin-top:16px;">' . wp_kses_post( $args['desc'] ) . '</p>';
568
+    }
569 569
 }
570 570
 
571 571
 /**
@@ -573,9 +573,9 @@  discard block
 block discarded – undo
573 573
  */
574 574
 function wpinv_radio_callback( $args ) {
575 575
 
576
-	$std = isset( $args['std'] ) ? $args['std'] : '';
577
-	$std = wpinv_get_option( $args['id'], $std );
578
-	?>
576
+    $std = isset( $args['std'] ) ? $args['std'] : '';
577
+    $std = wpinv_get_option( $args['id'], $std );
578
+    ?>
579 579
 		<fieldset>
580 580
 			<ul id="wpinv-settings-<?php echo esc_attr( $args['id'] ); ?>" style="margin-top: 0;">
581 581
 				<?php foreach( $args['options'] as $key => $option ) : ?>
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
 			</ul>
590 590
 		</fieldset>
591 591
 	<?php
592
-	getpaid_settings_description_callback( $args );
592
+    getpaid_settings_description_callback( $args );
593 593
 }
594 594
 
595 595
 /**
@@ -597,176 +597,176 @@  discard block
 block discarded – undo
597 597
  */
598 598
 function getpaid_settings_description_callback( $args ) {
599 599
 
600
-	if ( ! empty( $args['desc'] ) ) {
601
-		$description = wp_kses_post( $args['desc'] );
602
-		echo "<p class='description'>$description</p>";
603
-	}
600
+    if ( ! empty( $args['desc'] ) ) {
601
+        $description = wp_kses_post( $args['desc'] );
602
+        echo "<p class='description'>$description</p>";
603
+    }
604 604
 
605 605
 }
606 606
 
607 607
 function wpinv_gateways_callback( $args ) {
608
-	global $wpinv_options;
608
+    global $wpinv_options;
609 609
     
610 610
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
611 611
 
612
-	foreach ( $args['options'] as $key => $option ) :
613
-		$sanitize_key = wpinv_sanitize_key( $key );
612
+    foreach ( $args['options'] as $key => $option ) :
613
+        $sanitize_key = wpinv_sanitize_key( $key );
614 614
         
615 615
         if ( isset( $wpinv_options['gateways'][ $key ] ) )
616
-			$enabled = '1';
617
-		else
618
-			$enabled = null;
616
+            $enabled = '1';
617
+        else
618
+            $enabled = null;
619 619
 
620
-		echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
621
-		echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
622
-	endforeach;
620
+        echo '<input name="wpinv_settings[' . esc_attr( $args['id'] ) . '][' . $sanitize_key . ']" id="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']" type="checkbox" value="1" ' . checked('1', $enabled, false) . '/>&nbsp;';
621
+        echo '<label for="wpinv_settings[' . $sanitize_id . '][' . $sanitize_key . ']">' . esc_html( $option['admin_label'] ) . '</label><br/>';
622
+    endforeach;
623 623
 }
624 624
 
625 625
 function wpinv_gateway_select_callback($args) {
626
-	global $wpinv_options;
626
+    global $wpinv_options;
627 627
     
628 628
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
629 629
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
630 630
 
631
-	echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
631
+    echo '<select name="wpinv_settings[' . $sanitize_id . ']"" id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'" >';
632 632
 
633
-	foreach ( $args['options'] as $key => $option ) :
634
-		if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
633
+    foreach ( $args['options'] as $key => $option ) :
634
+        if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
635 635
             $selected = selected( $key, $args['selected'], false );
636 636
         } else {
637 637
             $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $key, $wpinv_options[$args['id']], false ) : '';
638 638
         }
639
-		echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
640
-	endforeach;
639
+        echo '<option value="' . wpinv_sanitize_key( $key ) . '"' . $selected . '>' . esc_html( $option['admin_label'] ) . '</option>';
640
+    endforeach;
641 641
 
642
-	echo '</select>';
643
-	echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
642
+    echo '</select>';
643
+    echo '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
644 644
 }
645 645
 
646 646
 function wpinv_text_callback( $args ) {
647
-	global $wpinv_options;
647
+    global $wpinv_options;
648 648
     
649 649
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
650 650
 
651
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
652
-		$value = $wpinv_options[ $args['id'] ];
653
-	} else {
654
-		$value = isset( $args['std'] ) ? $args['std'] : '';
655
-	}
656
-
657
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
658
-		$args['readonly'] = true;
659
-		$value = isset( $args['std'] ) ? $args['std'] : '';
660
-		$name  = '';
661
-	} else {
662
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
663
-	}
664
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
665
-
666
-	$readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
667
-	$size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
668
-	$html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
669
-	$html    .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
670
-
671
-	echo $html;
651
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
652
+        $value = $wpinv_options[ $args['id'] ];
653
+    } else {
654
+        $value = isset( $args['std'] ) ? $args['std'] : '';
655
+    }
656
+
657
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
658
+        $args['readonly'] = true;
659
+        $value = isset( $args['std'] ) ? $args['std'] : '';
660
+        $name  = '';
661
+    } else {
662
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
663
+    }
664
+    $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
665
+
666
+    $readonly = $args['readonly'] === true ? ' readonly="readonly"' : '';
667
+    $size     = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
668
+    $html     = '<input type="text" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"' . $readonly . '/>';
669
+    $html    .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
670
+
671
+    echo $html;
672 672
 }
673 673
 
674 674
 function wpinv_number_callback( $args ) {
675
-	global $wpinv_options;
675
+    global $wpinv_options;
676 676
     
677 677
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
678 678
 
679
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
680
-		$value = $wpinv_options[ $args['id'] ];
681
-	} else {
682
-		$value = isset( $args['std'] ) ? $args['std'] : '';
683
-	}
684
-
685
-	if ( isset( $args['faux'] ) && true === $args['faux'] ) {
686
-		$args['readonly'] = true;
687
-		$value = isset( $args['std'] ) ? $args['std'] : '';
688
-		$name  = '';
689
-	} else {
690
-		$name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
691
-	}
692
-
693
-	$max  = isset( $args['max'] ) ? $args['max'] : 999999;
694
-	$min  = isset( $args['min'] ) ? $args['min'] : 0;
695
-	$step = isset( $args['step'] ) ? $args['step'] : 1;
696
-	$class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
697
-
698
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
699
-	$html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
700
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
701
-
702
-	echo $html;
679
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
680
+        $value = $wpinv_options[ $args['id'] ];
681
+    } else {
682
+        $value = isset( $args['std'] ) ? $args['std'] : '';
683
+    }
684
+
685
+    if ( isset( $args['faux'] ) && true === $args['faux'] ) {
686
+        $args['readonly'] = true;
687
+        $value = isset( $args['std'] ) ? $args['std'] : '';
688
+        $name  = '';
689
+    } else {
690
+        $name = 'name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"';
691
+    }
692
+
693
+    $max  = isset( $args['max'] ) ? $args['max'] : 999999;
694
+    $min  = isset( $args['min'] ) ? $args['min'] : 0;
695
+    $step = isset( $args['step'] ) ? $args['step'] : 1;
696
+    $class = !empty( $args['class'] ) ? sanitize_html_class( $args['class'] ) : '';
697
+
698
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
699
+    $html = '<input type="number" step="' . esc_attr( $step ) . '" max="' . esc_attr( $max ) . '" min="' . esc_attr( $min ) . '" class="' . sanitize_html_class( $size ) . '-text ' . $class . '" id="wpinv_settings[' . $sanitize_id . ']" ' . $name . ' value="' . esc_attr( stripslashes( $value ) ) . '"/>';
700
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
701
+
702
+    echo $html;
703 703
 }
704 704
 
705 705
 function wpinv_textarea_callback( $args ) {
706
-	global $wpinv_options;
706
+    global $wpinv_options;
707 707
     
708 708
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
709 709
 
710
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
711
-		$value = $wpinv_options[ $args['id'] ];
712
-	} else {
713
-		$value = isset( $args['std'] ) ? $args['std'] : '';
714
-	}
710
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
711
+        $value = $wpinv_options[ $args['id'] ];
712
+    } else {
713
+        $value = isset( $args['std'] ) ? $args['std'] : '';
714
+    }
715 715
     
716 716
     $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
717 717
     $class = ( isset( $args['class'] ) && ! is_null( $args['class'] ) ) ? $args['class'] : 'large-text';
718 718
 
719
-	$html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
720
-	$html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
719
+    $html = '<textarea class="' . sanitize_html_class( $class ) . ' txtarea-' . sanitize_html_class( $size ) . ' wpi-' . esc_attr( sanitize_html_class( $sanitize_id ) ) . ' " cols="' . $args['cols'] . '" rows="' . $args['rows'] . '" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
720
+    $html .= '<br /><label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
721 721
 
722
-	echo $html;
722
+    echo $html;
723 723
 }
724 724
 
725 725
 function wpinv_password_callback( $args ) {
726
-	global $wpinv_options;
726
+    global $wpinv_options;
727 727
     
728 728
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
729 729
 
730
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
731
-		$value = $wpinv_options[ $args['id'] ];
732
-	} else {
733
-		$value = isset( $args['std'] ) ? $args['std'] : '';
734
-	}
730
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
731
+        $value = $wpinv_options[ $args['id'] ];
732
+    } else {
733
+        $value = isset( $args['std'] ) ? $args['std'] : '';
734
+    }
735 735
 
736
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
737
-	$html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
738
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
736
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
737
+    $html = '<input type="password" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '"/>';
738
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
739 739
 
740
-	echo $html;
740
+    echo $html;
741 741
 }
742 742
 
743 743
 function wpinv_missing_callback($args) {
744
-	printf(
745
-		__( 'The callback function used for the %s setting is missing.', 'invoicing' ),
746
-		'<strong>' . $args['id'] . '</strong>'
747
-	);
744
+    printf(
745
+        __( 'The callback function used for the %s setting is missing.', 'invoicing' ),
746
+        '<strong>' . $args['id'] . '</strong>'
747
+    );
748 748
 }
749 749
 
750 750
 function wpinv_select_callback($args) {
751
-	global $wpinv_options;
751
+    global $wpinv_options;
752 752
     
753 753
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
754 754
 
755
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
756
-		$value = $wpinv_options[ $args['id'] ];
757
-	} else {
758
-		$value = isset( $args['std'] ) ? $args['std'] : '';
759
-	}
755
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
756
+        $value = $wpinv_options[ $args['id'] ];
757
+    } else {
758
+        $value = isset( $args['std'] ) ? $args['std'] : '';
759
+    }
760 760
     
761 761
     if ( isset( $args['selected'] ) && $args['selected'] !== null && $args['selected'] !== false ) {
762 762
         $value = $args['selected'];
763 763
     }
764 764
 
765
-	if ( isset( $args['placeholder'] ) ) {
766
-		$placeholder = $args['placeholder'];
767
-	} else {
768
-		$placeholder = '';
769
-	}
765
+    if ( isset( $args['placeholder'] ) ) {
766
+        $placeholder = $args['placeholder'];
767
+    } else {
768
+        $placeholder = '';
769
+    }
770 770
     
771 771
     if( !empty( $args['onchange'] ) ) {
772 772
         $onchange = ' onchange="' . esc_attr( $args['onchange'] ) . '"';
@@ -776,137 +776,137 @@  discard block
 block discarded – undo
776 776
 
777 777
     $class = !empty( $args['class'] ) ? ' ' . esc_attr( $args['class'] ) : '';
778 778
 
779
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'"  name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
779
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" class="'.$class.'"  name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" data-placeholder="' . esc_html( $placeholder ) . '"' . $onchange . ' />';
780 780
 
781
-	foreach ( $args['options'] as $option => $name ) {
782
-		$selected = selected( $option, $value, false );
783
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
784
-	}
781
+    foreach ( $args['options'] as $option => $name ) {
782
+        $selected = selected( $option, $value, false );
783
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
784
+    }
785 785
 
786
-	$html .= '</select>';
787
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
786
+    $html .= '</select>';
787
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
788 788
 
789
-	echo $html;
789
+    echo $html;
790 790
 }
791 791
 
792 792
 function wpinv_color_select_callback( $args ) {
793
-	global $wpinv_options;
793
+    global $wpinv_options;
794 794
     
795 795
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
796 796
 
797
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
798
-		$value = $wpinv_options[ $args['id'] ];
799
-	} else {
800
-		$value = isset( $args['std'] ) ? $args['std'] : '';
801
-	}
797
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
798
+        $value = $wpinv_options[ $args['id'] ];
799
+    } else {
800
+        $value = isset( $args['std'] ) ? $args['std'] : '';
801
+    }
802 802
 
803
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
803
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"/>';
804 804
 
805
-	foreach ( $args['options'] as $option => $color ) {
806
-		$selected = selected( $option, $value, false );
807
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
808
-	}
805
+    foreach ( $args['options'] as $option => $color ) {
806
+        $selected = selected( $option, $value, false );
807
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $color['label'] ) . '</option>';
808
+    }
809 809
 
810
-	$html .= '</select>';
811
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
810
+    $html .= '</select>';
811
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
812 812
 
813
-	echo $html;
813
+    echo $html;
814 814
 }
815 815
 
816 816
 function wpinv_rich_editor_callback( $args ) {
817
-	global $wpinv_options, $wp_version;
817
+    global $wpinv_options, $wp_version;
818 818
     
819 819
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
820 820
 
821
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
822
-		$value = $wpinv_options[ $args['id'] ];
821
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
822
+        $value = $wpinv_options[ $args['id'] ];
823 823
 
824
-		if( empty( $args['allow_blank'] ) && empty( $value ) ) {
825
-			$value = isset( $args['std'] ) ? $args['std'] : '';
826
-		}
827
-	} else {
828
-		$value = isset( $args['std'] ) ? $args['std'] : '';
829
-	}
824
+        if( empty( $args['allow_blank'] ) && empty( $value ) ) {
825
+            $value = isset( $args['std'] ) ? $args['std'] : '';
826
+        }
827
+    } else {
828
+        $value = isset( $args['std'] ) ? $args['std'] : '';
829
+    }
830 830
 
831
-	$rows = isset( $args['size'] ) ? $args['size'] : 20;
831
+    $rows = isset( $args['size'] ) ? $args['size'] : 20;
832 832
 
833
-	$html = '<div class="getpaid-settings-editor-input">';
834
-	if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
835
-		ob_start();
836
-		wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
837
-		$html .= ob_get_clean();
838
-	} else {
839
-		$html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
840
-	}
833
+    $html = '<div class="getpaid-settings-editor-input">';
834
+    if ( $wp_version >= 3.3 && function_exists( 'wp_editor' ) ) {
835
+        ob_start();
836
+        wp_editor( stripslashes( $value ), 'wpinv_settings_' . esc_attr( $args['id'] ), array( 'textarea_name' => 'wpinv_settings[' . esc_attr( $args['id'] ) . ']', 'textarea_rows' => absint( $rows ), 'media_buttons' => false ) );
837
+        $html .= ob_get_clean();
838
+    } else {
839
+        $html .= '<textarea class="large-text" rows="10" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" class="wpi-' . esc_attr( sanitize_html_class( $args['id'] ) ) . '">' . esc_textarea( stripslashes( $value ) ) . '</textarea>';
840
+    }
841 841
 
842
-	$html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
842
+    $html .= '</div><br/><label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
843 843
 
844
-	echo $html;
844
+    echo $html;
845 845
 }
846 846
 
847 847
 function wpinv_upload_callback( $args ) {
848
-	global $wpinv_options;
848
+    global $wpinv_options;
849 849
     
850 850
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
851 851
 
852
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
853
-		$value = $wpinv_options[$args['id']];
854
-	} else {
855
-		$value = isset($args['std']) ? $args['std'] : '';
856
-	}
852
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
853
+        $value = $wpinv_options[$args['id']];
854
+    } else {
855
+        $value = isset($args['std']) ? $args['std'] : '';
856
+    }
857 857
 
858
-	$size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
859
-	$html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
860
-	$html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
861
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
858
+    $size = ( isset( $args['size'] ) && ! is_null( $args['size'] ) ) ? $args['size'] : 'regular';
859
+    $html = '<input type="text" class="' . sanitize_html_class( $size ) . '-text" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( stripslashes( $value ) ) . '"/>';
860
+    $html .= '<span>&nbsp;<input type="button" class="wpinv_settings_upload_button button-secondary" value="' . __( 'Upload File', 'invoicing' ) . '"/></span>';
861
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> ' . wp_kses_post( $args['desc'] ) . '</label>';
862 862
 
863
-	echo $html;
863
+    echo $html;
864 864
 }
865 865
 
866 866
 function wpinv_color_callback( $args ) {
867
-	global $wpinv_options;
867
+    global $wpinv_options;
868 868
     
869 869
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
870 870
 
871
-	if ( isset( $wpinv_options[ $args['id'] ] ) ) {
872
-		$value = $wpinv_options[ $args['id'] ];
873
-	} else {
874
-		$value = isset( $args['std'] ) ? $args['std'] : '';
875
-	}
871
+    if ( isset( $wpinv_options[ $args['id'] ] ) ) {
872
+        $value = $wpinv_options[ $args['id'] ];
873
+    } else {
874
+        $value = isset( $args['std'] ) ? $args['std'] : '';
875
+    }
876 876
 
877
-	$default = isset( $args['std'] ) ? $args['std'] : '';
877
+    $default = isset( $args['std'] ) ? $args['std'] : '';
878 878
 
879
-	$html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
880
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
879
+    $html = '<input type="text" class="wpinv-color-picker" id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']" value="' . esc_attr( $value ) . '" data-default-color="' . esc_attr( $default ) . '" />';
880
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
881 881
 
882
-	echo $html;
882
+    echo $html;
883 883
 }
884 884
 
885 885
 function wpinv_country_states_callback($args) {
886
-	global $wpinv_options;
886
+    global $wpinv_options;
887 887
     
888 888
     $sanitize_id = wpinv_sanitize_key( $args['id'] );
889 889
 
890
-	if ( isset( $args['placeholder'] ) ) {
891
-		$placeholder = $args['placeholder'];
892
-	} else {
893
-		$placeholder = '';
894
-	}
890
+    if ( isset( $args['placeholder'] ) ) {
891
+        $placeholder = $args['placeholder'];
892
+    } else {
893
+        $placeholder = '';
894
+    }
895 895
 
896
-	$states = wpinv_get_country_states();
896
+    $states = wpinv_get_country_states();
897 897
 
898
-	$class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
899
-	$html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
898
+    $class = empty( $states ) ? ' class="wpinv-no-states"' : ' class="wpi_select2"';
899
+    $html = '<select id="wpinv_settings[' . $sanitize_id . ']" name="wpinv_settings[' . esc_attr( $args['id'] ) . ']"' . $class . 'data-placeholder="' . esc_html( $placeholder ) . '"/>';
900 900
 
901
-	foreach ( $states as $option => $name ) {
902
-		$selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
903
-		$html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
904
-	}
901
+    foreach ( $states as $option => $name ) {
902
+        $selected = isset( $wpinv_options[ $args['id'] ] ) ? selected( $option, $wpinv_options[$args['id']], false ) : '';
903
+        $html .= '<option value="' . esc_attr( $option ) . '" ' . $selected . '>' . esc_html( $name ) . '</option>';
904
+    }
905 905
 
906
-	$html .= '</select>';
907
-	$html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
906
+    $html .= '</select>';
907
+    $html .= '<label for="wpinv_settings[' . $sanitize_id . ']"> '  . wp_kses_post( $args['desc'] ) . '</label>';
908 908
 
909
-	echo $html;
909
+    echo $html;
910 910
 }
911 911
 
912 912
 /**
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
  */
915 915
 function wpinv_tax_rates_callback() {
916 916
 	
917
-	?>
917
+    ?>
918 918
 		</td>
919 919
 	</tr>
920 920
 	<tr class="bsui">
@@ -929,17 +929,17 @@  discard block
 block discarded – undo
929 929
  * Displays a tax rate' edit row.
930 930
  */
931 931
 function wpinv_tax_rate_callback( $tax_rate, $key, $echo = true ) {
932
-	ob_start();
932
+    ob_start();
933 933
 
934
-	$key                      = sanitize_key( $key );
935
-	$tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
936
-	include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
934
+    $key                      = sanitize_key( $key );
935
+    $tax_rate['reduced_rate'] = empty( $tax_rate['reduced_rate'] ) ? 0 : $tax_rate['reduced_rate'];
936
+    include plugin_dir_path( __FILE__ ) . 'views/html-tax-rate-edit.php';
937 937
 
938
-	if ( $echo ) {
939
-		echo ob_get_clean( $echo );
940
-	} else {
941
-		return ob_get_clean( $echo ); 
942
-	}
938
+    if ( $echo ) {
939
+        echo ob_get_clean( $echo );
940
+    } else {
941
+        return ob_get_clean( $echo ); 
942
+    }
943 943
 
944 944
 }
945 945
 
@@ -967,15 +967,15 @@  discard block
 block discarded – undo
967 967
 }
968 968
 
969 969
 function wpinv_descriptive_text_callback( $args ) {
970
-	echo wp_kses_post( $args['desc'] );
970
+    echo wp_kses_post( $args['desc'] );
971 971
 }
972 972
 
973 973
 function wpinv_hook_callback( $args ) {
974
-	do_action( 'wpinv_' . $args['id'], $args );
974
+    do_action( 'wpinv_' . $args['id'], $args );
975 975
 }
976 976
 
977 977
 function wpinv_set_settings_cap() {
978
-	return wpinv_get_capability();
978
+    return wpinv_get_capability();
979 979
 }
980 980
 add_filter( 'option_page_capability_wpinv_settings', 'wpinv_set_settings_cap' );
981 981
 
Please login to merge, or discard this patch.
includes/wpinv-tax-functions.php 1 patch
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -215,16 +215,16 @@  discard block
 block discarded – undo
215 215
 function getpaid_prepare_item_tax( $item, $tax_name, $tax_amount, $recurring_tax_amount ) {
216 216
 
217 217
     $initial_tax   = $tax_amount;
218
-	$recurring_tax = 0;
218
+    $recurring_tax = 0;
219 219
 
220 220
     if ( $item->is_recurring() ) {
221
-		$recurring_tax = $recurring_tax_amount;
222
-	}
221
+        $recurring_tax = $recurring_tax_amount;
222
+    }
223 223
 
224
-	return array(
225
-		'name'          => sanitize_text_field( $tax_name ),
226
-		'initial_tax'   => $initial_tax,
227
-		'recurring_tax' => $recurring_tax,
224
+    return array(
225
+        'name'          => sanitize_text_field( $tax_name ),
226
+        'initial_tax'   => $initial_tax,
227
+        'recurring_tax' => $recurring_tax,
228 228
     );
229 229
 
230 230
 }
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
  */
329 329
 function wpinv_should_validate_vat_number() {
330 330
     $validate = wpinv_get_option( 'validate_vat_number' );
331
-	return ! empty( $validate );
331
+    return ! empty( $validate );
332 332
 }
333 333
 
334 334
 function wpinv_sales_tax_for_year( $year = null ) {
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission.php 1 patch
Indentation   +761 added lines, -761 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,187 +10,187 @@  discard block
 block discarded – undo
10 10
 class GetPaid_Payment_Form_Submission {
11 11
 
12 12
     /**
13
-	 * Submission ID
14
-	 *
15
-	 * @var string
16
-	 */
17
-	public $id = null;
18
-
19
-	/**
20
-	 * The raw submission data.
21
-	 *
22
-	 * @var array
23
-	 */
24
-	protected $data = null;
25
-
26
-	/**
27
-	 * Submission totals
28
-	 *
29
-	 * @var array
30
-	 */
31
-	protected $totals = array(
32
-
33
-		'subtotal'      => array(
34
-			'initial'   => 0,
35
-			'recurring' => 0,
36
-		),
37
-
38
-		'discount'      => array(
39
-			'initial'   => 0,
40
-			'recurring' => 0,
41
-		),
42
-
43
-		'fees'          => array(
44
-			'initial'   => 0,
45
-			'recurring' => 0,
46
-		),
47
-
48
-		'taxes'         => array(
49
-			'initial'   => 0,
50
-			'recurring' => 0,
51
-		),
52
-
53
-	);
54
-
55
-	/**
56
-	 * Sets the associated payment form.
57
-	 *
58
-	 * @var GetPaid_Payment_Form
59
-	 */
13
+     * Submission ID
14
+     *
15
+     * @var string
16
+     */
17
+    public $id = null;
18
+
19
+    /**
20
+     * The raw submission data.
21
+     *
22
+     * @var array
23
+     */
24
+    protected $data = null;
25
+
26
+    /**
27
+     * Submission totals
28
+     *
29
+     * @var array
30
+     */
31
+    protected $totals = array(
32
+
33
+        'subtotal'      => array(
34
+            'initial'   => 0,
35
+            'recurring' => 0,
36
+        ),
37
+
38
+        'discount'      => array(
39
+            'initial'   => 0,
40
+            'recurring' => 0,
41
+        ),
42
+
43
+        'fees'          => array(
44
+            'initial'   => 0,
45
+            'recurring' => 0,
46
+        ),
47
+
48
+        'taxes'         => array(
49
+            'initial'   => 0,
50
+            'recurring' => 0,
51
+        ),
52
+
53
+    );
54
+
55
+    /**
56
+     * Sets the associated payment form.
57
+     *
58
+     * @var GetPaid_Payment_Form
59
+     */
60 60
     protected $payment_form = null;
61 61
 
62 62
     /**
63
-	 * The country for the submission.
64
-	 *
65
-	 * @var string
66
-	 */
67
-	public $country = null;
68
-
69
-    /**
70
-	 * The state for the submission.
71
-	 *
72
-	 * @since 1.0.19
73
-	 * @var string
74
-	 */
75
-	public $state = null;
76
-
77
-	/**
78
-	 * The invoice associated with the submission.
79
-	 *
80
-	 * @var WPInv_Invoice
81
-	 */
82
-	protected $invoice = null;
83
-
84
-	/**
85
-	 * The recurring item for the submission.
86
-	 *
87
-	 * @var int
88
-	 */
89
-	public $has_recurring = 0;
90
-
91
-	/**
92
-	 * An array of fees for the submission.
93
-	 *
94
-	 * @var array
95
-	 */
96
-	protected $fees = array();
97
-
98
-	/**
99
-	 * An array of discounts for the submission.
100
-	 *
101
-	 * @var array
102
-	 */
103
-	protected $discounts = array();
104
-
105
-	/**
106
-	 * An array of taxes for the submission.
107
-	 *
108
-	 * @var array
109
-	 */
110
-	protected $taxes = array();
111
-
112
-	/**
113
-	 * An array of items for the submission.
114
-	 *
115
-	 * @var GetPaid_Form_Item[]
116
-	 */
117
-	protected $items = array();
118
-
119
-	/**
120
-	 * The last error.
121
-	 *
122
-	 * @var string
123
-	 */
124
-	public $last_error = null;
125
-
126
-    /**
127
-	 * Class constructor.
128
-	 *
129
-	 */
130
-	public function __construct() {
131
-
132
-		// Set the state and country to the default state and country.
133
-		$this->country = wpinv_default_billing_country();
134
-		$this->state   = wpinv_get_default_state();
135
-
136
-		// Do we have an actual submission?
137
-		if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
138
-			$this->load_data( $_POST );
139
-		}
140
-
141
-	}
142
-
143
-	/**
144
-	 * Loads submission data.
145
-	 *
146
-	 * @param array $data
147
-	 */
148
-	public function load_data( $data ) {
149
-
150
-		// Remove slashes from the submitted data...
151
-		$data       = wp_unslash( $data );
152
-
153
-		// Allow plugins to filter the data.
154
-		$data       = apply_filters( 'getpaid_submission_data', $data, $this );
155
-
156
-		// Cache it...
157
-		$this->data = $data;
158
-
159
-		// Then generate a unique id from the data.
160
-		$this->id   = md5( wp_json_encode( $data ) );
161
-
162
-		// Finally, process the submission.
163
-		try {
164
-
165
-			// Each process is passed an instance of the class (with reference)
166
-			// and should throw an Exception whenever it encounters one.
167
-			$processors = apply_filters(
168
-				'getpaid_payment_form_submission_processors',
169
-				array(
170
-					array( $this, 'process_payment_form' ),
171
-					array( $this, 'process_invoice' ),
172
-					array( $this, 'process_fees' ),
173
-					array( $this, 'process_items' ),
174
-					array( $this, 'process_taxes' ),
175
-					array( $this, 'process_discount' ),
176
-				),
177
-				$this		
178
-			);
179
-
180
-			foreach ( $processors as $processor ) {
181
-				call_user_func_array( $processor, array( &$this ) );
182
-			}
183
-
184
-		} catch ( Exception $e ) {
185
-			$this->last_error = $e->getMessage();
186
-		}
187
-
188
-		// Fired when we are done processing a submission.
189
-		do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
190
-
191
-	}
192
-
193
-	/*
63
+     * The country for the submission.
64
+     *
65
+     * @var string
66
+     */
67
+    public $country = null;
68
+
69
+    /**
70
+     * The state for the submission.
71
+     *
72
+     * @since 1.0.19
73
+     * @var string
74
+     */
75
+    public $state = null;
76
+
77
+    /**
78
+     * The invoice associated with the submission.
79
+     *
80
+     * @var WPInv_Invoice
81
+     */
82
+    protected $invoice = null;
83
+
84
+    /**
85
+     * The recurring item for the submission.
86
+     *
87
+     * @var int
88
+     */
89
+    public $has_recurring = 0;
90
+
91
+    /**
92
+     * An array of fees for the submission.
93
+     *
94
+     * @var array
95
+     */
96
+    protected $fees = array();
97
+
98
+    /**
99
+     * An array of discounts for the submission.
100
+     *
101
+     * @var array
102
+     */
103
+    protected $discounts = array();
104
+
105
+    /**
106
+     * An array of taxes for the submission.
107
+     *
108
+     * @var array
109
+     */
110
+    protected $taxes = array();
111
+
112
+    /**
113
+     * An array of items for the submission.
114
+     *
115
+     * @var GetPaid_Form_Item[]
116
+     */
117
+    protected $items = array();
118
+
119
+    /**
120
+     * The last error.
121
+     *
122
+     * @var string
123
+     */
124
+    public $last_error = null;
125
+
126
+    /**
127
+     * Class constructor.
128
+     *
129
+     */
130
+    public function __construct() {
131
+
132
+        // Set the state and country to the default state and country.
133
+        $this->country = wpinv_default_billing_country();
134
+        $this->state   = wpinv_get_default_state();
135
+
136
+        // Do we have an actual submission?
137
+        if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
138
+            $this->load_data( $_POST );
139
+        }
140
+
141
+    }
142
+
143
+    /**
144
+     * Loads submission data.
145
+     *
146
+     * @param array $data
147
+     */
148
+    public function load_data( $data ) {
149
+
150
+        // Remove slashes from the submitted data...
151
+        $data       = wp_unslash( $data );
152
+
153
+        // Allow plugins to filter the data.
154
+        $data       = apply_filters( 'getpaid_submission_data', $data, $this );
155
+
156
+        // Cache it...
157
+        $this->data = $data;
158
+
159
+        // Then generate a unique id from the data.
160
+        $this->id   = md5( wp_json_encode( $data ) );
161
+
162
+        // Finally, process the submission.
163
+        try {
164
+
165
+            // Each process is passed an instance of the class (with reference)
166
+            // and should throw an Exception whenever it encounters one.
167
+            $processors = apply_filters(
168
+                'getpaid_payment_form_submission_processors',
169
+                array(
170
+                    array( $this, 'process_payment_form' ),
171
+                    array( $this, 'process_invoice' ),
172
+                    array( $this, 'process_fees' ),
173
+                    array( $this, 'process_items' ),
174
+                    array( $this, 'process_taxes' ),
175
+                    array( $this, 'process_discount' ),
176
+                ),
177
+                $this		
178
+            );
179
+
180
+            foreach ( $processors as $processor ) {
181
+                call_user_func_array( $processor, array( &$this ) );
182
+            }
183
+
184
+        } catch ( Exception $e ) {
185
+            $this->last_error = $e->getMessage();
186
+        }
187
+
188
+        // Fired when we are done processing a submission.
189
+        do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
190
+
191
+    }
192
+
193
+    /*
194 194
 	|--------------------------------------------------------------------------
195 195
 	| Payment Forms.
196 196
 	|--------------------------------------------------------------------------
@@ -199,39 +199,39 @@  discard block
 block discarded – undo
199 199
 	| submission has an active payment form etc.
200 200
     */
201 201
 
202
-	/**
203
-	 * Prepares the submission's payment form.
204
-	 *
205
-	 * @since 1.0.19
206
-	 */
207
-	public function process_payment_form() {
202
+    /**
203
+     * Prepares the submission's payment form.
204
+     *
205
+     * @since 1.0.19
206
+     */
207
+    public function process_payment_form() {
208 208
 
209
-		// Every submission needs an active payment form.
210
-		if ( empty( $this->data['form_id'] ) ) {
211
-			throw new Exception( __( 'Missing payment form', 'invoicing' ) );
212
-		}
209
+        // Every submission needs an active payment form.
210
+        if ( empty( $this->data['form_id'] ) ) {
211
+            throw new Exception( __( 'Missing payment form', 'invoicing' ) );
212
+        }
213 213
 
214
-		// Fetch the payment form.
215
-		$this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] );
214
+        // Fetch the payment form.
215
+        $this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] );
216 216
 
217
-		if ( ! $this->payment_form->is_active() ) {
218
-			throw new Exception( __( 'Payment form not active', 'invoicing' ) );
219
-		}
217
+        if ( ! $this->payment_form->is_active() ) {
218
+            throw new Exception( __( 'Payment form not active', 'invoicing' ) );
219
+        }
220 220
 
221
-		do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) );
222
-	}
221
+        do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) );
222
+    }
223 223
 
224 224
     /**
225
-	 * Returns the payment form.
226
-	 *
227
-	 * @since 1.0.19
228
-	 * @return GetPaid_Payment_Form
229
-	 */
230
-	public function get_payment_form() {
231
-		return $this->payment_form;
232
-	}
225
+     * Returns the payment form.
226
+     *
227
+     * @since 1.0.19
228
+     * @return GetPaid_Payment_Form
229
+     */
230
+    public function get_payment_form() {
231
+        return $this->payment_form;
232
+    }
233 233
 
234
-	/*
234
+    /*
235 235
 	|--------------------------------------------------------------------------
236 236
 	| Invoices.
237 237
 	|--------------------------------------------------------------------------
@@ -240,61 +240,61 @@  discard block
 block discarded – undo
240 240
 	| might be for an existing invoice.
241 241
 	*/
242 242
 
243
-	/**
244
-	 * Prepares the submission's invoice.
245
-	 *
246
-	 * @since 1.0.19
247
-	 */
248
-	public function process_invoice() {
243
+    /**
244
+     * Prepares the submission's invoice.
245
+     *
246
+     * @since 1.0.19
247
+     */
248
+    public function process_invoice() {
249 249
 
250
-		// Abort if there is no invoice.
251
-		if ( empty( $this->data['invoice_id'] ) ) {
252
-			return;
253
-		}
250
+        // Abort if there is no invoice.
251
+        if ( empty( $this->data['invoice_id'] ) ) {
252
+            return;
253
+        }
254 254
 
255
-		// If the submission is for an existing invoice, ensure that it exists
256
-		// and that it is not paid for.
257
-		$invoice = wpinv_get_invoice( $this->data['invoice_id'] );
255
+        // If the submission is for an existing invoice, ensure that it exists
256
+        // and that it is not paid for.
257
+        $invoice = wpinv_get_invoice( $this->data['invoice_id'] );
258 258
 
259 259
         if ( empty( $invoice ) ) {
260
-			throw new Exception( __( 'Invalid invoice', 'invoicing' ) );
261
-		}
262
-
263
-		if ( $invoice->is_paid() ) {
264
-			throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) );
265
-		}
266
-
267
-		$this->payment_form->set_items( $invoice->get_items() );
268
-		$this->payment_form->invoice = $invoice;
269
-
270
-		$this->country = $invoice->get_country();
271
-		$this->state   = $invoice->get_state();
272
-		$this->invoice = $invoice;
273
-
274
-		do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) );
275
-	}
276
-
277
-	/**
278
-	 * Returns the associated invoice.
279
-	 *
280
-	 * @since 1.0.19
281
-	 * @return WPInv_Invoice
282
-	 */
283
-	public function get_invoice() {
284
-		return $this->invoice;
285
-	}
286
-
287
-	/**
288
-	 * Checks whether there is an invoice associated with this submission.
289
-	 *
290
-	 * @since 1.0.19
291
-	 * @return bool
292
-	 */
293
-	public function has_invoice() {
294
-		return ! empty( $this->invoice );
295
-	}
296
-
297
-	/*
260
+            throw new Exception( __( 'Invalid invoice', 'invoicing' ) );
261
+        }
262
+
263
+        if ( $invoice->is_paid() ) {
264
+            throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) );
265
+        }
266
+
267
+        $this->payment_form->set_items( $invoice->get_items() );
268
+        $this->payment_form->invoice = $invoice;
269
+
270
+        $this->country = $invoice->get_country();
271
+        $this->state   = $invoice->get_state();
272
+        $this->invoice = $invoice;
273
+
274
+        do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) );
275
+    }
276
+
277
+    /**
278
+     * Returns the associated invoice.
279
+     *
280
+     * @since 1.0.19
281
+     * @return WPInv_Invoice
282
+     */
283
+    public function get_invoice() {
284
+        return $this->invoice;
285
+    }
286
+
287
+    /**
288
+     * Checks whether there is an invoice associated with this submission.
289
+     *
290
+     * @since 1.0.19
291
+     * @return bool
292
+     */
293
+    public function has_invoice() {
294
+        return ! empty( $this->invoice );
295
+    }
296
+
297
+    /*
298 298
 	|--------------------------------------------------------------------------
299 299
 	| Items.
300 300
 	|--------------------------------------------------------------------------
@@ -303,115 +303,115 @@  discard block
 block discarded – undo
303 303
 	| recurring item. But can have an unlimited number of non-recurring items.
304 304
 	*/
305 305
 
306
-	/**
307
-	 * Prepares the submission's items.
308
-	 *
309
-	 * @since 1.0.19
310
-	 */
311
-	public function process_items() {
312
-
313
-		$processor = new GetPaid_Payment_Form_Submission_Items( $this );
314
-
315
-		foreach ( $processor->items as $item ) {
316
-			$this->add_item( $item );
317
-		}
318
-
319
-		do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) );
320
-	}
321
-
322
-	/**
323
-	 * Adds an item to the submission.
324
-	 *
325
-	 * @since 1.0.19
326
-	 * @param GetPaid_Form_Item $item
327
-	 */
328
-	public function add_item( $item ) {
329
-
330
-		// Make sure that it is available for purchase.
331
-		if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) {
332
-			return;
333
-		}
334
-
335
-		// Each submission can only contain one recurring item.
336
-		if ( $item->is_recurring() ) {
337
-
338
-			if ( $this->has_recurring != 0 ) {
339
-				throw new Exception( __( 'You can only buy one recurring item at a time.', 'invoicing' ) );
340
-			}
341
-
342
-			$this->has_recurring = $item->get_id();
343
-
344
-		}
345
-
346
-		// Update the items and totals.
347
-		$this->items[ $item->get_id() ]         = $item;
348
-		$this->totals['subtotal']['initial']   += $item->get_sub_total();
349
-		$this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total();
350
-
351
-	}
352
-
353
-	/**
354
-	 * Removes a specific item.
355
-	 * 
356
-	 * You should not call this method after the discounts and taxes
357
-	 * have been calculated.
358
-	 *
359
-	 * @since 1.0.19
360
-	 */
361
-	public function remove_item( $item_id ) {
362
-
363
-		if ( isset( $this->items[ $item_id ] ) ) {
364
-			$this->totals['subtotal']['initial']   -= $this->items[ $item_id ]->get_sub_total();
365
-			$this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total();
366
-
367
-			if ( $this->items[ $item_id ]->is_recurring() ) {
368
-				$this->has_recurring = 0;
369
-			}
370
-
371
-			unset( $this->items[ $item_id ] );
372
-		}
373
-
374
-	}
375
-
376
-	/**
377
-	 * Returns the subtotal.
378
-	 *
379
-	 * @since 1.0.19
380
-	 */
381
-	public function get_subtotal() {
382
-
383
-		if ( wpinv_prices_include_tax() ) {
384
-			return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial'];
385
-		}
386
-
387
-		return $this->totals['subtotal']['initial'];
388
-	}
389
-
390
-	/**
391
-	 * Returns the recurring subtotal.
392
-	 *
393
-	 * @since 1.0.19
394
-	 */
395
-	public function get_recurring_subtotal() {
396
-
397
-		if ( wpinv_prices_include_tax() ) {
398
-			return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring'];
399
-		}
400
-
401
-		return $this->totals['subtotal']['recurring'];
402
-	}
403
-
404
-	/**
405
-	 * Returns all items.
406
-	 *
407
-	 * @since 1.0.19
408
-	 * @return GetPaid_Form_Item[]
409
-	 */
410
-	public function get_items() {
411
-		return $this->items;
412
-	}
413
-
414
-	/*
306
+    /**
307
+     * Prepares the submission's items.
308
+     *
309
+     * @since 1.0.19
310
+     */
311
+    public function process_items() {
312
+
313
+        $processor = new GetPaid_Payment_Form_Submission_Items( $this );
314
+
315
+        foreach ( $processor->items as $item ) {
316
+            $this->add_item( $item );
317
+        }
318
+
319
+        do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) );
320
+    }
321
+
322
+    /**
323
+     * Adds an item to the submission.
324
+     *
325
+     * @since 1.0.19
326
+     * @param GetPaid_Form_Item $item
327
+     */
328
+    public function add_item( $item ) {
329
+
330
+        // Make sure that it is available for purchase.
331
+        if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) {
332
+            return;
333
+        }
334
+
335
+        // Each submission can only contain one recurring item.
336
+        if ( $item->is_recurring() ) {
337
+
338
+            if ( $this->has_recurring != 0 ) {
339
+                throw new Exception( __( 'You can only buy one recurring item at a time.', 'invoicing' ) );
340
+            }
341
+
342
+            $this->has_recurring = $item->get_id();
343
+
344
+        }
345
+
346
+        // Update the items and totals.
347
+        $this->items[ $item->get_id() ]         = $item;
348
+        $this->totals['subtotal']['initial']   += $item->get_sub_total();
349
+        $this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total();
350
+
351
+    }
352
+
353
+    /**
354
+     * Removes a specific item.
355
+     * 
356
+     * You should not call this method after the discounts and taxes
357
+     * have been calculated.
358
+     *
359
+     * @since 1.0.19
360
+     */
361
+    public function remove_item( $item_id ) {
362
+
363
+        if ( isset( $this->items[ $item_id ] ) ) {
364
+            $this->totals['subtotal']['initial']   -= $this->items[ $item_id ]->get_sub_total();
365
+            $this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total();
366
+
367
+            if ( $this->items[ $item_id ]->is_recurring() ) {
368
+                $this->has_recurring = 0;
369
+            }
370
+
371
+            unset( $this->items[ $item_id ] );
372
+        }
373
+
374
+    }
375
+
376
+    /**
377
+     * Returns the subtotal.
378
+     *
379
+     * @since 1.0.19
380
+     */
381
+    public function get_subtotal() {
382
+
383
+        if ( wpinv_prices_include_tax() ) {
384
+            return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial'];
385
+        }
386
+
387
+        return $this->totals['subtotal']['initial'];
388
+    }
389
+
390
+    /**
391
+     * Returns the recurring subtotal.
392
+     *
393
+     * @since 1.0.19
394
+     */
395
+    public function get_recurring_subtotal() {
396
+
397
+        if ( wpinv_prices_include_tax() ) {
398
+            return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring'];
399
+        }
400
+
401
+        return $this->totals['subtotal']['recurring'];
402
+    }
403
+
404
+    /**
405
+     * Returns all items.
406
+     *
407
+     * @since 1.0.19
408
+     * @return GetPaid_Form_Item[]
409
+     */
410
+    public function get_items() {
411
+        return $this->items;
412
+    }
413
+
414
+    /*
415 415
 	|--------------------------------------------------------------------------
416 416
 	| Taxes
417 417
 	|--------------------------------------------------------------------------
@@ -420,122 +420,122 @@  discard block
 block discarded – undo
420 420
 	| or only one-time.
421 421
     */
422 422
 
423
-	/**
424
-	 * Prepares the submission's taxes.
425
-	 *
426
-	 * @since 1.0.19
427
-	 */
428
-	public function process_taxes() {
429
-
430
-		// Abort if we're not using taxes.
431
-		if ( ! $this->use_taxes() ) {
432
-			return;
433
-		}
434
-
435
-		// If a custom country && state has been passed in, use it to calculate taxes.
436
-		$country = $this->get_field( 'wpinv_country', 'billing' );
437
-		if ( ! empty( $country ) ) {
438
-			$this->country = $country;
439
-		}
440
-
441
-		$state = $this->get_field( 'wpinv_state', 'billing' );
442
-		if ( ! empty( $state ) ) {
443
-			$this->state = $state;
444
-		}
445
-
446
-		// Abort if the country is not taxable.
447
-		if ( wpinv_is_country_taxable( $this->country ) ) {
448
-			return;
449
-		}
450
-
451
-		$processor = new GetPaid_Payment_Form_Submission_Taxes( $this );
452
-
453
-		foreach ( $processor->taxes as $tax ) {
454
-			$this->add_tax( $tax );
455
-		}
456
-
457
-		do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) );
458
-	}
459
-
460
-	/**
461
-	 * Adds a tax to the submission.
462
-	 *
463
-	 * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
464
-	 * @since 1.0.19
465
-	 */
466
-	public function add_tax( $tax ) {
467
-
468
-		if ( wpinv_round_tax_per_tax_rate() ) {
469
-			$tax['initial_tax']   = wpinv_round_amount( $tax['initial_tax'] );
470
-			$tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] );
471
-		}
472
-
473
-		$this->taxes[ $tax['name'] ]         = $tax;
474
-		$this->totals['taxes']['initial']   += wpinv_sanitize_amount( $tax['initial_tax'] );
475
-		$this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] );
476
-
477
-	}
478
-
479
-	/**
480
-	 * Removes a specific tax.
481
-	 *
482
-	 * @since 1.0.19
483
-	 */
484
-	public function remove_tax( $tax_name ) {
485
-
486
-		if ( isset( $this->taxes[ $tax_name ] ) ) {
487
-			$this->totals['taxes']['initial']   -= $this->taxes[ $tax_name ]['initial_tax'];
488
-			$this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax'];
489
-			unset( $this->taxes[ $tax_name ] );
490
-		}
491
-
492
-	}
493
-
494
-	/**
495
-	 * Whether or not we'll use taxes for the submission.
496
-	 *
497
-	 * @since 1.0.19
498
-	 */
499
-	public function use_taxes() {
500
-
501
-		$use_taxes = wpinv_use_taxes();
502
-
503
-		if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) {
504
-			$use_taxes = false;
505
-		}
506
-
507
-		return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
508
-
509
-	}
510
-
511
-	/**
512
-	 * Returns the tax.
513
-	 *
514
-	 * @since 1.0.19
515
-	 */
516
-	public function get_tax() {
517
-		return $this->totals['taxes']['initial'];
518
-	}
519
-
520
-	/**
521
-	 * Returns the recurring tax.
522
-	 *
523
-	 * @since 1.0.19
524
-	 */
525
-	public function get_recurring_tax() {
526
-		return $this->totals['taxes']['recurring'];
527
-	}
528
-
529
-	/**
530
-	 * Returns all taxes.
531
-	 *
532
-	 * @since 1.0.19
533
-	 */
534
-	public function get_taxes() {
535
-		return $this->taxes;
536
-	}
537
-
538
-	/*
423
+    /**
424
+     * Prepares the submission's taxes.
425
+     *
426
+     * @since 1.0.19
427
+     */
428
+    public function process_taxes() {
429
+
430
+        // Abort if we're not using taxes.
431
+        if ( ! $this->use_taxes() ) {
432
+            return;
433
+        }
434
+
435
+        // If a custom country && state has been passed in, use it to calculate taxes.
436
+        $country = $this->get_field( 'wpinv_country', 'billing' );
437
+        if ( ! empty( $country ) ) {
438
+            $this->country = $country;
439
+        }
440
+
441
+        $state = $this->get_field( 'wpinv_state', 'billing' );
442
+        if ( ! empty( $state ) ) {
443
+            $this->state = $state;
444
+        }
445
+
446
+        // Abort if the country is not taxable.
447
+        if ( wpinv_is_country_taxable( $this->country ) ) {
448
+            return;
449
+        }
450
+
451
+        $processor = new GetPaid_Payment_Form_Submission_Taxes( $this );
452
+
453
+        foreach ( $processor->taxes as $tax ) {
454
+            $this->add_tax( $tax );
455
+        }
456
+
457
+        do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) );
458
+    }
459
+
460
+    /**
461
+     * Adds a tax to the submission.
462
+     *
463
+     * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
464
+     * @since 1.0.19
465
+     */
466
+    public function add_tax( $tax ) {
467
+
468
+        if ( wpinv_round_tax_per_tax_rate() ) {
469
+            $tax['initial_tax']   = wpinv_round_amount( $tax['initial_tax'] );
470
+            $tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] );
471
+        }
472
+
473
+        $this->taxes[ $tax['name'] ]         = $tax;
474
+        $this->totals['taxes']['initial']   += wpinv_sanitize_amount( $tax['initial_tax'] );
475
+        $this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] );
476
+
477
+    }
478
+
479
+    /**
480
+     * Removes a specific tax.
481
+     *
482
+     * @since 1.0.19
483
+     */
484
+    public function remove_tax( $tax_name ) {
485
+
486
+        if ( isset( $this->taxes[ $tax_name ] ) ) {
487
+            $this->totals['taxes']['initial']   -= $this->taxes[ $tax_name ]['initial_tax'];
488
+            $this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax'];
489
+            unset( $this->taxes[ $tax_name ] );
490
+        }
491
+
492
+    }
493
+
494
+    /**
495
+     * Whether or not we'll use taxes for the submission.
496
+     *
497
+     * @since 1.0.19
498
+     */
499
+    public function use_taxes() {
500
+
501
+        $use_taxes = wpinv_use_taxes();
502
+
503
+        if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) {
504
+            $use_taxes = false;
505
+        }
506
+
507
+        return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
508
+
509
+    }
510
+
511
+    /**
512
+     * Returns the tax.
513
+     *
514
+     * @since 1.0.19
515
+     */
516
+    public function get_tax() {
517
+        return $this->totals['taxes']['initial'];
518
+    }
519
+
520
+    /**
521
+     * Returns the recurring tax.
522
+     *
523
+     * @since 1.0.19
524
+     */
525
+    public function get_recurring_tax() {
526
+        return $this->totals['taxes']['recurring'];
527
+    }
528
+
529
+    /**
530
+     * Returns all taxes.
531
+     *
532
+     * @since 1.0.19
533
+     */
534
+    public function get_taxes() {
535
+        return $this->taxes;
536
+    }
537
+
538
+    /*
539 539
 	|--------------------------------------------------------------------------
540 540
 	| Discounts
541 541
 	|--------------------------------------------------------------------------
@@ -544,99 +544,99 @@  discard block
 block discarded – undo
544 544
 	| or only one-time. They also do not have to come from a discount code.
545 545
     */
546 546
 
547
-	/**
548
-	 * Prepares the submission's discount.
549
-	 *
550
-	 * @since 1.0.19
551
-	 */
552
-	public function process_discount() {
553
-
554
-		$initial_total    = $this->get_subtotal() + $this->get_fee() + $this->get_tax();
555
-		$recurring_total  = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax();
556
-		$processor        = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total );
557
-
558
-		foreach ( $processor->discounts as $discount ) {
559
-			$this->add_discount( $discount );
560
-		}
561
-
562
-		do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) );
563
-	}
564
-
565
-	/**
566
-	 * Adds a discount to the submission.
567
-	 *
568
-	 * @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.
569
-	 * @since 1.0.19
570
-	 */
571
-	public function add_discount( $discount ) {
572
-		$this->discounts[ $discount['name'] ]   = $discount;
573
-		$this->totals['discount']['initial']   += wpinv_sanitize_amount( $discount['initial_discount'] );
574
-		$this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] );
575
-	}
576
-
577
-	/**
578
-	 * Removes a discount from the submission.
579
-	 *
580
-	 * @since 1.0.19
581
-	 */
582
-	public function remove_discount( $name ) {
583
-
584
-		if ( isset( $this->discounts[ $name ] ) ) {
585
-			$this->totals['discount']['initial']   -= $this->discounts[ $name ]['initial_discount'];
586
-			$this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount'];
587
-			unset( $this->discounts[ $name ] );
588
-		}
589
-
590
-	}
591
-
592
-	/**
593
-	 * Checks whether there is a discount code associated with this submission.
594
-	 *
595
-	 * @since 1.0.19
596
-	 * @return bool
597
-	 */
598
-	public function has_discount_code() {
599
-		return ! empty( $this->discounts['discount_code'] );
600
-	}
601
-
602
-	/**
603
-	 * Returns the discount code.
604
-	 *
605
-	 * @since 1.0.19
606
-	 * @return string
607
-	 */
608
-	public function get_discount_code() {
609
-		return $this->has_discount_code() ? $this->discounts['discount_code']['discount_code'] : '';
610
-	}
611
-
612
-	/**
613
-	 * Returns the discount.
614
-	 *
615
-	 * @since 1.0.19
616
-	 */
617
-	public function get_discount() {
618
-		return $this->totals['discount']['initial'];
619
-	}
620
-
621
-	/**
622
-	 * Returns the recurring discount.
623
-	 *
624
-	 * @since 1.0.19
625
-	 */
626
-	public function get_recurring_discount() {
627
-		return $this->totals['discount']['recurring'];
628
-	}
629
-
630
-	/**
631
-	 * Returns all discounts.
632
-	 *
633
-	 * @since 1.0.19
634
-	 */
635
-	public function get_discounts() {
636
-		return $this->discounts;
637
-	}
638
-
639
-	/*
547
+    /**
548
+     * Prepares the submission's discount.
549
+     *
550
+     * @since 1.0.19
551
+     */
552
+    public function process_discount() {
553
+
554
+        $initial_total    = $this->get_subtotal() + $this->get_fee() + $this->get_tax();
555
+        $recurring_total  = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax();
556
+        $processor        = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total );
557
+
558
+        foreach ( $processor->discounts as $discount ) {
559
+            $this->add_discount( $discount );
560
+        }
561
+
562
+        do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) );
563
+    }
564
+
565
+    /**
566
+     * Adds a discount to the submission.
567
+     *
568
+     * @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.
569
+     * @since 1.0.19
570
+     */
571
+    public function add_discount( $discount ) {
572
+        $this->discounts[ $discount['name'] ]   = $discount;
573
+        $this->totals['discount']['initial']   += wpinv_sanitize_amount( $discount['initial_discount'] );
574
+        $this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] );
575
+    }
576
+
577
+    /**
578
+     * Removes a discount from the submission.
579
+     *
580
+     * @since 1.0.19
581
+     */
582
+    public function remove_discount( $name ) {
583
+
584
+        if ( isset( $this->discounts[ $name ] ) ) {
585
+            $this->totals['discount']['initial']   -= $this->discounts[ $name ]['initial_discount'];
586
+            $this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount'];
587
+            unset( $this->discounts[ $name ] );
588
+        }
589
+
590
+    }
591
+
592
+    /**
593
+     * Checks whether there is a discount code associated with this submission.
594
+     *
595
+     * @since 1.0.19
596
+     * @return bool
597
+     */
598
+    public function has_discount_code() {
599
+        return ! empty( $this->discounts['discount_code'] );
600
+    }
601
+
602
+    /**
603
+     * Returns the discount code.
604
+     *
605
+     * @since 1.0.19
606
+     * @return string
607
+     */
608
+    public function get_discount_code() {
609
+        return $this->has_discount_code() ? $this->discounts['discount_code']['discount_code'] : '';
610
+    }
611
+
612
+    /**
613
+     * Returns the discount.
614
+     *
615
+     * @since 1.0.19
616
+     */
617
+    public function get_discount() {
618
+        return $this->totals['discount']['initial'];
619
+    }
620
+
621
+    /**
622
+     * Returns the recurring discount.
623
+     *
624
+     * @since 1.0.19
625
+     */
626
+    public function get_recurring_discount() {
627
+        return $this->totals['discount']['recurring'];
628
+    }
629
+
630
+    /**
631
+     * Returns all discounts.
632
+     *
633
+     * @since 1.0.19
634
+     */
635
+    public function get_discounts() {
636
+        return $this->discounts;
637
+    }
638
+
639
+    /*
640 640
 	|--------------------------------------------------------------------------
641 641
 	| Fees
642 642
 	|--------------------------------------------------------------------------
@@ -646,89 +646,89 @@  discard block
 block discarded – undo
646 646
 	| fees.
647 647
     */
648 648
 
649
-	/**
650
-	 * Prepares the submission's fees.
651
-	 *
652
-	 * @since 1.0.19
653
-	 */
654
-	public function process_fees() {
655
-
656
-		$fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this );
657
-
658
-		foreach ( $fees_processor->fees as $fee ) {
659
-			$this->add_fee( $fee );
660
-		}
661
-
662
-		do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) );
663
-	}
664
-
665
-	/**
666
-	 * Adds a fee to the submission.
667
-	 *
668
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
669
-	 * @since 1.0.19
670
-	 */
671
-	public function add_fee( $fee ) {
672
-
673
-		$this->fees[ $fee['name'] ]         = $fee;
674
-		$this->totals['fees']['initial']   += wpinv_sanitize_amount( $fee['initial_fee'] );
675
-		$this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] );
676
-
677
-	}
678
-
679
-	/**
680
-	 * Removes a fee from the submission.
681
-	 *
682
-	 * @since 1.0.19
683
-	 */
684
-	public function remove_fee( $name ) {
685
-
686
-		if ( isset( $this->fees[ $name ] ) ) {
687
-			$this->totals['fees']['initial']   -= $this->fees[ $name ]['initial_fee'];
688
-			$this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee'];
689
-			unset( $this->fees[ $name ] );
690
-		}
691
-
692
-	}
693
-
694
-	/**
695
-	 * Returns the fees.
696
-	 *
697
-	 * @since 1.0.19
698
-	 */
699
-	public function get_fee() {
700
-		return $this->totals['fees']['initial'];
701
-	}
702
-
703
-	/**
704
-	 * Returns the recurring fees.
705
-	 *
706
-	 * @since 1.0.19
707
-	 */
708
-	public function get_recurring_fee() {
709
-		return $this->totals['fees']['recurring'];
710
-	}
711
-
712
-	/**
713
-	 * Returns all fees.
714
-	 *
715
-	 * @since 1.0.19
716
-	 */
717
-	public function get_fees() {
718
-		return $this->fees;
719
-	}
720
-
721
-	/**
722
-	 * Checks if there are any fees for the form.
723
-	 *
724
-	 * @return bool
725
-	 * @since 1.0.19
726
-	 */
727
-	public function has_fees() {
728
-		return count( $this->fees ) !== 0;
729
-	}
730
-
731
-	/*
649
+    /**
650
+     * Prepares the submission's fees.
651
+     *
652
+     * @since 1.0.19
653
+     */
654
+    public function process_fees() {
655
+
656
+        $fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this );
657
+
658
+        foreach ( $fees_processor->fees as $fee ) {
659
+            $this->add_fee( $fee );
660
+        }
661
+
662
+        do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) );
663
+    }
664
+
665
+    /**
666
+     * Adds a fee to the submission.
667
+     *
668
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
669
+     * @since 1.0.19
670
+     */
671
+    public function add_fee( $fee ) {
672
+
673
+        $this->fees[ $fee['name'] ]         = $fee;
674
+        $this->totals['fees']['initial']   += wpinv_sanitize_amount( $fee['initial_fee'] );
675
+        $this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] );
676
+
677
+    }
678
+
679
+    /**
680
+     * Removes a fee from the submission.
681
+     *
682
+     * @since 1.0.19
683
+     */
684
+    public function remove_fee( $name ) {
685
+
686
+        if ( isset( $this->fees[ $name ] ) ) {
687
+            $this->totals['fees']['initial']   -= $this->fees[ $name ]['initial_fee'];
688
+            $this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee'];
689
+            unset( $this->fees[ $name ] );
690
+        }
691
+
692
+    }
693
+
694
+    /**
695
+     * Returns the fees.
696
+     *
697
+     * @since 1.0.19
698
+     */
699
+    public function get_fee() {
700
+        return $this->totals['fees']['initial'];
701
+    }
702
+
703
+    /**
704
+     * Returns the recurring fees.
705
+     *
706
+     * @since 1.0.19
707
+     */
708
+    public function get_recurring_fee() {
709
+        return $this->totals['fees']['recurring'];
710
+    }
711
+
712
+    /**
713
+     * Returns all fees.
714
+     *
715
+     * @since 1.0.19
716
+     */
717
+    public function get_fees() {
718
+        return $this->fees;
719
+    }
720
+
721
+    /**
722
+     * Checks if there are any fees for the form.
723
+     *
724
+     * @return bool
725
+     * @since 1.0.19
726
+     */
727
+    public function has_fees() {
728
+        return count( $this->fees ) !== 0;
729
+    }
730
+
731
+    /*
732 732
 	|--------------------------------------------------------------------------
733 733
 	| MISC
734 734
 	|--------------------------------------------------------------------------
@@ -736,109 +736,109 @@  discard block
 block discarded – undo
736 736
 	| Extra submission functions.
737 737
     */
738 738
 
739
-	/**
740
-	 * Returns the total amount to collect for this submission.
741
-	 *
742
-	 * @since 1.0.19
743
-	 */
744
-	public function get_total() {
745
-		$total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() - $this->get_discount();
746
-		return max( $total, 0 );
747
-	}
748
-
749
-	/**
750
-	 * Returns the recurring total amount to collect for this submission.
751
-	 *
752
-	 * @since 1.0.19
753
-	 */
754
-	public function get_recurring_total() {
755
-		$total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() - $this->get_recurring_discount();
756
-		return max( $total, 0 );
757
-	}
758
-
759
-	/**
760
-	 * Whether payment details should be collected for this submission.
761
-	 *
762
-	 * @since 1.0.19
763
-	 */
764
-	public function should_collect_payment_details() {
765
-		$initial   = $this->get_total();
766
-		$recurring = $this->get_recurring_total();
767
-
768
-		if ( $this->has_recurring == 0 ) {
769
-			$recurring = 0;
770
-		}
771
-
772
-		$collect = $initial > 0 || $recurring > 0;
773
-		return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this  );
774
-	}
775
-
776
-	/**
777
-	 * Returns the billing email of the user.
778
-	 *
779
-	 * @since 1.0.19
780
-	 */
781
-	public function get_billing_email() {
782
-		return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this  );
783
-	}
784
-
785
-	/**
786
-	 * Checks if the submitter has a billing email.
787
-	 *
788
-	 * @since 1.0.19
789
-	 */
790
-	public function has_billing_email() {
791
-		$billing_email = $this->get_billing_email();
792
-		return ! empty( $billing_email ) && is_email( $billing_email );
793
-	}
794
-
795
-	/**
796
-	 * Returns the appropriate currency for the submission.
797
-	 *
798
-	 * @since 1.0.19
799
-	 * @return string
800
-	 */
801
-	public function get_currency() {
802
-		return $this->has_invoice() ? $this->invoice->get_currency() : wpinv_get_currency();
803
-    }
804
-
805
-    /**
806
-	 * Returns the raw submission data.
807
-	 *
808
-	 * @since 1.0.19
809
-	 * @return array
810
-	 */
811
-	public function get_data() {
812
-		return $this->data;
813
-	}
814
-
815
-	/**
816
-	 * Returns a field from the submission data
817
-	 *
818
-	 * @param string $field
819
-	 * @since 1.0.19
820
-	 * @return mixed|null
821
-	 */
822
-	public function get_field( $field, $sub_array_key = null ) {
823
-		return getpaid_get_array_field( $this->data, $field, $sub_array_key );
824
-	}
825
-
826
-	/**
827
-	 * Checks if a required field is set.
828
-	 *
829
-	 * @since 1.0.19
830
-	 */
831
-	public function is_required_field_set( $field ) {
832
-		return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
833
-	}
834
-
835
-	/**
836
-	 * Formats an amount
837
-	 *
838
-	 * @since 1.0.19
839
-	 */
840
-	public function format_amount( $amount ) {
841
-		return wpinv_price( $amount, $this->get_currency() );
842
-	}
739
+    /**
740
+     * Returns the total amount to collect for this submission.
741
+     *
742
+     * @since 1.0.19
743
+     */
744
+    public function get_total() {
745
+        $total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() - $this->get_discount();
746
+        return max( $total, 0 );
747
+    }
748
+
749
+    /**
750
+     * Returns the recurring total amount to collect for this submission.
751
+     *
752
+     * @since 1.0.19
753
+     */
754
+    public function get_recurring_total() {
755
+        $total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() - $this->get_recurring_discount();
756
+        return max( $total, 0 );
757
+    }
758
+
759
+    /**
760
+     * Whether payment details should be collected for this submission.
761
+     *
762
+     * @since 1.0.19
763
+     */
764
+    public function should_collect_payment_details() {
765
+        $initial   = $this->get_total();
766
+        $recurring = $this->get_recurring_total();
767
+
768
+        if ( $this->has_recurring == 0 ) {
769
+            $recurring = 0;
770
+        }
771
+
772
+        $collect = $initial > 0 || $recurring > 0;
773
+        return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this  );
774
+    }
775
+
776
+    /**
777
+     * Returns the billing email of the user.
778
+     *
779
+     * @since 1.0.19
780
+     */
781
+    public function get_billing_email() {
782
+        return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this  );
783
+    }
784
+
785
+    /**
786
+     * Checks if the submitter has a billing email.
787
+     *
788
+     * @since 1.0.19
789
+     */
790
+    public function has_billing_email() {
791
+        $billing_email = $this->get_billing_email();
792
+        return ! empty( $billing_email ) && is_email( $billing_email );
793
+    }
794
+
795
+    /**
796
+     * Returns the appropriate currency for the submission.
797
+     *
798
+     * @since 1.0.19
799
+     * @return string
800
+     */
801
+    public function get_currency() {
802
+        return $this->has_invoice() ? $this->invoice->get_currency() : wpinv_get_currency();
803
+    }
804
+
805
+    /**
806
+     * Returns the raw submission data.
807
+     *
808
+     * @since 1.0.19
809
+     * @return array
810
+     */
811
+    public function get_data() {
812
+        return $this->data;
813
+    }
814
+
815
+    /**
816
+     * Returns a field from the submission data
817
+     *
818
+     * @param string $field
819
+     * @since 1.0.19
820
+     * @return mixed|null
821
+     */
822
+    public function get_field( $field, $sub_array_key = null ) {
823
+        return getpaid_get_array_field( $this->data, $field, $sub_array_key );
824
+    }
825
+
826
+    /**
827
+     * Checks if a required field is set.
828
+     *
829
+     * @since 1.0.19
830
+     */
831
+    public function is_required_field_set( $field ) {
832
+        return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
833
+    }
834
+
835
+    /**
836
+     * Formats an amount
837
+     *
838
+     * @since 1.0.19
839
+     */
840
+    public function format_amount( $amount ) {
841
+        return wpinv_price( $amount, $this->get_currency() );
842
+    }
843 843
 
844 844
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-taxes.php 1 patch
Indentation   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -12,213 +12,213 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Taxes {
14 14
 
15
-	/**
16
-	 * Submission taxes.
17
-	 * @var array
18
-	 */
19
-	public $taxes = array();
15
+    /**
16
+     * Submission taxes.
17
+     * @var array
18
+     */
19
+    public $taxes = array();
20
+
21
+    /**
22
+     * Class constructor
23
+     *
24
+     * @param GetPaid_Payment_Form_Submission $submission
25
+     */
26
+    public function __construct( $submission ) {
27
+
28
+        // Validate VAT number.
29
+        $this->validate_vat( $submission );
30
+
31
+        foreach ( $submission->get_items() as $item ) {
32
+            $this->process_item_tax( $item, $submission );
33
+        }
34
+
35
+        // Process any existing invoice taxes.
36
+        if ( $submission->has_invoice() ) {
37
+            $this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes );
38
+        }
39
+
40
+    }
41
+
42
+    /**
43
+     * Maybe process tax.
44
+     *
45
+     * @since 1.0.19
46
+     * @param GetPaid_Form_Item $item
47
+     * @param GetPaid_Payment_Form_Submission $submission
48
+     */
49
+    public function process_item_tax( $item, $submission ) {
50
+
51
+        $rates    = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state );
52
+        $taxes    = getpaid_calculate_item_taxes( $item->get_sub_total(), $rates );
53
+        $r_taxes  = getpaid_calculate_item_taxes( $item->get_recurring_sub_total(), $rates );
54
+
55
+        foreach ( $taxes as $name => $amount ) {
56
+            $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
57
+            $tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
58
+
59
+            if ( ! isset( $this->taxes[ $name ] ) ) {
60
+                $this->taxes[ $name ] = $tax;
61
+                continue;
62
+            }
63
+
64
+            $this->taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
65
+            $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
66
+
67
+        }
68
+
69
+    }
70
+
71
+    /**
72
+     * Checks if the submission has a digital item.
73
+     *
74
+     * @param GetPaid_Payment_Form_Submission $submission
75
+     * @since 1.0.19
76
+     * @return bool
77
+     */
78
+    public function has_digital_item( $submission ) {
79
+
80
+        foreach ( $submission->get_items() as $item ) {
81
+
82
+            if ( 'digital' == $item->get_vat_rule() ) {
83
+                return true;
84
+            }
85
+
86
+        }
87
+
88
+        return false;
89
+    }
90
+
91
+    /**
92
+     * Checks if this is an eu store.
93
+     *
94
+     * @since 1.0.19
95
+     * @return bool
96
+     */
97
+    public function is_eu_store() {
98
+        return $this->is_eu_country( wpinv_get_default_country() );
99
+    }
100
+
101
+    /**
102
+     * Checks if this is an eu country.
103
+     *
104
+     * @param string $country
105
+     * @since 1.0.19
106
+     * @return bool
107
+     */
108
+    public function is_eu_country( $country ) {
109
+        return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country );
110
+    }
111
+
112
+    /**
113
+     * Checks if this is an eu purchase.
114
+     *
115
+     * @param string $customer_country
116
+     * @since 1.0.19
117
+     * @return bool
118
+     */
119
+    public function is_eu_transaction( $customer_country ) {
120
+        return $this->is_eu_country( $customer_country ) && $this->is_eu_store();
121
+    }
122
+
123
+    /**
124
+     * Retrieves the vat number.
125
+     *
126
+     * @param GetPaid_Payment_Form_Submission $submission
127
+     * @since 1.0.19
128
+     * @return string
129
+     */
130
+    public function get_vat_number( $submission ) {
131
+
132
+        // Retrieve from the posted number.
133
+        $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' );
134
+        if ( ! empty( $vat_number ) ) {
135
+            return wpinv_clean( $vat_number );
136
+        }
137
+
138
+        // Retrieve from the invoice.
139
+        return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : '';
140
+    }
141
+
142
+    /**
143
+     * Retrieves the company.
144
+     *
145
+     * @param GetPaid_Payment_Form_Submission $submission
146
+     * @since 1.0.19
147
+     * @return string
148
+     */
149
+    public function get_company( $submission ) {
150
+
151
+        // Retrieve from the posted data.
152
+        $company = $submission->get_field( 'wpinv_company', 'billing' );
153
+        if ( ! empty( $company ) ) {
154
+            return wpinv_clean( $company );
155
+        }
156
+
157
+        // Retrieve from the invoice.
158
+        return $submission->has_invoice() ? $submission->get_invoice()->get_company() : '';
159
+    }
160
+
161
+    /**
162
+     * Checks if we require a VAT number.
163
+     *
164
+     * @param bool $ip_in_eu Whether the customer IP is from the EU
165
+     * @param bool $country_in_eu Whether the customer country is from the EU
166
+     * @since 1.0.19
167
+     * @return string
168
+     */
169
+    public function requires_vat( $ip_in_eu, $country_in_eu ) {
170
+
171
+        $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
172
+        $prevent_b2c = ! empty( $prevent_b2c );
173
+        $is_eu       = $ip_in_eu || $country_in_eu;
174
+
175
+        return $prevent_b2c && $is_eu;
176
+    }
20 177
 
21 178
     /**
22
-	 * Class constructor
23
-	 *
24
-	 * @param GetPaid_Payment_Form_Submission $submission
25
-	 */
26
-	public function __construct( $submission ) {
27
-
28
-		// Validate VAT number.
29
-		$this->validate_vat( $submission );
30
-
31
-		foreach ( $submission->get_items() as $item ) {
32
-			$this->process_item_tax( $item, $submission );
33
-		}
34
-
35
-		// Process any existing invoice taxes.
36
-		if ( $submission->has_invoice() ) {
37
-			$this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes );
38
-		}
39
-
40
-	}
41
-
42
-	/**
43
-	 * Maybe process tax.
44
-	 *
45
-	 * @since 1.0.19
46
-	 * @param GetPaid_Form_Item $item
47
-	 * @param GetPaid_Payment_Form_Submission $submission
48
-	 */
49
-	public function process_item_tax( $item, $submission ) {
50
-
51
-		$rates    = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state );
52
-		$taxes    = getpaid_calculate_item_taxes( $item->get_sub_total(), $rates );
53
-		$r_taxes  = getpaid_calculate_item_taxes( $item->get_recurring_sub_total(), $rates );
54
-
55
-		foreach ( $taxes as $name => $amount ) {
56
-			$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
57
-			$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
58
-
59
-			if ( ! isset( $this->taxes[ $name ] ) ) {
60
-				$this->taxes[ $name ] = $tax;
61
-				continue;
62
-			}
63
-
64
-			$this->taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
65
-			$this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
66
-
67
-		}
68
-
69
-	}
70
-
71
-	/**
72
-	 * Checks if the submission has a digital item.
73
-	 *
74
-	 * @param GetPaid_Payment_Form_Submission $submission
75
-	 * @since 1.0.19
76
-	 * @return bool
77
-	 */
78
-	public function has_digital_item( $submission ) {
79
-
80
-		foreach ( $submission->get_items() as $item ) {
81
-
82
-			if ( 'digital' == $item->get_vat_rule() ) {
83
-				return true;
84
-			}
85
-
86
-		}
87
-
88
-		return false;
89
-	}
90
-
91
-	/**
92
-	 * Checks if this is an eu store.
93
-	 *
94
-	 * @since 1.0.19
95
-	 * @return bool
96
-	 */
97
-	public function is_eu_store() {
98
-		return $this->is_eu_country( wpinv_get_default_country() );
99
-	}
100
-
101
-	/**
102
-	 * Checks if this is an eu country.
103
-	 *
104
-	 * @param string $country
105
-	 * @since 1.0.19
106
-	 * @return bool
107
-	 */
108
-	public function is_eu_country( $country ) {
109
-		return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country );
110
-	}
111
-
112
-	/**
113
-	 * Checks if this is an eu purchase.
114
-	 *
115
-	 * @param string $customer_country
116
-	 * @since 1.0.19
117
-	 * @return bool
118
-	 */
119
-	public function is_eu_transaction( $customer_country ) {
120
-		return $this->is_eu_country( $customer_country ) && $this->is_eu_store();
121
-	}
122
-
123
-	/**
124
-	 * Retrieves the vat number.
125
-	 *
126
-	 * @param GetPaid_Payment_Form_Submission $submission
127
-	 * @since 1.0.19
128
-	 * @return string
129
-	 */
130
-	public function get_vat_number( $submission ) {
131
-
132
-		// Retrieve from the posted number.
133
-		$vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' );
134
-		if ( ! empty( $vat_number ) ) {
135
-			return wpinv_clean( $vat_number );
136
-		}
137
-
138
-		// Retrieve from the invoice.
139
-		return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : '';
140
-	}
141
-
142
-	/**
143
-	 * Retrieves the company.
144
-	 *
145
-	 * @param GetPaid_Payment_Form_Submission $submission
146
-	 * @since 1.0.19
147
-	 * @return string
148
-	 */
149
-	public function get_company( $submission ) {
150
-
151
-		// Retrieve from the posted data.
152
-		$company = $submission->get_field( 'wpinv_company', 'billing' );
153
-		if ( ! empty( $company ) ) {
154
-			return wpinv_clean( $company );
155
-		}
156
-
157
-		// Retrieve from the invoice.
158
-		return $submission->has_invoice() ? $submission->get_invoice()->get_company() : '';
159
-	}
160
-
161
-	/**
162
-	 * Checks if we require a VAT number.
163
-	 *
164
-	 * @param bool $ip_in_eu Whether the customer IP is from the EU
165
-	 * @param bool $country_in_eu Whether the customer country is from the EU
166
-	 * @since 1.0.19
167
-	 * @return string
168
-	 */
169
-	public function requires_vat( $ip_in_eu, $country_in_eu ) {
170
-
171
-		$prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
172
-		$prevent_b2c = ! empty( $prevent_b2c );
173
-		$is_eu       = $ip_in_eu || $country_in_eu;
174
-
175
-		return $prevent_b2c && $is_eu;
176
-	}
177
-
178
-	/**
179
-	 * Validate VAT data.
180
-	 *
181
-	 * @param GetPaid_Payment_Form_Submission $submission
182
-	 * @since 1.0.19
183
-	 */
184
-	public function validate_vat( $submission ) {
185
-
186
-		$has_digital = $this->has_digital_item( $submission );
187
-		$in_eu       = $this->is_eu_transaction( $submission->country );
188
-
189
-		// Abort if we are not validating vat numbers.
190
-		if ( ! $has_digital && ! $in_eu ) {
179
+     * Validate VAT data.
180
+     *
181
+     * @param GetPaid_Payment_Form_Submission $submission
182
+     * @since 1.0.19
183
+     */
184
+    public function validate_vat( $submission ) {
185
+
186
+        $has_digital = $this->has_digital_item( $submission );
187
+        $in_eu       = $this->is_eu_transaction( $submission->country );
188
+
189
+        // Abort if we are not validating vat numbers.
190
+        if ( ! $has_digital && ! $in_eu ) {
191 191
             return;
192
-		}
192
+        }
193 193
 
194
-		// Prepare variables.
195
-		$vat_number  = $this->get_vat_number( $submission );
196
-		$ip_country  = getpaid_get_ip_country();
194
+        // Prepare variables.
195
+        $vat_number  = $this->get_vat_number( $submission );
196
+        $ip_country  = getpaid_get_ip_country();
197 197
         $is_eu       = $this->is_eu_country( $submission->country );
198 198
         $is_ip_eu    = $this->is_eu_country( $ip_country );
199 199
 
200
-		// If we're preventing business to consumer purchases, ensure
201
-		if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
200
+        // If we're preventing business to consumer purchases, ensure
201
+        if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
202 202
 
203
-			// Ensure that a vat number has been specified.
204
-			throw new Exception(
205
-				wp_sprintf(
206
-					__( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
207
-					getpaid_vat_name()
208
-				)
209
-			);
203
+            // Ensure that a vat number has been specified.
204
+            throw new Exception(
205
+                wp_sprintf(
206
+                    __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
207
+                    getpaid_vat_name()
208
+                )
209
+            );
210 210
 
211
-		}
211
+        }
212 212
 
213
-		// Abort if we are not validating vat (vat number should exist, user should be in eu and business too).
214
-		if ( ! $is_eu || ! $in_eu || empty( $vat_number ) ) {
213
+        // Abort if we are not validating vat (vat number should exist, user should be in eu and business too).
214
+        if ( ! $is_eu || ! $in_eu || empty( $vat_number ) ) {
215 215
             return;
216
-		}
216
+        }
217 217
 
218
-		if ( ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) {
219
-			throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) );
220
-		}
218
+        if ( ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) {
219
+            throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) );
220
+        }
221 221
 
222
-	}
222
+    }
223 223
 
224 224
 }
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 1 patch
Indentation   +2360 added lines, -2360 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,165 +1341,165 @@  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 (float) $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 (float) $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 (float) $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 (float) $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 (float) $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 (float) $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 1444
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1445
-	}
1445
+    }
1446 1446
 
1447
-	/**
1448
-	 * Get the recurring invoice total.
1449
-	 *
1450
-	 * @since 1.0.19
1447
+    /**
1448
+     * Get the recurring invoice total.
1449
+     *
1450
+     * @since 1.0.19
1451 1451
      * @param  string $context View or edit context.
1452 1452
      * @return float
1453
-	 */
1453
+     */
1454 1454
     public function get_recurring_total() {
1455 1455
 
1456
-		if ( empty( $this->totals ) ) {
1457
-			$this->recalculate_total();
1458
-		}
1456
+        if ( empty( $this->totals ) ) {
1457
+            $this->recalculate_total();
1458
+        }
1459 1459
 
1460
-		$tax      = $this->totals['tax']['recurring'];
1461
-		$fee      = $this->totals['fee']['recurring'];
1462
-		$discount = $this->totals['discount']['recurring'];
1463
-		$subtotal = $this->totals['subtotal']['recurring'];
1464
-		$total    = $tax + $fee - $discount + $subtotal;
1460
+        $tax      = $this->totals['tax']['recurring'];
1461
+        $fee      = $this->totals['fee']['recurring'];
1462
+        $discount = $this->totals['discount']['recurring'];
1463
+        $subtotal = $this->totals['subtotal']['recurring'];
1464
+        $total    = $tax + $fee - $discount + $subtotal;
1465 1465
 
1466
-		if ( 0 > $total ) {
1467
-			$total = 0;
1468
-		}
1466
+        if ( 0 > $total ) {
1467
+            $total = 0;
1468
+        }
1469 1469
 
1470 1470
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1471
-	}
1471
+    }
1472 1472
 
1473
-	/**
1474
-	 * Returns recurring payment details.
1475
-	 *
1476
-	 * @since 1.0.19
1473
+    /**
1474
+     * Returns recurring payment details.
1475
+     *
1476
+     * @since 1.0.19
1477 1477
      * @param  string $field Optionally provide a field to return.
1478
-	 * @param string $currency Whether to include the currency.
1478
+     * @param string $currency Whether to include the currency.
1479 1479
      * @return float|string
1480
-	 */
1480
+     */
1481 1481
     public function get_recurring_details( $field = '', $currency = false ) {
1482 1482
 
1483
-		// Maybe recalculate totals.
1484
-		if ( empty( $this->totals ) ) {
1485
-			$this->recalculate_total();
1486
-		}
1483
+        // Maybe recalculate totals.
1484
+        if ( empty( $this->totals ) ) {
1485
+            $this->recalculate_total();
1486
+        }
1487 1487
 
1488
-		// Prepare recurring totals.
1488
+        // Prepare recurring totals.
1489 1489
         $data = apply_filters(
1490
-			'wpinv_get_invoice_recurring_details',
1491
-			array(
1492
-				'cart_details' => $this->get_cart_details(),
1493
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1494
-				'discount'     => $this->totals['discount']['recurring'],
1495
-				'tax'          => $this->totals['tax']['recurring'],
1496
-				'fee'          => $this->totals['fee']['recurring'],
1497
-				'total'        => $this->get_recurring_total(),
1498
-			),
1499
-			$this,
1500
-			$field,
1501
-			$currency
1502
-		);
1490
+            'wpinv_get_invoice_recurring_details',
1491
+            array(
1492
+                'cart_details' => $this->get_cart_details(),
1493
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1494
+                'discount'     => $this->totals['discount']['recurring'],
1495
+                'tax'          => $this->totals['tax']['recurring'],
1496
+                'fee'          => $this->totals['fee']['recurring'],
1497
+                'total'        => $this->get_recurring_total(),
1498
+            ),
1499
+            $this,
1500
+            $field,
1501
+            $currency
1502
+        );
1503 1503
 
1504 1504
         if ( isset( $data[$field] ) ) {
1505 1505
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1509,166 +1509,166 @@  discard block
 block discarded – undo
1509 1509
     }
1510 1510
 
1511 1511
     /**
1512
-	 * Get the invoice fees.
1513
-	 *
1514
-	 * @since 1.0.19
1515
-	 * @param  string $context View or edit context.
1516
-	 * @return array
1517
-	 */
1518
-	public function get_fees( $context = 'view' ) {
1519
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1512
+     * Get the invoice fees.
1513
+     *
1514
+     * @since 1.0.19
1515
+     * @param  string $context View or edit context.
1516
+     * @return array
1517
+     */
1518
+    public function get_fees( $context = 'view' ) {
1519
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1520 1520
     }
1521 1521
 
1522 1522
     /**
1523
-	 * Get the invoice discounts.
1524
-	 *
1525
-	 * @since 1.0.19
1526
-	 * @param  string $context View or edit context.
1527
-	 * @return array
1528
-	 */
1529
-	public function get_discounts( $context = 'view' ) {
1530
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1523
+     * Get the invoice discounts.
1524
+     *
1525
+     * @since 1.0.19
1526
+     * @param  string $context View or edit context.
1527
+     * @return array
1528
+     */
1529
+    public function get_discounts( $context = 'view' ) {
1530
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1531 1531
     }
1532 1532
 
1533 1533
     /**
1534
-	 * Get the invoice taxes.
1535
-	 *
1536
-	 * @since 1.0.19
1537
-	 * @param  string $context View or edit context.
1538
-	 * @return array
1539
-	 */
1540
-	public function get_taxes( $context = 'view' ) {
1541
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1534
+     * Get the invoice taxes.
1535
+     *
1536
+     * @since 1.0.19
1537
+     * @param  string $context View or edit context.
1538
+     * @return array
1539
+     */
1540
+    public function get_taxes( $context = 'view' ) {
1541
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1542 1542
     }
1543 1543
 
1544 1544
     /**
1545
-	 * Get the invoice items.
1546
-	 *
1547
-	 * @since 1.0.19
1548
-	 * @param  string $context View or edit context.
1549
-	 * @return GetPaid_Form_Item[]
1550
-	 */
1551
-	public function get_items( $context = 'view' ) {
1545
+     * Get the invoice items.
1546
+     *
1547
+     * @since 1.0.19
1548
+     * @param  string $context View or edit context.
1549
+     * @return GetPaid_Form_Item[]
1550
+     */
1551
+    public function get_items( $context = 'view' ) {
1552 1552
         return $this->get_prop( 'items', $context );
1553
-	}
1553
+    }
1554 1554
 	
1555
-	/**
1556
-	 * Get the invoice item ids.
1557
-	 *
1558
-	 * @since 1.0.19
1559
-	 * @return string
1560
-	 */
1561
-	public function get_item_ids() {
1562
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1555
+    /**
1556
+     * Get the invoice item ids.
1557
+     *
1558
+     * @since 1.0.19
1559
+     * @return string
1560
+     */
1561
+    public function get_item_ids() {
1562
+        return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1563 1563
     }
1564 1564
 
1565 1565
     /**
1566
-	 * Get the invoice's payment form.
1567
-	 *
1568
-	 * @since 1.0.19
1569
-	 * @param  string $context View or edit context.
1570
-	 * @return int
1571
-	 */
1572
-	public function get_payment_form( $context = 'view' ) {
1573
-		return intval( $this->get_prop( 'payment_form', $context ) );
1566
+     * Get the invoice's payment form.
1567
+     *
1568
+     * @since 1.0.19
1569
+     * @param  string $context View or edit context.
1570
+     * @return int
1571
+     */
1572
+    public function get_payment_form( $context = 'view' ) {
1573
+        return intval( $this->get_prop( 'payment_form', $context ) );
1574 1574
     }
1575 1575
 
1576 1576
     /**
1577
-	 * Get the invoice's submission id.
1578
-	 *
1579
-	 * @since 1.0.19
1580
-	 * @param  string $context View or edit context.
1581
-	 * @return string
1582
-	 */
1583
-	public function get_submission_id( $context = 'view' ) {
1584
-		return $this->get_prop( 'submission_id', $context );
1577
+     * Get the invoice's submission id.
1578
+     *
1579
+     * @since 1.0.19
1580
+     * @param  string $context View or edit context.
1581
+     * @return string
1582
+     */
1583
+    public function get_submission_id( $context = 'view' ) {
1584
+        return $this->get_prop( 'submission_id', $context );
1585 1585
     }
1586 1586
 
1587 1587
     /**
1588
-	 * Get the invoice's discount code.
1589
-	 *
1590
-	 * @since 1.0.19
1591
-	 * @param  string $context View or edit context.
1592
-	 * @return string
1593
-	 */
1594
-	public function get_discount_code( $context = 'view' ) {
1595
-		return $this->get_prop( 'discount_code', $context );
1588
+     * Get the invoice's discount code.
1589
+     *
1590
+     * @since 1.0.19
1591
+     * @param  string $context View or edit context.
1592
+     * @return string
1593
+     */
1594
+    public function get_discount_code( $context = 'view' ) {
1595
+        return $this->get_prop( 'discount_code', $context );
1596 1596
     }
1597 1597
 
1598 1598
     /**
1599
-	 * Get the invoice's gateway.
1600
-	 *
1601
-	 * @since 1.0.19
1602
-	 * @param  string $context View or edit context.
1603
-	 * @return string
1604
-	 */
1605
-	public function get_gateway( $context = 'view' ) {
1606
-		return $this->get_prop( 'gateway', $context );
1599
+     * Get the invoice's gateway.
1600
+     *
1601
+     * @since 1.0.19
1602
+     * @param  string $context View or edit context.
1603
+     * @return string
1604
+     */
1605
+    public function get_gateway( $context = 'view' ) {
1606
+        return $this->get_prop( 'gateway', $context );
1607 1607
     }
1608 1608
 
1609 1609
     /**
1610
-	 * Get the invoice's gateway display title.
1611
-	 *
1612
-	 * @since 1.0.19
1613
-	 * @return string
1614
-	 */
1610
+     * Get the invoice's gateway display title.
1611
+     *
1612
+     * @since 1.0.19
1613
+     * @return string
1614
+     */
1615 1615
     public function get_gateway_title() {
1616 1616
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1617 1617
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1618 1618
     }
1619 1619
 
1620 1620
     /**
1621
-	 * Get the invoice's transaction id.
1622
-	 *
1623
-	 * @since 1.0.19
1624
-	 * @param  string $context View or edit context.
1625
-	 * @return string
1626
-	 */
1627
-	public function get_transaction_id( $context = 'view' ) {
1628
-		return $this->get_prop( 'transaction_id', $context );
1621
+     * Get the invoice's transaction id.
1622
+     *
1623
+     * @since 1.0.19
1624
+     * @param  string $context View or edit context.
1625
+     * @return string
1626
+     */
1627
+    public function get_transaction_id( $context = 'view' ) {
1628
+        return $this->get_prop( 'transaction_id', $context );
1629 1629
     }
1630 1630
 
1631 1631
     /**
1632
-	 * Get the invoice's currency.
1633
-	 *
1634
-	 * @since 1.0.19
1635
-	 * @param  string $context View or edit context.
1636
-	 * @return string
1637
-	 */
1638
-	public function get_currency( $context = 'view' ) {
1632
+     * Get the invoice's currency.
1633
+     *
1634
+     * @since 1.0.19
1635
+     * @param  string $context View or edit context.
1636
+     * @return string
1637
+     */
1638
+    public function get_currency( $context = 'view' ) {
1639 1639
         $currency = $this->get_prop( 'currency', $context );
1640 1640
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1641 1641
     }
1642 1642
 
1643 1643
     /**
1644
-	 * Checks if we are charging taxes for this invoice.
1645
-	 *
1646
-	 * @since 1.0.19
1647
-	 * @param  string $context View or edit context.
1648
-	 * @return bool
1649
-	 */
1650
-	public function get_disable_taxes( $context = 'view' ) {
1644
+     * Checks if we are charging taxes for this invoice.
1645
+     *
1646
+     * @since 1.0.19
1647
+     * @param  string $context View or edit context.
1648
+     * @return bool
1649
+     */
1650
+    public function get_disable_taxes( $context = 'view' ) {
1651 1651
         return (bool) $this->get_prop( 'disable_taxes', $context );
1652 1652
     }
1653 1653
 
1654 1654
     /**
1655
-	 * Retrieves the subscription id for an invoice.
1656
-	 *
1657
-	 * @since 1.0.19
1658
-	 * @param  string $context View or edit context.
1659
-	 * @return int
1660
-	 */
1655
+     * Retrieves the subscription id for an invoice.
1656
+     *
1657
+     * @since 1.0.19
1658
+     * @param  string $context View or edit context.
1659
+     * @return int
1660
+     */
1661 1661
     public function get_subscription_id( $context = 'view' ) {
1662
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1663
-	}
1664
-
1665
-	/**
1666
-	 * Retrieves the remote subscription id for an invoice.
1667
-	 *
1668
-	 * @since 1.0.19
1669
-	 * @param  string $context View or edit context.
1670
-	 * @return int
1671
-	 */
1662
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1663
+    }
1664
+
1665
+    /**
1666
+     * Retrieves the remote subscription id for an invoice.
1667
+     *
1668
+     * @since 1.0.19
1669
+     * @param  string $context View or edit context.
1670
+     * @return int
1671
+     */
1672 1672
     public function get_remote_subscription_id( $context = 'view' ) {
1673 1673
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1674 1674
 
@@ -1681,12 +1681,12 @@  discard block
 block discarded – undo
1681 1681
     }
1682 1682
 
1683 1683
     /**
1684
-	 * Retrieves the payment meta for an invoice.
1685
-	 *
1686
-	 * @since 1.0.19
1687
-	 * @param  string $context View or edit context.
1688
-	 * @return array
1689
-	 */
1684
+     * Retrieves the payment meta for an invoice.
1685
+     *
1686
+     * @since 1.0.19
1687
+     * @param  string $context View or edit context.
1688
+     * @return array
1689
+     */
1690 1690
     public function get_payment_meta( $context = 'view' ) {
1691 1691
 
1692 1692
         return array(
@@ -1706,31 +1706,31 @@  discard block
 block discarded – undo
1706 1706
     }
1707 1707
 
1708 1708
     /**
1709
-	 * Retrieves the cart details for an invoice.
1710
-	 *
1711
-	 * @since 1.0.19
1712
-	 * @return array
1713
-	 */
1709
+     * Retrieves the cart details for an invoice.
1710
+     *
1711
+     * @since 1.0.19
1712
+     * @return array
1713
+     */
1714 1714
     public function get_cart_details() {
1715 1715
         $items        = $this->get_items();
1716 1716
         $cart_details = array();
1717 1717
 
1718 1718
         foreach ( $items as $item ) {
1719
-			$item->invoice_id = $this->get_id();
1719
+            $item->invoice_id = $this->get_id();
1720 1720
             $cart_details[]   = $item->prepare_data_for_saving();
1721 1721
         }
1722 1722
 
1723 1723
         return $cart_details;
1724
-	}
1724
+    }
1725 1725
 
1726
-	/**
1727
-	 * Retrieves the recurring item.
1728
-	 *
1729
-	 * @return null|GetPaid_Form_Item|int
1730
-	 */
1731
-	public function get_recurring( $object = false ) {
1726
+    /**
1727
+     * Retrieves the recurring item.
1728
+     *
1729
+     * @return null|GetPaid_Form_Item|int
1730
+     */
1731
+    public function get_recurring( $object = false ) {
1732 1732
 
1733
-		// Are we returning an object?
1733
+        // Are we returning an object?
1734 1734
         if ( $object ) {
1735 1735
             return $this->get_item( $this->recurring_item );
1736 1736
         }
@@ -1738,114 +1738,114 @@  discard block
 block discarded – undo
1738 1738
         return $this->recurring_item;
1739 1739
     }
1740 1740
 
1741
-	/**
1742
-	 * Retrieves the subscription name.
1743
-	 *
1744
-	 * @since 1.0.19
1745
-	 * @return string
1746
-	 */
1747
-	public function get_subscription_name() {
1741
+    /**
1742
+     * Retrieves the subscription name.
1743
+     *
1744
+     * @since 1.0.19
1745
+     * @return string
1746
+     */
1747
+    public function get_subscription_name() {
1748 1748
 
1749
-		// Retrieve the recurring name
1749
+        // Retrieve the recurring name
1750 1750
         $item = $this->get_recurring( true );
1751 1751
 
1752
-		// Abort if it does not exist.
1752
+        // Abort if it does not exist.
1753 1753
         if ( empty( $item ) ) {
1754 1754
             return '';
1755 1755
         }
1756 1756
 
1757
-		// Return the item name.
1757
+        // Return the item name.
1758 1758
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1759
-	}
1760
-
1761
-	/**
1762
-	 * Retrieves the view url.
1763
-	 *
1764
-	 * @since 1.0.19
1765
-	 * @return string
1766
-	 */
1767
-	public function get_view_url() {
1759
+    }
1760
+
1761
+    /**
1762
+     * Retrieves the view url.
1763
+     *
1764
+     * @since 1.0.19
1765
+     * @return string
1766
+     */
1767
+    public function get_view_url() {
1768 1768
         $invoice_url = get_permalink( $this->get_id() );
1769
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1769
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1770 1770
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1771
-	}
1771
+    }
1772 1772
 
1773
-	/**
1774
-	 * Retrieves the payment url.
1775
-	 *
1776
-	 * @since 1.0.19
1777
-	 * @return string
1778
-	 */
1779
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1773
+    /**
1774
+     * Retrieves the payment url.
1775
+     *
1776
+     * @since 1.0.19
1777
+     * @return string
1778
+     */
1779
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1780 1780
 
1781
-		// Retrieve the checkout url.
1781
+        // Retrieve the checkout url.
1782 1782
         $pay_url = wpinv_get_checkout_uri();
1783 1783
 
1784
-		// Maybe force ssl.
1784
+        // Maybe force ssl.
1785 1785
         if ( is_ssl() ) {
1786 1786
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1787 1787
         }
1788 1788
 
1789
-		// Add the invoice key.
1790
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1789
+        // Add the invoice key.
1790
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1791 1791
 
1792
-		// (Maybe?) add a secret
1792
+        // (Maybe?) add a secret
1793 1793
         if ( $secret ) {
1794 1794
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1795 1795
         }
1796 1796
 
1797 1797
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1798
-	}
1798
+    }
1799 1799
 	
1800
-	/**
1801
-	 * Retrieves the receipt url.
1802
-	 *
1803
-	 * @since 1.0.19
1804
-	 * @return string
1805
-	 */
1806
-	public function get_receipt_url() {
1807
-
1808
-		// Retrieve the checkout url.
1800
+    /**
1801
+     * Retrieves the receipt url.
1802
+     *
1803
+     * @since 1.0.19
1804
+     * @return string
1805
+     */
1806
+    public function get_receipt_url() {
1807
+
1808
+        // Retrieve the checkout url.
1809 1809
         $receipt_url = wpinv_get_success_page_uri();
1810 1810
 
1811
-		// Maybe force ssl.
1811
+        // Maybe force ssl.
1812 1812
         if ( is_ssl() ) {
1813 1813
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1814 1814
         }
1815 1815
 
1816
-		// Add the invoice key.
1817
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1816
+        // Add the invoice key.
1817
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1818 1818
 
1819 1819
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1820
-	}
1820
+    }
1821 1821
 	
1822
-	/**
1823
-	 * Retrieves the default status.
1824
-	 *
1825
-	 * @since 1.0.19
1826
-	 * @return string
1827
-	 */
1828
-	public function get_default_status() {
1829
-
1830
-		$type   = $this->get_type();
1831
-		$status = "wpi-$type-pending";
1832
-		return str_replace( '-invoice', '', $status );
1833
-
1834
-	}
1835
-
1836
-    /**
1837
-	 * Magic method for accessing invoice properties.
1838
-	 *
1839
-	 * @since 1.0.15
1840
-	 * @access public
1841
-	 *
1842
-	 * @param string $key Discount data to retrieve
1843
-	 * @param  string $context View or edit context.
1844
-	 * @return mixed Value of the given invoice property (if set).
1845
-	 */
1846
-	public function get( $key, $context = 'view' ) {
1822
+    /**
1823
+     * Retrieves the default status.
1824
+     *
1825
+     * @since 1.0.19
1826
+     * @return string
1827
+     */
1828
+    public function get_default_status() {
1829
+
1830
+        $type   = $this->get_type();
1831
+        $status = "wpi-$type-pending";
1832
+        return str_replace( '-invoice', '', $status );
1833
+
1834
+    }
1835
+
1836
+    /**
1837
+     * Magic method for accessing invoice properties.
1838
+     *
1839
+     * @since 1.0.15
1840
+     * @access public
1841
+     *
1842
+     * @param string $key Discount data to retrieve
1843
+     * @param  string $context View or edit context.
1844
+     * @return mixed Value of the given invoice property (if set).
1845
+     */
1846
+    public function get( $key, $context = 'view' ) {
1847 1847
         return $this->get_prop( $key, $context );
1848
-	}
1848
+    }
1849 1849
 
1850 1850
     /*
1851 1851
 	|--------------------------------------------------------------------------
@@ -1858,130 +1858,130 @@  discard block
 block discarded – undo
1858 1858
     */
1859 1859
 
1860 1860
     /**
1861
-	 * Magic method for setting invoice properties.
1862
-	 *
1863
-	 * @since 1.0.19
1864
-	 * @access public
1865
-	 *
1866
-	 * @param string $key Discount data to retrieve
1867
-	 * @param  mixed $value new value.
1868
-	 * @return mixed Value of the given invoice property (if set).
1869
-	 */
1870
-	public function set( $key, $value ) {
1861
+     * Magic method for setting invoice properties.
1862
+     *
1863
+     * @since 1.0.19
1864
+     * @access public
1865
+     *
1866
+     * @param string $key Discount data to retrieve
1867
+     * @param  mixed $value new value.
1868
+     * @return mixed Value of the given invoice property (if set).
1869
+     */
1870
+    public function set( $key, $value ) {
1871 1871
 
1872 1872
         $setter = "set_$key";
1873 1873
         if ( is_callable( array( $this, $setter ) ) ) {
1874 1874
             $this->{$setter}( $value );
1875 1875
         }
1876 1876
 
1877
-	}
1877
+    }
1878 1878
 
1879
-	/**
1880
-	 * Sets item status.
1881
-	 *
1882
-	 * @since 1.0.19
1883
-	 * @param string $new_status    New status.
1884
-	 * @param string $note          Optional note to add.
1885
-	 * @param bool   $manual_update Is this a manual status change?.
1886
-	 * @return array details of change.
1887
-	 */
1888
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1889
-		$old_status = $this->get_status();
1879
+    /**
1880
+     * Sets item status.
1881
+     *
1882
+     * @since 1.0.19
1883
+     * @param string $new_status    New status.
1884
+     * @param string $note          Optional note to add.
1885
+     * @param bool   $manual_update Is this a manual status change?.
1886
+     * @return array details of change.
1887
+     */
1888
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1889
+        $old_status = $this->get_status();
1890 1890
 
1891
-		$statuses = $this->get_all_statuses();
1891
+        $statuses = $this->get_all_statuses();
1892 1892
 
1893
-		if ( isset( $statuses[ 'draft' ] ) ) {
1894
-			unset( $statuses[ 'draft' ] );
1895
-		}
1893
+        if ( isset( $statuses[ 'draft' ] ) ) {
1894
+            unset( $statuses[ 'draft' ] );
1895
+        }
1896 1896
 
1897
-		$this->set_prop( 'status', $new_status );
1897
+        $this->set_prop( 'status', $new_status );
1898 1898
 
1899
-		// If setting the status, ensure it's set to a valid status.
1900
-		if ( true === $this->object_read ) {
1899
+        // If setting the status, ensure it's set to a valid status.
1900
+        if ( true === $this->object_read ) {
1901 1901
 
1902
-			// Only allow valid new status.
1903
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1904
-				$new_status = $this->get_default_status();
1905
-			}
1902
+            // Only allow valid new status.
1903
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1904
+                $new_status = $this->get_default_status();
1905
+            }
1906 1906
 
1907
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1908
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1909
-				$old_status = $this->get_default_status();
1910
-			}
1907
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1908
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1909
+                $old_status = $this->get_default_status();
1910
+            }
1911 1911
 
1912
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1913
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1914
-				$old_status = 'wpi-pending';
1915
-			}
1912
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1913
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1914
+                $old_status = 'wpi-pending';
1915
+            }
1916 1916
 
1917
-		}
1917
+        }
1918 1918
 
1919
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1920
-			$this->status_transition = array(
1921
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1922
-				'to'     => $new_status,
1923
-				'note'   => $note,
1924
-				'manual' => (bool) $manual_update,
1925
-			);
1919
+        if ( true === $this->object_read && $old_status !== $new_status ) {
1920
+            $this->status_transition = array(
1921
+                'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1922
+                'to'     => $new_status,
1923
+                'note'   => $note,
1924
+                'manual' => (bool) $manual_update,
1925
+            );
1926 1926
 
1927
-			if ( $manual_update ) {
1928
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1929
-			}
1927
+            if ( $manual_update ) {
1928
+                do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1929
+            }
1930 1930
 
1931
-			$this->maybe_set_date_paid();
1931
+            $this->maybe_set_date_paid();
1932 1932
 
1933
-		}
1933
+        }
1934 1934
 
1935
-		return array(
1936
-			'from' => $old_status,
1937
-			'to'   => $new_status,
1938
-		);
1939
-	}
1935
+        return array(
1936
+            'from' => $old_status,
1937
+            'to'   => $new_status,
1938
+        );
1939
+    }
1940 1940
 
1941
-	/**
1942
-	 * Maybe set date paid.
1943
-	 *
1944
-	 * Sets the date paid variable when transitioning to the payment complete
1945
-	 * order status.
1946
-	 *
1947
-	 * @since 1.0.19
1948
-	 */
1949
-	public function maybe_set_date_paid() {
1941
+    /**
1942
+     * Maybe set date paid.
1943
+     *
1944
+     * Sets the date paid variable when transitioning to the payment complete
1945
+     * order status.
1946
+     *
1947
+     * @since 1.0.19
1948
+     */
1949
+    public function maybe_set_date_paid() {
1950 1950
 
1951
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1952
-			$this->set_date_completed( current_time( 'mysql' ) );
1953
-		}
1954
-	}
1951
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1952
+            $this->set_date_completed( current_time( 'mysql' ) );
1953
+        }
1954
+    }
1955 1955
 
1956 1956
     /**
1957
-	 * Set parent invoice ID.
1958
-	 *
1959
-	 * @since 1.0.19
1960
-	 */
1961
-	public function set_parent_id( $value ) {
1962
-		if ( $value && ( $value === $this->get_id() ) ) {
1963
-			return;
1964
-		}
1965
-		$this->set_prop( 'parent_id', absint( $value ) );
1957
+     * Set parent invoice ID.
1958
+     *
1959
+     * @since 1.0.19
1960
+     */
1961
+    public function set_parent_id( $value ) {
1962
+        if ( $value && ( $value === $this->get_id() ) ) {
1963
+            return;
1964
+        }
1965
+        $this->set_prop( 'parent_id', absint( $value ) );
1966 1966
     }
1967 1967
 
1968 1968
     /**
1969
-	 * Set plugin version when the invoice was created.
1970
-	 *
1971
-	 * @since 1.0.19
1972
-	 */
1973
-	public function set_version( $value ) {
1974
-		$this->set_prop( 'version', $value );
1969
+     * Set plugin version when the invoice was created.
1970
+     *
1971
+     * @since 1.0.19
1972
+     */
1973
+    public function set_version( $value ) {
1974
+        $this->set_prop( 'version', $value );
1975 1975
     }
1976
-
1977
-    /**
1978
-	 * Set date when the invoice was created.
1979
-	 *
1980
-	 * @since 1.0.19
1981
-	 * @param string $value Value to set.
1976
+
1977
+    /**
1978
+     * Set date when the invoice was created.
1979
+     *
1980
+     * @since 1.0.19
1981
+     * @param string $value Value to set.
1982 1982
      * @return bool Whether or not the date was set.
1983
-	 */
1984
-	public function set_date_created( $value ) {
1983
+     */
1984
+    public function set_date_created( $value ) {
1985 1985
         $date = strtotime( $value );
1986 1986
 
1987 1987
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1989,19 +1989,19 @@  discard block
 block discarded – undo
1989 1989
             return true;
1990 1990
         }
1991 1991
 
1992
-		$this->set_prop( 'date_created', '' );
1993
-		return false;
1992
+        $this->set_prop( 'date_created', '' );
1993
+        return false;
1994 1994
 
1995 1995
     }
1996 1996
 
1997 1997
     /**
1998
-	 * Set date invoice due date.
1999
-	 *
2000
-	 * @since 1.0.19
2001
-	 * @param string $value Value to set.
1998
+     * Set date invoice due date.
1999
+     *
2000
+     * @since 1.0.19
2001
+     * @param string $value Value to set.
2002 2002
      * @return bool Whether or not the date was set.
2003
-	 */
2004
-	public function set_due_date( $value ) {
2003
+     */
2004
+    public function set_due_date( $value ) {
2005 2005
         $date = strtotime( $value );
2006 2006
 
2007 2007
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2009,29 +2009,29 @@  discard block
 block discarded – undo
2009 2009
             return true;
2010 2010
         }
2011 2011
 
2012
-		$this->set_prop( 'due_date', '' );
2012
+        $this->set_prop( 'due_date', '' );
2013 2013
         return false;
2014 2014
 
2015 2015
     }
2016 2016
 
2017 2017
     /**
2018
-	 * Alias of self::set_due_date().
2019
-	 *
2020
-	 * @since 1.0.19
2021
-	 * @param  string $value New name.
2022
-	 */
2023
-	public function set_date_due( $value ) {
2024
-		$this->set_due_date( $value );
2018
+     * Alias of self::set_due_date().
2019
+     *
2020
+     * @since 1.0.19
2021
+     * @param  string $value New name.
2022
+     */
2023
+    public function set_date_due( $value ) {
2024
+        $this->set_due_date( $value );
2025 2025
     }
2026 2026
 
2027 2027
     /**
2028
-	 * Set date invoice was completed.
2029
-	 *
2030
-	 * @since 1.0.19
2031
-	 * @param string $value Value to set.
2028
+     * Set date invoice was completed.
2029
+     *
2030
+     * @since 1.0.19
2031
+     * @param string $value Value to set.
2032 2032
      * @return bool Whether or not the date was set.
2033
-	 */
2034
-	public function set_completed_date( $value ) {
2033
+     */
2034
+    public function set_completed_date( $value ) {
2035 2035
         $date = strtotime( $value );
2036 2036
 
2037 2037
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -2039,29 +2039,29 @@  discard block
 block discarded – undo
2039 2039
             return true;
2040 2040
         }
2041 2041
 
2042
-		$this->set_prop( 'completed_date', '' );
2042
+        $this->set_prop( 'completed_date', '' );
2043 2043
         return false;
2044 2044
 
2045 2045
     }
2046 2046
 
2047 2047
     /**
2048
-	 * Alias of self::set_completed_date().
2049
-	 *
2050
-	 * @since 1.0.19
2051
-	 * @param  string $value New name.
2052
-	 */
2053
-	public function set_date_completed( $value ) {
2054
-		$this->set_completed_date( $value );
2048
+     * Alias of self::set_completed_date().
2049
+     *
2050
+     * @since 1.0.19
2051
+     * @param  string $value New name.
2052
+     */
2053
+    public function set_date_completed( $value ) {
2054
+        $this->set_completed_date( $value );
2055 2055
     }
2056 2056
 
2057 2057
     /**
2058
-	 * Set date when the invoice was last modified.
2059
-	 *
2060
-	 * @since 1.0.19
2061
-	 * @param string $value Value to set.
2058
+     * Set date when the invoice was last modified.
2059
+     *
2060
+     * @since 1.0.19
2061
+     * @param string $value Value to set.
2062 2062
      * @return bool Whether or not the date was set.
2063
-	 */
2064
-	public function set_date_modified( $value ) {
2063
+     */
2064
+    public function set_date_modified( $value ) {
2065 2065
         $date = strtotime( $value );
2066 2066
 
2067 2067
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2069,763 +2069,763 @@  discard block
 block discarded – undo
2069 2069
             return true;
2070 2070
         }
2071 2071
 
2072
-		$this->set_prop( 'date_modified', '' );
2072
+        $this->set_prop( 'date_modified', '' );
2073 2073
         return false;
2074 2074
 
2075 2075
     }
2076 2076
 
2077 2077
     /**
2078
-	 * Set the invoice number.
2079
-	 *
2080
-	 * @since 1.0.19
2081
-	 * @param  string $value New number.
2082
-	 */
2083
-	public function set_number( $value ) {
2078
+     * Set the invoice number.
2079
+     *
2080
+     * @since 1.0.19
2081
+     * @param  string $value New number.
2082
+     */
2083
+    public function set_number( $value ) {
2084 2084
         $number = sanitize_text_field( $value );
2085
-		$this->set_prop( 'number', $number );
2085
+        $this->set_prop( 'number', $number );
2086 2086
     }
2087 2087
 
2088 2088
     /**
2089
-	 * Set the invoice type.
2090
-	 *
2091
-	 * @since 1.0.19
2092
-	 * @param  string $value Type.
2093
-	 */
2094
-	public function set_type( $value ) {
2089
+     * Set the invoice type.
2090
+     *
2091
+     * @since 1.0.19
2092
+     * @param  string $value Type.
2093
+     */
2094
+    public function set_type( $value ) {
2095 2095
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2096
-		$this->set_prop( 'type', $type );
2097
-	}
2096
+        $this->set_prop( 'type', $type );
2097
+    }
2098 2098
 
2099 2099
     /**
2100
-	 * Set the invoice post type.
2101
-	 *
2102
-	 * @since 1.0.19
2103
-	 * @param  string $value Post type.
2104
-	 */
2105
-	public function set_post_type( $value ) {
2100
+     * Set the invoice post type.
2101
+     *
2102
+     * @since 1.0.19
2103
+     * @param  string $value Post type.
2104
+     */
2105
+    public function set_post_type( $value ) {
2106 2106
         if ( getpaid_is_invoice_post_type( $value ) ) {
2107
-			$this->set_type( $value );
2107
+            $this->set_type( $value );
2108 2108
             $this->set_prop( 'post_type', $value );
2109 2109
         }
2110 2110
     }
2111 2111
 
2112 2112
     /**
2113
-	 * Set the invoice key.
2114
-	 *
2115
-	 * @since 1.0.19
2116
-	 * @param  string $value New key.
2117
-	 */
2118
-	public function set_key( $value ) {
2113
+     * Set the invoice key.
2114
+     *
2115
+     * @since 1.0.19
2116
+     * @param  string $value New key.
2117
+     */
2118
+    public function set_key( $value ) {
2119 2119
         $key = sanitize_text_field( $value );
2120
-		$this->set_prop( 'key', $key );
2120
+        $this->set_prop( 'key', $key );
2121 2121
     }
2122 2122
 
2123 2123
     /**
2124
-	 * Set the invoice mode.
2125
-	 *
2126
-	 * @since 1.0.19
2127
-	 * @param  string $value mode.
2128
-	 */
2129
-	public function set_mode( $value ) {
2124
+     * Set the invoice mode.
2125
+     *
2126
+     * @since 1.0.19
2127
+     * @param  string $value mode.
2128
+     */
2129
+    public function set_mode( $value ) {
2130 2130
         if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2131 2131
             $this->set_prop( 'value', $value );
2132 2132
         }
2133 2133
     }
2134 2134
 
2135 2135
     /**
2136
-	 * Set the invoice path.
2137
-	 *
2138
-	 * @since 1.0.19
2139
-	 * @param  string $value path.
2140
-	 */
2141
-	public function set_path( $value ) {
2136
+     * Set the invoice path.
2137
+     *
2138
+     * @since 1.0.19
2139
+     * @param  string $value path.
2140
+     */
2141
+    public function set_path( $value ) {
2142 2142
         $this->set_prop( 'path', $value );
2143 2143
     }
2144 2144
 
2145 2145
     /**
2146
-	 * Set the invoice name.
2147
-	 *
2148
-	 * @since 1.0.19
2149
-	 * @param  string $value New name.
2150
-	 */
2151
-	public function set_name( $value ) {
2146
+     * Set the invoice name.
2147
+     *
2148
+     * @since 1.0.19
2149
+     * @param  string $value New name.
2150
+     */
2151
+    public function set_name( $value ) {
2152 2152
         $name = sanitize_text_field( $value );
2153
-		$this->set_prop( 'name', $name );
2153
+        $this->set_prop( 'name', $name );
2154 2154
     }
2155 2155
 
2156 2156
     /**
2157
-	 * Alias of self::set_name().
2158
-	 *
2159
-	 * @since 1.0.19
2160
-	 * @param  string $value New name.
2161
-	 */
2162
-	public function set_title( $value ) {
2163
-		$this->set_name( $value );
2157
+     * Alias of self::set_name().
2158
+     *
2159
+     * @since 1.0.19
2160
+     * @param  string $value New name.
2161
+     */
2162
+    public function set_title( $value ) {
2163
+        $this->set_name( $value );
2164 2164
     }
2165 2165
 
2166 2166
     /**
2167
-	 * Set the invoice description.
2168
-	 *
2169
-	 * @since 1.0.19
2170
-	 * @param  string $value New description.
2171
-	 */
2172
-	public function set_description( $value ) {
2167
+     * Set the invoice description.
2168
+     *
2169
+     * @since 1.0.19
2170
+     * @param  string $value New description.
2171
+     */
2172
+    public function set_description( $value ) {
2173 2173
         $description = wp_kses_post( $value );
2174
-		$this->set_prop( 'description', $description );
2174
+        $this->set_prop( 'description', $description );
2175
+    }
2176
+
2177
+    /**
2178
+     * Alias of self::set_description().
2179
+     *
2180
+     * @since 1.0.19
2181
+     * @param  string $value New description.
2182
+     */
2183
+    public function set_excerpt( $value ) {
2184
+        $this->set_description( $value );
2185
+    }
2186
+
2187
+    /**
2188
+     * Alias of self::set_description().
2189
+     *
2190
+     * @since 1.0.19
2191
+     * @param  string $value New description.
2192
+     */
2193
+    public function set_summary( $value ) {
2194
+        $this->set_description( $value );
2175 2195
     }
2176 2196
 
2177 2197
     /**
2178
-	 * Alias of self::set_description().
2179
-	 *
2180
-	 * @since 1.0.19
2181
-	 * @param  string $value New description.
2182
-	 */
2183
-	public function set_excerpt( $value ) {
2184
-		$this->set_description( $value );
2198
+     * Set the receiver of the invoice.
2199
+     *
2200
+     * @since 1.0.19
2201
+     * @param  int $value New author.
2202
+     */
2203
+    public function set_author( $value ) {
2204
+        $user = get_user_by( 'id', (int) $value );
2205
+
2206
+        if ( $user && $user->ID ) {
2207
+            $this->set_prop( 'author', $user->ID );
2208
+            $this->set_prop( 'email', $user->user_email );
2209
+        }
2210
+
2185 2211
     }
2186 2212
 
2187 2213
     /**
2188
-	 * Alias of self::set_description().
2189
-	 *
2190
-	 * @since 1.0.19
2191
-	 * @param  string $value New description.
2192
-	 */
2193
-	public function set_summary( $value ) {
2194
-		$this->set_description( $value );
2214
+     * Alias of self::set_author().
2215
+     *
2216
+     * @since 1.0.19
2217
+     * @param  int $value New user id.
2218
+     */
2219
+    public function set_user_id( $value ) {
2220
+        $this->set_author( $value );
2195 2221
     }
2196 2222
 
2197 2223
     /**
2198
-	 * Set the receiver of the invoice.
2199
-	 *
2200
-	 * @since 1.0.19
2201
-	 * @param  int $value New author.
2202
-	 */
2203
-	public function set_author( $value ) {
2204
-		$user = get_user_by( 'id', (int) $value );
2224
+     * Alias of self::set_author().
2225
+     *
2226
+     * @since 1.0.19
2227
+     * @param  int $value New user id.
2228
+     */
2229
+    public function set_customer_id( $value ) {
2230
+        $this->set_author( $value );
2231
+    }
2205 2232
 
2206
-		if ( $user && $user->ID ) {
2207
-			$this->set_prop( 'author', $user->ID );
2208
-			$this->set_prop( 'email', $user->user_email );
2209
-		}
2233
+    /**
2234
+     * Set the customer's ip.
2235
+     *
2236
+     * @since 1.0.19
2237
+     * @param  string $value ip address.
2238
+     */
2239
+    public function set_ip( $value ) {
2240
+        $this->set_prop( 'ip', $value );
2241
+    }
2210 2242
 
2243
+    /**
2244
+     * Alias of self::set_ip().
2245
+     *
2246
+     * @since 1.0.19
2247
+     * @param  string $value ip address.
2248
+     */
2249
+    public function set_user_ip( $value ) {
2250
+        $this->set_ip( $value );
2211 2251
     }
2212 2252
 
2213 2253
     /**
2214
-	 * Alias of self::set_author().
2215
-	 *
2216
-	 * @since 1.0.19
2217
-	 * @param  int $value New user id.
2218
-	 */
2219
-	public function set_user_id( $value ) {
2220
-		$this->set_author( $value );
2254
+     * Set the customer's first name.
2255
+     *
2256
+     * @since 1.0.19
2257
+     * @param  string $value first name.
2258
+     */
2259
+    public function set_first_name( $value ) {
2260
+        $this->set_prop( 'first_name', $value );
2221 2261
     }
2222 2262
 
2223 2263
     /**
2224
-	 * Alias of self::set_author().
2225
-	 *
2226
-	 * @since 1.0.19
2227
-	 * @param  int $value New user id.
2228
-	 */
2229
-	public function set_customer_id( $value ) {
2230
-		$this->set_author( $value );
2264
+     * Alias of self::set_first_name().
2265
+     *
2266
+     * @since 1.0.19
2267
+     * @param  string $value first name.
2268
+     */
2269
+    public function set_user_first_name( $value ) {
2270
+        $this->set_first_name( $value );
2231 2271
     }
2232 2272
 
2233 2273
     /**
2234
-	 * Set the customer's ip.
2235
-	 *
2236
-	 * @since 1.0.19
2237
-	 * @param  string $value ip address.
2238
-	 */
2239
-	public function set_ip( $value ) {
2240
-		$this->set_prop( 'ip', $value );
2274
+     * Alias of self::set_first_name().
2275
+     *
2276
+     * @since 1.0.19
2277
+     * @param  string $value first name.
2278
+     */
2279
+    public function set_customer_first_name( $value ) {
2280
+        $this->set_first_name( $value );
2241 2281
     }
2242 2282
 
2243 2283
     /**
2244
-	 * Alias of self::set_ip().
2245
-	 *
2246
-	 * @since 1.0.19
2247
-	 * @param  string $value ip address.
2248
-	 */
2249
-	public function set_user_ip( $value ) {
2250
-		$this->set_ip( $value );
2284
+     * Set the customer's last name.
2285
+     *
2286
+     * @since 1.0.19
2287
+     * @param  string $value last name.
2288
+     */
2289
+    public function set_last_name( $value ) {
2290
+        $this->set_prop( 'last_name', $value );
2251 2291
     }
2252 2292
 
2253 2293
     /**
2254
-	 * Set the customer's first name.
2255
-	 *
2256
-	 * @since 1.0.19
2257
-	 * @param  string $value first name.
2258
-	 */
2259
-	public function set_first_name( $value ) {
2260
-		$this->set_prop( 'first_name', $value );
2294
+     * Alias of self::set_last_name().
2295
+     *
2296
+     * @since 1.0.19
2297
+     * @param  string $value last name.
2298
+     */
2299
+    public function set_user_last_name( $value ) {
2300
+        $this->set_last_name( $value );
2261 2301
     }
2262 2302
 
2263 2303
     /**
2264
-	 * Alias of self::set_first_name().
2265
-	 *
2266
-	 * @since 1.0.19
2267
-	 * @param  string $value first name.
2268
-	 */
2269
-	public function set_user_first_name( $value ) {
2270
-		$this->set_first_name( $value );
2304
+     * Alias of self::set_last_name().
2305
+     *
2306
+     * @since 1.0.19
2307
+     * @param  string $value last name.
2308
+     */
2309
+    public function set_customer_last_name( $value ) {
2310
+        $this->set_last_name( $value );
2271 2311
     }
2272 2312
 
2273 2313
     /**
2274
-	 * Alias of self::set_first_name().
2275
-	 *
2276
-	 * @since 1.0.19
2277
-	 * @param  string $value first name.
2278
-	 */
2279
-	public function set_customer_first_name( $value ) {
2280
-		$this->set_first_name( $value );
2314
+     * Set the customer's phone number.
2315
+     *
2316
+     * @since 1.0.19
2317
+     * @param  string $value phone.
2318
+     */
2319
+    public function set_phone( $value ) {
2320
+        $this->set_prop( 'phone', $value );
2281 2321
     }
2282 2322
 
2283 2323
     /**
2284
-	 * Set the customer's last name.
2285
-	 *
2286
-	 * @since 1.0.19
2287
-	 * @param  string $value last name.
2288
-	 */
2289
-	public function set_last_name( $value ) {
2290
-		$this->set_prop( 'last_name', $value );
2324
+     * Alias of self::set_phone().
2325
+     *
2326
+     * @since 1.0.19
2327
+     * @param  string $value phone.
2328
+     */
2329
+    public function set_user_phone( $value ) {
2330
+        $this->set_phone( $value );
2291 2331
     }
2292 2332
 
2293 2333
     /**
2294
-	 * Alias of self::set_last_name().
2295
-	 *
2296
-	 * @since 1.0.19
2297
-	 * @param  string $value last name.
2298
-	 */
2299
-	public function set_user_last_name( $value ) {
2300
-		$this->set_last_name( $value );
2334
+     * Alias of self::set_phone().
2335
+     *
2336
+     * @since 1.0.19
2337
+     * @param  string $value phone.
2338
+     */
2339
+    public function set_customer_phone( $value ) {
2340
+        $this->set_phone( $value );
2301 2341
     }
2302 2342
 
2303 2343
     /**
2304
-	 * Alias of self::set_last_name().
2305
-	 *
2306
-	 * @since 1.0.19
2307
-	 * @param  string $value last name.
2308
-	 */
2309
-	public function set_customer_last_name( $value ) {
2310
-		$this->set_last_name( $value );
2344
+     * Alias of self::set_phone().
2345
+     *
2346
+     * @since 1.0.19
2347
+     * @param  string $value phone.
2348
+     */
2349
+    public function set_phone_number( $value ) {
2350
+        $this->set_phone( $value );
2311 2351
     }
2312 2352
 
2313 2353
     /**
2314
-	 * Set the customer's phone number.
2315
-	 *
2316
-	 * @since 1.0.19
2317
-	 * @param  string $value phone.
2318
-	 */
2319
-	public function set_phone( $value ) {
2320
-		$this->set_prop( 'phone', $value );
2354
+     * Set the customer's email address.
2355
+     *
2356
+     * @since 1.0.19
2357
+     * @param  string $value email address.
2358
+     */
2359
+    public function set_email( $value ) {
2360
+        $this->set_prop( 'email', $value );
2321 2361
     }
2322 2362
 
2323 2363
     /**
2324
-	 * Alias of self::set_phone().
2325
-	 *
2326
-	 * @since 1.0.19
2327
-	 * @param  string $value phone.
2328
-	 */
2329
-	public function set_user_phone( $value ) {
2330
-		$this->set_phone( $value );
2364
+     * Alias of self::set_email().
2365
+     *
2366
+     * @since 1.0.19
2367
+     * @param  string $value email address.
2368
+     */
2369
+    public function set_user_email( $value ) {
2370
+        $this->set_email( $value );
2331 2371
     }
2332 2372
 
2333 2373
     /**
2334
-	 * Alias of self::set_phone().
2335
-	 *
2336
-	 * @since 1.0.19
2337
-	 * @param  string $value phone.
2338
-	 */
2339
-	public function set_customer_phone( $value ) {
2340
-		$this->set_phone( $value );
2374
+     * Alias of self::set_email().
2375
+     *
2376
+     * @since 1.0.19
2377
+     * @param  string $value email address.
2378
+     */
2379
+    public function set_email_address( $value ) {
2380
+        $this->set_email( $value );
2341 2381
     }
2342 2382
 
2343 2383
     /**
2344
-	 * Alias of self::set_phone().
2345
-	 *
2346
-	 * @since 1.0.19
2347
-	 * @param  string $value phone.
2348
-	 */
2349
-	public function set_phone_number( $value ) {
2350
-		$this->set_phone( $value );
2384
+     * Alias of self::set_email().
2385
+     *
2386
+     * @since 1.0.19
2387
+     * @param  string $value email address.
2388
+     */
2389
+    public function set_customer_email( $value ) {
2390
+        $this->set_email( $value );
2351 2391
     }
2352 2392
 
2353 2393
     /**
2354
-	 * Set the customer's email address.
2355
-	 *
2356
-	 * @since 1.0.19
2357
-	 * @param  string $value email address.
2358
-	 */
2359
-	public function set_email( $value ) {
2360
-		$this->set_prop( 'email', $value );
2394
+     * Set the customer's country.
2395
+     *
2396
+     * @since 1.0.19
2397
+     * @param  string $value country.
2398
+     */
2399
+    public function set_country( $value ) {
2400
+        $this->set_prop( 'country', $value );
2361 2401
     }
2362 2402
 
2363 2403
     /**
2364
-	 * Alias of self::set_email().
2365
-	 *
2366
-	 * @since 1.0.19
2367
-	 * @param  string $value email address.
2368
-	 */
2369
-	public function set_user_email( $value ) {
2370
-		$this->set_email( $value );
2404
+     * Alias of self::set_country().
2405
+     *
2406
+     * @since 1.0.19
2407
+     * @param  string $value country.
2408
+     */
2409
+    public function set_user_country( $value ) {
2410
+        $this->set_country( $value );
2371 2411
     }
2372 2412
 
2373 2413
     /**
2374
-	 * Alias of self::set_email().
2375
-	 *
2376
-	 * @since 1.0.19
2377
-	 * @param  string $value email address.
2378
-	 */
2379
-	public function set_email_address( $value ) {
2380
-		$this->set_email( $value );
2414
+     * Alias of self::set_country().
2415
+     *
2416
+     * @since 1.0.19
2417
+     * @param  string $value country.
2418
+     */
2419
+    public function set_customer_country( $value ) {
2420
+        $this->set_country( $value );
2381 2421
     }
2382 2422
 
2383 2423
     /**
2384
-	 * Alias of self::set_email().
2385
-	 *
2386
-	 * @since 1.0.19
2387
-	 * @param  string $value email address.
2388
-	 */
2389
-	public function set_customer_email( $value ) {
2390
-		$this->set_email( $value );
2424
+     * Set the customer's state.
2425
+     *
2426
+     * @since 1.0.19
2427
+     * @param  string $value state.
2428
+     */
2429
+    public function set_state( $value ) {
2430
+        $this->set_prop( 'state', $value );
2391 2431
     }
2392 2432
 
2393 2433
     /**
2394
-	 * Set the customer's country.
2395
-	 *
2396
-	 * @since 1.0.19
2397
-	 * @param  string $value country.
2398
-	 */
2399
-	public function set_country( $value ) {
2400
-		$this->set_prop( 'country', $value );
2434
+     * Alias of self::set_state().
2435
+     *
2436
+     * @since 1.0.19
2437
+     * @param  string $value state.
2438
+     */
2439
+    public function set_user_state( $value ) {
2440
+        $this->set_state( $value );
2401 2441
     }
2402 2442
 
2403 2443
     /**
2404
-	 * Alias of self::set_country().
2405
-	 *
2406
-	 * @since 1.0.19
2407
-	 * @param  string $value country.
2408
-	 */
2409
-	public function set_user_country( $value ) {
2410
-		$this->set_country( $value );
2444
+     * Alias of self::set_state().
2445
+     *
2446
+     * @since 1.0.19
2447
+     * @param  string $value state.
2448
+     */
2449
+    public function set_customer_state( $value ) {
2450
+        $this->set_state( $value );
2411 2451
     }
2412 2452
 
2413 2453
     /**
2414
-	 * Alias of self::set_country().
2415
-	 *
2416
-	 * @since 1.0.19
2417
-	 * @param  string $value country.
2418
-	 */
2419
-	public function set_customer_country( $value ) {
2420
-		$this->set_country( $value );
2454
+     * Set the customer's city.
2455
+     *
2456
+     * @since 1.0.19
2457
+     * @param  string $value city.
2458
+     */
2459
+    public function set_city( $value ) {
2460
+        $this->set_prop( 'city', $value );
2421 2461
     }
2422 2462
 
2423 2463
     /**
2424
-	 * Set the customer's state.
2425
-	 *
2426
-	 * @since 1.0.19
2427
-	 * @param  string $value state.
2428
-	 */
2429
-	public function set_state( $value ) {
2430
-		$this->set_prop( 'state', $value );
2464
+     * Alias of self::set_city().
2465
+     *
2466
+     * @since 1.0.19
2467
+     * @param  string $value city.
2468
+     */
2469
+    public function set_user_city( $value ) {
2470
+        $this->set_city( $value );
2431 2471
     }
2432 2472
 
2433 2473
     /**
2434
-	 * Alias of self::set_state().
2435
-	 *
2436
-	 * @since 1.0.19
2437
-	 * @param  string $value state.
2438
-	 */
2439
-	public function set_user_state( $value ) {
2440
-		$this->set_state( $value );
2474
+     * Alias of self::set_city().
2475
+     *
2476
+     * @since 1.0.19
2477
+     * @param  string $value city.
2478
+     */
2479
+    public function set_customer_city( $value ) {
2480
+        $this->set_city( $value );
2441 2481
     }
2442 2482
 
2443 2483
     /**
2444
-	 * Alias of self::set_state().
2445
-	 *
2446
-	 * @since 1.0.19
2447
-	 * @param  string $value state.
2448
-	 */
2449
-	public function set_customer_state( $value ) {
2450
-		$this->set_state( $value );
2484
+     * Set the customer's zip code.
2485
+     *
2486
+     * @since 1.0.19
2487
+     * @param  string $value zip.
2488
+     */
2489
+    public function set_zip( $value ) {
2490
+        $this->set_prop( 'zip', $value );
2451 2491
     }
2452 2492
 
2453 2493
     /**
2454
-	 * Set the customer's city.
2455
-	 *
2456
-	 * @since 1.0.19
2457
-	 * @param  string $value city.
2458
-	 */
2459
-	public function set_city( $value ) {
2460
-		$this->set_prop( 'city', $value );
2494
+     * Alias of self::set_zip().
2495
+     *
2496
+     * @since 1.0.19
2497
+     * @param  string $value zip.
2498
+     */
2499
+    public function set_user_zip( $value ) {
2500
+        $this->set_zip( $value );
2461 2501
     }
2462 2502
 
2463 2503
     /**
2464
-	 * Alias of self::set_city().
2465
-	 *
2466
-	 * @since 1.0.19
2467
-	 * @param  string $value city.
2468
-	 */
2469
-	public function set_user_city( $value ) {
2470
-		$this->set_city( $value );
2504
+     * Alias of self::set_zip().
2505
+     *
2506
+     * @since 1.0.19
2507
+     * @param  string $value zip.
2508
+     */
2509
+    public function set_customer_zip( $value ) {
2510
+        $this->set_zip( $value );
2471 2511
     }
2472 2512
 
2473 2513
     /**
2474
-	 * Alias of self::set_city().
2475
-	 *
2476
-	 * @since 1.0.19
2477
-	 * @param  string $value city.
2478
-	 */
2479
-	public function set_customer_city( $value ) {
2480
-		$this->set_city( $value );
2514
+     * Set the customer's company.
2515
+     *
2516
+     * @since 1.0.19
2517
+     * @param  string $value company.
2518
+     */
2519
+    public function set_company( $value ) {
2520
+        $this->set_prop( 'company', $value );
2481 2521
     }
2482 2522
 
2483 2523
     /**
2484
-	 * Set the customer's zip code.
2485
-	 *
2486
-	 * @since 1.0.19
2487
-	 * @param  string $value zip.
2488
-	 */
2489
-	public function set_zip( $value ) {
2490
-		$this->set_prop( 'zip', $value );
2524
+     * Alias of self::set_company().
2525
+     *
2526
+     * @since 1.0.19
2527
+     * @param  string $value company.
2528
+     */
2529
+    public function set_user_company( $value ) {
2530
+        $this->set_company( $value );
2491 2531
     }
2492 2532
 
2493 2533
     /**
2494
-	 * Alias of self::set_zip().
2495
-	 *
2496
-	 * @since 1.0.19
2497
-	 * @param  string $value zip.
2498
-	 */
2499
-	public function set_user_zip( $value ) {
2500
-		$this->set_zip( $value );
2534
+     * Alias of self::set_company().
2535
+     *
2536
+     * @since 1.0.19
2537
+     * @param  string $value company.
2538
+     */
2539
+    public function set_customer_company( $value ) {
2540
+        $this->set_company( $value );
2501 2541
     }
2502 2542
 
2503 2543
     /**
2504
-	 * Alias of self::set_zip().
2505
-	 *
2506
-	 * @since 1.0.19
2507
-	 * @param  string $value zip.
2508
-	 */
2509
-	public function set_customer_zip( $value ) {
2510
-		$this->set_zip( $value );
2544
+     * Set the customer's var number.
2545
+     *
2546
+     * @since 1.0.19
2547
+     * @param  string $value var number.
2548
+     */
2549
+    public function set_vat_number( $value ) {
2550
+        $this->set_prop( 'vat_number', $value );
2511 2551
     }
2512 2552
 
2513 2553
     /**
2514
-	 * Set the customer's company.
2515
-	 *
2516
-	 * @since 1.0.19
2517
-	 * @param  string $value company.
2518
-	 */
2519
-	public function set_company( $value ) {
2520
-		$this->set_prop( 'company', $value );
2554
+     * Alias of self::set_vat_number().
2555
+     *
2556
+     * @since 1.0.19
2557
+     * @param  string $value var number.
2558
+     */
2559
+    public function set_user_vat_number( $value ) {
2560
+        $this->set_vat_number( $value );
2521 2561
     }
2522 2562
 
2523 2563
     /**
2524
-	 * Alias of self::set_company().
2525
-	 *
2526
-	 * @since 1.0.19
2527
-	 * @param  string $value company.
2528
-	 */
2529
-	public function set_user_company( $value ) {
2530
-		$this->set_company( $value );
2564
+     * Alias of self::set_vat_number().
2565
+     *
2566
+     * @since 1.0.19
2567
+     * @param  string $value var number.
2568
+     */
2569
+    public function set_customer_vat_number( $value ) {
2570
+        $this->set_vat_number( $value );
2531 2571
     }
2532 2572
 
2533 2573
     /**
2534
-	 * Alias of self::set_company().
2535
-	 *
2536
-	 * @since 1.0.19
2537
-	 * @param  string $value company.
2538
-	 */
2539
-	public function set_customer_company( $value ) {
2540
-		$this->set_company( $value );
2574
+     * Set the customer's vat rate.
2575
+     *
2576
+     * @since 1.0.19
2577
+     * @param  string $value var rate.
2578
+     */
2579
+    public function set_vat_rate( $value ) {
2580
+        $this->set_prop( 'vat_rate', $value );
2541 2581
     }
2542 2582
 
2543 2583
     /**
2544
-	 * Set the customer's var number.
2545
-	 *
2546
-	 * @since 1.0.19
2547
-	 * @param  string $value var number.
2548
-	 */
2549
-	public function set_vat_number( $value ) {
2550
-		$this->set_prop( 'vat_number', $value );
2584
+     * Alias of self::set_vat_rate().
2585
+     *
2586
+     * @since 1.0.19
2587
+     * @param  string $value var number.
2588
+     */
2589
+    public function set_user_vat_rate( $value ) {
2590
+        $this->set_vat_rate( $value );
2551 2591
     }
2552 2592
 
2553 2593
     /**
2554
-	 * Alias of self::set_vat_number().
2555
-	 *
2556
-	 * @since 1.0.19
2557
-	 * @param  string $value var number.
2558
-	 */
2559
-	public function set_user_vat_number( $value ) {
2560
-		$this->set_vat_number( $value );
2594
+     * Alias of self::set_vat_rate().
2595
+     *
2596
+     * @since 1.0.19
2597
+     * @param  string $value var number.
2598
+     */
2599
+    public function set_customer_vat_rate( $value ) {
2600
+        $this->set_vat_rate( $value );
2561 2601
     }
2562 2602
 
2563 2603
     /**
2564
-	 * Alias of self::set_vat_number().
2565
-	 *
2566
-	 * @since 1.0.19
2567
-	 * @param  string $value var number.
2568
-	 */
2569
-	public function set_customer_vat_number( $value ) {
2570
-		$this->set_vat_number( $value );
2604
+     * Set the customer's address.
2605
+     *
2606
+     * @since 1.0.19
2607
+     * @param  string $value address.
2608
+     */
2609
+    public function set_address( $value ) {
2610
+        $this->set_prop( 'address', $value );
2571 2611
     }
2572 2612
 
2573 2613
     /**
2574
-	 * Set the customer's vat rate.
2575
-	 *
2576
-	 * @since 1.0.19
2577
-	 * @param  string $value var rate.
2578
-	 */
2579
-	public function set_vat_rate( $value ) {
2580
-		$this->set_prop( 'vat_rate', $value );
2614
+     * Alias of self::set_address().
2615
+     *
2616
+     * @since 1.0.19
2617
+     * @param  string $value address.
2618
+     */
2619
+    public function set_user_address( $value ) {
2620
+        $this->set_address( $value );
2581 2621
     }
2582 2622
 
2583 2623
     /**
2584
-	 * Alias of self::set_vat_rate().
2585
-	 *
2586
-	 * @since 1.0.19
2587
-	 * @param  string $value var number.
2588
-	 */
2589
-	public function set_user_vat_rate( $value ) {
2590
-		$this->set_vat_rate( $value );
2624
+     * Alias of self::set_address().
2625
+     *
2626
+     * @since 1.0.19
2627
+     * @param  string $value address.
2628
+     */
2629
+    public function set_customer_address( $value ) {
2630
+        $this->set_address( $value );
2591 2631
     }
2592 2632
 
2593 2633
     /**
2594
-	 * Alias of self::set_vat_rate().
2595
-	 *
2596
-	 * @since 1.0.19
2597
-	 * @param  string $value var number.
2598
-	 */
2599
-	public function set_customer_vat_rate( $value ) {
2600
-		$this->set_vat_rate( $value );
2634
+     * Set whether the customer has viewed the invoice or not.
2635
+     *
2636
+     * @since 1.0.19
2637
+     * @param  int|bool $value confirmed.
2638
+     */
2639
+    public function set_is_viewed( $value ) {
2640
+        $this->set_prop( 'is_viewed', $value );
2601 2641
     }
2602 2642
 
2603 2643
     /**
2604
-	 * Set the customer's address.
2605
-	 *
2606
-	 * @since 1.0.19
2607
-	 * @param  string $value address.
2608
-	 */
2609
-	public function set_address( $value ) {
2610
-		$this->set_prop( 'address', $value );
2644
+     * Set extra email recipients.
2645
+     *
2646
+     * @since 1.0.19
2647
+     * @param  string $value email recipients.
2648
+     */
2649
+    public function set_email_cc( $value ) {
2650
+        $this->set_prop( 'email_cc', $value );
2611 2651
     }
2612 2652
 
2613 2653
     /**
2614
-	 * Alias of self::set_address().
2615
-	 *
2616
-	 * @since 1.0.19
2617
-	 * @param  string $value address.
2618
-	 */
2619
-	public function set_user_address( $value ) {
2620
-		$this->set_address( $value );
2654
+     * Set the invoice template.
2655
+     *
2656
+     * @since 1.0.19
2657
+     * @param  string $value template.
2658
+     */
2659
+    public function set_template( $value ) {
2660
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2661
+            $this->set_prop( 'template', $value );
2662
+        }
2621 2663
     }
2622 2664
 
2623 2665
     /**
2624
-	 * Alias of self::set_address().
2625
-	 *
2626
-	 * @since 1.0.19
2627
-	 * @param  string $value address.
2628
-	 */
2629
-	public function set_customer_address( $value ) {
2630
-		$this->set_address( $value );
2666
+     * Set the invoice source.
2667
+     *
2668
+     * @since 1.0.19
2669
+     * @param  string $value email recipients.
2670
+     */
2671
+    public function created_via( $value ) {
2672
+        $this->set_prop( 'created_via', sanitize_text_field( $value ) );
2631 2673
     }
2632 2674
 
2633 2675
     /**
2634
-	 * Set whether the customer has viewed the invoice or not.
2635
-	 *
2636
-	 * @since 1.0.19
2637
-	 * @param  int|bool $value confirmed.
2638
-	 */
2639
-	public function set_is_viewed( $value ) {
2640
-		$this->set_prop( 'is_viewed', $value );
2641
-	}
2642
-
2643
-	/**
2644
-	 * Set extra email recipients.
2645
-	 *
2646
-	 * @since 1.0.19
2647
-	 * @param  string $value email recipients.
2648
-	 */
2649
-	public function set_email_cc( $value ) {
2650
-		$this->set_prop( 'email_cc', $value );
2651
-	}
2652
-
2653
-	/**
2654
-	 * Set the invoice template.
2655
-	 *
2656
-	 * @since 1.0.19
2657
-	 * @param  string $value template.
2658
-	 */
2659
-	public function set_template( $value ) {
2660
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2661
-			$this->set_prop( 'template', $value );
2662
-		}
2663
-	}
2664
-
2665
-	/**
2666
-	 * Set the invoice source.
2667
-	 *
2668
-	 * @since 1.0.19
2669
-	 * @param  string $value email recipients.
2670
-	 */
2671
-	public function created_via( $value ) {
2672
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2673
-	}
2674
-
2675
-	/**
2676
-	 * Set the customer's address confirmed status.
2677
-	 *
2678
-	 * @since 1.0.19
2679
-	 * @param  int|bool $value confirmed.
2680
-	 */
2681
-	public function set_address_confirmed( $value ) {
2682
-		$this->set_prop( 'address_confirmed', $value );
2676
+     * Set the customer's address confirmed status.
2677
+     *
2678
+     * @since 1.0.19
2679
+     * @param  int|bool $value confirmed.
2680
+     */
2681
+    public function set_address_confirmed( $value ) {
2682
+        $this->set_prop( 'address_confirmed', $value );
2683 2683
     }
2684 2684
 
2685 2685
     /**
2686
-	 * Alias of self::set_address_confirmed().
2687
-	 *
2688
-	 * @since 1.0.19
2689
-	 * @param  int|bool $value confirmed.
2690
-	 */
2691
-	public function set_user_address_confirmed( $value ) {
2692
-		$this->set_address_confirmed( $value );
2686
+     * Alias of self::set_address_confirmed().
2687
+     *
2688
+     * @since 1.0.19
2689
+     * @param  int|bool $value confirmed.
2690
+     */
2691
+    public function set_user_address_confirmed( $value ) {
2692
+        $this->set_address_confirmed( $value );
2693 2693
     }
2694 2694
 
2695 2695
     /**
2696
-	 * Alias of self::set_address_confirmed().
2697
-	 *
2698
-	 * @since 1.0.19
2699
-	 * @param  int|bool $value confirmed.
2700
-	 */
2701
-	public function set_customer_address_confirmed( $value ) {
2702
-		$this->set_address_confirmed( $value );
2696
+     * Alias of self::set_address_confirmed().
2697
+     *
2698
+     * @since 1.0.19
2699
+     * @param  int|bool $value confirmed.
2700
+     */
2701
+    public function set_customer_address_confirmed( $value ) {
2702
+        $this->set_address_confirmed( $value );
2703 2703
     }
2704 2704
 
2705 2705
     /**
2706
-	 * Set the invoice sub total.
2707
-	 *
2708
-	 * @since 1.0.19
2709
-	 * @param  float $value sub total.
2710
-	 */
2711
-	public function set_subtotal( $value ) {
2712
-		$this->set_prop( 'subtotal', $value );
2706
+     * Set the invoice sub total.
2707
+     *
2708
+     * @since 1.0.19
2709
+     * @param  float $value sub total.
2710
+     */
2711
+    public function set_subtotal( $value ) {
2712
+        $this->set_prop( 'subtotal', $value );
2713 2713
     }
2714 2714
 
2715 2715
     /**
2716
-	 * Set the invoice discount amount.
2717
-	 *
2718
-	 * @since 1.0.19
2719
-	 * @param  float $value discount total.
2720
-	 */
2721
-	public function set_total_discount( $value ) {
2722
-		$this->set_prop( 'total_discount', $value );
2716
+     * Set the invoice discount amount.
2717
+     *
2718
+     * @since 1.0.19
2719
+     * @param  float $value discount total.
2720
+     */
2721
+    public function set_total_discount( $value ) {
2722
+        $this->set_prop( 'total_discount', $value );
2723 2723
     }
2724 2724
 
2725 2725
     /**
2726
-	 * Alias of self::set_total_discount().
2727
-	 *
2728
-	 * @since 1.0.19
2729
-	 * @param  float $value discount total.
2730
-	 */
2731
-	public function set_discount( $value ) {
2732
-		$this->set_total_discount( $value );
2726
+     * Alias of self::set_total_discount().
2727
+     *
2728
+     * @since 1.0.19
2729
+     * @param  float $value discount total.
2730
+     */
2731
+    public function set_discount( $value ) {
2732
+        $this->set_total_discount( $value );
2733 2733
     }
2734 2734
 
2735 2735
     /**
2736
-	 * Set the invoice tax amount.
2737
-	 *
2738
-	 * @since 1.0.19
2739
-	 * @param  float $value tax total.
2740
-	 */
2741
-	public function set_total_tax( $value ) {
2742
-		$this->set_prop( 'total_tax', $value );
2736
+     * Set the invoice tax amount.
2737
+     *
2738
+     * @since 1.0.19
2739
+     * @param  float $value tax total.
2740
+     */
2741
+    public function set_total_tax( $value ) {
2742
+        $this->set_prop( 'total_tax', $value );
2743 2743
     }
2744 2744
 
2745 2745
     /**
2746
-	 * Alias of self::set_total_tax().
2747
-	 *
2748
-	 * @since 1.0.19
2749
-	 * @param  float $value tax total.
2750
-	 */
2751
-	public function set_tax_total( $value ) {
2752
-		$this->set_total_tax( $value );
2746
+     * Alias of self::set_total_tax().
2747
+     *
2748
+     * @since 1.0.19
2749
+     * @param  float $value tax total.
2750
+     */
2751
+    public function set_tax_total( $value ) {
2752
+        $this->set_total_tax( $value );
2753 2753
     }
2754 2754
 
2755 2755
     /**
2756
-	 * Set the invoice fees amount.
2757
-	 *
2758
-	 * @since 1.0.19
2759
-	 * @param  float $value fees total.
2760
-	 */
2761
-	public function set_total_fees( $value ) {
2762
-		$this->set_prop( 'total_fees', $value );
2756
+     * Set the invoice fees amount.
2757
+     *
2758
+     * @since 1.0.19
2759
+     * @param  float $value fees total.
2760
+     */
2761
+    public function set_total_fees( $value ) {
2762
+        $this->set_prop( 'total_fees', $value );
2763 2763
     }
2764 2764
 
2765 2765
     /**
2766
-	 * Alias of self::set_total_fees().
2767
-	 *
2768
-	 * @since 1.0.19
2769
-	 * @param  float $value fees total.
2770
-	 */
2771
-	public function set_fees_total( $value ) {
2772
-		$this->set_total_fees( $value );
2766
+     * Alias of self::set_total_fees().
2767
+     *
2768
+     * @since 1.0.19
2769
+     * @param  float $value fees total.
2770
+     */
2771
+    public function set_fees_total( $value ) {
2772
+        $this->set_total_fees( $value );
2773 2773
     }
2774 2774
 
2775 2775
     /**
2776
-	 * Set the invoice fees.
2777
-	 *
2778
-	 * @since 1.0.19
2779
-	 * @param  array $value fees.
2780
-	 */
2781
-	public function set_fees( $value ) {
2776
+     * Set the invoice fees.
2777
+     *
2778
+     * @since 1.0.19
2779
+     * @param  array $value fees.
2780
+     */
2781
+    public function set_fees( $value ) {
2782 2782
 
2783
-		if ( ! is_array( $value ) ) {
2784
-			$value = array();
2785
-		}
2783
+        if ( ! is_array( $value ) ) {
2784
+            $value = array();
2785
+        }
2786 2786
 
2787
-		$this->set_prop( 'fees', $value );
2787
+        $this->set_prop( 'fees', $value );
2788 2788
 
2789 2789
     }
2790 2790
 
2791 2791
     /**
2792
-	 * Set the invoice taxes.
2793
-	 *
2794
-	 * @since 1.0.19
2795
-	 * @param  array $value taxes.
2796
-	 */
2797
-	public function set_taxes( $value ) {
2792
+     * Set the invoice taxes.
2793
+     *
2794
+     * @since 1.0.19
2795
+     * @param  array $value taxes.
2796
+     */
2797
+    public function set_taxes( $value ) {
2798 2798
 
2799
-		if ( ! is_array( $value ) ) {
2800
-			$value = array();
2801
-		}
2799
+        if ( ! is_array( $value ) ) {
2800
+            $value = array();
2801
+        }
2802 2802
 
2803
-		$this->set_prop( 'taxes', $value );
2803
+        $this->set_prop( 'taxes', $value );
2804 2804
 
2805 2805
     }
2806 2806
 
2807 2807
     /**
2808
-	 * Set the invoice discounts.
2809
-	 *
2810
-	 * @since 1.0.19
2811
-	 * @param  array $value discounts.
2812
-	 */
2813
-	public function set_discounts( $value ) {
2808
+     * Set the invoice discounts.
2809
+     *
2810
+     * @since 1.0.19
2811
+     * @param  array $value discounts.
2812
+     */
2813
+    public function set_discounts( $value ) {
2814 2814
 
2815
-		if ( ! is_array( $value ) ) {
2816
-			$value = array();
2817
-		}
2815
+        if ( ! is_array( $value ) ) {
2816
+            $value = array();
2817
+        }
2818 2818
 
2819
-		$this->set_prop( 'discounts', $value );
2819
+        $this->set_prop( 'discounts', $value );
2820 2820
     }
2821 2821
 
2822 2822
     /**
2823
-	 * Set the invoice items.
2824
-	 *
2825
-	 * @since 1.0.19
2826
-	 * @param  GetPaid_Form_Item[] $value items.
2827
-	 */
2828
-	public function set_items( $value ) {
2823
+     * Set the invoice items.
2824
+     *
2825
+     * @since 1.0.19
2826
+     * @param  GetPaid_Form_Item[] $value items.
2827
+     */
2828
+    public function set_items( $value ) {
2829 2829
 
2830 2830
         // Remove existing items.
2831 2831
         $this->set_prop( 'items', array() );
@@ -2842,95 +2842,95 @@  discard block
 block discarded – undo
2842 2842
     }
2843 2843
 
2844 2844
     /**
2845
-	 * Set the payment form.
2846
-	 *
2847
-	 * @since 1.0.19
2848
-	 * @param  int $value payment form.
2849
-	 */
2850
-	public function set_payment_form( $value ) {
2851
-		$this->set_prop( 'payment_form', $value );
2845
+     * Set the payment form.
2846
+     *
2847
+     * @since 1.0.19
2848
+     * @param  int $value payment form.
2849
+     */
2850
+    public function set_payment_form( $value ) {
2851
+        $this->set_prop( 'payment_form', $value );
2852 2852
     }
2853 2853
 
2854 2854
     /**
2855
-	 * Set the submission id.
2856
-	 *
2857
-	 * @since 1.0.19
2858
-	 * @param  string $value submission id.
2859
-	 */
2860
-	public function set_submission_id( $value ) {
2861
-		$this->set_prop( 'submission_id', $value );
2855
+     * Set the submission id.
2856
+     *
2857
+     * @since 1.0.19
2858
+     * @param  string $value submission id.
2859
+     */
2860
+    public function set_submission_id( $value ) {
2861
+        $this->set_prop( 'submission_id', $value );
2862 2862
     }
2863 2863
 
2864 2864
     /**
2865
-	 * Set the discount code.
2866
-	 *
2867
-	 * @since 1.0.19
2868
-	 * @param  string $value discount code.
2869
-	 */
2870
-	public function set_discount_code( $value ) {
2871
-		$this->set_prop( 'discount_code', $value );
2865
+     * Set the discount code.
2866
+     *
2867
+     * @since 1.0.19
2868
+     * @param  string $value discount code.
2869
+     */
2870
+    public function set_discount_code( $value ) {
2871
+        $this->set_prop( 'discount_code', $value );
2872 2872
     }
2873 2873
 
2874 2874
     /**
2875
-	 * Set the gateway.
2876
-	 *
2877
-	 * @since 1.0.19
2878
-	 * @param  string $value gateway.
2879
-	 */
2880
-	public function set_gateway( $value ) {
2881
-		$this->set_prop( 'gateway', $value );
2875
+     * Set the gateway.
2876
+     *
2877
+     * @since 1.0.19
2878
+     * @param  string $value gateway.
2879
+     */
2880
+    public function set_gateway( $value ) {
2881
+        $this->set_prop( 'gateway', $value );
2882 2882
     }
2883 2883
 
2884 2884
     /**
2885
-	 * Set the transaction id.
2886
-	 *
2887
-	 * @since 1.0.19
2888
-	 * @param  string $value transaction id.
2889
-	 */
2890
-	public function set_transaction_id( $value ) {
2891
-		if ( ! empty( $value ) ) {
2892
-			$this->set_prop( 'transaction_id', $value );
2893
-		}
2885
+     * Set the transaction id.
2886
+     *
2887
+     * @since 1.0.19
2888
+     * @param  string $value transaction id.
2889
+     */
2890
+    public function set_transaction_id( $value ) {
2891
+        if ( ! empty( $value ) ) {
2892
+            $this->set_prop( 'transaction_id', $value );
2893
+        }
2894 2894
     }
2895 2895
 
2896 2896
     /**
2897
-	 * Set the currency id.
2898
-	 *
2899
-	 * @since 1.0.19
2900
-	 * @param  string $value currency id.
2901
-	 */
2902
-	public function set_currency( $value ) {
2903
-		$this->set_prop( 'currency', $value );
2897
+     * Set the currency id.
2898
+     *
2899
+     * @since 1.0.19
2900
+     * @param  string $value currency id.
2901
+     */
2902
+    public function set_currency( $value ) {
2903
+        $this->set_prop( 'currency', $value );
2904 2904
     }
2905 2905
 
2906
-	/**
2907
-	 * Set whether to disable taxes.
2908
-	 *
2909
-	 * @since 1.0.19
2910
-	 * @param  bool $value value.
2911
-	 */
2912
-	public function set_disable_taxes( $value ) {
2913
-		$this->set_prop( 'disable_taxes', (bool) $value );
2914
-	}
2906
+    /**
2907
+     * Set whether to disable taxes.
2908
+     *
2909
+     * @since 1.0.19
2910
+     * @param  bool $value value.
2911
+     */
2912
+    public function set_disable_taxes( $value ) {
2913
+        $this->set_prop( 'disable_taxes', (bool) $value );
2914
+    }
2915 2915
 
2916 2916
     /**
2917
-	 * Set the subscription id.
2918
-	 *
2919
-	 * @since 1.0.19
2920
-	 * @param  string $value subscription id.
2921
-	 */
2922
-	public function set_subscription_id( $value ) {
2923
-		$this->set_prop( 'subscription_id', $value );
2924
-	}
2917
+     * Set the subscription id.
2918
+     *
2919
+     * @since 1.0.19
2920
+     * @param  string $value subscription id.
2921
+     */
2922
+    public function set_subscription_id( $value ) {
2923
+        $this->set_prop( 'subscription_id', $value );
2924
+    }
2925 2925
 	
2926
-	/**
2927
-	 * Set the remote subscription id.
2928
-	 *
2929
-	 * @since 1.0.19
2930
-	 * @param  string $value subscription id.
2931
-	 */
2932
-	public function set_remote_subscription_id( $value ) {
2933
-		$this->set_prop( 'remote_subscription_id', $value );
2926
+    /**
2927
+     * Set the remote subscription id.
2928
+     *
2929
+     * @since 1.0.19
2930
+     * @param  string $value subscription id.
2931
+     */
2932
+    public function set_remote_subscription_id( $value ) {
2933
+        $this->set_prop( 'remote_subscription_id', $value );
2934 2934
     }
2935 2935
 
2936 2936
     /*
@@ -2969,24 +2969,24 @@  discard block
 block discarded – undo
2969 2969
      */
2970 2970
     public function is_taxable() {
2971 2971
         return ! $this->get_disable_taxes();
2972
-	}
2972
+    }
2973 2973
 
2974
-	/**
2975
-	 * @deprecated
2976
-	 */
2977
-	public function has_vat() {
2974
+    /**
2975
+     * @deprecated
2976
+     */
2977
+    public function has_vat() {
2978 2978
         return $this->is_taxable();
2979
-	}
2979
+    }
2980 2980
 
2981
-	/**
2982
-	 * Checks to see if the invoice requires payment.
2983
-	 */
2984
-	public function is_free() {
2981
+    /**
2982
+     * Checks to see if the invoice requires payment.
2983
+     */
2984
+    public function is_free() {
2985 2985
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2986 2986
 
2987
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2988
-			$is_free = false;
2989
-		}
2987
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2988
+            $is_free = false;
2989
+        }
2990 2990
 
2991 2991
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2992 2992
     }
@@ -2997,46 +2997,46 @@  discard block
 block discarded – undo
2997 2997
     public function is_paid() {
2998 2998
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2999 2999
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3000
-	}
3000
+    }
3001 3001
 
3002
-	/**
3002
+    /**
3003 3003
      * Checks if the invoice needs payment.
3004 3004
      */
3005
-	public function needs_payment() {
3006
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3005
+    public function needs_payment() {
3006
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3007 3007
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3008 3008
     }
3009 3009
   
3010
-	/**
3010
+    /**
3011 3011
      * Checks if the invoice is refunded.
3012 3012
      */
3013
-	public function is_refunded() {
3013
+    public function is_refunded() {
3014 3014
         $is_refunded = $this->has_status( 'wpi-refunded' );
3015 3015
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3016
-	}
3016
+    }
3017 3017
 
3018
-	/**
3018
+    /**
3019 3019
      * Checks if the invoice is held.
3020 3020
      */
3021
-	public function is_held() {
3021
+    public function is_held() {
3022 3022
         $is_held = $this->has_status( 'wpi-onhold' );
3023 3023
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3024
-	}
3024
+    }
3025 3025
 
3026
-	/**
3026
+    /**
3027 3027
      * Checks if the invoice is due.
3028 3028
      */
3029
-	public function is_due() {
3030
-		$due_date = $this->get_due_date();
3031
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3032
-	}
3029
+    public function is_due() {
3030
+        $due_date = $this->get_due_date();
3031
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3032
+    }
3033 3033
 
3034
-	/**
3034
+    /**
3035 3035
      * Checks if the invoice is draft.
3036 3036
      */
3037
-	public function is_draft() {
3037
+    public function is_draft() {
3038 3038
         return $this->has_status( 'draft, auto-draft' );
3039
-	}
3039
+    }
3040 3040
 
3041 3041
     /**
3042 3042
      * Checks if the invoice has a given status.
@@ -3044,9 +3044,9 @@  discard block
 block discarded – undo
3044 3044
     public function has_status( $status ) {
3045 3045
         $status = wpinv_parse_list( $status );
3046 3046
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3047
-	}
3047
+    }
3048 3048
 
3049
-	/**
3049
+    /**
3050 3050
      * Checks if the invoice is of a given type.
3051 3051
      */
3052 3052
     public function is_type( $type ) {
@@ -3069,25 +3069,25 @@  discard block
 block discarded – undo
3069 3069
      */
3070 3070
     public function has_free_trial() {
3071 3071
         return $this->is_recurring() && 0 == $this->get_initial_total();
3072
-	}
3072
+    }
3073 3073
 
3074
-	/**
3074
+    /**
3075 3075
      * @deprecated
3076 3076
      */
3077 3077
     public function is_free_trial() {
3078 3078
         $this->has_free_trial();
3079 3079
     }
3080 3080
 
3081
-	/**
3081
+    /**
3082 3082
      * Check if the initial payment if 0.
3083 3083
      *
3084 3084
      */
3085
-	public function is_initial_free() {
3085
+    public function is_initial_free() {
3086 3086
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3087 3087
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3088 3088
     }
3089 3089
 	
3090
-	/**
3090
+    /**
3091 3091
      * Check if the recurring item has a free trial.
3092 3092
      *
3093 3093
      */
@@ -3100,21 +3100,21 @@  discard block
 block discarded – undo
3100 3100
 
3101 3101
         $item = $this->get_recurring( true );
3102 3102
         return $item->has_free_trial();
3103
-	}
3103
+    }
3104 3104
 
3105
-	/**
3105
+    /**
3106 3106
      * Check if the free trial is a result of a discount.
3107 3107
      */
3108 3108
     public function is_free_trial_from_discount() {
3109
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3110
-	}
3109
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3110
+    }
3111 3111
 	
3112
-	/**
3112
+    /**
3113 3113
      * @deprecated
3114 3114
      */
3115 3115
     public function discount_first_payment_only() {
3116 3116
 
3117
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3117
+        $discount = wpinv_get_discount_obj( $this->get_discount_code() );
3118 3118
         if ( ! $discount->exists() || ! $this->is_recurring() ) {
3119 3119
             return true;
3120 3120
         }
@@ -3139,28 +3139,28 @@  discard block
 block discarded – undo
3139 3139
      */
3140 3140
     public function add_item( $item ) {
3141 3141
 
3142
-		if ( is_array( $item ) ) {
3143
-			$item = $this->process_array_item( $item );
3144
-		}
3142
+        if ( is_array( $item ) ) {
3143
+            $item = $this->process_array_item( $item );
3144
+        }
3145 3145
 
3146
-		if ( is_numeric( $item ) ) {
3147
-			$item = new GetPaid_Form_Item( $item );
3148
-		}
3146
+        if ( is_numeric( $item ) ) {
3147
+            $item = new GetPaid_Form_Item( $item );
3148
+        }
3149 3149
 
3150 3150
         // Make sure that it is available for purchase.
3151
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3152
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3151
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3152
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3153 3153
         }
3154 3154
 
3155 3155
         // Do we have a recurring item?
3156
-		if ( $item->is_recurring() ) {
3156
+        if ( $item->is_recurring() ) {
3157 3157
 
3158
-			// An invoice can only contain one recurring item.
3159
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3160
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3161
-			}
3158
+            // An invoice can only contain one recurring item.
3159
+            if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3160
+                return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3161
+            }
3162 3162
 
3163
-			$this->recurring_item = $item->get_id();
3163
+            $this->recurring_item = $item->get_id();
3164 3164
         }
3165 3165
 
3166 3166
         // Invoice id.
@@ -3171,60 +3171,60 @@  discard block
 block discarded – undo
3171 3171
         $items[ (int) $item->get_id() ] = $item;
3172 3172
 
3173 3173
         $this->set_prop( 'items', $items );
3174
-		return true;
3175
-	}
3174
+        return true;
3175
+    }
3176 3176
 
3177
-	/**
3178
-	 * Converts an array to an item.
3179
-	 *
3180
-	 * @since 1.0.19
3181
-	 * @return GetPaid_Form_Item
3182
-	 */
3183
-	protected function process_array_item( $array ) {
3177
+    /**
3178
+     * Converts an array to an item.
3179
+     *
3180
+     * @since 1.0.19
3181
+     * @return GetPaid_Form_Item
3182
+     */
3183
+    protected function process_array_item( $array ) {
3184 3184
 
3185
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3186
-		$item    = new GetPaid_Form_Item( $item_id );
3185
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3186
+        $item    = new GetPaid_Form_Item( $item_id );
3187 3187
 
3188
-		// Set item data.
3189
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3190
-			if ( isset( $array[ "item_$key" ] ) ) {
3191
-				$method = "set_$key";
3192
-				$item->$method( $array[ "item_$key" ] );
3193
-			}
3194
-		}
3188
+        // Set item data.
3189
+        foreach ( array( 'name', 'price', 'description' ) as $key ) {
3190
+            if ( isset( $array[ "item_$key" ] ) ) {
3191
+                $method = "set_$key";
3192
+                $item->$method( $array[ "item_$key" ] );
3193
+            }
3194
+        }
3195 3195
 
3196
-		if ( isset( $array['quantity'] ) ) {
3197
-			$item->set_quantity( $array['quantity'] );
3198
-		}
3196
+        if ( isset( $array['quantity'] ) ) {
3197
+            $item->set_quantity( $array['quantity'] );
3198
+        }
3199 3199
 
3200
-		// Set item meta.
3201
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3202
-			$item->set_item_meta( $array['meta'] );
3203
-		}
3200
+        // Set item meta.
3201
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3202
+            $item->set_item_meta( $array['meta'] );
3203
+        }
3204 3204
 
3205
-		return $item;
3205
+        return $item;
3206 3206
 
3207
-	}
3207
+    }
3208 3208
 
3209 3209
     /**
3210
-	 * Retrieves a specific item.
3211
-	 *
3212
-	 * @since 1.0.19
3213
-	 */
3214
-	public function get_item( $item_id ) {
3215
-		$items   = $this->get_items();
3216
-		$item_id = (int) $item_id;
3217
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3210
+     * Retrieves a specific item.
3211
+     *
3212
+     * @since 1.0.19
3213
+     */
3214
+    public function get_item( $item_id ) {
3215
+        $items   = $this->get_items();
3216
+        $item_id = (int) $item_id;
3217
+        return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3218 3218
     }
3219 3219
 
3220 3220
     /**
3221
-	 * Removes a specific item.
3222
-	 *
3223
-	 * @since 1.0.19
3224
-	 */
3225
-	public function remove_item( $item_id ) {
3226
-		$items   = $this->get_items();
3227
-		$item_id = (int) $item_id;
3221
+     * Removes a specific item.
3222
+     *
3223
+     * @since 1.0.19
3224
+     */
3225
+    public function remove_item( $item_id ) {
3226
+        $items   = $this->get_items();
3227
+        $item_id = (int) $item_id;
3228 3228
 
3229 3229
         if ( $item_id == $this->recurring_item ) {
3230 3230
             $this->recurring_item = null;
@@ -3237,35 +3237,35 @@  discard block
 block discarded – undo
3237 3237
     }
3238 3238
 
3239 3239
     /**
3240
-	 * Adds a fee to the invoice.
3241
-	 *
3242
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3243
-	 * @since 1.0.19
3244
-	 */
3240
+     * Adds a fee to the invoice.
3241
+     *
3242
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3243
+     * @since 1.0.19
3244
+     */
3245 3245
     public function add_fee( $fee ) {
3246 3246
 
3247
-		$fees                 = $this->get_fees();
3248
-		$fees[ $fee['name'] ] = $fee;
3249
-		$this->set_prop( 'fees', $fees );
3247
+        $fees                 = $this->get_fees();
3248
+        $fees[ $fee['name'] ] = $fee;
3249
+        $this->set_prop( 'fees', $fees );
3250 3250
 
3251 3251
     }
3252 3252
 
3253 3253
     /**
3254
-	 * Retrieves a specific fee.
3255
-	 *
3256
-	 * @since 1.0.19
3257
-	 */
3258
-	public function get_fee( $fee ) {
3254
+     * Retrieves a specific fee.
3255
+     *
3256
+     * @since 1.0.19
3257
+     */
3258
+    public function get_fee( $fee ) {
3259 3259
         $fees = $this->get_fees();
3260
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3260
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3261 3261
     }
3262 3262
 
3263 3263
     /**
3264
-	 * Removes a specific fee.
3265
-	 *
3266
-	 * @since 1.0.19
3267
-	 */
3268
-	public function remove_fee( $fee ) {
3264
+     * Removes a specific fee.
3265
+     *
3266
+     * @since 1.0.19
3267
+     */
3268
+    public function remove_fee( $fee ) {
3269 3269
         $fees = $this->get_fees();
3270 3270
         if ( isset( $fees[ $fee ] ) ) {
3271 3271
             unset( $fees[ $fee ] );
@@ -3273,43 +3273,43 @@  discard block
 block discarded – undo
3273 3273
         }
3274 3274
     }
3275 3275
 
3276
-	/**
3277
-	 * Adds a discount to the invoice.
3278
-	 *
3279
-	 * @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.
3280
-	 * @since 1.0.19
3281
-	 */
3282
-	public function add_discount( $discount ) {
3276
+    /**
3277
+     * Adds a discount to the invoice.
3278
+     *
3279
+     * @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.
3280
+     * @since 1.0.19
3281
+     */
3282
+    public function add_discount( $discount ) {
3283 3283
 
3284
-		$discounts = $this->get_discounts();
3285
-		$discounts[ $discount['name'] ] = $discount;
3286
-		$this->set_prop( 'discounts', $discounts );
3284
+        $discounts = $this->get_discounts();
3285
+        $discounts[ $discount['name'] ] = $discount;
3286
+        $this->set_prop( 'discounts', $discounts );
3287 3287
 
3288
-	}
3288
+    }
3289 3289
 
3290 3290
     /**
3291
-	 * Retrieves a specific discount.
3292
-	 *
3293
-	 * @since 1.0.19
3294
-	 * @return float
3295
-	 */
3296
-	public function get_discount( $discount = false ) {
3291
+     * Retrieves a specific discount.
3292
+     *
3293
+     * @since 1.0.19
3294
+     * @return float
3295
+     */
3296
+    public function get_discount( $discount = false ) {
3297 3297
 
3298
-		// Backwards compatibilty.
3299
-		if ( empty( $discount ) ) {
3300
-			return $this->get_total_discount();
3301
-		}
3298
+        // Backwards compatibilty.
3299
+        if ( empty( $discount ) ) {
3300
+            return $this->get_total_discount();
3301
+        }
3302 3302
 
3303 3303
         $discounts = $this->get_discounts();
3304
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3304
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3305 3305
     }
3306 3306
 
3307 3307
     /**
3308
-	 * Removes a specific discount.
3309
-	 *
3310
-	 * @since 1.0.19
3311
-	 */
3312
-	public function remove_discount( $discount ) {
3308
+     * Removes a specific discount.
3309
+     *
3310
+     * @since 1.0.19
3311
+     */
3312
+    public function remove_discount( $discount ) {
3313 3313
         $discounts = $this->get_discounts();
3314 3314
         if ( isset( $discounts[ $discount ] ) ) {
3315 3315
             unset( $discounts[ $discount ] );
@@ -3326,34 +3326,34 @@  discard block
 block discarded – undo
3326 3326
         if ( $this->is_taxable() ) {
3327 3327
 
3328 3328
             $taxes                 = $this->get_taxes();
3329
-			$taxes[ $tax['name'] ] = $tax;
3330
-			$this->set_prop( 'taxes', $tax );
3329
+            $taxes[ $tax['name'] ] = $tax;
3330
+            $this->set_prop( 'taxes', $tax );
3331 3331
 
3332 3332
         }
3333 3333
     }
3334 3334
 
3335 3335
     /**
3336
-	 * Retrieves a specific tax.
3337
-	 *
3338
-	 * @since 1.0.19
3339
-	 */
3340
-	public function get_tax( $tax = null ) {
3336
+     * Retrieves a specific tax.
3337
+     *
3338
+     * @since 1.0.19
3339
+     */
3340
+    public function get_tax( $tax = null ) {
3341 3341
 
3342
-		// Backwards compatility.
3343
-		if ( empty( $tax ) ) {
3344
-			return $this->get_total_tax();
3345
-		}
3342
+        // Backwards compatility.
3343
+        if ( empty( $tax ) ) {
3344
+            return $this->get_total_tax();
3345
+        }
3346 3346
 
3347 3347
         $taxes = $this->get_taxes();
3348
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3348
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3349 3349
     }
3350 3350
 
3351 3351
     /**
3352
-	 * Removes a specific tax.
3353
-	 *
3354
-	 * @since 1.0.19
3355
-	 */
3356
-	public function remove_tax( $tax ) {
3352
+     * Removes a specific tax.
3353
+     *
3354
+     * @since 1.0.19
3355
+     */
3356
+    public function remove_tax( $tax ) {
3357 3357
         $taxes = $this->get_taxes();
3358 3358
         if ( isset( $taxes[ $tax ] ) ) {
3359 3359
             unset( $taxes[ $tax ] );
@@ -3362,134 +3362,134 @@  discard block
 block discarded – undo
3362 3362
     }
3363 3363
 
3364 3364
     /**
3365
-	 * Recalculates the invoice subtotal.
3366
-	 *
3367
-	 * @since 1.0.19
3368
-	 * @return float The recalculated subtotal
3369
-	 */
3370
-	public function recalculate_subtotal() {
3365
+     * Recalculates the invoice subtotal.
3366
+     *
3367
+     * @since 1.0.19
3368
+     * @return float The recalculated subtotal
3369
+     */
3370
+    public function recalculate_subtotal() {
3371 3371
         $items     = $this->get_items();
3372
-		$subtotal  = 0;
3373
-		$recurring = 0;
3372
+        $subtotal  = 0;
3373
+        $recurring = 0;
3374 3374
 
3375 3375
         foreach ( $items as $item ) {
3376
-			$subtotal  += $item->get_sub_total();
3377
-			$recurring += $item->get_recurring_sub_total();
3376
+            $subtotal  += $item->get_sub_total();
3377
+            $recurring += $item->get_recurring_sub_total();
3378 3378
         }
3379 3379
 
3380
-		$current = $this->is_renewal() ? $recurring : $subtotal;
3381
-		$this->set_subtotal( $current );
3380
+        $current = $this->is_renewal() ? $recurring : $subtotal;
3381
+        $this->set_subtotal( $current );
3382 3382
 
3383
-		$this->totals['subtotal'] = array(
3384
-			'initial'   => $subtotal,
3385
-			'recurring' => $recurring,
3386
-		);
3383
+        $this->totals['subtotal'] = array(
3384
+            'initial'   => $subtotal,
3385
+            'recurring' => $recurring,
3386
+        );
3387 3387
 
3388 3388
         return $current;
3389 3389
     }
3390 3390
 
3391 3391
     /**
3392
-	 * Recalculates the invoice discount total.
3393
-	 *
3394
-	 * @since 1.0.19
3395
-	 * @return float The recalculated discount
3396
-	 */
3397
-	public function recalculate_total_discount() {
3392
+     * Recalculates the invoice discount total.
3393
+     *
3394
+     * @since 1.0.19
3395
+     * @return float The recalculated discount
3396
+     */
3397
+    public function recalculate_total_discount() {
3398 3398
         $discounts = $this->get_discounts();
3399
-		$discount  = 0;
3400
-		$recurring = 0;
3399
+        $discount  = 0;
3400
+        $recurring = 0;
3401 3401
 
3402 3402
         foreach ( $discounts as $data ) {
3403
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3404
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3405
-		}
3403
+            $discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3404
+            $recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3405
+        }
3406 3406
 
3407
-		$current = $this->is_renewal() ? $recurring : $discount;
3407
+        $current = $this->is_renewal() ? $recurring : $discount;
3408 3408
 
3409
-		$this->set_total_discount( $current );
3409
+        $this->set_total_discount( $current );
3410 3410
 
3411
-		$this->totals['discount'] = array(
3412
-			'initial'   => $discount,
3413
-			'recurring' => $recurring,
3414
-		);
3411
+        $this->totals['discount'] = array(
3412
+            'initial'   => $discount,
3413
+            'recurring' => $recurring,
3414
+        );
3415 3415
 
3416
-		return $current;
3416
+        return $current;
3417 3417
 
3418 3418
     }
3419 3419
 
3420 3420
     /**
3421
-	 * Recalculates the invoice tax total.
3422
-	 *
3423
-	 * @since 1.0.19
3424
-	 * @return float The recalculated tax
3425
-	 */
3426
-	public function recalculate_total_tax() {
3421
+     * Recalculates the invoice tax total.
3422
+     *
3423
+     * @since 1.0.19
3424
+     * @return float The recalculated tax
3425
+     */
3426
+    public function recalculate_total_tax() {
3427 3427
         $taxes     = $this->get_taxes();
3428
-		$tax       = 0;
3429
-		$recurring = 0;
3428
+        $tax       = 0;
3429
+        $recurring = 0;
3430 3430
 
3431 3431
         foreach ( $taxes as $data ) {
3432
-			$tax       += wpinv_sanitize_amount( $data['initial_tax'] );
3433
-			$recurring += wpinv_sanitize_amount( $data['recurring_tax'] );
3434
-		}
3432
+            $tax       += wpinv_sanitize_amount( $data['initial_tax'] );
3433
+            $recurring += wpinv_sanitize_amount( $data['recurring_tax'] );
3434
+        }
3435 3435
 
3436
-		$current = $this->is_renewal() ? $recurring : $tax;
3437
-		$this->set_total_tax( $current );
3436
+        $current = $this->is_renewal() ? $recurring : $tax;
3437
+        $this->set_total_tax( $current );
3438 3438
 
3439
-		$this->totals['tax'] = array(
3440
-			'initial'   => $tax,
3441
-			'recurring' => $recurring,
3442
-		);
3439
+        $this->totals['tax'] = array(
3440
+            'initial'   => $tax,
3441
+            'recurring' => $recurring,
3442
+        );
3443 3443
 
3444
-		return $current;
3444
+        return $current;
3445 3445
 
3446 3446
     }
3447 3447
 
3448 3448
     /**
3449
-	 * Recalculates the invoice fees total.
3450
-	 *
3451
-	 * @since 1.0.19
3452
-	 * @return float The recalculated fee
3453
-	 */
3454
-	public function recalculate_total_fees() {
3455
-		$fees      = $this->get_fees();
3456
-		$fee       = 0;
3457
-		$recurring = 0;
3449
+     * Recalculates the invoice fees total.
3450
+     *
3451
+     * @since 1.0.19
3452
+     * @return float The recalculated fee
3453
+     */
3454
+    public function recalculate_total_fees() {
3455
+        $fees      = $this->get_fees();
3456
+        $fee       = 0;
3457
+        $recurring = 0;
3458 3458
 
3459 3459
         foreach ( $fees as $data ) {
3460
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3461
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3462
-		}
3460
+            $fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3461
+            $recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3462
+        }
3463 3463
 
3464
-		$current = $this->is_renewal() ? $recurring : $fee;
3465
-		$this->set_total_fees( $current );
3464
+        $current = $this->is_renewal() ? $recurring : $fee;
3465
+        $this->set_total_fees( $current );
3466 3466
 
3467
-		$this->totals['fee'] = array(
3468
-			'initial'   => $fee,
3469
-			'recurring' => $recurring,
3470
-		);
3467
+        $this->totals['fee'] = array(
3468
+            'initial'   => $fee,
3469
+            'recurring' => $recurring,
3470
+        );
3471 3471
 
3472 3472
         $this->set_total_fees( $fee );
3473 3473
         return $current;
3474 3474
     }
3475 3475
 
3476 3476
     /**
3477
-	 * Recalculates the invoice total.
3478
-	 *
3479
-	 * @since 1.0.19
3477
+     * Recalculates the invoice total.
3478
+     *
3479
+     * @since 1.0.19
3480 3480
      * @return float The invoice total
3481
-	 */
3482
-	public function recalculate_total() {
3481
+     */
3482
+    public function recalculate_total() {
3483 3483
         $this->recalculate_subtotal();
3484 3484
         $this->recalculate_total_fees();
3485 3485
         $this->recalculate_total_discount();
3486 3486
         $this->recalculate_total_tax();
3487
-		return $this->get_total();
3488
-	}
3487
+        return $this->get_total();
3488
+    }
3489 3489
 
3490
-	/**
3491
-	 * @deprecated
3492
-	 */
3490
+    /**
3491
+     * @deprecated
3492
+     */
3493 3493
     public function recalculate_totals() {
3494 3494
         $this->recalculate_total();
3495 3495
         $this->save( true );
@@ -3507,7 +3507,7 @@  discard block
 block discarded – undo
3507 3507
      * Adds a note to an invoice.
3508 3508
      *
3509 3509
      * @param string $note The note being added.
3510
-	 * @return int|false The new note's ID on success, false on failure.
3510
+     * @return int|false The new note's ID on success, false on failure.
3511 3511
      *
3512 3512
      */
3513 3513
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3517,21 +3517,21 @@  discard block
 block discarded – undo
3517 3517
             return false;
3518 3518
         }
3519 3519
 
3520
-		$author       = 'System';
3521
-		$author_email = '[email protected]';
3520
+        $author       = 'System';
3521
+        $author_email = '[email protected]';
3522 3522
 
3523
-		// If this is an admin comment or it has been added by the user.
3524
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3525
-			$user         = get_user_by( 'id', get_current_user_id() );
3523
+        // If this is an admin comment or it has been added by the user.
3524
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3525
+            $user         = get_user_by( 'id', get_current_user_id() );
3526 3526
             $author       = $user->display_name;
3527 3527
             $author_email = $user->user_email;
3528
-		}
3528
+        }
3529 3529
 
3530
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3530
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3531 3531
 
3532
-	}
3532
+    }
3533 3533
 
3534
-	/**
3534
+    /**
3535 3535
      * Generates a unique key for the invoice.
3536 3536
      */
3537 3537
     public function generate_key( $string = '' ) {
@@ -3551,113 +3551,113 @@  discard block
 block discarded – undo
3551 3551
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3552 3552
         }
3553 3553
 
3554
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3555
-
3556
-	}
3557
-
3558
-	/**
3559
-	 * Handle the status transition.
3560
-	 */
3561
-	protected function status_transition() {
3562
-		$status_transition = $this->status_transition;
3563
-
3564
-		// Reset status transition variable.
3565
-		$this->status_transition = false;
3566
-
3567
-		if ( $status_transition ) {
3568
-			try {
3554
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3569 3555
 
3570
-				// Fire a hook for the status change.
3571
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3572
-
3573
-				// @deprecated this is deprecated and will be removed in the future.
3574
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3575
-
3576
-				if ( ! empty( $status_transition['from'] ) ) {
3577
-
3578
-					/* translators: 1: old invoice status 2: new invoice status */
3579
-					$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  ) );
3580
-
3581
-					// Fire another hook.
3582
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3583
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3584
-
3585
-					// @deprecated this is deprecated and will be removed in the future.
3586
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3587
-
3588
-					// Note the transition occurred.
3589
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3590
-
3591
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3592
-					if (
3593
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3594
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3595
-					) {
3596
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3597
-					}
3598
-
3599
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3600
-					if (
3601
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3602
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3603
-					) {
3604
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3605
-					}
3606
-				} else {
3607
-					/* translators: %s: new invoice status */
3608
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3609
-
3610
-					// Note the transition occurred.
3611
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3556
+    }
3612 3557
 
3613
-				}
3614
-			} catch ( Exception $e ) {
3615
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3616
-			}
3617
-		}
3618
-	}
3558
+    /**
3559
+     * Handle the status transition.
3560
+     */
3561
+    protected function status_transition() {
3562
+        $status_transition = $this->status_transition;
3563
+
3564
+        // Reset status transition variable.
3565
+        $this->status_transition = false;
3566
+
3567
+        if ( $status_transition ) {
3568
+            try {
3569
+
3570
+                // Fire a hook for the status change.
3571
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3572
+
3573
+                // @deprecated this is deprecated and will be removed in the future.
3574
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3575
+
3576
+                if ( ! empty( $status_transition['from'] ) ) {
3577
+
3578
+                    /* translators: 1: old invoice status 2: new invoice status */
3579
+                    $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  ) );
3580
+
3581
+                    // Fire another hook.
3582
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3583
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3584
+
3585
+                    // @deprecated this is deprecated and will be removed in the future.
3586
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3587
+
3588
+                    // Note the transition occurred.
3589
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3590
+
3591
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3592
+                    if (
3593
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3594
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3595
+                    ) {
3596
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3597
+                    }
3598
+
3599
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3600
+                    if (
3601
+                        in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3602
+                        && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3603
+                    ) {
3604
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3605
+                    }
3606
+                } else {
3607
+                    /* translators: %s: new invoice status */
3608
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3609
+
3610
+                    // Note the transition occurred.
3611
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3612
+
3613
+                }
3614
+            } catch ( Exception $e ) {
3615
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3616
+            }
3617
+        }
3618
+    }
3619 3619
 
3620
-	/**
3621
-	 * Updates an invoice status.
3622
-	 */
3623
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3620
+    /**
3621
+     * Updates an invoice status.
3622
+     */
3623
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3624 3624
 
3625
-		// Fires before updating a status.
3626
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3625
+        // Fires before updating a status.
3626
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3627 3627
 
3628
-		// Update the status.
3629
-		$this->set_status( $new_status, $note, $manual );
3628
+        // Update the status.
3629
+        $this->set_status( $new_status, $note, $manual );
3630 3630
 
3631
-		// Save the order.
3632
-		return $this->save();
3631
+        // Save the order.
3632
+        return $this->save();
3633 3633
 
3634
-	}
3634
+    }
3635 3635
 
3636
-	/**
3637
-	 * @deprecated
3638
-	 */
3639
-	public function refresh_item_ids() {
3636
+    /**
3637
+     * @deprecated
3638
+     */
3639
+    public function refresh_item_ids() {
3640 3640
         $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3641 3641
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3642
-	}
3642
+    }
3643 3643
 
3644
-	/**
3645
-	 * @deprecated
3646
-	 */
3647
-	public function update_items( $temp = false ) {
3644
+    /**
3645
+     * @deprecated
3646
+     */
3647
+    public function update_items( $temp = false ) {
3648 3648
 
3649
-		$this->set_items( $this->get_items() );
3649
+        $this->set_items( $this->get_items() );
3650 3650
 
3651
-		if ( ! $temp ) {
3652
-			$this->save();
3653
-		}
3651
+        if ( ! $temp ) {
3652
+            $this->save();
3653
+        }
3654 3654
 
3655 3655
         return $this;
3656
-	}
3656
+    }
3657 3657
 
3658
-	/**
3659
-	 * @deprecated
3660
-	 */
3658
+    /**
3659
+     * @deprecated
3660
+     */
3661 3661
     public function validate_discount() {
3662 3662
 
3663 3663
         $discount_code = $this->get_discount_code();
@@ -3673,97 +3673,97 @@  discard block
 block discarded – undo
3673 3673
 
3674 3674
     }
3675 3675
 
3676
-	/**
3677
-	 * Refunds an invoice.
3678
-	 */
3676
+    /**
3677
+     * Refunds an invoice.
3678
+     */
3679 3679
     public function refund() {
3680
-		$this->set_status( 'wpi-refunded' );
3680
+        $this->set_status( 'wpi-refunded' );
3681 3681
         $this->save();
3682
-	}
3682
+    }
3683 3683
 
3684
-	/**
3685
-	 * Marks an invoice as paid.
3686
-	 * 
3687
-	 * @param string $transaction_id
3688
-	 */
3684
+    /**
3685
+     * Marks an invoice as paid.
3686
+     * 
3687
+     * @param string $transaction_id
3688
+     */
3689 3689
     public function mark_paid( $transaction_id = null, $note = '' ) {
3690 3690
 
3691
-		// Set the transaction id.
3692
-		if ( empty( $transaction_id ) ) {
3693
-			$transaction_id = $this->generate_key('trans_');
3694
-		}
3691
+        // Set the transaction id.
3692
+        if ( empty( $transaction_id ) ) {
3693
+            $transaction_id = $this->generate_key('trans_');
3694
+        }
3695 3695
 
3696
-		if ( ! $this->get_transaction_id() ) {
3697
-			$this->set_transaction_id( $transaction_id );
3698
-		}
3696
+        if ( ! $this->get_transaction_id() ) {
3697
+            $this->set_transaction_id( $transaction_id );
3698
+        }
3699 3699
 
3700
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3701
-			return $this->save();
3702
-		}
3700
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3701
+            return $this->save();
3702
+        }
3703 3703
 
3704
-		// Set the completed date.
3705
-		$this->set_date_completed( current_time( 'mysql' ) );
3704
+        // Set the completed date.
3705
+        $this->set_date_completed( current_time( 'mysql' ) );
3706 3706
 
3707
-		// Set the new status.
3708
-		if ( $this->is_renewal() ) {
3707
+        // Set the new status.
3708
+        if ( $this->is_renewal() ) {
3709 3709
 
3710
-			$_note = sprintf(
3711
-				__( 'Renewed via %s', 'invoicing' ),
3712
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3713
-			);
3710
+            $_note = sprintf(
3711
+                __( 'Renewed via %s', 'invoicing' ),
3712
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3713
+            );
3714 3714
 
3715
-			if ( 'none' == $this->get_gateway() ) {
3716
-				$_note = $note;
3717
-			}
3715
+            if ( 'none' == $this->get_gateway() ) {
3716
+                $_note = $note;
3717
+            }
3718 3718
 
3719
-			$this->set_status( 'wpi-renewal', $_note );
3719
+            $this->set_status( 'wpi-renewal', $_note );
3720 3720
 
3721
-		} else {
3721
+        } else {
3722 3722
 
3723
-			$_note = sprintf(
3724
-				__( 'Paid via %s', 'invoicing' ),
3725
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3726
-			);
3723
+            $_note = sprintf(
3724
+                __( 'Paid via %s', 'invoicing' ),
3725
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3726
+            );
3727 3727
 
3728
-			if ( 'none' == $this->get_gateway() ) {
3729
-				$_note = $note;
3730
-			}
3728
+            if ( 'none' == $this->get_gateway() ) {
3729
+                $_note = $note;
3730
+            }
3731 3731
 
3732
-			$this->set_status( 'publish',$_note );
3732
+            $this->set_status( 'publish',$_note );
3733 3733
 
3734
-		}
3734
+        }
3735 3735
 
3736
-		// Set checkout mode.
3737
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3738
-		$this->set_mode( $mode );
3736
+        // Set checkout mode.
3737
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3738
+        $this->set_mode( $mode );
3739 3739
 
3740
-		// Save the invoice.
3740
+        // Save the invoice.
3741 3741
         $this->save();
3742
-	}
3743
-
3744
-
3745
-	/**
3746
-	 * Save data to the database.
3747
-	 *
3748
-	 * @since 1.0.19
3749
-	 * @return int invoice ID
3750
-	 */
3751
-	public function save() {
3752
-		$this->maybe_set_date_paid();
3753
-		$this->maybe_set_key();
3754
-		parent::save();
3755
-		$this->clear_cache();
3756
-		$this->status_transition();
3757
-		return $this->get_id();
3758
-	}
3759
-
3760
-	/**
3742
+    }
3743
+
3744
+
3745
+    /**
3746
+     * Save data to the database.
3747
+     *
3748
+     * @since 1.0.19
3749
+     * @return int invoice ID
3750
+     */
3751
+    public function save() {
3752
+        $this->maybe_set_date_paid();
3753
+        $this->maybe_set_key();
3754
+        parent::save();
3755
+        $this->clear_cache();
3756
+        $this->status_transition();
3757
+        return $this->get_id();
3758
+    }
3759
+
3760
+    /**
3761 3761
      * Clears the subscription's cache.
3762 3762
      */
3763 3763
     public function clear_cache() {
3764
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3765
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3766
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3767
-	}
3764
+        wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3765
+        wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3766
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3767
+    }
3768 3768
 
3769 3769
 }
Please login to merge, or discard this patch.