Passed
Push — master ( 7abbad...7a9f16 )
by Brian
11:26
created
templates/invoice/line-totals.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -9,26 +9,26 @@  discard block
 block discarded – undo
9 9
  * @var WPInv_Invoice $invoice
10 10
  */
11 11
 
12
-defined( 'ABSPATH' ) || exit;
12
+defined('ABSPATH') || exit;
13 13
 
14 14
 // Totals rows.
15
-$totals = getpaid_invoice_totals_rows( $invoice );
15
+$totals = getpaid_invoice_totals_rows($invoice);
16 16
 
17
-do_action( 'getpaid_before_invoice_line_totals', $invoice, $totals );
17
+do_action('getpaid_before_invoice_line_totals', $invoice, $totals);
18 18
 
19 19
 ?>
20 20
 <div class='getpaid-invoice-line-totals'>
21 21
     <div class="row">
22 22
         <div class="col-12 offset-sm-6 col-sm-6 border-sm-left pl-sm-0">
23 23
 
24
-            <?php foreach ( $totals as $key => $label ) : ?>
24
+            <?php foreach ($totals as $key => $label) : ?>
25 25
 
26
-                <div class="getpaid-invoice-line-totals-col <?php echo sanitize_html_class( $key ); ?>">
26
+                <div class="getpaid-invoice-line-totals-col <?php echo sanitize_html_class($key); ?>">
27 27
 
28 28
                     <div class="form-row">
29 29
 
30 30
                         <div class="col-8 getpaid-invoice-line-totals-label">
31
-                            <?php echo esc_html( $label ); ?>
31
+                            <?php echo esc_html($label); ?>
32 32
                         </div>
33 33
 
34 34
                         <div class="col-4 getpaid-invoice-line-totals-value pl-0">
@@ -36,15 +36,15 @@  discard block
 block discarded – undo
36 36
                             <?php
37 37
 
38 38
                                 // Total tax.
39
-                                if ( 'tax' == $key ) {
40
-                                    echo wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() );
39
+                                if ('tax' == $key) {
40
+                                    echo wpinv_price($invoice->get_total_tax(), $invoice->get_currency());
41 41
 
42
-                                    if ( wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) {
42
+                                    if (wpinv_use_taxes() && !$invoice->get_disable_taxes()) {
43 43
 
44 44
                                         $taxes = $invoice->get_total_tax();
45
-                                        if ( empty( $taxes ) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $invoice->get_country() ) ) {
45
+                                        if (empty($taxes) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($invoice->get_country())) {
46 46
                                             echo ' <em class="text-muted small">';
47
-                                            _x( '(Reverse charged)','This is a legal term for reverse charging tax in the EU', 'invoicing' );
47
+                                            _x('(Reverse charged)', 'This is a legal term for reverse charging tax in the EU', 'invoicing');
48 48
                                             echo '</em>';
49 49
                                         }
50 50
 
@@ -53,32 +53,32 @@  discard block
 block discarded – undo
53 53
                                 }
54 54
 
55 55
                                 // Total Fee.
56
-                                if ( 'fee' == $key ) {
57
-                                    echo wpinv_price( $invoice->get_total_fees(), $invoice->get_currency() );
56
+                                if ('fee' == $key) {
57
+                                    echo wpinv_price($invoice->get_total_fees(), $invoice->get_currency());
58 58
                                 }
59 59
 
60 60
                                 // Total discount.
61
-                                if ( 'discount' == $key ) {
62
-                                    echo wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() );
61
+                                if ('discount' == $key) {
62
+                                    echo wpinv_price($invoice->get_total_discount(), $invoice->get_currency());
63 63
                                 }
64 64
 
65 65
                                 // Shipping.
66
-                                if ( 'shipping' == $key ) {
67
-                                    echo wpinv_price( $invoice->get_shipping(), $invoice->get_currency() );
66
+                                if ('shipping' == $key) {
67
+                                    echo wpinv_price($invoice->get_shipping(), $invoice->get_currency());
68 68
                                 }
69 69
 
70 70
                                 // Sub total.
71
-                                if ( 'subtotal' == $key ) {
72
-                                    echo wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() );
71
+                                if ('subtotal' == $key) {
72
+                                    echo wpinv_price($invoice->get_subtotal(), $invoice->get_currency());
73 73
                                 }
74 74
 
75 75
                                 // Total.
76
-                                if ( 'total' == $key ) {
77
-                                    echo wpinv_price( $invoice->get_total(), $invoice->get_currency() );
76
+                                if ('total' == $key) {
77
+                                    echo wpinv_price($invoice->get_total(), $invoice->get_currency());
78 78
                                 }
79 79
  
80 80
                                 // Fires when printing a cart total.
81
-                                do_action( "getpaid_invoice_cart_totals_$key", $invoice );
81
+                                do_action("getpaid_invoice_cart_totals_$key", $invoice);
82 82
 
83 83
                             ?>
84 84
 
@@ -92,4 +92,4 @@  discard block
 block discarded – undo
92 92
     </div>
93 93
 </div> <!-- end .getpaid-invoice-line-totals -->
94 94
 
95
-<?php do_action(  'getpaid_after_invoice_line_totals', $invoice, $totals ); ?>
95
+<?php do_action('getpaid_after_invoice_line_totals', $invoice, $totals); ?>
Please login to merge, or discard this patch.
includes/invoice-functions.php 1 patch
Spacing   +369 added lines, -369 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Retrieves the current invoice.
@@ -14,15 +14,15 @@  discard block
 block discarded – undo
14 14
 function getpaid_get_current_invoice_id() {
15 15
 
16 16
     // Ensure that we have an invoice key.
17
-    if ( empty( $_GET['invoice_key'] ) ) {
17
+    if (empty($_GET['invoice_key'])) {
18 18
         return 0;
19 19
     }
20 20
 
21 21
     // Retrieve an invoice using the key.
22
-    $invoice = new WPInv_Invoice( $_GET['invoice_key'] );
22
+    $invoice = new WPInv_Invoice($_GET['invoice_key']);
23 23
 
24 24
     // Compare the invoice key and the parsed key.
25
-    if ( $invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key'] ) {
25
+    if ($invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key']) {
26 26
         return $invoice->get_id();
27 27
     }
28 28
 
@@ -32,42 +32,42 @@  discard block
 block discarded – undo
32 32
 /**
33 33
  * Checks if the current user cna view an invoice.
34 34
  */
35
-function wpinv_user_can_view_invoice( $invoice ) {
36
-    $invoice = new WPInv_Invoice( $invoice );
35
+function wpinv_user_can_view_invoice($invoice) {
36
+    $invoice = new WPInv_Invoice($invoice);
37 37
 
38 38
     // Abort if the invoice does not exist.
39
-    if ( 0 == $invoice->get_id() ) {
39
+    if (0 == $invoice->get_id()) {
40 40
         return false;
41 41
     }
42 42
 
43 43
     // Don't allow trash, draft status
44
-    if ( $invoice->is_draft() ) {
44
+    if ($invoice->is_draft()) {
45 45
         return false;
46 46
     }
47 47
 
48 48
     // If users are not required to login to check out, compare the invoice keys.
49
-    if ( ! wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && trim( $_GET['invoice_key'] ) == $invoice->get_key() ) {
49
+    if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && trim($_GET['invoice_key']) == $invoice->get_key()) {
50 50
         return true;
51 51
     }
52 52
 
53 53
     // Always enable for admins..
54
-    if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->get_id() ) ) { // Admin user
54
+    if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->get_id())) { // Admin user
55 55
         return true;
56 56
     }
57 57
 
58 58
     // Else, ensure that this is their invoice.
59
-    if ( is_user_logged_in() && $invoice->get_user_id() == get_current_user_id() ) {
59
+    if (is_user_logged_in() && $invoice->get_user_id() == get_current_user_id()) {
60 60
         return true;
61 61
     }
62 62
 
63
-    return apply_filters( 'wpinv_current_user_can_view_invoice', false, $invoice );
63
+    return apply_filters('wpinv_current_user_can_view_invoice', false, $invoice);
64 64
 }
65 65
 
66 66
 /**
67 67
  * Checks if the current user cna view an invoice receipt.
68 68
  */
69
-function wpinv_can_view_receipt( $invoice ) {
70
-	return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice );
69
+function wpinv_can_view_receipt($invoice) {
70
+	return (bool) apply_filters('wpinv_can_view_receipt', wpinv_user_can_view_invoice($invoice), $invoice);
71 71
 }
72 72
 
73 73
 /**
@@ -77,16 +77,16 @@  discard block
 block discarded – undo
77 77
  */
78 78
 function getpaid_get_invoice_post_types() {
79 79
     $post_types = array(
80
-        'wpi_quote'   => __( 'Quote', 'invoicing' ),
81
-        'wpi_invoice' => __( 'Invoice', 'invoicing' ),
80
+        'wpi_quote'   => __('Quote', 'invoicing'),
81
+        'wpi_invoice' => __('Invoice', 'invoicing'),
82 82
     );
83 83
 
84 84
     // Ensure the quotes addon is installed.
85
-    if ( ! defined( 'WPINV_QUOTES_VERSION' ) ) {
86
-        unset( $post_types['wpi_quote'] );
85
+    if (!defined('WPINV_QUOTES_VERSION')) {
86
+        unset($post_types['wpi_quote']);
87 87
     }
88 88
 
89
-    return apply_filters( 'getpaid_invoice_post_types', $post_types );
89
+    return apply_filters('getpaid_invoice_post_types', $post_types);
90 90
 }
91 91
 
92 92
 /**
@@ -95,8 +95,8 @@  discard block
 block discarded – undo
95 95
  *
96 96
  * @param string $post_type The post type to check for.
97 97
  */
98
-function getpaid_is_invoice_post_type( $post_type ) {
99
-    return is_scalar( $post_type ) && ! empty( $post_type ) && array_key_exists( $post_type, getpaid_get_invoice_post_types() );
98
+function getpaid_is_invoice_post_type($post_type) {
99
+    return is_scalar($post_type) && !empty($post_type) && array_key_exists($post_type, getpaid_get_invoice_post_types());
100 100
 }
101 101
 
102 102
 /**
@@ -106,9 +106,9 @@  discard block
 block discarded – undo
106 106
  * @param  bool  $wp_error       Whether to return false or WP_Error on failure.
107 107
  * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success.
108 108
  */
109
-function wpinv_create_invoice( $data = array(), $deprecated = null, $wp_error = false ) {
110
-    $data[ 'invoice_id' ] = 0;
111
-    return wpinv_insert_invoice( $data, $wp_error );
109
+function wpinv_create_invoice($data = array(), $deprecated = null, $wp_error = false) {
110
+    $data['invoice_id'] = 0;
111
+    return wpinv_insert_invoice($data, $wp_error);
112 112
 }
113 113
 
114 114
 /**
@@ -118,36 +118,36 @@  discard block
 block discarded – undo
118 118
  * @param  bool  $wp_error       Whether to return false or WP_Error on failure.
119 119
  * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success.
120 120
  */
121
-function wpinv_update_invoice( $data = array(), $wp_error = false ) {
121
+function wpinv_update_invoice($data = array(), $wp_error = false) {
122 122
 
123 123
     // Backwards compatibility.
124
-    if ( ! empty( $data['ID'] ) ) {
124
+    if (!empty($data['ID'])) {
125 125
         $data['invoice_id'] = $data['ID'];
126 126
     }
127 127
 
128 128
     // Do we have an invoice id?
129
-    if ( empty( $data['invoice_id'] ) ) {
130
-        return $wp_error ? new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ) : 0;
129
+    if (empty($data['invoice_id'])) {
130
+        return $wp_error ? new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')) : 0;
131 131
     }
132 132
 
133 133
     // Retrieve the invoice.
134
-    $invoice = wpinv_get_invoice( $data['invoice_id'] );
134
+    $invoice = wpinv_get_invoice($data['invoice_id']);
135 135
 
136 136
     // And abort if it does not exist.
137
-    if ( empty( $invoice ) ) {
138
-        return $wp_error ? new WP_Error( 'missing_invoice', __( 'Invoice not found.', 'invoicing' ) ) : 0;
137
+    if (empty($invoice)) {
138
+        return $wp_error ? new WP_Error('missing_invoice', __('Invoice not found.', 'invoicing')) : 0;
139 139
     }
140 140
 
141 141
     // Do not update totals for paid / refunded invoices.
142
-    if ( $invoice->is_paid() || $invoice->is_refunded() ) {
142
+    if ($invoice->is_paid() || $invoice->is_refunded()) {
143 143
 
144
-        if ( ! empty( $data['items'] ) || ! empty( $data['cart_details'] ) ) {
145
-            return $wp_error ? new WP_Error( 'paid_invoice', __( 'You can not update cart items for invoices that have already been paid for.', 'invoicing' ) ) : 0;
144
+        if (!empty($data['items']) || !empty($data['cart_details'])) {
145
+            return $wp_error ? new WP_Error('paid_invoice', __('You can not update cart items for invoices that have already been paid for.', 'invoicing')) : 0;
146 146
         }
147 147
 
148 148
     }
149 149
 
150
-    return wpinv_insert_invoice( $data, $wp_error );
150
+    return wpinv_insert_invoice($data, $wp_error);
151 151
 
152 152
 }
153 153
 
@@ -158,34 +158,34 @@  discard block
 block discarded – undo
158 158
  * @param  bool  $wp_error       Whether to return false or WP_Error on failure.
159 159
  * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success.
160 160
  */
161
-function wpinv_insert_invoice( $data = array(), $wp_error = false ) {
161
+function wpinv_insert_invoice($data = array(), $wp_error = false) {
162 162
 
163 163
     // Ensure that we have invoice data.
164
-    if ( empty( $data ) ) {
164
+    if (empty($data)) {
165 165
         return false;
166 166
     }
167 167
 
168 168
     // The invoice id will be provided when updating an invoice.
169
-    $data['invoice_id'] = ! empty( $data['invoice_id'] ) ? (int) $data['invoice_id'] : false;
169
+    $data['invoice_id'] = !empty($data['invoice_id']) ? (int) $data['invoice_id'] : false;
170 170
 
171 171
     // Retrieve the invoice.
172
-    $invoice = new WPInv_Invoice( $data['invoice_id'] );
172
+    $invoice = new WPInv_Invoice($data['invoice_id']);
173 173
 
174 174
     // Do we have an error?
175
-    if ( ! empty( $invoice->last_error ) ) {
176
-        return $wp_error ? new WP_Error( 'invalid_invoice_id', $invoice->last_error ) : 0;
175
+    if (!empty($invoice->last_error)) {
176
+        return $wp_error ? new WP_Error('invalid_invoice_id', $invoice->last_error) : 0;
177 177
     }
178 178
 
179 179
     // Backwards compatibility (billing address).
180
-    if ( ! empty( $data['user_info'] ) ) {
180
+    if (!empty($data['user_info'])) {
181 181
 
182
-        foreach ( $data['user_info'] as $key => $value ) {
182
+        foreach ($data['user_info'] as $key => $value) {
183 183
 
184
-            if ( $key == 'discounts' ) {
184
+            if ($key == 'discounts') {
185 185
                 $value = (array) $value;
186
-                $data[ 'discount_code' ] = empty( $value ) ? null : $value[0];
186
+                $data['discount_code'] = empty($value) ? null : $value[0];
187 187
             } else {
188
-                $data[ $key ] = $value;
188
+                $data[$key] = $value;
189 189
             }
190 190
 
191 191
         }
@@ -193,30 +193,30 @@  discard block
 block discarded – undo
193 193
     }
194 194
 
195 195
     // Backwards compatibility.
196
-    if ( ! empty( $data['payment_details'] ) ) {
196
+    if (!empty($data['payment_details'])) {
197 197
 
198
-        foreach ( $data['payment_details'] as $key => $value ) {
199
-            $data[ $key ] = $value;
198
+        foreach ($data['payment_details'] as $key => $value) {
199
+            $data[$key] = $value;
200 200
         }
201 201
 
202 202
     }
203 203
 
204 204
     // Set up the owner of the invoice.
205
-    $user_id = ! empty( $data['user_id'] ) ? wpinv_clean( $data['user_id'] ) : get_current_user_id();
205
+    $user_id = !empty($data['user_id']) ? wpinv_clean($data['user_id']) : get_current_user_id();
206 206
 
207 207
     // Make sure the user exists.
208
-    if ( ! get_userdata( $user_id ) ) {
209
-        return $wp_error ? new WP_Error( 'wpinv_invalid_user', __( 'There is no user with that ID.', 'invoicing' ) ) : 0;
208
+    if (!get_userdata($user_id)) {
209
+        return $wp_error ? new WP_Error('wpinv_invalid_user', __('There is no user with that ID.', 'invoicing')) : 0;
210 210
     }
211 211
 
212
-    $address = wpinv_get_user_address( $user_id );
212
+    $address = wpinv_get_user_address($user_id);
213 213
 
214
-    foreach ( $address as $key => $value ) {
214
+    foreach ($address as $key => $value) {
215 215
 
216
-        if ( $value == '' ) {
217
-            $address[ $key ] = null;
216
+        if ($value == '') {
217
+            $address[$key] = null;
218 218
         } else {
219
-            $address[ $key ] = wpinv_clean( $value );
219
+            $address[$key] = wpinv_clean($value);
220 220
         }
221 221
 
222 222
     }
@@ -227,103 +227,103 @@  discard block
 block discarded – undo
227 227
         array(
228 228
 
229 229
             // Basic info.
230
-            'template'             => isset( $data['template'] ) ? wpinv_clean( $data['template'] ) : null,
231
-            'email_cc'             => isset( $data['email_cc'] ) ? wpinv_clean( $data['email_cc'] ) : null,
232
-            'date_created'         => isset( $data['created_date'] ) ? wpinv_clean( $data['created_date'] ) : null,
233
-            'due_date'             => isset( $data['due_date'] ) ? wpinv_clean( $data['due_date'] ) : null,
234
-            'date_completed'       => isset( $data['date_completed'] ) ? wpinv_clean( $data['date_completed'] ) : null,
235
-            'number'               => isset( $data['number'] ) ? wpinv_clean( $data['number'] ) : null,
236
-            'key'                  => isset( $data['key'] ) ? wpinv_clean( $data['key'] ) : null,
237
-            'status'               => isset( $data['status'] ) ? wpinv_clean( $data['status'] ) : null,
238
-            'post_type'            => isset( $data['post_type'] ) ? wpinv_clean( $data['post_type'] ) : null,
239
-            'user_ip'              => isset( $data['ip'] ) ? wpinv_clean( $data['ip'] ) : wpinv_get_ip(),
240
-            'parent_id'            => isset( $data['parent'] ) ? intval( $data['parent'] ) : null,
241
-            'mode'                 => isset( $data['mode'] ) ? wpinv_clean( $data['mode'] ) : null,
242
-            'description'          => isset( $data['description'] ) ? wp_kses_post( $data['description'] ) : null,
230
+            'template'             => isset($data['template']) ? wpinv_clean($data['template']) : null,
231
+            'email_cc'             => isset($data['email_cc']) ? wpinv_clean($data['email_cc']) : null,
232
+            'date_created'         => isset($data['created_date']) ? wpinv_clean($data['created_date']) : null,
233
+            'due_date'             => isset($data['due_date']) ? wpinv_clean($data['due_date']) : null,
234
+            'date_completed'       => isset($data['date_completed']) ? wpinv_clean($data['date_completed']) : null,
235
+            'number'               => isset($data['number']) ? wpinv_clean($data['number']) : null,
236
+            'key'                  => isset($data['key']) ? wpinv_clean($data['key']) : null,
237
+            'status'               => isset($data['status']) ? wpinv_clean($data['status']) : null,
238
+            'post_type'            => isset($data['post_type']) ? wpinv_clean($data['post_type']) : null,
239
+            'user_ip'              => isset($data['ip']) ? wpinv_clean($data['ip']) : wpinv_get_ip(),
240
+            'parent_id'            => isset($data['parent']) ? intval($data['parent']) : null,
241
+            'mode'                 => isset($data['mode']) ? wpinv_clean($data['mode']) : null,
242
+            'description'          => isset($data['description']) ? wp_kses_post($data['description']) : null,
243 243
 
244 244
             // Payment info.
245
-            'disable_taxes'        => ! empty( $data['disable_taxes'] ),
246
-            'currency'             => isset( $data['currency'] ) ? wpinv_clean( $data['currency'] ) : wpinv_get_currency(),
247
-            'gateway'              => isset( $data['gateway'] ) ? wpinv_clean( $data['gateway'] ) : null,
248
-            'transaction_id'       => isset( $data['transaction_id'] ) ? wpinv_clean( $data['transaction_id'] ) : null,
249
-            'discount_code'        => isset( $data['discount_code'] ) ? wpinv_clean( $data['discount_code'] ) : null,
250
-            'payment_form'         => isset( $data['payment_form'] ) ? intval( $data['payment_form'] ) : null,
251
-            'submission_id'        => isset( $data['submission_id'] ) ? wpinv_clean( $data['submission_id'] ) : null,
252
-            'subscription_id'      => isset( $data['subscription_id'] ) ? wpinv_clean( $data['subscription_id'] ) : null,
253
-            'is_viewed'            => isset( $data['is_viewed'] ) ? wpinv_clean( $data['is_viewed'] ) : null,
254
-            'fees'                 => isset( $data['fees'] ) ? wpinv_clean( $data['fees'] ) : null,
255
-            'discounts'            => isset( $data['discounts'] ) ? wpinv_clean( $data['discounts'] ) : null,
256
-            'taxes'                => isset( $data['taxes'] ) ? wpinv_clean( $data['taxes'] ) : null,
245
+            'disable_taxes'        => !empty($data['disable_taxes']),
246
+            'currency'             => isset($data['currency']) ? wpinv_clean($data['currency']) : wpinv_get_currency(),
247
+            'gateway'              => isset($data['gateway']) ? wpinv_clean($data['gateway']) : null,
248
+            'transaction_id'       => isset($data['transaction_id']) ? wpinv_clean($data['transaction_id']) : null,
249
+            'discount_code'        => isset($data['discount_code']) ? wpinv_clean($data['discount_code']) : null,
250
+            'payment_form'         => isset($data['payment_form']) ? intval($data['payment_form']) : null,
251
+            'submission_id'        => isset($data['submission_id']) ? wpinv_clean($data['submission_id']) : null,
252
+            'subscription_id'      => isset($data['subscription_id']) ? wpinv_clean($data['subscription_id']) : null,
253
+            'is_viewed'            => isset($data['is_viewed']) ? wpinv_clean($data['is_viewed']) : null,
254
+            'fees'                 => isset($data['fees']) ? wpinv_clean($data['fees']) : null,
255
+            'discounts'            => isset($data['discounts']) ? wpinv_clean($data['discounts']) : null,
256
+            'taxes'                => isset($data['taxes']) ? wpinv_clean($data['taxes']) : null,
257 257
 
258 258
 
259 259
             // Billing details.
260 260
             'user_id'              => $data['user_id'],
261
-            'first_name'           => isset( $data['first_name'] ) ? wpinv_clean( $data['first_name'] ) : $address['first_name'],
262
-            'last_name'            => isset( $data['last_name'] ) ? wpinv_clean( $data['last_name'] ) : $address['last_name'],
263
-            'address'              => isset( $data['address'] ) ? wpinv_clean( $data['address'] ) : $address['address'] ,
264
-            'vat_number'           => isset( $data['vat_number'] ) ? wpinv_clean( $data['vat_number'] ) : $address['vat_number'],
265
-            'company'              => isset( $data['company'] ) ? wpinv_clean( $data['company'] ) : $address['company'],
266
-            'zip'                  => isset( $data['zip'] ) ? wpinv_clean( $data['zip'] ) : $address['zip'],
267
-            'state'                => isset( $data['state'] ) ? wpinv_clean( $data['state'] ) : $address['state'],
268
-            'city'                 => isset( $data['city'] ) ? wpinv_clean( $data['city'] ) : $address['city'],
269
-            'country'              => isset( $data['country'] ) ? wpinv_clean( $data['country'] ) : $address['country'],
270
-            'phone'                => isset( $data['phone'] ) ? wpinv_clean( $data['phone'] ) : $address['phone'],
271
-            'address_confirmed'    => ! empty( $data['address_confirmed'] ),
261
+            'first_name'           => isset($data['first_name']) ? wpinv_clean($data['first_name']) : $address['first_name'],
262
+            'last_name'            => isset($data['last_name']) ? wpinv_clean($data['last_name']) : $address['last_name'],
263
+            'address'              => isset($data['address']) ? wpinv_clean($data['address']) : $address['address'],
264
+            'vat_number'           => isset($data['vat_number']) ? wpinv_clean($data['vat_number']) : $address['vat_number'],
265
+            'company'              => isset($data['company']) ? wpinv_clean($data['company']) : $address['company'],
266
+            'zip'                  => isset($data['zip']) ? wpinv_clean($data['zip']) : $address['zip'],
267
+            'state'                => isset($data['state']) ? wpinv_clean($data['state']) : $address['state'],
268
+            'city'                 => isset($data['city']) ? wpinv_clean($data['city']) : $address['city'],
269
+            'country'              => isset($data['country']) ? wpinv_clean($data['country']) : $address['country'],
270
+            'phone'                => isset($data['phone']) ? wpinv_clean($data['phone']) : $address['phone'],
271
+            'address_confirmed'    => !empty($data['address_confirmed']),
272 272
 
273 273
         )
274 274
 
275 275
     );
276 276
 
277 277
     // Backwards compatibililty.
278
-    if ( ! empty( $data['cart_details'] ) && is_array( $data['cart_details'] ) ) {
278
+    if (!empty($data['cart_details']) && is_array($data['cart_details'])) {
279 279
         $data['items'] = array();
280 280
 
281
-        foreach( $data['cart_details'] as $_item ) {
281
+        foreach ($data['cart_details'] as $_item) {
282 282
 
283 283
             // Ensure that we have an item id.
284
-            if ( empty(  $_item['id']  ) ) {
284
+            if (empty($_item['id'])) {
285 285
                 continue;
286 286
             }
287 287
 
288 288
             // Retrieve the item.
289
-            $item = new GetPaid_Form_Item(  $_item['id']  );
289
+            $item = new GetPaid_Form_Item($_item['id']);
290 290
 
291 291
             // Ensure that it is purchasable.
292
-            if ( ! $item->can_purchase() ) {
292
+            if (!$item->can_purchase()) {
293 293
                 continue;
294 294
             }
295 295
 
296 296
             // Set quantity.
297
-            if ( ! empty( $_item['quantity'] ) && is_numeric( $_item['quantity'] ) ) {
298
-                $item->set_quantity( $_item['quantity'] );
297
+            if (!empty($_item['quantity']) && is_numeric($_item['quantity'])) {
298
+                $item->set_quantity($_item['quantity']);
299 299
             }
300 300
 
301 301
             // Set price.
302
-            if ( isset( $_item['item_price'] ) ) {
303
-                $item->set_price( $_item['item_price'] );
302
+            if (isset($_item['item_price'])) {
303
+                $item->set_price($_item['item_price']);
304 304
             }
305 305
 
306
-            if ( isset( $_item['custom_price'] ) ) {
307
-                $item->set_price( $_item['custom_price'] );
306
+            if (isset($_item['custom_price'])) {
307
+                $item->set_price($_item['custom_price']);
308 308
             }
309 309
 
310 310
             // Set name.
311
-            if ( ! empty( $_item['name'] ) ) {
312
-                $item->set_name( $_item['name'] );
311
+            if (!empty($_item['name'])) {
312
+                $item->set_name($_item['name']);
313 313
             }
314 314
 
315 315
             // Set description.
316
-            if ( isset( $_item['description'] ) ) {
317
-                $item->set_custom_description( $_item['description'] );
316
+            if (isset($_item['description'])) {
317
+                $item->set_custom_description($_item['description']);
318 318
             }
319 319
 
320 320
             // Set meta.
321
-            if ( isset( $_item['meta'] ) && is_array( $_item['meta'] ) ) {
321
+            if (isset($_item['meta']) && is_array($_item['meta'])) {
322 322
 
323
-                $item->set_item_meta( $_item['meta'] );
323
+                $item->set_item_meta($_item['meta']);
324 324
 
325
-                if ( isset( $_item['meta']['description'] ) ) {
326
-                    $item->set_custom_description( $_item['meta']['description'] );
325
+                if (isset($_item['meta']['description'])) {
326
+                    $item->set_custom_description($_item['meta']['description']);
327 327
                 }
328 328
 
329 329
             }
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
     }
335 335
 
336 336
     // Add invoice items.
337
-    if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) {
337
+    if (!empty($data['items']) && is_array($data['items'])) {
338 338
 
339
-        $invoice->set_items( array() );
339
+        $invoice->set_items(array());
340 340
 
341
-        foreach ( $data['items'] as $item ) {
341
+        foreach ($data['items'] as $item) {
342 342
 
343
-            if ( is_object( $item ) && is_a( $item, 'GetPaid_Form_Item' ) && $item->can_purchase() ) {
344
-                $invoice->add_item( $item );
343
+            if (is_object($item) && is_a($item, 'GetPaid_Form_Item') && $item->can_purchase()) {
344
+                $invoice->add_item($item);
345 345
             }
346 346
 
347 347
         }
@@ -352,30 +352,30 @@  discard block
 block discarded – undo
352 352
     $invoice->recalculate_total();
353 353
     $invoice->save();
354 354
 
355
-    if ( ! $invoice->get_id() ) {
356
-        return $wp_error ? new WP_Error( 'wpinv_insert_invoice_error', __( 'An error occured when saving your invoice.', 'invoicing' ) ) : 0;
355
+    if (!$invoice->get_id()) {
356
+        return $wp_error ? new WP_Error('wpinv_insert_invoice_error', __('An error occured when saving your invoice.', 'invoicing')) : 0;
357 357
     }
358 358
 
359 359
     // Add private note.
360
-    if ( ! empty( $data['private_note'] ) ) {
361
-        $invoice->add_note( $data['private_note'] );
360
+    if (!empty($data['private_note'])) {
361
+        $invoice->add_note($data['private_note']);
362 362
     }
363 363
 
364 364
     // User notes.
365
-    if ( !empty( $data['user_note'] ) ) {
366
-        $invoice->add_note( $data['user_note'], true );
365
+    if (!empty($data['user_note'])) {
366
+        $invoice->add_note($data['user_note'], true);
367 367
     }
368 368
 
369 369
     // Created via.
370
-    if ( isset( $data['created_via'] ) ) {
371
-        update_post_meta( $invoice->get_id(), 'wpinv_created_via', $data['created_via'] );
370
+    if (isset($data['created_via'])) {
371
+        update_post_meta($invoice->get_id(), 'wpinv_created_via', $data['created_via']);
372 372
     }
373 373
 
374 374
     // Backwards compatiblity.
375
-    if ( $invoice->is_quote() ) {
375
+    if ($invoice->is_quote()) {
376 376
 
377
-        if ( isset( $data['valid_until'] ) ) {
378
-            update_post_meta( $invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until'] );
377
+        if (isset($data['valid_until'])) {
378
+            update_post_meta($invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until']);
379 379
         }
380 380
 
381 381
     }
@@ -390,20 +390,20 @@  discard block
 block discarded – undo
390 390
  * @param $bool $deprecated
391 391
  * @return WPInv_Invoice|null
392 392
  */
393
-function wpinv_get_invoice( $invoice = 0, $deprecated = false ) {
393
+function wpinv_get_invoice($invoice = 0, $deprecated = false) {
394 394
 
395 395
     // If we are retrieving the invoice from the cart...
396
-    if ( $deprecated && empty( $invoice ) ) {
396
+    if ($deprecated && empty($invoice)) {
397 397
         $invoice = (int) getpaid_get_current_invoice_id();
398 398
     }
399 399
 
400 400
     // Retrieve the invoice.
401
-    if ( ! is_a( $invoice, 'WPInv_Invoice' ) ) {
402
-        $invoice = new WPInv_Invoice( $invoice );
401
+    if (!is_a($invoice, 'WPInv_Invoice')) {
402
+        $invoice = new WPInv_Invoice($invoice);
403 403
     }
404 404
 
405 405
     // Check if it exists.
406
-    if ( $invoice->exists() ) {
406
+    if ($invoice->exists()) {
407 407
         return $invoice;
408 408
     }
409 409
 
@@ -416,15 +416,15 @@  discard block
 block discarded – undo
416 416
  * @param array $args Args to search for.
417 417
  * @return WPInv_Invoice[]|int[]|object
418 418
  */
419
-function wpinv_get_invoices( $args ) {
419
+function wpinv_get_invoices($args) {
420 420
 
421 421
     // Prepare args.
422 422
     $args = wp_parse_args(
423 423
         $args,
424 424
         array(
425
-            'status'   => array_keys( wpinv_get_invoice_statuses() ),
425
+            'status'   => array_keys(wpinv_get_invoice_statuses()),
426 426
             'type'     => 'wpi_invoice',
427
-            'limit'    => get_option( 'posts_per_page' ),
427
+            'limit'    => get_option('posts_per_page'),
428 428
             'return'   => 'objects',
429 429
         )
430 430
     );
@@ -442,24 +442,24 @@  discard block
 block discarded – undo
442 442
         'post__in'       => 'include',
443 443
     );
444 444
 
445
-    foreach ( $map_legacy as $to => $from ) {
446
-        if ( isset( $args[ $from ] ) ) {
447
-            $args[ $to ] = $args[ $from ];
448
-            unset( $args[ $from ] );
445
+    foreach ($map_legacy as $to => $from) {
446
+        if (isset($args[$from])) {
447
+            $args[$to] = $args[$from];
448
+            unset($args[$from]);
449 449
         }
450 450
     }
451 451
 
452 452
     // Backwards compatibility.
453
-    if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) {
453
+    if (!empty($args['email']) && empty($args['user'])) {
454 454
         $args['user'] = $args['email'];
455
-        unset( $args['email'] );
455
+        unset($args['email']);
456 456
     }
457 457
 
458 458
     // Handle cases where the user is set as an email.
459
-    if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) {
460
-        $user = get_user_by( 'email', $args['user'] );
459
+    if (!empty($args['author']) && is_email($args['author'])) {
460
+        $user = get_user_by('email', $args['user']);
461 461
 
462
-        if ( $user ) {
462
+        if ($user) {
463 463
             $args['author'] = $user->user_email;
464 464
         }
465 465
 
@@ -470,31 +470,31 @@  discard block
 block discarded – undo
470 470
 
471 471
     // Show all posts.
472 472
     $paginate = true;
473
-    if ( isset( $args['paginate'] ) ) {
473
+    if (isset($args['paginate'])) {
474 474
 
475 475
         $paginate = $args['paginate'];
476
-        $args['no_found_rows'] = empty( $args['paginate'] );
477
-        unset( $args['paginate'] );
476
+        $args['no_found_rows'] = empty($args['paginate']);
477
+        unset($args['paginate']);
478 478
 
479 479
     }
480 480
 
481 481
     // Whether to return objects or fields.
482 482
     $return = $args['return'];
483
-    unset( $args['return'] );
483
+    unset($args['return']);
484 484
 
485 485
     // Get invoices.
486
-    $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) );
486
+    $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args));
487 487
 
488 488
     // Prepare the results.
489
-    if ( 'objects' === $return ) {
490
-        $results = array_map( 'wpinv_get_invoice', $invoices->posts );
491
-    } elseif ( 'self' === $return ) {
489
+    if ('objects' === $return) {
490
+        $results = array_map('wpinv_get_invoice', $invoices->posts);
491
+    } elseif ('self' === $return) {
492 492
         return $invoices;
493 493
     } else {
494 494
         $results = $invoices->posts;
495 495
     }
496 496
 
497
-    if ( $paginate ) {
497
+    if ($paginate) {
498 498
         return (object) array(
499 499
             'invoices'      => $results,
500 500
             'total'         => $invoices->found_posts,
@@ -512,8 +512,8 @@  discard block
 block discarded – undo
512 512
  * @param string $transaction_id The transaction id to check.
513 513
  * @return int Invoice id on success or 0 on failure
514 514
  */
515
-function wpinv_get_id_by_transaction_id( $transaction_id ) {
516
-    return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' );
515
+function wpinv_get_id_by_transaction_id($transaction_id) {
516
+    return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id');
517 517
 }
518 518
 
519 519
 /**
@@ -522,8 +522,8 @@  discard block
 block discarded – undo
522 522
  * @param string $invoice_number The invoice number to check.
523 523
  * @return int Invoice id on success or 0 on failure
524 524
  */
525
-function wpinv_get_id_by_invoice_number( $invoice_number ) {
526
-    return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' );
525
+function wpinv_get_id_by_invoice_number($invoice_number) {
526
+    return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number');
527 527
 }
528 528
 
529 529
 /**
@@ -532,8 +532,8 @@  discard block
 block discarded – undo
532 532
  * @param string $invoice_key The invoice key to check.
533 533
  * @return int Invoice id on success or 0 on failure
534 534
  */
535
-function wpinv_get_invoice_id_by_key( $invoice_key ) {
536
-    return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' );
535
+function wpinv_get_invoice_id_by_key($invoice_key) {
536
+    return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key');
537 537
 }
538 538
 
539 539
 /**
@@ -543,19 +543,19 @@  discard block
 block discarded – undo
543 543
  * @param string $type Optionally filter by type i.e customer|system
544 544
  * @return array|null
545 545
  */
546
-function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) {
546
+function wpinv_get_invoice_notes($invoice = 0, $type = '') {
547 547
 
548 548
     // Prepare the invoice.
549
-    $invoice = wpinv_get_invoice( $invoice );
550
-    if ( empty( $invoice ) ) {
549
+    $invoice = wpinv_get_invoice($invoice);
550
+    if (empty($invoice)) {
551 551
         return NULL;
552 552
     }
553 553
 
554 554
     // Fetch notes.
555
-    $notes = getpaid_notes()->get_invoice_notes( $invoice->get_id(), $type );
555
+    $notes = getpaid_notes()->get_invoice_notes($invoice->get_id(), $type);
556 556
 
557 557
     // Filter the notes.
558
-    return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type );
558
+    return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type);
559 559
 }
560 560
 
561 561
 /**
@@ -563,10 +563,10 @@  discard block
 block discarded – undo
563 563
  *
564 564
  * @param string $post_type
565 565
  */
566
-function wpinv_get_user_invoices_columns( $post_type = 'wpi_invoice' ) {
566
+function wpinv_get_user_invoices_columns($post_type = 'wpi_invoice') {
567 567
 
568
-    $label   = getpaid_get_post_type_label( $post_type, false );
569
-    $label   = empty( $label ) ? __( 'Invoice', 'invoicing' ) : sanitize_text_field( $label );
568
+    $label   = getpaid_get_post_type_label($post_type, false);
569
+    $label   = empty($label) ? __('Invoice', 'invoicing') : sanitize_text_field($label);
570 570
     $columns = array(
571 571
 
572 572
             'invoice-number'  => array(
@@ -575,22 +575,22 @@  discard block
 block discarded – undo
575 575
             ),
576 576
 
577 577
             'created-date'    => array(
578
-                'title' => __( 'Created Date', 'invoicing' ),
578
+                'title' => __('Created Date', 'invoicing'),
579 579
                 'class' => 'text-left'
580 580
             ),
581 581
 
582 582
             'payment-date'    => array(
583
-                'title' => __( 'Payment Date', 'invoicing' ),
583
+                'title' => __('Payment Date', 'invoicing'),
584 584
                 'class' => 'text-left'
585 585
             ),
586 586
 
587 587
             'invoice-status'  => array(
588
-                'title' => __( 'Status', 'invoicing' ),
588
+                'title' => __('Status', 'invoicing'),
589 589
                 'class' => 'text-center'
590 590
             ),
591 591
 
592 592
             'invoice-total'   => array(
593
-                'title' => __( 'Total', 'invoicing' ),
593
+                'title' => __('Total', 'invoicing'),
594 594
                 'class' => 'text-right'
595 595
             ),
596 596
 
@@ -601,7 +601,7 @@  discard block
 block discarded – undo
601 601
 
602 602
         );
603 603
 
604
-    return apply_filters( 'wpinv_user_invoices_columns', $columns, $post_type );
604
+    return apply_filters('wpinv_user_invoices_columns', $columns, $post_type);
605 605
 }
606 606
 
607 607
 /**
@@ -611,59 +611,59 @@  discard block
 block discarded – undo
611 611
 
612 612
     // Find the invoice.
613 613
     $invoice_id = getpaid_get_current_invoice_id();
614
-    $invoice = new WPInv_Invoice( $invoice_id );
614
+    $invoice = new WPInv_Invoice($invoice_id);
615 615
 
616 616
     // Abort if non was found.
617
-    if ( empty( $invoice_id ) || $invoice->is_draft() ) {
617
+    if (empty($invoice_id) || $invoice->is_draft()) {
618 618
 
619 619
         return aui()->alert(
620 620
             array(
621 621
                 'type'    => 'warning',
622
-                'content' => __( 'We could not find your invoice', 'invoicing' ),
622
+                'content' => __('We could not find your invoice', 'invoicing'),
623 623
             )
624 624
         );
625 625
 
626 626
     }
627 627
 
628 628
     // Can the user view this invoice?
629
-    if ( ! wpinv_can_view_receipt( $invoice_id ) ) {
629
+    if (!wpinv_can_view_receipt($invoice_id)) {
630 630
 
631 631
         return aui()->alert(
632 632
             array(
633 633
                 'type'    => 'warning',
634
-                'content' => __( 'You are not allowed to view this receipt', 'invoicing' ),
634
+                'content' => __('You are not allowed to view this receipt', 'invoicing'),
635 635
             )
636 636
         );
637 637
 
638 638
     }
639 639
 
640 640
     // Load the template.
641
-    return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) );
641
+    return wpinv_get_template_html('invoice-receipt.php', compact('invoice'));
642 642
 
643 643
 }
644 644
 
645 645
 /**
646 646
  * Displays the invoice history.
647 647
  */
648
-function getpaid_invoice_history( $user_id = 0, $post_type = 'wpi_invoice' ) {
648
+function getpaid_invoice_history($user_id = 0, $post_type = 'wpi_invoice') {
649 649
 
650 650
     // Ensure that we have a user id.
651
-    if ( empty( $user_id ) || ! is_numeric( $user_id ) ) {
651
+    if (empty($user_id) || !is_numeric($user_id)) {
652 652
         $user_id = get_current_user_id();
653 653
     }
654 654
 
655
-    $label = getpaid_get_post_type_label( $post_type );
656
-    $label = empty( $label ) ? __( 'Invoices', 'invoicing' ) : sanitize_text_field( $label );
655
+    $label = getpaid_get_post_type_label($post_type);
656
+    $label = empty($label) ? __('Invoices', 'invoicing') : sanitize_text_field($label);
657 657
 
658 658
     // View user id.
659
-    if ( empty( $user_id ) ) {
659
+    if (empty($user_id)) {
660 660
 
661 661
         return aui()->alert(
662 662
             array(
663 663
                 'type'    => 'warning',
664 664
                 'content' => sprintf(
665
-                    __( 'You must be logged in to view your %s.', 'invoicing' ),
666
-                    strtolower( $label )
665
+                    __('You must be logged in to view your %s.', 'invoicing'),
666
+                    strtolower($label)
667 667
                 )
668 668
             )
669 669
         );
@@ -674,23 +674,23 @@  discard block
 block discarded – undo
674 674
     $invoices = wpinv_get_invoices(
675 675
 
676 676
         array(
677
-            'page'      => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1,
677
+            'page'      => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1,
678 678
             'user'      => $user_id,
679 679
             'paginate'  => true,
680 680
             'type'      => $post_type,
681
-            'status'    => array_keys( wpinv_get_invoice_statuses( false, false, $post_type ) ),
681
+            'status'    => array_keys(wpinv_get_invoice_statuses(false, false, $post_type)),
682 682
         )
683 683
 
684 684
     );
685 685
 
686
-    if ( empty( $invoices->total ) ) {
686
+    if (empty($invoices->total)) {
687 687
 
688 688
         return aui()->alert(
689 689
             array(
690 690
                 'type'    => 'info',
691 691
                 'content' => sprintf(
692
-                    __( 'No %s found.', 'invoicing' ),
693
-                    strtolower( $label )
692
+                    __('No %s found.', 'invoicing'),
693
+                    strtolower($label)
694 694
                 )
695 695
             )
696 696
         );
@@ -698,38 +698,38 @@  discard block
 block discarded – undo
698 698
     }
699 699
 
700 700
     // Load the template.
701
-    return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices', 'post_type' ) );
701
+    return wpinv_get_template_html('invoice-history.php', compact('invoices', 'post_type'));
702 702
 
703 703
 }
704 704
 
705 705
 /**
706 706
  * Formats an invoice number given an invoice type.
707 707
  */
708
-function wpinv_format_invoice_number( $number, $type = '' ) {
708
+function wpinv_format_invoice_number($number, $type = '') {
709 709
 
710 710
     // Allow other plugins to overide this.
711
-    $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type );
712
-    if ( null !== $check ) {
711
+    $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type);
712
+    if (null !== $check) {
713 713
         return $check;
714 714
     }
715 715
 
716 716
     // Ensure that we have a numeric number.
717
-    if ( ! is_numeric( $number ) ) {
717
+    if (!is_numeric($number)) {
718 718
         return $number;
719 719
     }
720 720
 
721 721
     // Format the number.
722
-    $padd             = absint( (int) wpinv_get_option( 'invoice_number_padd', 5 ) );
723
-    $prefix           = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_prefix', 'INV-' ) );
724
-    $prefix           = sanitize_text_field( apply_filters( 'getpaid_invoice_type_prefix', $prefix, $type ) );
725
-    $postfix          = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_postfix' ) );
726
-    $postfix          = sanitize_text_field( apply_filters( 'getpaid_invoice_type_postfix', $postfix, $type ) );
727
-    $formatted_number = zeroise( absint( $number ), $padd );
722
+    $padd             = absint((int) wpinv_get_option('invoice_number_padd', 5));
723
+    $prefix           = sanitize_text_field((string) wpinv_get_option('invoice_number_prefix', 'INV-'));
724
+    $prefix           = sanitize_text_field(apply_filters('getpaid_invoice_type_prefix', $prefix, $type));
725
+    $postfix          = sanitize_text_field((string) wpinv_get_option('invoice_number_postfix'));
726
+    $postfix          = sanitize_text_field(apply_filters('getpaid_invoice_type_postfix', $postfix, $type));
727
+    $formatted_number = zeroise(absint($number), $padd);
728 728
 
729 729
     // Add the prefix and post fix.
730 730
     $formatted_number = $prefix . $formatted_number . $postfix;
731 731
 
732
-    return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd );
732
+    return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd);
733 733
 }
734 734
 
735 735
 /**
@@ -738,58 +738,58 @@  discard block
 block discarded – undo
738 738
  * @param string $type.
739 739
  * @return int|null|bool
740 740
  */
741
-function wpinv_get_next_invoice_number( $type = '' ) {
741
+function wpinv_get_next_invoice_number($type = '') {
742 742
 
743 743
     // Allow plugins to overide this.
744
-    $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type );
745
-    if ( null !== $check ) {
744
+    $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type);
745
+    if (null !== $check) {
746 746
         return $check;
747 747
     }
748 748
 
749 749
     // Ensure sequential invoice numbers is active.
750
-    if ( ! wpinv_sequential_number_active() ) {
750
+    if (!wpinv_sequential_number_active()) {
751 751
         return false;
752 752
     }
753 753
 
754 754
     // Retrieve the current number and the start number.
755
-    $number = (int) get_option( 'wpinv_last_invoice_number', 0 );
756
-    $start  = absint( (int) wpinv_get_option( 'invoice_sequence_start', 1 ) );
755
+    $number = (int) get_option('wpinv_last_invoice_number', 0);
756
+    $start  = absint((int) wpinv_get_option('invoice_sequence_start', 1));
757 757
 
758 758
     // Ensure that we are starting at a positive integer.
759
-    $start  = max( $start, 1 );
759
+    $start  = max($start, 1);
760 760
 
761 761
     // If this is the first invoice, use the start number.
762
-    $number = max( $start, $number );
762
+    $number = max($start, $number);
763 763
 
764 764
     // Format the invoice number.
765
-    $formatted_number = wpinv_format_invoice_number( $number, $type );
765
+    $formatted_number = wpinv_format_invoice_number($number, $type);
766 766
 
767 767
     // Ensure that this number is unique.
768
-    $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $formatted_number, 'number' );
768
+    $invoice_id = WPInv_Invoice::get_invoice_id_by_field($formatted_number, 'number');
769 769
 
770 770
     // We found a match. Nice.
771
-    if ( empty( $invoice_id ) ) {
772
-        update_option( 'wpinv_last_invoice_number', $number );
773
-        return apply_filters( 'wpinv_get_next_invoice_number', $number );
771
+    if (empty($invoice_id)) {
772
+        update_option('wpinv_last_invoice_number', $number);
773
+        return apply_filters('wpinv_get_next_invoice_number', $number);
774 774
     }
775 775
 
776
-    update_option( 'wpinv_last_invoice_number', $number + 1 );
777
-    return wpinv_get_next_invoice_number( $type );
776
+    update_option('wpinv_last_invoice_number', $number + 1);
777
+    return wpinv_get_next_invoice_number($type);
778 778
 
779 779
 }
780 780
 
781 781
 /**
782 782
  * The prefix used for invoice paths.
783 783
  */
784
-function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) {
785
-    return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type );
784
+function wpinv_post_name_prefix($post_type = 'wpi_invoice') {
785
+    return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type);
786 786
 }
787 787
 
788
-function wpinv_generate_post_name( $post_ID ) {
789
-    $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) );
790
-    $post_name = sanitize_title( $prefix . $post_ID );
788
+function wpinv_generate_post_name($post_ID) {
789
+    $prefix = wpinv_post_name_prefix(get_post_type($post_ID));
790
+    $post_name = sanitize_title($prefix . $post_ID);
791 791
 
792
-    return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix );
792
+    return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix);
793 793
 }
794 794
 
795 795
 /**
@@ -797,8 +797,8 @@  discard block
 block discarded – undo
797 797
  *
798 798
  * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object.
799 799
  */
800
-function wpinv_is_invoice_viewed( $invoice ) {
801
-    $invoice = new WPInv_Invoice( $invoice );
800
+function wpinv_is_invoice_viewed($invoice) {
801
+    $invoice = new WPInv_Invoice($invoice);
802 802
     return (bool) $invoice->get_is_viewed();
803 803
 }
804 804
 
@@ -807,17 +807,17 @@  discard block
 block discarded – undo
807 807
  *
808 808
  * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object.
809 809
  */
810
-function getpaid_maybe_mark_invoice_as_viewed( $invoice ) {
811
-    $invoice = new WPInv_Invoice( $invoice );
810
+function getpaid_maybe_mark_invoice_as_viewed($invoice) {
811
+    $invoice = new WPInv_Invoice($invoice);
812 812
 
813
-    if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) {
814
-        $invoice->set_is_viewed( true );
813
+    if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) {
814
+        $invoice->set_is_viewed(true);
815 815
         $invoice->save();
816 816
     }
817 817
 
818 818
 }
819
-add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' );
820
-add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' );
819
+add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed');
820
+add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed');
821 821
 
822 822
 /**
823 823
  * Processes an invoice refund.
@@ -826,27 +826,27 @@  discard block
 block discarded – undo
826 826
  * @param array $status_transition
827 827
  * @todo: descrease customer/store earnings
828 828
  */
829
-function getpaid_maybe_process_refund( $invoice, $status_transition ) {
829
+function getpaid_maybe_process_refund($invoice, $status_transition) {
830 830
 
831
-    if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) {
831
+    if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) {
832 832
         return;
833 833
     }
834 834
 
835 835
     $discount_code = $invoice->get_discount_code();
836
-    if ( ! empty( $discount_code ) ) {
837
-        $discount = wpinv_get_discount_obj( $discount_code );
836
+    if (!empty($discount_code)) {
837
+        $discount = wpinv_get_discount_obj($discount_code);
838 838
 
839
-        if ( $discount->exists() ) {
839
+        if ($discount->exists()) {
840 840
             $discount->increase_usage( -1 );
841 841
         }
842 842
 
843 843
     }
844 844
 
845
-    do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice->get_id() );
846
-    do_action( 'wpinv_refund_invoice', $invoice, $invoice->get_id() );
847
-    do_action( 'wpinv_post_refund_invoice', $invoice, $invoice->get_id() );
845
+    do_action('wpinv_pre_refund_invoice', $invoice, $invoice->get_id());
846
+    do_action('wpinv_refund_invoice', $invoice, $invoice->get_id());
847
+    do_action('wpinv_post_refund_invoice', $invoice, $invoice->get_id());
848 848
 }
849
-add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2 );
849
+add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 2);
850 850
 
851 851
 
852 852
 /**
@@ -854,49 +854,49 @@  discard block
 block discarded – undo
854 854
  *
855 855
  * @param int $invoice_id
856 856
  */
857
-function getpaid_process_invoice_payment( $invoice_id ) {
857
+function getpaid_process_invoice_payment($invoice_id) {
858 858
 
859 859
     // Fetch the invoice.
860
-    $invoice = new WPInv_Invoice( $invoice_id );
860
+    $invoice = new WPInv_Invoice($invoice_id);
861 861
 
862 862
     // We only want to do this once.
863
-    if ( 1 ==  get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) {
863
+    if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) {
864 864
         return;
865 865
     }
866 866
 
867
-    update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 );
867
+    update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1);
868 868
 
869 869
     // Fires when processing a payment.
870
-    do_action( 'getpaid_process_payment', $invoice );
870
+    do_action('getpaid_process_payment', $invoice);
871 871
 
872 872
     // Fire an action for each invoice item.
873
-    foreach( $invoice->get_items() as $item ) {
874
-        do_action( 'getpaid_process_item_payment', $item, $invoice );
873
+    foreach ($invoice->get_items() as $item) {
874
+        do_action('getpaid_process_item_payment', $item, $invoice);
875 875
     }
876 876
 
877 877
     // Increase discount usage.
878 878
     $discount_code = $invoice->get_discount_code();
879
-    if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) {
880
-        $discount = wpinv_get_discount_obj( $discount_code );
879
+    if (!empty($discount_code) && !$invoice->is_renewal()) {
880
+        $discount = wpinv_get_discount_obj($discount_code);
881 881
 
882
-        if ( $discount->exists() ) {
882
+        if ($discount->exists()) {
883 883
             $discount->increase_usage();
884 884
         }
885 885
 
886 886
     }
887 887
 
888 888
     // Record reverse vat.
889
-    if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) {
889
+    if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) {
890 890
 
891 891
         $taxes = $invoice->get_total_tax();
892
-        if ( empty( $taxes ) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $invoice->get_country() ) ) {
893
-            $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true );
892
+        if (empty($taxes) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($invoice->get_country())) {
893
+            $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true);
894 894
         }
895 895
 
896 896
     }
897 897
 
898 898
 }
899
-add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' );
899
+add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment');
900 900
 
901 901
 /**
902 902
  * Returns an array of invoice item columns
@@ -904,13 +904,13 @@  discard block
 block discarded – undo
904 904
  * @param int|WPInv_Invoice $invoice
905 905
  * @return array
906 906
  */
907
-function getpaid_invoice_item_columns( $invoice ) {
907
+function getpaid_invoice_item_columns($invoice) {
908 908
 
909 909
     // Prepare the invoice.
910
-    $invoice = new WPInv_Invoice( $invoice );
910
+    $invoice = new WPInv_Invoice($invoice);
911 911
 
912 912
     // Abort if there is no invoice.
913
-    if ( 0 == $invoice->get_id() ) {
913
+    if (0 == $invoice->get_id()) {
914 914
         return array();
915 915
     }
916 916
 
@@ -918,57 +918,57 @@  discard block
 block discarded – undo
918 918
     $columns = apply_filters(
919 919
         'getpaid_invoice_item_columns',
920 920
         array(
921
-            'name'     => __( 'Item', 'invoicing' ),
922
-            'price'    => __( 'Price', 'invoicing' ),
923
-            'tax_rate' => __( 'Tax Rate', 'invoicing' ),
924
-            'quantity' => __( 'Quantity', 'invoicing' ),
925
-            'subtotal' => __( 'Item Subtotal', 'invoicing' ),
921
+            'name'     => __('Item', 'invoicing'),
922
+            'price'    => __('Price', 'invoicing'),
923
+            'tax_rate' => __('Tax Rate', 'invoicing'),
924
+            'quantity' => __('Quantity', 'invoicing'),
925
+            'subtotal' => __('Item Subtotal', 'invoicing'),
926 926
         ),
927 927
         $invoice
928 928
     );
929 929
 
930 930
     // Quantities.
931
-    if ( isset( $columns[ 'quantity' ] ) ) {
931
+    if (isset($columns['quantity'])) {
932 932
 
933
-        if ( 'hours' == $invoice->get_template() ) {
934
-            $columns[ 'quantity' ] = __( 'Hours', 'invoicing' );
933
+        if ('hours' == $invoice->get_template()) {
934
+            $columns['quantity'] = __('Hours', 'invoicing');
935 935
         }
936 936
 
937
-        if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) {
938
-            unset( $columns[ 'quantity' ] );
937
+        if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) {
938
+            unset($columns['quantity']);
939 939
         }
940 940
 
941 941
     }
942 942
 
943 943
 
944 944
     // Price.
945
-    if ( isset( $columns[ 'price' ] ) ) {
945
+    if (isset($columns['price'])) {
946 946
 
947
-        if ( 'amount' == $invoice->get_template() ) {
948
-            $columns[ 'price' ] = __( 'Amount', 'invoicing' );
947
+        if ('amount' == $invoice->get_template()) {
948
+            $columns['price'] = __('Amount', 'invoicing');
949 949
         }
950 950
 
951
-        if ( 'hours' == $invoice->get_template() ) {
952
-            $columns[ 'price' ] = __( 'Rate', 'invoicing' );
951
+        if ('hours' == $invoice->get_template()) {
952
+            $columns['price'] = __('Rate', 'invoicing');
953 953
         }
954 954
 
955 955
     }
956 956
 
957 957
 
958 958
     // Sub total.
959
-    if ( isset( $columns[ 'subtotal' ] ) ) {
959
+    if (isset($columns['subtotal'])) {
960 960
 
961
-        if ( 'amount' == $invoice->get_template() ) {
962
-            unset( $columns[ 'subtotal' ] );
961
+        if ('amount' == $invoice->get_template()) {
962
+            unset($columns['subtotal']);
963 963
         }
964 964
 
965 965
     }
966 966
 
967 967
     // Tax rates.
968
-    if ( isset( $columns[ 'tax_rate' ] ) ) {
968
+    if (isset($columns['tax_rate'])) {
969 969
 
970
-        if ( 0 == $invoice->get_tax() ) {
971
-            unset( $columns[ 'tax_rate' ] );
970
+        if (0 == $invoice->get_tax()) {
971
+            unset($columns['tax_rate']);
972 972
         }
973 973
 
974 974
     }
@@ -982,43 +982,43 @@  discard block
 block discarded – undo
982 982
  * @param int|WPInv_Invoice $invoice
983 983
  * @return array
984 984
  */
985
-function getpaid_invoice_totals_rows( $invoice ) {
985
+function getpaid_invoice_totals_rows($invoice) {
986 986
 
987 987
     // Prepare the invoice.
988
-    $invoice = new WPInv_Invoice( $invoice );
988
+    $invoice = new WPInv_Invoice($invoice);
989 989
 
990 990
     // Abort if there is no invoice.
991
-    if ( 0 == $invoice->get_id() ) {
991
+    if (0 == $invoice->get_id()) {
992 992
         return array();
993 993
     }
994 994
 
995 995
     $totals = apply_filters(
996 996
         'getpaid_invoice_totals_rows',
997 997
         array(
998
-            'subtotal' => __( 'Subtotal', 'invoicing' ),
999
-            'shipping' => __( 'Shipping', 'invoicing' ),
1000
-            'tax'      => __( 'Tax', 'invoicing' ),
1001
-            'fee'      => __( 'Fee', 'invoicing' ),
1002
-            'discount' => __( 'Discount', 'invoicing' ),
1003
-            'total'    => __( 'Total', 'invoicing' ),
998
+            'subtotal' => __('Subtotal', 'invoicing'),
999
+            'shipping' => __('Shipping', 'invoicing'),
1000
+            'tax'      => __('Tax', 'invoicing'),
1001
+            'fee'      => __('Fee', 'invoicing'),
1002
+            'discount' => __('Discount', 'invoicing'),
1003
+            'total'    => __('Total', 'invoicing'),
1004 1004
         ),
1005 1005
         $invoice
1006 1006
     );
1007 1007
 
1008
-    if ( ! $invoice->has_shipping() ) {
1009
-        unset( $totals['shipping'] );
1008
+    if (!$invoice->has_shipping()) {
1009
+        unset($totals['shipping']);
1010 1010
     }
1011 1011
 
1012
-    if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) {
1013
-        unset( $totals['tax'] );
1012
+    if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) {
1013
+        unset($totals['tax']);
1014 1014
     }
1015 1015
 
1016
-    if ( 0 == $invoice->get_total_fees() && isset( $totals['fee'] ) ) {
1017
-        unset( $totals['fee'] );
1016
+    if (0 == $invoice->get_total_fees() && isset($totals['fee'])) {
1017
+        unset($totals['fee']);
1018 1018
     }
1019 1019
 
1020
-    if ( 0 == $invoice->get_total_discount() && isset( $totals['discount'] ) ) {
1021
-        unset( $totals['discount'] );
1020
+    if (0 == $invoice->get_total_discount() && isset($totals['discount'])) {
1021
+        unset($totals['discount']);
1022 1022
     }
1023 1023
 
1024 1024
     return $totals;
@@ -1029,47 +1029,47 @@  discard block
 block discarded – undo
1029 1029
  *
1030 1030
  * @param WPInv_Invoice $invoice
1031 1031
  */
1032
-function getpaid_new_invoice( $invoice ) {
1032
+function getpaid_new_invoice($invoice) {
1033 1033
 
1034
-    if ( ! $invoice->get_status() ) {
1034
+    if (!$invoice->get_status()) {
1035 1035
         return;
1036 1036
     }
1037 1037
 
1038 1038
     // Add an invoice created note.
1039 1039
     $invoice->add_note(
1040 1040
         sprintf(
1041
-            __( '%s created with the status "%s".', 'invoicing' ),
1042
-            ucfirst( $invoice->get_invoice_quote_type() ),
1043
-            wpinv_status_nicename( $invoice->get_status(), $invoice  )
1041
+            __('%s created with the status "%s".', 'invoicing'),
1042
+            ucfirst($invoice->get_invoice_quote_type()),
1043
+            wpinv_status_nicename($invoice->get_status(), $invoice)
1044 1044
         )
1045 1045
     );
1046 1046
 
1047 1047
 }
1048
-add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' );
1048
+add_action('getpaid_new_invoice', 'getpaid_new_invoice');
1049 1049
 
1050 1050
 /**
1051 1051
  * This function updates invoice caches.
1052 1052
  *
1053 1053
  * @param WPInv_Invoice $invoice
1054 1054
  */
1055
-function getpaid_update_invoice_caches( $invoice ) {
1055
+function getpaid_update_invoice_caches($invoice) {
1056 1056
 
1057 1057
     // Cache invoice number.
1058
-    wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" );
1058
+    wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids");
1059 1059
 
1060 1060
     // Cache invoice key.
1061
-    wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" );
1061
+    wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids");
1062 1062
 
1063 1063
     // (Maybe) cache transaction id.
1064 1064
     $transaction_id = $invoice->get_transaction_id();
1065 1065
 
1066
-    if ( ! empty( $transaction_id ) ) {
1067
-        wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" );
1066
+    if (!empty($transaction_id)) {
1067
+        wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids");
1068 1068
     }
1069 1069
 
1070 1070
 }
1071
-add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 );
1072
-add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 );
1071
+add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5);
1072
+add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5);
1073 1073
 
1074 1074
 /**
1075 1075
  * Duplicates an invoice.
@@ -1079,7 +1079,7 @@  discard block
 block discarded – undo
1079 1079
  * @param  WPInv_Invoice $old_invoice The invoice to duplicate
1080 1080
  * @return WPInv_Invoice The new invoice.
1081 1081
  */
1082
-function getpaid_duplicate_invoice( $old_invoice ) {
1082
+function getpaid_duplicate_invoice($old_invoice) {
1083 1083
 
1084 1084
     // Create the new invoice.
1085 1085
     $invoice = new WPInv_Invoice();
@@ -1140,133 +1140,133 @@  discard block
 block discarded – undo
1140 1140
  * @param WPInv_Invoice $invoice
1141 1141
  * @return array
1142 1142
  */
1143
-function getpaid_get_invoice_meta( $invoice ) {
1143
+function getpaid_get_invoice_meta($invoice) {
1144 1144
 
1145 1145
     // Load the invoice meta.
1146 1146
     $meta = array(
1147 1147
 
1148 1148
         'number' => array(
1149 1149
             'label' => sprintf(
1150
-                __( '%s Number', 'invoicing' ),
1151
-                ucfirst( $invoice->get_invoice_quote_type() )
1150
+                __('%s Number', 'invoicing'),
1151
+                ucfirst($invoice->get_invoice_quote_type())
1152 1152
             ),
1153
-            'value' => sanitize_text_field( $invoice->get_number() ),
1153
+            'value' => sanitize_text_field($invoice->get_number()),
1154 1154
         ),
1155 1155
 
1156 1156
         'status' => array(
1157 1157
             'label' => sprintf(
1158
-                __( '%s Status', 'invoicing' ),
1159
-                ucfirst( $invoice->get_invoice_quote_type() )
1158
+                __('%s Status', 'invoicing'),
1159
+                ucfirst($invoice->get_invoice_quote_type())
1160 1160
             ),
1161 1161
             'value' => $invoice->get_status_label_html(),
1162 1162
         ),
1163 1163
 
1164 1164
         'date' => array(
1165 1165
             'label' => sprintf(
1166
-                __( '%s Date', 'invoicing' ),
1167
-                ucfirst( $invoice->get_invoice_quote_type() )
1166
+                __('%s Date', 'invoicing'),
1167
+                ucfirst($invoice->get_invoice_quote_type())
1168 1168
             ),
1169
-            'value' => getpaid_format_date( $invoice->get_created_date() ),
1169
+            'value' => getpaid_format_date($invoice->get_created_date()),
1170 1170
         ),
1171 1171
 
1172 1172
         'date_paid' => array(
1173
-            'label' => __( 'Paid On', 'invoicing' ),
1174
-            'value' => getpaid_format_date( $invoice->get_completed_date() ),
1173
+            'label' => __('Paid On', 'invoicing'),
1174
+            'value' => getpaid_format_date($invoice->get_completed_date()),
1175 1175
         ),
1176 1176
 
1177 1177
         'gateway'   => array(
1178
-            'label' => __( 'Payment Method', 'invoicing' ),
1179
-            'value' => sanitize_text_field( $invoice->get_gateway_title() ),
1178
+            'label' => __('Payment Method', 'invoicing'),
1179
+            'value' => sanitize_text_field($invoice->get_gateway_title()),
1180 1180
         ),
1181 1181
 
1182 1182
         'transaction_id' => array(
1183
-            'label' => __( 'Transaction ID', 'invoicing' ),
1184
-            'value' => sanitize_text_field( $invoice->get_transaction_id() ),
1183
+            'label' => __('Transaction ID', 'invoicing'),
1184
+            'value' => sanitize_text_field($invoice->get_transaction_id()),
1185 1185
         ),
1186 1186
 
1187 1187
         'due_date'  => array(
1188
-            'label' => __( 'Due Date', 'invoicing' ),
1189
-            'value' => getpaid_format_date( $invoice->get_due_date() ),
1188
+            'label' => __('Due Date', 'invoicing'),
1189
+            'value' => getpaid_format_date($invoice->get_due_date()),
1190 1190
         ),
1191 1191
 
1192 1192
         'vat_number' => array(
1193
-            'label' => __( 'VAT Number', 'invoicing' ),
1194
-            'value' => sanitize_text_field( $invoice->get_vat_number() ),
1193
+            'label' => __('VAT Number', 'invoicing'),
1194
+            'value' => sanitize_text_field($invoice->get_vat_number()),
1195 1195
         ),
1196 1196
 
1197 1197
     );
1198 1198
 
1199
-    $additional_meta = get_post_meta( $invoice->get_id(), 'additional_meta_data', true );
1199
+    $additional_meta = get_post_meta($invoice->get_id(), 'additional_meta_data', true);
1200 1200
 
1201
-    if ( ! empty( $additional_meta ) ) {
1201
+    if (!empty($additional_meta)) {
1202 1202
 
1203
-        foreach ( $additional_meta as $label => $value ) {
1204
-            $meta[ sanitize_key( $label ) ] = array(
1205
-                'label' => esc_html( $label ),
1206
-                'value' => esc_html( $value ),
1203
+        foreach ($additional_meta as $label => $value) {
1204
+            $meta[sanitize_key($label)] = array(
1205
+                'label' => esc_html($label),
1206
+                'value' => esc_html($value),
1207 1207
             );
1208 1208
         }
1209 1209
 
1210 1210
     }
1211 1211
     // If it is not paid, remove the date of payment.
1212
-    if ( ! $invoice->is_paid() && ! $invoice->is_refunded() ) {
1213
-        unset( $meta[ 'date_paid' ] );
1214
-        unset( $meta[ 'transaction_id' ] );
1212
+    if (!$invoice->is_paid() && !$invoice->is_refunded()) {
1213
+        unset($meta['date_paid']);
1214
+        unset($meta['transaction_id']);
1215 1215
     }
1216 1216
 
1217
-    if ( ! $invoice->is_paid() || 'none' == $invoice->get_gateway() ) {
1218
-        unset( $meta[ 'gateway' ] );
1217
+    if (!$invoice->is_paid() || 'none' == $invoice->get_gateway()) {
1218
+        unset($meta['gateway']);
1219 1219
     }
1220 1220
 
1221 1221
     // Only display the due date if due dates are enabled.
1222
-    if ( ! $invoice->needs_payment() || ! wpinv_get_option( 'overdue_active' ) ) {
1223
-        unset( $meta[ 'due_date' ] );
1222
+    if (!$invoice->needs_payment() || !wpinv_get_option('overdue_active')) {
1223
+        unset($meta['due_date']);
1224 1224
     }
1225 1225
 
1226 1226
     // Only display the vat number if taxes are enabled.
1227
-    if ( ! wpinv_use_taxes() ) {
1228
-        unset( $meta[ 'vat_number' ] );
1227
+    if (!wpinv_use_taxes()) {
1228
+        unset($meta['vat_number']);
1229 1229
     }
1230 1230
 
1231 1231
     // Link to the parent invoice.
1232
-    if ( $invoice->get_parent_id() > 0 ) {
1232
+    if ($invoice->get_parent_id() > 0) {
1233 1233
 
1234
-        $meta[ 'parent' ] = array(
1234
+        $meta['parent'] = array(
1235 1235
 
1236 1236
             'label' => sprintf(
1237
-                __( 'Parent %s', 'invoicing' ),
1238
-                ucfirst( $invoice->get_invoice_quote_type() )
1237
+                __('Parent %s', 'invoicing'),
1238
+                ucfirst($invoice->get_invoice_quote_type())
1239 1239
             ),
1240 1240
 
1241
-            'value' => wpinv_invoice_link( $invoice->get_parent_id() ),
1241
+            'value' => wpinv_invoice_link($invoice->get_parent_id()),
1242 1242
 
1243 1243
         );
1244 1244
 
1245 1245
     }
1246 1246
 
1247 1247
     
1248
-    if ( $invoice->is_recurring() ) {
1248
+    if ($invoice->is_recurring()) {
1249 1249
 
1250
-        $subscription = getpaid_get_invoice_subscriptions( $invoice );
1251
-        if ( ! empty ( $subscription ) && ! is_array( $subscription ) && $subscription->exists() ) {
1250
+        $subscription = getpaid_get_invoice_subscriptions($invoice);
1251
+        if (!empty ($subscription) && !is_array($subscription) && $subscription->exists()) {
1252 1252
 
1253 1253
             // Display the renewal date.
1254
-            if ( $subscription->is_active() && 'cancelled' != $subscription->get_status() ) {
1254
+            if ($subscription->is_active() && 'cancelled' != $subscription->get_status()) {
1255 1255
 
1256
-                $meta[ 'renewal_date' ] = array(
1257
-                    'label' => __( 'Renews On', 'invoicing' ),
1258
-                    'value' => getpaid_format_date( $subscription->get_expiration() ),
1256
+                $meta['renewal_date'] = array(
1257
+                    'label' => __('Renews On', 'invoicing'),
1258
+                    'value' => getpaid_format_date($subscription->get_expiration()),
1259 1259
                 );
1260 1260
 
1261 1261
             }
1262 1262
 
1263
-            if ( $invoice->is_parent() ) {
1263
+            if ($invoice->is_parent()) {
1264 1264
 
1265 1265
                 // Display the recurring amount.
1266
-                $meta[ 'recurring_total' ] = array(
1266
+                $meta['recurring_total'] = array(
1267 1267
 
1268
-                    'label' => __( 'Recurring Amount', 'invoicing' ),
1269
-                    'value' => wpinv_price( $subscription->get_recurring_amount(), $invoice->get_currency() ),
1268
+                    'label' => __('Recurring Amount', 'invoicing'),
1269
+                    'value' => wpinv_price($subscription->get_recurring_amount(), $invoice->get_currency()),
1270 1270
 
1271 1271
                 );
1272 1272
 
@@ -1276,15 +1276,15 @@  discard block
 block discarded – undo
1276 1276
     }
1277 1277
 
1278 1278
     // Add the invoice total to the meta.
1279
-    $meta[ 'invoice_total' ] = array(
1279
+    $meta['invoice_total'] = array(
1280 1280
 
1281
-        'label' => __( 'Total Amount', 'invoicing' ),
1282
-        'value' => wpinv_price( $invoice->get_total(), $invoice->get_currency() ),
1281
+        'label' => __('Total Amount', 'invoicing'),
1282
+        'value' => wpinv_price($invoice->get_total(), $invoice->get_currency()),
1283 1283
 
1284 1284
     );
1285 1285
 
1286 1286
     // Provide a way for third party plugins to filter the meta.
1287
-    $meta = apply_filters( 'getpaid_invoice_meta_data', $meta, $invoice );
1287
+    $meta = apply_filters('getpaid_invoice_meta_data', $meta, $invoice);
1288 1288
 
1289 1289
     return $meta;
1290 1290
 
@@ -1323,12 +1323,12 @@  discard block
 block discarded – undo
1323 1323
  * @param GetPaid_Form_Item $item
1324 1324
  * @return float
1325 1325
  */
1326
-function getpaid_get_invoice_tax_rate( $invoice, $item ) {
1326
+function getpaid_get_invoice_tax_rate($invoice, $item) {
1327 1327
 
1328
-    $rates   = getpaid_get_item_tax_rates( $item, $invoice->get_country(), $invoice->get_state() );
1329
-	$rates   = getpaid_filter_item_tax_rates( $item, $rates );
1330
-    $rates   = wp_list_pluck( $rates, 'rate' );
1328
+    $rates   = getpaid_get_item_tax_rates($item, $invoice->get_country(), $invoice->get_state());
1329
+	$rates = getpaid_filter_item_tax_rates($item, $rates);
1330
+    $rates   = wp_list_pluck($rates, 'rate');
1331 1331
 
1332
-    return array_sum( $rates );
1332
+    return array_sum($rates);
1333 1333
 
1334 1334
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission.php 1 patch
Spacing   +130 added lines, -130 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 		$this->state   = wpinv_get_default_state();
147 147
 
148 148
 		// Do we have an actual submission?
149
-		if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
150
-			$this->load_data( $_POST );
149
+		if (isset($_POST['getpaid_payment_form_submission'])) {
150
+			$this->load_data($_POST);
151 151
 		}
152 152
 
153 153
 	}
@@ -157,19 +157,19 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @param array $data
159 159
 	 */
160
-	public function load_data( $data ) {
160
+	public function load_data($data) {
161 161
 
162 162
 		// Remove slashes from the submitted data...
163
-		$data       = wp_kses_post_deep( wp_unslash( $data ) );
163
+		$data       = wp_kses_post_deep(wp_unslash($data));
164 164
 
165 165
 		// Allow plugins to filter the data.
166
-		$data       = apply_filters( 'getpaid_submission_data', $data, $this );
166
+		$data       = apply_filters('getpaid_submission_data', $data, $this);
167 167
 
168 168
 		// Cache it...
169 169
 		$this->data = $data;
170 170
 
171 171
 		// Then generate a unique id from the data.
172
-		$this->id   = md5( wp_json_encode( $data ) );
172
+		$this->id   = md5(wp_json_encode($data));
173 173
 
174 174
 		// Finally, process the submission.
175 175
 		try {
@@ -179,30 +179,30 @@  discard block
 block discarded – undo
179 179
 			$processors = apply_filters(
180 180
 				'getpaid_payment_form_submission_processors',
181 181
 				array(
182
-					array( $this, 'process_payment_form' ),
183
-					array( $this, 'process_invoice' ),
184
-					array( $this, 'process_fees' ),
185
-					array( $this, 'process_items' ),
186
-					array( $this, 'process_discount' ),
187
-					array( $this, 'process_taxes' ),
182
+					array($this, 'process_payment_form'),
183
+					array($this, 'process_invoice'),
184
+					array($this, 'process_fees'),
185
+					array($this, 'process_items'),
186
+					array($this, 'process_discount'),
187
+					array($this, 'process_taxes'),
188 188
 				),
189 189
 				$this		
190 190
 			);
191 191
 
192
-			foreach ( $processors as $processor ) {
193
-				call_user_func_array( $processor, array( &$this ) );
192
+			foreach ($processors as $processor) {
193
+				call_user_func_array($processor, array(&$this));
194 194
 			}
195 195
 
196
-		} catch( GetPaid_Payment_Exception $e ) {
196
+		} catch (GetPaid_Payment_Exception $e) {
197 197
 			$this->last_error      = $e->getMessage();
198 198
 			$this->last_error_code = $e->getErrorCode();
199
-		} catch ( Exception $e ) {
199
+		} catch (Exception $e) {
200 200
 			$this->last_error      = $e->getMessage();
201 201
 			$this->last_error_code = $e->getCode();
202 202
 		}
203 203
 
204 204
 		// Fired when we are done processing a submission.
205
-		do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
205
+		do_action_ref_array('getpaid_process_submission', array(&$this));
206 206
 
207 207
 	}
208 208
 
@@ -223,18 +223,18 @@  discard block
 block discarded – undo
223 223
 	public function process_payment_form() {
224 224
 
225 225
 		// Every submission needs an active payment form.
226
-		if ( empty( $this->data['form_id'] ) ) {
227
-			throw new Exception( __( 'Missing payment form', 'invoicing' ) );
226
+		if (empty($this->data['form_id'])) {
227
+			throw new Exception(__('Missing payment form', 'invoicing'));
228 228
 		}
229 229
 
230 230
 		// Fetch the payment form.
231
-		$this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] );
231
+		$this->payment_form = new GetPaid_Payment_Form($this->data['form_id']);
232 232
 
233
-		if ( ! $this->payment_form->is_active() ) {
234
-			throw new Exception( __( 'Payment form not active', 'invoicing' ) );
233
+		if (!$this->payment_form->is_active()) {
234
+			throw new Exception(__('Payment form not active', 'invoicing'));
235 235
 		}
236 236
 
237
-		do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) );
237
+		do_action_ref_array('getpaid_submissions_process_payment_form', array(&$this));
238 238
 	}
239 239
 
240 240
     /**
@@ -264,53 +264,53 @@  discard block
 block discarded – undo
264 264
 	public function process_invoice() {
265 265
 
266 266
 		// Abort if there is no invoice.
267
-		if ( empty( $this->data['invoice_id'] ) ) {
267
+		if (empty($this->data['invoice_id'])) {
268 268
 			return;
269 269
 		}
270 270
 
271 271
 		// If the submission is for an existing invoice, ensure that it exists
272 272
 		// and that it is not paid for.
273
-		$invoice = wpinv_get_invoice( $this->data['invoice_id'] );
273
+		$invoice = wpinv_get_invoice($this->data['invoice_id']);
274 274
 
275
-        if ( empty( $invoice ) ) {
276
-			throw new Exception( __( 'Invalid invoice', 'invoicing' ) );
275
+        if (empty($invoice)) {
276
+			throw new Exception(__('Invalid invoice', 'invoicing'));
277 277
 		}
278 278
 
279
-		if ( $invoice->is_paid() ) {
280
-			throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) );
279
+		if ($invoice->is_paid()) {
280
+			throw new Exception(__('This invoice is already paid for.', 'invoicing'));
281 281
 		}
282 282
 
283 283
 		$this->payment_form->invoice = $invoice;
284
-		if ( ! $this->payment_form->is_default() ) {
284
+		if (!$this->payment_form->is_default()) {
285 285
 
286 286
 			$items    = array();
287 287
 			$item_ids = array();
288 288
 	
289
-			foreach ( $invoice->get_items() as $item ) {
290
-				if ( ! in_array( $item->get_id(), $item_ids ) ) {
289
+			foreach ($invoice->get_items() as $item) {
290
+				if (!in_array($item->get_id(), $item_ids)) {
291 291
 					$item_ids[] = $item->get_id();
292 292
 					$items[]    = $item;
293 293
 				}
294 294
 			}
295 295
 	
296
-			foreach ( $this->payment_form->get_items() as $item ) {
297
-				if ( ! in_array( $item->get_id(), $item_ids ) ) {
296
+			foreach ($this->payment_form->get_items() as $item) {
297
+				if (!in_array($item->get_id(), $item_ids)) {
298 298
 					$item_ids[] = $item->get_id();
299 299
 					$items[]    = $item;
300 300
 				}
301 301
 			}
302 302
 	
303
-			$this->payment_form->set_items( $items );
303
+			$this->payment_form->set_items($items);
304 304
 	
305 305
 		} else {
306
-			$this->payment_form->set_items( $invoice->get_items() );
306
+			$this->payment_form->set_items($invoice->get_items());
307 307
 		}
308 308
 
309 309
 		$this->country = $invoice->get_country();
310 310
 		$this->state   = $invoice->get_state();
311 311
 		$this->invoice = $invoice;
312 312
 
313
-		do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) );
313
+		do_action_ref_array('getpaid_submissions_process_invoice', array(&$this));
314 314
 	}
315 315
 
316 316
 	/**
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
 	 * @return bool
331 331
 	 */
332 332
 	public function has_invoice() {
333
-		return ! empty( $this->invoice );
333
+		return !empty($this->invoice);
334 334
 	}
335 335
 
336 336
 	/*
@@ -349,13 +349,13 @@  discard block
 block discarded – undo
349 349
 	 */
350 350
 	public function process_items() {
351 351
 
352
-		$processor = new GetPaid_Payment_Form_Submission_Items( $this );
352
+		$processor = new GetPaid_Payment_Form_Submission_Items($this);
353 353
 
354
-		foreach ( $processor->items as $item ) {
355
-			$this->add_item( $item );
354
+		foreach ($processor->items as $item) {
355
+			$this->add_item($item);
356 356
 		}
357 357
 
358
-		do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) );
358
+		do_action_ref_array('getpaid_submissions_process_items', array(&$this));
359 359
 	}
360 360
 
361 361
 	/**
@@ -364,20 +364,20 @@  discard block
 block discarded – undo
364 364
 	 * @since 1.0.19
365 365
 	 * @param GetPaid_Form_Item $item
366 366
 	 */
367
-	public function add_item( $item ) {
367
+	public function add_item($item) {
368 368
 
369 369
 		// Make sure that it is available for purchase.
370
-		if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) {
370
+		if (!$item->can_purchase() || isset($this->items[$item->get_id()])) {
371 371
 			return;
372 372
 		}
373 373
 
374 374
 		// Each submission can only contain one recurring item.
375
-		if ( $item->is_recurring() ) {
375
+		if ($item->is_recurring()) {
376 376
 			$this->has_recurring = $item->get_id();
377 377
 		}
378 378
 
379 379
 		// Update the items and totals.
380
-		$this->items[ $item->get_id() ]         = $item;
380
+		$this->items[$item->get_id()]         = $item;
381 381
 		$this->totals['subtotal']['initial']   += $item->get_sub_total();
382 382
 		$this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total();
383 383
 
@@ -391,17 +391,17 @@  discard block
 block discarded – undo
391 391
 	 *
392 392
 	 * @since 1.0.19
393 393
 	 */
394
-	public function remove_item( $item_id ) {
394
+	public function remove_item($item_id) {
395 395
 
396
-		if ( isset( $this->items[ $item_id ] ) ) {
397
-			$this->totals['subtotal']['initial']   -= $this->items[ $item_id ]->get_sub_total();
398
-			$this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total();
396
+		if (isset($this->items[$item_id])) {
397
+			$this->totals['subtotal']['initial']   -= $this->items[$item_id]->get_sub_total();
398
+			$this->totals['subtotal']['recurring'] -= $this->items[$item_id]->get_recurring_sub_total();
399 399
 
400
-			if ( $this->items[ $item_id ]->is_recurring() ) {
400
+			if ($this->items[$item_id]->is_recurring()) {
401 401
 				$this->has_recurring = 0;
402 402
 			}
403 403
 
404
-			unset( $this->items[ $item_id ] );
404
+			unset($this->items[$item_id]);
405 405
 		}
406 406
 
407 407
 	}
@@ -413,7 +413,7 @@  discard block
 block discarded – undo
413 413
 	 */
414 414
 	public function get_subtotal() {
415 415
 
416
-		if ( wpinv_prices_include_tax() ) {
416
+		if (wpinv_prices_include_tax()) {
417 417
 			return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial'];
418 418
 		}
419 419
 
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 	 */
428 428
 	public function get_recurring_subtotal() {
429 429
 
430
-		if ( wpinv_prices_include_tax() ) {
430
+		if (wpinv_prices_include_tax()) {
431 431
 			return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring'];
432 432
 		}
433 433
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
 	 * @return bool
452 452
 	 */
453 453
 	public function has_subscription_group() {
454
-		return $this->has_recurring && getpaid_should_group_subscriptions( $this ) && 1 == count( getpaid_get_subscription_groups( $this ) );
454
+		return $this->has_recurring && getpaid_should_group_subscriptions($this) && 1 == count(getpaid_get_subscription_groups($this));
455 455
 	}
456 456
 
457 457
 	/**
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 	 * @return bool
462 462
 	 */
463 463
 	public function has_multiple_subscription_groups() {
464
-		return $this->has_recurring && 1 < count( getpaid_get_subscription_groups( $this ) );
464
+		return $this->has_recurring && 1 < count(getpaid_get_subscription_groups($this));
465 465
 	}
466 466
 
467 467
 	/*
@@ -481,39 +481,39 @@  discard block
 block discarded – undo
481 481
 	public function process_taxes() {
482 482
 
483 483
 		// Abort if we're not using taxes.
484
-		if ( ! $this->use_taxes() ) {
484
+		if (!$this->use_taxes()) {
485 485
 			return;
486 486
 		}
487 487
 
488 488
 		// If a custom country && state has been passed in, use it to calculate taxes.
489
-		$country = $this->get_field( 'wpinv_country', 'billing' );
490
-		if ( ! empty( $country ) ) {
489
+		$country = $this->get_field('wpinv_country', 'billing');
490
+		if (!empty($country)) {
491 491
 			$this->country = $country;
492 492
 		}
493 493
 
494
-		$state = $this->get_field( 'wpinv_state', 'billing' );
495
-		if ( ! empty( $state ) ) {
494
+		$state = $this->get_field('wpinv_state', 'billing');
495
+		if (!empty($state)) {
496 496
 			$this->state = $state;
497 497
 		}
498 498
 
499 499
 		// Confirm if the provided country and the ip country are similar.
500
-		$address_confirmed = $this->get_field( 'confirm-address' );
501
-		if ( isset( $_POST['billing']['country'] ) && wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty( $address_confirmed ) ) {
502
-			throw new Exception( __( 'The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing' ) );
500
+		$address_confirmed = $this->get_field('confirm-address');
501
+		if (isset($_POST['billing']['country']) && wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty($address_confirmed)) {
502
+			throw new Exception(__('The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing'));
503 503
 		}
504 504
 
505 505
 		// Abort if the country is not taxable.
506
-		if ( ! wpinv_is_country_taxable( $this->country ) ) {
506
+		if (!wpinv_is_country_taxable($this->country)) {
507 507
 			return;
508 508
 		}
509 509
 
510
-		$processor = new GetPaid_Payment_Form_Submission_Taxes( $this );
510
+		$processor = new GetPaid_Payment_Form_Submission_Taxes($this);
511 511
 
512
-		foreach ( $processor->taxes as $tax ) {
513
-			$this->add_tax( $tax );
512
+		foreach ($processor->taxes as $tax) {
513
+			$this->add_tax($tax);
514 514
 		}
515 515
 
516
-		do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) );
516
+		do_action_ref_array('getpaid_submissions_process_taxes', array(&$this));
517 517
 	}
518 518
 
519 519
 	/**
@@ -522,16 +522,16 @@  discard block
 block discarded – undo
522 522
 	 * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
523 523
 	 * @since 1.0.19
524 524
 	 */
525
-	public function add_tax( $tax ) {
525
+	public function add_tax($tax) {
526 526
 
527
-		if ( wpinv_round_tax_per_tax_rate() ) {
528
-			$tax['initial_tax']   = wpinv_round_amount( $tax['initial_tax'] );
529
-			$tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] );
527
+		if (wpinv_round_tax_per_tax_rate()) {
528
+			$tax['initial_tax']   = wpinv_round_amount($tax['initial_tax']);
529
+			$tax['recurring_tax'] = wpinv_round_amount($tax['recurring_tax']);
530 530
 		}
531 531
 
532
-		$this->taxes[ $tax['name'] ]         = $tax;
533
-		$this->totals['taxes']['initial']   += wpinv_sanitize_amount( $tax['initial_tax'] );
534
-		$this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] );
532
+		$this->taxes[$tax['name']]         = $tax;
533
+		$this->totals['taxes']['initial']   += wpinv_sanitize_amount($tax['initial_tax']);
534
+		$this->totals['taxes']['recurring'] += wpinv_sanitize_amount($tax['recurring_tax']);
535 535
 
536 536
 	}
537 537
 
@@ -540,12 +540,12 @@  discard block
 block discarded – undo
540 540
 	 *
541 541
 	 * @since 1.0.19
542 542
 	 */
543
-	public function remove_tax( $tax_name ) {
543
+	public function remove_tax($tax_name) {
544 544
 
545
-		if ( isset( $this->taxes[ $tax_name ] ) ) {
546
-			$this->totals['taxes']['initial']   -= $this->taxes[ $tax_name ]['initial_tax'];
547
-			$this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax'];
548
-			unset( $this->taxes[ $tax_name ] );
545
+		if (isset($this->taxes[$tax_name])) {
546
+			$this->totals['taxes']['initial']   -= $this->taxes[$tax_name]['initial_tax'];
547
+			$this->totals['taxes']['recurring'] -= $this->taxes[$tax_name]['recurring_tax'];
548
+			unset($this->taxes[$tax_name]);
549 549
 		}
550 550
 
551 551
 	}
@@ -559,11 +559,11 @@  discard block
 block discarded – undo
559 559
 
560 560
 		$use_taxes = wpinv_use_taxes();
561 561
 
562
-		if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) {
562
+		if ($this->has_invoice() && !$this->invoice->is_taxable()) {
563 563
 			$use_taxes = false;
564 564
 		}
565 565
 
566
-		return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
566
+		return apply_filters('getpaid_submission_use_taxes', $use_taxes, $this);
567 567
 
568 568
 	}
569 569
 
@@ -612,13 +612,13 @@  discard block
 block discarded – undo
612 612
 
613 613
 		$initial_total    = $this->get_subtotal() + $this->get_fee() + $this->get_tax();
614 614
 		$recurring_total  = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax();
615
-		$processor        = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total );
615
+		$processor        = new GetPaid_Payment_Form_Submission_Discount($this, $initial_total, $recurring_total);
616 616
 
617
-		foreach ( $processor->discounts as $discount ) {
618
-			$this->add_discount( $discount );
617
+		foreach ($processor->discounts as $discount) {
618
+			$this->add_discount($discount);
619 619
 		}
620 620
 
621
-		do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) );
621
+		do_action_ref_array('getpaid_submissions_process_discounts', array(&$this));
622 622
 	}
623 623
 
624 624
 	/**
@@ -627,10 +627,10 @@  discard block
 block discarded – undo
627 627
 	 * @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.
628 628
 	 * @since 1.0.19
629 629
 	 */
630
-	public function add_discount( $discount ) {
631
-		$this->discounts[ $discount['name'] ]   = $discount;
632
-		$this->totals['discount']['initial']   += wpinv_sanitize_amount( $discount['initial_discount'] );
633
-		$this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] );
630
+	public function add_discount($discount) {
631
+		$this->discounts[$discount['name']]   = $discount;
632
+		$this->totals['discount']['initial']   += wpinv_sanitize_amount($discount['initial_discount']);
633
+		$this->totals['discount']['recurring'] += wpinv_sanitize_amount($discount['recurring_discount']);
634 634
 	}
635 635
 
636 636
 	/**
@@ -638,12 +638,12 @@  discard block
 block discarded – undo
638 638
 	 *
639 639
 	 * @since 1.0.19
640 640
 	 */
641
-	public function remove_discount( $name ) {
641
+	public function remove_discount($name) {
642 642
 
643
-		if ( isset( $this->discounts[ $name ] ) ) {
644
-			$this->totals['discount']['initial']   -= $this->discounts[ $name ]['initial_discount'];
645
-			$this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount'];
646
-			unset( $this->discounts[ $name ] );
643
+		if (isset($this->discounts[$name])) {
644
+			$this->totals['discount']['initial']   -= $this->discounts[$name]['initial_discount'];
645
+			$this->totals['discount']['recurring'] -= $this->discounts[$name]['recurring_discount'];
646
+			unset($this->discounts[$name]);
647 647
 		}
648 648
 
649 649
 	}
@@ -655,7 +655,7 @@  discard block
 block discarded – undo
655 655
 	 * @return bool
656 656
 	 */
657 657
 	public function has_discount_code() {
658
-		return ! empty( $this->discounts['discount_code'] );
658
+		return !empty($this->discounts['discount_code']);
659 659
 	}
660 660
 
661 661
 	/**
@@ -712,13 +712,13 @@  discard block
 block discarded – undo
712 712
 	 */
713 713
 	public function process_fees() {
714 714
 
715
-		$fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this );
715
+		$fees_processor = new GetPaid_Payment_Form_Submission_Fees($this);
716 716
 
717
-		foreach ( $fees_processor->fees as $fee ) {
718
-			$this->add_fee( $fee );
717
+		foreach ($fees_processor->fees as $fee) {
718
+			$this->add_fee($fee);
719 719
 		}
720 720
 
721
-		do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) );
721
+		do_action_ref_array('getpaid_submissions_process_fees', array(&$this));
722 722
 	}
723 723
 
724 724
 	/**
@@ -727,17 +727,17 @@  discard block
 block discarded – undo
727 727
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
728 728
 	 * @since 1.0.19
729 729
 	 */
730
-	public function add_fee( $fee ) {
730
+	public function add_fee($fee) {
731 731
 
732
-		if ( $fee['name'] == 'shipping' ) {
733
-			$this->totals['shipping']['initial']   += wpinv_sanitize_amount( $fee['initial_fee'] );
734
-			$this->totals['shipping']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] );
732
+		if ($fee['name'] == 'shipping') {
733
+			$this->totals['shipping']['initial']   += wpinv_sanitize_amount($fee['initial_fee']);
734
+			$this->totals['shipping']['recurring'] += wpinv_sanitize_amount($fee['recurring_fee']);
735 735
 			return;
736 736
 		}
737 737
 
738
-		$this->fees[ $fee['name'] ]         = $fee;
739
-		$this->totals['fees']['initial']   += wpinv_sanitize_amount( $fee['initial_fee'] );
740
-		$this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] );
738
+		$this->fees[$fee['name']]         = $fee;
739
+		$this->totals['fees']['initial']   += wpinv_sanitize_amount($fee['initial_fee']);
740
+		$this->totals['fees']['recurring'] += wpinv_sanitize_amount($fee['recurring_fee']);
741 741
 
742 742
 	}
743 743
 
@@ -746,15 +746,15 @@  discard block
 block discarded – undo
746 746
 	 *
747 747
 	 * @since 1.0.19
748 748
 	 */
749
-	public function remove_fee( $name ) {
749
+	public function remove_fee($name) {
750 750
 
751
-		if ( isset( $this->fees[ $name ] ) ) {
752
-			$this->totals['fees']['initial']   -= $this->fees[ $name ]['initial_fee'];
753
-			$this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee'];
754
-			unset( $this->fees[ $name ] );
751
+		if (isset($this->fees[$name])) {
752
+			$this->totals['fees']['initial']   -= $this->fees[$name]['initial_fee'];
753
+			$this->totals['fees']['recurring'] -= $this->fees[$name]['recurring_fee'];
754
+			unset($this->fees[$name]);
755 755
 		}
756 756
 
757
-		if ( 'shipping' == $name ) {
757
+		if ('shipping' == $name) {
758 758
 			$this->totals['shipping']['initial']   = 0;
759 759
 			$this->totals['shipping']['recurring'] = 0;
760 760
 		}
@@ -795,7 +795,7 @@  discard block
 block discarded – undo
795 795
 	 * @since 1.0.19
796 796
 	 */
797 797
 	public function has_fees() {
798
-		return count( $this->fees ) !== 0;
798
+		return count($this->fees) !== 0;
799 799
 	}
800 800
 
801 801
 	/*
@@ -831,7 +831,7 @@  discard block
 block discarded – undo
831 831
 	 * @since 1.0.19
832 832
 	 */
833 833
 	public function has_shipping() {
834
-		return apply_filters( 'getpaid_payment_form_has_shipping', false, $this );
834
+		return apply_filters('getpaid_payment_form_has_shipping', false, $this);
835 835
 	}
836 836
 
837 837
 	/**
@@ -841,7 +841,7 @@  discard block
 block discarded – undo
841 841
 	 * @since 1.0.19
842 842
 	 */
843 843
 	public function is_initial_fetch() {
844
-		return empty( $this->data['initial_state'] );
844
+		return empty($this->data['initial_state']);
845 845
 	}
846 846
 
847 847
 	/**
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
 	 */
852 852
 	public function get_total() {
853 853
 		$total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() + $this->get_shipping() - $this->get_discount();
854
-		return max( $total, 0 );
854
+		return max($total, 0);
855 855
 	}
856 856
 
857 857
 	/**
@@ -861,7 +861,7 @@  discard block
 block discarded – undo
861 861
 	 */
862 862
 	public function get_recurring_total() {
863 863
 		$total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() + $this->get_recurring_shipping() - $this->get_recurring_discount();
864
-		return max( $total, 0 );
864
+		return max($total, 0);
865 865
 	}
866 866
 
867 867
 	/**
@@ -873,12 +873,12 @@  discard block
 block discarded – undo
873 873
 		$initial   = $this->get_total();
874 874
 		$recurring = $this->get_recurring_total();
875 875
 
876
-		if ( $this->has_recurring == 0 ) {
876
+		if ($this->has_recurring == 0) {
877 877
 			$recurring = 0;
878 878
 		}
879 879
 
880 880
 		$collect = $initial > 0 || $recurring > 0;
881
-		return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this  );
881
+		return apply_filters('getpaid_submission_should_collect_payment_details', $collect, $this);
882 882
 	}
883 883
 
884 884
 	/**
@@ -887,7 +887,7 @@  discard block
 block discarded – undo
887 887
 	 * @since 1.0.19
888 888
 	 */
889 889
 	public function get_billing_email() {
890
-		return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this  );
890
+		return apply_filters('getpaid_get_submission_billing_email', $this->get_field('billing_email'), $this);
891 891
 	}
892 892
 
893 893
 	/**
@@ -897,7 +897,7 @@  discard block
 block discarded – undo
897 897
 	 */
898 898
 	public function has_billing_email() {
899 899
 		$billing_email = $this->get_billing_email();
900
-		return ! empty( $billing_email ) && is_email( $billing_email );
900
+		return !empty($billing_email) && is_email($billing_email);
901 901
 	}
902 902
 
903 903
 	/**
@@ -927,8 +927,8 @@  discard block
 block discarded – undo
927 927
 	 * @since 1.0.19
928 928
 	 * @return mixed|null
929 929
 	 */
930
-	public function get_field( $field, $sub_array_key = null ) {
931
-		return getpaid_get_array_field( $this->data, $field, $sub_array_key );
930
+	public function get_field($field, $sub_array_key = null) {
931
+		return getpaid_get_array_field($this->data, $field, $sub_array_key);
932 932
 	}
933 933
 
934 934
 	/**
@@ -936,8 +936,8 @@  discard block
 block discarded – undo
936 936
 	 *
937 937
 	 * @since 1.0.19
938 938
 	 */
939
-	public function is_required_field_set( $field ) {
940
-		return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
939
+	public function is_required_field_set($field) {
940
+		return empty($field['required']) || !empty($this->data[$field['id']]);
941 941
 	}
942 942
 
943 943
 	/**
@@ -945,8 +945,8 @@  discard block
 block discarded – undo
945 945
 	 *
946 946
 	 * @since 1.0.19
947 947
 	 */
948
-	public function format_amount( $amount ) {
949
-		return wpinv_price( $amount, $this->get_currency() );
948
+	public function format_amount($amount) {
949
+		return wpinv_price($amount, $this->get_currency());
950 950
 	}
951 951
 
952 952
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-checkout.php 1 patch
Spacing   +134 added lines, -134 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Main Checkout Class.
@@ -22,7 +22,7 @@  discard block
 block discarded – undo
22 22
 	 * 
23 23
 	 * @param GetPaid_Payment_Form_Submission $submission
24 24
 	 */
25
-	public function __construct( $submission ) {
25
+	public function __construct($submission) {
26 26
 		$this->payment_form_submission = $submission;
27 27
 	}
28 28
 
@@ -38,22 +38,22 @@  discard block
 block discarded – undo
38 38
 		// Prepare the invoice.
39 39
 		$items      = $this->get_submission_items();
40 40
 		$invoice    = $this->get_submission_invoice();
41
-		$invoice    = $this->process_submission_invoice( $invoice, $items );
41
+		$invoice    = $this->process_submission_invoice($invoice, $items);
42 42
 		$prepared   = $this->prepare_submission_data_for_saving();
43 43
 
44
-		$this->prepare_billing_info( $invoice );
44
+		$this->prepare_billing_info($invoice);
45 45
 
46
-		$shipping   = $this->prepare_shipping_info( $invoice );
46
+		$shipping = $this->prepare_shipping_info($invoice);
47 47
 
48 48
 		// Save the invoice.
49
-		$invoice->set_is_viewed( true );
49
+		$invoice->set_is_viewed(true);
50 50
 		$invoice->recalculate_total();
51 51
         $invoice->save();
52 52
 
53
-		do_action( 'getpaid_checkout_invoice_updated', $invoice );
53
+		do_action('getpaid_checkout_invoice_updated', $invoice);
54 54
 
55 55
 		// Send to the gateway.
56
-		$this->post_process_submission( $invoice, $prepared, $shipping );
56
+		$this->post_process_submission($invoice, $prepared, $shipping);
57 57
 	}
58 58
 
59 59
 	/**
@@ -66,34 +66,34 @@  discard block
 block discarded – undo
66 66
 		$data       = $submission->get_data();
67 67
 
68 68
 		// Do we have an error?
69
-        if ( ! empty( $submission->last_error ) ) {
70
-			wp_send_json_error( $submission->last_error );
69
+        if (!empty($submission->last_error)) {
70
+			wp_send_json_error($submission->last_error);
71 71
         }
72 72
 
73 73
 		// We need a billing email.
74
-        if ( ! $submission->has_billing_email() ) {
75
-            wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
74
+        if (!$submission->has_billing_email()) {
75
+            wp_send_json_error(__('Provide a valid billing email.', 'invoicing'));
76 76
 		}
77 77
 
78 78
 		// Non-recurring gateways should not be allowed to process recurring invoices.
79
-		if ( $submission->should_collect_payment_details() && $submission->has_recurring && ! wpinv_gateway_support_subscription( $data['wpi-gateway'] ) ) {
80
-			wp_send_json_error( __( 'The selected payment gateway does not support subscription payments.', 'invoicing' ) );
79
+		if ($submission->should_collect_payment_details() && $submission->has_recurring && !wpinv_gateway_support_subscription($data['wpi-gateway'])) {
80
+			wp_send_json_error(__('The selected payment gateway does not support subscription payments.', 'invoicing'));
81 81
 		}
82 82
 
83 83
 		// Ensure the gateway is active.
84
-		if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
-			wpinv_set_error( 'invalid_gateway', __( 'The selected payment gateway is not active', 'invoicing' ) );
84
+		if ($submission->should_collect_payment_details() && !wpinv_is_gateway_active($data['wpi-gateway'])) {
85
+			wpinv_set_error('invalid_gateway', __('The selected payment gateway is not active', 'invoicing'));
86 86
 		}
87 87
 
88 88
 		// Clear any existing errors.
89 89
 		wpinv_clear_errors();
90 90
 
91 91
 		// Allow themes and plugins to hook to errors
92
-		do_action( 'getpaid_checkout_error_checks', $submission );
92
+		do_action('getpaid_checkout_error_checks', $submission);
93 93
 
94 94
 		// Do we have any errors?
95
-        if ( wpinv_get_errors() ) {
96
-            wp_send_json_error( getpaid_get_errors_html() );
95
+        if (wpinv_get_errors()) {
96
+            wp_send_json_error(getpaid_get_errors_html());
97 97
 		}
98 98
 
99 99
 	}
@@ -108,8 +108,8 @@  discard block
 block discarded – undo
108 108
 		$items = $this->payment_form_submission->get_items();
109 109
 
110 110
         // Ensure that we have items.
111
-        if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) {
112
-            wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) );
111
+        if (empty($items) && !$this->payment_form_submission->has_fees()) {
112
+            wp_send_json_error(__('Please provide at least one item or amount.', 'invoicing'));
113 113
 		}
114 114
 
115 115
 		return $items;
@@ -123,17 +123,17 @@  discard block
 block discarded – undo
123 123
 	protected function get_submission_invoice() {
124 124
 		$submission = $this->payment_form_submission;
125 125
 
126
-		if ( ! $submission->has_invoice() ) {
126
+		if (!$submission->has_invoice()) {
127 127
 			$invoice = new WPInv_Invoice();
128
-			$invoice->set_created_via( 'payment_form' );
128
+			$invoice->set_created_via('payment_form');
129 129
 			return $invoice;
130 130
         }
131 131
 
132 132
 		$invoice = $submission->get_invoice();
133 133
 
134 134
 		// Make sure that it is neither paid or refunded.
135
-		if ( $invoice->is_paid() || $invoice->is_refunded() ) {
136
-			wp_send_json_error( __( 'This invoice has already been paid for.', 'invoicing' ) );
135
+		if ($invoice->is_paid() || $invoice->is_refunded()) {
136
+			wp_send_json_error(__('This invoice has already been paid for.', 'invoicing'));
137 137
 		}
138 138
 
139 139
 		return $invoice;
@@ -146,33 +146,33 @@  discard block
 block discarded – undo
146 146
 	 * @param GetPaid_Form_Item[] $items
147 147
 	 * @return WPInv_Invoice
148 148
 	 */
149
-	protected function process_submission_invoice( $invoice, $items ) {
149
+	protected function process_submission_invoice($invoice, $items) {
150 150
 
151 151
 		$submission = $this->payment_form_submission;
152 152
 
153 153
 		// Set-up the invoice details.
154
-		$invoice->set_email( sanitize_email( $submission->get_billing_email() ) );
155
-		$invoice->set_user_id( $this->get_submission_customer() );
156
-		$invoice->set_payment_form( absint( $submission->get_payment_form()->get_id() ) );
157
-        $invoice->set_items( $items );
158
-        $invoice->set_fees( $submission->get_fees() );
159
-        $invoice->set_taxes( $submission->get_taxes() );
160
-		$invoice->set_discounts( $submission->get_discounts() );
161
-		$invoice->set_gateway( $submission->get_field( 'wpi-gateway' ) );
162
-		$invoice->set_currency( $submission->get_currency() );
163
-
164
-		if ( $submission->has_shipping() ) {
165
-			$invoice->set_shipping( $submission->get_shipping() );
154
+		$invoice->set_email(sanitize_email($submission->get_billing_email()));
155
+		$invoice->set_user_id($this->get_submission_customer());
156
+		$invoice->set_payment_form(absint($submission->get_payment_form()->get_id()));
157
+        $invoice->set_items($items);
158
+        $invoice->set_fees($submission->get_fees());
159
+        $invoice->set_taxes($submission->get_taxes());
160
+		$invoice->set_discounts($submission->get_discounts());
161
+		$invoice->set_gateway($submission->get_field('wpi-gateway'));
162
+		$invoice->set_currency($submission->get_currency());
163
+
164
+		if ($submission->has_shipping()) {
165
+			$invoice->set_shipping($submission->get_shipping());
166 166
 		}
167 167
 
168
-		$address_confirmed = $submission->get_field( 'confirm-address' );
169
-		$invoice->set_address_confirmed( ! empty( $address_confirmed ) );
168
+		$address_confirmed = $submission->get_field('confirm-address');
169
+		$invoice->set_address_confirmed(!empty($address_confirmed));
170 170
 
171
-		if ( $submission->has_discount_code() ) {
172
-            $invoice->set_discount_code( $submission->get_discount_code() );
171
+		if ($submission->has_discount_code()) {
172
+            $invoice->set_discount_code($submission->get_discount_code());
173 173
 		}
174 174
 
175
-		getpaid_maybe_add_default_address( $invoice );
175
+		getpaid_maybe_add_default_address($invoice);
176 176
 		return $invoice;
177 177
 	}
178 178
 
@@ -185,33 +185,33 @@  discard block
 block discarded – undo
185 185
 		$submission = $this->payment_form_submission;
186 186
 
187 187
 		// If this is an existing invoice...
188
-		if ( $submission->has_invoice() ) {
188
+		if ($submission->has_invoice()) {
189 189
 			return $submission->get_invoice()->get_user_id();
190 190
 		}
191 191
 
192 192
 		// (Maybe) create the user.
193 193
         $user = get_current_user_id();
194 194
 
195
-        if ( empty( $user ) ) {
196
-            $user = get_user_by( 'email', $submission->get_billing_email() );
195
+        if (empty($user)) {
196
+            $user = get_user_by('email', $submission->get_billing_email());
197 197
         }
198 198
 
199
-        if ( empty( $user ) ) {
200
-            $user = wpinv_create_user( $submission->get_billing_email() );
199
+        if (empty($user)) {
200
+            $user = wpinv_create_user($submission->get_billing_email());
201 201
 
202 202
 			// (Maybe) send new user notification.
203
-			$should_send_notification = wpinv_get_option( 'disable_new_user_emails' );
204
-			if ( ! empty( $user ) && is_numeric( $user ) && apply_filters( 'getpaid_send_new_user_notification', empty( $should_send_notification ), $user ) ) {
205
-				wp_send_new_user_notifications( $user, 'user' );
203
+			$should_send_notification = wpinv_get_option('disable_new_user_emails');
204
+			if (!empty($user) && is_numeric($user) && apply_filters('getpaid_send_new_user_notification', empty($should_send_notification), $user)) {
205
+				wp_send_new_user_notifications($user, 'user');
206 206
 			}
207 207
 
208 208
         }
209 209
 
210
-        if ( is_wp_error( $user ) ) {
211
-            wp_send_json_error( $user->get_error_message() );
210
+        if (is_wp_error($user)) {
211
+            wp_send_json_error($user->get_error_message());
212 212
         }
213 213
 
214
-        if ( is_numeric( $user ) ) {
214
+        if (is_numeric($user)) {
215 215
             return $user;
216 216
 		}
217 217
 
@@ -235,24 +235,24 @@  discard block
 block discarded – undo
235 235
 		);
236 236
 
237 237
         // Raw submission details.
238
-		$data     = $submission->get_data();
238
+		$data = $submission->get_data();
239 239
 
240 240
 		// Loop through the submitted details.
241
-        foreach ( $submission->get_payment_form()->get_elements() as $field ) {
241
+        foreach ($submission->get_payment_form()->get_elements() as $field) {
242 242
 
243 243
 			// Skip premade fields.
244
-            if ( ! empty( $field['premade'] ) ) {
244
+            if (!empty($field['premade'])) {
245 245
                 continue;
246 246
             }
247 247
 
248 248
 			// Ensure address is provided.
249
-			if ( $field['type'] == 'address' ) {
250
-                $address_type = isset( $field['address_type'] ) && 'shipping' === $field['address_type'] ? 'shipping' : 'billing';
249
+			if ($field['type'] == 'address') {
250
+                $address_type = isset($field['address_type']) && 'shipping' === $field['address_type'] ? 'shipping' : 'billing';
251 251
 
252
-				foreach ( $field['fields'] as $address_field ) {
252
+				foreach ($field['fields'] as $address_field) {
253 253
 
254
-					if ( ! empty( $address_field['visible'] ) && ! empty( $address_field['required'] ) && '' === trim( $_POST[ $address_type ][ $address_field['name'] ] ) ) {
255
-						wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) );
254
+					if (!empty($address_field['visible']) && !empty($address_field['required']) && '' === trim($_POST[$address_type][$address_field['name']])) {
255
+						wp_send_json_error(__('Please fill all required fields.', 'invoicing'));
256 256
 					}
257 257
 
258 258
 				}
@@ -260,49 +260,49 @@  discard block
 block discarded – undo
260 260
             }
261 261
 
262 262
             // If it is required and not set, abort.
263
-            if ( ! $submission->is_required_field_set( $field ) ) {
264
-                wp_send_json_error( __( 'Please fill all required fields.', 'invoicing' ) );
263
+            if (!$submission->is_required_field_set($field)) {
264
+                wp_send_json_error(__('Please fill all required fields.', 'invoicing'));
265 265
             }
266 266
 
267 267
             // Handle misc fields.
268
-            if ( isset( $data[ $field['id'] ] ) ) {
268
+            if (isset($data[$field['id']])) {
269 269
 
270 270
 				// Uploads.
271
-				if ( $field['type'] == 'file_upload' ) {
272
-					$max_file_num = empty( $field['max_file_num'] ) ? 1 : absint( $field['max_file_num'] );
271
+				if ($field['type'] == 'file_upload') {
272
+					$max_file_num = empty($field['max_file_num']) ? 1 : absint($field['max_file_num']);
273 273
 
274
-					if ( count( $data[ $field['id'] ] ) > $max_file_num ) {
275
-						wp_send_json_error( __( 'Maximum number of allowed files exceeded.', 'invoicing' ) );
274
+					if (count($data[$field['id']]) > $max_file_num) {
275
+						wp_send_json_error(__('Maximum number of allowed files exceeded.', 'invoicing'));
276 276
 					}
277 277
 
278 278
 					$value = array();
279 279
 
280
-					foreach ( $data[ $field['id'] ] as $url => $name ) {
280
+					foreach ($data[$field['id']] as $url => $name) {
281 281
 						$value[] = sprintf(
282 282
 							'<a href="%s" target="_blank">%s</a>',
283
-							esc_url_raw( $url ),
284
-							esc_html( $name )
283
+							esc_url_raw($url),
284
+							esc_html($name)
285 285
 						);
286 286
 					}
287 287
 
288
-					$value = implode( ' | ', $value );
288
+					$value = implode(' | ', $value);
289 289
 
290
-				} else if ( $field['type'] == 'checkbox' ) {
291
-					$value = isset( $data[ $field['id'] ] ) ? __( 'Yes', 'invoicing' ) : __( 'No', 'invoicing' );
290
+				} else if ($field['type'] == 'checkbox') {
291
+					$value = isset($data[$field['id']]) ? __('Yes', 'invoicing') : __('No', 'invoicing');
292 292
 				} else {
293
-					$value = wp_kses_post( $data[ $field['id'] ] );
293
+					$value = wp_kses_post($data[$field['id']]);
294 294
 				}
295 295
 
296 296
                 $label = $field['id'];
297 297
 
298
-                if ( isset( $field['label'] ) ) {
298
+                if (isset($field['label'])) {
299 299
                     $label = $field['label'];
300 300
                 }
301 301
 
302
-				if ( ! empty( $field['add_meta'] ) ) {
303
-					$prepared['meta'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
302
+				if (!empty($field['add_meta'])) {
303
+					$prepared['meta'][wpinv_clean($label)] = wp_kses_post_deep($value);
304 304
 				}
305
-				$prepared['all'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
305
+				$prepared['all'][wpinv_clean($label)] = wp_kses_post_deep($value);
306 306
 
307 307
             }
308 308
 
@@ -319,30 +319,30 @@  discard block
 block discarded – undo
319 319
 	 * @param WPInv_Invoice $invoice
320 320
 	 * @param string $type
321 321
      */
322
-    public function prepare_address_details( $invoice, $type = 'billing' ) {
322
+    public function prepare_address_details($invoice, $type = 'billing') {
323 323
 
324 324
 		$data     = $this->payment_form_submission->get_data();
325
-		$type     = sanitize_key( $type );
325
+		$type     = sanitize_key($type);
326 326
 		$address  = array();
327 327
 		$prepared = array();
328 328
 
329
-		if ( ! empty( $data[ $type ] ) ) {
330
-			$address = $data[ $type ];
329
+		if (!empty($data[$type])) {
330
+			$address = $data[$type];
331 331
 		}
332 332
 
333 333
 		// Clean address details.
334
-		foreach ( $address as $key => $value ) {
335
-			$key             = sanitize_key( $key );
336
-			$key             = str_replace( 'wpinv_', '', $key );
337
-			$value           = wpinv_clean( $value );
338
-			$prepared[ $key] = apply_filters( "getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice );
334
+		foreach ($address as $key => $value) {
335
+			$key             = sanitize_key($key);
336
+			$key             = str_replace('wpinv_', '', $key);
337
+			$value           = wpinv_clean($value);
338
+			$prepared[$key] = apply_filters("getpaid_checkout_{$type}_address_$key", $value, $this->payment_form_submission, $invoice);
339 339
 		}
340 340
 
341 341
 		// Filter address details.
342
-		$prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
342
+		$prepared = apply_filters("getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice);
343 343
 
344 344
 		// Remove non-whitelisted values.
345
-		return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
345
+		return array_filter($prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY);
346 346
 
347 347
 	}
348 348
 
@@ -352,12 +352,12 @@  discard block
 block discarded – undo
352 352
 	 * @return array
353 353
 	 * @param WPInv_Invoice $invoice
354 354
      */
355
-    protected function prepare_billing_info( &$invoice ) {
355
+    protected function prepare_billing_info(&$invoice) {
356 356
 
357
-		$billing_address = $this->prepare_address_details( $invoice, 'billing' );
357
+		$billing_address = $this->prepare_address_details($invoice, 'billing');
358 358
 
359 359
 		// Update the invoice with the billing details.
360
-		$invoice->set_props( $billing_address );
360
+		$invoice->set_props($billing_address);
361 361
 
362 362
 	}
363 363
 
@@ -367,15 +367,15 @@  discard block
 block discarded – undo
367 367
 	 * @return array
368 368
 	 * @param WPInv_Invoice $invoice
369 369
      */
370
-    protected function prepare_shipping_info( $invoice ) {
370
+    protected function prepare_shipping_info($invoice) {
371 371
 
372 372
 		$data = $this->payment_form_submission->get_data();
373 373
 
374
-		if ( empty( $data['same-shipping-address'] ) ) {
375
-			return $this->prepare_address_details( $invoice, 'shipping' );
374
+		if (empty($data['same-shipping-address'])) {
375
+			return $this->prepare_address_details($invoice, 'shipping');
376 376
 		}
377 377
 
378
-		return $this->prepare_address_details( $invoice, 'billing' );
378
+		return $this->prepare_address_details($invoice, 'billing');
379 379
 
380 380
 	}
381 381
 
@@ -386,42 +386,42 @@  discard block
 block discarded – undo
386 386
 	 * @param array $prepared_payment_form_data
387 387
 	 * @param array $shipping
388 388
 	 */
389
-	protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
389
+	protected function post_process_submission($invoice, $prepared_payment_form_data, $shipping) {
390 390
 
391 391
 		// Ensure the invoice exists.
392
-        if ( ! $invoice->exists() ) {
393
-            wp_send_json_error( __( 'An error occured while saving your invoice. Please try again.', 'invoicing' ) );
392
+        if (!$invoice->exists()) {
393
+            wp_send_json_error(__('An error occured while saving your invoice. Please try again.', 'invoicing'));
394 394
         }
395 395
 
396 396
 		// Save payment form data.
397
-		$prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
398
-        delete_post_meta( $invoice->get_id(), 'payment_form_data' );
399
-		delete_post_meta( $invoice->get_id(), 'additional_meta_data' );
400
-		if ( ! empty( $prepared_payment_form_data ) ) {
397
+		$prepared_payment_form_data = apply_filters('getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice);
398
+        delete_post_meta($invoice->get_id(), 'payment_form_data');
399
+		delete_post_meta($invoice->get_id(), 'additional_meta_data');
400
+		if (!empty($prepared_payment_form_data)) {
401 401
 
402
-			if ( ! empty( $prepared_payment_form_data['all'] ) ) {
403
-				update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all'] );
402
+			if (!empty($prepared_payment_form_data['all'])) {
403
+				update_post_meta($invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all']);
404 404
 			}
405 405
 
406
-			if ( ! empty( $prepared_payment_form_data['meta'] ) ) {
407
-				update_post_meta( $invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta'] );
406
+			if (!empty($prepared_payment_form_data['meta'])) {
407
+				update_post_meta($invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta']);
408 408
 			}
409 409
 
410 410
 		}
411 411
 
412 412
 		// Save payment form data.
413
-		$shipping = apply_filters( 'getpaid_checkout_shipping_details', $shipping, $this->payment_form_submission );
414
-        if ( ! empty( $shipping ) ) {
415
-            update_post_meta( $invoice->get_id(), 'shipping_address', $shipping );
413
+		$shipping = apply_filters('getpaid_checkout_shipping_details', $shipping, $this->payment_form_submission);
414
+        if (!empty($shipping)) {
415
+            update_post_meta($invoice->get_id(), 'shipping_address', $shipping);
416 416
 		}
417 417
 
418 418
 		// Backwards compatibility.
419
-        add_filter( 'wp_redirect', array( $this, 'send_redirect_response' ) );
419
+        add_filter('wp_redirect', array($this, 'send_redirect_response'));
420 420
 
421
-		$this->process_payment( $invoice );
421
+		$this->process_payment($invoice);
422 422
 
423 423
         // If we are here, there was an error.
424
-		wpinv_send_back_to_checkout( $invoice );
424
+		wpinv_send_back_to_checkout($invoice);
425 425
 
426 426
 	}
427 427
 
@@ -430,41 +430,41 @@  discard block
 block discarded – undo
430 430
 	 *
431 431
 	 * @param WPInv_Invoice $invoice
432 432
 	 */
433
-	protected function process_payment( $invoice ) {
433
+	protected function process_payment($invoice) {
434 434
 
435 435
 		// Clear any checkout errors.
436 436
 		wpinv_clear_errors();
437 437
 
438 438
 		// No need to send free invoices to the gateway.
439
-		if ( $invoice->is_free() ) {
440
-			$this->process_free_payment( $invoice );
439
+		if ($invoice->is_free()) {
440
+			$this->process_free_payment($invoice);
441 441
 		}
442 442
 
443 443
 		$submission = $this->payment_form_submission;
444 444
 
445 445
 		// Fires before sending to the gateway.
446
-		do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
446
+		do_action('getpaid_checkout_before_gateway', $invoice, $submission);
447 447
 
448 448
 		// Allow the sumission data to be modified before it is sent to the gateway.
449 449
 		$submission_data    = $submission->get_data();
450
-		$submission_gateway = apply_filters( 'getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice );
451
-		$submission_data    = apply_filters( 'getpaid_gateway_submission_data', $submission_data, $submission, $invoice );
450
+		$submission_gateway = apply_filters('getpaid_gateway_submission_gateway', $invoice->get_gateway(), $submission, $invoice);
451
+		$submission_data    = apply_filters('getpaid_gateway_submission_data', $submission_data, $submission, $invoice);
452 452
 
453 453
 		// Validate the currency.
454
-		if ( ! apply_filters( "getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency() ) ) {
455
-			wpinv_set_error( 'invalid_currency', __( 'The chosen payment gateway does not support this currency', 'invoicing' ) );
454
+		if (!apply_filters("getpaid_gateway_{$submission_gateway}_is_valid_for_currency", true, $invoice->get_currency())) {
455
+			wpinv_set_error('invalid_currency', __('The chosen payment gateway does not support this currency', 'invoicing'));
456 456
 		}
457 457
 
458 458
 		// Check to see if we have any errors.
459
-		if ( wpinv_get_errors() ) {
460
-			wpinv_send_back_to_checkout( $invoice );
459
+		if (wpinv_get_errors()) {
460
+			wpinv_send_back_to_checkout($invoice);
461 461
 		}
462 462
 
463 463
 		// Send info to the gateway for payment processing
464
-		do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
464
+		do_action("getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission);
465 465
 
466 466
 		// Backwards compatibility.
467
-		wpinv_send_to_gateway( $submission_gateway, $invoice );
467
+		wpinv_send_to_gateway($submission_gateway, $invoice);
468 468
 
469 469
 	}
470 470
 
@@ -473,12 +473,12 @@  discard block
 block discarded – undo
473 473
 	 *
474 474
 	 * @param WPInv_Invoice $invoice
475 475
 	 */
476
-	protected function process_free_payment( $invoice ) {
476
+	protected function process_free_payment($invoice) {
477 477
 
478
-		$invoice->set_gateway( 'none' );
479
-		$invoice->add_note( __( "This is a free invoice and won't be sent to the payment gateway", 'invoicing' ), false, false, true );
478
+		$invoice->set_gateway('none');
479
+		$invoice->add_note(__("This is a free invoice and won't be sent to the payment gateway", 'invoicing'), false, false, true);
480 480
 		$invoice->mark_paid();
481
-		wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
481
+		wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key()));
482 482
 
483 483
 	}
484 484
 
@@ -486,9 +486,9 @@  discard block
 block discarded – undo
486 486
      * Sends a redrect response to payment details.
487 487
      *
488 488
      */
489
-    public function send_redirect_response( $url ) {
490
-        $url = urlencode( $url );
491
-        wp_send_json_success( $url );
489
+    public function send_redirect_response($url) {
490
+        $url = urlencode($url);
491
+        wp_send_json_success($url);
492 492
     }
493 493
 
494 494
 }
Please login to merge, or discard this patch.
admin/meta-boxes/class-getpaid-meta-box-invoice-shipping-address.php 1 patch
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  *
7 7
  */
8 8
 
9
-if ( ! defined( 'ABSPATH' ) ) {
9
+if (!defined('ABSPATH')) {
10 10
 	exit; // Exit if accessed directly
11 11
 }
12 12
 
@@ -20,13 +20,13 @@  discard block
 block discarded – undo
20 20
 	 *
21 21
 	 * @param WP_Post $post
22 22
 	 */
23
-	public static function output( $post ) {
23
+	public static function output($post) {
24 24
 
25 25
 		// Retrieve shipping address.
26
-		$shipping_address = get_post_meta( $post->ID, 'shipping_address', true );
26
+		$shipping_address = get_post_meta($post->ID, 'shipping_address', true);
27 27
 
28 28
 		// Abort if it is invalid.
29
-		if ( ! is_array( $shipping_address ) ) {
29
+		if (!is_array($shipping_address)) {
30 30
 			return;
31 31
 		}
32 32
 
@@ -34,29 +34,29 @@  discard block
 block discarded – undo
34 34
 
35 35
 		<div class="bsui">
36 36
 
37
-			<?php if ( ! empty( $shipping_address['method'] ) ) : ?>
37
+			<?php if (!empty($shipping_address['method'])) : ?>
38 38
 
39 39
 				<div class="form-group form-row" style="color: green;">
40 40
 					<div class="col">
41
-						<span style="font-weight: 600"><?php esc_html_e( 'Shipping Method', 'invoicing' ); ?>:</span>
41
+						<span style="font-weight: 600"><?php esc_html_e('Shipping Method', 'invoicing'); ?>:</span>
42 42
 					</div>
43 43
 					<div class="col">
44
-						<?php echo wp_kses_post( $shipping_address['method'] ); ?>
44
+						<?php echo wp_kses_post($shipping_address['method']); ?>
45 45
 					</div>
46 46
 				</div>
47 47
 
48 48
 			<?php endif; ?>
49 49
 
50
-			<?php foreach ( getpaid_user_address_fields() as $key => $label ) : ?>
50
+			<?php foreach (getpaid_user_address_fields() as $key => $label) : ?>
51 51
 
52
-					<?php if ( ! empty( $shipping_address[ $key ] ) ) : ?>
52
+					<?php if (!empty($shipping_address[$key])) : ?>
53 53
 
54 54
 						<div class="form-group form-row">
55 55
 							<div class="col">
56
-								<span style="font-weight: 600"><?php echo esc_html( $label ); ?>:</span>
56
+								<span style="font-weight: 600"><?php echo esc_html($label); ?>:</span>
57 57
 							</div>
58 58
 							<div class="col">
59
-								<?php echo self::prepare_for_display( $shipping_address, $key ); ?>
59
+								<?php echo self::prepare_for_display($shipping_address, $key); ?>
60 60
 							</div>
61 61
 						</div>
62 62
 
@@ -77,21 +77,21 @@  discard block
 block discarded – undo
77 77
 	 * @param string $key
78 78
 	 * @return string
79 79
 	 */
80
-	public static function prepare_for_display( $address, $key ) {
80
+	public static function prepare_for_display($address, $key) {
81 81
 
82 82
 		// Prepare the value.
83
-		$value = $address[ $key ];
83
+		$value = $address[$key];
84 84
 
85
-		if ( $key == 'country' ) {
86
-			$value = wpinv_country_name( $value );
85
+		if ($key == 'country') {
86
+			$value = wpinv_country_name($value);
87 87
 		}
88 88
 
89
-		if ( $key == 'state' ) {
90
-			$country = isset( $address[ 'country' ] ) ? $address[ 'country' ] : wpinv_get_default_country();
91
-			$value = wpinv_state_name( $value, $country );
89
+		if ($key == 'state') {
90
+			$country = isset($address['country']) ? $address['country'] : wpinv_get_default_country();
91
+			$value = wpinv_state_name($value, $country);
92 92
 		}
93 93
 
94
-		return esc_html( $value );
94
+		return esc_html($value);
95 95
 
96 96
 	}
97 97
 
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 1 patch
Spacing   +802 added lines, -802 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Invoice class.
@@ -145,40 +145,40 @@  discard block
 block discarded – undo
145 145
 	 *
146 146
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
147 147
 	 */
148
-    public function __construct( $invoice = 0 ) {
148
+    public function __construct($invoice = 0) {
149 149
 
150
-        parent::__construct( $invoice );
150
+        parent::__construct($invoice);
151 151
 
152
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( (int) $invoice ) ) ) {
153
-			$this->set_id( (int) $invoice );
154
-		} elseif ( $invoice instanceof self ) {
155
-			$this->set_id( $invoice->get_id() );
156
-		} elseif ( ! empty( $invoice->ID ) ) {
157
-			$this->set_id( $invoice->ID );
158
-		} elseif ( is_array( $invoice ) ) {
159
-			$this->set_props( $invoice );
152
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type((int) $invoice))) {
153
+			$this->set_id((int) $invoice);
154
+		} elseif ($invoice instanceof self) {
155
+			$this->set_id($invoice->get_id());
156
+		} elseif (!empty($invoice->ID)) {
157
+			$this->set_id($invoice->ID);
158
+		} elseif (is_array($invoice)) {
159
+			$this->set_props($invoice);
160 160
 
161
-			if ( isset( $invoice['ID'] ) ) {
162
-				$this->set_id( $invoice['ID'] );
161
+			if (isset($invoice['ID'])) {
162
+				$this->set_id($invoice['ID']);
163 163
 			}
164 164
 
165
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
166
-			$this->set_id( $invoice_id );
167
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
168
-			$this->set_id( $invoice_id );
169
-		} elseif ( is_string( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
170
-			$this->set_id( $invoice_id );
165
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
166
+			$this->set_id($invoice_id);
167
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
168
+			$this->set_id($invoice_id);
169
+		} elseif (is_string($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
170
+			$this->set_id($invoice_id);
171 171
 		} else {
172
-			$this->set_object_read( true );
172
+			$this->set_object_read(true);
173 173
 		}
174 174
 
175 175
         // Load the datastore.
176
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
176
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
177 177
 
178
-		if ( $this->get_id() > 0 ) {
179
-            $this->post = get_post( $this->get_id() );
178
+		if ($this->get_id() > 0) {
179
+            $this->post = get_post($this->get_id());
180 180
             $this->ID   = $this->get_id();
181
-			$this->data_store->read( $this );
181
+			$this->data_store->read($this);
182 182
         }
183 183
 
184 184
     }
@@ -193,38 +193,38 @@  discard block
 block discarded – undo
193 193
 	 * @since 1.0.15
194 194
 	 * @return int
195 195
 	 */
196
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
196
+	public static function get_invoice_id_by_field($value, $field = 'key') {
197 197
         global $wpdb;
198 198
 
199 199
 		// Trim the value.
200
-		$value = trim( $value );
200
+		$value = trim($value);
201 201
 
202
-		if ( empty( $value ) ) {
202
+		if (empty($value)) {
203 203
 			return 0;
204 204
 		}
205 205
 
206 206
         // Valid fields.
207
-        $fields = array( 'key', 'number', 'transaction_id' );
207
+        $fields = array('key', 'number', 'transaction_id');
208 208
 
209 209
 		// Ensure a field has been passed.
210
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
210
+		if (empty($field) || !in_array($field, $fields)) {
211 211
 			return 0;
212 212
 		}
213 213
 
214 214
 		// Maybe retrieve from the cache.
215
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
-		if ( false !== $invoice_id ) {
215
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
216
+		if (false !== $invoice_id) {
217 217
 			return $invoice_id;
218 218
 		}
219 219
 
220 220
         // Fetch from the db.
221 221
         $table       = $wpdb->prefix . 'getpaid_invoices';
222 222
         $invoice_id  = (int) $wpdb->get_var(
223
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
223
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
224 224
         );
225 225
 
226 226
 		// Update the cache with our data
227
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
227
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
228 228
 
229 229
 		return $invoice_id;
230 230
     }
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
     /**
233 233
      * Checks if an invoice key is set.
234 234
      */
235
-    public function _isset( $key ) {
236
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
235
+    public function _isset($key) {
236
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
237 237
     }
238 238
 
239 239
     /*
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 	 * @param  string $context View or edit context.
259 259
 	 * @return int
260 260
 	 */
261
-	public function get_parent_id( $context = 'view' ) {
262
-		return (int) $this->get_prop( 'parent_id', $context );
261
+	public function get_parent_id($context = 'view') {
262
+		return (int) $this->get_prop('parent_id', $context);
263 263
     }
264 264
 
265 265
     /**
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 * @return WPInv_Invoice
270 270
 	 */
271 271
     public function get_parent_payment() {
272
-        return new WPInv_Invoice( $this->get_parent_id() );
272
+        return new WPInv_Invoice($this->get_parent_id());
273 273
     }
274 274
 
275 275
     /**
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 	 * @param  string $context View or edit context.
290 290
 	 * @return string
291 291
 	 */
292
-	public function get_status( $context = 'view' ) {
293
-		return $this->get_prop( 'status', $context );
292
+	public function get_status($context = 'view') {
293
+		return $this->get_prop('status', $context);
294 294
 	}
295 295
 	
296 296
 	/**
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 	 * @return array
301 301
 	 */
302 302
 	public function get_all_statuses() {
303
-		return wpinv_get_invoice_statuses( true, true, $this );
303
+		return wpinv_get_invoice_statuses(true, true, $this);
304 304
     }
305 305
 
306 306
     /**
@@ -312,9 +312,9 @@  discard block
 block discarded – undo
312 312
     public function get_status_nicename() {
313 313
 		$statuses = $this->get_all_statuses();
314 314
 
315
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
315
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
316 316
 
317
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
317
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
318 318
     }
319 319
 
320 320
 	/**
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	 */
326 326
 	public function get_status_class() {
327 327
 		$statuses = getpaid_get_invoice_status_classes();
328
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
328
+		return isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : 'badge-dark';
329 329
 	}
330 330
 
331 331
 	/**
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
      */
337 337
     public function get_status_label_html() {
338 338
 
339
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
340
-		$status       = sanitize_html_class( $this->get_status() );
341
-		$class        = esc_attr( $this->get_status_class() );
339
+		$status_label = sanitize_text_field($this->get_status_nicename());
340
+		$status       = sanitize_html_class($this->get_status());
341
+		$class        = esc_attr($this->get_status_class());
342 342
 
343 343
 		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
344 344
 	}
@@ -350,23 +350,23 @@  discard block
 block discarded – undo
350 350
 	 * @param  string $context View or edit context.
351 351
 	 * @return string
352 352
 	 */
353
-	public function get_version( $context = 'view' ) {
354
-		return $this->get_prop( 'version', $context );
353
+	public function get_version($context = 'view') {
354
+		return $this->get_prop('version', $context);
355 355
 	}
356 356
 
357 357
 	/**
358 358
 	 * @deprecated
359 359
 	 */
360
-	public function get_invoice_date( $format = true ) {
361
-		$date      = getpaid_format_date( $this->get_date_completed() );
362
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
363
-		$formatted = getpaid_format_date( $date );
360
+	public function get_invoice_date($format = true) {
361
+		$date      = getpaid_format_date($this->get_date_completed());
362
+		$date      = empty($date) ? $this->get_date_created() : $this->get_date_completed();
363
+		$formatted = getpaid_format_date($date);
364 364
 
365
-		if ( $format ) {
365
+		if ($format) {
366 366
 			return $formatted;
367 367
 		}
368 368
 
369
-		return empty( $formatted ) ? '' : $date;
369
+		return empty($formatted) ? '' : $date;
370 370
 
371 371
     }
372 372
 
@@ -377,8 +377,8 @@  discard block
 block discarded – undo
377 377
 	 * @param  string $context View or edit context.
378 378
 	 * @return string
379 379
 	 */
380
-	public function get_date_created( $context = 'view' ) {
381
-		return $this->get_prop( 'date_created', $context );
380
+	public function get_date_created($context = 'view') {
381
+		return $this->get_prop('date_created', $context);
382 382
 	}
383 383
 	
384 384
 	/**
@@ -388,8 +388,8 @@  discard block
 block discarded – undo
388 388
 	 * @param  string $context View or edit context.
389 389
 	 * @return string
390 390
 	 */
391
-	public function get_created_date( $context = 'view' ) {
392
-		return $this->get_date_created( $context );
391
+	public function get_created_date($context = 'view') {
392
+		return $this->get_date_created($context);
393 393
     }
394 394
 
395 395
     /**
@@ -399,11 +399,11 @@  discard block
 block discarded – undo
399 399
 	 * @param  string $context View or edit context.
400 400
 	 * @return string
401 401
 	 */
402
-	public function get_date_created_gmt( $context = 'view' ) {
403
-        $date = $this->get_date_created( $context );
402
+	public function get_date_created_gmt($context = 'view') {
403
+        $date = $this->get_date_created($context);
404 404
 
405
-        if ( $date ) {
406
-            $date = get_gmt_from_date( $date );
405
+        if ($date) {
406
+            $date = get_gmt_from_date($date);
407 407
         }
408 408
 		return $date;
409 409
     }
@@ -415,8 +415,8 @@  discard block
 block discarded – undo
415 415
 	 * @param  string $context View or edit context.
416 416
 	 * @return string
417 417
 	 */
418
-	public function get_date_modified( $context = 'view' ) {
419
-		return $this->get_prop( 'date_modified', $context );
418
+	public function get_date_modified($context = 'view') {
419
+		return $this->get_prop('date_modified', $context);
420 420
 	}
421 421
 
422 422
 	/**
@@ -426,8 +426,8 @@  discard block
 block discarded – undo
426 426
 	 * @param  string $context View or edit context.
427 427
 	 * @return string
428 428
 	 */
429
-	public function get_modified_date( $context = 'view' ) {
430
-		return $this->get_date_modified( $context );
429
+	public function get_modified_date($context = 'view') {
430
+		return $this->get_date_modified($context);
431 431
     }
432 432
 
433 433
     /**
@@ -437,11 +437,11 @@  discard block
 block discarded – undo
437 437
 	 * @param  string $context View or edit context.
438 438
 	 * @return string
439 439
 	 */
440
-	public function get_date_modified_gmt( $context = 'view' ) {
441
-        $date = $this->get_date_modified( $context );
440
+	public function get_date_modified_gmt($context = 'view') {
441
+        $date = $this->get_date_modified($context);
442 442
 
443
-        if ( $date ) {
444
-            $date = get_gmt_from_date( $date );
443
+        if ($date) {
444
+            $date = get_gmt_from_date($date);
445 445
         }
446 446
 		return $date;
447 447
     }
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param  string $context View or edit context.
454 454
 	 * @return string
455 455
 	 */
456
-	public function get_due_date( $context = 'view' ) {
457
-		return $this->get_prop( 'due_date', $context );
456
+	public function get_due_date($context = 'view') {
457
+		return $this->get_prop('due_date', $context);
458 458
     }
459 459
 
460 460
     /**
@@ -464,8 +464,8 @@  discard block
 block discarded – undo
464 464
 	 * @param  string $context View or edit context.
465 465
 	 * @return string
466 466
 	 */
467
-	public function get_date_due( $context = 'view' ) {
468
-		return $this->get_due_date( $context );
467
+	public function get_date_due($context = 'view') {
468
+		return $this->get_due_date($context);
469 469
     }
470 470
 
471 471
     /**
@@ -475,11 +475,11 @@  discard block
 block discarded – undo
475 475
 	 * @param  string $context View or edit context.
476 476
 	 * @return string
477 477
 	 */
478
-	public function get_due_date_gmt( $context = 'view' ) {
479
-        $date = $this->get_due_date( $context );
478
+	public function get_due_date_gmt($context = 'view') {
479
+        $date = $this->get_due_date($context);
480 480
 
481
-        if ( $date ) {
482
-            $date = get_gmt_from_date( $date );
481
+        if ($date) {
482
+            $date = get_gmt_from_date($date);
483 483
         }
484 484
 		return $date;
485 485
     }
@@ -491,8 +491,8 @@  discard block
 block discarded – undo
491 491
 	 * @param  string $context View or edit context.
492 492
 	 * @return string
493 493
 	 */
494
-	public function get_gmt_date_due( $context = 'view' ) {
495
-		return $this->get_due_date_gmt( $context );
494
+	public function get_gmt_date_due($context = 'view') {
495
+		return $this->get_due_date_gmt($context);
496 496
     }
497 497
 
498 498
     /**
@@ -502,8 +502,8 @@  discard block
 block discarded – undo
502 502
 	 * @param  string $context View or edit context.
503 503
 	 * @return string
504 504
 	 */
505
-	public function get_completed_date( $context = 'view' ) {
506
-		return $this->get_prop( 'completed_date', $context );
505
+	public function get_completed_date($context = 'view') {
506
+		return $this->get_prop('completed_date', $context);
507 507
     }
508 508
 
509 509
     /**
@@ -513,8 +513,8 @@  discard block
 block discarded – undo
513 513
 	 * @param  string $context View or edit context.
514 514
 	 * @return string
515 515
 	 */
516
-	public function get_date_completed( $context = 'view' ) {
517
-		return $this->get_completed_date( $context );
516
+	public function get_date_completed($context = 'view') {
517
+		return $this->get_completed_date($context);
518 518
     }
519 519
 
520 520
     /**
@@ -524,11 +524,11 @@  discard block
 block discarded – undo
524 524
 	 * @param  string $context View or edit context.
525 525
 	 * @return string
526 526
 	 */
527
-	public function get_completed_date_gmt( $context = 'view' ) {
528
-        $date = $this->get_completed_date( $context );
527
+	public function get_completed_date_gmt($context = 'view') {
528
+        $date = $this->get_completed_date($context);
529 529
 
530
-        if ( $date ) {
531
-            $date = get_gmt_from_date( $date );
530
+        if ($date) {
531
+            $date = get_gmt_from_date($date);
532 532
         }
533 533
 		return $date;
534 534
     }
@@ -540,8 +540,8 @@  discard block
 block discarded – undo
540 540
 	 * @param  string $context View or edit context.
541 541
 	 * @return string
542 542
 	 */
543
-	public function get_gmt_completed_date( $context = 'view' ) {
544
-		return $this->get_completed_date_gmt( $context );
543
+	public function get_gmt_completed_date($context = 'view') {
544
+		return $this->get_completed_date_gmt($context);
545 545
     }
546 546
 
547 547
     /**
@@ -551,12 +551,12 @@  discard block
 block discarded – undo
551 551
 	 * @param  string $context View or edit context.
552 552
 	 * @return string
553 553
 	 */
554
-	public function get_number( $context = 'view' ) {
555
-		$number = $this->get_prop( 'number', $context );
554
+	public function get_number($context = 'view') {
555
+		$number = $this->get_prop('number', $context);
556 556
 
557
-		if ( empty( $number ) ) {
557
+		if (empty($number)) {
558 558
 			$number = $this->generate_number();
559
-			$this->set_number( $this->generate_number() );
559
+			$this->set_number($this->generate_number());
560 560
 		}
561 561
 
562 562
 		return $number;
@@ -570,8 +570,8 @@  discard block
 block discarded – undo
570 570
 	public function maybe_set_number() {
571 571
         $number = $this->get_number();
572 572
 
573
-        if ( empty( $number ) || $this->get_id() == $number ) {
574
-			$this->set_number( $this->generate_number() );
573
+        if (empty($number) || $this->get_id() == $number) {
574
+			$this->set_number($this->generate_number());
575 575
         }
576 576
 
577 577
 	}
@@ -583,8 +583,8 @@  discard block
 block discarded – undo
583 583
 	 * @param  string $context View or edit context.
584 584
 	 * @return string
585 585
 	 */
586
-	public function get_key( $context = 'view' ) {
587
-        return $this->get_prop( 'key', $context );
586
+	public function get_key($context = 'view') {
587
+        return $this->get_prop('key', $context);
588 588
 	}
589 589
 
590 590
 	/**
@@ -595,9 +595,9 @@  discard block
 block discarded – undo
595 595
 	public function maybe_set_key() {
596 596
         $key = $this->get_key();
597 597
 
598
-        if ( empty( $key ) ) {
599
-            $key = $this->generate_key( $this->get_type() . '_' );
600
-            $this->set_key( $key );
598
+        if (empty($key)) {
599
+            $key = $this->generate_key($this->get_type() . '_');
600
+            $this->set_key($key);
601 601
         }
602 602
 
603 603
     }
@@ -609,8 +609,8 @@  discard block
 block discarded – undo
609 609
 	 * @param  string $context View or edit context.
610 610
 	 * @return string
611 611
 	 */
612
-	public function get_type( $context = 'view' ) {
613
-        return $this->get_prop( 'type', $context );
612
+	public function get_type($context = 'view') {
613
+        return $this->get_prop('type', $context);
614 614
 	}
615 615
 
616 616
 	/**
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 	 * @return string
621 621
 	 */
622 622
 	public function get_invoice_quote_type() {
623
-        return getpaid_get_post_type_label( $this->get_post_type(), false );
623
+        return getpaid_get_post_type_label($this->get_post_type(), false);
624 624
     }
625 625
 
626 626
     /**
@@ -630,8 +630,8 @@  discard block
 block discarded – undo
630 630
 	 * @param  string $context View or edit context.
631 631
 	 * @return string
632 632
 	 */
633
-	public function get_label( $context = 'view' ) {
634
-        return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
633
+	public function get_label($context = 'view') {
634
+        return getpaid_get_post_type_label($this->get_post_type($context), false);
635 635
 	}
636 636
 
637 637
 	/**
@@ -641,8 +641,8 @@  discard block
 block discarded – undo
641 641
 	 * @param  string $context View or edit context.
642 642
 	 * @return string
643 643
 	 */
644
-	public function get_post_type( $context = 'view' ) {
645
-        return $this->get_prop( 'post_type', $context );
644
+	public function get_post_type($context = 'view') {
645
+        return $this->get_prop('post_type', $context);
646 646
     }
647 647
 
648 648
     /**
@@ -652,8 +652,8 @@  discard block
 block discarded – undo
652 652
 	 * @param  string $context View or edit context.
653 653
 	 * @return string
654 654
 	 */
655
-	public function get_mode( $context = 'view' ) {
656
-        return $this->get_prop( 'mode', $context );
655
+	public function get_mode($context = 'view') {
656
+        return $this->get_prop('mode', $context);
657 657
     }
658 658
 
659 659
     /**
@@ -663,13 +663,13 @@  discard block
 block discarded – undo
663 663
 	 * @param  string $context View or edit context.
664 664
 	 * @return string
665 665
 	 */
666
-	public function get_path( $context = 'view' ) {
667
-        $path   = $this->get_prop( 'path', $context );
666
+	public function get_path($context = 'view') {
667
+        $path = $this->get_prop('path', $context);
668 668
 		$prefix = $this->get_type();
669 669
 
670
-		if ( 0 !== strpos( $path, $prefix ) ) {
671
-			$path = sanitize_title(  $prefix . '-' . $this->get_id()  );
672
-			$this->set_path( $path );
670
+		if (0 !== strpos($path, $prefix)) {
671
+			$path = sanitize_title($prefix . '-' . $this->get_id());
672
+			$this->set_path($path);
673 673
 		}
674 674
 
675 675
 		return $path;
@@ -682,8 +682,8 @@  discard block
 block discarded – undo
682 682
 	 * @param  string $context View or edit context.
683 683
 	 * @return string
684 684
 	 */
685
-	public function get_name( $context = 'view' ) {
686
-        return $this->get_prop( 'title', $context );
685
+	public function get_name($context = 'view') {
686
+        return $this->get_prop('title', $context);
687 687
     }
688 688
 
689 689
     /**
@@ -693,8 +693,8 @@  discard block
 block discarded – undo
693 693
 	 * @param  string $context View or edit context.
694 694
 	 * @return string
695 695
 	 */
696
-	public function get_title( $context = 'view' ) {
697
-		return $this->get_name( $context );
696
+	public function get_title($context = 'view') {
697
+		return $this->get_name($context);
698 698
     }
699 699
 
700 700
     /**
@@ -704,8 +704,8 @@  discard block
 block discarded – undo
704 704
 	 * @param  string $context View or edit context.
705 705
 	 * @return string
706 706
 	 */
707
-	public function get_description( $context = 'view' ) {
708
-		return $this->get_prop( 'description', $context );
707
+	public function get_description($context = 'view') {
708
+		return $this->get_prop('description', $context);
709 709
     }
710 710
 
711 711
     /**
@@ -715,8 +715,8 @@  discard block
 block discarded – undo
715 715
 	 * @param  string $context View or edit context.
716 716
 	 * @return string
717 717
 	 */
718
-	public function get_excerpt( $context = 'view' ) {
719
-		return $this->get_description( $context );
718
+	public function get_excerpt($context = 'view') {
719
+		return $this->get_description($context);
720 720
     }
721 721
 
722 722
     /**
@@ -726,8 +726,8 @@  discard block
 block discarded – undo
726 726
 	 * @param  string $context View or edit context.
727 727
 	 * @return string
728 728
 	 */
729
-	public function get_summary( $context = 'view' ) {
730
-		return $this->get_description( $context );
729
+	public function get_summary($context = 'view') {
730
+		return $this->get_description($context);
731 731
     }
732 732
 
733 733
     /**
@@ -737,26 +737,26 @@  discard block
 block discarded – undo
737 737
      * @param  string $context View or edit context.
738 738
 	 * @return array
739 739
 	 */
740
-    public function get_user_info( $context = 'view' ) {
740
+    public function get_user_info($context = 'view') {
741 741
 
742 742
         $user_info = array(
743
-            'user_id'    => $this->get_user_id( $context ),
744
-            'email'      => $this->get_email( $context ),
745
-            'first_name' => $this->get_first_name( $context ),
746
-            'last_name'  => $this->get_last_name( $context ),
747
-            'address'    => $this->get_address( $context ),
748
-            'phone'      => $this->get_phone( $context ),
749
-            'city'       => $this->get_city( $context ),
750
-            'country'    => $this->get_country( $context ),
751
-            'state'      => $this->get_state( $context ),
752
-            'zip'        => $this->get_zip( $context ),
753
-            'company'    => $this->get_company( $context ),
754
-			'company_id' => $this->get_company_id( $context ),
755
-            'vat_number' => $this->get_vat_number( $context ),
756
-            'discount'   => $this->get_discount_code( $context ),
743
+            'user_id'    => $this->get_user_id($context),
744
+            'email'      => $this->get_email($context),
745
+            'first_name' => $this->get_first_name($context),
746
+            'last_name'  => $this->get_last_name($context),
747
+            'address'    => $this->get_address($context),
748
+            'phone'      => $this->get_phone($context),
749
+            'city'       => $this->get_city($context),
750
+            'country'    => $this->get_country($context),
751
+            'state'      => $this->get_state($context),
752
+            'zip'        => $this->get_zip($context),
753
+            'company'    => $this->get_company($context),
754
+			'company_id' => $this->get_company_id($context),
755
+            'vat_number' => $this->get_vat_number($context),
756
+            'discount'   => $this->get_discount_code($context),
757 757
 		);
758 758
 
759
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
759
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
760 760
 
761 761
     }
762 762
 
@@ -767,8 +767,8 @@  discard block
 block discarded – undo
767 767
 	 * @param  string $context View or edit context.
768 768
 	 * @return int
769 769
 	 */
770
-	public function get_author( $context = 'view' ) {
771
-		return (int) $this->get_prop( 'author', $context );
770
+	public function get_author($context = 'view') {
771
+		return (int) $this->get_prop('author', $context);
772 772
     }
773 773
 
774 774
     /**
@@ -778,8 +778,8 @@  discard block
 block discarded – undo
778 778
 	 * @param  string $context View or edit context.
779 779
 	 * @return int
780 780
 	 */
781
-	public function get_user_id( $context = 'view' ) {
782
-		return $this->get_author( $context );
781
+	public function get_user_id($context = 'view') {
782
+		return $this->get_author($context);
783 783
     }
784 784
 
785 785
      /**
@@ -789,8 +789,8 @@  discard block
 block discarded – undo
789 789
 	 * @param  string $context View or edit context.
790 790
 	 * @return int
791 791
 	 */
792
-	public function get_customer_id( $context = 'view' ) {
793
-		return $this->get_author( $context );
792
+	public function get_customer_id($context = 'view') {
793
+		return $this->get_author($context);
794 794
     }
795 795
 
796 796
     /**
@@ -800,8 +800,8 @@  discard block
 block discarded – undo
800 800
 	 * @param  string $context View or edit context.
801 801
 	 * @return string
802 802
 	 */
803
-	public function get_ip( $context = 'view' ) {
804
-		return $this->get_prop( 'user_ip', $context );
803
+	public function get_ip($context = 'view') {
804
+		return $this->get_prop('user_ip', $context);
805 805
     }
806 806
 
807 807
     /**
@@ -811,8 +811,8 @@  discard block
 block discarded – undo
811 811
 	 * @param  string $context View or edit context.
812 812
 	 * @return string
813 813
 	 */
814
-	public function get_user_ip( $context = 'view' ) {
815
-		return $this->get_ip( $context );
814
+	public function get_user_ip($context = 'view') {
815
+		return $this->get_ip($context);
816 816
     }
817 817
 
818 818
      /**
@@ -822,8 +822,8 @@  discard block
 block discarded – undo
822 822
 	 * @param  string $context View or edit context.
823 823
 	 * @return string
824 824
 	 */
825
-	public function get_customer_ip( $context = 'view' ) {
826
-		return $this->get_ip( $context );
825
+	public function get_customer_ip($context = 'view') {
826
+		return $this->get_ip($context);
827 827
     }
828 828
 
829 829
     /**
@@ -833,8 +833,8 @@  discard block
 block discarded – undo
833 833
 	 * @param  string $context View or edit context.
834 834
 	 * @return string
835 835
 	 */
836
-	public function get_first_name( $context = 'view' ) {
837
-		return $this->get_prop( 'first_name', $context );
836
+	public function get_first_name($context = 'view') {
837
+		return $this->get_prop('first_name', $context);
838 838
     }
839 839
 
840 840
     /**
@@ -844,8 +844,8 @@  discard block
 block discarded – undo
844 844
 	 * @param  string $context View or edit context.
845 845
 	 * @return string
846 846
 	 */
847
-	public function get_user_first_name( $context = 'view' ) {
848
-		return $this->get_first_name( $context );
847
+	public function get_user_first_name($context = 'view') {
848
+		return $this->get_first_name($context);
849 849
     }
850 850
 
851 851
      /**
@@ -855,8 +855,8 @@  discard block
 block discarded – undo
855 855
 	 * @param  string $context View or edit context.
856 856
 	 * @return string
857 857
 	 */
858
-	public function get_customer_first_name( $context = 'view' ) {
859
-		return $this->get_first_name( $context );
858
+	public function get_customer_first_name($context = 'view') {
859
+		return $this->get_first_name($context);
860 860
     }
861 861
 
862 862
     /**
@@ -866,8 +866,8 @@  discard block
 block discarded – undo
866 866
 	 * @param  string $context View or edit context.
867 867
 	 * @return string
868 868
 	 */
869
-	public function get_last_name( $context = 'view' ) {
870
-		return $this->get_prop( 'last_name', $context );
869
+	public function get_last_name($context = 'view') {
870
+		return $this->get_prop('last_name', $context);
871 871
     }
872 872
 
873 873
     /**
@@ -877,8 +877,8 @@  discard block
 block discarded – undo
877 877
 	 * @param  string $context View or edit context.
878 878
 	 * @return string
879 879
 	 */
880
-	public function get_user_last_name( $context = 'view' ) {
881
-		return $this->get_last_name( $context );
880
+	public function get_user_last_name($context = 'view') {
881
+		return $this->get_last_name($context);
882 882
     }
883 883
 
884 884
     /**
@@ -888,8 +888,8 @@  discard block
 block discarded – undo
888 888
 	 * @param  string $context View or edit context.
889 889
 	 * @return string
890 890
 	 */
891
-	public function get_customer_last_name( $context = 'view' ) {
892
-		return $this->get_last_name( $context );
891
+	public function get_customer_last_name($context = 'view') {
892
+		return $this->get_last_name($context);
893 893
     }
894 894
 
895 895
     /**
@@ -899,8 +899,8 @@  discard block
 block discarded – undo
899 899
 	 * @param  string $context View or edit context.
900 900
 	 * @return string
901 901
 	 */
902
-	public function get_full_name( $context = 'view' ) {
903
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
902
+	public function get_full_name($context = 'view') {
903
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
904 904
     }
905 905
 
906 906
     /**
@@ -910,8 +910,8 @@  discard block
 block discarded – undo
910 910
 	 * @param  string $context View or edit context.
911 911
 	 * @return string
912 912
 	 */
913
-	public function get_user_full_name( $context = 'view' ) {
914
-		return $this->get_full_name( $context );
913
+	public function get_user_full_name($context = 'view') {
914
+		return $this->get_full_name($context);
915 915
     }
916 916
 
917 917
     /**
@@ -921,8 +921,8 @@  discard block
 block discarded – undo
921 921
 	 * @param  string $context View or edit context.
922 922
 	 * @return string
923 923
 	 */
924
-	public function get_customer_full_name( $context = 'view' ) {
925
-		return $this->get_full_name( $context );
924
+	public function get_customer_full_name($context = 'view') {
925
+		return $this->get_full_name($context);
926 926
     }
927 927
 
928 928
     /**
@@ -932,8 +932,8 @@  discard block
 block discarded – undo
932 932
 	 * @param  string $context View or edit context.
933 933
 	 * @return string
934 934
 	 */
935
-	public function get_phone( $context = 'view' ) {
936
-		return $this->get_prop( 'phone', $context );
935
+	public function get_phone($context = 'view') {
936
+		return $this->get_prop('phone', $context);
937 937
     }
938 938
 
939 939
     /**
@@ -943,8 +943,8 @@  discard block
 block discarded – undo
943 943
 	 * @param  string $context View or edit context.
944 944
 	 * @return string
945 945
 	 */
946
-	public function get_phone_number( $context = 'view' ) {
947
-		return $this->get_phone( $context );
946
+	public function get_phone_number($context = 'view') {
947
+		return $this->get_phone($context);
948 948
     }
949 949
 
950 950
     /**
@@ -954,8 +954,8 @@  discard block
 block discarded – undo
954 954
 	 * @param  string $context View or edit context.
955 955
 	 * @return string
956 956
 	 */
957
-	public function get_user_phone( $context = 'view' ) {
958
-		return $this->get_phone( $context );
957
+	public function get_user_phone($context = 'view') {
958
+		return $this->get_phone($context);
959 959
     }
960 960
 
961 961
     /**
@@ -965,8 +965,8 @@  discard block
 block discarded – undo
965 965
 	 * @param  string $context View or edit context.
966 966
 	 * @return string
967 967
 	 */
968
-	public function get_customer_phone( $context = 'view' ) {
969
-		return $this->get_phone( $context );
968
+	public function get_customer_phone($context = 'view') {
969
+		return $this->get_phone($context);
970 970
     }
971 971
 
972 972
     /**
@@ -976,8 +976,8 @@  discard block
 block discarded – undo
976 976
 	 * @param  string $context View or edit context.
977 977
 	 * @return string
978 978
 	 */
979
-	public function get_email( $context = 'view' ) {
980
-		return $this->get_prop( 'email', $context );
979
+	public function get_email($context = 'view') {
980
+		return $this->get_prop('email', $context);
981 981
     }
982 982
 
983 983
     /**
@@ -987,8 +987,8 @@  discard block
 block discarded – undo
987 987
 	 * @param  string $context View or edit context.
988 988
 	 * @return string
989 989
 	 */
990
-	public function get_email_address( $context = 'view' ) {
991
-		return $this->get_email( $context );
990
+	public function get_email_address($context = 'view') {
991
+		return $this->get_email($context);
992 992
     }
993 993
 
994 994
     /**
@@ -998,8 +998,8 @@  discard block
 block discarded – undo
998 998
 	 * @param  string $context View or edit context.
999 999
 	 * @return string
1000 1000
 	 */
1001
-	public function get_user_email( $context = 'view' ) {
1002
-		return $this->get_email( $context );
1001
+	public function get_user_email($context = 'view') {
1002
+		return $this->get_email($context);
1003 1003
     }
1004 1004
 
1005 1005
     /**
@@ -1009,8 +1009,8 @@  discard block
 block discarded – undo
1009 1009
 	 * @param  string $context View or edit context.
1010 1010
 	 * @return string
1011 1011
 	 */
1012
-	public function get_customer_email( $context = 'view' ) {
1013
-		return $this->get_email( $context );
1012
+	public function get_customer_email($context = 'view') {
1013
+		return $this->get_email($context);
1014 1014
     }
1015 1015
 
1016 1016
     /**
@@ -1020,9 +1020,9 @@  discard block
 block discarded – undo
1020 1020
 	 * @param  string $context View or edit context.
1021 1021
 	 * @return string
1022 1022
 	 */
1023
-	public function get_country( $context = 'view' ) {
1024
-		$country = $this->get_prop( 'country', $context );
1025
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1023
+	public function get_country($context = 'view') {
1024
+		$country = $this->get_prop('country', $context);
1025
+		return empty($country) ? wpinv_get_default_country() : $country;
1026 1026
     }
1027 1027
 
1028 1028
     /**
@@ -1032,8 +1032,8 @@  discard block
 block discarded – undo
1032 1032
 	 * @param  string $context View or edit context.
1033 1033
 	 * @return string
1034 1034
 	 */
1035
-	public function get_user_country( $context = 'view' ) {
1036
-		return $this->get_country( $context );
1035
+	public function get_user_country($context = 'view') {
1036
+		return $this->get_country($context);
1037 1037
     }
1038 1038
 
1039 1039
     /**
@@ -1043,8 +1043,8 @@  discard block
 block discarded – undo
1043 1043
 	 * @param  string $context View or edit context.
1044 1044
 	 * @return string
1045 1045
 	 */
1046
-	public function get_customer_country( $context = 'view' ) {
1047
-		return $this->get_country( $context );
1046
+	public function get_customer_country($context = 'view') {
1047
+		return $this->get_country($context);
1048 1048
     }
1049 1049
 
1050 1050
     /**
@@ -1054,9 +1054,9 @@  discard block
 block discarded – undo
1054 1054
 	 * @param  string $context View or edit context.
1055 1055
 	 * @return string
1056 1056
 	 */
1057
-	public function get_state( $context = 'view' ) {
1058
-		$state = $this->get_prop( 'state', $context );
1059
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1057
+	public function get_state($context = 'view') {
1058
+		$state = $this->get_prop('state', $context);
1059
+		return empty($state) ? wpinv_get_default_state() : $state;
1060 1060
     }
1061 1061
 
1062 1062
     /**
@@ -1066,8 +1066,8 @@  discard block
 block discarded – undo
1066 1066
 	 * @param  string $context View or edit context.
1067 1067
 	 * @return string
1068 1068
 	 */
1069
-	public function get_user_state( $context = 'view' ) {
1070
-		return $this->get_state( $context );
1069
+	public function get_user_state($context = 'view') {
1070
+		return $this->get_state($context);
1071 1071
     }
1072 1072
 
1073 1073
     /**
@@ -1077,8 +1077,8 @@  discard block
 block discarded – undo
1077 1077
 	 * @param  string $context View or edit context.
1078 1078
 	 * @return string
1079 1079
 	 */
1080
-	public function get_customer_state( $context = 'view' ) {
1081
-		return $this->get_state( $context );
1080
+	public function get_customer_state($context = 'view') {
1081
+		return $this->get_state($context);
1082 1082
     }
1083 1083
 
1084 1084
     /**
@@ -1088,8 +1088,8 @@  discard block
 block discarded – undo
1088 1088
 	 * @param  string $context View or edit context.
1089 1089
 	 * @return string
1090 1090
 	 */
1091
-	public function get_city( $context = 'view' ) {
1092
-		return $this->get_prop( 'city', $context );
1091
+	public function get_city($context = 'view') {
1092
+		return $this->get_prop('city', $context);
1093 1093
     }
1094 1094
 
1095 1095
     /**
@@ -1099,8 +1099,8 @@  discard block
 block discarded – undo
1099 1099
 	 * @param  string $context View or edit context.
1100 1100
 	 * @return string
1101 1101
 	 */
1102
-	public function get_user_city( $context = 'view' ) {
1103
-		return $this->get_city( $context );
1102
+	public function get_user_city($context = 'view') {
1103
+		return $this->get_city($context);
1104 1104
     }
1105 1105
 
1106 1106
     /**
@@ -1110,8 +1110,8 @@  discard block
 block discarded – undo
1110 1110
 	 * @param  string $context View or edit context.
1111 1111
 	 * @return string
1112 1112
 	 */
1113
-	public function get_customer_city( $context = 'view' ) {
1114
-		return $this->get_city( $context );
1113
+	public function get_customer_city($context = 'view') {
1114
+		return $this->get_city($context);
1115 1115
     }
1116 1116
 
1117 1117
     /**
@@ -1121,8 +1121,8 @@  discard block
 block discarded – undo
1121 1121
 	 * @param  string $context View or edit context.
1122 1122
 	 * @return string
1123 1123
 	 */
1124
-	public function get_zip( $context = 'view' ) {
1125
-		return $this->get_prop( 'zip', $context );
1124
+	public function get_zip($context = 'view') {
1125
+		return $this->get_prop('zip', $context);
1126 1126
     }
1127 1127
 
1128 1128
     /**
@@ -1132,8 +1132,8 @@  discard block
 block discarded – undo
1132 1132
 	 * @param  string $context View or edit context.
1133 1133
 	 * @return string
1134 1134
 	 */
1135
-	public function get_user_zip( $context = 'view' ) {
1136
-		return $this->get_zip( $context );
1135
+	public function get_user_zip($context = 'view') {
1136
+		return $this->get_zip($context);
1137 1137
     }
1138 1138
 
1139 1139
     /**
@@ -1143,8 +1143,8 @@  discard block
 block discarded – undo
1143 1143
 	 * @param  string $context View or edit context.
1144 1144
 	 * @return string
1145 1145
 	 */
1146
-	public function get_customer_zip( $context = 'view' ) {
1147
-		return $this->get_zip( $context );
1146
+	public function get_customer_zip($context = 'view') {
1147
+		return $this->get_zip($context);
1148 1148
     }
1149 1149
 
1150 1150
     /**
@@ -1154,8 +1154,8 @@  discard block
 block discarded – undo
1154 1154
 	 * @param  string $context View or edit context.
1155 1155
 	 * @return string
1156 1156
 	 */
1157
-	public function get_company( $context = 'view' ) {
1158
-		return $this->get_prop( 'company', $context );
1157
+	public function get_company($context = 'view') {
1158
+		return $this->get_prop('company', $context);
1159 1159
     }
1160 1160
 
1161 1161
     /**
@@ -1165,8 +1165,8 @@  discard block
 block discarded – undo
1165 1165
 	 * @param  string $context View or edit context.
1166 1166
 	 * @return string
1167 1167
 	 */
1168
-	public function get_user_company( $context = 'view' ) {
1169
-		return $this->get_company( $context );
1168
+	public function get_user_company($context = 'view') {
1169
+		return $this->get_company($context);
1170 1170
     }
1171 1171
 
1172 1172
     /**
@@ -1176,8 +1176,8 @@  discard block
 block discarded – undo
1176 1176
 	 * @param  string $context View or edit context.
1177 1177
 	 * @return string
1178 1178
 	 */
1179
-	public function get_customer_company( $context = 'view' ) {
1180
-		return $this->get_company( $context );
1179
+	public function get_customer_company($context = 'view') {
1180
+		return $this->get_company($context);
1181 1181
     }
1182 1182
 
1183 1183
 	/**
@@ -1187,8 +1187,8 @@  discard block
 block discarded – undo
1187 1187
 	 * @param  string $context View or edit context.
1188 1188
 	 * @return string
1189 1189
 	 */
1190
-	public function get_company_id( $context = 'view' ) {
1191
-		return $this->get_prop( 'company_id', $context );
1190
+	public function get_company_id($context = 'view') {
1191
+		return $this->get_prop('company_id', $context);
1192 1192
     }
1193 1193
 
1194 1194
     /**
@@ -1198,8 +1198,8 @@  discard block
 block discarded – undo
1198 1198
 	 * @param  string $context View or edit context.
1199 1199
 	 * @return string
1200 1200
 	 */
1201
-	public function get_vat_number( $context = 'view' ) {
1202
-		return $this->get_prop( 'vat_number', $context );
1201
+	public function get_vat_number($context = 'view') {
1202
+		return $this->get_prop('vat_number', $context);
1203 1203
     }
1204 1204
 
1205 1205
     /**
@@ -1209,8 +1209,8 @@  discard block
 block discarded – undo
1209 1209
 	 * @param  string $context View or edit context.
1210 1210
 	 * @return string
1211 1211
 	 */
1212
-	public function get_user_vat_number( $context = 'view' ) {
1213
-		return $this->get_vat_number( $context );
1212
+	public function get_user_vat_number($context = 'view') {
1213
+		return $this->get_vat_number($context);
1214 1214
     }
1215 1215
 
1216 1216
     /**
@@ -1220,8 +1220,8 @@  discard block
 block discarded – undo
1220 1220
 	 * @param  string $context View or edit context.
1221 1221
 	 * @return string
1222 1222
 	 */
1223
-	public function get_customer_vat_number( $context = 'view' ) {
1224
-		return $this->get_vat_number( $context );
1223
+	public function get_customer_vat_number($context = 'view') {
1224
+		return $this->get_vat_number($context);
1225 1225
     }
1226 1226
 
1227 1227
     /**
@@ -1231,8 +1231,8 @@  discard block
 block discarded – undo
1231 1231
 	 * @param  string $context View or edit context.
1232 1232
 	 * @return string
1233 1233
 	 */
1234
-	public function get_vat_rate( $context = 'view' ) {
1235
-		return $this->get_prop( 'vat_rate', $context );
1234
+	public function get_vat_rate($context = 'view') {
1235
+		return $this->get_prop('vat_rate', $context);
1236 1236
     }
1237 1237
 
1238 1238
     /**
@@ -1242,8 +1242,8 @@  discard block
 block discarded – undo
1242 1242
 	 * @param  string $context View or edit context.
1243 1243
 	 * @return string
1244 1244
 	 */
1245
-	public function get_user_vat_rate( $context = 'view' ) {
1246
-		return $this->get_vat_rate( $context );
1245
+	public function get_user_vat_rate($context = 'view') {
1246
+		return $this->get_vat_rate($context);
1247 1247
     }
1248 1248
 
1249 1249
     /**
@@ -1253,8 +1253,8 @@  discard block
 block discarded – undo
1253 1253
 	 * @param  string $context View or edit context.
1254 1254
 	 * @return string
1255 1255
 	 */
1256
-	public function get_customer_vat_rate( $context = 'view' ) {
1257
-		return $this->get_vat_rate( $context );
1256
+	public function get_customer_vat_rate($context = 'view') {
1257
+		return $this->get_vat_rate($context);
1258 1258
     }
1259 1259
 
1260 1260
     /**
@@ -1264,8 +1264,8 @@  discard block
 block discarded – undo
1264 1264
 	 * @param  string $context View or edit context.
1265 1265
 	 * @return string
1266 1266
 	 */
1267
-	public function get_address( $context = 'view' ) {
1268
-		return $this->get_prop( 'address', $context );
1267
+	public function get_address($context = 'view') {
1268
+		return $this->get_prop('address', $context);
1269 1269
     }
1270 1270
 
1271 1271
     /**
@@ -1275,8 +1275,8 @@  discard block
 block discarded – undo
1275 1275
 	 * @param  string $context View or edit context.
1276 1276
 	 * @return string
1277 1277
 	 */
1278
-	public function get_user_address( $context = 'view' ) {
1279
-		return $this->get_address( $context );
1278
+	public function get_user_address($context = 'view') {
1279
+		return $this->get_address($context);
1280 1280
     }
1281 1281
 
1282 1282
     /**
@@ -1286,8 +1286,8 @@  discard block
 block discarded – undo
1286 1286
 	 * @param  string $context View or edit context.
1287 1287
 	 * @return string
1288 1288
 	 */
1289
-	public function get_customer_address( $context = 'view' ) {
1290
-		return $this->get_address( $context );
1289
+	public function get_customer_address($context = 'view') {
1290
+		return $this->get_address($context);
1291 1291
     }
1292 1292
 
1293 1293
     /**
@@ -1297,8 +1297,8 @@  discard block
 block discarded – undo
1297 1297
 	 * @param  string $context View or edit context.
1298 1298
 	 * @return bool
1299 1299
 	 */
1300
-	public function get_is_viewed( $context = 'view' ) {
1301
-		return (bool) $this->get_prop( 'is_viewed', $context );
1300
+	public function get_is_viewed($context = 'view') {
1301
+		return (bool) $this->get_prop('is_viewed', $context);
1302 1302
 	}
1303 1303
 
1304 1304
 	/**
@@ -1308,8 +1308,8 @@  discard block
 block discarded – undo
1308 1308
 	 * @param  string $context View or edit context.
1309 1309
 	 * @return bool
1310 1310
 	 */
1311
-	public function get_email_cc( $context = 'view' ) {
1312
-		return $this->get_prop( 'email_cc', $context );
1311
+	public function get_email_cc($context = 'view') {
1312
+		return $this->get_prop('email_cc', $context);
1313 1313
 	}
1314 1314
 
1315 1315
 	/**
@@ -1319,8 +1319,8 @@  discard block
 block discarded – undo
1319 1319
 	 * @param  string $context View or edit context.
1320 1320
 	 * @return bool
1321 1321
 	 */
1322
-	public function get_template( $context = 'view' ) {
1323
-		return $this->get_prop( 'template', $context );
1322
+	public function get_template($context = 'view') {
1323
+		return $this->get_prop('template', $context);
1324 1324
 	}
1325 1325
 
1326 1326
 	/**
@@ -1330,8 +1330,8 @@  discard block
 block discarded – undo
1330 1330
 	 * @param  string $context View or edit context.
1331 1331
 	 * @return bool
1332 1332
 	 */
1333
-	public function get_created_via( $context = 'view' ) {
1334
-		return $this->get_prop( 'created_via', $context );
1333
+	public function get_created_via($context = 'view') {
1334
+		return $this->get_prop('created_via', $context);
1335 1335
 	}
1336 1336
 
1337 1337
 	/**
@@ -1341,8 +1341,8 @@  discard block
 block discarded – undo
1341 1341
 	 * @param  string $context View or edit context.
1342 1342
 	 * @return bool
1343 1343
 	 */
1344
-	public function get_address_confirmed( $context = 'view' ) {
1345
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1344
+	public function get_address_confirmed($context = 'view') {
1345
+		return (bool) $this->get_prop('address_confirmed', $context);
1346 1346
     }
1347 1347
 
1348 1348
     /**
@@ -1352,8 +1352,8 @@  discard block
 block discarded – undo
1352 1352
 	 * @param  string $context View or edit context.
1353 1353
 	 * @return bool
1354 1354
 	 */
1355
-	public function get_user_address_confirmed( $context = 'view' ) {
1356
-		return $this->get_address_confirmed( $context );
1355
+	public function get_user_address_confirmed($context = 'view') {
1356
+		return $this->get_address_confirmed($context);
1357 1357
     }
1358 1358
 
1359 1359
     /**
@@ -1363,8 +1363,8 @@  discard block
 block discarded – undo
1363 1363
 	 * @param  string $context View or edit context.
1364 1364
 	 * @return bool
1365 1365
 	 */
1366
-	public function get_customer_address_confirmed( $context = 'view' ) {
1367
-		return $this->get_address_confirmed( $context );
1366
+	public function get_customer_address_confirmed($context = 'view') {
1367
+		return $this->get_address_confirmed($context);
1368 1368
     }
1369 1369
 
1370 1370
 	/**
@@ -1374,17 +1374,17 @@  discard block
 block discarded – undo
1374 1374
 	 * @param  string $context View or edit context.
1375 1375
 	 * @return float
1376 1376
 	 */
1377
-	public function get_shipping( $context = 'view' ) {
1377
+	public function get_shipping($context = 'view') {
1378 1378
 
1379
-		if ( $context = 'view' ) {
1380
-			return floatval( $this->get_prop( 'shipping', $context ) );
1379
+		if ($context = 'view') {
1380
+			return floatval($this->get_prop('shipping', $context));
1381 1381
 		}
1382 1382
  
1383
-		return $this->get_prop( 'shipping', $context );
1383
+		return $this->get_prop('shipping', $context);
1384 1384
     }
1385 1385
 
1386 1386
 	public function has_shipping() {
1387
-		return null !== $this->get_prop( 'shipping', 'edit' );
1387
+		return null !== $this->get_prop('shipping', 'edit');
1388 1388
     }
1389 1389
 
1390 1390
     /**
@@ -1394,12 +1394,12 @@  discard block
 block discarded – undo
1394 1394
 	 * @param  string $context View or edit context.
1395 1395
 	 * @return float
1396 1396
 	 */
1397
-	public function get_subtotal( $context = 'view' ) {
1398
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1397
+	public function get_subtotal($context = 'view') {
1398
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1399 1399
 
1400 1400
         // Backwards compatibility.
1401
-        if ( is_bool( $context ) && $context ) {
1402
-            return wpinv_price( $subtotal, $this->get_currency() );
1401
+        if (is_bool($context) && $context) {
1402
+            return wpinv_price($subtotal, $this->get_currency());
1403 1403
         }
1404 1404
 
1405 1405
         return $subtotal;
@@ -1412,8 +1412,8 @@  discard block
 block discarded – undo
1412 1412
 	 * @param  string $context View or edit context.
1413 1413
 	 * @return float
1414 1414
 	 */
1415
-	public function get_total_discount( $context = 'view' ) {
1416
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1415
+	public function get_total_discount($context = 'view') {
1416
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context)));
1417 1417
     }
1418 1418
 
1419 1419
     /**
@@ -1423,18 +1423,18 @@  discard block
 block discarded – undo
1423 1423
 	 * @param  string $context View or edit context.
1424 1424
 	 * @return float
1425 1425
 	 */
1426
-	public function get_total_tax( $context = 'view' ) {
1427
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1426
+	public function get_total_tax($context = 'view') {
1427
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context)));
1428 1428
 	}
1429 1429
 
1430 1430
 	/**
1431 1431
 	 * @deprecated
1432 1432
 	 */
1433
-	public function get_final_tax( $currency = false ) {
1433
+	public function get_final_tax($currency = false) {
1434 1434
 		$tax = $this->get_total_tax();
1435 1435
 
1436
-        if ( $currency ) {
1437
-			return wpinv_price( $tax, $this->get_currency() );
1436
+        if ($currency) {
1437
+			return wpinv_price($tax, $this->get_currency());
1438 1438
         }
1439 1439
 
1440 1440
         return $tax;
@@ -1447,8 +1447,8 @@  discard block
 block discarded – undo
1447 1447
 	 * @param  string $context View or edit context.
1448 1448
 	 * @return float
1449 1449
 	 */
1450
-	public function get_total_fees( $context = 'view' ) {
1451
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1450
+	public function get_total_fees($context = 'view') {
1451
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context)));
1452 1452
     }
1453 1453
 
1454 1454
     /**
@@ -1458,8 +1458,8 @@  discard block
 block discarded – undo
1458 1458
 	 * @param  string $context View or edit context.
1459 1459
 	 * @return float
1460 1460
 	 */
1461
-	public function get_fees_total( $context = 'view' ) {
1462
-		return $this->get_total_fees( $context );
1461
+	public function get_fees_total($context = 'view') {
1462
+		return $this->get_total_fees($context);
1463 1463
     }
1464 1464
 
1465 1465
     /**
@@ -1468,14 +1468,14 @@  discard block
 block discarded – undo
1468 1468
 	 * @since 1.0.19
1469 1469
      * @return float
1470 1470
 	 */
1471
-	public function get_total( $context = 'view' ) {
1472
-		$total = $this->get_prop( 'total', $context );
1471
+	public function get_total($context = 'view') {
1472
+		$total = $this->get_prop('total', $context);
1473 1473
 
1474
-		if ( $this->has_shipping() && $context == 'view' ) {
1475
-			$total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1474
+		if ($this->has_shipping() && $context == 'view') {
1475
+			$total = $this->get_prop('total', $context) + $this->get_shipping($context);
1476 1476
 		}
1477 1477
 
1478
-		return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1478
+		return wpinv_round_amount(wpinv_sanitize_amount($total));
1479 1479
 	}
1480 1480
 
1481 1481
 	/**
@@ -1487,20 +1487,20 @@  discard block
 block discarded – undo
1487 1487
 	public function get_non_recurring_total() {
1488 1488
 
1489 1489
 		$subtotal = 0;
1490
-		foreach ( $this->get_items() as $item ) {
1491
-			if ( ! $item->is_recurring() ) {
1490
+		foreach ($this->get_items() as $item) {
1491
+			if (!$item->is_recurring()) {
1492 1492
 				$subtotal += $item->get_sub_total();
1493 1493
 			}
1494 1494
 		}
1495 1495
 
1496
-		foreach ( $this->get_fees() as $fee ) {
1497
-			if ( empty( $fee['recurring_fee'] ) ) {
1498
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1496
+		foreach ($this->get_fees() as $fee) {
1497
+			if (empty($fee['recurring_fee'])) {
1498
+				$subtotal += wpinv_sanitize_amount($fee['initial_fee']);
1499 1499
 			}
1500 1500
 		}
1501 1501
 
1502
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1503
-        return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1502
+		$subtotal = wpinv_round_amount(wpinv_sanitize_amount($subtotal));
1503
+        return apply_filters('wpinv_get_non_recurring_invoice_total', $subtotal, $this);
1504 1504
 
1505 1505
     }
1506 1506
 
@@ -1523,7 +1523,7 @@  discard block
 block discarded – undo
1523 1523
 	 */
1524 1524
     public function get_initial_total() {
1525 1525
 
1526
-		if ( empty( $this->totals ) ) {
1526
+		if (empty($this->totals)) {
1527 1527
 			$this->recalculate_total();
1528 1528
 		}
1529 1529
 
@@ -1533,12 +1533,12 @@  discard block
 block discarded – undo
1533 1533
 		$subtotal = $this->totals['subtotal']['initial'];
1534 1534
 		$total    = $tax + $fee - $discount + $subtotal;
1535 1535
 
1536
-		if ( 0 > $total ) {
1536
+		if (0 > $total) {
1537 1537
 			$total = 0;
1538 1538
 		}
1539 1539
 
1540
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1541
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1540
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1541
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1542 1542
 	}
1543 1543
 
1544 1544
 	/**
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
 	 */
1551 1551
     public function get_recurring_total() {
1552 1552
 
1553
-		if ( empty( $this->totals ) ) {
1553
+		if (empty($this->totals)) {
1554 1554
 			$this->recalculate_total();
1555 1555
 		}
1556 1556
 
@@ -1560,12 +1560,12 @@  discard block
 block discarded – undo
1560 1560
 		$subtotal = $this->totals['subtotal']['recurring'];
1561 1561
 		$total    = $tax + $fee - $discount + $subtotal;
1562 1562
 
1563
-		if ( 0 > $total ) {
1563
+		if (0 > $total) {
1564 1564
 			$total = 0;
1565 1565
 		}
1566 1566
 
1567
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1568
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1567
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1568
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1569 1569
 	}
1570 1570
 
1571 1571
 	/**
@@ -1576,10 +1576,10 @@  discard block
 block discarded – undo
1576 1576
 	 * @param string $currency Whether to include the currency.
1577 1577
      * @return float|string
1578 1578
 	 */
1579
-    public function get_recurring_details( $field = '', $currency = false ) {
1579
+    public function get_recurring_details($field = '', $currency = false) {
1580 1580
 
1581 1581
 		// Maybe recalculate totals.
1582
-		if ( empty( $this->totals ) ) {
1582
+		if (empty($this->totals)) {
1583 1583
 			$this->recalculate_total();
1584 1584
 		}
1585 1585
 
@@ -1599,8 +1599,8 @@  discard block
 block discarded – undo
1599 1599
 			$currency
1600 1600
 		);
1601 1601
 
1602
-        if ( isset( $data[$field] ) ) {
1603
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1602
+        if (isset($data[$field])) {
1603
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1604 1604
         }
1605 1605
 
1606 1606
         return $data;
@@ -1613,8 +1613,8 @@  discard block
 block discarded – undo
1613 1613
 	 * @param  string $context View or edit context.
1614 1614
 	 * @return array
1615 1615
 	 */
1616
-	public function get_fees( $context = 'view' ) {
1617
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1616
+	public function get_fees($context = 'view') {
1617
+		return wpinv_parse_list($this->get_prop('fees', $context));
1618 1618
     }
1619 1619
 
1620 1620
     /**
@@ -1624,8 +1624,8 @@  discard block
 block discarded – undo
1624 1624
 	 * @param  string $context View or edit context.
1625 1625
 	 * @return array
1626 1626
 	 */
1627
-	public function get_discounts( $context = 'view' ) {
1628
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1627
+	public function get_discounts($context = 'view') {
1628
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1629 1629
     }
1630 1630
 
1631 1631
     /**
@@ -1635,8 +1635,8 @@  discard block
 block discarded – undo
1635 1635
 	 * @param  string $context View or edit context.
1636 1636
 	 * @return array
1637 1637
 	 */
1638
-	public function get_taxes( $context = 'view' ) {
1639
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1638
+	public function get_taxes($context = 'view') {
1639
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1640 1640
     }
1641 1641
 
1642 1642
     /**
@@ -1646,8 +1646,8 @@  discard block
 block discarded – undo
1646 1646
 	 * @param  string $context View or edit context.
1647 1647
 	 * @return GetPaid_Form_Item[]
1648 1648
 	 */
1649
-	public function get_items( $context = 'view' ) {
1650
-        return $this->get_prop( 'items', $context );
1649
+	public function get_items($context = 'view') {
1650
+        return $this->get_prop('items', $context);
1651 1651
 	}
1652 1652
 
1653 1653
 	/**
@@ -1657,7 +1657,7 @@  discard block
 block discarded – undo
1657 1657
 	 * @return string
1658 1658
 	 */
1659 1659
 	public function get_item_ids() {
1660
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1660
+		return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id'));
1661 1661
     }
1662 1662
 
1663 1663
     /**
@@ -1667,8 +1667,8 @@  discard block
 block discarded – undo
1667 1667
 	 * @param  string $context View or edit context.
1668 1668
 	 * @return int
1669 1669
 	 */
1670
-	public function get_payment_form( $context = 'view' ) {
1671
-		return intval( $this->get_prop( 'payment_form', $context ) );
1670
+	public function get_payment_form($context = 'view') {
1671
+		return intval($this->get_prop('payment_form', $context));
1672 1672
     }
1673 1673
 
1674 1674
     /**
@@ -1678,8 +1678,8 @@  discard block
 block discarded – undo
1678 1678
 	 * @param  string $context View or edit context.
1679 1679
 	 * @return string
1680 1680
 	 */
1681
-	public function get_submission_id( $context = 'view' ) {
1682
-		return $this->get_prop( 'submission_id', $context );
1681
+	public function get_submission_id($context = 'view') {
1682
+		return $this->get_prop('submission_id', $context);
1683 1683
     }
1684 1684
 
1685 1685
     /**
@@ -1689,8 +1689,8 @@  discard block
 block discarded – undo
1689 1689
 	 * @param  string $context View or edit context.
1690 1690
 	 * @return string
1691 1691
 	 */
1692
-	public function get_discount_code( $context = 'view' ) {
1693
-		return $this->get_prop( 'discount_code', $context );
1692
+	public function get_discount_code($context = 'view') {
1693
+		return $this->get_prop('discount_code', $context);
1694 1694
     }
1695 1695
 
1696 1696
     /**
@@ -1700,8 +1700,8 @@  discard block
 block discarded – undo
1700 1700
 	 * @param  string $context View or edit context.
1701 1701
 	 * @return string
1702 1702
 	 */
1703
-	public function get_gateway( $context = 'view' ) {
1704
-		return $this->get_prop( 'gateway', $context );
1703
+	public function get_gateway($context = 'view') {
1704
+		return $this->get_prop('gateway', $context);
1705 1705
     }
1706 1706
 
1707 1707
     /**
@@ -1711,8 +1711,8 @@  discard block
 block discarded – undo
1711 1711
 	 * @return string
1712 1712
 	 */
1713 1713
     public function get_gateway_title() {
1714
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1715
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1714
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1715
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1716 1716
     }
1717 1717
 
1718 1718
     /**
@@ -1722,8 +1722,8 @@  discard block
 block discarded – undo
1722 1722
 	 * @param  string $context View or edit context.
1723 1723
 	 * @return string
1724 1724
 	 */
1725
-	public function get_transaction_id( $context = 'view' ) {
1726
-		return $this->get_prop( 'transaction_id', $context );
1725
+	public function get_transaction_id($context = 'view') {
1726
+		return $this->get_prop('transaction_id', $context);
1727 1727
     }
1728 1728
 
1729 1729
     /**
@@ -1733,9 +1733,9 @@  discard block
 block discarded – undo
1733 1733
 	 * @param  string $context View or edit context.
1734 1734
 	 * @return string
1735 1735
 	 */
1736
-	public function get_currency( $context = 'view' ) {
1737
-        $currency = $this->get_prop( 'currency', $context );
1738
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1736
+	public function get_currency($context = 'view') {
1737
+        $currency = $this->get_prop('currency', $context);
1738
+        return empty($currency) ? wpinv_get_currency() : $currency;
1739 1739
     }
1740 1740
 
1741 1741
     /**
@@ -1745,8 +1745,8 @@  discard block
 block discarded – undo
1745 1745
 	 * @param  string $context View or edit context.
1746 1746
 	 * @return bool
1747 1747
 	 */
1748
-	public function get_disable_taxes( $context = 'view' ) {
1749
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1748
+	public function get_disable_taxes($context = 'view') {
1749
+        return (bool) $this->get_prop('disable_taxes', $context);
1750 1750
     }
1751 1751
 
1752 1752
     /**
@@ -1756,8 +1756,8 @@  discard block
 block discarded – undo
1756 1756
 	 * @param  string $context View or edit context.
1757 1757
 	 * @return int
1758 1758
 	 */
1759
-    public function get_subscription_id( $context = 'view' ) {
1760
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1759
+    public function get_subscription_id($context = 'view') {
1760
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1761 1761
 	}
1762 1762
 
1763 1763
 	/**
@@ -1767,12 +1767,12 @@  discard block
 block discarded – undo
1767 1767
 	 * @param  string $context View or edit context.
1768 1768
 	 * @return int
1769 1769
 	 */
1770
-    public function get_remote_subscription_id( $context = 'view' ) {
1771
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1770
+    public function get_remote_subscription_id($context = 'view') {
1771
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1772 1772
 
1773
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1773
+        if (empty($subscription_id) && $this->is_renewal()) {
1774 1774
             $parent = $this->get_parent();
1775
-            return $parent->get_remote_subscription_id( $context );
1775
+            return $parent->get_remote_subscription_id($context);
1776 1776
         }
1777 1777
 
1778 1778
         return $subscription_id;
@@ -1785,20 +1785,20 @@  discard block
 block discarded – undo
1785 1785
 	 * @param  string $context View or edit context.
1786 1786
 	 * @return array
1787 1787
 	 */
1788
-    public function get_payment_meta( $context = 'view' ) {
1788
+    public function get_payment_meta($context = 'view') {
1789 1789
 
1790 1790
         return array(
1791
-            'price'        => $this->get_total( $context ),
1792
-            'date'         => $this->get_date_created( $context ),
1793
-            'user_email'   => $this->get_email( $context ),
1794
-            'invoice_key'  => $this->get_key( $context ),
1795
-            'currency'     => $this->get_currency( $context ),
1796
-            'items'        => $this->get_items( $context ),
1797
-            'user_info'    => $this->get_user_info( $context ),
1791
+            'price'        => $this->get_total($context),
1792
+            'date'         => $this->get_date_created($context),
1793
+            'user_email'   => $this->get_email($context),
1794
+            'invoice_key'  => $this->get_key($context),
1795
+            'currency'     => $this->get_currency($context),
1796
+            'items'        => $this->get_items($context),
1797
+            'user_info'    => $this->get_user_info($context),
1798 1798
             'cart_details' => $this->get_cart_details(),
1799
-            'status'       => $this->get_status( $context ),
1800
-            'fees'         => $this->get_fees( $context ),
1801
-            'taxes'        => $this->get_taxes( $context ),
1799
+            'status'       => $this->get_status($context),
1800
+            'fees'         => $this->get_fees($context),
1801
+            'taxes'        => $this->get_taxes($context),
1802 1802
         );
1803 1803
 
1804 1804
     }
@@ -1813,9 +1813,9 @@  discard block
 block discarded – undo
1813 1813
         $items        = $this->get_items();
1814 1814
         $cart_details = array();
1815 1815
 
1816
-        foreach ( $items as $item ) {
1816
+        foreach ($items as $item) {
1817 1817
 			$item->invoice_id = $this->get_id();
1818
-            $cart_details[]   = $item->prepare_data_for_saving();
1818
+            $cart_details[] = $item->prepare_data_for_saving();
1819 1819
         }
1820 1820
 
1821 1821
         return $cart_details;
@@ -1826,11 +1826,11 @@  discard block
 block discarded – undo
1826 1826
 	 *
1827 1827
 	 * @return null|GetPaid_Form_Item|int
1828 1828
 	 */
1829
-	public function get_recurring( $object = false ) {
1829
+	public function get_recurring($object = false) {
1830 1830
 
1831 1831
 		// Are we returning an object?
1832
-        if ( $object ) {
1833
-            return $this->get_item( $this->recurring_item );
1832
+        if ($object) {
1833
+            return $this->get_item($this->recurring_item);
1834 1834
         }
1835 1835
 
1836 1836
         return $this->recurring_item;
@@ -1845,15 +1845,15 @@  discard block
 block discarded – undo
1845 1845
 	public function get_subscription_name() {
1846 1846
 
1847 1847
 		// Retrieve the recurring name
1848
-        $item = $this->get_recurring( true );
1848
+        $item = $this->get_recurring(true);
1849 1849
 
1850 1850
 		// Abort if it does not exist.
1851
-        if ( empty( $item ) ) {
1851
+        if (empty($item)) {
1852 1852
             return '';
1853 1853
         }
1854 1854
 
1855 1855
 		// Return the item name.
1856
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1856
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1857 1857
 	}
1858 1858
 
1859 1859
 	/**
@@ -1863,9 +1863,9 @@  discard block
 block discarded – undo
1863 1863
 	 * @return string
1864 1864
 	 */
1865 1865
 	public function get_view_url() {
1866
-        $invoice_url = get_permalink( $this->get_id() );
1867
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1868
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1866
+        $invoice_url = get_permalink($this->get_id());
1867
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1868
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1869 1869
 	}
1870 1870
 
1871 1871
 	/**
@@ -1874,25 +1874,25 @@  discard block
 block discarded – undo
1874 1874
 	 * @since 1.0.19
1875 1875
 	 * @return string
1876 1876
 	 */
1877
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1877
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1878 1878
 
1879 1879
 		// Retrieve the checkout url.
1880 1880
         $pay_url = wpinv_get_checkout_uri();
1881 1881
 
1882 1882
 		// Maybe force ssl.
1883
-        if ( is_ssl() ) {
1884
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1883
+        if (is_ssl()) {
1884
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1885 1885
         }
1886 1886
 
1887 1887
 		// Add the invoice key.
1888
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1888
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1889 1889
 
1890 1890
 		// (Maybe?) add a secret
1891
-        if ( $secret ) {
1892
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1891
+        if ($secret) {
1892
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1893 1893
         }
1894 1894
 
1895
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1895
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1896 1896
 	}
1897 1897
 	
1898 1898
 	/**
@@ -1907,14 +1907,14 @@  discard block
 block discarded – undo
1907 1907
         $receipt_url = wpinv_get_success_page_uri();
1908 1908
 
1909 1909
 		// Maybe force ssl.
1910
-        if ( is_ssl() ) {
1911
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1910
+        if (is_ssl()) {
1911
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1912 1912
         }
1913 1913
 
1914 1914
 		// Add the invoice key.
1915
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1915
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1916 1916
 
1917
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1917
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1918 1918
 	}
1919 1919
 	
1920 1920
 	/**
@@ -1927,7 +1927,7 @@  discard block
 block discarded – undo
1927 1927
 
1928 1928
 		$type   = $this->get_type();
1929 1929
 		$status = "wpi-$type-pending";
1930
-		return str_replace( '-invoice', '', $status );
1930
+		return str_replace('-invoice', '', $status);
1931 1931
 
1932 1932
 	}
1933 1933
 
@@ -1941,8 +1941,8 @@  discard block
 block discarded – undo
1941 1941
 	 * @param  string $context View or edit context.
1942 1942
 	 * @return mixed Value of the given invoice property (if set).
1943 1943
 	 */
1944
-	public function get( $key, $context = 'view' ) {
1945
-        return $this->get_prop( $key, $context );
1944
+	public function get($key, $context = 'view') {
1945
+        return $this->get_prop($key, $context);
1946 1946
 	}
1947 1947
 
1948 1948
     /*
@@ -1965,11 +1965,11 @@  discard block
 block discarded – undo
1965 1965
 	 * @param  mixed $value new value.
1966 1966
 	 * @return mixed Value of the given invoice property (if set).
1967 1967
 	 */
1968
-	public function set( $key, $value ) {
1968
+	public function set($key, $value) {
1969 1969
 
1970 1970
         $setter = "set_$key";
1971
-        if ( is_callable( array( $this, $setter ) ) ) {
1972
-            $this->{$setter}( $value );
1971
+        if (is_callable(array($this, $setter))) {
1972
+            $this->{$setter}($value);
1973 1973
         }
1974 1974
 
1975 1975
 	}
@@ -1983,45 +1983,45 @@  discard block
 block discarded – undo
1983 1983
 	 * @param bool   $manual_update Is this a manual status change?.
1984 1984
 	 * @return array details of change.
1985 1985
 	 */
1986
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1986
+	public function set_status($new_status, $note = '', $manual_update = false) {
1987 1987
 		$old_status = $this->get_status();
1988 1988
 
1989 1989
 		$statuses = $this->get_all_statuses();
1990 1990
 
1991
-		if ( isset( $statuses[ 'draft' ] ) ) {
1992
-			unset( $statuses[ 'draft' ] );
1991
+		if (isset($statuses['draft'])) {
1992
+			unset($statuses['draft']);
1993 1993
 		}
1994 1994
 
1995
-		$this->set_prop( 'status', $new_status );
1995
+		$this->set_prop('status', $new_status);
1996 1996
 
1997 1997
 		// If setting the status, ensure it's set to a valid status.
1998
-		if ( true === $this->object_read ) {
1998
+		if (true === $this->object_read) {
1999 1999
 
2000 2000
 			// Only allow valid new status.
2001
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
2001
+			if (!array_key_exists($new_status, $statuses)) {
2002 2002
 				$new_status = $this->get_default_status();
2003 2003
 			}
2004 2004
 
2005 2005
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2006
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2006
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
2007 2007
 				$old_status = $this->get_default_status();
2008 2008
 			}
2009 2009
 
2010 2010
 			// Paid - Renewal (i.e when duplicating a parent invoice )
2011
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2011
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
2012 2012
 				$old_status = 'wpi-pending';
2013 2013
 			}
2014 2014
 
2015
-			if ( $old_status !== $new_status ) {
2015
+			if ($old_status !== $new_status) {
2016 2016
 				$this->status_transition = array(
2017
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2017
+					'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
2018 2018
 					'to'     => $new_status,
2019 2019
 					'note'   => $note,
2020 2020
 					'manual' => (bool) $manual_update,
2021 2021
 				);
2022 2022
 
2023
-				if ( $manual_update ) {
2024
-					do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
2023
+				if ($manual_update) {
2024
+					do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
2025 2025
 				}
2026 2026
 
2027 2027
 				$this->maybe_set_date_paid();
@@ -2046,8 +2046,8 @@  discard block
 block discarded – undo
2046 2046
 	 */
2047 2047
 	public function maybe_set_date_paid() {
2048 2048
 
2049
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2050
-			$this->set_date_completed( current_time( 'mysql' ) );
2049
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
2050
+			$this->set_date_completed(current_time('mysql'));
2051 2051
 		}
2052 2052
 	}
2053 2053
 
@@ -2056,11 +2056,11 @@  discard block
 block discarded – undo
2056 2056
 	 *
2057 2057
 	 * @since 1.0.19
2058 2058
 	 */
2059
-	public function set_parent_id( $value ) {
2060
-		if ( $value && ( $value === $this->get_id() ) ) {
2059
+	public function set_parent_id($value) {
2060
+		if ($value && ($value === $this->get_id())) {
2061 2061
 			return;
2062 2062
 		}
2063
-		$this->set_prop( 'parent_id', absint( $value ) );
2063
+		$this->set_prop('parent_id', absint($value));
2064 2064
     }
2065 2065
 
2066 2066
     /**
@@ -2068,8 +2068,8 @@  discard block
 block discarded – undo
2068 2068
 	 *
2069 2069
 	 * @since 1.0.19
2070 2070
 	 */
2071
-	public function set_version( $value ) {
2072
-		$this->set_prop( 'version', $value );
2071
+	public function set_version($value) {
2072
+		$this->set_prop('version', $value);
2073 2073
     }
2074 2074
 
2075 2075
     /**
@@ -2079,15 +2079,15 @@  discard block
 block discarded – undo
2079 2079
 	 * @param string $value Value to set.
2080 2080
      * @return bool Whether or not the date was set.
2081 2081
 	 */
2082
-	public function set_date_created( $value ) {
2083
-        $date = strtotime( $value );
2082
+	public function set_date_created($value) {
2083
+        $date = strtotime($value);
2084 2084
 
2085
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2086
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
2085
+        if ($date && $value !== '0000-00-00 00:00:00') {
2086
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
2087 2087
             return true;
2088 2088
         }
2089 2089
 
2090
-		$this->set_prop( 'date_created', '' );
2090
+		$this->set_prop('date_created', '');
2091 2091
 		return false;
2092 2092
 
2093 2093
     }
@@ -2099,15 +2099,15 @@  discard block
 block discarded – undo
2099 2099
 	 * @param string $value Value to set.
2100 2100
      * @return bool Whether or not the date was set.
2101 2101
 	 */
2102
-	public function set_due_date( $value ) {
2103
-        $date = strtotime( $value );
2102
+	public function set_due_date($value) {
2103
+        $date = strtotime($value);
2104 2104
 
2105
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2106
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
2105
+        if ($date && $value !== '0000-00-00 00:00:00') {
2106
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
2107 2107
             return true;
2108 2108
         }
2109 2109
 
2110
-		$this->set_prop( 'due_date', '' );
2110
+		$this->set_prop('due_date', '');
2111 2111
         return false;
2112 2112
 
2113 2113
     }
@@ -2118,8 +2118,8 @@  discard block
 block discarded – undo
2118 2118
 	 * @since 1.0.19
2119 2119
 	 * @param  string $value New name.
2120 2120
 	 */
2121
-	public function set_date_due( $value ) {
2122
-		$this->set_due_date( $value );
2121
+	public function set_date_due($value) {
2122
+		$this->set_due_date($value);
2123 2123
     }
2124 2124
 
2125 2125
     /**
@@ -2129,15 +2129,15 @@  discard block
 block discarded – undo
2129 2129
 	 * @param string $value Value to set.
2130 2130
      * @return bool Whether or not the date was set.
2131 2131
 	 */
2132
-	public function set_completed_date( $value ) {
2133
-        $date = strtotime( $value );
2132
+	public function set_completed_date($value) {
2133
+        $date = strtotime($value);
2134 2134
 
2135
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
2136
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2135
+        if ($date && $value !== '0000-00-00 00:00:00') {
2136
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2137 2137
             return true;
2138 2138
         }
2139 2139
 
2140
-		$this->set_prop( 'completed_date', '' );
2140
+		$this->set_prop('completed_date', '');
2141 2141
         return false;
2142 2142
 
2143 2143
     }
@@ -2148,8 +2148,8 @@  discard block
 block discarded – undo
2148 2148
 	 * @since 1.0.19
2149 2149
 	 * @param  string $value New name.
2150 2150
 	 */
2151
-	public function set_date_completed( $value ) {
2152
-		$this->set_completed_date( $value );
2151
+	public function set_date_completed($value) {
2152
+		$this->set_completed_date($value);
2153 2153
     }
2154 2154
 
2155 2155
     /**
@@ -2159,15 +2159,15 @@  discard block
 block discarded – undo
2159 2159
 	 * @param string $value Value to set.
2160 2160
      * @return bool Whether or not the date was set.
2161 2161
 	 */
2162
-	public function set_date_modified( $value ) {
2163
-        $date = strtotime( $value );
2162
+	public function set_date_modified($value) {
2163
+        $date = strtotime($value);
2164 2164
 
2165
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2166
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2165
+        if ($date && $value !== '0000-00-00 00:00:00') {
2166
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2167 2167
             return true;
2168 2168
         }
2169 2169
 
2170
-		$this->set_prop( 'date_modified', '' );
2170
+		$this->set_prop('date_modified', '');
2171 2171
         return false;
2172 2172
 
2173 2173
     }
@@ -2178,9 +2178,9 @@  discard block
 block discarded – undo
2178 2178
 	 * @since 1.0.19
2179 2179
 	 * @param  string $value New number.
2180 2180
 	 */
2181
-	public function set_number( $value ) {
2182
-        $number = sanitize_text_field( $value );
2183
-		$this->set_prop( 'number', $number );
2181
+	public function set_number($value) {
2182
+        $number = sanitize_text_field($value);
2183
+		$this->set_prop('number', $number);
2184 2184
     }
2185 2185
 
2186 2186
     /**
@@ -2189,9 +2189,9 @@  discard block
 block discarded – undo
2189 2189
 	 * @since 1.0.19
2190 2190
 	 * @param  string $value Type.
2191 2191
 	 */
2192
-	public function set_type( $value ) {
2193
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2194
-		$this->set_prop( 'type', $type );
2192
+	public function set_type($value) {
2193
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2194
+		$this->set_prop('type', $type);
2195 2195
 	}
2196 2196
 
2197 2197
     /**
@@ -2200,10 +2200,10 @@  discard block
 block discarded – undo
2200 2200
 	 * @since 1.0.19
2201 2201
 	 * @param  string $value Post type.
2202 2202
 	 */
2203
-	public function set_post_type( $value ) {
2204
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2205
-			$this->set_type( $value );
2206
-            $this->set_prop( 'post_type', $value );
2203
+	public function set_post_type($value) {
2204
+        if (getpaid_is_invoice_post_type($value)) {
2205
+			$this->set_type($value);
2206
+            $this->set_prop('post_type', $value);
2207 2207
         }
2208 2208
     }
2209 2209
 
@@ -2213,9 +2213,9 @@  discard block
 block discarded – undo
2213 2213
 	 * @since 1.0.19
2214 2214
 	 * @param  string $value New key.
2215 2215
 	 */
2216
-	public function set_key( $value ) {
2217
-        $key = sanitize_text_field( $value );
2218
-		$this->set_prop( 'key', $key );
2216
+	public function set_key($value) {
2217
+        $key = sanitize_text_field($value);
2218
+		$this->set_prop('key', $key);
2219 2219
     }
2220 2220
 
2221 2221
     /**
@@ -2224,9 +2224,9 @@  discard block
 block discarded – undo
2224 2224
 	 * @since 1.0.19
2225 2225
 	 * @param  string $value mode.
2226 2226
 	 */
2227
-	public function set_mode( $value ) {
2228
-        if ( in_array( $value, array( 'live', 'test' ) ) ) {
2229
-            $this->set_prop( 'mode', $value );
2227
+	public function set_mode($value) {
2228
+        if (in_array($value, array('live', 'test'))) {
2229
+            $this->set_prop('mode', $value);
2230 2230
         }
2231 2231
     }
2232 2232
 
@@ -2236,8 +2236,8 @@  discard block
 block discarded – undo
2236 2236
 	 * @since 1.0.19
2237 2237
 	 * @param  string $value path.
2238 2238
 	 */
2239
-	public function set_path( $value ) {
2240
-        $this->set_prop( 'path', $value );
2239
+	public function set_path($value) {
2240
+        $this->set_prop('path', $value);
2241 2241
     }
2242 2242
 
2243 2243
     /**
@@ -2246,9 +2246,9 @@  discard block
 block discarded – undo
2246 2246
 	 * @since 1.0.19
2247 2247
 	 * @param  string $value New name.
2248 2248
 	 */
2249
-	public function set_name( $value ) {
2250
-        $name = sanitize_text_field( $value );
2251
-		$this->set_prop( 'name', $name );
2249
+	public function set_name($value) {
2250
+        $name = sanitize_text_field($value);
2251
+		$this->set_prop('name', $name);
2252 2252
     }
2253 2253
 
2254 2254
     /**
@@ -2257,8 +2257,8 @@  discard block
 block discarded – undo
2257 2257
 	 * @since 1.0.19
2258 2258
 	 * @param  string $value New name.
2259 2259
 	 */
2260
-	public function set_title( $value ) {
2261
-		$this->set_name( $value );
2260
+	public function set_title($value) {
2261
+		$this->set_name($value);
2262 2262
     }
2263 2263
 
2264 2264
     /**
@@ -2267,9 +2267,9 @@  discard block
 block discarded – undo
2267 2267
 	 * @since 1.0.19
2268 2268
 	 * @param  string $value New description.
2269 2269
 	 */
2270
-	public function set_description( $value ) {
2271
-        $description = wp_kses_post( $value );
2272
-		$this->set_prop( 'description', $description );
2270
+	public function set_description($value) {
2271
+        $description = wp_kses_post($value);
2272
+		$this->set_prop('description', $description);
2273 2273
     }
2274 2274
 
2275 2275
     /**
@@ -2278,8 +2278,8 @@  discard block
 block discarded – undo
2278 2278
 	 * @since 1.0.19
2279 2279
 	 * @param  string $value New description.
2280 2280
 	 */
2281
-	public function set_excerpt( $value ) {
2282
-		$this->set_description( $value );
2281
+	public function set_excerpt($value) {
2282
+		$this->set_description($value);
2283 2283
     }
2284 2284
 
2285 2285
     /**
@@ -2288,8 +2288,8 @@  discard block
 block discarded – undo
2288 2288
 	 * @since 1.0.19
2289 2289
 	 * @param  string $value New description.
2290 2290
 	 */
2291
-	public function set_summary( $value ) {
2292
-		$this->set_description( $value );
2291
+	public function set_summary($value) {
2292
+		$this->set_description($value);
2293 2293
     }
2294 2294
 
2295 2295
     /**
@@ -2298,12 +2298,12 @@  discard block
 block discarded – undo
2298 2298
 	 * @since 1.0.19
2299 2299
 	 * @param  int $value New author.
2300 2300
 	 */
2301
-	public function set_author( $value ) {
2302
-		$user = get_user_by( 'id', (int) $value );
2301
+	public function set_author($value) {
2302
+		$user = get_user_by('id', (int) $value);
2303 2303
 
2304
-		if ( $user && $user->ID ) {
2305
-			$this->set_prop( 'author', $user->ID );
2306
-			$this->set_prop( 'email', $user->user_email );
2304
+		if ($user && $user->ID) {
2305
+			$this->set_prop('author', $user->ID);
2306
+			$this->set_prop('email', $user->user_email);
2307 2307
 		}
2308 2308
 
2309 2309
     }
@@ -2314,8 +2314,8 @@  discard block
 block discarded – undo
2314 2314
 	 * @since 1.0.19
2315 2315
 	 * @param  int $value New user id.
2316 2316
 	 */
2317
-	public function set_user_id( $value ) {
2318
-		$this->set_author( $value );
2317
+	public function set_user_id($value) {
2318
+		$this->set_author($value);
2319 2319
     }
2320 2320
 
2321 2321
     /**
@@ -2324,8 +2324,8 @@  discard block
 block discarded – undo
2324 2324
 	 * @since 1.0.19
2325 2325
 	 * @param  int $value New user id.
2326 2326
 	 */
2327
-	public function set_customer_id( $value ) {
2328
-		$this->set_author( $value );
2327
+	public function set_customer_id($value) {
2328
+		$this->set_author($value);
2329 2329
     }
2330 2330
 
2331 2331
     /**
@@ -2334,8 +2334,8 @@  discard block
 block discarded – undo
2334 2334
 	 * @since 1.0.19
2335 2335
 	 * @param  string $value ip address.
2336 2336
 	 */
2337
-	public function set_ip( $value ) {
2338
-		$this->set_prop( 'ip', $value );
2337
+	public function set_ip($value) {
2338
+		$this->set_prop('ip', $value);
2339 2339
     }
2340 2340
 
2341 2341
     /**
@@ -2344,8 +2344,8 @@  discard block
 block discarded – undo
2344 2344
 	 * @since 1.0.19
2345 2345
 	 * @param  string $value ip address.
2346 2346
 	 */
2347
-	public function set_user_ip( $value ) {
2348
-		$this->set_ip( $value );
2347
+	public function set_user_ip($value) {
2348
+		$this->set_ip($value);
2349 2349
     }
2350 2350
 
2351 2351
     /**
@@ -2354,8 +2354,8 @@  discard block
 block discarded – undo
2354 2354
 	 * @since 1.0.19
2355 2355
 	 * @param  string $value first name.
2356 2356
 	 */
2357
-	public function set_first_name( $value ) {
2358
-		$this->set_prop( 'first_name', $value );
2357
+	public function set_first_name($value) {
2358
+		$this->set_prop('first_name', $value);
2359 2359
     }
2360 2360
 
2361 2361
     /**
@@ -2364,8 +2364,8 @@  discard block
 block discarded – undo
2364 2364
 	 * @since 1.0.19
2365 2365
 	 * @param  string $value first name.
2366 2366
 	 */
2367
-	public function set_user_first_name( $value ) {
2368
-		$this->set_first_name( $value );
2367
+	public function set_user_first_name($value) {
2368
+		$this->set_first_name($value);
2369 2369
     }
2370 2370
 
2371 2371
     /**
@@ -2374,8 +2374,8 @@  discard block
 block discarded – undo
2374 2374
 	 * @since 1.0.19
2375 2375
 	 * @param  string $value first name.
2376 2376
 	 */
2377
-	public function set_customer_first_name( $value ) {
2378
-		$this->set_first_name( $value );
2377
+	public function set_customer_first_name($value) {
2378
+		$this->set_first_name($value);
2379 2379
     }
2380 2380
 
2381 2381
     /**
@@ -2384,8 +2384,8 @@  discard block
 block discarded – undo
2384 2384
 	 * @since 1.0.19
2385 2385
 	 * @param  string $value last name.
2386 2386
 	 */
2387
-	public function set_last_name( $value ) {
2388
-		$this->set_prop( 'last_name', $value );
2387
+	public function set_last_name($value) {
2388
+		$this->set_prop('last_name', $value);
2389 2389
     }
2390 2390
 
2391 2391
     /**
@@ -2394,8 +2394,8 @@  discard block
 block discarded – undo
2394 2394
 	 * @since 1.0.19
2395 2395
 	 * @param  string $value last name.
2396 2396
 	 */
2397
-	public function set_user_last_name( $value ) {
2398
-		$this->set_last_name( $value );
2397
+	public function set_user_last_name($value) {
2398
+		$this->set_last_name($value);
2399 2399
     }
2400 2400
 
2401 2401
     /**
@@ -2404,8 +2404,8 @@  discard block
 block discarded – undo
2404 2404
 	 * @since 1.0.19
2405 2405
 	 * @param  string $value last name.
2406 2406
 	 */
2407
-	public function set_customer_last_name( $value ) {
2408
-		$this->set_last_name( $value );
2407
+	public function set_customer_last_name($value) {
2408
+		$this->set_last_name($value);
2409 2409
     }
2410 2410
 
2411 2411
     /**
@@ -2414,8 +2414,8 @@  discard block
 block discarded – undo
2414 2414
 	 * @since 1.0.19
2415 2415
 	 * @param  string $value phone.
2416 2416
 	 */
2417
-	public function set_phone( $value ) {
2418
-		$this->set_prop( 'phone', $value );
2417
+	public function set_phone($value) {
2418
+		$this->set_prop('phone', $value);
2419 2419
     }
2420 2420
 
2421 2421
     /**
@@ -2424,8 +2424,8 @@  discard block
 block discarded – undo
2424 2424
 	 * @since 1.0.19
2425 2425
 	 * @param  string $value phone.
2426 2426
 	 */
2427
-	public function set_user_phone( $value ) {
2428
-		$this->set_phone( $value );
2427
+	public function set_user_phone($value) {
2428
+		$this->set_phone($value);
2429 2429
     }
2430 2430
 
2431 2431
     /**
@@ -2434,8 +2434,8 @@  discard block
 block discarded – undo
2434 2434
 	 * @since 1.0.19
2435 2435
 	 * @param  string $value phone.
2436 2436
 	 */
2437
-	public function set_customer_phone( $value ) {
2438
-		$this->set_phone( $value );
2437
+	public function set_customer_phone($value) {
2438
+		$this->set_phone($value);
2439 2439
     }
2440 2440
 
2441 2441
     /**
@@ -2444,8 +2444,8 @@  discard block
 block discarded – undo
2444 2444
 	 * @since 1.0.19
2445 2445
 	 * @param  string $value phone.
2446 2446
 	 */
2447
-	public function set_phone_number( $value ) {
2448
-		$this->set_phone( $value );
2447
+	public function set_phone_number($value) {
2448
+		$this->set_phone($value);
2449 2449
     }
2450 2450
 
2451 2451
     /**
@@ -2454,8 +2454,8 @@  discard block
 block discarded – undo
2454 2454
 	 * @since 1.0.19
2455 2455
 	 * @param  string $value email address.
2456 2456
 	 */
2457
-	public function set_email( $value ) {
2458
-		$this->set_prop( 'email', $value );
2457
+	public function set_email($value) {
2458
+		$this->set_prop('email', $value);
2459 2459
     }
2460 2460
 
2461 2461
     /**
@@ -2464,8 +2464,8 @@  discard block
 block discarded – undo
2464 2464
 	 * @since 1.0.19
2465 2465
 	 * @param  string $value email address.
2466 2466
 	 */
2467
-	public function set_user_email( $value ) {
2468
-		$this->set_email( $value );
2467
+	public function set_user_email($value) {
2468
+		$this->set_email($value);
2469 2469
     }
2470 2470
 
2471 2471
     /**
@@ -2474,8 +2474,8 @@  discard block
 block discarded – undo
2474 2474
 	 * @since 1.0.19
2475 2475
 	 * @param  string $value email address.
2476 2476
 	 */
2477
-	public function set_email_address( $value ) {
2478
-		$this->set_email( $value );
2477
+	public function set_email_address($value) {
2478
+		$this->set_email($value);
2479 2479
     }
2480 2480
 
2481 2481
     /**
@@ -2484,8 +2484,8 @@  discard block
 block discarded – undo
2484 2484
 	 * @since 1.0.19
2485 2485
 	 * @param  string $value email address.
2486 2486
 	 */
2487
-	public function set_customer_email( $value ) {
2488
-		$this->set_email( $value );
2487
+	public function set_customer_email($value) {
2488
+		$this->set_email($value);
2489 2489
     }
2490 2490
 
2491 2491
     /**
@@ -2494,8 +2494,8 @@  discard block
 block discarded – undo
2494 2494
 	 * @since 1.0.19
2495 2495
 	 * @param  string $value country.
2496 2496
 	 */
2497
-	public function set_country( $value ) {
2498
-		$this->set_prop( 'country', $value );
2497
+	public function set_country($value) {
2498
+		$this->set_prop('country', $value);
2499 2499
     }
2500 2500
 
2501 2501
     /**
@@ -2504,8 +2504,8 @@  discard block
 block discarded – undo
2504 2504
 	 * @since 1.0.19
2505 2505
 	 * @param  string $value country.
2506 2506
 	 */
2507
-	public function set_user_country( $value ) {
2508
-		$this->set_country( $value );
2507
+	public function set_user_country($value) {
2508
+		$this->set_country($value);
2509 2509
     }
2510 2510
 
2511 2511
     /**
@@ -2514,8 +2514,8 @@  discard block
 block discarded – undo
2514 2514
 	 * @since 1.0.19
2515 2515
 	 * @param  string $value country.
2516 2516
 	 */
2517
-	public function set_customer_country( $value ) {
2518
-		$this->set_country( $value );
2517
+	public function set_customer_country($value) {
2518
+		$this->set_country($value);
2519 2519
     }
2520 2520
 
2521 2521
     /**
@@ -2524,8 +2524,8 @@  discard block
 block discarded – undo
2524 2524
 	 * @since 1.0.19
2525 2525
 	 * @param  string $value state.
2526 2526
 	 */
2527
-	public function set_state( $value ) {
2528
-		$this->set_prop( 'state', $value );
2527
+	public function set_state($value) {
2528
+		$this->set_prop('state', $value);
2529 2529
     }
2530 2530
 
2531 2531
     /**
@@ -2534,8 +2534,8 @@  discard block
 block discarded – undo
2534 2534
 	 * @since 1.0.19
2535 2535
 	 * @param  string $value state.
2536 2536
 	 */
2537
-	public function set_user_state( $value ) {
2538
-		$this->set_state( $value );
2537
+	public function set_user_state($value) {
2538
+		$this->set_state($value);
2539 2539
     }
2540 2540
 
2541 2541
     /**
@@ -2544,8 +2544,8 @@  discard block
 block discarded – undo
2544 2544
 	 * @since 1.0.19
2545 2545
 	 * @param  string $value state.
2546 2546
 	 */
2547
-	public function set_customer_state( $value ) {
2548
-		$this->set_state( $value );
2547
+	public function set_customer_state($value) {
2548
+		$this->set_state($value);
2549 2549
     }
2550 2550
 
2551 2551
     /**
@@ -2554,8 +2554,8 @@  discard block
 block discarded – undo
2554 2554
 	 * @since 1.0.19
2555 2555
 	 * @param  string $value city.
2556 2556
 	 */
2557
-	public function set_city( $value ) {
2558
-		$this->set_prop( 'city', $value );
2557
+	public function set_city($value) {
2558
+		$this->set_prop('city', $value);
2559 2559
     }
2560 2560
 
2561 2561
     /**
@@ -2564,8 +2564,8 @@  discard block
 block discarded – undo
2564 2564
 	 * @since 1.0.19
2565 2565
 	 * @param  string $value city.
2566 2566
 	 */
2567
-	public function set_user_city( $value ) {
2568
-		$this->set_city( $value );
2567
+	public function set_user_city($value) {
2568
+		$this->set_city($value);
2569 2569
     }
2570 2570
 
2571 2571
     /**
@@ -2574,8 +2574,8 @@  discard block
 block discarded – undo
2574 2574
 	 * @since 1.0.19
2575 2575
 	 * @param  string $value city.
2576 2576
 	 */
2577
-	public function set_customer_city( $value ) {
2578
-		$this->set_city( $value );
2577
+	public function set_customer_city($value) {
2578
+		$this->set_city($value);
2579 2579
     }
2580 2580
 
2581 2581
     /**
@@ -2584,8 +2584,8 @@  discard block
 block discarded – undo
2584 2584
 	 * @since 1.0.19
2585 2585
 	 * @param  string $value zip.
2586 2586
 	 */
2587
-	public function set_zip( $value ) {
2588
-		$this->set_prop( 'zip', $value );
2587
+	public function set_zip($value) {
2588
+		$this->set_prop('zip', $value);
2589 2589
     }
2590 2590
 
2591 2591
     /**
@@ -2594,8 +2594,8 @@  discard block
 block discarded – undo
2594 2594
 	 * @since 1.0.19
2595 2595
 	 * @param  string $value zip.
2596 2596
 	 */
2597
-	public function set_user_zip( $value ) {
2598
-		$this->set_zip( $value );
2597
+	public function set_user_zip($value) {
2598
+		$this->set_zip($value);
2599 2599
     }
2600 2600
 
2601 2601
     /**
@@ -2604,8 +2604,8 @@  discard block
 block discarded – undo
2604 2604
 	 * @since 1.0.19
2605 2605
 	 * @param  string $value zip.
2606 2606
 	 */
2607
-	public function set_customer_zip( $value ) {
2608
-		$this->set_zip( $value );
2607
+	public function set_customer_zip($value) {
2608
+		$this->set_zip($value);
2609 2609
     }
2610 2610
 
2611 2611
     /**
@@ -2614,8 +2614,8 @@  discard block
 block discarded – undo
2614 2614
 	 * @since 1.0.19
2615 2615
 	 * @param  string $value company.
2616 2616
 	 */
2617
-	public function set_company( $value ) {
2618
-		$this->set_prop( 'company', $value );
2617
+	public function set_company($value) {
2618
+		$this->set_prop('company', $value);
2619 2619
     }
2620 2620
 
2621 2621
     /**
@@ -2624,8 +2624,8 @@  discard block
 block discarded – undo
2624 2624
 	 * @since 1.0.19
2625 2625
 	 * @param  string $value company.
2626 2626
 	 */
2627
-	public function set_user_company( $value ) {
2628
-		$this->set_company( $value );
2627
+	public function set_user_company($value) {
2628
+		$this->set_company($value);
2629 2629
     }
2630 2630
 
2631 2631
     /**
@@ -2634,8 +2634,8 @@  discard block
 block discarded – undo
2634 2634
 	 * @since 1.0.19
2635 2635
 	 * @param  string $value company.
2636 2636
 	 */
2637
-	public function set_customer_company( $value ) {
2638
-		$this->set_company( $value );
2637
+	public function set_customer_company($value) {
2638
+		$this->set_company($value);
2639 2639
     }
2640 2640
 
2641 2641
 	/**
@@ -2644,8 +2644,8 @@  discard block
 block discarded – undo
2644 2644
 	 * @since 1.0.19
2645 2645
 	 * @param  string $value company id.
2646 2646
 	 */
2647
-	public function set_company_id( $value ) {
2648
-		$this->set_prop( 'company_id', $value );
2647
+	public function set_company_id($value) {
2648
+		$this->set_prop('company_id', $value);
2649 2649
     }
2650 2650
 
2651 2651
     /**
@@ -2654,8 +2654,8 @@  discard block
 block discarded – undo
2654 2654
 	 * @since 1.0.19
2655 2655
 	 * @param  string $value var number.
2656 2656
 	 */
2657
-	public function set_vat_number( $value ) {
2658
-		$this->set_prop( 'vat_number', $value );
2657
+	public function set_vat_number($value) {
2658
+		$this->set_prop('vat_number', $value);
2659 2659
     }
2660 2660
 
2661 2661
     /**
@@ -2664,8 +2664,8 @@  discard block
 block discarded – undo
2664 2664
 	 * @since 1.0.19
2665 2665
 	 * @param  string $value var number.
2666 2666
 	 */
2667
-	public function set_user_vat_number( $value ) {
2668
-		$this->set_vat_number( $value );
2667
+	public function set_user_vat_number($value) {
2668
+		$this->set_vat_number($value);
2669 2669
     }
2670 2670
 
2671 2671
     /**
@@ -2674,8 +2674,8 @@  discard block
 block discarded – undo
2674 2674
 	 * @since 1.0.19
2675 2675
 	 * @param  string $value var number.
2676 2676
 	 */
2677
-	public function set_customer_vat_number( $value ) {
2678
-		$this->set_vat_number( $value );
2677
+	public function set_customer_vat_number($value) {
2678
+		$this->set_vat_number($value);
2679 2679
     }
2680 2680
 
2681 2681
     /**
@@ -2684,8 +2684,8 @@  discard block
 block discarded – undo
2684 2684
 	 * @since 1.0.19
2685 2685
 	 * @param  string $value var rate.
2686 2686
 	 */
2687
-	public function set_vat_rate( $value ) {
2688
-		$this->set_prop( 'vat_rate', $value );
2687
+	public function set_vat_rate($value) {
2688
+		$this->set_prop('vat_rate', $value);
2689 2689
     }
2690 2690
 
2691 2691
     /**
@@ -2694,8 +2694,8 @@  discard block
 block discarded – undo
2694 2694
 	 * @since 1.0.19
2695 2695
 	 * @param  string $value var number.
2696 2696
 	 */
2697
-	public function set_user_vat_rate( $value ) {
2698
-		$this->set_vat_rate( $value );
2697
+	public function set_user_vat_rate($value) {
2698
+		$this->set_vat_rate($value);
2699 2699
     }
2700 2700
 
2701 2701
     /**
@@ -2704,8 +2704,8 @@  discard block
 block discarded – undo
2704 2704
 	 * @since 1.0.19
2705 2705
 	 * @param  string $value var number.
2706 2706
 	 */
2707
-	public function set_customer_vat_rate( $value ) {
2708
-		$this->set_vat_rate( $value );
2707
+	public function set_customer_vat_rate($value) {
2708
+		$this->set_vat_rate($value);
2709 2709
     }
2710 2710
 
2711 2711
     /**
@@ -2714,8 +2714,8 @@  discard block
 block discarded – undo
2714 2714
 	 * @since 1.0.19
2715 2715
 	 * @param  string $value address.
2716 2716
 	 */
2717
-	public function set_address( $value ) {
2718
-		$this->set_prop( 'address', $value );
2717
+	public function set_address($value) {
2718
+		$this->set_prop('address', $value);
2719 2719
     }
2720 2720
 
2721 2721
     /**
@@ -2724,8 +2724,8 @@  discard block
 block discarded – undo
2724 2724
 	 * @since 1.0.19
2725 2725
 	 * @param  string $value address.
2726 2726
 	 */
2727
-	public function set_user_address( $value ) {
2728
-		$this->set_address( $value );
2727
+	public function set_user_address($value) {
2728
+		$this->set_address($value);
2729 2729
     }
2730 2730
 
2731 2731
     /**
@@ -2734,8 +2734,8 @@  discard block
 block discarded – undo
2734 2734
 	 * @since 1.0.19
2735 2735
 	 * @param  string $value address.
2736 2736
 	 */
2737
-	public function set_customer_address( $value ) {
2738
-		$this->set_address( $value );
2737
+	public function set_customer_address($value) {
2738
+		$this->set_address($value);
2739 2739
     }
2740 2740
 
2741 2741
     /**
@@ -2744,8 +2744,8 @@  discard block
 block discarded – undo
2744 2744
 	 * @since 1.0.19
2745 2745
 	 * @param  int|bool $value confirmed.
2746 2746
 	 */
2747
-	public function set_is_viewed( $value ) {
2748
-		$this->set_prop( 'is_viewed', $value );
2747
+	public function set_is_viewed($value) {
2748
+		$this->set_prop('is_viewed', $value);
2749 2749
 	}
2750 2750
 
2751 2751
 	/**
@@ -2754,8 +2754,8 @@  discard block
 block discarded – undo
2754 2754
 	 * @since 1.0.19
2755 2755
 	 * @param  string $value email recipients.
2756 2756
 	 */
2757
-	public function set_email_cc( $value ) {
2758
-		$this->set_prop( 'email_cc', $value );
2757
+	public function set_email_cc($value) {
2758
+		$this->set_prop('email_cc', $value);
2759 2759
 	}
2760 2760
 
2761 2761
 	/**
@@ -2764,9 +2764,9 @@  discard block
 block discarded – undo
2764 2764
 	 * @since 1.0.19
2765 2765
 	 * @param  string $value template.
2766 2766
 	 */
2767
-	public function set_template( $value ) {
2768
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2769
-			$this->set_prop( 'template', $value );
2767
+	public function set_template($value) {
2768
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2769
+			$this->set_prop('template', $value);
2770 2770
 		}
2771 2771
 	}
2772 2772
 
@@ -2777,8 +2777,8 @@  discard block
 block discarded – undo
2777 2777
 	 * @param  string $value source.
2778 2778
 	 * @deprecated
2779 2779
 	 */
2780
-	public function created_via( $value ) {
2781
-		$this->set_created_via( sanitize_text_field( $value ) );
2780
+	public function created_via($value) {
2781
+		$this->set_created_via(sanitize_text_field($value));
2782 2782
 	}
2783 2783
 
2784 2784
 	/**
@@ -2787,8 +2787,8 @@  discard block
 block discarded – undo
2787 2787
 	 * @since 1.0.19
2788 2788
 	 * @param  string $value source.
2789 2789
 	 */
2790
-	public function set_created_via( $value ) {
2791
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2790
+	public function set_created_via($value) {
2791
+		$this->set_prop('created_via', sanitize_text_field($value));
2792 2792
 	}
2793 2793
 
2794 2794
 	/**
@@ -2797,8 +2797,8 @@  discard block
 block discarded – undo
2797 2797
 	 * @since 1.0.19
2798 2798
 	 * @param  int|bool $value confirmed.
2799 2799
 	 */
2800
-	public function set_address_confirmed( $value ) {
2801
-		$this->set_prop( 'address_confirmed', $value );
2800
+	public function set_address_confirmed($value) {
2801
+		$this->set_prop('address_confirmed', $value);
2802 2802
     }
2803 2803
 
2804 2804
     /**
@@ -2807,8 +2807,8 @@  discard block
 block discarded – undo
2807 2807
 	 * @since 1.0.19
2808 2808
 	 * @param  int|bool $value confirmed.
2809 2809
 	 */
2810
-	public function set_user_address_confirmed( $value ) {
2811
-		$this->set_address_confirmed( $value );
2810
+	public function set_user_address_confirmed($value) {
2811
+		$this->set_address_confirmed($value);
2812 2812
     }
2813 2813
 
2814 2814
     /**
@@ -2817,8 +2817,8 @@  discard block
 block discarded – undo
2817 2817
 	 * @since 1.0.19
2818 2818
 	 * @param  int|bool $value confirmed.
2819 2819
 	 */
2820
-	public function set_customer_address_confirmed( $value ) {
2821
-		$this->set_address_confirmed( $value );
2820
+	public function set_customer_address_confirmed($value) {
2821
+		$this->set_address_confirmed($value);
2822 2822
     }
2823 2823
 
2824 2824
     /**
@@ -2827,13 +2827,13 @@  discard block
 block discarded – undo
2827 2827
 	 * @since 1.0.19
2828 2828
 	 * @param  float $value shipping amount.
2829 2829
 	 */
2830
-	public function set_shipping( $value ) {
2830
+	public function set_shipping($value) {
2831 2831
 
2832
-		if ( ! is_numeric( $value ) ) {
2833
-			return $this->set_prop( 'shipping', null );
2832
+		if (!is_numeric($value)) {
2833
+			return $this->set_prop('shipping', null);
2834 2834
 		}
2835 2835
 
2836
-		$this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2836
+		$this->set_prop('shipping', max(0, floatval($value)));
2837 2837
 	}
2838 2838
 
2839 2839
 	/**
@@ -2842,8 +2842,8 @@  discard block
 block discarded – undo
2842 2842
 	 * @since 1.0.19
2843 2843
 	 * @param  float $value sub total.
2844 2844
 	 */
2845
-	public function set_subtotal( $value ) {
2846
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2845
+	public function set_subtotal($value) {
2846
+		$this->set_prop('subtotal', max(0, $value));
2847 2847
 	}
2848 2848
 
2849 2849
 	/**
@@ -2852,8 +2852,8 @@  discard block
 block discarded – undo
2852 2852
 	 * @since 1.0.19
2853 2853
 	 * @param  float $value sub total.
2854 2854
 	 */
2855
-	public function set_total( $value ) {
2856
-		$this->set_prop( 'total', max( 0, $value ) );
2855
+	public function set_total($value) {
2856
+		$this->set_prop('total', max(0, $value));
2857 2857
     }
2858 2858
 
2859 2859
     /**
@@ -2862,8 +2862,8 @@  discard block
 block discarded – undo
2862 2862
 	 * @since 1.0.19
2863 2863
 	 * @param  float $value discount total.
2864 2864
 	 */
2865
-	public function set_total_discount( $value ) {
2866
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2865
+	public function set_total_discount($value) {
2866
+		$this->set_prop('total_discount', max(0, $value));
2867 2867
     }
2868 2868
 
2869 2869
     /**
@@ -2872,8 +2872,8 @@  discard block
 block discarded – undo
2872 2872
 	 * @since 1.0.19
2873 2873
 	 * @param  float $value discount total.
2874 2874
 	 */
2875
-	public function set_discount( $value ) {
2876
-		$this->set_total_discount( $value );
2875
+	public function set_discount($value) {
2876
+		$this->set_total_discount($value);
2877 2877
     }
2878 2878
 
2879 2879
     /**
@@ -2882,8 +2882,8 @@  discard block
 block discarded – undo
2882 2882
 	 * @since 1.0.19
2883 2883
 	 * @param  float $value tax total.
2884 2884
 	 */
2885
-	public function set_total_tax( $value ) {
2886
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2885
+	public function set_total_tax($value) {
2886
+		$this->set_prop('total_tax', max(0, $value));
2887 2887
     }
2888 2888
 
2889 2889
     /**
@@ -2892,8 +2892,8 @@  discard block
 block discarded – undo
2892 2892
 	 * @since 1.0.19
2893 2893
 	 * @param  float $value tax total.
2894 2894
 	 */
2895
-	public function set_tax_total( $value ) {
2896
-		$this->set_total_tax( $value );
2895
+	public function set_tax_total($value) {
2896
+		$this->set_total_tax($value);
2897 2897
     }
2898 2898
 
2899 2899
     /**
@@ -2902,8 +2902,8 @@  discard block
 block discarded – undo
2902 2902
 	 * @since 1.0.19
2903 2903
 	 * @param  float $value fees total.
2904 2904
 	 */
2905
-	public function set_total_fees( $value ) {
2906
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2905
+	public function set_total_fees($value) {
2906
+		$this->set_prop('total_fees', max(0, $value));
2907 2907
     }
2908 2908
 
2909 2909
     /**
@@ -2912,8 +2912,8 @@  discard block
 block discarded – undo
2912 2912
 	 * @since 1.0.19
2913 2913
 	 * @param  float $value fees total.
2914 2914
 	 */
2915
-	public function set_fees_total( $value ) {
2916
-		$this->set_total_fees( $value );
2915
+	public function set_fees_total($value) {
2916
+		$this->set_total_fees($value);
2917 2917
     }
2918 2918
 
2919 2919
     /**
@@ -2922,13 +2922,13 @@  discard block
 block discarded – undo
2922 2922
 	 * @since 1.0.19
2923 2923
 	 * @param  array $value fees.
2924 2924
 	 */
2925
-	public function set_fees( $value ) {
2925
+	public function set_fees($value) {
2926 2926
 
2927
-		if ( ! is_array( $value ) ) {
2927
+		if (!is_array($value)) {
2928 2928
 			$value = array();
2929 2929
 		}
2930 2930
 
2931
-		$this->set_prop( 'fees', $value );
2931
+		$this->set_prop('fees', $value);
2932 2932
 
2933 2933
     }
2934 2934
 
@@ -2938,13 +2938,13 @@  discard block
 block discarded – undo
2938 2938
 	 * @since 1.0.19
2939 2939
 	 * @param  array $value taxes.
2940 2940
 	 */
2941
-	public function set_taxes( $value ) {
2941
+	public function set_taxes($value) {
2942 2942
 
2943
-		if ( ! is_array( $value ) ) {
2943
+		if (!is_array($value)) {
2944 2944
 			$value = array();
2945 2945
 		}
2946 2946
 
2947
-		$this->set_prop( 'taxes', $value );
2947
+		$this->set_prop('taxes', $value);
2948 2948
 
2949 2949
     }
2950 2950
 
@@ -2954,13 +2954,13 @@  discard block
 block discarded – undo
2954 2954
 	 * @since 1.0.19
2955 2955
 	 * @param  array $value discounts.
2956 2956
 	 */
2957
-	public function set_discounts( $value ) {
2957
+	public function set_discounts($value) {
2958 2958
 
2959
-		if ( ! is_array( $value ) ) {
2959
+		if (!is_array($value)) {
2960 2960
 			$value = array();
2961 2961
 		}
2962 2962
 
2963
-		$this->set_prop( 'discounts', $value );
2963
+		$this->set_prop('discounts', $value);
2964 2964
     }
2965 2965
 
2966 2966
     /**
@@ -2969,19 +2969,19 @@  discard block
 block discarded – undo
2969 2969
 	 * @since 1.0.19
2970 2970
 	 * @param  GetPaid_Form_Item[] $value items.
2971 2971
 	 */
2972
-	public function set_items( $value ) {
2972
+	public function set_items($value) {
2973 2973
 
2974 2974
         // Remove existing items.
2975
-        $this->set_prop( 'items', array() );
2975
+        $this->set_prop('items', array());
2976 2976
 		$this->recurring_item = null;
2977 2977
 
2978 2978
         // Ensure that we have an array.
2979
-        if ( ! is_array( $value ) ) {
2979
+        if (!is_array($value)) {
2980 2980
             return;
2981 2981
         }
2982 2982
 
2983
-        foreach ( $value as $item ) {
2984
-            $this->add_item( $item );
2983
+        foreach ($value as $item) {
2984
+            $this->add_item($item);
2985 2985
         }
2986 2986
 
2987 2987
     }
@@ -2992,8 +2992,8 @@  discard block
 block discarded – undo
2992 2992
 	 * @since 1.0.19
2993 2993
 	 * @param  int $value payment form.
2994 2994
 	 */
2995
-	public function set_payment_form( $value ) {
2996
-		$this->set_prop( 'payment_form', $value );
2995
+	public function set_payment_form($value) {
2996
+		$this->set_prop('payment_form', $value);
2997 2997
     }
2998 2998
 
2999 2999
     /**
@@ -3002,8 +3002,8 @@  discard block
 block discarded – undo
3002 3002
 	 * @since 1.0.19
3003 3003
 	 * @param  string $value submission id.
3004 3004
 	 */
3005
-	public function set_submission_id( $value ) {
3006
-		$this->set_prop( 'submission_id', $value );
3005
+	public function set_submission_id($value) {
3006
+		$this->set_prop('submission_id', $value);
3007 3007
     }
3008 3008
 
3009 3009
     /**
@@ -3012,8 +3012,8 @@  discard block
 block discarded – undo
3012 3012
 	 * @since 1.0.19
3013 3013
 	 * @param  string $value discount code.
3014 3014
 	 */
3015
-	public function set_discount_code( $value ) {
3016
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3015
+	public function set_discount_code($value) {
3016
+		$this->set_prop('discount_code', sanitize_text_field($value));
3017 3017
     }
3018 3018
 
3019 3019
     /**
@@ -3022,8 +3022,8 @@  discard block
 block discarded – undo
3022 3022
 	 * @since 1.0.19
3023 3023
 	 * @param  string $value gateway.
3024 3024
 	 */
3025
-	public function set_gateway( $value ) {
3026
-		$this->set_prop( 'gateway', $value );
3025
+	public function set_gateway($value) {
3026
+		$this->set_prop('gateway', $value);
3027 3027
     }
3028 3028
 
3029 3029
     /**
@@ -3032,9 +3032,9 @@  discard block
 block discarded – undo
3032 3032
 	 * @since 1.0.19
3033 3033
 	 * @param  string $value transaction id.
3034 3034
 	 */
3035
-	public function set_transaction_id( $value ) {
3036
-		if ( ! empty( $value ) ) {
3037
-			$this->set_prop( 'transaction_id', $value );
3035
+	public function set_transaction_id($value) {
3036
+		if (!empty($value)) {
3037
+			$this->set_prop('transaction_id', $value);
3038 3038
 		}
3039 3039
     }
3040 3040
 
@@ -3044,8 +3044,8 @@  discard block
 block discarded – undo
3044 3044
 	 * @since 1.0.19
3045 3045
 	 * @param  string $value currency id.
3046 3046
 	 */
3047
-	public function set_currency( $value ) {
3048
-		$this->set_prop( 'currency', $value );
3047
+	public function set_currency($value) {
3048
+		$this->set_prop('currency', $value);
3049 3049
     }
3050 3050
 
3051 3051
 	/**
@@ -3054,8 +3054,8 @@  discard block
 block discarded – undo
3054 3054
 	 * @since 1.0.19
3055 3055
 	 * @param  bool $value value.
3056 3056
 	 */
3057
-	public function set_disable_taxes( $value ) {
3058
-		$this->set_prop( 'disable_taxes', (bool) $value );
3057
+	public function set_disable_taxes($value) {
3058
+		$this->set_prop('disable_taxes', (bool) $value);
3059 3059
 	}
3060 3060
 
3061 3061
     /**
@@ -3064,8 +3064,8 @@  discard block
 block discarded – undo
3064 3064
 	 * @since 1.0.19
3065 3065
 	 * @param  string $value subscription id.
3066 3066
 	 */
3067
-	public function set_subscription_id( $value ) {
3068
-		$this->set_prop( 'subscription_id', $value );
3067
+	public function set_subscription_id($value) {
3068
+		$this->set_prop('subscription_id', $value);
3069 3069
 	}
3070 3070
 	
3071 3071
 	/**
@@ -3074,8 +3074,8 @@  discard block
 block discarded – undo
3074 3074
 	 * @since 1.0.19
3075 3075
 	 * @param  string $value subscription id.
3076 3076
 	 */
3077
-	public function set_remote_subscription_id( $value ) {
3078
-		$this->set_prop( 'remote_subscription_id', $value );
3077
+	public function set_remote_subscription_id($value) {
3078
+		$this->set_prop('remote_subscription_id', $value);
3079 3079
     }
3080 3080
 
3081 3081
     /*
@@ -3092,28 +3092,28 @@  discard block
 block discarded – undo
3092 3092
      */
3093 3093
     public function is_parent() {
3094 3094
         $parent = $this->get_parent_id();
3095
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
3095
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
3096 3096
     }
3097 3097
 
3098 3098
     /**
3099 3099
      * Checks if this is a renewal invoice.
3100 3100
      */
3101 3101
     public function is_renewal() {
3102
-        return $this->is_recurring() && ! $this->is_parent();
3102
+        return $this->is_recurring() && !$this->is_parent();
3103 3103
     }
3104 3104
 
3105 3105
     /**
3106 3106
      * Checks if this is a recurring invoice.
3107 3107
      */
3108 3108
     public function is_recurring() {
3109
-        return ! empty( $this->recurring_item );
3109
+        return !empty($this->recurring_item);
3110 3110
     }
3111 3111
 
3112 3112
     /**
3113 3113
      * Checks if this is a taxable invoice.
3114 3114
      */
3115 3115
     public function is_taxable() {
3116
-        return ! $this->get_disable_taxes();
3116
+        return !$this->get_disable_taxes();
3117 3117
 	}
3118 3118
 
3119 3119
 	/**
@@ -3127,45 +3127,45 @@  discard block
 block discarded – undo
3127 3127
 	 * Checks to see if the invoice requires payment.
3128 3128
 	 */
3129 3129
 	public function is_free() {
3130
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3130
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
3131 3131
 
3132
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3132
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
3133 3133
 			$is_free = false;
3134 3134
 		}
3135 3135
 
3136
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3136
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
3137 3137
     }
3138 3138
 
3139 3139
     /**
3140 3140
      * Checks if the invoice is paid.
3141 3141
      */
3142 3142
     public function is_paid() {
3143
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3144
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3143
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
3144
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
3145 3145
 	}
3146 3146
 
3147 3147
 	/**
3148 3148
      * Checks if the invoice needs payment.
3149 3149
      */
3150 3150
 	public function needs_payment() {
3151
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3152
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3151
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
3152
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
3153 3153
     }
3154 3154
   
3155 3155
 	/**
3156 3156
      * Checks if the invoice is refunded.
3157 3157
      */
3158 3158
 	public function is_refunded() {
3159
-        $is_refunded = $this->has_status( 'wpi-refunded' );
3160
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3159
+        $is_refunded = $this->has_status('wpi-refunded');
3160
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
3161 3161
 	}
3162 3162
 
3163 3163
 	/**
3164 3164
      * Checks if the invoice is held.
3165 3165
      */
3166 3166
 	public function is_held() {
3167
-        $is_held = $this->has_status( 'wpi-onhold' );
3168
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3167
+        $is_held = $this->has_status('wpi-onhold');
3168
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
3169 3169
 	}
3170 3170
 
3171 3171
 	/**
@@ -3173,30 +3173,30 @@  discard block
 block discarded – undo
3173 3173
      */
3174 3174
 	public function is_due() {
3175 3175
 		$due_date = $this->get_due_date();
3176
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3176
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3177 3177
 	}
3178 3178
 
3179 3179
 	/**
3180 3180
      * Checks if the invoice is draft.
3181 3181
      */
3182 3182
 	public function is_draft() {
3183
-        return $this->has_status( 'draft, auto-draft' );
3183
+        return $this->has_status('draft, auto-draft');
3184 3184
 	}
3185 3185
 
3186 3186
     /**
3187 3187
      * Checks if the invoice has a given status.
3188 3188
      */
3189
-    public function has_status( $status ) {
3190
-        $status = wpinv_parse_list( $status );
3191
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3189
+    public function has_status($status) {
3190
+        $status = wpinv_parse_list($status);
3191
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3192 3192
 	}
3193 3193
 
3194 3194
 	/**
3195 3195
      * Checks if the invoice is of a given type.
3196 3196
      */
3197
-    public function is_type( $type ) {
3198
-        $type = wpinv_parse_list( $type );
3199
-        return in_array( $this->get_type(), $type );
3197
+    public function is_type($type) {
3198
+        $type = wpinv_parse_list($type);
3199
+        return in_array($this->get_type(), $type);
3200 3200
     }
3201 3201
 
3202 3202
     /**
@@ -3228,8 +3228,8 @@  discard block
 block discarded – undo
3228 3228
      *
3229 3229
      */
3230 3230
 	public function is_initial_free() {
3231
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3232
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3231
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3232
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3233 3233
     }
3234 3234
 	
3235 3235
 	/**
@@ -3239,11 +3239,11 @@  discard block
 block discarded – undo
3239 3239
     public function item_has_free_trial() {
3240 3240
 
3241 3241
         // Ensure we have a recurring item.
3242
-        if ( ! $this->is_recurring() ) {
3242
+        if (!$this->is_recurring()) {
3243 3243
             return false;
3244 3244
         }
3245 3245
 
3246
-        $item = $this->get_recurring( true );
3246
+        $item = $this->get_recurring(true);
3247 3247
         return $item->has_free_trial();
3248 3248
 	}
3249 3249
 
@@ -3251,7 +3251,7 @@  discard block
 block discarded – undo
3251 3251
      * Check if the free trial is a result of a discount.
3252 3252
      */
3253 3253
     public function is_free_trial_from_discount() {
3254
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3254
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3255 3255
 	}
3256 3256
 	
3257 3257
 	/**
@@ -3259,12 +3259,12 @@  discard block
 block discarded – undo
3259 3259
      */
3260 3260
     public function discount_first_payment_only() {
3261 3261
 
3262
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3263
-        if ( ! $discount->exists() || ! $this->is_recurring() ) {
3262
+		$discount = wpinv_get_discount_obj($this->get_discount_code());
3263
+        if (!$discount->exists() || !$this->is_recurring()) {
3264 3264
             return true;
3265 3265
         }
3266 3266
 
3267
-        return ! $discount->get_is_recurring();
3267
+        return !$discount->get_is_recurring();
3268 3268
     }
3269 3269
 
3270 3270
     /*
@@ -3282,23 +3282,23 @@  discard block
 block discarded – undo
3282 3282
      * @param GetPaid_Form_Item|array $item
3283 3283
      * @return WP_Error|Bool
3284 3284
      */
3285
-    public function add_item( $item ) {
3285
+    public function add_item($item) {
3286 3286
 
3287
-		if ( is_array( $item ) ) {
3288
-			$item = $this->process_array_item( $item );
3287
+		if (is_array($item)) {
3288
+			$item = $this->process_array_item($item);
3289 3289
 		}
3290 3290
 
3291
-		if ( is_numeric( $item ) ) {
3292
-			$item = new GetPaid_Form_Item( $item );
3291
+		if (is_numeric($item)) {
3292
+			$item = new GetPaid_Form_Item($item);
3293 3293
 		}
3294 3294
 
3295 3295
         // Make sure that it is available for purchase.
3296
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3297
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3296
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3297
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3298 3298
         }
3299 3299
 
3300 3300
         // Do we have a recurring item?
3301
-		if ( $item->is_recurring() ) {
3301
+		if ($item->is_recurring()) {
3302 3302
 			$this->recurring_item = $item->get_id();
3303 3303
         }
3304 3304
 
@@ -3306,9 +3306,9 @@  discard block
 block discarded – undo
3306 3306
         $item->invoice_id = (int) $this->get_id();
3307 3307
 
3308 3308
 		// Remove duplicates.
3309
-		$this->remove_item( $item->get_id() );
3309
+		$this->remove_item($item->get_id());
3310 3310
 
3311
-		if ( 0 == $item->get_quantity() ) {
3311
+		if (0 == $item->get_quantity()) {
3312 3312
 			return;
3313 3313
 		}
3314 3314
 
@@ -3318,7 +3318,7 @@  discard block
 block discarded – undo
3318 3318
 		// Add new item.
3319 3319
         $items[] = $item;
3320 3320
 
3321
-        $this->set_prop( 'items', $items );
3321
+        $this->set_prop('items', $items);
3322 3322
 
3323 3323
 		return true;
3324 3324
 	}
@@ -3329,26 +3329,26 @@  discard block
 block discarded – undo
3329 3329
 	 * @since 1.0.19
3330 3330
 	 * @return GetPaid_Form_Item
3331 3331
 	 */
3332
-	protected function process_array_item( $array ) {
3332
+	protected function process_array_item($array) {
3333 3333
 
3334
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3335
-		$item    = new GetPaid_Form_Item( $item_id );
3334
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3335
+		$item    = new GetPaid_Form_Item($item_id);
3336 3336
 
3337 3337
 		// Set item data.
3338
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3339
-			if ( isset( $array[ "item_$key" ] ) ) {
3338
+		foreach (array('name', 'price', 'description') as $key) {
3339
+			if (isset($array["item_$key"])) {
3340 3340
 				$method = "set_$key";
3341
-				$item->$method( $array[ "item_$key" ] );
3341
+				$item->$method($array["item_$key"]);
3342 3342
 			}
3343 3343
 		}
3344 3344
 
3345
-		if ( isset( $array['quantity'] ) ) {
3346
-			$item->set_quantity( $array['quantity'] );
3345
+		if (isset($array['quantity'])) {
3346
+			$item->set_quantity($array['quantity']);
3347 3347
 		}
3348 3348
 
3349 3349
 		// Set item meta.
3350
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3351
-			$item->set_item_meta( $array['meta'] );
3350
+		if (isset($array['meta']) && is_array($array['meta'])) {
3351
+			$item->set_item_meta($array['meta']);
3352 3352
 		}
3353 3353
 
3354 3354
 		return $item;
@@ -3361,10 +3361,10 @@  discard block
 block discarded – undo
3361 3361
 	 * @since 1.0.19
3362 3362
 	 * @return GetPaid_Form_Item|null
3363 3363
 	 */
3364
-	public function get_item( $item_id ) {
3364
+	public function get_item($item_id) {
3365 3365
 
3366
-		foreach ( $this->get_items() as $item ) {
3367
-			if ( (int) $item_id == $item->get_id() ) {
3366
+		foreach ($this->get_items() as $item) {
3367
+			if ((int) $item_id == $item->get_id()) {
3368 3368
 				return $item;
3369 3369
 			}
3370 3370
 		}
@@ -3377,16 +3377,16 @@  discard block
 block discarded – undo
3377 3377
 	 *
3378 3378
 	 * @since 1.0.19
3379 3379
 	 */
3380
-	public function remove_item( $item_id ) {
3380
+	public function remove_item($item_id) {
3381 3381
 		$items   = $this->get_items();
3382 3382
 		$item_id = (int) $item_id;
3383 3383
 
3384
-		foreach ( $items as $index => $item ) {
3385
-			if ( (int) $item_id == $item->get_id() ) {
3386
-				unset( $items[ $index ] );
3387
-				$this->set_prop( 'items', $items );
3384
+		foreach ($items as $index => $item) {
3385
+			if ((int) $item_id == $item->get_id()) {
3386
+				unset($items[$index]);
3387
+				$this->set_prop('items', $items);
3388 3388
 
3389
-				if ( $item_id == $this->recurring_item ) {
3389
+				if ($item_id == $this->recurring_item) {
3390 3390
 					$this->recurring_item = null;
3391 3391
 				}
3392 3392
 
@@ -3401,11 +3401,11 @@  discard block
 block discarded – undo
3401 3401
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3402 3402
 	 * @since 1.0.19
3403 3403
 	 */
3404
-    public function add_fee( $fee ) {
3404
+    public function add_fee($fee) {
3405 3405
 
3406 3406
 		$fees                 = $this->get_fees();
3407
-		$fees[ $fee['name'] ] = $fee;
3408
-		$this->set_prop( 'fees', $fees );
3407
+		$fees[$fee['name']] = $fee;
3408
+		$this->set_prop('fees', $fees);
3409 3409
 
3410 3410
     }
3411 3411
 
@@ -3414,9 +3414,9 @@  discard block
 block discarded – undo
3414 3414
 	 *
3415 3415
 	 * @since 1.0.19
3416 3416
 	 */
3417
-	public function get_fee( $fee ) {
3417
+	public function get_fee($fee) {
3418 3418
         $fees = $this->get_fees();
3419
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3419
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3420 3420
     }
3421 3421
 
3422 3422
     /**
@@ -3424,11 +3424,11 @@  discard block
 block discarded – undo
3424 3424
 	 *
3425 3425
 	 * @since 1.0.19
3426 3426
 	 */
3427
-	public function remove_fee( $fee ) {
3427
+	public function remove_fee($fee) {
3428 3428
         $fees = $this->get_fees();
3429
-        if ( isset( $fees[ $fee ] ) ) {
3430
-            unset( $fees[ $fee ] );
3431
-            $this->set_prop( 'fees', $fees );
3429
+        if (isset($fees[$fee])) {
3430
+            unset($fees[$fee]);
3431
+            $this->set_prop('fees', $fees);
3432 3432
         }
3433 3433
     }
3434 3434
 
@@ -3438,11 +3438,11 @@  discard block
 block discarded – undo
3438 3438
 	 * @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.
3439 3439
 	 * @since 1.0.19
3440 3440
 	 */
3441
-	public function add_discount( $discount ) {
3441
+	public function add_discount($discount) {
3442 3442
 
3443 3443
 		$discounts = $this->get_discounts();
3444
-		$discounts[ $discount['name'] ] = $discount;
3445
-		$this->set_prop( 'discounts', $discounts );
3444
+		$discounts[$discount['name']] = $discount;
3445
+		$this->set_prop('discounts', $discounts);
3446 3446
 
3447 3447
 	}
3448 3448
 
@@ -3452,15 +3452,15 @@  discard block
 block discarded – undo
3452 3452
 	 * @since 1.0.19
3453 3453
 	 * @return float
3454 3454
 	 */
3455
-	public function get_discount( $discount = false ) {
3455
+	public function get_discount($discount = false) {
3456 3456
 
3457 3457
 		// Backwards compatibilty.
3458
-		if ( empty( $discount ) ) {
3458
+		if (empty($discount)) {
3459 3459
 			return $this->get_total_discount();
3460 3460
 		}
3461 3461
 
3462 3462
         $discounts = $this->get_discounts();
3463
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3463
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3464 3464
     }
3465 3465
 
3466 3466
     /**
@@ -3468,15 +3468,15 @@  discard block
 block discarded – undo
3468 3468
 	 *
3469 3469
 	 * @since 1.0.19
3470 3470
 	 */
3471
-	public function remove_discount( $discount ) {
3471
+	public function remove_discount($discount) {
3472 3472
         $discounts = $this->get_discounts();
3473
-        if ( isset( $discounts[ $discount ] ) ) {
3474
-            unset( $discounts[ $discount ] );
3475
-            $this->set_prop( 'discounts', $discounts );
3473
+        if (isset($discounts[$discount])) {
3474
+            unset($discounts[$discount]);
3475
+            $this->set_prop('discounts', $discounts);
3476 3476
         }
3477 3477
 
3478
-		if ( 'discount_code' == $discount ) {
3479
-			foreach ( $this->get_items() as $item ) {
3478
+		if ('discount_code' == $discount) {
3479
+			foreach ($this->get_items() as $item) {
3480 3480
 				$item->item_discount           = 0;
3481 3481
 				$item->recurring_item_discount = 0;
3482 3482
 			}
@@ -3489,12 +3489,12 @@  discard block
 block discarded – undo
3489 3489
      *
3490 3490
      * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
3491 3491
      */
3492
-    public function add_tax( $tax ) {
3493
-        if ( $this->is_taxable() ) {
3492
+    public function add_tax($tax) {
3493
+        if ($this->is_taxable()) {
3494 3494
 
3495
-            $taxes                 = $this->get_taxes();
3496
-			$taxes[ $tax['name'] ] = $tax;
3497
-			$this->set_prop( 'taxes', $tax );
3495
+            $taxes = $this->get_taxes();
3496
+			$taxes[$tax['name']] = $tax;
3497
+			$this->set_prop('taxes', $tax);
3498 3498
 
3499 3499
         }
3500 3500
     }
@@ -3504,15 +3504,15 @@  discard block
 block discarded – undo
3504 3504
 	 *
3505 3505
 	 * @since 1.0.19
3506 3506
 	 */
3507
-	public function get_tax( $tax = null ) {
3507
+	public function get_tax($tax = null) {
3508 3508
 
3509 3509
 		// Backwards compatility.
3510
-		if ( empty( $tax ) ) {
3510
+		if (empty($tax)) {
3511 3511
 			return $this->get_total_tax();
3512 3512
 		}
3513 3513
 
3514 3514
         $taxes = $this->get_taxes();
3515
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3515
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3516 3516
     }
3517 3517
 
3518 3518
     /**
@@ -3520,11 +3520,11 @@  discard block
 block discarded – undo
3520 3520
 	 *
3521 3521
 	 * @since 1.0.19
3522 3522
 	 */
3523
-	public function remove_tax( $tax ) {
3523
+	public function remove_tax($tax) {
3524 3524
         $taxes = $this->get_taxes();
3525
-        if ( isset( $taxes[ $tax ] ) ) {
3526
-            unset( $taxes[ $tax ] );
3527
-            $this->set_prop( 'taxes', $taxes );
3525
+        if (isset($taxes[$tax])) {
3526
+            unset($taxes[$tax]);
3527
+            $this->set_prop('taxes', $taxes);
3528 3528
         }
3529 3529
     }
3530 3530
 
@@ -3535,22 +3535,22 @@  discard block
 block discarded – undo
3535 3535
 	 * @return float The recalculated subtotal
3536 3536
 	 */
3537 3537
 	public function recalculate_subtotal() {
3538
-        $items     = $this->get_items();
3538
+        $items = $this->get_items();
3539 3539
 		$subtotal  = 0;
3540 3540
 		$recurring = 0;
3541 3541
 
3542
-        foreach ( $items as $item ) {
3543
-			$subtotal  += $item->get_sub_total( 'edit' );
3544
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3542
+        foreach ($items as $item) {
3543
+			$subtotal  += $item->get_sub_total('edit');
3544
+			$recurring += $item->get_recurring_sub_total('edit');
3545 3545
         }
3546 3546
 
3547
-		if ( wpinv_prices_include_tax() ) {
3548
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3549
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3547
+		if (wpinv_prices_include_tax()) {
3548
+			$subtotal  = max(0, $subtotal - $this->totals['tax']['initial']);
3549
+			$recurring = max(0, $recurring - $this->totals['tax']['recurring']);
3550 3550
 		}
3551 3551
 
3552 3552
 		$current = $this->is_renewal() ? $recurring : $subtotal;
3553
-		$this->set_subtotal( $current );
3553
+		$this->set_subtotal($current);
3554 3554
 
3555 3555
 		$this->totals['subtotal'] = array(
3556 3556
 			'initial'   => $subtotal,
@@ -3571,14 +3571,14 @@  discard block
 block discarded – undo
3571 3571
 		$discount  = 0;
3572 3572
 		$recurring = 0;
3573 3573
 
3574
-        foreach ( $discounts as $data ) {
3575
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3576
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3574
+        foreach ($discounts as $data) {
3575
+			$discount  += wpinv_sanitize_amount($data['initial_discount']);
3576
+			$recurring += wpinv_sanitize_amount($data['recurring_discount']);
3577 3577
 		}
3578 3578
 
3579 3579
 		$current = $this->is_renewal() ? $recurring : $discount;
3580 3580
 
3581
-		$this->set_total_discount( $current );
3581
+		$this->set_total_discount($current);
3582 3582
 
3583 3583
 		$this->totals['discount'] = array(
3584 3584
 			'initial'   => $discount,
@@ -3599,13 +3599,13 @@  discard block
 block discarded – undo
3599 3599
 
3600 3600
 		// Maybe disable taxes.
3601 3601
 		$vat_number = $this->get_vat_number();
3602
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3602
+		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($this->get_country()) && !empty($vat_number);
3603 3603
 
3604
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3604
+		if (wpinv_is_base_country($this->get_country()) && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) {
3605 3605
 			$skip_tax = false;
3606 3606
 		}
3607 3607
 
3608
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax   ) {
3608
+		if (!wpinv_use_taxes() || $this->get_disable_taxes() || !wpinv_is_country_taxable($this->get_country()) || $skip_tax) {
3609 3609
 
3610 3610
 			$this->totals['tax'] = array(
3611 3611
 				'initial'   => 0,
@@ -3614,38 +3614,38 @@  discard block
 block discarded – undo
3614 3614
 
3615 3615
 			$this->tax_rate = 0;
3616 3616
 
3617
-			$this->set_taxes( array() );
3617
+			$this->set_taxes(array());
3618 3618
 			$current = 0;
3619 3619
 		} else {
3620 3620
 
3621 3621
 			$item_taxes = array();
3622 3622
 
3623
-			foreach ( $this->get_items() as $item ) {
3624
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3625
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3626
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3627
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3628
-				foreach ( $taxes as $name => $amount ) {
3629
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3630
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3631
-
3632
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3633
-						$item_taxes[ $name ] = $tax;
3623
+			foreach ($this->get_items() as $item) {
3624
+				$rates    = getpaid_get_item_tax_rates($item, $this->get_country(), $this->get_state());
3625
+				$rates    = getpaid_filter_item_tax_rates($item, $rates);
3626
+				$taxes    = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates);
3627
+				$r_taxes  = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates);
3628
+				foreach ($taxes as $name => $amount) {
3629
+					$recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0;
3630
+					$tax       = getpaid_prepare_item_tax($item, $name, $amount, $recurring);
3631
+
3632
+					if (!isset($item_taxes[$name])) {
3633
+						$item_taxes[$name] = $tax;
3634 3634
 						continue;
3635 3635
 					}
3636 3636
 
3637
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3638
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3637
+					$item_taxes[$name]['initial_tax']   += $tax['initial_tax'];
3638
+					$item_taxes[$name]['recurring_tax'] += $tax['recurring_tax'];
3639 3639
 
3640 3640
 				}
3641 3641
 
3642 3642
 			}
3643 3643
 
3644
-			$item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3645
-			$this->set_taxes( $item_taxes );
3644
+			$item_taxes = array_replace($this->get_taxes(), $item_taxes);
3645
+			$this->set_taxes($item_taxes);
3646 3646
 
3647
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3648
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3647
+			$initial_tax   = array_sum(wp_list_pluck($item_taxes, 'initial_tax'));
3648
+			$recurring_tax = array_sum(wp_list_pluck($item_taxes, 'recurring_tax'));
3649 3649
 
3650 3650
 			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3651 3651
 
@@ -3656,7 +3656,7 @@  discard block
 block discarded – undo
3656 3656
 
3657 3657
 		}
3658 3658
 
3659
-		$this->set_total_tax( $current );
3659
+		$this->set_total_tax($current);
3660 3660
 
3661 3661
 		return $current;
3662 3662
 
@@ -3673,20 +3673,20 @@  discard block
 block discarded – undo
3673 3673
 		$fee       = 0;
3674 3674
 		$recurring = 0;
3675 3675
 
3676
-        foreach ( $fees as $data ) {
3677
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3678
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3676
+        foreach ($fees as $data) {
3677
+			$fee       += wpinv_sanitize_amount($data['initial_fee']);
3678
+			$recurring += wpinv_sanitize_amount($data['recurring_fee']);
3679 3679
 		}
3680 3680
 
3681 3681
 		$current = $this->is_renewal() ? $recurring : $fee;
3682
-		$this->set_total_fees( $current );
3682
+		$this->set_total_fees($current);
3683 3683
 
3684 3684
 		$this->totals['fee'] = array(
3685 3685
 			'initial'   => $fee,
3686 3686
 			'recurring' => $recurring,
3687 3687
 		);
3688 3688
 
3689
-        $this->set_total_fees( $fee );
3689
+        $this->set_total_fees($fee);
3690 3690
         return $current;
3691 3691
     }
3692 3692
 
@@ -3701,7 +3701,7 @@  discard block
 block discarded – undo
3701 3701
         $this->recalculate_total_discount();
3702 3702
 		$this->recalculate_total_tax();
3703 3703
 		$this->recalculate_subtotal();
3704
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3704
+		$this->set_total($this->get_total_tax('edit') + $this->get_total_fees('edit') + $this->get_subtotal('edit') - $this->get_total_discount('edit'));
3705 3705
 		return $this->get_total();
3706 3706
 	}
3707 3707
 
@@ -3710,7 +3710,7 @@  discard block
 block discarded – undo
3710 3710
 	 */
3711 3711
     public function recalculate_totals() {
3712 3712
         $this->recalculate_total();
3713
-        $this->save( true );
3713
+        $this->save(true);
3714 3714
         return $this;
3715 3715
     }
3716 3716
 
@@ -3728,8 +3728,8 @@  discard block
 block discarded – undo
3728 3728
 	 * @return int|false The new note's ID on success, false on failure.
3729 3729
      *
3730 3730
      */
3731
-    public function add_system_note( $note ) {
3732
-		return $this->add_note( $note, false, false, true );
3731
+    public function add_system_note($note) {
3732
+		return $this->add_note($note, false, false, true);
3733 3733
 	}
3734 3734
 
3735 3735
     /**
@@ -3739,10 +3739,10 @@  discard block
 block discarded – undo
3739 3739
 	 * @return int|false The new note's ID on success, false on failure.
3740 3740
      *
3741 3741
      */
3742
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3742
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3743 3743
 
3744 3744
         // Bail if no note specified or this invoice is not yet saved.
3745
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3745
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3746 3746
             return false;
3747 3747
         }
3748 3748
 
@@ -3750,23 +3750,23 @@  discard block
 block discarded – undo
3750 3750
 		$author_email = '[email protected]';
3751 3751
 
3752 3752
 		// If this is an admin comment or it has been added by the user.
3753
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3754
-			$user         = get_user_by( 'id', get_current_user_id() );
3753
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3754
+			$user = get_user_by('id', get_current_user_id());
3755 3755
             $author       = $user->display_name;
3756 3756
             $author_email = $user->user_email;
3757 3757
 		}
3758 3758
 
3759
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3759
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3760 3760
 
3761 3761
 	}
3762 3762
 
3763 3763
 	/**
3764 3764
      * Generates a unique key for the invoice.
3765 3765
      */
3766
-    public function generate_key( $string = '' ) {
3767
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3766
+    public function generate_key($string = '') {
3767
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3768 3768
         return strtolower(
3769
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3769
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3770 3770
         );
3771 3771
     }
3772 3772
 
@@ -3776,11 +3776,11 @@  discard block
 block discarded – undo
3776 3776
     public function generate_number() {
3777 3777
         $number = $this->get_id();
3778 3778
 
3779
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3780
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3779
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3780
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3781 3781
         }
3782 3782
 
3783
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3783
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3784 3784
 
3785 3785
 	}
3786 3786
 
@@ -3793,55 +3793,55 @@  discard block
 block discarded – undo
3793 3793
 		// Reset status transition variable.
3794 3794
 		$this->status_transition = false;
3795 3795
 
3796
-		if ( $status_transition ) {
3796
+		if ($status_transition) {
3797 3797
 			try {
3798 3798
 
3799 3799
 				// Fire a hook for the status change.
3800
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3800
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3801 3801
 
3802 3802
 				// @deprecated this is deprecated and will be removed in the future.
3803
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3803
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3804 3804
 
3805
-				if ( ! empty( $status_transition['from'] ) ) {
3805
+				if (!empty($status_transition['from'])) {
3806 3806
 
3807 3807
 					/* translators: 1: old invoice status 2: new invoice status */
3808
-					$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  ) );
3808
+					$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));
3809 3809
 
3810 3810
 					// Fire another hook.
3811
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3812
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3811
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3812
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3813 3813
 
3814 3814
 					// @deprecated this is deprecated and will be removed in the future.
3815
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3815
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3816 3816
 
3817 3817
 					// Note the transition occurred.
3818
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3818
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']);
3819 3819
 
3820 3820
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3821 3821
 					if (
3822
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3823
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3822
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3823
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3824 3824
 					) {
3825
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3825
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3826 3826
 					}
3827 3827
 
3828 3828
 					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3829 3829
 					if (
3830
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3831
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3830
+						in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3831
+						&& in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3832 3832
 					) {
3833
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3833
+						do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition);
3834 3834
 					}
3835 3835
 				} else {
3836 3836
 					/* translators: %s: new invoice status */
3837
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3837
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this));
3838 3838
 
3839 3839
 					// Note the transition occurred.
3840
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3840
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3841 3841
 
3842 3842
 				}
3843
-			} catch ( Exception $e ) {
3844
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3843
+			} catch (Exception $e) {
3844
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3845 3845
 			}
3846 3846
 		}
3847 3847
 	}
@@ -3849,13 +3849,13 @@  discard block
 block discarded – undo
3849 3849
 	/**
3850 3850
 	 * Updates an invoice status.
3851 3851
 	 */
3852
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3852
+	public function update_status($new_status = false, $note = '', $manual = false) {
3853 3853
 
3854 3854
 		// Fires before updating a status.
3855
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3855
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3856 3856
 
3857 3857
 		// Update the status.
3858
-		$this->set_status( $new_status, $note, $manual );
3858
+		$this->set_status($new_status, $note, $manual);
3859 3859
 
3860 3860
 		// Save the order.
3861 3861
 		return $this->save();
@@ -3866,18 +3866,18 @@  discard block
 block discarded – undo
3866 3866
 	 * @deprecated
3867 3867
 	 */
3868 3868
 	public function refresh_item_ids() {
3869
-        $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
3870
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3869
+        $item_ids = implode(',', array_unique(wp_list_pluck($this->get_cart_details(), 'item_id')));
3870
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3871 3871
 	}
3872 3872
 
3873 3873
 	/**
3874 3874
 	 * @deprecated
3875 3875
 	 */
3876
-	public function update_items( $temp = false ) {
3876
+	public function update_items($temp = false) {
3877 3877
 
3878
-		$this->set_items( $this->get_items() );
3878
+		$this->set_items($this->get_items());
3879 3879
 
3880
-		if ( ! $temp ) {
3880
+		if (!$temp) {
3881 3881
 			$this->save();
3882 3882
 		}
3883 3883
 
@@ -3891,11 +3891,11 @@  discard block
 block discarded – undo
3891 3891
 
3892 3892
         $discount_code = $this->get_discount_code();
3893 3893
 
3894
-        if ( empty( $discount_code ) ) {
3894
+        if (empty($discount_code)) {
3895 3895
             return false;
3896 3896
         }
3897 3897
 
3898
-        $discount = wpinv_get_discount_obj( $discount_code );
3898
+        $discount = wpinv_get_discount_obj($discount_code);
3899 3899
 
3900 3900
         // Ensure it is active.
3901 3901
         return $discount->exists();
@@ -3906,7 +3906,7 @@  discard block
 block discarded – undo
3906 3906
 	 * Refunds an invoice.
3907 3907
 	 */
3908 3908
     public function refund() {
3909
-		$this->set_status( 'wpi-refunded' );
3909
+		$this->set_status('wpi-refunded');
3910 3910
         $this->save();
3911 3911
 	}
3912 3912
 
@@ -3915,53 +3915,53 @@  discard block
 block discarded – undo
3915 3915
 	 * 
3916 3916
 	 * @param string $transaction_id
3917 3917
 	 */
3918
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3918
+    public function mark_paid($transaction_id = null, $note = '') {
3919 3919
 
3920 3920
 		// Set the transaction id.
3921
-		if ( empty( $transaction_id ) ) {
3921
+		if (empty($transaction_id)) {
3922 3922
 			$transaction_id = $this->generate_key('trans_');
3923 3923
 		}
3924 3924
 
3925
-		if ( ! $this->get_transaction_id() ) {
3926
-			$this->set_transaction_id( $transaction_id );
3925
+		if (!$this->get_transaction_id()) {
3926
+			$this->set_transaction_id($transaction_id);
3927 3927
 		}
3928 3928
 
3929
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3929
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3930 3930
 			return $this->save();
3931 3931
 		}
3932 3932
 
3933 3933
 		// Set the completed date.
3934
-		$this->set_date_completed( current_time( 'mysql' ) );
3934
+		$this->set_date_completed(current_time('mysql'));
3935 3935
 
3936 3936
 		// Set the new status.
3937
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
3938
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
3937
+		$gateway = sanitize_text_field($this->get_gateway_title());
3938
+		if ($this->is_renewal() || !$this->is_parent()) {
3939 3939
 
3940
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3941
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3940
+			$_note = wp_sprintf(__('Renewed via %s', 'invoicing'), $gateway);
3941
+			$_note = $_note . empty($note) ? '' : " ($note)";
3942 3942
 
3943
-			if ( 'none' == $this->get_gateway() ) {
3943
+			if ('none' == $this->get_gateway()) {
3944 3944
 				$_note = $note;
3945 3945
 			}
3946 3946
 
3947
-			$this->set_status( 'wpi-renewal', $_note );
3947
+			$this->set_status('wpi-renewal', $_note);
3948 3948
 
3949 3949
 		} else {
3950 3950
 
3951
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3952
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3951
+			$_note = wp_sprintf(__('Paid via %s', 'invoicing'), $gateway);
3952
+			$_note = $_note . empty($note) ? '' : " ($note)";
3953 3953
 
3954
-			if ( 'none' == $this->get_gateway() ) {
3954
+			if ('none' == $this->get_gateway()) {
3955 3955
 				$_note = $note;
3956 3956
 			}
3957 3957
 
3958
-			$this->set_status( 'publish', $_note );
3958
+			$this->set_status('publish', $_note);
3959 3959
 
3960 3960
 		}
3961 3961
 
3962 3962
 		// Set checkout mode.
3963
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3964
-		$this->set_mode( $mode );
3963
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3964
+		$this->set_mode($mode);
3965 3965
 
3966 3966
 		// Save the invoice.
3967 3967
         $this->save();
@@ -3986,9 +3986,9 @@  discard block
 block discarded – undo
3986 3986
      * Clears the subscription's cache.
3987 3987
      */
3988 3988
     public function clear_cache() {
3989
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3990
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3991
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3989
+		wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
3990
+		wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
3991
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
3992 3992
 	}
3993 3993
 
3994 3994
 }
Please login to merge, or discard this patch.