Passed
Push — master ( ba7ab2...125258 )
by Brian
12:29 queued 06:30
created
includes/payments/class-getpaid-checkout.php 2 patches
Indentation   +301 added lines, -301 removed lines patch added patch discarded remove patch
@@ -12,184 +12,184 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Checkout {
14 14
 
15
-	/**
16
-	 * @var GetPaid_Payment_Form_Submission
17
-	 */
18
-	protected $payment_form_submission;
19
-
20
-	/**
21
-	 * Class constructor.
22
-	 * 
23
-	 * @param GetPaid_Payment_Form_Submission $submission
24
-	 */
25
-	public function __construct( $submission ) {
26
-		$this->payment_form_submission = $submission;
27
-	}
28
-
29
-	/**
30
-	 * Processes the checkout.
31
-	 *
32
-	 */
33
-	public function process_checkout() {
34
-
35
-		// Validate the submission.
36
-		$this->validate_submission();
37
-
38
-		// Prepare the invoice.
39
-		$items      = $this->get_submission_items();
40
-		$invoice    = $this->get_submission_invoice();
41
-		$invoice    = $this->process_submission_invoice( $invoice, $items );
42
-		$prepared   = $this->prepare_submission_data_for_saving();
43
-
44
-		$this->prepare_billing_info( $invoice );
45
-
46
-		$shipping   = $this->prepare_shipping_info( $invoice );
47
-
48
-		// Save the invoice.
49
-		$invoice->set_is_viewed( true );
50
-		$invoice->recalculate_total();
15
+    /**
16
+     * @var GetPaid_Payment_Form_Submission
17
+     */
18
+    protected $payment_form_submission;
19
+
20
+    /**
21
+     * Class constructor.
22
+     * 
23
+     * @param GetPaid_Payment_Form_Submission $submission
24
+     */
25
+    public function __construct( $submission ) {
26
+        $this->payment_form_submission = $submission;
27
+    }
28
+
29
+    /**
30
+     * Processes the checkout.
31
+     *
32
+     */
33
+    public function process_checkout() {
34
+
35
+        // Validate the submission.
36
+        $this->validate_submission();
37
+
38
+        // Prepare the invoice.
39
+        $items      = $this->get_submission_items();
40
+        $invoice    = $this->get_submission_invoice();
41
+        $invoice    = $this->process_submission_invoice( $invoice, $items );
42
+        $prepared   = $this->prepare_submission_data_for_saving();
43
+
44
+        $this->prepare_billing_info( $invoice );
45
+
46
+        $shipping   = $this->prepare_shipping_info( $invoice );
47
+
48
+        // Save the invoice.
49
+        $invoice->set_is_viewed( true );
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
-		// Send to the gateway.
56
-		$this->post_process_submission( $invoice, $prepared, $shipping );
57
-	}
55
+        // Send to the gateway.
56
+        $this->post_process_submission( $invoice, $prepared, $shipping );
57
+    }
58 58
 
59
-	/**
60
-	 * Validates the submission.
61
-	 *
62
-	 */
63
-	protected function validate_submission() {
59
+    /**
60
+     * Validates the submission.
61
+     *
62
+     */
63
+    protected function validate_submission() {
64 64
 
65
-		$submission = $this->payment_form_submission;
66
-		$data       = $submission->get_data();
65
+        $submission = $this->payment_form_submission;
66
+        $data       = $submission->get_data();
67 67
 
68
-		// Do we have an error?
68
+        // Do we have an error?
69 69
         if ( ! empty( $submission->last_error ) ) {
70
-			wp_send_json_error( $submission->last_error );
70
+            wp_send_json_error( $submission->last_error );
71 71
         }
72 72
 
73
-		// We need a billing email.
73
+        // We need a billing email.
74 74
         if ( ! $submission->has_billing_email() ) {
75 75
             wp_send_json_error( __( 'Provide a valid billing email.', 'invoicing' ) );
76
-		}
76
+        }
77 77
 
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' ) );
81
-		}
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' ) );
81
+        }
82 82
 
83
-		// Ensure the gateway is active.
84
-		if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
-			wp_send_json_error( __( 'The selected payment gateway is not active', 'invoicing' ) );
86
-		}
83
+        // Ensure the gateway is active.
84
+        if ( $submission->should_collect_payment_details() && ! wpinv_is_gateway_active( $data['wpi-gateway'] ) ) {
85
+            wp_send_json_error( __( 'The selected payment gateway is not active', 'invoicing' ) );
86
+        }
87 87
 
88
-		// Clear any existing errors.
89
-		wpinv_clear_errors();
88
+        // Clear any existing errors.
89
+        wpinv_clear_errors();
90 90
 
91
-		// Allow themes and plugins to hook to errors
92
-		do_action( 'getpaid_checkout_error_checks', $submission );
91
+        // Allow themes and plugins to hook to errors
92
+        do_action( 'getpaid_checkout_error_checks', $submission );
93 93
 
94
-		// Do we have any errors?
94
+        // Do we have any errors?
95 95
         if ( wpinv_get_errors() ) {
96 96
             wp_send_json_error( getpaid_get_errors_html() );
97
-		}
97
+        }
98 98
 
99
-	}
99
+    }
100 100
 
101
-	/**
102
-	 * Retrieves submission items.
103
-	 *
104
-	 * @return GetPaid_Form_Item[]
105
-	 */
106
-	protected function get_submission_items() {
101
+    /**
102
+     * Retrieves submission items.
103
+     *
104
+     * @return GetPaid_Form_Item[]
105
+     */
106
+    protected function get_submission_items() {
107 107
 
108
-		$items = $this->payment_form_submission->get_items();
108
+        $items = $this->payment_form_submission->get_items();
109 109
 
110 110
         // Ensure that we have items.
111 111
         if ( empty( $items ) && ! $this->payment_form_submission->has_fees() ) {
112 112
             wp_send_json_error( __( 'Please provide at least one item or amount.', 'invoicing' ) );
113
-		}
114
-
115
-		return $items;
116
-	}
117
-
118
-	/**
119
-	 * Retrieves submission invoice.
120
-	 *
121
-	 * @return WPInv_Invoice
122
-	 */
123
-	protected function get_submission_invoice() {
124
-		$submission = $this->payment_form_submission;
125
-
126
-		if ( ! $submission->has_invoice() ) {
127
-			$invoice = new WPInv_Invoice();
128
-			$invoice->set_created_via( 'payment_form' );
129
-			return $invoice;
130 113
         }
131 114
 
132
-		$invoice = $submission->get_invoice();
115
+        return $items;
116
+    }
117
+
118
+    /**
119
+     * Retrieves submission invoice.
120
+     *
121
+     * @return WPInv_Invoice
122
+     */
123
+    protected function get_submission_invoice() {
124
+        $submission = $this->payment_form_submission;
125
+
126
+        if ( ! $submission->has_invoice() ) {
127
+            $invoice = new WPInv_Invoice();
128
+            $invoice->set_created_via( 'payment_form' );
129
+            return $invoice;
130
+        }
131
+
132
+        $invoice = $submission->get_invoice();
133 133
 
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' ) );
137
-		}
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' ) );
137
+        }
138 138
 
139
-		return $invoice;
140
-	}
139
+        return $invoice;
140
+    }
141 141
 
142
-	/**
143
-	 * Processes the submission invoice.
144
-	 *
145
-	 * @param WPInv_Invoice $invoice
146
-	 * @param GetPaid_Form_Item[] $items
147
-	 * @return WPInv_Invoice
148
-	 */
149
-	protected function process_submission_invoice( $invoice, $items ) {
142
+    /**
143
+     * Processes the submission invoice.
144
+     *
145
+     * @param WPInv_Invoice $invoice
146
+     * @param GetPaid_Form_Item[] $items
147
+     * @return WPInv_Invoice
148
+     */
149
+    protected function process_submission_invoice( $invoice, $items ) {
150 150
 
151
-		$submission = $this->payment_form_submission;
151
+        $submission = $this->payment_form_submission;
152 152
 
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() ) );
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 157
         $invoice->set_items( $items );
158 158
         $invoice->set_fees( $submission->get_fees() );
159 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() );
160
+        $invoice->set_discounts( $submission->get_discounts() );
161
+        $invoice->set_gateway( $submission->get_field( 'wpi-gateway' ) );
162
+        $invoice->set_currency( $submission->get_currency() );
163 163
 
164
-		if ( $submission->has_shipping() ) {
165
-			$invoice->set_shipping( $submission->get_shipping() );
166
-		}
164
+        if ( $submission->has_shipping() ) {
165
+            $invoice->set_shipping( $submission->get_shipping() );
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() ) {
171
+        if ( $submission->has_discount_code() ) {
172 172
             $invoice->set_discount_code( $submission->get_discount_code() );
173
-		}
174
-
175
-		getpaid_maybe_add_default_address( $invoice );
176
-		return $invoice;
177
-	}
178
-
179
-	/**
180
-	 * Retrieves the submission's customer.
181
-	 *
182
-	 * @return int The customer id.
183
-	 */
184
-	protected function get_submission_customer() {
185
-		$submission = $this->payment_form_submission;
186
-
187
-		// If this is an existing invoice...
188
-		if ( $submission->has_invoice() ) {
189
-			return $submission->get_invoice()->get_user_id();
190
-		}
191
-
192
-		// (Maybe) create the user.
173
+        }
174
+
175
+        getpaid_maybe_add_default_address( $invoice );
176
+        return $invoice;
177
+    }
178
+
179
+    /**
180
+     * Retrieves the submission's customer.
181
+     *
182
+     * @return int The customer id.
183
+     */
184
+    protected function get_submission_customer() {
185
+        $submission = $this->payment_form_submission;
186
+
187
+        // If this is an existing invoice...
188
+        if ( $submission->has_invoice() ) {
189
+            return $submission->get_invoice()->get_user_id();
190
+        }
191
+
192
+        // (Maybe) create the user.
193 193
         $user = get_current_user_id();
194 194
 
195 195
         if ( empty( $user ) ) {
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
         if ( empty( $user ) ) {
200 200
             $user = wpinv_create_user( $submission->get_billing_email() );
201 201
 
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' );
206
-			}
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' );
206
+            }
207 207
 
208 208
         }
209 209
 
@@ -213,49 +213,49 @@  discard block
 block discarded – undo
213 213
 
214 214
         if ( is_numeric( $user ) ) {
215 215
             return $user;
216
-		}
216
+        }
217 217
 
218
-		return $user->ID;
218
+        return $user->ID;
219 219
 
220
-	}
220
+    }
221 221
 
222
-	/**
222
+    /**
223 223
      * Prepares submission data for saving to the database.
224 224
      *
225
-	 * @return array
225
+     * @return array
226 226
      */
227 227
     public function prepare_submission_data_for_saving() {
228 228
 
229
-		$submission = $this->payment_form_submission;
229
+        $submission = $this->payment_form_submission;
230 230
 
231
-		// Prepared submission details.
231
+        // Prepared submission details.
232 232
         $prepared = array(
233
-			'all'  => array(),
234
-			'meta' => array(),
235
-		);
233
+            'all'  => array(),
234
+            'meta' => array(),
235
+        );
236 236
 
237 237
         // Raw submission details.
238
-		$data     = $submission->get_data();
238
+        $data     = $submission->get_data();
239 239
 
240
-		// Loop through the submitted details.
240
+        // Loop through the submitted details.
241 241
         foreach ( $submission->get_payment_form()->get_elements() as $field ) {
242 242
 
243
-			// Skip premade fields.
243
+            // Skip premade fields.
244 244
             if ( ! empty( $field['premade'] ) ) {
245 245
                 continue;
246 246
             }
247 247
 
248
-			// Ensure address is provided.
249
-			if ( $field['type'] == 'address' ) {
248
+            // Ensure address is provided.
249
+            if ( $field['type'] == 'address' ) {
250 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' ) );
256
-					}
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
+                    }
257 257
 
258
-				}
258
+                }
259 259
 
260 260
             }
261 261
 
@@ -267,31 +267,31 @@  discard block
 block discarded – undo
267 267
             // Handle misc fields.
268 268
             if ( isset( $data[ $field['id'] ] ) ) {
269 269
 
270
-				// Uploads.
271
-				if ( $field['type'] == 'file_upload' ) {
272
-					$max_file_num = empty( $field['max_file_num'] ) ? 1 : absint( $field['max_file_num'] );
270
+                // Uploads.
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' ) );
276
-					}
274
+                    if ( count( $data[ $field['id'] ] ) > $max_file_num ) {
275
+                        wp_send_json_error( __( 'Maximum number of allowed files exceeded.', 'invoicing' ) );
276
+                    }
277 277
 
278
-					$value = array();
278
+                    $value = array();
279 279
 
280
-					foreach ( $data[ $field['id'] ] as $url => $name ) {
281
-						$value[] = sprintf(
282
-							'<a href="%s" target="_blank">%s</a>',
283
-							esc_url_raw( $url ),
284
-							esc_html( $name )
285
-						);
286
-					}
280
+                    foreach ( $data[ $field['id'] ] as $url => $name ) {
281
+                        $value[] = sprintf(
282
+                            '<a href="%s" target="_blank">%s</a>',
283
+                            esc_url_raw( $url ),
284
+                            esc_html( $name )
285
+                        );
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' );
292
-				} else {
293
-					$value = wp_kses_post( $data[ $field['id'] ] );
294
-				}
290
+                } else if ( $field['type'] == 'checkbox' ) {
291
+                    $value = isset( $data[ $field['id'] ] ) ? __( 'Yes', 'invoicing' ) : __( 'No', 'invoicing' );
292
+                } else {
293
+                    $value = wp_kses_post( $data[ $field['id'] ] );
294
+                }
295 295
 
296 296
                 $label = $field['id'];
297 297
 
@@ -299,190 +299,190 @@  discard block
 block discarded – undo
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 );
304
-				}
305
-				$prepared['all'][ 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
+                }
305
+                $prepared['all'][ wpinv_clean( $label ) ] = wp_kses_post_deep( $value );
306 306
 
307 307
             }
308 308
 
309
-		}
309
+        }
310 310
 
311
-		return $prepared;
311
+        return $prepared;
312 312
 
313
-	}
313
+    }
314 314
 
315
-	/**
315
+    /**
316 316
      * Retrieves address details.
317 317
      *
318
-	 * @return array
319
-	 * @param WPInv_Invoice $invoice
320
-	 * @param string $type
318
+     * @return array
319
+     * @param WPInv_Invoice $invoice
320
+     * @param string $type
321 321
      */
322 322
     public function prepare_address_details( $invoice, $type = 'billing' ) {
323 323
 
324
-		$data     = $this->payment_form_submission->get_data();
325
-		$type     = sanitize_key( $type );
326
-		$address  = array();
327
-		$prepared = array();
324
+        $data     = $this->payment_form_submission->get_data();
325
+        $type     = sanitize_key( $type );
326
+        $address  = array();
327
+        $prepared = array();
328 328
 
329
-		if ( ! empty( $data[ $type ] ) ) {
330
-			$address = $data[ $type ];
331
-		}
329
+        if ( ! empty( $data[ $type ] ) ) {
330
+            $address = $data[ $type ];
331
+        }
332 332
 
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 );
339
-		}
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 );
339
+        }
340 340
 
341
-		// Filter address details.
342
-		$prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
341
+        // Filter address details.
342
+        $prepared = apply_filters( "getpaid_checkout_{$type}_address", $prepared, $this->payment_form_submission, $invoice );
343 343
 
344
-		// Remove non-whitelisted values.
345
-		return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
344
+        // Remove non-whitelisted values.
345
+        return array_filter( $prepared, 'getpaid_is_address_field_whitelisted', ARRAY_FILTER_USE_KEY );
346 346
 
347
-	}
347
+    }
348 348
 
349
-	/**
349
+    /**
350 350
      * Prepares the billing details.
351 351
      *
352
-	 * @return array
353
-	 * @param WPInv_Invoice $invoice
352
+     * @return array
353
+     * @param WPInv_Invoice $invoice
354 354
      */
355 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
-		// Update the invoice with the billing details.
360
-		$invoice->set_props( $billing_address );
359
+        // Update the invoice with the billing details.
360
+        $invoice->set_props( $billing_address );
361 361
 
362
-	}
362
+    }
363 363
 
364
-	/**
364
+    /**
365 365
      * Prepares the shipping details.
366 366
      *
367
-	 * @return array
368
-	 * @param WPInv_Invoice $invoice
367
+     * @return array
368
+     * @param WPInv_Invoice $invoice
369 369
      */
370 370
     protected function prepare_shipping_info( $invoice ) {
371 371
 
372
-		$data = $this->payment_form_submission->get_data();
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' );
376
-		}
374
+        if ( empty( $data['same-shipping-address'] ) ) {
375
+            return $this->prepare_address_details( $invoice, 'shipping' );
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
 
382
-	/**
383
-	 * Confirms the submission is valid and send users to the gateway.
384
-	 *
385
-	 * @param WPInv_Invoice $invoice
386
-	 * @param array $prepared_payment_form_data
387
-	 * @param array $shipping
388
-	 */
389
-	protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
382
+    /**
383
+     * Confirms the submission is valid and send users to the gateway.
384
+     *
385
+     * @param WPInv_Invoice $invoice
386
+     * @param array $prepared_payment_form_data
387
+     * @param array $shipping
388
+     */
389
+    protected function post_process_submission( $invoice, $prepared_payment_form_data, $shipping ) {
390 390
 
391
-		// Ensure the invoice exists.
391
+        // Ensure the invoice exists.
392 392
         if ( ! $invoice->exists() ) {
393 393
             wp_send_json_error( __( 'An error occured while saving your invoice. Please try again.', 'invoicing' ) );
394 394
         }
395 395
 
396
-		// Save payment form data.
397
-		$prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
396
+        // Save payment form data.
397
+        $prepared_payment_form_data = apply_filters( 'getpaid_prepared_payment_form_data', $prepared_payment_form_data, $invoice );
398 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 ) ) {
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'] );
404
-			}
402
+            if ( ! empty( $prepared_payment_form_data['all'] ) ) {
403
+                update_post_meta( $invoice->get_id(), 'payment_form_data', $prepared_payment_form_data['all'] );
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'] );
408
-			}
406
+            if ( ! empty( $prepared_payment_form_data['meta'] ) ) {
407
+                update_post_meta( $invoice->get_id(), 'additional_meta_data', $prepared_payment_form_data['meta'] );
408
+            }
409 409
 
410
-		}
410
+        }
411 411
 
412
-		// Save payment form data.
413
-		$shipping = apply_filters( 'getpaid_checkout_shipping_details', $shipping, $this->payment_form_submission );
412
+        // Save payment form data.
413
+        $shipping = apply_filters( 'getpaid_checkout_shipping_details', $shipping, $this->payment_form_submission );
414 414
         if ( ! empty( $shipping ) ) {
415 415
             update_post_meta( $invoice->get_id(), 'shipping_address', $shipping );
416
-		}
416
+        }
417 417
 
418
-		// Backwards compatibility.
418
+        // Backwards compatibility.
419 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
 
428
-	/**
429
-	 * Processes the actual payment.
430
-	 *
431
-	 * @param WPInv_Invoice $invoice
432
-	 */
433
-	protected function process_payment( $invoice ) {
428
+    /**
429
+     * Processes the actual payment.
430
+     *
431
+     * @param WPInv_Invoice $invoice
432
+     */
433
+    protected function process_payment( $invoice ) {
434 434
 
435
-		// Clear any checkout errors.
436
-		wpinv_clear_errors();
435
+        // Clear any checkout errors.
436
+        wpinv_clear_errors();
437 437
 
438
-		// No need to send free invoices to the gateway.
439
-		if ( $invoice->is_free() ) {
440
-			$this->process_free_payment( $invoice );
441
-		}
438
+        // No need to send free invoices to the gateway.
439
+        if ( $invoice->is_free() ) {
440
+            $this->process_free_payment( $invoice );
441
+        }
442 442
 
443
-		$submission = $this->payment_form_submission;
443
+        $submission = $this->payment_form_submission;
444 444
 
445
-		// Fires before sending to the gateway.
446
-		do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
445
+        // Fires before sending to the gateway.
446
+        do_action( 'getpaid_checkout_before_gateway', $invoice, $submission );
447 447
 
448
-		// Allow the sumission data to be modified before it is sent to the gateway.
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 );
448
+        // Allow the sumission data to be modified before it is sent to the gateway.
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 );
452 452
 
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' ) );
456
-		}
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' ) );
456
+        }
457 457
 
458
-		// Check to see if we have any errors.
459
-		if ( wpinv_get_errors() ) {
460
-			wpinv_send_back_to_checkout( $invoice );
461
-		}
458
+        // Check to see if we have any errors.
459
+        if ( wpinv_get_errors() ) {
460
+            wpinv_send_back_to_checkout( $invoice );
461
+        }
462 462
 
463
-		// Send info to the gateway for payment processing
464
-		do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
463
+        // Send info to the gateway for payment processing
464
+        do_action( "getpaid_gateway_$submission_gateway", $invoice, $submission_data, $submission );
465 465
 
466
-		// Backwards compatibility.
467
-		wpinv_send_to_gateway( $submission_gateway, $invoice );
466
+        // Backwards compatibility.
467
+        wpinv_send_to_gateway( $submission_gateway, $invoice );
468 468
 
469
-	}
469
+    }
470 470
 
471
-	/**
472
-	 * Marks the invoice as paid in case the checkout is free.
473
-	 *
474
-	 * @param WPInv_Invoice $invoice
475
-	 */
476
-	protected function process_free_payment( $invoice ) {
471
+    /**
472
+     * Marks the invoice as paid in case the checkout is free.
473
+     *
474
+     * @param WPInv_Invoice $invoice
475
+     */
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 );
480
-		$invoice->mark_paid();
481
-		wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
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
+        $invoice->mark_paid();
481
+        wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) );
482 482
 
483
-	}
483
+    }
484 484
 
485
-	/**
485
+    /**
486 486
      * Sends a redrect response to payment details.
487 487
      *
488 488
      */
Please login to merge, or discard this 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
-			wp_send_json_error( __( 'The selected payment gateway is not active', 'invoicing' ) );
84
+		if ($submission->should_collect_payment_details() && !wpinv_is_gateway_active($data['wpi-gateway'])) {
85
+			wp_send_json_error(__('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.
includes/gateways/class-getpaid-paypal-gateway-ipn-handler.php 2 patches
Indentation   +390 added lines, -390 removed lines patch added patch discarded remove patch
@@ -12,474 +12,474 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Paypal_Gateway_IPN_Handler {
14 14
 
15
-	/**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
20
-	protected $id = 'paypal';
21
-
22
-	/**
23
-	 * Payment method object.
24
-	 *
25
-	 * @var GetPaid_Paypal_Gateway
26
-	 */
27
-	protected $gateway;
28
-
29
-	/**
30
-	 * Class constructor.
31
-	 *
32
-	 * @param GetPaid_Paypal_Gateway $gateway
33
-	 */
34
-	public function __construct( $gateway ) {
35
-		$this->gateway = $gateway;
36
-		$this->verify_ipn();
37
-	}
38
-
39
-	/**
40
-	 * Processes ipns and marks payments as complete.
41
-	 *
42
-	 * @return void
43
-	 */
44
-	public function verify_ipn() {
45
-
46
-		wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
47
-
48
-		// Validate the IPN.
49
-		if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
-			wp_die( 'PayPal IPN Request Failure', 500 );
51
-		}
52
-
53
-		// Process the IPN.
54
-		$posted  = wp_kses_post_deep( wp_unslash( $_POST ) );
55
-		$invoice = $this->get_ipn_invoice( $posted );
56
-
57
-		// Abort if it was not paid by our gateway.
58
-		if ( $this->id != $invoice->get_gateway() ) {
59
-			wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
-			wp_die( 'Invoice not paid via PayPal', 200 );
61
-		}
62
-
63
-		$posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
-		$posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
65
-
66
-		wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
68
-
69
-		if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
-			call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
-			wpinv_error_log( 'Done processing IPN', false );
72
-			wp_die( 'Processed', 200 );
73
-		}
74
-
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
-		wp_die( 'Unsupported IPN type', 200 );
77
-
78
-	}
79
-
80
-	/**
81
-	 * Retrieves IPN Invoice.
82
-	 *
83
-	 * @param array $posted
84
-	 * @return WPInv_Invoice
85
-	 */
86
-	protected function get_ipn_invoice( $posted ) {
87
-
88
-		wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
89
-
90
-		if ( ! empty( $posted['custom'] ) ) {
91
-			$invoice = new WPInv_Invoice( $posted['custom'] );
92
-
93
-			if ( $invoice->exists() ) {
94
-				wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
95
-				return $invoice;
96
-			}
97
-
98
-		}
99
-
100
-		wpinv_error_log( 'Could not retrieve the associated invoice.', false );
101
-		wp_die( 'Could not retrieve the associated invoice.', 200 );
102
-	}
103
-
104
-	/**
105
-	 * Check PayPal IPN validity.
106
-	 */
107
-	protected function validate_ipn() {
108
-
109
-		wpinv_error_log( 'Validating PayPal IPN response', false );
110
-
111
-		// Retrieve the associated invoice.
112
-		$posted  = wp_kses_post_deep( wp_unslash( $_POST ) );
113
-		$invoice = $this->get_ipn_invoice( $posted );
114
-
115
-		if ( $this->gateway->is_sandbox( $invoice ) ) {
116
-			wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
117
-		}
118
-
119
-		// Validate the IPN.
120
-		$posted['cmd'] = '_notify-validate';
121
-
122
-		// Send back post vars to paypal.
123
-		$params = array(
124
-			'body'        => $posted,
125
-			'timeout'     => 60,
126
-			'httpversion' => '1.1',
127
-			'compress'    => false,
128
-			'decompress'  => false,
129
-			'user-agent'  => 'GetPaid/' . WPINV_VERSION,
130
-		);
131
-
132
-		// Post back to get a response.
133
-		$response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
134
-
135
-		// Check to see if the request was valid.
136
-		if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
137
-			wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
138
-			return true;
139
-		}
140
-
141
-		if ( is_wp_error( $response ) ) {
142
-			wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
143
-			return false;
144
-		}
15
+    /**
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20
+    protected $id = 'paypal';
21
+
22
+    /**
23
+     * Payment method object.
24
+     *
25
+     * @var GetPaid_Paypal_Gateway
26
+     */
27
+    protected $gateway;
28
+
29
+    /**
30
+     * Class constructor.
31
+     *
32
+     * @param GetPaid_Paypal_Gateway $gateway
33
+     */
34
+    public function __construct( $gateway ) {
35
+        $this->gateway = $gateway;
36
+        $this->verify_ipn();
37
+    }
38
+
39
+    /**
40
+     * Processes ipns and marks payments as complete.
41
+     *
42
+     * @return void
43
+     */
44
+    public function verify_ipn() {
45
+
46
+        wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
47
+
48
+        // Validate the IPN.
49
+        if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
+            wp_die( 'PayPal IPN Request Failure', 500 );
51
+        }
52
+
53
+        // Process the IPN.
54
+        $posted  = wp_kses_post_deep( wp_unslash( $_POST ) );
55
+        $invoice = $this->get_ipn_invoice( $posted );
56
+
57
+        // Abort if it was not paid by our gateway.
58
+        if ( $this->id != $invoice->get_gateway() ) {
59
+            wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
+            wp_die( 'Invoice not paid via PayPal', 200 );
61
+        }
62
+
63
+        $posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
+        $posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
65
+
66
+        wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
+        wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
68
+
69
+        if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
+            call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
+            wpinv_error_log( 'Done processing IPN', false );
72
+            wp_die( 'Processed', 200 );
73
+        }
74
+
75
+        wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
+        wp_die( 'Unsupported IPN type', 200 );
77
+
78
+    }
79
+
80
+    /**
81
+     * Retrieves IPN Invoice.
82
+     *
83
+     * @param array $posted
84
+     * @return WPInv_Invoice
85
+     */
86
+    protected function get_ipn_invoice( $posted ) {
87
+
88
+        wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
89
+
90
+        if ( ! empty( $posted['custom'] ) ) {
91
+            $invoice = new WPInv_Invoice( $posted['custom'] );
92
+
93
+            if ( $invoice->exists() ) {
94
+                wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
95
+                return $invoice;
96
+            }
97
+
98
+        }
99
+
100
+        wpinv_error_log( 'Could not retrieve the associated invoice.', false );
101
+        wp_die( 'Could not retrieve the associated invoice.', 200 );
102
+    }
103
+
104
+    /**
105
+     * Check PayPal IPN validity.
106
+     */
107
+    protected function validate_ipn() {
108
+
109
+        wpinv_error_log( 'Validating PayPal IPN response', false );
110
+
111
+        // Retrieve the associated invoice.
112
+        $posted  = wp_kses_post_deep( wp_unslash( $_POST ) );
113
+        $invoice = $this->get_ipn_invoice( $posted );
114
+
115
+        if ( $this->gateway->is_sandbox( $invoice ) ) {
116
+            wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
117
+        }
118
+
119
+        // Validate the IPN.
120
+        $posted['cmd'] = '_notify-validate';
121
+
122
+        // Send back post vars to paypal.
123
+        $params = array(
124
+            'body'        => $posted,
125
+            'timeout'     => 60,
126
+            'httpversion' => '1.1',
127
+            'compress'    => false,
128
+            'decompress'  => false,
129
+            'user-agent'  => 'GetPaid/' . WPINV_VERSION,
130
+        );
131
+
132
+        // Post back to get a response.
133
+        $response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
134
+
135
+        // Check to see if the request was valid.
136
+        if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
137
+            wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
138
+            return true;
139
+        }
140
+
141
+        if ( is_wp_error( $response ) ) {
142
+            wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
143
+            return false;
144
+        }
145 145
 
146
-		wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
147
-		return false;
148
-
149
-	}
146
+        wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
147
+        return false;
148
+
149
+    }
150 150
 
151
-	/**
152
-	 * Check currency from IPN matches the invoice.
153
-	 *
154
-	 * @param WPInv_Invoice $invoice          Invoice object.
155
-	 * @param string   $currency currency to validate.
156
-	 */
157
-	protected function validate_ipn_currency( $invoice, $currency ) {
151
+    /**
152
+     * Check currency from IPN matches the invoice.
153
+     *
154
+     * @param WPInv_Invoice $invoice          Invoice object.
155
+     * @param string   $currency currency to validate.
156
+     */
157
+    protected function validate_ipn_currency( $invoice, $currency ) {
158 158
 
159
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
159
+        if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
160 160
 
161
-			/* translators: %s: currency code. */
162
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
161
+            /* translators: %s: currency code. */
162
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
163 163
 
164
-			wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
165
-		}
164
+            wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
165
+        }
166 166
 
167
-		wpinv_error_log( $currency, 'Validated IPN Currency', false );
168
-	}
167
+        wpinv_error_log( $currency, 'Validated IPN Currency', false );
168
+    }
169 169
 
170
-	/**
171
-	 * Check payment amount from IPN matches the invoice.
172
-	 *
173
-	 * @param WPInv_Invoice $invoice          Invoice object.
174
-	 * @param float   $amount amount to validate.
175
-	 */
176
-	protected function validate_ipn_amount( $invoice, $amount ) {
177
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
170
+    /**
171
+     * Check payment amount from IPN matches the invoice.
172
+     *
173
+     * @param WPInv_Invoice $invoice          Invoice object.
174
+     * @param float   $amount amount to validate.
175
+     */
176
+    protected function validate_ipn_amount( $invoice, $amount ) {
177
+        if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
178 178
 
179
-			/* translators: %s: Amount. */
180
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
179
+            /* translators: %s: Amount. */
180
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
181 181
 
182
-			wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
183
-		}
182
+            wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
183
+        }
184 184
 
185
-		wpinv_error_log( $amount, 'Validated IPN Amount', false );
186
-	}
185
+        wpinv_error_log( $amount, 'Validated IPN Amount', false );
186
+    }
187 187
 
188
-	/**
189
-	 * Verify receiver email from PayPal.
190
-	 *
191
-	 * @param WPInv_Invoice $invoice          Invoice object.
192
-	 * @param string   $receiver_email Email to validate.
193
-	 */
194
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
195
-		$paypal_email = wpinv_get_option( 'paypal_email' );
188
+    /**
189
+     * Verify receiver email from PayPal.
190
+     *
191
+     * @param WPInv_Invoice $invoice          Invoice object.
192
+     * @param string   $receiver_email Email to validate.
193
+     */
194
+    protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
195
+        $paypal_email = wpinv_get_option( 'paypal_email' );
196 196
 
197
-		if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
198
-			wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
197
+        if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
198
+            wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
199 199
 
200
-			/* translators: %s: email address . */
201
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
200
+            /* translators: %s: email address . */
201
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
202 202
 
203
-			return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
204
-		}
203
+            return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
204
+        }
205 205
 
206
-		wpinv_error_log( 'Validated PayPal Email', false );
207
-	}
206
+        wpinv_error_log( 'Validated PayPal Email', false );
207
+    }
208 208
 
209
-	/**
210
-	 * Handles one time payments.
211
-	 *
212
-	 * @param WPInv_Invoice $invoice  Invoice object.
213
-	 * @param array    $posted Posted data.
214
-	 */
215
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
209
+    /**
210
+     * Handles one time payments.
211
+     *
212
+     * @param WPInv_Invoice $invoice  Invoice object.
213
+     * @param array    $posted Posted data.
214
+     */
215
+    protected function ipn_txn_web_accept( $invoice, $posted ) {
216 216
 
217
-		// Collect payment details
218
-		$payment_status = strtolower( $posted['payment_status'] );
219
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
217
+        // Collect payment details
218
+        $payment_status = strtolower( $posted['payment_status'] );
219
+        $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
220 220
 
221
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
222
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
221
+        $this->validate_ipn_receiver_email( $invoice, $business_email );
222
+        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
223 223
 
224
-		// Update the transaction id.
225
-		if ( ! empty( $posted['txn_id'] ) ) {
226
-			$invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
227
-			$invoice->save();
228
-		}
224
+        // Update the transaction id.
225
+        if ( ! empty( $posted['txn_id'] ) ) {
226
+            $invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
227
+            $invoice->save();
228
+        }
229 229
 
230
-		$invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
230
+        $invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
231 231
 
232
-		// Process a refund.
233
-		if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
232
+        // Process a refund.
233
+        if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
234 234
 
235
-			update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
235
+            update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
236 236
 
237
-			if ( ! $invoice->is_refunded() ) {
238
-				$invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
239
-			}
237
+            if ( ! $invoice->is_refunded() ) {
238
+                $invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
239
+            }
240 240
 
241
-			return wpinv_error_log( $posted['reason_code'], false );
242
-		}
241
+            return wpinv_error_log( $posted['reason_code'], false );
242
+        }
243 243
 
244
-		// Process payments.
245
-		if ( $payment_status == 'completed' ) {
244
+        // Process payments.
245
+        if ( $payment_status == 'completed' ) {
246 246
 
247
-			if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
248
-				return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
249
-			}
247
+            if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
248
+                return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
249
+            }
250 250
 
251
-			$this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
251
+            $this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
252 252
 
253
-			$note = '';
253
+            $note = '';
254 254
 
255
-			if ( ! empty( $posted['mc_fee'] ) ) {
256
-				$note = sprintf( __( 'PayPal Transaction Fee %s.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
257
-			}
255
+            if ( ! empty( $posted['mc_fee'] ) ) {
256
+                $note = sprintf( __( 'PayPal Transaction Fee %s.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
257
+            }
258 258
 
259
-			if ( ! empty( $posted['payer_status'] ) ) {
260
-				$note = ' ' . sprintf( __( 'Buyer status %s.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
261
-			}
259
+            if ( ! empty( $posted['payer_status'] ) ) {
260
+                $note = ' ' . sprintf( __( 'Buyer status %s.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
261
+            }
262 262
 
263
-			$invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
264
-			return wpinv_error_log( 'Invoice marked as paid.', false );
263
+            $invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
264
+            return wpinv_error_log( 'Invoice marked as paid.', false );
265 265
 
266
-		}
266
+        }
267 267
 
268
-		// Pending payments.
269
-		if ( $payment_status == 'pending' ) {
268
+        // Pending payments.
269
+        if ( $payment_status == 'pending' ) {
270 270
 
271
-			/* translators: %s: pending reason. */
272
-			$invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
271
+            /* translators: %s: pending reason. */
272
+            $invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
273 273
 
274
-			return wpinv_error_log( 'Invoice marked as "payment held".', false );
275
-		}
274
+            return wpinv_error_log( 'Invoice marked as "payment held".', false );
275
+        }
276 276
 
277
-		/* translators: %s: payment status. */
278
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
277
+        /* translators: %s: payment status. */
278
+        $invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
279 279
 
280
-	}
280
+    }
281 281
 
282
-	/**
283
-	 * Handles one time payments.
284
-	 *
285
-	 * @param WPInv_Invoice $invoice  Invoice object.
286
-	 * @param array    $posted Posted data.
287
-	 */
288
-	protected function ipn_txn_cart( $invoice, $posted ) {
289
-		$this->ipn_txn_web_accept( $invoice, $posted );
290
-	}
282
+    /**
283
+     * Handles one time payments.
284
+     *
285
+     * @param WPInv_Invoice $invoice  Invoice object.
286
+     * @param array    $posted Posted data.
287
+     */
288
+    protected function ipn_txn_cart( $invoice, $posted ) {
289
+        $this->ipn_txn_web_accept( $invoice, $posted );
290
+    }
291 291
 
292
-	/**
293
-	 * Handles subscription sign ups.
294
-	 *
295
-	 * @param WPInv_Invoice $invoice  Invoice object.
296
-	 * @param array    $posted Posted data.
297
-	 */
298
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
292
+    /**
293
+     * Handles subscription sign ups.
294
+     *
295
+     * @param WPInv_Invoice $invoice  Invoice object.
296
+     * @param array    $posted Posted data.
297
+     */
298
+    protected function ipn_txn_subscr_signup( $invoice, $posted ) {
299 299
 
300
-		wpinv_error_log( 'Processing subscription signup', false );
300
+        wpinv_error_log( 'Processing subscription signup', false );
301 301
 
302
-		// Make sure the invoice has a subscription.
303
-		$subscription = getpaid_get_invoice_subscription( $invoice );
302
+        // Make sure the invoice has a subscription.
303
+        $subscription = getpaid_get_invoice_subscription( $invoice );
304 304
 
305
-		if ( empty( $subscription ) ) {
306
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
307
-		}
305
+        if ( empty( $subscription ) ) {
306
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
307
+        }
308 308
 
309
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
309
+        wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
310 310
 
311
-		// Validate the IPN.
312
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
313
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
314
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
311
+        // Validate the IPN.
312
+        $business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
313
+        $this->validate_ipn_receiver_email( $invoice, $business_email );
314
+        $this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
315 315
 
316
-		// Activate the subscription.
317
-		$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
318
-		$subscription->set_date_created( current_time( 'mysql' ) );
319
-		$subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
320
-		$subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
321
-		$subscription->activate();
316
+        // Activate the subscription.
317
+        $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
318
+        $subscription->set_date_created( current_time( 'mysql' ) );
319
+        $subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
320
+        $subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
321
+        $subscription->activate();
322 322
 
323
-		// Set the transaction id.
324
-		if ( ! empty( $posted['txn_id'] ) ) {
325
-			$invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
326
-			$invoice->set_transaction_id( $posted['txn_id'] );
327
-		}
323
+        // Set the transaction id.
324
+        if ( ! empty( $posted['txn_id'] ) ) {
325
+            $invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
326
+            $invoice->set_transaction_id( $posted['txn_id'] );
327
+        }
328 328
 
329
-		// Update the payment status.
330
-		$invoice->mark_paid();
329
+        // Update the payment status.
330
+        $invoice->mark_paid();
331 331
 
332
-		$invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
332
+        $invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
333 333
 
334
-		wpinv_error_log( 'Subscription started.', false );
335
-	}
334
+        wpinv_error_log( 'Subscription started.', false );
335
+    }
336 336
 
337
-	/**
338
-	 * Handles subscription renewals.
339
-	 *
340
-	 * @param WPInv_Invoice $invoice  Invoice object.
341
-	 * @param array    $posted Posted data.
342
-	 */
343
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
337
+    /**
338
+     * Handles subscription renewals.
339
+     *
340
+     * @param WPInv_Invoice $invoice  Invoice object.
341
+     * @param array    $posted Posted data.
342
+     */
343
+    protected function ipn_txn_subscr_payment( $invoice, $posted ) {
344 344
 
345
-		// Make sure the invoice has a subscription.
346
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
345
+        // Make sure the invoice has a subscription.
346
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
347 347
 
348
-		if ( empty( $subscription ) ) {
349
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
350
-		}
348
+        if ( empty( $subscription ) ) {
349
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
350
+        }
351 351
 
352
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
352
+        wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
353 353
 
354
-		// PayPal sends a subscr_payment for the first payment too.
355
-		$date_completed = getpaid_format_date( $invoice->get_date_completed() );
356
-		$date_created   = getpaid_format_date( $invoice->get_date_created() );
357
-		$today_date     = getpaid_format_date( current_time( 'mysql' ) );
358
-		$payment_date   = getpaid_format_date( $posted['payment_date'] );
359
-		$subscribe_date = getpaid_format_date( $subscription->get_date_created() );
360
-		$dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
354
+        // PayPal sends a subscr_payment for the first payment too.
355
+        $date_completed = getpaid_format_date( $invoice->get_date_completed() );
356
+        $date_created   = getpaid_format_date( $invoice->get_date_created() );
357
+        $today_date     = getpaid_format_date( current_time( 'mysql' ) );
358
+        $payment_date   = getpaid_format_date( $posted['payment_date'] );
359
+        $subscribe_date = getpaid_format_date( $subscription->get_date_created() );
360
+        $dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
361 361
 
362
-		foreach( $dates as $date ) {
362
+        foreach( $dates as $date ) {
363 363
 
364
-			if ( $date !== $today_date && $date !== $payment_date ) {
365
-				continue;
366
-			}
364
+            if ( $date !== $today_date && $date !== $payment_date ) {
365
+                continue;
366
+            }
367 367
 
368
-			if ( ! empty( $posted['txn_id'] ) ) {
369
-				$invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );	
370
-				$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
371
-			}
368
+            if ( ! empty( $posted['txn_id'] ) ) {
369
+                $invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );	
370
+                $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
371
+            }
372 372
 
373
-			return $invoice->mark_paid();
374
-
375
-		}
373
+            return $invoice->mark_paid();
374
+
375
+        }
376 376
 
377
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
378
-
379
-		// Abort if the payment is already recorded.
380
-		if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
381
-			return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed', false );
382
-		}
383
-
384
-		$args = array(
385
-			'transaction_id' => $posted['txn_id'],
386
-			'gateway'        => $this->id,
387
-		);
388
-
389
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
377
+        wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
378
+
379
+        // Abort if the payment is already recorded.
380
+        if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
381
+            return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed', false );
382
+        }
383
+
384
+        $args = array(
385
+            'transaction_id' => $posted['txn_id'],
386
+            'gateway'        => $this->id,
387
+        );
388
+
389
+        $invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
390 390
 
391
-		if ( empty( $invoice ) ) {
392
-			return;
393
-		}
391
+        if ( empty( $invoice ) ) {
392
+            return;
393
+        }
394 394
 
395
-		$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
396
-		$invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
395
+        $invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
396
+        $invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
397 397
 
398
-		$subscription->renew();
399
-		wpinv_error_log( 'Subscription renewed.', false );
398
+        $subscription->renew();
399
+        wpinv_error_log( 'Subscription renewed.', false );
400 400
 
401
-	}
401
+    }
402 402
 
403
-	/**
404
-	 * Handles subscription cancelations.
405
-	 *
406
-	 * @param WPInv_Invoice $invoice  Invoice object.
407
-	 */
408
-	protected function ipn_txn_subscr_cancel( $invoice ) {
403
+    /**
404
+     * Handles subscription cancelations.
405
+     *
406
+     * @param WPInv_Invoice $invoice  Invoice object.
407
+     */
408
+    protected function ipn_txn_subscr_cancel( $invoice ) {
409 409
 
410
-		// Make sure the invoice has a subscription.
411
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
412
-
413
-		if ( empty( $subscription ) ) {
414
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
415
-		}
416
-
417
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
418
-		$subscription->cancel();
419
-		wpinv_error_log( 'Subscription cancelled.', false );
410
+        // Make sure the invoice has a subscription.
411
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
412
+
413
+        if ( empty( $subscription ) ) {
414
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
415
+        }
416
+
417
+        wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
418
+        $subscription->cancel();
419
+        wpinv_error_log( 'Subscription cancelled.', false );
420 420
 
421
-	}
421
+    }
422 422
 
423
-	/**
424
-	 * Handles subscription completions.
425
-	 *
426
-	 * @param WPInv_Invoice $invoice  Invoice object.
427
-	 * @param array    $posted Posted data.
428
-	 */
429
-	protected function ipn_txn_subscr_eot( $invoice ) {
423
+    /**
424
+     * Handles subscription completions.
425
+     *
426
+     * @param WPInv_Invoice $invoice  Invoice object.
427
+     * @param array    $posted Posted data.
428
+     */
429
+    protected function ipn_txn_subscr_eot( $invoice ) {
430 430
 
431
-		// Make sure the invoice has a subscription.
432
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
431
+        // Make sure the invoice has a subscription.
432
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
433 433
 
434
-		if ( empty( $subscription ) ) {
435
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
436
-		}
434
+        if ( empty( $subscription ) ) {
435
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
436
+        }
437 437
 
438
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
439
-		$subscription->complete();
440
-		wpinv_error_log( 'Subscription completed.', false );
438
+        wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
439
+        $subscription->complete();
440
+        wpinv_error_log( 'Subscription completed.', false );
441 441
 
442
-	}
442
+    }
443 443
 
444
-	/**
445
-	 * Handles subscription fails.
446
-	 *
447
-	 * @param WPInv_Invoice $invoice  Invoice object.
448
-	 * @param array    $posted Posted data.
449
-	 */
450
-	protected function ipn_txn_subscr_failed( $invoice ) {
444
+    /**
445
+     * Handles subscription fails.
446
+     *
447
+     * @param WPInv_Invoice $invoice  Invoice object.
448
+     * @param array    $posted Posted data.
449
+     */
450
+    protected function ipn_txn_subscr_failed( $invoice ) {
451 451
 
452
-		// Make sure the invoice has a subscription.
453
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
452
+        // Make sure the invoice has a subscription.
453
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
454 454
 
455
-		if ( empty( $subscription ) ) {
456
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
457
-		}
455
+        if ( empty( $subscription ) ) {
456
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
457
+        }
458 458
 
459
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
460
-		$subscription->failing();
461
-		wpinv_error_log( 'Subscription marked as failing.', false );
459
+        wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
460
+        $subscription->failing();
461
+        wpinv_error_log( 'Subscription marked as failing.', false );
462 462
 
463
-	}
463
+    }
464 464
 
465
-	/**
466
-	 * Handles subscription suspensions.
467
-	 *
468
-	 * @param WPInv_Invoice $invoice  Invoice object.
469
-	 * @param array    $posted Posted data.
470
-	 */
471
-	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
465
+    /**
466
+     * Handles subscription suspensions.
467
+     *
468
+     * @param WPInv_Invoice $invoice  Invoice object.
469
+     * @param array    $posted Posted data.
470
+     */
471
+    protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
472 472
 
473
-		// Make sure the invoice has a subscription.
474
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
473
+        // Make sure the invoice has a subscription.
474
+        $subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
475 475
 
476
-		if ( empty( $subscription ) ) {
477
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
478
-		}
479
-
480
-		wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
481
-		$subscription->cancel();
482
-		wpinv_error_log( 'Subscription cancelled.', false );
483
-	}
476
+        if ( empty( $subscription ) ) {
477
+            return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
478
+        }
479
+
480
+        wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
481
+        $subscription->cancel();
482
+        wpinv_error_log( 'Subscription cancelled.', false );
483
+    }
484 484
 
485 485
 }
Please login to merge, or discard this patch.
Spacing   +151 added lines, -151 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
  * Paypal Payment Gateway IPN handler class.
@@ -31,7 +31,7 @@  discard block
 block discarded – undo
31 31
 	 *
32 32
 	 * @param GetPaid_Paypal_Gateway $gateway
33 33
 	 */
34
-	public function __construct( $gateway ) {
34
+	public function __construct($gateway) {
35 35
 		$this->gateway = $gateway;
36 36
 		$this->verify_ipn();
37 37
 	}
@@ -43,37 +43,37 @@  discard block
 block discarded – undo
43 43
 	 */
44 44
 	public function verify_ipn() {
45 45
 
46
-		wpinv_error_log( 'GetPaid PayPal IPN Handler', false );
46
+		wpinv_error_log('GetPaid PayPal IPN Handler', false);
47 47
 
48 48
 		// Validate the IPN.
49
-		if ( empty( $_POST ) || ! $this->validate_ipn() ) {
50
-			wp_die( 'PayPal IPN Request Failure', 500 );
49
+		if (empty($_POST) || !$this->validate_ipn()) {
50
+			wp_die('PayPal IPN Request Failure', 500);
51 51
 		}
52 52
 
53 53
 		// Process the IPN.
54
-		$posted  = wp_kses_post_deep( wp_unslash( $_POST ) );
55
-		$invoice = $this->get_ipn_invoice( $posted );
54
+		$posted  = wp_kses_post_deep(wp_unslash($_POST));
55
+		$invoice = $this->get_ipn_invoice($posted);
56 56
 
57 57
 		// Abort if it was not paid by our gateway.
58
-		if ( $this->id != $invoice->get_gateway() ) {
59
-			wpinv_error_log( 'Aborting, Invoice was not paid via PayPal', false );
60
-			wp_die( 'Invoice not paid via PayPal', 200 );
58
+		if ($this->id != $invoice->get_gateway()) {
59
+			wpinv_error_log('Aborting, Invoice was not paid via PayPal', false);
60
+			wp_die('Invoice not paid via PayPal', 200);
61 61
 		}
62 62
 
63
-		$posted['payment_status'] = isset( $posted['payment_status'] ) ? sanitize_key( strtolower( $posted['payment_status'] ) ) : '';
64
-		$posted['txn_type']       = sanitize_key( strtolower( $posted['txn_type'] ) );
63
+		$posted['payment_status'] = isset($posted['payment_status']) ? sanitize_key(strtolower($posted['payment_status'])) : '';
64
+		$posted['txn_type']       = sanitize_key(strtolower($posted['txn_type']));
65 65
 
66
-		wpinv_error_log( 'Payment status:' . $posted['payment_status'], false );
67
-		wpinv_error_log( 'IPN Type:' . $posted['txn_type'], false );
66
+		wpinv_error_log('Payment status:' . $posted['payment_status'], false);
67
+		wpinv_error_log('IPN Type:' . $posted['txn_type'], false);
68 68
 
69
-		if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
70
-			call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
71
-			wpinv_error_log( 'Done processing IPN', false );
72
-			wp_die( 'Processed', 200 );
69
+		if (method_exists($this, 'ipn_txn_' . $posted['txn_type'])) {
70
+			call_user_func(array($this, 'ipn_txn_' . $posted['txn_type']), $invoice, $posted);
71
+			wpinv_error_log('Done processing IPN', false);
72
+			wp_die('Processed', 200);
73 73
 		}
74 74
 
75
-		wpinv_error_log( 'Aborting, Unsupported IPN type:' . $posted['txn_type'], false );
76
-		wp_die( 'Unsupported IPN type', 200 );
75
+		wpinv_error_log('Aborting, Unsupported IPN type:' . $posted['txn_type'], false);
76
+		wp_die('Unsupported IPN type', 200);
77 77
 
78 78
 	}
79 79
 
@@ -83,22 +83,22 @@  discard block
 block discarded – undo
83 83
 	 * @param array $posted
84 84
 	 * @return WPInv_Invoice
85 85
 	 */
86
-	protected function get_ipn_invoice( $posted ) {
86
+	protected function get_ipn_invoice($posted) {
87 87
 
88
-		wpinv_error_log( 'Retrieving PayPal IPN Response Invoice', false );
88
+		wpinv_error_log('Retrieving PayPal IPN Response Invoice', false);
89 89
 
90
-		if ( ! empty( $posted['custom'] ) ) {
91
-			$invoice = new WPInv_Invoice( $posted['custom'] );
90
+		if (!empty($posted['custom'])) {
91
+			$invoice = new WPInv_Invoice($posted['custom']);
92 92
 
93
-			if ( $invoice->exists() ) {
94
-				wpinv_error_log( 'Found invoice #' . $invoice->get_number(), false );
93
+			if ($invoice->exists()) {
94
+				wpinv_error_log('Found invoice #' . $invoice->get_number(), false);
95 95
 				return $invoice;
96 96
 			}
97 97
 
98 98
 		}
99 99
 
100
-		wpinv_error_log( 'Could not retrieve the associated invoice.', false );
101
-		wp_die( 'Could not retrieve the associated invoice.', 200 );
100
+		wpinv_error_log('Could not retrieve the associated invoice.', false);
101
+		wp_die('Could not retrieve the associated invoice.', 200);
102 102
 	}
103 103
 
104 104
 	/**
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
 	 */
107 107
 	protected function validate_ipn() {
108 108
 
109
-		wpinv_error_log( 'Validating PayPal IPN response', false );
109
+		wpinv_error_log('Validating PayPal IPN response', false);
110 110
 
111 111
 		// Retrieve the associated invoice.
112
-		$posted  = wp_kses_post_deep( wp_unslash( $_POST ) );
113
-		$invoice = $this->get_ipn_invoice( $posted );
112
+		$posted  = wp_kses_post_deep(wp_unslash($_POST));
113
+		$invoice = $this->get_ipn_invoice($posted);
114 114
 
115
-		if ( $this->gateway->is_sandbox( $invoice ) ) {
116
-			wpinv_error_log( $posted, 'Invoice was processed in sandbox hence logging the posted data', false );
115
+		if ($this->gateway->is_sandbox($invoice)) {
116
+			wpinv_error_log($posted, 'Invoice was processed in sandbox hence logging the posted data', false);
117 117
 		}
118 118
 
119 119
 		// Validate the IPN.
@@ -130,20 +130,20 @@  discard block
 block discarded – undo
130 130
 		);
131 131
 
132 132
 		// Post back to get a response.
133
-		$response = wp_safe_remote_post( $this->gateway->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
133
+		$response = wp_safe_remote_post($this->gateway->is_sandbox($invoice) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params);
134 134
 
135 135
 		// Check to see if the request was valid.
136
-		if ( ! is_wp_error( $response ) && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
137
-			wpinv_error_log( 'Received valid response from PayPal IPN: ' . $response['body'], false );
136
+		if (!is_wp_error($response) && $response['response']['code'] < 300 && strstr($response['body'], 'VERIFIED')) {
137
+			wpinv_error_log('Received valid response from PayPal IPN: ' . $response['body'], false);
138 138
 			return true;
139 139
 		}
140 140
 
141
-		if ( is_wp_error( $response ) ) {
142
-			wpinv_error_log( $response->get_error_message(), 'Received invalid response from PayPal IPN' );
141
+		if (is_wp_error($response)) {
142
+			wpinv_error_log($response->get_error_message(), 'Received invalid response from PayPal IPN');
143 143
 			return false;
144 144
 		}
145 145
 
146
-		wpinv_error_log( $response['body'], 'Received invalid response from PayPal IPN' );
146
+		wpinv_error_log($response['body'], 'Received invalid response from PayPal IPN');
147 147
 		return false;
148 148
 
149 149
 	}
@@ -154,17 +154,17 @@  discard block
 block discarded – undo
154 154
 	 * @param WPInv_Invoice $invoice          Invoice object.
155 155
 	 * @param string   $currency currency to validate.
156 156
 	 */
157
-	protected function validate_ipn_currency( $invoice, $currency ) {
157
+	protected function validate_ipn_currency($invoice, $currency) {
158 158
 
159
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
159
+		if (strtolower($invoice->get_currency()) !== strtolower($currency)) {
160 160
 
161 161
 			/* translators: %s: currency code. */
162
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
162
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal currencies do not match (code %s).', 'invoicing'), $currency));
163 163
 
164
-			wpinv_error_log( "Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true );
164
+			wpinv_error_log("Currencies do not match: {$currency} instead of {$invoice->get_currency()}", 'IPN Error', __FILE__, __LINE__, true);
165 165
 		}
166 166
 
167
-		wpinv_error_log( $currency, 'Validated IPN Currency', false );
167
+		wpinv_error_log($currency, 'Validated IPN Currency', false);
168 168
 	}
169 169
 
170 170
 	/**
@@ -173,16 +173,16 @@  discard block
 block discarded – undo
173 173
 	 * @param WPInv_Invoice $invoice          Invoice object.
174 174
 	 * @param float   $amount amount to validate.
175 175
 	 */
176
-	protected function validate_ipn_amount( $invoice, $amount ) {
177
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
176
+	protected function validate_ipn_amount($invoice, $amount) {
177
+		if (number_format($invoice->get_total(), 2, '.', '') !== number_format($amount, 2, '.', '')) {
178 178
 
179 179
 			/* translators: %s: Amount. */
180
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
180
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal amounts do not match (gross %s).', 'invoicing'), $amount));
181 181
 
182
-			wpinv_error_log( "Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true );
182
+			wpinv_error_log("Amounts do not match: {$amount} instead of {$invoice->get_total()}", 'IPN Error', __FILE__, __LINE__, true);
183 183
 		}
184 184
 
185
-		wpinv_error_log( $amount, 'Validated IPN Amount', false );
185
+		wpinv_error_log($amount, 'Validated IPN Amount', false);
186 186
 	}
187 187
 
188 188
 	/**
@@ -191,19 +191,19 @@  discard block
 block discarded – undo
191 191
 	 * @param WPInv_Invoice $invoice          Invoice object.
192 192
 	 * @param string   $receiver_email Email to validate.
193 193
 	 */
194
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
195
-		$paypal_email = wpinv_get_option( 'paypal_email' );
194
+	protected function validate_ipn_receiver_email($invoice, $receiver_email) {
195
+		$paypal_email = wpinv_get_option('paypal_email');
196 196
 
197
-		if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
198
-			wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
197
+		if (strcasecmp(trim($receiver_email), trim($paypal_email)) !== 0) {
198
+			wpinv_record_gateway_error('IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}");
199 199
 
200 200
 			/* translators: %s: email address . */
201
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
201
+			$invoice->update_status('wpi-processing', sprintf(__('Validation error: PayPal IPN response from a different email address (%s).', 'invoicing'), $receiver_email));
202 202
 
203
-			return wpinv_error_log( "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true );
203
+			return wpinv_error_log("IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}", 'IPN Error', __FILE__, __LINE__, true);
204 204
 		}
205 205
 
206
-		wpinv_error_log( 'Validated PayPal Email', false );
206
+		wpinv_error_log('Validated PayPal Email', false);
207 207
 	}
208 208
 
209 209
 	/**
@@ -212,70 +212,70 @@  discard block
 block discarded – undo
212 212
 	 * @param WPInv_Invoice $invoice  Invoice object.
213 213
 	 * @param array    $posted Posted data.
214 214
 	 */
215
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
215
+	protected function ipn_txn_web_accept($invoice, $posted) {
216 216
 
217 217
 		// Collect payment details
218
-		$payment_status = strtolower( $posted['payment_status'] );
219
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
218
+		$payment_status = strtolower($posted['payment_status']);
219
+		$business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']);
220 220
 
221
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
222
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
221
+		$this->validate_ipn_receiver_email($invoice, $business_email);
222
+		$this->validate_ipn_currency($invoice, $posted['mc_currency']);
223 223
 
224 224
 		// Update the transaction id.
225
-		if ( ! empty( $posted['txn_id'] ) ) {
226
-			$invoice->set_transaction_id( wpinv_clean( $posted['txn_id'] ) );
225
+		if (!empty($posted['txn_id'])) {
226
+			$invoice->set_transaction_id(wpinv_clean($posted['txn_id']));
227 227
 			$invoice->save();
228 228
 		}
229 229
 
230
-		$invoice->add_system_note( __( 'Processing invoice IPN', 'invoicing' ) );
230
+		$invoice->add_system_note(__('Processing invoice IPN', 'invoicing'));
231 231
 
232 232
 		// Process a refund.
233
-		if ( $payment_status == 'refunded' || $payment_status == 'reversed' ) {
233
+		if ($payment_status == 'refunded' || $payment_status == 'reversed') {
234 234
 
235
-			update_post_meta( $invoice->get_id(), 'refunded_remotely', 1 );
235
+			update_post_meta($invoice->get_id(), 'refunded_remotely', 1);
236 236
 
237
-			if ( ! $invoice->is_refunded() ) {
238
-				$invoice->update_status( 'wpi-refunded', $posted['reason_code'] );
237
+			if (!$invoice->is_refunded()) {
238
+				$invoice->update_status('wpi-refunded', $posted['reason_code']);
239 239
 			}
240 240
 
241
-			return wpinv_error_log( $posted['reason_code'], false );
241
+			return wpinv_error_log($posted['reason_code'], false);
242 242
 		}
243 243
 
244 244
 		// Process payments.
245
-		if ( $payment_status == 'completed' ) {
245
+		if ($payment_status == 'completed') {
246 246
 
247
-			if ( $invoice->is_paid() && 'wpi_processing' != $invoice->get_status() ) {
248
-				return wpinv_error_log( 'Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false );
247
+			if ($invoice->is_paid() && 'wpi_processing' != $invoice->get_status()) {
248
+				return wpinv_error_log('Aborting, Invoice #' . $invoice->get_number() . ' is already paid.', false);
249 249
 			}
250 250
 
251
-			$this->validate_ipn_amount( $invoice, $posted['mc_gross'] );
251
+			$this->validate_ipn_amount($invoice, $posted['mc_gross']);
252 252
 
253 253
 			$note = '';
254 254
 
255
-			if ( ! empty( $posted['mc_fee'] ) ) {
256
-				$note = sprintf( __( 'PayPal Transaction Fee %s.', 'invoicing' ), sanitize_text_field( $posted['mc_fee'] ) );
255
+			if (!empty($posted['mc_fee'])) {
256
+				$note = sprintf(__('PayPal Transaction Fee %s.', 'invoicing'), sanitize_text_field($posted['mc_fee']));
257 257
 			}
258 258
 
259
-			if ( ! empty( $posted['payer_status'] ) ) {
260
-				$note = ' ' . sprintf( __( 'Buyer status %s.', 'invoicing' ), sanitize_text_field( $posted['payer_status'] ) );
259
+			if (!empty($posted['payer_status'])) {
260
+				$note = ' ' . sprintf(__('Buyer status %s.', 'invoicing'), sanitize_text_field($posted['payer_status']));
261 261
 			}
262 262
 
263
-			$invoice->mark_paid( ( ! empty( $posted['txn_id'] ) ? sanitize_text_field( $posted['txn_id'] ) : '' ), trim( $note ) );
264
-			return wpinv_error_log( 'Invoice marked as paid.', false );
263
+			$invoice->mark_paid((!empty($posted['txn_id']) ? sanitize_text_field($posted['txn_id']) : ''), trim($note));
264
+			return wpinv_error_log('Invoice marked as paid.', false);
265 265
 
266 266
 		}
267 267
 
268 268
 		// Pending payments.
269
-		if ( $payment_status == 'pending' ) {
269
+		if ($payment_status == 'pending') {
270 270
 
271 271
 			/* translators: %s: pending reason. */
272
-			$invoice->update_status( 'wpi-onhold', sprintf( __( 'Payment pending (%s).', 'invoicing' ), $posted['pending_reason'] ) );
272
+			$invoice->update_status('wpi-onhold', sprintf(__('Payment pending (%s).', 'invoicing'), $posted['pending_reason']));
273 273
 
274
-			return wpinv_error_log( 'Invoice marked as "payment held".', false );
274
+			return wpinv_error_log('Invoice marked as "payment held".', false);
275 275
 		}
276 276
 
277 277
 		/* translators: %s: payment status. */
278
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), sanitize_text_field( $posted['payment_status'] ) ) );
278
+		$invoice->update_status('wpi-failed', sprintf(__('Payment %s via IPN.', 'invoicing'), sanitize_text_field($posted['payment_status'])));
279 279
 
280 280
 	}
281 281
 
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
 	 * @param WPInv_Invoice $invoice  Invoice object.
286 286
 	 * @param array    $posted Posted data.
287 287
 	 */
288
-	protected function ipn_txn_cart( $invoice, $posted ) {
289
-		$this->ipn_txn_web_accept( $invoice, $posted );
288
+	protected function ipn_txn_cart($invoice, $posted) {
289
+		$this->ipn_txn_web_accept($invoice, $posted);
290 290
 	}
291 291
 
292 292
 	/**
@@ -295,43 +295,43 @@  discard block
 block discarded – undo
295 295
 	 * @param WPInv_Invoice $invoice  Invoice object.
296 296
 	 * @param array    $posted Posted data.
297 297
 	 */
298
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
298
+	protected function ipn_txn_subscr_signup($invoice, $posted) {
299 299
 
300
-		wpinv_error_log( 'Processing subscription signup', false );
300
+		wpinv_error_log('Processing subscription signup', false);
301 301
 
302 302
 		// Make sure the invoice has a subscription.
303
-		$subscription = getpaid_get_invoice_subscription( $invoice );
303
+		$subscription = getpaid_get_invoice_subscription($invoice);
304 304
 
305
-		if ( empty( $subscription ) ) {
306
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
305
+		if (empty($subscription)) {
306
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
307 307
 		}
308 308
 
309
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
309
+		wpinv_error_log('Found subscription #' . $subscription->get_id(), false);
310 310
 
311 311
 		// Validate the IPN.
312
-		$business_email = isset( $posted['business'] ) && is_email( $posted['business'] ) ? trim( $posted['business'] ) : trim( $posted['receiver_email'] );
313
-		$this->validate_ipn_receiver_email( $invoice, $business_email );
314
-		$this->validate_ipn_currency( $invoice, $posted['mc_currency'] );
312
+		$business_email = isset($posted['business']) && is_email($posted['business']) ? trim($posted['business']) : trim($posted['receiver_email']);
313
+		$this->validate_ipn_receiver_email($invoice, $business_email);
314
+		$this->validate_ipn_currency($invoice, $posted['mc_currency']);
315 315
 
316 316
 		// Activate the subscription.
317
-		$duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() );
318
-		$subscription->set_date_created( current_time( 'mysql' ) );
319
-		$subscription->set_expiration( date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ) );
320
-		$subscription->set_profile_id( sanitize_text_field( $posted['subscr_id'] ) );
317
+		$duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created());
318
+		$subscription->set_date_created(current_time('mysql'));
319
+		$subscription->set_expiration(date('Y-m-d H:i:s', (current_time('timestamp') + $duration)));
320
+		$subscription->set_profile_id(sanitize_text_field($posted['subscr_id']));
321 321
 		$subscription->activate();
322 322
 
323 323
 		// Set the transaction id.
324
-		if ( ! empty( $posted['txn_id'] ) ) {
325
-			$invoice->add_note( sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
326
-			$invoice->set_transaction_id( $posted['txn_id'] );
324
+		if (!empty($posted['txn_id'])) {
325
+			$invoice->add_note(sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $posted['txn_id']), false, false, true);
326
+			$invoice->set_transaction_id($posted['txn_id']);
327 327
 		}
328 328
 
329 329
 		// Update the payment status.
330 330
 		$invoice->mark_paid();
331 331
 
332
-		$invoice->add_note( sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
332
+		$invoice->add_note(sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true);
333 333
 
334
-		wpinv_error_log( 'Subscription started.', false );
334
+		wpinv_error_log('Subscription started.', false);
335 335
 	}
336 336
 
337 337
 	/**
@@ -340,45 +340,45 @@  discard block
 block discarded – undo
340 340
 	 * @param WPInv_Invoice $invoice  Invoice object.
341 341
 	 * @param array    $posted Posted data.
342 342
 	 */
343
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
343
+	protected function ipn_txn_subscr_payment($invoice, $posted) {
344 344
 
345 345
 		// Make sure the invoice has a subscription.
346
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
346
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
347 347
 
348
-		if ( empty( $subscription ) ) {
349
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
348
+		if (empty($subscription)) {
349
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
350 350
 		}
351 351
 
352
-		wpinv_error_log( 'Found subscription #' . $subscription->get_id(), false );
352
+		wpinv_error_log('Found subscription #' . $subscription->get_id(), false);
353 353
 
354 354
 		// PayPal sends a subscr_payment for the first payment too.
355
-		$date_completed = getpaid_format_date( $invoice->get_date_completed() );
356
-		$date_created   = getpaid_format_date( $invoice->get_date_created() );
357
-		$today_date     = getpaid_format_date( current_time( 'mysql' ) );
358
-		$payment_date   = getpaid_format_date( $posted['payment_date'] );
359
-		$subscribe_date = getpaid_format_date( $subscription->get_date_created() );
360
-		$dates          = array_filter( compact( 'date_completed', 'date_created', 'subscribe_date' ) );
355
+		$date_completed = getpaid_format_date($invoice->get_date_completed());
356
+		$date_created   = getpaid_format_date($invoice->get_date_created());
357
+		$today_date     = getpaid_format_date(current_time('mysql'));
358
+		$payment_date   = getpaid_format_date($posted['payment_date']);
359
+		$subscribe_date = getpaid_format_date($subscription->get_date_created());
360
+		$dates          = array_filter(compact('date_completed', 'date_created', 'subscribe_date'));
361 361
 
362
-		foreach( $dates as $date ) {
362
+		foreach ($dates as $date) {
363 363
 
364
-			if ( $date !== $today_date && $date !== $payment_date ) {
364
+			if ($date !== $today_date && $date !== $payment_date) {
365 365
 				continue;
366 366
 			}
367 367
 
368
-			if ( ! empty( $posted['txn_id'] ) ) {
369
-				$invoice->set_transaction_id( sanitize_text_field( $posted['txn_id'] ) );	
370
-				$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , sanitize_text_field( $posted['txn_id'] ) ), false, false, true );
368
+			if (!empty($posted['txn_id'])) {
369
+				$invoice->set_transaction_id(sanitize_text_field($posted['txn_id']));	
370
+				$invoice->add_note(wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), sanitize_text_field($posted['txn_id'])), false, false, true);
371 371
 			}
372 372
 
373 373
 			return $invoice->mark_paid();
374 374
 
375 375
 		}
376 376
 
377
-		wpinv_error_log( 'Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false );
377
+		wpinv_error_log('Processing subscription renewal payment for the invoice ' . $invoice->get_id(), false);
378 378
 
379 379
 		// Abort if the payment is already recorded.
380
-		if ( wpinv_get_id_by_transaction_id( $posted['txn_id'] ) ) {
381
-			return wpinv_error_log( 'Aborting, Transaction ' . $posted['txn_id'] .' has already been processed', false );
380
+		if (wpinv_get_id_by_transaction_id($posted['txn_id'])) {
381
+			return wpinv_error_log('Aborting, Transaction ' . $posted['txn_id'] . ' has already been processed', false);
382 382
 		}
383 383
 
384 384
 		$args = array(
@@ -386,17 +386,17 @@  discard block
 block discarded – undo
386 386
 			'gateway'        => $this->id,
387 387
 		);
388 388
 
389
-		$invoice = wpinv_get_invoice( $subscription->add_payment( $args ) );
389
+		$invoice = wpinv_get_invoice($subscription->add_payment($args));
390 390
 
391
-		if ( empty( $invoice ) ) {
391
+		if (empty($invoice)) {
392 392
 			return;
393 393
 		}
394 394
 
395
-		$invoice->add_note( wp_sprintf( __( 'PayPal Transaction ID: %s', 'invoicing' ) , $posted['txn_id'] ), false, false, true );
396
-		$invoice->add_note( wp_sprintf( __( 'PayPal Subscription ID: %s', 'invoicing' ) , $posted['subscr_id'] ), false, false, true );
395
+		$invoice->add_note(wp_sprintf(__('PayPal Transaction ID: %s', 'invoicing'), $posted['txn_id']), false, false, true);
396
+		$invoice->add_note(wp_sprintf(__('PayPal Subscription ID: %s', 'invoicing'), $posted['subscr_id']), false, false, true);
397 397
 
398 398
 		$subscription->renew();
399
-		wpinv_error_log( 'Subscription renewed.', false );
399
+		wpinv_error_log('Subscription renewed.', false);
400 400
 
401 401
 	}
402 402
 
@@ -405,18 +405,18 @@  discard block
 block discarded – undo
405 405
 	 *
406 406
 	 * @param WPInv_Invoice $invoice  Invoice object.
407 407
 	 */
408
-	protected function ipn_txn_subscr_cancel( $invoice ) {
408
+	protected function ipn_txn_subscr_cancel($invoice) {
409 409
 
410 410
 		// Make sure the invoice has a subscription.
411
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
411
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
412 412
 
413
-		if ( empty( $subscription ) ) {
414
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
413
+		if (empty($subscription)) {
414
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
415 415
 		}
416 416
 
417
-		wpinv_error_log( 'Processing subscription cancellation for the invoice ' . $invoice->get_id(), false );
417
+		wpinv_error_log('Processing subscription cancellation for the invoice ' . $invoice->get_id(), false);
418 418
 		$subscription->cancel();
419
-		wpinv_error_log( 'Subscription cancelled.', false );
419
+		wpinv_error_log('Subscription cancelled.', false);
420 420
 
421 421
 	}
422 422
 
@@ -426,18 +426,18 @@  discard block
 block discarded – undo
426 426
 	 * @param WPInv_Invoice $invoice  Invoice object.
427 427
 	 * @param array    $posted Posted data.
428 428
 	 */
429
-	protected function ipn_txn_subscr_eot( $invoice ) {
429
+	protected function ipn_txn_subscr_eot($invoice) {
430 430
 
431 431
 		// Make sure the invoice has a subscription.
432
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
432
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
433 433
 
434
-		if ( empty( $subscription ) ) {
435
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
434
+		if (empty($subscription)) {
435
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
436 436
 		}
437 437
 
438
-		wpinv_error_log( 'Processing subscription end of life for the invoice ' . $invoice->get_id(), false );
438
+		wpinv_error_log('Processing subscription end of life for the invoice ' . $invoice->get_id(), false);
439 439
 		$subscription->complete();
440
-		wpinv_error_log( 'Subscription completed.', false );
440
+		wpinv_error_log('Subscription completed.', false);
441 441
 
442 442
 	}
443 443
 
@@ -447,18 +447,18 @@  discard block
 block discarded – undo
447 447
 	 * @param WPInv_Invoice $invoice  Invoice object.
448 448
 	 * @param array    $posted Posted data.
449 449
 	 */
450
-	protected function ipn_txn_subscr_failed( $invoice ) {
450
+	protected function ipn_txn_subscr_failed($invoice) {
451 451
 
452 452
 		// Make sure the invoice has a subscription.
453
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
453
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
454 454
 
455
-		if ( empty( $subscription ) ) {
456
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
455
+		if (empty($subscription)) {
456
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
457 457
 		}
458 458
 
459
-		wpinv_error_log( 'Processing subscription payment failure for the invoice ' . $invoice->get_id(), false );
459
+		wpinv_error_log('Processing subscription payment failure for the invoice ' . $invoice->get_id(), false);
460 460
 		$subscription->failing();
461
-		wpinv_error_log( 'Subscription marked as failing.', false );
461
+		wpinv_error_log('Subscription marked as failing.', false);
462 462
 
463 463
 	}
464 464
 
@@ -468,18 +468,18 @@  discard block
 block discarded – undo
468 468
 	 * @param WPInv_Invoice $invoice  Invoice object.
469 469
 	 * @param array    $posted Posted data.
470 470
 	 */
471
-	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment( $invoice ) {
471
+	protected function ipn_txn_recurring_payment_suspended_due_to_max_failed_payment($invoice) {
472 472
 
473 473
 		// Make sure the invoice has a subscription.
474
-		$subscription = getpaid_subscriptions()->get_invoice_subscription( $invoice );
474
+		$subscription = getpaid_subscriptions()->get_invoice_subscription($invoice);
475 475
 
476
-		if ( empty( $subscription ) ) {
477
-			return wpinv_error_log( 'Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false );
476
+		if (empty($subscription)) {
477
+			return wpinv_error_log('Aborting, Subscription for the invoice ' . $invoice->get_id() . ' not found', false);
478 478
 		}
479 479
 
480
-		wpinv_error_log( 'Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false );
480
+		wpinv_error_log('Processing subscription cancellation due to max failed payment for the invoice ' . $invoice->get_id(), false);
481 481
 		$subscription->cancel();
482
-		wpinv_error_log( 'Subscription cancelled.', false );
482
+		wpinv_error_log('Subscription cancelled.', false);
483 483
 	}
484 484
 
485 485
 }
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports-export.php 2 patches
Indentation   +175 added lines, -175 removed lines patch added patch discarded remove patch
@@ -12,47 +12,47 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports_Export {
14 14
 
15
-	/**
16
-	 * Displays the reports tab.
17
-	 *
18
-	 */
19
-	public function display() {
20
-
21
-		echo "<div class='row mt-4' style='max-width: 920px;' >";
22
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
23
-			$this->display_post_type_export( $post_type );
24
-		}
25
-		$this->display_subscription_export();
26
-		echo "</div>";
27
-
28
-	}
29
-
30
-	/**
31
-	 * Retrieves the download url.
32
-	 *
33
-	 */
34
-	public function get_download_url( $post_type ) {
35
-
36
-		return wp_nonce_url(
37
-			add_query_arg(
38
-				array(
39
-					'getpaid-admin-action' => 'export_invoices',
40
-					'post_type'            => urlencode( $post_type ),
41
-				)
42
-			),
43
-			'getpaid-nonce',
44
-			'getpaid-nonce'
45
-		);
46
-
47
-	}
48
-
49
-	/**
50
-	 * Displays a single post type export card.
51
-	 *
52
-	 */
53
-	public function display_post_type_export( $post_type ) {
54
-
55
-		?>
15
+    /**
16
+     * Displays the reports tab.
17
+     *
18
+     */
19
+    public function display() {
20
+
21
+        echo "<div class='row mt-4' style='max-width: 920px;' >";
22
+        foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
23
+            $this->display_post_type_export( $post_type );
24
+        }
25
+        $this->display_subscription_export();
26
+        echo "</div>";
27
+
28
+    }
29
+
30
+    /**
31
+     * Retrieves the download url.
32
+     *
33
+     */
34
+    public function get_download_url( $post_type ) {
35
+
36
+        return wp_nonce_url(
37
+            add_query_arg(
38
+                array(
39
+                    'getpaid-admin-action' => 'export_invoices',
40
+                    'post_type'            => urlencode( $post_type ),
41
+                )
42
+            ),
43
+            'getpaid-nonce',
44
+            'getpaid-nonce'
45
+        );
46
+
47
+    }
48
+
49
+    /**
50
+     * Displays a single post type export card.
51
+     *
52
+     */
53
+    public function display_post_type_export( $post_type ) {
54
+
55
+        ?>
56 56
 
57 57
 		<div class="col-12 col-md-6">
58 58
 			<div class="card m-0 p-0" style="max-width:100%">
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 				<div class="card-header">
61 61
 					<strong>
62 62
 						<?php
63
-							printf(
64
-								__( 'Export %s', 'invoicing' ),
65
-								sanitize_text_field( getpaid_get_post_type_label( $post_type ) )
66
-							);
67
-						?>
63
+                            printf(
64
+                                __( 'Export %s', 'invoicing' ),
65
+                                sanitize_text_field( getpaid_get_post_type_label( $post_type ) )
66
+                            );
67
+                        ?>
68 68
 					</strong>
69 69
 				</div>
70 70
 
@@ -73,12 +73,12 @@  discard block
 block discarded – undo
73 73
 					<form method="post" action="<?php echo esc_url( $this->get_download_url( $post_type ) ); ?>">
74 74
 
75 75
 						<?php
76
-							$this->display_markup( $this->generate_from_date( $post_type ) );
77
-							$this->display_markup( $this->generate_to_date( $post_type ) );
78
-							$this->display_markup( $this->generate_post_status_select( $post_type ) );
79
-							$this->display_markup( $this->generate_file_type_select( $post_type ) );
80
-							submit_button( __( 'Download', 'invoicing' ) );
81
-						?>
76
+                            $this->display_markup( $this->generate_from_date( $post_type ) );
77
+                            $this->display_markup( $this->generate_to_date( $post_type ) );
78
+                            $this->display_markup( $this->generate_post_status_select( $post_type ) );
79
+                            $this->display_markup( $this->generate_file_type_select( $post_type ) );
80
+                            submit_button( __( 'Download', 'invoicing' ) );
81
+                        ?>
82 82
 
83 83
 					</form>
84 84
 
@@ -89,122 +89,122 @@  discard block
 block discarded – undo
89 89
 
90 90
 		<?php
91 91
 
92
-	}
93
-
94
-	/**
95
-	 * Generates the from date input field.
96
-	 *
97
-	 */
98
-	public function generate_from_date( $post_type ) {
99
-
100
-		return aui()->input(
101
-			array(
102
-				'name'       => 'from_date',
103
-				'id'         => esc_attr( "$post_type-from_date" ),
104
-				'placeholder'=> 'yy-mm-dd',
105
-				'label'      => __( 'From Date', 'invoicing' ),
106
-				'label_type' => 'vertical',
107
-				'label_class' => 'd-block',
108
-				'type'       => 'datepicker',
109
-			)
110
-		);
111
-
112
-	}
113
-
114
-	/**
115
-	 * Generates the to date input field.
116
-	 *
117
-	 */
118
-	public function generate_to_date( $post_type ) {
119
-
120
-		return aui()->input(
121
-			array(
122
-				'name'       => 'to_date',
123
-				'id'         => esc_attr( "$post_type-to_date" ),
124
-				'placeholder'=> 'yy-mm-dd',
125
-				'label'      => __( 'To Date', 'invoicing' ),
126
-				'label_type' => 'vertical',
127
-				'label_class' => 'd-block',
128
-				'type'       => 'datepicker',
129
-			)
130
-		);
131
-
132
-	}
133
-
134
-	/**
135
-	 * Generates the to post status select field.
136
-	 *
137
-	 */
138
-	public function generate_post_status_select( $post_type ) {
139
-
140
-		if ( 'subscriptions' === $post_type ) {
141
-			$options = getpaid_get_subscription_statuses();
142
-		} else {
143
-			$options = wpinv_get_invoice_statuses( true, false, $post_type );
144
-		}
145
-
146
-		return aui()->select(
147
-			array(
148
-				'name'        => 'status',
149
-				'id'          => esc_attr( "$post_type-status" ),
150
-				'placeholder' => __( 'All Statuses', 'invoicing' ),
151
-				'label'       => __( 'Status', 'invoicing' ),
152
-				'label_type'  => 'vertical',
153
-				'label_class' => 'd-block',
154
-				'options'     => $options,
155
-			)
156
-		);
157
-
158
-	}
159
-
160
-	/**
161
-	 * Generates the to file type select field.
162
-	 *
163
-	 */
164
-	public function generate_file_type_select( $post_type ) {
165
-
166
-		return aui()->select(
167
-			array(
168
-				'name'        => 'file_type',
169
-				'id'          => esc_attr( "$post_type-file_type" ),
170
-				'placeholder' => __( 'Select File Type', 'invoicing' ),
171
-				'label'       => __( 'Export File', 'invoicing' ),
172
-				'label_type'  => 'vertical',
173
-				'label_class' => 'd-block',
174
-				'options'     => array(
175
-					'csv'  => __( 'CSV', 'invoicing' ),
176
-					'xml'  => __( 'XML', 'invoicing' ),
177
-					'json' => __( 'JSON', 'invoicing' ),
178
-				),
179
-			)
180
-		);
181
-
182
-	}
183
-
184
-	/**
185
-	 * Displays a field's markup.
186
-	 *
187
-	 */
188
-	public function display_markup( $markup ) {
189
-
190
-		echo str_replace(
191
-			array(
192
-				'form-control',
193
-				'custom-select'
194
-			),
195
-			'regular-text',
196
-			$markup
197
-		);
198
-
199
-	}
200
-
201
-	/**
202
-	 * Displays a subscription export card.
203
-	 *
204
-	 */
205
-	public function display_subscription_export() {
206
-
207
-		?>
92
+    }
93
+
94
+    /**
95
+     * Generates the from date input field.
96
+     *
97
+     */
98
+    public function generate_from_date( $post_type ) {
99
+
100
+        return aui()->input(
101
+            array(
102
+                'name'       => 'from_date',
103
+                'id'         => esc_attr( "$post_type-from_date" ),
104
+                'placeholder'=> 'yy-mm-dd',
105
+                'label'      => __( 'From Date', 'invoicing' ),
106
+                'label_type' => 'vertical',
107
+                'label_class' => 'd-block',
108
+                'type'       => 'datepicker',
109
+            )
110
+        );
111
+
112
+    }
113
+
114
+    /**
115
+     * Generates the to date input field.
116
+     *
117
+     */
118
+    public function generate_to_date( $post_type ) {
119
+
120
+        return aui()->input(
121
+            array(
122
+                'name'       => 'to_date',
123
+                'id'         => esc_attr( "$post_type-to_date" ),
124
+                'placeholder'=> 'yy-mm-dd',
125
+                'label'      => __( 'To Date', 'invoicing' ),
126
+                'label_type' => 'vertical',
127
+                'label_class' => 'd-block',
128
+                'type'       => 'datepicker',
129
+            )
130
+        );
131
+
132
+    }
133
+
134
+    /**
135
+     * Generates the to post status select field.
136
+     *
137
+     */
138
+    public function generate_post_status_select( $post_type ) {
139
+
140
+        if ( 'subscriptions' === $post_type ) {
141
+            $options = getpaid_get_subscription_statuses();
142
+        } else {
143
+            $options = wpinv_get_invoice_statuses( true, false, $post_type );
144
+        }
145
+
146
+        return aui()->select(
147
+            array(
148
+                'name'        => 'status',
149
+                'id'          => esc_attr( "$post_type-status" ),
150
+                'placeholder' => __( 'All Statuses', 'invoicing' ),
151
+                'label'       => __( 'Status', 'invoicing' ),
152
+                'label_type'  => 'vertical',
153
+                'label_class' => 'd-block',
154
+                'options'     => $options,
155
+            )
156
+        );
157
+
158
+    }
159
+
160
+    /**
161
+     * Generates the to file type select field.
162
+     *
163
+     */
164
+    public function generate_file_type_select( $post_type ) {
165
+
166
+        return aui()->select(
167
+            array(
168
+                'name'        => 'file_type',
169
+                'id'          => esc_attr( "$post_type-file_type" ),
170
+                'placeholder' => __( 'Select File Type', 'invoicing' ),
171
+                'label'       => __( 'Export File', 'invoicing' ),
172
+                'label_type'  => 'vertical',
173
+                'label_class' => 'd-block',
174
+                'options'     => array(
175
+                    'csv'  => __( 'CSV', 'invoicing' ),
176
+                    'xml'  => __( 'XML', 'invoicing' ),
177
+                    'json' => __( 'JSON', 'invoicing' ),
178
+                ),
179
+            )
180
+        );
181
+
182
+    }
183
+
184
+    /**
185
+     * Displays a field's markup.
186
+     *
187
+     */
188
+    public function display_markup( $markup ) {
189
+
190
+        echo str_replace(
191
+            array(
192
+                'form-control',
193
+                'custom-select'
194
+            ),
195
+            'regular-text',
196
+            $markup
197
+        );
198
+
199
+    }
200
+
201
+    /**
202
+     * Displays a subscription export card.
203
+     *
204
+     */
205
+    public function display_subscription_export() {
206
+
207
+        ?>
208 208
 
209 209
 		<div class="col-12 col-md-6">
210 210
 			<div class="card m-0 p-0" style="max-width:100%">
@@ -220,12 +220,12 @@  discard block
 block discarded – undo
220 220
 					<form method="post" action="<?php echo esc_url( $this->get_download_url( 'subscriptions' ) ); ?>">
221 221
 
222 222
 						<?php
223
-							$this->display_markup( $this->generate_from_date( 'subscriptions' ) );
224
-							$this->display_markup( $this->generate_to_date( 'subscriptions' ) );
225
-							$this->display_markup( $this->generate_post_status_select( 'subscriptions' ) );
226
-							$this->display_markup( $this->generate_file_type_select( 'subscriptions' ) );
227
-							submit_button( __( 'Download', 'invoicing' ) );
228
-						?>
223
+                            $this->display_markup( $this->generate_from_date( 'subscriptions' ) );
224
+                            $this->display_markup( $this->generate_to_date( 'subscriptions' ) );
225
+                            $this->display_markup( $this->generate_post_status_select( 'subscriptions' ) );
226
+                            $this->display_markup( $this->generate_file_type_select( 'subscriptions' ) );
227
+                            submit_button( __( 'Download', 'invoicing' ) );
228
+                        ?>
229 229
 
230 230
 					</form>
231 231
 
@@ -236,6 +236,6 @@  discard block
 block discarded – undo
236 236
 
237 237
 		<?php
238 238
 
239
-	}
239
+    }
240 240
 
241 241
 }
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports_Export Class.
@@ -19,8 +19,8 @@  discard block
 block discarded – undo
19 19
 	public function display() {
20 20
 
21 21
 		echo "<div class='row mt-4' style='max-width: 920px;' >";
22
-		foreach ( array_keys( getpaid_get_invoice_post_types() ) as $post_type ) {
23
-			$this->display_post_type_export( $post_type );
22
+		foreach (array_keys(getpaid_get_invoice_post_types()) as $post_type) {
23
+			$this->display_post_type_export($post_type);
24 24
 		}
25 25
 		$this->display_subscription_export();
26 26
 		echo "</div>";
@@ -31,13 +31,13 @@  discard block
 block discarded – undo
31 31
 	 * Retrieves the download url.
32 32
 	 *
33 33
 	 */
34
-	public function get_download_url( $post_type ) {
34
+	public function get_download_url($post_type) {
35 35
 
36 36
 		return wp_nonce_url(
37 37
 			add_query_arg(
38 38
 				array(
39 39
 					'getpaid-admin-action' => 'export_invoices',
40
-					'post_type'            => urlencode( $post_type ),
40
+					'post_type'            => urlencode($post_type),
41 41
 				)
42 42
 			),
43 43
 			'getpaid-nonce',
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * Displays a single post type export card.
51 51
 	 *
52 52
 	 */
53
-	public function display_post_type_export( $post_type ) {
53
+	public function display_post_type_export($post_type) {
54 54
 
55 55
 		?>
56 56
 
@@ -61,8 +61,8 @@  discard block
 block discarded – undo
61 61
 					<strong>
62 62
 						<?php
63 63
 							printf(
64
-								__( 'Export %s', 'invoicing' ),
65
-								sanitize_text_field( getpaid_get_post_type_label( $post_type ) )
64
+								__('Export %s', 'invoicing'),
65
+								sanitize_text_field(getpaid_get_post_type_label($post_type))
66 66
 							);
67 67
 						?>
68 68
 					</strong>
@@ -70,14 +70,14 @@  discard block
 block discarded – undo
70 70
 
71 71
 				<div class="card-body">
72 72
 
73
-					<form method="post" action="<?php echo esc_url( $this->get_download_url( $post_type ) ); ?>">
73
+					<form method="post" action="<?php echo esc_url($this->get_download_url($post_type)); ?>">
74 74
 
75 75
 						<?php
76
-							$this->display_markup( $this->generate_from_date( $post_type ) );
77
-							$this->display_markup( $this->generate_to_date( $post_type ) );
78
-							$this->display_markup( $this->generate_post_status_select( $post_type ) );
79
-							$this->display_markup( $this->generate_file_type_select( $post_type ) );
80
-							submit_button( __( 'Download', 'invoicing' ) );
76
+							$this->display_markup($this->generate_from_date($post_type));
77
+							$this->display_markup($this->generate_to_date($post_type));
78
+							$this->display_markup($this->generate_post_status_select($post_type));
79
+							$this->display_markup($this->generate_file_type_select($post_type));
80
+							submit_button(__('Download', 'invoicing'));
81 81
 						?>
82 82
 
83 83
 					</form>
@@ -95,14 +95,14 @@  discard block
 block discarded – undo
95 95
 	 * Generates the from date input field.
96 96
 	 *
97 97
 	 */
98
-	public function generate_from_date( $post_type ) {
98
+	public function generate_from_date($post_type) {
99 99
 
100 100
 		return aui()->input(
101 101
 			array(
102 102
 				'name'       => 'from_date',
103
-				'id'         => esc_attr( "$post_type-from_date" ),
103
+				'id'         => esc_attr("$post_type-from_date"),
104 104
 				'placeholder'=> 'yy-mm-dd',
105
-				'label'      => __( 'From Date', 'invoicing' ),
105
+				'label'      => __('From Date', 'invoicing'),
106 106
 				'label_type' => 'vertical',
107 107
 				'label_class' => 'd-block',
108 108
 				'type'       => 'datepicker',
@@ -115,14 +115,14 @@  discard block
 block discarded – undo
115 115
 	 * Generates the to date input field.
116 116
 	 *
117 117
 	 */
118
-	public function generate_to_date( $post_type ) {
118
+	public function generate_to_date($post_type) {
119 119
 
120 120
 		return aui()->input(
121 121
 			array(
122 122
 				'name'       => 'to_date',
123
-				'id'         => esc_attr( "$post_type-to_date" ),
123
+				'id'         => esc_attr("$post_type-to_date"),
124 124
 				'placeholder'=> 'yy-mm-dd',
125
-				'label'      => __( 'To Date', 'invoicing' ),
125
+				'label'      => __('To Date', 'invoicing'),
126 126
 				'label_type' => 'vertical',
127 127
 				'label_class' => 'd-block',
128 128
 				'type'       => 'datepicker',
@@ -135,20 +135,20 @@  discard block
 block discarded – undo
135 135
 	 * Generates the to post status select field.
136 136
 	 *
137 137
 	 */
138
-	public function generate_post_status_select( $post_type ) {
138
+	public function generate_post_status_select($post_type) {
139 139
 
140
-		if ( 'subscriptions' === $post_type ) {
140
+		if ('subscriptions' === $post_type) {
141 141
 			$options = getpaid_get_subscription_statuses();
142 142
 		} else {
143
-			$options = wpinv_get_invoice_statuses( true, false, $post_type );
143
+			$options = wpinv_get_invoice_statuses(true, false, $post_type);
144 144
 		}
145 145
 
146 146
 		return aui()->select(
147 147
 			array(
148 148
 				'name'        => 'status',
149
-				'id'          => esc_attr( "$post_type-status" ),
150
-				'placeholder' => __( 'All Statuses', 'invoicing' ),
151
-				'label'       => __( 'Status', 'invoicing' ),
149
+				'id'          => esc_attr("$post_type-status"),
150
+				'placeholder' => __('All Statuses', 'invoicing'),
151
+				'label'       => __('Status', 'invoicing'),
152 152
 				'label_type'  => 'vertical',
153 153
 				'label_class' => 'd-block',
154 154
 				'options'     => $options,
@@ -161,20 +161,20 @@  discard block
 block discarded – undo
161 161
 	 * Generates the to file type select field.
162 162
 	 *
163 163
 	 */
164
-	public function generate_file_type_select( $post_type ) {
164
+	public function generate_file_type_select($post_type) {
165 165
 
166 166
 		return aui()->select(
167 167
 			array(
168 168
 				'name'        => 'file_type',
169
-				'id'          => esc_attr( "$post_type-file_type" ),
170
-				'placeholder' => __( 'Select File Type', 'invoicing' ),
171
-				'label'       => __( 'Export File', 'invoicing' ),
169
+				'id'          => esc_attr("$post_type-file_type"),
170
+				'placeholder' => __('Select File Type', 'invoicing'),
171
+				'label'       => __('Export File', 'invoicing'),
172 172
 				'label_type'  => 'vertical',
173 173
 				'label_class' => 'd-block',
174 174
 				'options'     => array(
175
-					'csv'  => __( 'CSV', 'invoicing' ),
176
-					'xml'  => __( 'XML', 'invoicing' ),
177
-					'json' => __( 'JSON', 'invoicing' ),
175
+					'csv'  => __('CSV', 'invoicing'),
176
+					'xml'  => __('XML', 'invoicing'),
177
+					'json' => __('JSON', 'invoicing'),
178 178
 				),
179 179
 			)
180 180
 		);
@@ -185,7 +185,7 @@  discard block
 block discarded – undo
185 185
 	 * Displays a field's markup.
186 186
 	 *
187 187
 	 */
188
-	public function display_markup( $markup ) {
188
+	public function display_markup($markup) {
189 189
 
190 190
 		echo str_replace(
191 191
 			array(
@@ -211,20 +211,20 @@  discard block
 block discarded – undo
211 211
 
212 212
 				<div class="card-header">
213 213
 					<strong>
214
-						<?php _e( 'Export Subscriptions', 'invoicing' ); ?>
214
+						<?php _e('Export Subscriptions', 'invoicing'); ?>
215 215
 					</strong>
216 216
 				</div>
217 217
 
218 218
 				<div class="card-body">
219 219
 
220
-					<form method="post" action="<?php echo esc_url( $this->get_download_url( 'subscriptions' ) ); ?>">
220
+					<form method="post" action="<?php echo esc_url($this->get_download_url('subscriptions')); ?>">
221 221
 
222 222
 						<?php
223
-							$this->display_markup( $this->generate_from_date( 'subscriptions' ) );
224
-							$this->display_markup( $this->generate_to_date( 'subscriptions' ) );
225
-							$this->display_markup( $this->generate_post_status_select( 'subscriptions' ) );
226
-							$this->display_markup( $this->generate_file_type_select( 'subscriptions' ) );
227
-							submit_button( __( 'Download', 'invoicing' ) );
223
+							$this->display_markup($this->generate_from_date('subscriptions'));
224
+							$this->display_markup($this->generate_to_date('subscriptions'));
225
+							$this->display_markup($this->generate_post_status_select('subscriptions'));
226
+							$this->display_markup($this->generate_file_type_select('subscriptions'));
227
+							submit_button(__('Download', 'invoicing'));
228 228
 						?>
229 229
 
230 230
 					</form>
Please login to merge, or discard this patch.
includes/reports/class-getpaid-subscription-exporter.php 2 patches
Indentation   +172 added lines, -172 removed lines patch added patch discarded remove patch
@@ -12,177 +12,177 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Subscription_Exporter extends GetPaid_Graph_Downloader {
14 14
 
15
-	/**
16
-	 * Retrieves subscription query args.
17
-	 * 
18
-	 * @param array $args Args to search for.
19
-	 * @return array
20
-	 */
21
-	public function get_subscription_query_args( $args ) {
22
-
23
-		$query_args = array(
24
-			'status'      => 'all',
25
-			'number'      => -1,
26
-			'count_total' => false,
27
-			'fields'      => 'all',
28
-		);
29
-
30
-		if ( ! empty( $args['status'] ) && in_array( $args['status'], array_keys( getpaid_get_subscription_statuses() ), true ) ) {
31
-			$query_args['status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
32
-		}
33
-
34
-		$date_query = array();
35
-		if ( ! empty( $args['to_date'] ) ) {
36
-			$date_query['before'] = wpinv_clean( $args['to_date'] );
37
-		}
38
-
39
-		if ( ! empty( $args['from_date'] ) ) {
40
-			$date_query['after'] = wpinv_clean( $args['from_date'] );
41
-		}
42
-
43
-		if ( ! empty( $date_query ) ) {
44
-			$date_query['inclusive']          = true;
45
-			$query_args['date_created_query'] = array( $date_query );
46
-		}
47
-
48
-		return $query_args;
49
-	}
50
-
51
-	/**
52
-	 * Retrieves subscriptions.
53
-	 * 
54
-	 * @param array $query_args GetPaid_Subscriptions_Query args.
55
-	 * @return WPInv_Subscription[]
56
-	 */
57
-	public function get_subscriptions( $query_args ) {
58
-
59
-		// Get subscriptions.
60
-		$subscriptions = new GetPaid_Subscriptions_Query( $query_args );
61
-
62
-		// Prepare the results.
63
-		return $subscriptions->get_results();
64
-
65
-	}
66
-
67
-	/**
68
-	 * Handles the actual download.
69
-	 *
70
-	 */
71
-	public function export( $post_type, $args ) {
72
-
73
-		$subscriptions = $this->get_subscriptions( $this->get_subscription_query_args( $args ) );
74
-		$stream        = $this->prepare_output();
75
-		$headers       = $this->get_export_fields();
76
-		$file_type     = $this->prepare_file_type( 'subscriptions' );
77
-
78
-		if ( 'csv' == $file_type ) {
79
-			$this->download_csv( $subscriptions, $stream, $headers );
80
-		} else if( 'xml' == $file_type ) {
81
-			$this->download_xml( $subscriptions, $stream, $headers );
82
-		} else {
83
-			$this->download_json( $subscriptions, $stream, $headers );
84
-		}
85
-
86
-		fclose( $stream );
87
-		exit;
88
-	}
89
-
90
-	/**
91
-	 * Prepares a single subscription for download.
92
-	 *
93
-	 * @param WPInv_Subscription $subscription The subscription to prepare..
94
-	 * @param array $fields The fields to stream.
95
-	 * @since       1.0.19
96
-	 * @return array
97
-	 */
98
-	public function prepare_row( $subscription, $fields ) {
99
-
100
-		$prepared      = array();
101
-		$amount_fields = $this->get_amount_fields();
102
-		$invoice       = $subscription->get_parent_payment();
103
-
104
-		foreach ( $fields as $field ) {
105
-
106
-			$value  = '';
107
-			$method = "get_$field";
108
-
109
-			if ( 0 === stripos( $field, 'customer' ) || 'currency' === $field ) {
110
-
111
-				if ( method_exists( $invoice, $method ) ) {
112
-					$value  = $invoice->$method();
113
-				}
114
-
115
-			} else if ( method_exists( $subscription, $method ) ) {
116
-				$value  = $subscription->$method();
117
-			}
118
-
119
-			if ( in_array( $field, $amount_fields ) ) {
120
-				$value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
121
-			}
122
-
123
-			$prepared[ $field ] = wpinv_clean( $value );
124
-
125
-		}
126
-
127
-		return $prepared;
128
-	}
129
-
130
-	/**
131
-	 * Retrieves export fields.
132
-	 *
133
-	 * @since       1.0.19
134
-	 * @return array
135
-	 */
136
-	public function get_export_fields() {
137
-
138
-		$fields = array(
139
-			'id',
140
-			'currency',
141
-			'initial_amount',
142
-			'recurring_amount',
143
-			'trial_period',
144
-			'frequency',
145
-			'period',
146
-			'bill_times',
147
-			'parent_payment_id',
148
-			'profile_id',
149
-			'product_id',
150
-			'status',
151
-			'date_created',
152
-			'date_expires',
153
-
154
-			'customer_id',
155
-			'customer_first_name',
156
-			'customer_last_name',
157
-			'customer_phone',
158
-			'customer_email',
159
-			'customer_country',
160
-			'customer_city',
161
-			'customer_state',
162
-			'customer_zip',
163
-			'customer_company',
164
-			'customer_vat_number',
165
-			'customer_address',
166
-
167
-    	);
168
-
169
-		return apply_filters( 'getpaid_subscription_exporter_get_fields', $fields );
170
-	}
171
-
172
-	/**
173
-	 * Retrieves amount fields.
174
-	 *
175
-	 * @since       1.0.19
176
-	 * @return array
177
-	 */
178
-	public function get_amount_fields() {
179
-
180
-		$fields = array(
181
-			'initial_amount',
182
-			'recurring_amount'
183
-    	);
184
-
185
-		return apply_filters( 'getpaid_subscription_exporter_get_amount_fields', $fields );
186
-	}
15
+    /**
16
+     * Retrieves subscription query args.
17
+     * 
18
+     * @param array $args Args to search for.
19
+     * @return array
20
+     */
21
+    public function get_subscription_query_args( $args ) {
22
+
23
+        $query_args = array(
24
+            'status'      => 'all',
25
+            'number'      => -1,
26
+            'count_total' => false,
27
+            'fields'      => 'all',
28
+        );
29
+
30
+        if ( ! empty( $args['status'] ) && in_array( $args['status'], array_keys( getpaid_get_subscription_statuses() ), true ) ) {
31
+            $query_args['status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
32
+        }
33
+
34
+        $date_query = array();
35
+        if ( ! empty( $args['to_date'] ) ) {
36
+            $date_query['before'] = wpinv_clean( $args['to_date'] );
37
+        }
38
+
39
+        if ( ! empty( $args['from_date'] ) ) {
40
+            $date_query['after'] = wpinv_clean( $args['from_date'] );
41
+        }
42
+
43
+        if ( ! empty( $date_query ) ) {
44
+            $date_query['inclusive']          = true;
45
+            $query_args['date_created_query'] = array( $date_query );
46
+        }
47
+
48
+        return $query_args;
49
+    }
50
+
51
+    /**
52
+     * Retrieves subscriptions.
53
+     * 
54
+     * @param array $query_args GetPaid_Subscriptions_Query args.
55
+     * @return WPInv_Subscription[]
56
+     */
57
+    public function get_subscriptions( $query_args ) {
58
+
59
+        // Get subscriptions.
60
+        $subscriptions = new GetPaid_Subscriptions_Query( $query_args );
61
+
62
+        // Prepare the results.
63
+        return $subscriptions->get_results();
64
+
65
+    }
66
+
67
+    /**
68
+     * Handles the actual download.
69
+     *
70
+     */
71
+    public function export( $post_type, $args ) {
72
+
73
+        $subscriptions = $this->get_subscriptions( $this->get_subscription_query_args( $args ) );
74
+        $stream        = $this->prepare_output();
75
+        $headers       = $this->get_export_fields();
76
+        $file_type     = $this->prepare_file_type( 'subscriptions' );
77
+
78
+        if ( 'csv' == $file_type ) {
79
+            $this->download_csv( $subscriptions, $stream, $headers );
80
+        } else if( 'xml' == $file_type ) {
81
+            $this->download_xml( $subscriptions, $stream, $headers );
82
+        } else {
83
+            $this->download_json( $subscriptions, $stream, $headers );
84
+        }
85
+
86
+        fclose( $stream );
87
+        exit;
88
+    }
89
+
90
+    /**
91
+     * Prepares a single subscription for download.
92
+     *
93
+     * @param WPInv_Subscription $subscription The subscription to prepare..
94
+     * @param array $fields The fields to stream.
95
+     * @since       1.0.19
96
+     * @return array
97
+     */
98
+    public function prepare_row( $subscription, $fields ) {
99
+
100
+        $prepared      = array();
101
+        $amount_fields = $this->get_amount_fields();
102
+        $invoice       = $subscription->get_parent_payment();
103
+
104
+        foreach ( $fields as $field ) {
105
+
106
+            $value  = '';
107
+            $method = "get_$field";
108
+
109
+            if ( 0 === stripos( $field, 'customer' ) || 'currency' === $field ) {
110
+
111
+                if ( method_exists( $invoice, $method ) ) {
112
+                    $value  = $invoice->$method();
113
+                }
114
+
115
+            } else if ( method_exists( $subscription, $method ) ) {
116
+                $value  = $subscription->$method();
117
+            }
118
+
119
+            if ( in_array( $field, $amount_fields ) ) {
120
+                $value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
121
+            }
122
+
123
+            $prepared[ $field ] = wpinv_clean( $value );
124
+
125
+        }
126
+
127
+        return $prepared;
128
+    }
129
+
130
+    /**
131
+     * Retrieves export fields.
132
+     *
133
+     * @since       1.0.19
134
+     * @return array
135
+     */
136
+    public function get_export_fields() {
137
+
138
+        $fields = array(
139
+            'id',
140
+            'currency',
141
+            'initial_amount',
142
+            'recurring_amount',
143
+            'trial_period',
144
+            'frequency',
145
+            'period',
146
+            'bill_times',
147
+            'parent_payment_id',
148
+            'profile_id',
149
+            'product_id',
150
+            'status',
151
+            'date_created',
152
+            'date_expires',
153
+
154
+            'customer_id',
155
+            'customer_first_name',
156
+            'customer_last_name',
157
+            'customer_phone',
158
+            'customer_email',
159
+            'customer_country',
160
+            'customer_city',
161
+            'customer_state',
162
+            'customer_zip',
163
+            'customer_company',
164
+            'customer_vat_number',
165
+            'customer_address',
166
+
167
+        );
168
+
169
+        return apply_filters( 'getpaid_subscription_exporter_get_fields', $fields );
170
+    }
171
+
172
+    /**
173
+     * Retrieves amount fields.
174
+     *
175
+     * @since       1.0.19
176
+     * @return array
177
+     */
178
+    public function get_amount_fields() {
179
+
180
+        $fields = array(
181
+            'initial_amount',
182
+            'recurring_amount'
183
+        );
184
+
185
+        return apply_filters( 'getpaid_subscription_exporter_get_amount_fields', $fields );
186
+    }
187 187
 
188 188
 }
Please login to merge, or discard this patch.
Spacing   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Subscription_Exporter Class.
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @param array $args Args to search for.
19 19
 	 * @return array
20 20
 	 */
21
-	public function get_subscription_query_args( $args ) {
21
+	public function get_subscription_query_args($args) {
22 22
 
23 23
 		$query_args = array(
24 24
 			'status'      => 'all',
@@ -27,22 +27,22 @@  discard block
 block discarded – undo
27 27
 			'fields'      => 'all',
28 28
 		);
29 29
 
30
-		if ( ! empty( $args['status'] ) && in_array( $args['status'], array_keys( getpaid_get_subscription_statuses() ), true ) ) {
31
-			$query_args['status'] = wpinv_clean( wpinv_parse_list( $args['status'] ) );
30
+		if (!empty($args['status']) && in_array($args['status'], array_keys(getpaid_get_subscription_statuses()), true)) {
31
+			$query_args['status'] = wpinv_clean(wpinv_parse_list($args['status']));
32 32
 		}
33 33
 
34 34
 		$date_query = array();
35
-		if ( ! empty( $args['to_date'] ) ) {
36
-			$date_query['before'] = wpinv_clean( $args['to_date'] );
35
+		if (!empty($args['to_date'])) {
36
+			$date_query['before'] = wpinv_clean($args['to_date']);
37 37
 		}
38 38
 
39
-		if ( ! empty( $args['from_date'] ) ) {
40
-			$date_query['after'] = wpinv_clean( $args['from_date'] );
39
+		if (!empty($args['from_date'])) {
40
+			$date_query['after'] = wpinv_clean($args['from_date']);
41 41
 		}
42 42
 
43
-		if ( ! empty( $date_query ) ) {
43
+		if (!empty($date_query)) {
44 44
 			$date_query['inclusive']          = true;
45
-			$query_args['date_created_query'] = array( $date_query );
45
+			$query_args['date_created_query'] = array($date_query);
46 46
 		}
47 47
 
48 48
 		return $query_args;
@@ -54,10 +54,10 @@  discard block
 block discarded – undo
54 54
 	 * @param array $query_args GetPaid_Subscriptions_Query args.
55 55
 	 * @return WPInv_Subscription[]
56 56
 	 */
57
-	public function get_subscriptions( $query_args ) {
57
+	public function get_subscriptions($query_args) {
58 58
 
59 59
 		// Get subscriptions.
60
-		$subscriptions = new GetPaid_Subscriptions_Query( $query_args );
60
+		$subscriptions = new GetPaid_Subscriptions_Query($query_args);
61 61
 
62 62
 		// Prepare the results.
63 63
 		return $subscriptions->get_results();
@@ -68,22 +68,22 @@  discard block
 block discarded – undo
68 68
 	 * Handles the actual download.
69 69
 	 *
70 70
 	 */
71
-	public function export( $post_type, $args ) {
71
+	public function export($post_type, $args) {
72 72
 
73
-		$subscriptions = $this->get_subscriptions( $this->get_subscription_query_args( $args ) );
73
+		$subscriptions = $this->get_subscriptions($this->get_subscription_query_args($args));
74 74
 		$stream        = $this->prepare_output();
75 75
 		$headers       = $this->get_export_fields();
76
-		$file_type     = $this->prepare_file_type( 'subscriptions' );
76
+		$file_type     = $this->prepare_file_type('subscriptions');
77 77
 
78
-		if ( 'csv' == $file_type ) {
79
-			$this->download_csv( $subscriptions, $stream, $headers );
80
-		} else if( 'xml' == $file_type ) {
81
-			$this->download_xml( $subscriptions, $stream, $headers );
78
+		if ('csv' == $file_type) {
79
+			$this->download_csv($subscriptions, $stream, $headers);
80
+		} else if ('xml' == $file_type) {
81
+			$this->download_xml($subscriptions, $stream, $headers);
82 82
 		} else {
83
-			$this->download_json( $subscriptions, $stream, $headers );
83
+			$this->download_json($subscriptions, $stream, $headers);
84 84
 		}
85 85
 
86
-		fclose( $stream );
86
+		fclose($stream);
87 87
 		exit;
88 88
 	}
89 89
 
@@ -95,32 +95,32 @@  discard block
 block discarded – undo
95 95
 	 * @since       1.0.19
96 96
 	 * @return array
97 97
 	 */
98
-	public function prepare_row( $subscription, $fields ) {
98
+	public function prepare_row($subscription, $fields) {
99 99
 
100 100
 		$prepared      = array();
101 101
 		$amount_fields = $this->get_amount_fields();
102 102
 		$invoice       = $subscription->get_parent_payment();
103 103
 
104
-		foreach ( $fields as $field ) {
104
+		foreach ($fields as $field) {
105 105
 
106 106
 			$value  = '';
107 107
 			$method = "get_$field";
108 108
 
109
-			if ( 0 === stripos( $field, 'customer' ) || 'currency' === $field ) {
109
+			if (0 === stripos($field, 'customer') || 'currency' === $field) {
110 110
 
111
-				if ( method_exists( $invoice, $method ) ) {
112
-					$value  = $invoice->$method();
111
+				if (method_exists($invoice, $method)) {
112
+					$value = $invoice->$method();
113 113
 				}
114 114
 
115
-			} else if ( method_exists( $subscription, $method ) ) {
116
-				$value  = $subscription->$method();
115
+			} else if (method_exists($subscription, $method)) {
116
+				$value = $subscription->$method();
117 117
 			}
118 118
 
119
-			if ( in_array( $field, $amount_fields ) ) {
120
-				$value  = wpinv_round_amount( wpinv_sanitize_amount( $value ) );
119
+			if (in_array($field, $amount_fields)) {
120
+				$value = wpinv_round_amount(wpinv_sanitize_amount($value));
121 121
 			}
122 122
 
123
-			$prepared[ $field ] = wpinv_clean( $value );
123
+			$prepared[$field] = wpinv_clean($value);
124 124
 
125 125
 		}
126 126
 
@@ -166,7 +166,7 @@  discard block
 block discarded – undo
166 166
 
167 167
     	);
168 168
 
169
-		return apply_filters( 'getpaid_subscription_exporter_get_fields', $fields );
169
+		return apply_filters('getpaid_subscription_exporter_get_fields', $fields);
170 170
 	}
171 171
 
172 172
 	/**
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
 			'recurring_amount'
183 183
     	);
184 184
 
185
-		return apply_filters( 'getpaid_subscription_exporter_get_amount_fields', $fields );
185
+		return apply_filters('getpaid_subscription_exporter_get_amount_fields', $fields);
186 186
 	}
187 187
 
188 188
 }
Please login to merge, or discard this patch.
includes/reports/class-getpaid-reports.php 2 patches
Indentation   +103 added lines, -103 removed lines patch added patch discarded remove patch
@@ -12,49 +12,49 @@  discard block
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Reports {
14 14
 
15
-	/**
16
-	 * Class constructor.
17
-	 *
18
-	 */
19
-	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
-
26
-	}
27
-
28
-	/**
29
-	 * Registers the reports page.
30
-	 *
31
-	 */
32
-	public function register_reports_page() {
33
-
34
-		add_submenu_page(
15
+    /**
16
+     * Class constructor.
17
+     *
18
+     */
19
+    public function __construct() {
20
+        add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
+        add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
+        add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
+        add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
+        add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
25
+
26
+    }
27
+
28
+    /**
29
+     * Registers the reports page.
30
+     *
31
+     */
32
+    public function register_reports_page() {
33
+
34
+        add_submenu_page(
35 35
             'wpinv',
36 36
             __( 'Reports', 'invoicing' ),
37 37
             __( 'Reports', 'invoicing' ),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40 40
             array( $this, 'display_reports_page' )
41
-		);
41
+        );
42 42
 
43
-	}
43
+    }
44 44
 
45
-	/**
46
-	 * Displays the reports page.
47
-	 *
48
-	 */
49
-	public function display_reports_page() {
45
+    /**
46
+     * Displays the reports page.
47
+     *
48
+     */
49
+    public function display_reports_page() {
50 50
 
51
-		// Prepare variables.
52
-		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
51
+        // Prepare variables.
52
+        $tabs        = $this->get_tabs();
53
+        $current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
+        $current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
55 55
 
56
-		// Display the current tab.
57
-		?>
56
+        // Display the current tab.
57
+        ?>
58 58
 
59 59
         <div class="wrap">
60 60
 
@@ -63,19 +63,19 @@  discard block
 block discarded – undo
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach( $tabs as $key => $label ) {
66
+                    foreach( $tabs as $key => $label ) {
67 67
 
68
-						$key   = sanitize_text_field( $key );
69
-						$label = sanitize_text_field( $label );
70
-						$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
-						$url   = esc_url(
72
-							add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73
-						);
68
+                        $key   = sanitize_text_field( $key );
69
+                        $label = sanitize_text_field( $label );
70
+                        $class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71
+                        $url   = esc_url(
72
+                            add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
73
+                        );
74 74
 
75
-						echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
75
+                        echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
76 76
 
77
-					}
78
-				?>
77
+                    }
78
+                ?>
79 79
 
80 80
 			</nav>
81 81
 
@@ -86,83 +86,83 @@  discard block
 block discarded – undo
86 86
         </div>
87 87
 		<?php
88 88
 
89
-			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true );
93
-			wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' );
89
+            // Wordfence loads an unsupported version of chart js on our page.
90
+            wp_deregister_style( 'chart-js' );
91
+            wp_deregister_script( 'chart-js' );
92
+            wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true );
93
+            wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' );
94 94
 
95
-	}
95
+    }
96 96
 
97
-	/**
98
-	 * Retrieves reports page tabs.
99
-	 *
100
-	 * @return array
101
-	 */
102
-	public function get_tabs() {
97
+    /**
98
+     * Retrieves reports page tabs.
99
+     *
100
+     * @return array
101
+     */
102
+    public function get_tabs() {
103 103
 
104
-		$tabs = array(
105
-			'reports' => __( 'Reports', 'invoicing' ),
106
-			'export'  => __( 'Export', 'invoicing' ),
107
-		);
104
+        $tabs = array(
105
+            'reports' => __( 'Reports', 'invoicing' ),
106
+            'export'  => __( 'Export', 'invoicing' ),
107
+        );
108 108
 
109
-		return apply_filters( 'getpaid_report_tabs', $tabs );
110
-	}
109
+        return apply_filters( 'getpaid_report_tabs', $tabs );
110
+    }
111 111
 
112
-	/**
113
-	 * Displays the reports tab.
114
-	 *
115
-	 */
116
-	public function display_reports_tab() {
112
+    /**
113
+     * Displays the reports tab.
114
+     *
115
+     */
116
+    public function display_reports_tab() {
117 117
 
118
-		$reports = new GetPaid_Reports_Report();
119
-		$reports->display();
118
+        $reports = new GetPaid_Reports_Report();
119
+        $reports->display();
120 120
 
121
-	}
121
+    }
122 122
 
123
-	/**
124
-	 * Displays the exports tab.
125
-	 *
126
-	 */
127
-	public function display_exports_tab() {
123
+    /**
124
+     * Displays the exports tab.
125
+     *
126
+     */
127
+    public function display_exports_tab() {
128 128
 
129
-		$exports = new GetPaid_Reports_Export();
130
-		$exports->display();
129
+        $exports = new GetPaid_Reports_Export();
130
+        $exports->display();
131 131
 
132
-	}
132
+    }
133 133
 
134
-	/**
135
-	 * Donwnloads a graph.
136
-	 *
137
-	 * @param array $args
138
-	 */
139
-	public function download_graph( $args ) {
134
+    /**
135
+     * Donwnloads a graph.
136
+     *
137
+     * @param array $args
138
+     */
139
+    public function download_graph( $args ) {
140 140
 
141
-		if ( ! empty( $args['graph'] ) ) {
142
-			$downloader = new GetPaid_Graph_Downloader();
143
-			$downloader->download( $args['graph'] );
144
-		}
141
+        if ( ! empty( $args['graph'] ) ) {
142
+            $downloader = new GetPaid_Graph_Downloader();
143
+            $downloader->download( $args['graph'] );
144
+        }
145 145
 
146
-	}
146
+    }
147 147
 
148
-	/**
149
-	 * Exports invoices.
150
-	 *
151
-	 * @param array $args
152
-	 */
153
-	public function export_invoices( $args ) {
148
+    /**
149
+     * Exports invoices.
150
+     *
151
+     * @param array $args
152
+     */
153
+    public function export_invoices( $args ) {
154 154
 
155
-		if ( ! empty( $args['post_type'] ) ) {
155
+        if ( ! empty( $args['post_type'] ) ) {
156 156
 
157
-			if ( 'subscriptions' === $args['post_type'] ) {
158
-				$downloader = new GetPaid_Subscription_Exporter();
159
-			} else {
160
-				$downloader = new GetPaid_Invoice_Exporter();
161
-			}
157
+            if ( 'subscriptions' === $args['post_type'] ) {
158
+                $downloader = new GetPaid_Subscription_Exporter();
159
+            } else {
160
+                $downloader = new GetPaid_Invoice_Exporter();
161
+            }
162 162
 
163
-			$downloader->export( $args['post_type'], $args );
164
-		}
163
+            $downloader->export( $args['post_type'], $args );
164
+        }
165 165
 
166
-	}
166
+    }
167 167
 
168 168
 }
Please login to merge, or discard this patch.
Spacing   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 
8
-defined( 'ABSPATH' ) || exit;
8
+defined('ABSPATH') || exit;
9 9
 
10 10
 /**
11 11
  * GetPaid_Reports Class.
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
 	 *
18 18
 	 */
19 19
 	public function __construct() {
20
-		add_action( 'admin_menu', array( $this, 'register_reports_page' ), 20 );
21
-		add_action( 'wpinv_reports_tab_reports', array( $this, 'display_reports_tab' ) );
22
-		add_action( 'wpinv_reports_tab_export', array( $this, 'display_exports_tab' ) );
23
-		add_action( 'getpaid_authenticated_admin_action_download_graph', array( $this, 'download_graph' ) );
24
-		add_action( 'getpaid_authenticated_admin_action_export_invoices', array( $this, 'export_invoices' ) );
20
+		add_action('admin_menu', array($this, 'register_reports_page'), 20);
21
+		add_action('wpinv_reports_tab_reports', array($this, 'display_reports_tab'));
22
+		add_action('wpinv_reports_tab_export', array($this, 'display_exports_tab'));
23
+		add_action('getpaid_authenticated_admin_action_download_graph', array($this, 'download_graph'));
24
+		add_action('getpaid_authenticated_admin_action_export_invoices', array($this, 'export_invoices'));
25 25
 
26 26
 	}
27 27
 
@@ -33,11 +33,11 @@  discard block
 block discarded – undo
33 33
 
34 34
 		add_submenu_page(
35 35
             'wpinv',
36
-            __( 'Reports', 'invoicing' ),
37
-            __( 'Reports', 'invoicing' ),
36
+            __('Reports', 'invoicing'),
37
+            __('Reports', 'invoicing'),
38 38
             wpinv_get_capability(),
39 39
             'wpinv-reports',
40
-            array( $this, 'display_reports_page' )
40
+            array($this, 'display_reports_page')
41 41
 		);
42 42
 
43 43
 	}
@@ -50,26 +50,26 @@  discard block
 block discarded – undo
50 50
 
51 51
 		// Prepare variables.
52 52
 		$tabs        = $this->get_tabs();
53
-		$current_tab = isset( $_GET['tab'] ) ? sanitize_text_field( $_GET['tab'] ) : 'reports';
54
-		$current_tab = array_key_exists( $current_tab, $tabs ) ? $current_tab : 'reports';
53
+		$current_tab = isset($_GET['tab']) ? sanitize_text_field($_GET['tab']) : 'reports';
54
+		$current_tab = array_key_exists($current_tab, $tabs) ? $current_tab : 'reports';
55 55
 
56 56
 		// Display the current tab.
57 57
 		?>
58 58
 
59 59
         <div class="wrap">
60 60
 
61
-			<h1><?php echo sanitize_text_field( $tabs[ $current_tab ] ); ?></h1>
61
+			<h1><?php echo sanitize_text_field($tabs[$current_tab]); ?></h1>
62 62
 
63 63
 			<nav class="nav-tab-wrapper">
64 64
 
65 65
 				<?php
66
-					foreach( $tabs as $key => $label ) {
66
+					foreach ($tabs as $key => $label) {
67 67
 
68
-						$key   = sanitize_text_field( $key );
69
-						$label = sanitize_text_field( $label );
68
+						$key   = sanitize_text_field($key);
69
+						$label = sanitize_text_field($label);
70 70
 						$class = $key == $current_tab ? 'nav-tab nav-tab-active' : 'nav-tab';
71 71
 						$url   = esc_url(
72
-							add_query_arg( 'tab', $key, admin_url( 'admin.php?page=wpinv-reports' ) )
72
+							add_query_arg('tab', $key, admin_url('admin.php?page=wpinv-reports'))
73 73
 						);
74 74
 
75 75
 						echo "\n\t\t\t<a href='$url' class='$class'>$label</a>";
@@ -79,18 +79,18 @@  discard block
 block discarded – undo
79 79
 
80 80
 			</nav>
81 81
 
82
-			<div class="bsui <?php echo esc_attr( $current_tab ); ?>">
83
-				<?php do_action( "wpinv_reports_tab_{$current_tab}" ); ?>
82
+			<div class="bsui <?php echo esc_attr($current_tab); ?>">
83
+				<?php do_action("wpinv_reports_tab_{$current_tab}"); ?>
84 84
 			</div>
85 85
 
86 86
         </div>
87 87
 		<?php
88 88
 
89 89
 			// Wordfence loads an unsupported version of chart js on our page.
90
-			wp_deregister_style( 'chart-js' );
91
-			wp_deregister_script( 'chart-js' );
92
-			wp_enqueue_script( 'chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array( 'jquery' ), '2.9.4', true );
93
-			wp_enqueue_style( 'chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4' );
90
+			wp_deregister_style('chart-js');
91
+			wp_deregister_script('chart-js');
92
+			wp_enqueue_script('chart-js', WPINV_PLUGIN_URL . 'assets/js/chart.bundle.min.js', array('jquery'), '2.9.4', true);
93
+			wp_enqueue_style('chart-js', WPINV_PLUGIN_URL . 'assets/css/chart.min.css', array(), '2.9.4');
94 94
 
95 95
 	}
96 96
 
@@ -102,11 +102,11 @@  discard block
 block discarded – undo
102 102
 	public function get_tabs() {
103 103
 
104 104
 		$tabs = array(
105
-			'reports' => __( 'Reports', 'invoicing' ),
106
-			'export'  => __( 'Export', 'invoicing' ),
105
+			'reports' => __('Reports', 'invoicing'),
106
+			'export'  => __('Export', 'invoicing'),
107 107
 		);
108 108
 
109
-		return apply_filters( 'getpaid_report_tabs', $tabs );
109
+		return apply_filters('getpaid_report_tabs', $tabs);
110 110
 	}
111 111
 
112 112
 	/**
@@ -136,11 +136,11 @@  discard block
 block discarded – undo
136 136
 	 *
137 137
 	 * @param array $args
138 138
 	 */
139
-	public function download_graph( $args ) {
139
+	public function download_graph($args) {
140 140
 
141
-		if ( ! empty( $args['graph'] ) ) {
141
+		if (!empty($args['graph'])) {
142 142
 			$downloader = new GetPaid_Graph_Downloader();
143
-			$downloader->download( $args['graph'] );
143
+			$downloader->download($args['graph']);
144 144
 		}
145 145
 
146 146
 	}
@@ -150,17 +150,17 @@  discard block
 block discarded – undo
150 150
 	 *
151 151
 	 * @param array $args
152 152
 	 */
153
-	public function export_invoices( $args ) {
153
+	public function export_invoices($args) {
154 154
 
155
-		if ( ! empty( $args['post_type'] ) ) {
155
+		if (!empty($args['post_type'])) {
156 156
 
157
-			if ( 'subscriptions' === $args['post_type'] ) {
157
+			if ('subscriptions' === $args['post_type']) {
158 158
 				$downloader = new GetPaid_Subscription_Exporter();
159 159
 			} else {
160 160
 				$downloader = new GetPaid_Invoice_Exporter();
161 161
 			}
162 162
 
163
-			$downloader->export( $args['post_type'], $args );
163
+			$downloader->export($args['post_type'], $args);
164 164
 		}
165 165
 
166 166
 	}
Please login to merge, or discard this patch.
includes/data/tax-rates.php 2 patches
Indentation   +260 added lines, -260 removed lines patch added patch discarded remove patch
@@ -12,265 +12,265 @@
 block discarded – undo
12 12
 
13 13
 return array(
14 14
 
15
-	array(
16
-		'country'      => 'AT', // Austria
17
-		'state'        => '',
18
-		'global'       => true,
19
-		'rate'         => 20,
20
-		'reduced_rate' => 13,
21
-		'name'         => __( 'VAT', 'invoicing' ),
22
-	),
23
-
24
-	array(
25
-		'country'      => 'BE', // Belgium
26
-		'state'        => '',
27
-		'global'       => true,
28
-		'rate'         => 21,
29
-		'reduced_rate' => 12,
30
-		'name'         => __( 'VAT', 'invoicing' ),
31
-	),
32
-
33
-	array(
34
-		'country'      => 'BG', // Bulgaria
35
-		'state'        => '',
36
-		'global'       => true,
37
-		'rate'         => 20,
38
-		'reduced_rate' => 9,
39
-		'name'         => __( 'VAT', 'invoicing' ),
40
-	),
41
-
42
-	array(
43
-		'country'      => 'HR', // Croatia
44
-		'state'        => '',
45
-		'global'       => true,
46
-		'rate'         => 25,
47
-		'reduced_rate' => 13,
48
-		'name'         => __( 'VAT', 'invoicing' ),
49
-	),
50
-
51
-	array(
52
-		'country'      => 'CY', // Cyprus
53
-		'state'        => '',
54
-		'global'       => true,
55
-		'rate'         => 19,
56
-		'reduced_rate' => 9,
57
-		'name'         => __( 'VAT', 'invoicing' ),
58
-	),
59
-
60
-	array(
61
-		'country'      => 'CZ', // Czech Republic
62
-		'state'        => '',
63
-		'global'       => true,
64
-		'rate'         => 21,
65
-		'reduced_rate' => 15,
66
-		'name'         => __( 'VAT', 'invoicing' ),
67
-	),
68
-
69
-	array(
70
-		'country'      => 'DK', // Denmark
71
-		'state'        => '',
72
-		'global'       => true,
73
-		'rate'         => 25,
74
-		'reduced_rate' => 0,
75
-		'name'         => __( 'VAT', 'invoicing' ),
76
-	),
77
-
78
-	array(
79
-		'country'      => 'EE', // Estonia
80
-		'state'        => '',
81
-		'global'       => true,
82
-		'rate'         => 20,
83
-		'reduced_rate' => 9,
84
-		'name'         => __( 'VAT', 'invoicing' ),
85
-	),
86
-
87
-	array(
88
-		'country'      => 'FI', // Finland
89
-		'state'        => '',
90
-		'global'       => true,
91
-		'rate'         => 24,
92
-		'reduced_rate' => 14,
93
-		'name'         => __( 'VAT', 'invoicing' ),
94
-	),
95
-
96
-	array(
97
-		'country'      => 'FR', // France
98
-		'state'        => '',
99
-		'global'       => true,
100
-		'rate'         => 20,
101
-		'reduced_rate' => 5.5,
102
-		'name'         => __( 'VAT', 'invoicing' ),
103
-	),
104
-
105
-	array(
106
-		'country'      => 'DE', // Germany
107
-		'state'        => '',
108
-		'global'       => true,
109
-		'rate'         => 19,
110
-		'reduced_rate' => 7,
111
-		'name'         => __( 'VAT', 'invoicing' ),
112
-	),
113
-
114
-	array(
115
-		'country'      => 'GR', // Greece
116
-		'state'        => '',
117
-		'global'       => true,
118
-		'rate'         => 24,
119
-		'reduced_rate' => 13,
120
-		'name'         => __( 'VAT', 'invoicing' ),
121
-	),
122
-
123
-	array(
124
-		'country'      => 'HU', // Hungary
125
-		'state'        => '',
126
-		'global'       => true,
127
-		'rate'         => 27,
128
-		'reduced_rate' => 18,
129
-		'name'         => __( 'VAT', 'invoicing' ),
130
-	),
131
-
132
-	array(
133
-		'country'      => 'IE', // Ireland
134
-		'state'        => '',
135
-		'global'       => true,
136
-		'rate'         => 23,
137
-		'reduced_rate' => 13.5,
138
-		'name'         => __( 'VAT', 'invoicing' ),
139
-	),
140
-
141
-	array(
142
-		'country'      => 'IT', // Italy
143
-		'state'        => '',
144
-		'global'       => true,
145
-		'rate'         => 22,
146
-		'reduced_rate' => 10,
147
-		'name'         => __( 'VAT', 'invoicing' ),
148
-	),
149
-
150
-	array(
151
-		'country'      => 'LV', // Latvia
152
-		'state'        => '',
153
-		'global'       => true,
154
-		'rate'         => 21,
155
-		'reduced_rate' => 12,
156
-		'name'         => __( 'VAT', 'invoicing' ),
157
-	),
158
-
159
-	array(
160
-		'country'      => 'LT', // Lithuania
161
-		'state'        => '',
162
-		'global'       => true,
163
-		'rate'         => 21,
164
-		'reduced_rate' => 9,
165
-		'name'         => __( 'VAT', 'invoicing' ),
166
-	),
167
-
168
-	array(
169
-		'country'      => 'LU', // Luxembourg
170
-		'state'        => '',
171
-		'global'       => true,
172
-		'rate'         => 17,
173
-		'reduced_rate' => 14,
174
-		'name'         => __( 'VAT', 'invoicing' ),
175
-	),
176
-
177
-	array(
178
-		'country'      => 'MT', // Malta
179
-		'state'        => '',
180
-		'global'       => true,
181
-		'rate'         => 18,
182
-		'reduced_rate' => 7,
183
-		'name'         => __( 'VAT', 'invoicing' ),
184
-	),
185
-
186
-	array(
187
-		'country'      => 'MC', // Monaco
188
-		'state'        => '',
189
-		'global'       => true,
190
-		'rate'         => 20,
191
-		'reduced_rate' => 10,
192
-		'name'         => __( 'VAT', 'invoicing' ),
193
-	),
194
-
195
-	array(
196
-		'country'      => 'NL', // Netherlands
197
-		'state'        => '',
198
-		'global'       => true,
199
-		'rate'         => 21,
200
-		'reduced_rate' => 9,
201
-		'name'         => __( 'VAT', 'invoicing' ),
202
-	),
203
-
204
-	array(
205
-		'country'      => 'PL', // Poland
206
-		'state'        => '',
207
-		'global'       => true,
208
-		'rate'         => 23,
209
-		'reduced_rate' => 8,
210
-		'name'         => __( 'VAT', 'invoicing' ),
211
-	),
212
-
213
-	array(
214
-		'country'      => 'PT', // Portugal
215
-		'state'        => '',
216
-		'global'       => true,
217
-		'rate'         => 23,
218
-		'reduced_rate' => 13,
219
-		'name'         => __( 'VAT', 'invoicing' ),
220
-	),
221
-
222
-	array(
223
-		'country'      => 'RO', // Romania
224
-		'state'        => '',
225
-		'global'       => true,
226
-		'rate'         => 19,
227
-		'reduced_rate' => 9,
228
-		'name'         => __( 'VAT', 'invoicing' ),
229
-	),
230
-
231
-	array(
232
-		'country'      => 'SK', // Slovakia
233
-		'state'        => '',
234
-		'global'       => true,
235
-		'rate'         => 20,
236
-		'reduced_rate' => 10,
237
-		'name'         => __( 'VAT', 'invoicing' ),
238
-	),
239
-
240
-	array(
241
-		'country'      => 'SI', // Slovenia
242
-		'state'        => '',
243
-		'global'       => true,
244
-		'rate'         => 22,
245
-		'reduced_rate' => 9.5,
246
-		'name'         => __( 'VAT', 'invoicing' ),
247
-	),
248
-
249
-	array(
250
-		'country'      => 'ES', // Spain
251
-		'state'        => '',
252
-		'global'       => true,
253
-		'rate'         => 21,
254
-		'reduced_rate' => 10,
255
-		'name'         => __( 'VAT', 'invoicing' ),
256
-	),
257
-
258
-	array(
259
-		'country'      => 'SE', // Sweden
260
-		'state'        => '',
261
-		'global'       => true,
262
-		'rate'         => 25,
263
-		'reduced_rate' => 12,
264
-		'name'         => __( 'VAT', 'invoicing' ),
265
-	),
266
-
267
-	array(
268
-		'country'      => 'GB', // UK
269
-		'state'        => '',
270
-		'global'       => true,
271
-		'rate'         => 20,
272
-		'reduced_rate' => 5,
273
-		'name'         => __( 'VAT', 'invoicing' ),
274
-	)
15
+    array(
16
+        'country'      => 'AT', // Austria
17
+        'state'        => '',
18
+        'global'       => true,
19
+        'rate'         => 20,
20
+        'reduced_rate' => 13,
21
+        'name'         => __( 'VAT', 'invoicing' ),
22
+    ),
23
+
24
+    array(
25
+        'country'      => 'BE', // Belgium
26
+        'state'        => '',
27
+        'global'       => true,
28
+        'rate'         => 21,
29
+        'reduced_rate' => 12,
30
+        'name'         => __( 'VAT', 'invoicing' ),
31
+    ),
32
+
33
+    array(
34
+        'country'      => 'BG', // Bulgaria
35
+        'state'        => '',
36
+        'global'       => true,
37
+        'rate'         => 20,
38
+        'reduced_rate' => 9,
39
+        'name'         => __( 'VAT', 'invoicing' ),
40
+    ),
41
+
42
+    array(
43
+        'country'      => 'HR', // Croatia
44
+        'state'        => '',
45
+        'global'       => true,
46
+        'rate'         => 25,
47
+        'reduced_rate' => 13,
48
+        'name'         => __( 'VAT', 'invoicing' ),
49
+    ),
50
+
51
+    array(
52
+        'country'      => 'CY', // Cyprus
53
+        'state'        => '',
54
+        'global'       => true,
55
+        'rate'         => 19,
56
+        'reduced_rate' => 9,
57
+        'name'         => __( 'VAT', 'invoicing' ),
58
+    ),
59
+
60
+    array(
61
+        'country'      => 'CZ', // Czech Republic
62
+        'state'        => '',
63
+        'global'       => true,
64
+        'rate'         => 21,
65
+        'reduced_rate' => 15,
66
+        'name'         => __( 'VAT', 'invoicing' ),
67
+    ),
68
+
69
+    array(
70
+        'country'      => 'DK', // Denmark
71
+        'state'        => '',
72
+        'global'       => true,
73
+        'rate'         => 25,
74
+        'reduced_rate' => 0,
75
+        'name'         => __( 'VAT', 'invoicing' ),
76
+    ),
77
+
78
+    array(
79
+        'country'      => 'EE', // Estonia
80
+        'state'        => '',
81
+        'global'       => true,
82
+        'rate'         => 20,
83
+        'reduced_rate' => 9,
84
+        'name'         => __( 'VAT', 'invoicing' ),
85
+    ),
86
+
87
+    array(
88
+        'country'      => 'FI', // Finland
89
+        'state'        => '',
90
+        'global'       => true,
91
+        'rate'         => 24,
92
+        'reduced_rate' => 14,
93
+        'name'         => __( 'VAT', 'invoicing' ),
94
+    ),
95
+
96
+    array(
97
+        'country'      => 'FR', // France
98
+        'state'        => '',
99
+        'global'       => true,
100
+        'rate'         => 20,
101
+        'reduced_rate' => 5.5,
102
+        'name'         => __( 'VAT', 'invoicing' ),
103
+    ),
104
+
105
+    array(
106
+        'country'      => 'DE', // Germany
107
+        'state'        => '',
108
+        'global'       => true,
109
+        'rate'         => 19,
110
+        'reduced_rate' => 7,
111
+        'name'         => __( 'VAT', 'invoicing' ),
112
+    ),
113
+
114
+    array(
115
+        'country'      => 'GR', // Greece
116
+        'state'        => '',
117
+        'global'       => true,
118
+        'rate'         => 24,
119
+        'reduced_rate' => 13,
120
+        'name'         => __( 'VAT', 'invoicing' ),
121
+    ),
122
+
123
+    array(
124
+        'country'      => 'HU', // Hungary
125
+        'state'        => '',
126
+        'global'       => true,
127
+        'rate'         => 27,
128
+        'reduced_rate' => 18,
129
+        'name'         => __( 'VAT', 'invoicing' ),
130
+    ),
131
+
132
+    array(
133
+        'country'      => 'IE', // Ireland
134
+        'state'        => '',
135
+        'global'       => true,
136
+        'rate'         => 23,
137
+        'reduced_rate' => 13.5,
138
+        'name'         => __( 'VAT', 'invoicing' ),
139
+    ),
140
+
141
+    array(
142
+        'country'      => 'IT', // Italy
143
+        'state'        => '',
144
+        'global'       => true,
145
+        'rate'         => 22,
146
+        'reduced_rate' => 10,
147
+        'name'         => __( 'VAT', 'invoicing' ),
148
+    ),
149
+
150
+    array(
151
+        'country'      => 'LV', // Latvia
152
+        'state'        => '',
153
+        'global'       => true,
154
+        'rate'         => 21,
155
+        'reduced_rate' => 12,
156
+        'name'         => __( 'VAT', 'invoicing' ),
157
+    ),
158
+
159
+    array(
160
+        'country'      => 'LT', // Lithuania
161
+        'state'        => '',
162
+        'global'       => true,
163
+        'rate'         => 21,
164
+        'reduced_rate' => 9,
165
+        'name'         => __( 'VAT', 'invoicing' ),
166
+    ),
167
+
168
+    array(
169
+        'country'      => 'LU', // Luxembourg
170
+        'state'        => '',
171
+        'global'       => true,
172
+        'rate'         => 17,
173
+        'reduced_rate' => 14,
174
+        'name'         => __( 'VAT', 'invoicing' ),
175
+    ),
176
+
177
+    array(
178
+        'country'      => 'MT', // Malta
179
+        'state'        => '',
180
+        'global'       => true,
181
+        'rate'         => 18,
182
+        'reduced_rate' => 7,
183
+        'name'         => __( 'VAT', 'invoicing' ),
184
+    ),
185
+
186
+    array(
187
+        'country'      => 'MC', // Monaco
188
+        'state'        => '',
189
+        'global'       => true,
190
+        'rate'         => 20,
191
+        'reduced_rate' => 10,
192
+        'name'         => __( 'VAT', 'invoicing' ),
193
+    ),
194
+
195
+    array(
196
+        'country'      => 'NL', // Netherlands
197
+        'state'        => '',
198
+        'global'       => true,
199
+        'rate'         => 21,
200
+        'reduced_rate' => 9,
201
+        'name'         => __( 'VAT', 'invoicing' ),
202
+    ),
203
+
204
+    array(
205
+        'country'      => 'PL', // Poland
206
+        'state'        => '',
207
+        'global'       => true,
208
+        'rate'         => 23,
209
+        'reduced_rate' => 8,
210
+        'name'         => __( 'VAT', 'invoicing' ),
211
+    ),
212
+
213
+    array(
214
+        'country'      => 'PT', // Portugal
215
+        'state'        => '',
216
+        'global'       => true,
217
+        'rate'         => 23,
218
+        'reduced_rate' => 13,
219
+        'name'         => __( 'VAT', 'invoicing' ),
220
+    ),
221
+
222
+    array(
223
+        'country'      => 'RO', // Romania
224
+        'state'        => '',
225
+        'global'       => true,
226
+        'rate'         => 19,
227
+        'reduced_rate' => 9,
228
+        'name'         => __( 'VAT', 'invoicing' ),
229
+    ),
230
+
231
+    array(
232
+        'country'      => 'SK', // Slovakia
233
+        'state'        => '',
234
+        'global'       => true,
235
+        'rate'         => 20,
236
+        'reduced_rate' => 10,
237
+        'name'         => __( 'VAT', 'invoicing' ),
238
+    ),
239
+
240
+    array(
241
+        'country'      => 'SI', // Slovenia
242
+        'state'        => '',
243
+        'global'       => true,
244
+        'rate'         => 22,
245
+        'reduced_rate' => 9.5,
246
+        'name'         => __( 'VAT', 'invoicing' ),
247
+    ),
248
+
249
+    array(
250
+        'country'      => 'ES', // Spain
251
+        'state'        => '',
252
+        'global'       => true,
253
+        'rate'         => 21,
254
+        'reduced_rate' => 10,
255
+        'name'         => __( 'VAT', 'invoicing' ),
256
+    ),
257
+
258
+    array(
259
+        'country'      => 'SE', // Sweden
260
+        'state'        => '',
261
+        'global'       => true,
262
+        'rate'         => 25,
263
+        'reduced_rate' => 12,
264
+        'name'         => __( 'VAT', 'invoicing' ),
265
+    ),
266
+
267
+    array(
268
+        'country'      => 'GB', // UK
269
+        'state'        => '',
270
+        'global'       => true,
271
+        'rate'         => 20,
272
+        'reduced_rate' => 5,
273
+        'name'         => __( 'VAT', 'invoicing' ),
274
+    )
275 275
 
276 276
 );
Please login to merge, or discard this patch.
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  * @version 1.0.19
9 9
  */
10 10
 
11
-defined( 'ABSPATH' ) || exit;
11
+defined('ABSPATH') || exit;
12 12
 
13 13
 return array(
14 14
 
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 		'global'       => true,
19 19
 		'rate'         => 20,
20 20
 		'reduced_rate' => 13,
21
-		'name'         => __( 'VAT', 'invoicing' ),
21
+		'name'         => __('VAT', 'invoicing'),
22 22
 	),
23 23
 
24 24
 	array(
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
 		'global'       => true,
28 28
 		'rate'         => 21,
29 29
 		'reduced_rate' => 12,
30
-		'name'         => __( 'VAT', 'invoicing' ),
30
+		'name'         => __('VAT', 'invoicing'),
31 31
 	),
32 32
 
33 33
 	array(
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
 		'global'       => true,
37 37
 		'rate'         => 20,
38 38
 		'reduced_rate' => 9,
39
-		'name'         => __( 'VAT', 'invoicing' ),
39
+		'name'         => __('VAT', 'invoicing'),
40 40
 	),
41 41
 
42 42
 	array(
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
 		'global'       => true,
46 46
 		'rate'         => 25,
47 47
 		'reduced_rate' => 13,
48
-		'name'         => __( 'VAT', 'invoicing' ),
48
+		'name'         => __('VAT', 'invoicing'),
49 49
 	),
50 50
 
51 51
 	array(
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		'global'       => true,
55 55
 		'rate'         => 19,
56 56
 		'reduced_rate' => 9,
57
-		'name'         => __( 'VAT', 'invoicing' ),
57
+		'name'         => __('VAT', 'invoicing'),
58 58
 	),
59 59
 
60 60
 	array(
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 		'global'       => true,
64 64
 		'rate'         => 21,
65 65
 		'reduced_rate' => 15,
66
-		'name'         => __( 'VAT', 'invoicing' ),
66
+		'name'         => __('VAT', 'invoicing'),
67 67
 	),
68 68
 
69 69
 	array(
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 		'global'       => true,
73 73
 		'rate'         => 25,
74 74
 		'reduced_rate' => 0,
75
-		'name'         => __( 'VAT', 'invoicing' ),
75
+		'name'         => __('VAT', 'invoicing'),
76 76
 	),
77 77
 
78 78
 	array(
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 		'global'       => true,
82 82
 		'rate'         => 20,
83 83
 		'reduced_rate' => 9,
84
-		'name'         => __( 'VAT', 'invoicing' ),
84
+		'name'         => __('VAT', 'invoicing'),
85 85
 	),
86 86
 
87 87
 	array(
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 		'global'       => true,
91 91
 		'rate'         => 24,
92 92
 		'reduced_rate' => 14,
93
-		'name'         => __( 'VAT', 'invoicing' ),
93
+		'name'         => __('VAT', 'invoicing'),
94 94
 	),
95 95
 
96 96
 	array(
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 		'global'       => true,
100 100
 		'rate'         => 20,
101 101
 		'reduced_rate' => 5.5,
102
-		'name'         => __( 'VAT', 'invoicing' ),
102
+		'name'         => __('VAT', 'invoicing'),
103 103
 	),
104 104
 
105 105
 	array(
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 		'global'       => true,
109 109
 		'rate'         => 19,
110 110
 		'reduced_rate' => 7,
111
-		'name'         => __( 'VAT', 'invoicing' ),
111
+		'name'         => __('VAT', 'invoicing'),
112 112
 	),
113 113
 
114 114
 	array(
@@ -117,7 +117,7 @@  discard block
 block discarded – undo
117 117
 		'global'       => true,
118 118
 		'rate'         => 24,
119 119
 		'reduced_rate' => 13,
120
-		'name'         => __( 'VAT', 'invoicing' ),
120
+		'name'         => __('VAT', 'invoicing'),
121 121
 	),
122 122
 
123 123
 	array(
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 		'global'       => true,
127 127
 		'rate'         => 27,
128 128
 		'reduced_rate' => 18,
129
-		'name'         => __( 'VAT', 'invoicing' ),
129
+		'name'         => __('VAT', 'invoicing'),
130 130
 	),
131 131
 
132 132
 	array(
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 		'global'       => true,
136 136
 		'rate'         => 23,
137 137
 		'reduced_rate' => 13.5,
138
-		'name'         => __( 'VAT', 'invoicing' ),
138
+		'name'         => __('VAT', 'invoicing'),
139 139
 	),
140 140
 
141 141
 	array(
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 		'global'       => true,
145 145
 		'rate'         => 22,
146 146
 		'reduced_rate' => 10,
147
-		'name'         => __( 'VAT', 'invoicing' ),
147
+		'name'         => __('VAT', 'invoicing'),
148 148
 	),
149 149
 
150 150
 	array(
@@ -153,7 +153,7 @@  discard block
 block discarded – undo
153 153
 		'global'       => true,
154 154
 		'rate'         => 21,
155 155
 		'reduced_rate' => 12,
156
-		'name'         => __( 'VAT', 'invoicing' ),
156
+		'name'         => __('VAT', 'invoicing'),
157 157
 	),
158 158
 
159 159
 	array(
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
 		'global'       => true,
163 163
 		'rate'         => 21,
164 164
 		'reduced_rate' => 9,
165
-		'name'         => __( 'VAT', 'invoicing' ),
165
+		'name'         => __('VAT', 'invoicing'),
166 166
 	),
167 167
 
168 168
 	array(
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
 		'global'       => true,
172 172
 		'rate'         => 17,
173 173
 		'reduced_rate' => 14,
174
-		'name'         => __( 'VAT', 'invoicing' ),
174
+		'name'         => __('VAT', 'invoicing'),
175 175
 	),
176 176
 
177 177
 	array(
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 		'global'       => true,
181 181
 		'rate'         => 18,
182 182
 		'reduced_rate' => 7,
183
-		'name'         => __( 'VAT', 'invoicing' ),
183
+		'name'         => __('VAT', 'invoicing'),
184 184
 	),
185 185
 
186 186
 	array(
@@ -189,7 +189,7 @@  discard block
 block discarded – undo
189 189
 		'global'       => true,
190 190
 		'rate'         => 20,
191 191
 		'reduced_rate' => 10,
192
-		'name'         => __( 'VAT', 'invoicing' ),
192
+		'name'         => __('VAT', 'invoicing'),
193 193
 	),
194 194
 
195 195
 	array(
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 		'global'       => true,
199 199
 		'rate'         => 21,
200 200
 		'reduced_rate' => 9,
201
-		'name'         => __( 'VAT', 'invoicing' ),
201
+		'name'         => __('VAT', 'invoicing'),
202 202
 	),
203 203
 
204 204
 	array(
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 		'global'       => true,
208 208
 		'rate'         => 23,
209 209
 		'reduced_rate' => 8,
210
-		'name'         => __( 'VAT', 'invoicing' ),
210
+		'name'         => __('VAT', 'invoicing'),
211 211
 	),
212 212
 
213 213
 	array(
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 		'global'       => true,
217 217
 		'rate'         => 23,
218 218
 		'reduced_rate' => 13,
219
-		'name'         => __( 'VAT', 'invoicing' ),
219
+		'name'         => __('VAT', 'invoicing'),
220 220
 	),
221 221
 
222 222
 	array(
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 		'global'       => true,
226 226
 		'rate'         => 19,
227 227
 		'reduced_rate' => 9,
228
-		'name'         => __( 'VAT', 'invoicing' ),
228
+		'name'         => __('VAT', 'invoicing'),
229 229
 	),
230 230
 
231 231
 	array(
@@ -234,7 +234,7 @@  discard block
 block discarded – undo
234 234
 		'global'       => true,
235 235
 		'rate'         => 20,
236 236
 		'reduced_rate' => 10,
237
-		'name'         => __( 'VAT', 'invoicing' ),
237
+		'name'         => __('VAT', 'invoicing'),
238 238
 	),
239 239
 
240 240
 	array(
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 		'global'       => true,
244 244
 		'rate'         => 22,
245 245
 		'reduced_rate' => 9.5,
246
-		'name'         => __( 'VAT', 'invoicing' ),
246
+		'name'         => __('VAT', 'invoicing'),
247 247
 	),
248 248
 
249 249
 	array(
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 		'global'       => true,
253 253
 		'rate'         => 21,
254 254
 		'reduced_rate' => 10,
255
-		'name'         => __( 'VAT', 'invoicing' ),
255
+		'name'         => __('VAT', 'invoicing'),
256 256
 	),
257 257
 
258 258
 	array(
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 		'global'       => true,
262 262
 		'rate'         => 25,
263 263
 		'reduced_rate' => 12,
264
-		'name'         => __( 'VAT', 'invoicing' ),
264
+		'name'         => __('VAT', 'invoicing'),
265 265
 	),
266 266
 
267 267
 	array(
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 		'global'       => true,
271 271
 		'rate'         => 20,
272 272
 		'reduced_rate' => 5,
273
-		'name'         => __( 'VAT', 'invoicing' ),
273
+		'name'         => __('VAT', 'invoicing'),
274 274
 	)
275 275
 
276 276
 );
Please login to merge, or discard this patch.
includes/class-wpinv-item.php 2 patches
Indentation   +732 added lines, -732 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,30 +10,30 @@  discard block
 block discarded – undo
10 10
 class WPInv_Item  extends GetPaid_Data {
11 11
 
12 12
     /**
13
-	 * Which data store to load.
14
-	 *
15
-	 * @var string
16
-	 */
13
+     * Which data store to load.
14
+     *
15
+     * @var string
16
+     */
17 17
     protected $data_store_name = 'item';
18 18
 
19 19
     /**
20
-	 * This is the name of this object type.
21
-	 *
22
-	 * @var string
23
-	 */
24
-	protected $object_type = 'item';
20
+     * This is the name of this object type.
21
+     *
22
+     * @var string
23
+     */
24
+    protected $object_type = 'item';
25 25
 
26 26
     /**
27
-	 * Item Data array. This is the core item data exposed in APIs.
28
-	 *
29
-	 * @since 1.0.19
30
-	 * @var array
31
-	 */
32
-	protected $data = array(
33
-		'parent_id'            => 0,
34
-		'status'               => 'draft',
35
-		'version'              => '',
36
-		'date_created'         => null,
27
+     * Item Data array. This is the core item data exposed in APIs.
28
+     *
29
+     * @since 1.0.19
30
+     * @var array
31
+     */
32
+    protected $data = array(
33
+        'parent_id'            => 0,
34
+        'status'               => 'draft',
35
+        'version'              => '',
36
+        'date_created'         => null,
37 37
         'date_modified'        => null,
38 38
         'name'                 => '',
39 39
         'description'          => '',
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
     );
59 59
 
60 60
     /**
61
-	 * Stores meta in cache for future reads.
62
-	 *
63
-	 * A group must be set to to enable caching.
64
-	 *
65
-	 * @var string
66
-	 */
67
-	protected $cache_group = 'getpaid_items';
61
+     * Stores meta in cache for future reads.
62
+     *
63
+     * A group must be set to to enable caching.
64
+     *
65
+     * @var string
66
+     */
67
+    protected $cache_group = 'getpaid_items';
68 68
 
69 69
     /**
70 70
      * Stores a reference to the original WP_Post object
@@ -74,37 +74,37 @@  discard block
 block discarded – undo
74 74
     protected $post = null;
75 75
 
76 76
     /**
77
-	 * Get the item if ID is passed, otherwise the item is new and empty.
78
-	 *
79
-	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80
-	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
83
-
84
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
90
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
-			$this->set_id( $item_id );
92
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
-			$this->set_id( $item_id );
94
-		} else {
95
-			$this->set_object_read( true );
96
-		}
77
+     * Get the item if ID is passed, otherwise the item is new and empty.
78
+     *
79
+     * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80
+     */
81
+    public function __construct( $item = 0 ) {
82
+        parent::__construct( $item );
83
+
84
+        if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
+            $this->set_id( $item );
86
+        } elseif ( $item instanceof self ) {
87
+            $this->set_id( $item->get_id() );
88
+        } elseif ( ! empty( $item->ID ) ) {
89
+            $this->set_id( $item->ID );
90
+        } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
+            $this->set_id( $item_id );
92
+        } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
+            $this->set_id( $item_id );
94
+        } else {
95
+            $this->set_object_read( true );
96
+        }
97 97
 
98 98
         // Load the datastore.
99
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
99
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
100 100
 
101
-		if ( $this->get_id() > 0 ) {
101
+        if ( $this->get_id() > 0 ) {
102 102
             $this->post = get_post( $this->get_id() );
103 103
             $this->ID   = $this->get_id();
104
-			$this->data_store->read( $this );
104
+            $this->data_store->read( $this );
105 105
         }
106 106
 
107
-	}
107
+    }
108 108
 
109 109
     /*
110 110
 	|--------------------------------------------------------------------------
@@ -122,401 +122,401 @@  discard block
 block discarded – undo
122 122
     */
123 123
 
124 124
     /**
125
-	 * Get parent item ID.
126
-	 *
127
-	 * @since 1.0.19
128
-	 * @param  string $context View or edit context.
129
-	 * @return int
130
-	 */
131
-	public function get_parent_id( $context = 'view' ) {
132
-		return (int) $this->get_prop( 'parent_id', $context );
125
+     * Get parent item ID.
126
+     *
127
+     * @since 1.0.19
128
+     * @param  string $context View or edit context.
129
+     * @return int
130
+     */
131
+    public function get_parent_id( $context = 'view' ) {
132
+        return (int) $this->get_prop( 'parent_id', $context );
133 133
     }
134 134
 
135 135
     /**
136
-	 * Get item status.
137
-	 *
138
-	 * @since 1.0.19
139
-	 * @param  string $context View or edit context.
140
-	 * @return string
141
-	 */
142
-	public function get_status( $context = 'view' ) {
143
-		return $this->get_prop( 'status', $context );
136
+     * Get item status.
137
+     *
138
+     * @since 1.0.19
139
+     * @param  string $context View or edit context.
140
+     * @return string
141
+     */
142
+    public function get_status( $context = 'view' ) {
143
+        return $this->get_prop( 'status', $context );
144 144
     }
145 145
 
146 146
     /**
147
-	 * Get plugin version when the item was created.
148
-	 *
149
-	 * @since 1.0.19
150
-	 * @param  string $context View or edit context.
151
-	 * @return string
152
-	 */
153
-	public function get_version( $context = 'view' ) {
154
-		return $this->get_prop( 'version', $context );
147
+     * Get plugin version when the item was created.
148
+     *
149
+     * @since 1.0.19
150
+     * @param  string $context View or edit context.
151
+     * @return string
152
+     */
153
+    public function get_version( $context = 'view' ) {
154
+        return $this->get_prop( 'version', $context );
155 155
     }
156 156
 
157 157
     /**
158
-	 * Get date when the item was created.
159
-	 *
160
-	 * @since 1.0.19
161
-	 * @param  string $context View or edit context.
162
-	 * @return string
163
-	 */
164
-	public function get_date_created( $context = 'view' ) {
165
-		return $this->get_prop( 'date_created', $context );
158
+     * Get date when the item was created.
159
+     *
160
+     * @since 1.0.19
161
+     * @param  string $context View or edit context.
162
+     * @return string
163
+     */
164
+    public function get_date_created( $context = 'view' ) {
165
+        return $this->get_prop( 'date_created', $context );
166 166
     }
167 167
 
168 168
     /**
169
-	 * Get GMT date when the item was created.
170
-	 *
171
-	 * @since 1.0.19
172
-	 * @param  string $context View or edit context.
173
-	 * @return string
174
-	 */
175
-	public function get_date_created_gmt( $context = 'view' ) {
169
+     * Get GMT date when the item was created.
170
+     *
171
+     * @since 1.0.19
172
+     * @param  string $context View or edit context.
173
+     * @return string
174
+     */
175
+    public function get_date_created_gmt( $context = 'view' ) {
176 176
         $date = $this->get_date_created( $context );
177 177
 
178 178
         if ( $date ) {
179 179
             $date = get_gmt_from_date( $date );
180 180
         }
181
-		return $date;
181
+        return $date;
182 182
     }
183 183
 
184 184
     /**
185
-	 * Get date when the item was last modified.
186
-	 *
187
-	 * @since 1.0.19
188
-	 * @param  string $context View or edit context.
189
-	 * @return string
190
-	 */
191
-	public function get_date_modified( $context = 'view' ) {
192
-		return $this->get_prop( 'date_modified', $context );
185
+     * Get date when the item was last modified.
186
+     *
187
+     * @since 1.0.19
188
+     * @param  string $context View or edit context.
189
+     * @return string
190
+     */
191
+    public function get_date_modified( $context = 'view' ) {
192
+        return $this->get_prop( 'date_modified', $context );
193 193
     }
194 194
 
195 195
     /**
196
-	 * Get GMT date when the item was last modified.
197
-	 *
198
-	 * @since 1.0.19
199
-	 * @param  string $context View or edit context.
200
-	 * @return string
201
-	 */
202
-	public function get_date_modified_gmt( $context = 'view' ) {
196
+     * Get GMT date when the item was last modified.
197
+     *
198
+     * @since 1.0.19
199
+     * @param  string $context View or edit context.
200
+     * @return string
201
+     */
202
+    public function get_date_modified_gmt( $context = 'view' ) {
203 203
         $date = $this->get_date_modified( $context );
204 204
 
205 205
         if ( $date ) {
206 206
             $date = get_gmt_from_date( $date );
207 207
         }
208
-		return $date;
208
+        return $date;
209 209
     }
210 210
 
211 211
     /**
212
-	 * Get the item name.
213
-	 *
214
-	 * @since 1.0.19
215
-	 * @param  string $context View or edit context.
216
-	 * @return string
217
-	 */
218
-	public function get_name( $context = 'view' ) {
219
-		return $this->get_prop( 'name', $context );
212
+     * Get the item name.
213
+     *
214
+     * @since 1.0.19
215
+     * @param  string $context View or edit context.
216
+     * @return string
217
+     */
218
+    public function get_name( $context = 'view' ) {
219
+        return $this->get_prop( 'name', $context );
220 220
     }
221 221
 
222 222
     /**
223
-	 * Alias of self::get_name().
224
-	 *
225
-	 * @since 1.0.19
226
-	 * @param  string $context View or edit context.
227
-	 * @return string
228
-	 */
229
-	public function get_title( $context = 'view' ) {
230
-		return $this->get_name( $context );
223
+     * Alias of self::get_name().
224
+     *
225
+     * @since 1.0.19
226
+     * @param  string $context View or edit context.
227
+     * @return string
228
+     */
229
+    public function get_title( $context = 'view' ) {
230
+        return $this->get_name( $context );
231 231
     }
232 232
 
233 233
     /**
234
-	 * Get the item description.
235
-	 *
236
-	 * @since 1.0.19
237
-	 * @param  string $context View or edit context.
238
-	 * @return string
239
-	 */
240
-	public function get_description( $context = 'view' ) {
241
-		return $this->get_prop( 'description', $context );
234
+     * Get the item description.
235
+     *
236
+     * @since 1.0.19
237
+     * @param  string $context View or edit context.
238
+     * @return string
239
+     */
240
+    public function get_description( $context = 'view' ) {
241
+        return $this->get_prop( 'description', $context );
242 242
     }
243 243
 
244 244
     /**
245
-	 * Alias of self::get_description().
246
-	 *
247
-	 * @since 1.0.19
248
-	 * @param  string $context View or edit context.
249
-	 * @return string
250
-	 */
251
-	public function get_excerpt( $context = 'view' ) {
252
-		return $this->get_description( $context );
245
+     * Alias of self::get_description().
246
+     *
247
+     * @since 1.0.19
248
+     * @param  string $context View or edit context.
249
+     * @return string
250
+     */
251
+    public function get_excerpt( $context = 'view' ) {
252
+        return $this->get_description( $context );
253 253
     }
254 254
 
255 255
     /**
256
-	 * Alias of self::get_description().
257
-	 *
258
-	 * @since 1.0.19
259
-	 * @param  string $context View or edit context.
260
-	 * @return string
261
-	 */
262
-	public function get_summary( $context = 'view' ) {
263
-		return $this->get_description( $context );
256
+     * Alias of self::get_description().
257
+     *
258
+     * @since 1.0.19
259
+     * @param  string $context View or edit context.
260
+     * @return string
261
+     */
262
+    public function get_summary( $context = 'view' ) {
263
+        return $this->get_description( $context );
264 264
     }
265 265
 
266 266
     /**
267
-	 * Get the owner of the item.
268
-	 *
269
-	 * @since 1.0.19
270
-	 * @param  string $context View or edit context.
271
-	 * @return int
272
-	 */
273
-	public function get_author( $context = 'view' ) {
274
-		return (int) $this->get_prop( 'author', $context );
275
-	}
267
+     * Get the owner of the item.
268
+     *
269
+     * @since 1.0.19
270
+     * @param  string $context View or edit context.
271
+     * @return int
272
+     */
273
+    public function get_author( $context = 'view' ) {
274
+        return (int) $this->get_prop( 'author', $context );
275
+    }
276 276
 	
277
-	/**
278
-	 * Alias of self::get_author().
279
-	 *
280
-	 * @since 1.0.19
281
-	 * @param  string $context View or edit context.
282
-	 * @return int
283
-	 */
284
-	public function get_owner( $context = 'view' ) {
285
-		return $this->get_author( $context );
286
-    }
287
-
288
-    /**
289
-	 * Get the price of the item.
290
-	 *
291
-	 * @since 1.0.19
292
-	 * @param  string $context View or edit context.
293
-	 * @return float
294
-	 */
295
-	public function get_price( $context = 'view' ) {
277
+    /**
278
+     * Alias of self::get_author().
279
+     *
280
+     * @since 1.0.19
281
+     * @param  string $context View or edit context.
282
+     * @return int
283
+     */
284
+    public function get_owner( $context = 'view' ) {
285
+        return $this->get_author( $context );
286
+    }
287
+
288
+    /**
289
+     * Get the price of the item.
290
+     *
291
+     * @since 1.0.19
292
+     * @param  string $context View or edit context.
293
+     * @return float
294
+     */
295
+    public function get_price( $context = 'view' ) {
296 296
         return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
297
-	}
297
+    }
298 298
 
299
-	/**
300
-	 * Get the inital price of the item.
301
-	 *
302
-	 * @since 1.0.19
303
-	 * @param  string $context View or edit context.
304
-	 * @return float
305
-	 */
306
-	public function get_initial_price( $context = 'view' ) {
299
+    /**
300
+     * Get the inital price of the item.
301
+     *
302
+     * @since 1.0.19
303
+     * @param  string $context View or edit context.
304
+     * @return float
305
+     */
306
+    public function get_initial_price( $context = 'view' ) {
307 307
 
308
-		$price = (float) $this->get_price( $context );
308
+        $price = (float) $this->get_price( $context );
309 309
 
310
-		if ( $this->has_free_trial() ) {
311
-			$price = 0;
312
-		}
310
+        if ( $this->has_free_trial() ) {
311
+            $price = 0;
312
+        }
313 313
 
314 314
         return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
315 315
     }
316 316
 
317 317
     /**
318
-	 * Returns a formated price.
319
-	 *
320
-	 * @since 1.0.19
321
-	 * @param  string $context View or edit context.
322
-	 * @return string
323
-	 */
318
+     * Returns a formated price.
319
+     *
320
+     * @since 1.0.19
321
+     * @param  string $context View or edit context.
322
+     * @return string
323
+     */
324 324
     public function get_the_price() {
325 325
         return wpinv_price( $this->get_price() );
326
-	}
327
-
328
-	/**
329
-	 * Returns the formated initial price.
330
-	 *
331
-	 * @since 1.0.19
332
-	 * @param  string $context View or edit context.
333
-	 * @return string
334
-	 */
326
+    }
327
+
328
+    /**
329
+     * Returns the formated initial price.
330
+     *
331
+     * @since 1.0.19
332
+     * @param  string $context View or edit context.
333
+     * @return string
334
+     */
335 335
     public function get_the_initial_price() {
336 336
         return wpinv_price( $this->get_initial_price() );
337 337
     }
338 338
 
339 339
     /**
340
-	 * Get the VAT rule of the item.
341
-	 *
342
-	 * @since 1.0.19
343
-	 * @param  string $context View or edit context.
344
-	 * @return string
345
-	 */
346
-	public function get_vat_rule( $context = 'view' ) {
340
+     * Get the VAT rule of the item.
341
+     *
342
+     * @since 1.0.19
343
+     * @param  string $context View or edit context.
344
+     * @return string
345
+     */
346
+    public function get_vat_rule( $context = 'view' ) {
347 347
         return $this->get_prop( 'vat_rule', $context );
348 348
     }
349 349
 
350 350
     /**
351
-	 * Get the VAT class of the item.
352
-	 *
353
-	 * @since 1.0.19
354
-	 * @param  string $context View or edit context.
355
-	 * @return string
356
-	 */
357
-	public function get_vat_class( $context = 'view' ) {
351
+     * Get the VAT class of the item.
352
+     *
353
+     * @since 1.0.19
354
+     * @param  string $context View or edit context.
355
+     * @return string
356
+     */
357
+    public function get_vat_class( $context = 'view' ) {
358 358
         return $this->get_prop( 'vat_class', $context );
359 359
     }
360 360
 
361 361
     /**
362
-	 * Get the type of the item.
363
-	 *
364
-	 * @since 1.0.19
365
-	 * @param  string $context View or edit context.
366
-	 * @return string
367
-	 */
368
-	public function get_type( $context = 'view' ) {
362
+     * Get the type of the item.
363
+     *
364
+     * @since 1.0.19
365
+     * @param  string $context View or edit context.
366
+     * @return string
367
+     */
368
+    public function get_type( $context = 'view' ) {
369 369
         return $this->get_prop( 'type', $context );
370 370
     }
371 371
 
372 372
     /**
373
-	 * Get the custom id of the item.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_custom_id( $context = 'view' ) {
373
+     * Get the custom id of the item.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_custom_id( $context = 'view' ) {
380 380
         return $this->get_prop( 'custom_id', $context );
381 381
     }
382 382
 
383 383
     /**
384
-	 * Get the custom name of the item.
385
-	 *
386
-	 * @since 1.0.19
387
-	 * @param  string $context View or edit context.
388
-	 * @return string
389
-	 */
390
-	public function get_custom_name( $context = 'view' ) {
384
+     * Get the custom name of the item.
385
+     *
386
+     * @since 1.0.19
387
+     * @param  string $context View or edit context.
388
+     * @return string
389
+     */
390
+    public function get_custom_name( $context = 'view' ) {
391 391
         return $this->get_prop( 'custom_name', $context );
392 392
     }
393 393
 
394 394
     /**
395
-	 * Get the custom singular name of the item.
396
-	 *
397
-	 * @since 1.0.19
398
-	 * @param  string $context View or edit context.
399
-	 * @return string
400
-	 */
401
-	public function get_custom_singular_name( $context = 'view' ) {
395
+     * Get the custom singular name of the item.
396
+     *
397
+     * @since 1.0.19
398
+     * @param  string $context View or edit context.
399
+     * @return string
400
+     */
401
+    public function get_custom_singular_name( $context = 'view' ) {
402 402
         return $this->get_prop( 'custom_singular_name', $context );
403 403
     }
404 404
 
405 405
     /**
406
-	 * Checks if an item is editable..
407
-	 *
408
-	 * @since 1.0.19
409
-	 * @param  string $context View or edit context.
410
-	 * @return int
411
-	 */
412
-	public function get_is_editable( $context = 'view' ) {
406
+     * Checks if an item is editable..
407
+     *
408
+     * @since 1.0.19
409
+     * @param  string $context View or edit context.
410
+     * @return int
411
+     */
412
+    public function get_is_editable( $context = 'view' ) {
413 413
         return (int) $this->get_prop( 'is_editable', $context );
414 414
     }
415 415
 
416 416
     /**
417
-	 * Alias of self::get_is_editable().
418
-	 *
419
-	 * @since 1.0.19
420
-	 * @param  string $context View or edit context.
421
-	 * @return int
422
-	 */
423
-	public function get_editable( $context = 'view' ) {
424
-		return $this->get_is_editable( $context );
417
+     * Alias of self::get_is_editable().
418
+     *
419
+     * @since 1.0.19
420
+     * @param  string $context View or edit context.
421
+     * @return int
422
+     */
423
+    public function get_editable( $context = 'view' ) {
424
+        return $this->get_is_editable( $context );
425 425
     }
426 426
 
427 427
     /**
428
-	 * Checks if dynamic pricing is enabled.
429
-	 *
430
-	 * @since 1.0.19
431
-	 * @param  string $context View or edit context.
432
-	 * @return int
433
-	 */
434
-	public function get_is_dynamic_pricing( $context = 'view' ) {
428
+     * Checks if dynamic pricing is enabled.
429
+     *
430
+     * @since 1.0.19
431
+     * @param  string $context View or edit context.
432
+     * @return int
433
+     */
434
+    public function get_is_dynamic_pricing( $context = 'view' ) {
435 435
         return (int) $this->get_prop( 'is_dynamic_pricing', $context );
436 436
     }
437 437
 
438 438
     /**
439
-	 * Returns the minimum price if dynamic pricing is enabled.
440
-	 *
441
-	 * @since 1.0.19
442
-	 * @param  string $context View or edit context.
443
-	 * @return float
444
-	 */
445
-	public function get_minimum_price( $context = 'view' ) {
439
+     * Returns the minimum price if dynamic pricing is enabled.
440
+     *
441
+     * @since 1.0.19
442
+     * @param  string $context View or edit context.
443
+     * @return float
444
+     */
445
+    public function get_minimum_price( $context = 'view' ) {
446 446
         return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
447 447
     }
448 448
 
449 449
     /**
450
-	 * Checks if this is a recurring item.
451
-	 *
452
-	 * @since 1.0.19
453
-	 * @param  string $context View or edit context.
454
-	 * @return int
455
-	 */
456
-	public function get_is_recurring( $context = 'view' ) {
450
+     * Checks if this is a recurring item.
451
+     *
452
+     * @since 1.0.19
453
+     * @param  string $context View or edit context.
454
+     * @return int
455
+     */
456
+    public function get_is_recurring( $context = 'view' ) {
457 457
         return (int) $this->get_prop( 'is_recurring', $context );
458
-	}
458
+    }
459 459
 	
460
-	/**
461
-	 * Get the recurring price of the item.
462
-	 *
463
-	 * @since 1.0.19
464
-	 * @param  string $context View or edit context.
465
-	 * @return float
466
-	 */
467
-	public function get_recurring_price( $context = 'view' ) {
468
-		$price = $this->get_price( $context );
460
+    /**
461
+     * Get the recurring price of the item.
462
+     *
463
+     * @since 1.0.19
464
+     * @param  string $context View or edit context.
465
+     * @return float
466
+     */
467
+    public function get_recurring_price( $context = 'view' ) {
468
+        $price = $this->get_price( $context );
469 469
         return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
470
-	}
471
-
472
-	/**
473
-	 * Get the formatted recurring price of the item.
474
-	 *
475
-	 * @since 1.0.19
476
-	 * @param  string $context View or edit context.
477
-	 * @return string
478
-	 */
470
+    }
471
+
472
+    /**
473
+     * Get the formatted recurring price of the item.
474
+     *
475
+     * @since 1.0.19
476
+     * @param  string $context View or edit context.
477
+     * @return string
478
+     */
479 479
     public function get_the_recurring_price() {
480 480
         return wpinv_price( $this->get_recurring_price() );
481
-	}
482
-
483
-	/**
484
-	 * Get the first renewal date (in timestamps) of the item.
485
-	 *
486
-	 * @since 1.0.19
487
-	 * @return int
488
-	 */
489
-	public function get_first_renewal_date() {
490
-
491
-		$periods = array(
492
-			'D' => 'days',
493
-			'W' => 'weeks',
494
-			'M' => 'months',
495
-			'Y' => 'years',
496
-		);
497
-
498
-		$period   = $this->get_recurring_period();
499
-		$interval = $this->get_recurring_interval();
500
-
501
-		if ( $this->has_free_trial() ) {
502
-			$period   = $this->get_trial_period();
503
-			$interval = $this->get_trial_interval();
504
-		}
505
-
506
-		$period       = $periods[ $period ];
507
-		$interval     = empty( $interval ) ? 1 : $interval;
508
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
481
+    }
482
+
483
+    /**
484
+     * Get the first renewal date (in timestamps) of the item.
485
+     *
486
+     * @since 1.0.19
487
+     * @return int
488
+     */
489
+    public function get_first_renewal_date() {
490
+
491
+        $periods = array(
492
+            'D' => 'days',
493
+            'W' => 'weeks',
494
+            'M' => 'months',
495
+            'Y' => 'years',
496
+        );
497
+
498
+        $period   = $this->get_recurring_period();
499
+        $interval = $this->get_recurring_interval();
500
+
501
+        if ( $this->has_free_trial() ) {
502
+            $period   = $this->get_trial_period();
503
+            $interval = $this->get_trial_interval();
504
+        }
505
+
506
+        $period       = $periods[ $period ];
507
+        $interval     = empty( $interval ) ? 1 : $interval;
508
+        $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
509 509
         return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
510 510
     }
511 511
 
512 512
     /**
513
-	 * Get the recurring period.
514
-	 *
515
-	 * @since 1.0.19
516
-	 * @param  bool $full Return abbreviation or in full.
517
-	 * @return string
518
-	 */
519
-	public function get_recurring_period( $full = false ) {
513
+     * Get the recurring period.
514
+     *
515
+     * @since 1.0.19
516
+     * @param  bool $full Return abbreviation or in full.
517
+     * @return string
518
+     */
519
+    public function get_recurring_period( $full = false ) {
520 520
         $period = $this->get_prop( 'recurring_period', 'view' );
521 521
 
522 522
         if ( $full && ! is_bool( $full ) ) {
@@ -527,58 +527,58 @@  discard block
 block discarded – undo
527 527
     }
528 528
 
529 529
     /**
530
-	 * Get the recurring interval.
531
-	 *
532
-	 * @since 1.0.19
533
-	 * @param  string $context View or edit context.
534
-	 * @return int
535
-	 */
536
-	public function get_recurring_interval( $context = 'view' ) {
537
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
538
-		return max( 1, $interval );
530
+     * Get the recurring interval.
531
+     *
532
+     * @since 1.0.19
533
+     * @param  string $context View or edit context.
534
+     * @return int
535
+     */
536
+    public function get_recurring_interval( $context = 'view' ) {
537
+        $interval = absint( $this->get_prop( 'recurring_interval', $context ) );
538
+        return max( 1, $interval );
539 539
     }
540 540
 
541 541
     /**
542
-	 * Get the recurring limit.
543
-	 *
544
-	 * @since 1.0.19
545
-	 * @param  string $context View or edit context.
546
-	 * @return int
547
-	 */
548
-	public function get_recurring_limit( $context = 'view' ) {
542
+     * Get the recurring limit.
543
+     *
544
+     * @since 1.0.19
545
+     * @param  string $context View or edit context.
546
+     * @return int
547
+     */
548
+    public function get_recurring_limit( $context = 'view' ) {
549 549
         return (int) $this->get_prop( 'recurring_limit', $context );
550 550
     }
551 551
 
552 552
     /**
553
-	 * Checks if we have a free trial.
554
-	 *
555
-	 * @since 1.0.19
556
-	 * @param  string $context View or edit context.
557
-	 * @return int
558
-	 */
559
-	public function get_is_free_trial( $context = 'view' ) {
553
+     * Checks if we have a free trial.
554
+     *
555
+     * @since 1.0.19
556
+     * @param  string $context View or edit context.
557
+     * @return int
558
+     */
559
+    public function get_is_free_trial( $context = 'view' ) {
560 560
         return (int) $this->get_prop( 'is_free_trial', $context );
561 561
     }
562 562
 
563 563
     /**
564
-	 * Alias for self::get_is_free_trial().
565
-	 *
566
-	 * @since 1.0.19
567
-	 * @param  string $context View or edit context.
568
-	 * @return int
569
-	 */
570
-	public function get_free_trial( $context = 'view' ) {
564
+     * Alias for self::get_is_free_trial().
565
+     *
566
+     * @since 1.0.19
567
+     * @param  string $context View or edit context.
568
+     * @return int
569
+     */
570
+    public function get_free_trial( $context = 'view' ) {
571 571
         return $this->get_is_free_trial( $context );
572 572
     }
573 573
 
574 574
     /**
575
-	 * Get the trial period.
576
-	 *
577
-	 * @since 1.0.19
578
-	 * @param  bool $full Return abbreviation or in full.
579
-	 * @return string
580
-	 */
581
-	public function get_trial_period( $full = false ) {
575
+     * Get the trial period.
576
+     *
577
+     * @since 1.0.19
578
+     * @param  bool $full Return abbreviation or in full.
579
+     * @return string
580
+     */
581
+    public function get_trial_period( $full = false ) {
582 582
         $period = $this->get_prop( 'trial_period', 'view' );
583 583
 
584 584
         if ( $full && ! is_bool( $full ) ) {
@@ -589,104 +589,104 @@  discard block
 block discarded – undo
589 589
     }
590 590
 
591 591
     /**
592
-	 * Get the trial interval.
593
-	 *
594
-	 * @since 1.0.19
595
-	 * @param  string $context View or edit context.
596
-	 * @return int
597
-	 */
598
-	public function get_trial_interval( $context = 'view' ) {
592
+     * Get the trial interval.
593
+     *
594
+     * @since 1.0.19
595
+     * @param  string $context View or edit context.
596
+     * @return int
597
+     */
598
+    public function get_trial_interval( $context = 'view' ) {
599 599
         return (int) $this->get_prop( 'trial_interval', $context );
600
-	}
600
+    }
601 601
 	
602
-	/**
603
-	 * Get the item's edit url.
604
-	 *
605
-	 * @since 1.0.19
606
-	 * @return string
607
-	 */
608
-	public function get_edit_url() {
602
+    /**
603
+     * Get the item's edit url.
604
+     *
605
+     * @since 1.0.19
606
+     * @return string
607
+     */
608
+    public function get_edit_url() {
609 609
         return get_edit_post_link( $this->get_id(), 'edit' );
610
-	}
611
-
612
-	/**
613
-	 * Given an item's name/custom id, it returns its id.
614
-	 *
615
-	 *
616
-	 * @static
617
-	 * @param string $value The item name or custom id.
618
-	 * @param string $field Either name or custom_id.
619
-	 * @param string $type in case you need to search for a given type.
620
-	 * @since 1.0.15
621
-	 * @return int
622
-	 */
623
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
624
-
625
-		// Trim the value.
626
-		$value = sanitize_text_field( $value );
627
-		if ( empty( $value ) ) {
628
-			return 0;
629
-		}
610
+    }
611
+
612
+    /**
613
+     * Given an item's name/custom id, it returns its id.
614
+     *
615
+     *
616
+     * @static
617
+     * @param string $value The item name or custom id.
618
+     * @param string $field Either name or custom_id.
619
+     * @param string $type in case you need to search for a given type.
620
+     * @since 1.0.15
621
+     * @return int
622
+     */
623
+    public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
624
+
625
+        // Trim the value.
626
+        $value = sanitize_text_field( $value );
627
+        if ( empty( $value ) ) {
628
+            return 0;
629
+        }
630 630
 
631 631
         // Valid fields.
632 632
         $fields = array( 'custom_id', 'name', 'slug' );
633 633
 
634
-		// Ensure a field has been passed.
635
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
636
-			return 0;
637
-		}
638
-
639
-		if ( $field == 'name' ) {
640
-			$field = 'slug';
641
-		}
642
-
643
-		// Maybe retrieve from the cache.
644
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
645
-		if ( ! empty( $item_id ) ) {
646
-			return $item_id;
647
-		}
648
-
649
-		// Fetch from the db.
650
-		$items = array();
651
-		if ( $field == 'slug' ) {
652
-			$items = get_posts(
653
-				array(
654
-					'post_type'      => 'wpi_item',
655
-					'name'           => $value,
656
-					'posts_per_page' => 1,
657
-					'post_status'    => 'any',
658
-				)
659
-			);
660
-		}
661
-
662
-		if ( $field =='custom_id' ) {
663
-			$items = get_posts(
664
-				array(
665
-					'post_type'      => 'wpi_item',
666
-					'posts_per_page' => 1,
667
-					'post_status'    => 'any',
668
-					'meta_query'     => array(
669
-						array(
670
-							'key'   => '_wpinv_type',
671
-                			'value' => $type,
672
-						),
673
-						array(
674
-							'key'   => '_wpinv_custom_id',
675
-                			'value' => $value,
676
-						)
677
-					)
678
-				)
679
-			);
680
-		}
681
-
682
-		if ( empty( $items ) ) {
683
-			return 0;
684
-		}
685
-
686
-		// Update the cache with our data
687
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
688
-
689
-		return $items[0]->ID;
634
+        // Ensure a field has been passed.
635
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
636
+            return 0;
637
+        }
638
+
639
+        if ( $field == 'name' ) {
640
+            $field = 'slug';
641
+        }
642
+
643
+        // Maybe retrieve from the cache.
644
+        $item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
645
+        if ( ! empty( $item_id ) ) {
646
+            return $item_id;
647
+        }
648
+
649
+        // Fetch from the db.
650
+        $items = array();
651
+        if ( $field == 'slug' ) {
652
+            $items = get_posts(
653
+                array(
654
+                    'post_type'      => 'wpi_item',
655
+                    'name'           => $value,
656
+                    'posts_per_page' => 1,
657
+                    'post_status'    => 'any',
658
+                )
659
+            );
660
+        }
661
+
662
+        if ( $field =='custom_id' ) {
663
+            $items = get_posts(
664
+                array(
665
+                    'post_type'      => 'wpi_item',
666
+                    'posts_per_page' => 1,
667
+                    'post_status'    => 'any',
668
+                    'meta_query'     => array(
669
+                        array(
670
+                            'key'   => '_wpinv_type',
671
+                            'value' => $type,
672
+                        ),
673
+                        array(
674
+                            'key'   => '_wpinv_custom_id',
675
+                            'value' => $value,
676
+                        )
677
+                    )
678
+                )
679
+            );
680
+        }
681
+
682
+        if ( empty( $items ) ) {
683
+            return 0;
684
+        }
685
+
686
+        // Update the cache with our data
687
+        wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
688
+
689
+        return $items[0]->ID;
690 690
     }
691 691
 
692 692
     /**
@@ -719,52 +719,52 @@  discard block
 block discarded – undo
719 719
     */
720 720
 
721 721
     /**
722
-	 * Set parent order ID.
723
-	 *
724
-	 * @since 1.0.19
725
-	 */
726
-	public function set_parent_id( $value ) {
727
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
728
-			return;
729
-		}
730
-		$this->set_prop( 'parent_id', absint( $value ) );
731
-	}
732
-
733
-    /**
734
-	 * Sets item status.
735
-	 *
736
-	 * @since 1.0.19
737
-	 * @param  string $status New status.
738
-	 * @return array details of change.
739
-	 */
740
-	public function set_status( $status ) {
722
+     * Set parent order ID.
723
+     *
724
+     * @since 1.0.19
725
+     */
726
+    public function set_parent_id( $value ) {
727
+        if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
728
+            return;
729
+        }
730
+        $this->set_prop( 'parent_id', absint( $value ) );
731
+    }
732
+
733
+    /**
734
+     * Sets item status.
735
+     *
736
+     * @since 1.0.19
737
+     * @param  string $status New status.
738
+     * @return array details of change.
739
+     */
740
+    public function set_status( $status ) {
741 741
         $old_status = $this->get_status();
742 742
 
743 743
         $this->set_prop( 'status', $status );
744 744
 
745
-		return array(
746
-			'from' => $old_status,
747
-			'to'   => $status,
748
-		);
745
+        return array(
746
+            'from' => $old_status,
747
+            'to'   => $status,
748
+        );
749 749
     }
750 750
 
751 751
     /**
752
-	 * Set plugin version when the item was created.
753
-	 *
754
-	 * @since 1.0.19
755
-	 */
756
-	public function set_version( $value ) {
757
-		$this->set_prop( 'version', $value );
752
+     * Set plugin version when the item was created.
753
+     *
754
+     * @since 1.0.19
755
+     */
756
+    public function set_version( $value ) {
757
+        $this->set_prop( 'version', $value );
758 758
     }
759 759
 
760 760
     /**
761
-	 * Set date when the item was created.
762
-	 *
763
-	 * @since 1.0.19
764
-	 * @param string $value Value to set.
761
+     * Set date when the item was created.
762
+     *
763
+     * @since 1.0.19
764
+     * @param string $value Value to set.
765 765
      * @return bool Whether or not the date was set.
766
-	 */
767
-	public function set_date_created( $value ) {
766
+     */
767
+    public function set_date_created( $value ) {
768 768
         $date = strtotime( $value );
769 769
 
770 770
         if ( $date ) {
@@ -777,13 +777,13 @@  discard block
 block discarded – undo
777 777
     }
778 778
 
779 779
     /**
780
-	 * Set date when the item was last modified.
781
-	 *
782
-	 * @since 1.0.19
783
-	 * @param string $value Value to set.
780
+     * Set date when the item was last modified.
781
+     *
782
+     * @since 1.0.19
783
+     * @param string $value Value to set.
784 784
      * @return bool Whether or not the date was set.
785
-	 */
786
-	public function set_date_modified( $value ) {
785
+     */
786
+    public function set_date_modified( $value ) {
787 787
         $date = strtotime( $value );
788 788
 
789 789
         if ( $date ) {
@@ -796,115 +796,115 @@  discard block
 block discarded – undo
796 796
     }
797 797
 
798 798
     /**
799
-	 * Set the item name.
800
-	 *
801
-	 * @since 1.0.19
802
-	 * @param  string $value New name.
803
-	 */
804
-	public function set_name( $value ) {
799
+     * Set the item name.
800
+     *
801
+     * @since 1.0.19
802
+     * @param  string $value New name.
803
+     */
804
+    public function set_name( $value ) {
805 805
         $name = sanitize_text_field( $value );
806
-		$this->set_prop( 'name', $name );
806
+        $this->set_prop( 'name', $name );
807 807
     }
808 808
 
809 809
     /**
810
-	 * Alias of self::set_name().
811
-	 *
812
-	 * @since 1.0.19
813
-	 * @param  string $value New name.
814
-	 */
815
-	public function set_title( $value ) {
816
-		$this->set_name( $value );
810
+     * Alias of self::set_name().
811
+     *
812
+     * @since 1.0.19
813
+     * @param  string $value New name.
814
+     */
815
+    public function set_title( $value ) {
816
+        $this->set_name( $value );
817 817
     }
818 818
 
819 819
     /**
820
-	 * Set the item description.
821
-	 *
822
-	 * @since 1.0.19
823
-	 * @param  string $value New description.
824
-	 */
825
-	public function set_description( $value ) {
826
-		$description = wp_kses_post( wp_unslash( $value ) );
827
-		return $this->set_prop( 'description', $description );
820
+     * Set the item description.
821
+     *
822
+     * @since 1.0.19
823
+     * @param  string $value New description.
824
+     */
825
+    public function set_description( $value ) {
826
+        $description = wp_kses_post( wp_unslash( $value ) );
827
+        return $this->set_prop( 'description', $description );
828 828
     }
829 829
 
830 830
     /**
831
-	 * Alias of self::set_description().
832
-	 *
833
-	 * @since 1.0.19
834
-	 * @param  string $value New description.
835
-	 */
836
-	public function set_excerpt( $value ) {
837
-		$this->set_description( $value );
831
+     * Alias of self::set_description().
832
+     *
833
+     * @since 1.0.19
834
+     * @param  string $value New description.
835
+     */
836
+    public function set_excerpt( $value ) {
837
+        $this->set_description( $value );
838 838
     }
839 839
 
840 840
     /**
841
-	 * Alias of self::set_description().
842
-	 *
843
-	 * @since 1.0.19
844
-	 * @param  string $value New description.
845
-	 */
846
-	public function set_summary( $value ) {
847
-		$this->set_description( $value );
841
+     * Alias of self::set_description().
842
+     *
843
+     * @since 1.0.19
844
+     * @param  string $value New description.
845
+     */
846
+    public function set_summary( $value ) {
847
+        $this->set_description( $value );
848 848
     }
849 849
 
850 850
     /**
851
-	 * Set the owner of the item.
852
-	 *
853
-	 * @since 1.0.19
854
-	 * @param  int $value New author.
855
-	 */
856
-	public function set_author( $value ) {
857
-		$this->set_prop( 'author', (int) $value );
858
-	}
851
+     * Set the owner of the item.
852
+     *
853
+     * @since 1.0.19
854
+     * @param  int $value New author.
855
+     */
856
+    public function set_author( $value ) {
857
+        $this->set_prop( 'author', (int) $value );
858
+    }
859 859
 	
860
-	/**
861
-	 * Alias of self::set_author().
862
-	 *
863
-	 * @since 1.0.19
864
-	 * @param  int $value New author.
865
-	 */
866
-	public function set_owner( $value ) {
867
-		$this->set_author( $value );
868
-    }
869
-
870
-    /**
871
-	 * Set the price of the item.
872
-	 *
873
-	 * @since 1.0.19
874
-	 * @param  float $value New price.
875
-	 */
876
-	public function set_price( $value ) {
860
+    /**
861
+     * Alias of self::set_author().
862
+     *
863
+     * @since 1.0.19
864
+     * @param  int $value New author.
865
+     */
866
+    public function set_owner( $value ) {
867
+        $this->set_author( $value );
868
+    }
869
+
870
+    /**
871
+     * Set the price of the item.
872
+     *
873
+     * @since 1.0.19
874
+     * @param  float $value New price.
875
+     */
876
+    public function set_price( $value ) {
877 877
         $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
878 878
     }
879 879
 
880 880
     /**
881
-	 * Set the VAT rule of the item.
882
-	 *
883
-	 * @since 1.0.19
884
-	 * @param  string $value new rule.
885
-	 */
886
-	public function set_vat_rule( $value ) {
881
+     * Set the VAT rule of the item.
882
+     *
883
+     * @since 1.0.19
884
+     * @param  string $value new rule.
885
+     */
886
+    public function set_vat_rule( $value ) {
887 887
         $this->set_prop( 'vat_rule', $value );
888 888
     }
889 889
 
890 890
     /**
891
-	 * Set the VAT class of the item.
892
-	 *
893
-	 * @since 1.0.19
894
-	 * @param  string $value new class.
895
-	 */
896
-	public function set_vat_class( $value ) {
891
+     * Set the VAT class of the item.
892
+     *
893
+     * @since 1.0.19
894
+     * @param  string $value new class.
895
+     */
896
+    public function set_vat_class( $value ) {
897 897
         $this->set_prop( 'vat_class', $value );
898 898
     }
899 899
 
900 900
     /**
901
-	 * Set the type of the item.
902
-	 *
903
-	 * @since 1.0.19
904
-	 * @param  string $value new item type.
905
-	 * @return string
906
-	 */
907
-	public function set_type( $value ) {
901
+     * Set the type of the item.
902
+     *
903
+     * @since 1.0.19
904
+     * @param  string $value new item type.
905
+     * @return string
906
+     */
907
+    public function set_type( $value ) {
908 908
 
909 909
         if ( empty( $value ) ) {
910 910
             $value = 'custom';
@@ -914,132 +914,132 @@  discard block
 block discarded – undo
914 914
     }
915 915
 
916 916
     /**
917
-	 * Set the custom id of the item.
918
-	 *
919
-	 * @since 1.0.19
920
-	 * @param  string $value new custom id.
921
-	 */
922
-	public function set_custom_id( $value ) {
917
+     * Set the custom id of the item.
918
+     *
919
+     * @since 1.0.19
920
+     * @param  string $value new custom id.
921
+     */
922
+    public function set_custom_id( $value ) {
923 923
         $this->set_prop( 'custom_id', $value );
924 924
     }
925 925
 
926 926
     /**
927
-	 * Set the custom name of the item.
928
-	 *
929
-	 * @since 1.0.19
930
-	 * @param  string $value new custom name.
931
-	 */
932
-	public function set_custom_name( $value ) {
927
+     * Set the custom name of the item.
928
+     *
929
+     * @since 1.0.19
930
+     * @param  string $value new custom name.
931
+     */
932
+    public function set_custom_name( $value ) {
933 933
         $this->set_prop( 'custom_name', $value );
934 934
     }
935 935
 
936 936
     /**
937
-	 * Set the custom singular name of the item.
938
-	 *
939
-	 * @since 1.0.19
940
-	 * @param  string $value new custom singular name.
941
-	 */
942
-	public function set_custom_singular_name( $value ) {
937
+     * Set the custom singular name of the item.
938
+     *
939
+     * @since 1.0.19
940
+     * @param  string $value new custom singular name.
941
+     */
942
+    public function set_custom_singular_name( $value ) {
943 943
         $this->set_prop( 'custom_singular_name', $value );
944 944
     }
945 945
 
946 946
     /**
947
-	 * Sets if an item is editable..
948
-	 *
949
-	 * @since 1.0.19
950
-	 * @param  int|bool $value whether or not the item is editable.
951
-	 */
952
-	public function set_is_editable( $value ) {
953
-		$this->set_prop( 'is_editable', (int) $value );
947
+     * Sets if an item is editable..
948
+     *
949
+     * @since 1.0.19
950
+     * @param  int|bool $value whether or not the item is editable.
951
+     */
952
+    public function set_is_editable( $value ) {
953
+        $this->set_prop( 'is_editable', (int) $value );
954 954
     }
955 955
 
956 956
     /**
957
-	 * Sets if dynamic pricing is enabled.
958
-	 *
959
-	 * @since 1.0.19
960
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
961
-	 */
962
-	public function set_is_dynamic_pricing( $value ) {
957
+     * Sets if dynamic pricing is enabled.
958
+     *
959
+     * @since 1.0.19
960
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
961
+     */
962
+    public function set_is_dynamic_pricing( $value ) {
963 963
         $this->set_prop( 'is_dynamic_pricing', (int) $value );
964 964
     }
965 965
 
966 966
     /**
967
-	 * Sets the minimum price if dynamic pricing is enabled.
968
-	 *
969
-	 * @since 1.0.19
970
-	 * @param  float $value minimum price.
971
-	 */
972
-	public function set_minimum_price( $value ) {
967
+     * Sets the minimum price if dynamic pricing is enabled.
968
+     *
969
+     * @since 1.0.19
970
+     * @param  float $value minimum price.
971
+     */
972
+    public function set_minimum_price( $value ) {
973 973
         $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
974 974
     }
975 975
 
976 976
     /**
977
-	 * Sets if this is a recurring item.
978
-	 *
979
-	 * @since 1.0.19
980
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
981
-	 */
982
-	public function set_is_recurring( $value ) {
977
+     * Sets if this is a recurring item.
978
+     *
979
+     * @since 1.0.19
980
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
981
+     */
982
+    public function set_is_recurring( $value ) {
983 983
         $this->set_prop( 'is_recurring', (int) $value );
984 984
     }
985 985
 
986 986
     /**
987
-	 * Set the recurring period.
988
-	 *
989
-	 * @since 1.0.19
990
-	 * @param  string $value new period.
991
-	 */
992
-	public function set_recurring_period( $value ) {
987
+     * Set the recurring period.
988
+     *
989
+     * @since 1.0.19
990
+     * @param  string $value new period.
991
+     */
992
+    public function set_recurring_period( $value ) {
993 993
         $this->set_prop( 'recurring_period', $value );
994 994
     }
995 995
 
996 996
     /**
997
-	 * Set the recurring interval.
998
-	 *
999
-	 * @since 1.0.19
1000
-	 * @param  int $value recurring interval.
1001
-	 */
1002
-	public function set_recurring_interval( $value ) {
997
+     * Set the recurring interval.
998
+     *
999
+     * @since 1.0.19
1000
+     * @param  int $value recurring interval.
1001
+     */
1002
+    public function set_recurring_interval( $value ) {
1003 1003
         return $this->set_prop( 'recurring_interval', (int) $value );
1004 1004
     }
1005 1005
 
1006 1006
     /**
1007
-	 * Get the recurring limit.
1008
-	 * @since 1.0.19
1009
-	 * @param  int $value The recurring limit.
1010
-	 * @return int
1011
-	 */
1012
-	public function set_recurring_limit( $value ) {
1007
+     * Get the recurring limit.
1008
+     * @since 1.0.19
1009
+     * @param  int $value The recurring limit.
1010
+     * @return int
1011
+     */
1012
+    public function set_recurring_limit( $value ) {
1013 1013
         $this->set_prop( 'recurring_limit', (int) $value );
1014 1014
     }
1015 1015
 
1016 1016
     /**
1017
-	 * Checks if we have a free trial.
1018
-	 *
1019
-	 * @since 1.0.19
1020
-	 * @param  int|bool $value whether or not it has a free trial.
1021
-	 */
1022
-	public function set_is_free_trial( $value ) {
1017
+     * Checks if we have a free trial.
1018
+     *
1019
+     * @since 1.0.19
1020
+     * @param  int|bool $value whether or not it has a free trial.
1021
+     */
1022
+    public function set_is_free_trial( $value ) {
1023 1023
         $this->set_prop( 'is_free_trial', (int) $value );
1024 1024
     }
1025 1025
 
1026 1026
     /**
1027
-	 * Set the trial period.
1028
-	 *
1029
-	 * @since 1.0.19
1030
-	 * @param  string $value trial period.
1031
-	 */
1032
-	public function set_trial_period( $value ) {
1027
+     * Set the trial period.
1028
+     *
1029
+     * @since 1.0.19
1030
+     * @param  string $value trial period.
1031
+     */
1032
+    public function set_trial_period( $value ) {
1033 1033
         $this->set_prop( 'trial_period', $value );
1034 1034
     }
1035 1035
 
1036 1036
     /**
1037
-	 * Set the trial interval.
1038
-	 *
1039
-	 * @since 1.0.19
1040
-	 * @param  int $value trial interval.
1041
-	 */
1042
-	public function set_trial_interval( $value ) {
1037
+     * Set the trial interval.
1038
+     *
1039
+     * @since 1.0.19
1040
+     * @param  int $value trial interval.
1041
+     */
1042
+    public function set_trial_interval( $value ) {
1043 1043
         $this->set_prop( 'trial_interval', $value );
1044 1044
     }
1045 1045
 
@@ -1047,17 +1047,17 @@  discard block
 block discarded – undo
1047 1047
      * Create an item. For backwards compatibilty.
1048 1048
      * 
1049 1049
      * @deprecated
1050
-	 * @return int item id
1050
+     * @return int item id
1051 1051
      */
1052 1052
     public function create( $data = array() ) {
1053 1053
 
1054
-		// Set the properties.
1055
-		if ( is_array( $data ) ) {
1056
-			$this->set_props( $data );
1057
-		}
1054
+        // Set the properties.
1055
+        if ( is_array( $data ) ) {
1056
+            $this->set_props( $data );
1057
+        }
1058 1058
 
1059
-		// Save the item.
1060
-		return $this->save();
1059
+        // Save the item.
1060
+        return $this->save();
1061 1061
 
1062 1062
     }
1063 1063
 
@@ -1065,7 +1065,7 @@  discard block
 block discarded – undo
1065 1065
      * Updates an item. For backwards compatibilty.
1066 1066
      * 
1067 1067
      * @deprecated
1068
-	 * @return int item id
1068
+     * @return int item id
1069 1069
      */
1070 1070
     public function update( $data = array() ) {
1071 1071
         return $this->create( $data );
@@ -1081,93 +1081,93 @@  discard block
 block discarded – undo
1081 1081
 	*/
1082 1082
 
1083 1083
     /**
1084
-	 * Checks whether the item has enabled dynamic pricing.
1085
-	 *
1086
-	 * @since 1.0.19
1087
-	 * @return bool
1088
-	 */
1089
-	public function user_can_set_their_price() {
1084
+     * Checks whether the item has enabled dynamic pricing.
1085
+     *
1086
+     * @since 1.0.19
1087
+     * @return bool
1088
+     */
1089
+    public function user_can_set_their_price() {
1090 1090
         return (bool) $this->get_is_dynamic_pricing();
1091
-	}
1091
+    }
1092 1092
 	
1093
-	/**
1094
-	 * Checks whether the item is recurring.
1095
-	 *
1096
-	 * @since 1.0.19
1097
-	 * @return bool
1098
-	 */
1099
-	public function is_recurring() {
1093
+    /**
1094
+     * Checks whether the item is recurring.
1095
+     *
1096
+     * @since 1.0.19
1097
+     * @return bool
1098
+     */
1099
+    public function is_recurring() {
1100 1100
         return (bool) $this->get_is_recurring();
1101 1101
     }
1102 1102
 
1103 1103
     /**
1104
-	 * Checks whether the item has a free trial.
1105
-	 *
1106
-	 * @since 1.0.19
1107
-	 * @return bool
1108
-	 */
1104
+     * Checks whether the item has a free trial.
1105
+     *
1106
+     * @since 1.0.19
1107
+     * @return bool
1108
+     */
1109 1109
     public function has_free_trial() {
1110 1110
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1111 1111
         return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1112 1112
     }
1113 1113
 
1114 1114
     /**
1115
-	 * Checks whether the item is free.
1116
-	 *
1117
-	 * @since 1.0.19
1118
-	 * @return bool
1119
-	 */
1115
+     * Checks whether the item is free.
1116
+     *
1117
+     * @since 1.0.19
1118
+     * @return bool
1119
+     */
1120 1120
     public function is_free() {
1121 1121
         $is_free   = $this->get_price() == 0;
1122 1122
         return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1123 1123
     }
1124 1124
 
1125 1125
     /**
1126
-	 * Checks the item status against a passed in status.
1127
-	 *
1128
-	 * @param array|string $status Status to check.
1129
-	 * @return bool
1130
-	 */
1131
-	public function has_status( $status ) {
1132
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1133
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1126
+     * Checks the item status against a passed in status.
1127
+     *
1128
+     * @param array|string $status Status to check.
1129
+     * @return bool
1130
+     */
1131
+    public function has_status( $status ) {
1132
+        $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1133
+        return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1134 1134
     }
1135 1135
 
1136 1136
     /**
1137
-	 * Checks the item type against a passed in types.
1138
-	 *
1139
-	 * @param array|string $type Type to check.
1140
-	 * @return bool
1141
-	 */
1142
-	public function is_type( $type ) {
1143
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1144
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1145
-	}
1137
+     * Checks the item type against a passed in types.
1138
+     *
1139
+     * @param array|string $type Type to check.
1140
+     * @return bool
1141
+     */
1142
+    public function is_type( $type ) {
1143
+        $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1144
+        return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1145
+    }
1146 1146
 
1147 1147
     /**
1148
-	 * Checks whether the item is editable.
1149
-	 *
1150
-	 * @since 1.0.19
1151
-	 * @return bool
1152
-	 */
1148
+     * Checks whether the item is editable.
1149
+     *
1150
+     * @since 1.0.19
1151
+     * @return bool
1152
+     */
1153 1153
     public function is_editable() {
1154 1154
         $is_editable = $this->get_is_editable();
1155 1155
         return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1156
-	}
1156
+    }
1157 1157
 
1158
-	/**
1159
-	 * Returns an array of cart fees.
1160
-	 */
1161
-	public function get_fees() {
1158
+    /**
1159
+     * Returns an array of cart fees.
1160
+     */
1161
+    public function get_fees() {
1162 1162
         return array();
1163 1163
     }
1164 1164
 
1165 1165
     /**
1166
-	 * Checks whether the item is purchasable.
1167
-	 *
1168
-	 * @since 1.0.19
1169
-	 * @return bool
1170
-	 */
1166
+     * Checks whether the item is purchasable.
1167
+     *
1168
+     * @since 1.0.19
1169
+     * @return bool
1170
+     */
1171 1171
     public function can_purchase() {
1172 1172
         $can_purchase = $this->exists();
1173 1173
 
@@ -1179,11 +1179,11 @@  discard block
 block discarded – undo
1179 1179
     }
1180 1180
 
1181 1181
     /**
1182
-	 * Checks whether the item supports dynamic pricing.
1183
-	 *
1184
-	 * @since 1.0.19
1185
-	 * @return bool
1186
-	 */
1182
+     * Checks whether the item supports dynamic pricing.
1183
+     *
1184
+     * @since 1.0.19
1185
+     * @return bool
1186
+     */
1187 1187
     public function supports_dynamic_pricing() {
1188 1188
         return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1189 1189
     }
Please login to merge, or discard this patch.
Spacing   +211 added lines, -211 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
 
@@ -78,30 +78,30 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80 80
 	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
83
-
84
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
90
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
-			$this->set_id( $item_id );
92
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
-			$this->set_id( $item_id );
81
+	public function __construct($item = 0) {
82
+		parent::__construct($item);
83
+
84
+		if (!empty($item) && is_numeric($item) && 'wpi_item' == get_post_type($item)) {
85
+			$this->set_id($item);
86
+		} elseif ($item instanceof self) {
87
+			$this->set_id($item->get_id());
88
+		} elseif (!empty($item->ID)) {
89
+			$this->set_id($item->ID);
90
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'custom_id')) {
91
+			$this->set_id($item_id);
92
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'name')) {
93
+			$this->set_id($item_id);
94 94
 		} else {
95
-			$this->set_object_read( true );
95
+			$this->set_object_read(true);
96 96
 		}
97 97
 
98 98
         // Load the datastore.
99
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
99
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
100 100
 
101
-		if ( $this->get_id() > 0 ) {
102
-            $this->post = get_post( $this->get_id() );
101
+		if ($this->get_id() > 0) {
102
+            $this->post = get_post($this->get_id());
103 103
             $this->ID   = $this->get_id();
104
-			$this->data_store->read( $this );
104
+			$this->data_store->read($this);
105 105
         }
106 106
 
107 107
 	}
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 * @param  string $context View or edit context.
129 129
 	 * @return int
130 130
 	 */
131
-	public function get_parent_id( $context = 'view' ) {
132
-		return (int) $this->get_prop( 'parent_id', $context );
131
+	public function get_parent_id($context = 'view') {
132
+		return (int) $this->get_prop('parent_id', $context);
133 133
     }
134 134
 
135 135
     /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 * @param  string $context View or edit context.
140 140
 	 * @return string
141 141
 	 */
142
-	public function get_status( $context = 'view' ) {
143
-		return $this->get_prop( 'status', $context );
142
+	public function get_status($context = 'view') {
143
+		return $this->get_prop('status', $context);
144 144
     }
145 145
 
146 146
     /**
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @param  string $context View or edit context.
151 151
 	 * @return string
152 152
 	 */
153
-	public function get_version( $context = 'view' ) {
154
-		return $this->get_prop( 'version', $context );
153
+	public function get_version($context = 'view') {
154
+		return $this->get_prop('version', $context);
155 155
     }
156 156
 
157 157
     /**
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 * @param  string $context View or edit context.
162 162
 	 * @return string
163 163
 	 */
164
-	public function get_date_created( $context = 'view' ) {
165
-		return $this->get_prop( 'date_created', $context );
164
+	public function get_date_created($context = 'view') {
165
+		return $this->get_prop('date_created', $context);
166 166
     }
167 167
 
168 168
     /**
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 	 * @param  string $context View or edit context.
173 173
 	 * @return string
174 174
 	 */
175
-	public function get_date_created_gmt( $context = 'view' ) {
176
-        $date = $this->get_date_created( $context );
175
+	public function get_date_created_gmt($context = 'view') {
176
+        $date = $this->get_date_created($context);
177 177
 
178
-        if ( $date ) {
179
-            $date = get_gmt_from_date( $date );
178
+        if ($date) {
179
+            $date = get_gmt_from_date($date);
180 180
         }
181 181
 		return $date;
182 182
     }
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	 * @param  string $context View or edit context.
189 189
 	 * @return string
190 190
 	 */
191
-	public function get_date_modified( $context = 'view' ) {
192
-		return $this->get_prop( 'date_modified', $context );
191
+	public function get_date_modified($context = 'view') {
192
+		return $this->get_prop('date_modified', $context);
193 193
     }
194 194
 
195 195
     /**
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	 * @param  string $context View or edit context.
200 200
 	 * @return string
201 201
 	 */
202
-	public function get_date_modified_gmt( $context = 'view' ) {
203
-        $date = $this->get_date_modified( $context );
202
+	public function get_date_modified_gmt($context = 'view') {
203
+        $date = $this->get_date_modified($context);
204 204
 
205
-        if ( $date ) {
206
-            $date = get_gmt_from_date( $date );
205
+        if ($date) {
206
+            $date = get_gmt_from_date($date);
207 207
         }
208 208
 		return $date;
209 209
     }
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 	 * @param  string $context View or edit context.
216 216
 	 * @return string
217 217
 	 */
218
-	public function get_name( $context = 'view' ) {
219
-		return $this->get_prop( 'name', $context );
218
+	public function get_name($context = 'view') {
219
+		return $this->get_prop('name', $context);
220 220
     }
221 221
 
222 222
     /**
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 * @param  string $context View or edit context.
227 227
 	 * @return string
228 228
 	 */
229
-	public function get_title( $context = 'view' ) {
230
-		return $this->get_name( $context );
229
+	public function get_title($context = 'view') {
230
+		return $this->get_name($context);
231 231
     }
232 232
 
233 233
     /**
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 * @param  string $context View or edit context.
238 238
 	 * @return string
239 239
 	 */
240
-	public function get_description( $context = 'view' ) {
241
-		return $this->get_prop( 'description', $context );
240
+	public function get_description($context = 'view') {
241
+		return $this->get_prop('description', $context);
242 242
     }
243 243
 
244 244
     /**
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param  string $context View or edit context.
249 249
 	 * @return string
250 250
 	 */
251
-	public function get_excerpt( $context = 'view' ) {
252
-		return $this->get_description( $context );
251
+	public function get_excerpt($context = 'view') {
252
+		return $this->get_description($context);
253 253
     }
254 254
 
255 255
     /**
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 	 * @param  string $context View or edit context.
260 260
 	 * @return string
261 261
 	 */
262
-	public function get_summary( $context = 'view' ) {
263
-		return $this->get_description( $context );
262
+	public function get_summary($context = 'view') {
263
+		return $this->get_description($context);
264 264
     }
265 265
 
266 266
     /**
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 * @param  string $context View or edit context.
271 271
 	 * @return int
272 272
 	 */
273
-	public function get_author( $context = 'view' ) {
274
-		return (int) $this->get_prop( 'author', $context );
273
+	public function get_author($context = 'view') {
274
+		return (int) $this->get_prop('author', $context);
275 275
 	}
276 276
 	
277 277
 	/**
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @param  string $context View or edit context.
282 282
 	 * @return int
283 283
 	 */
284
-	public function get_owner( $context = 'view' ) {
285
-		return $this->get_author( $context );
284
+	public function get_owner($context = 'view') {
285
+		return $this->get_author($context);
286 286
     }
287 287
 
288 288
     /**
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @param  string $context View or edit context.
293 293
 	 * @return float
294 294
 	 */
295
-	public function get_price( $context = 'view' ) {
296
-        return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
295
+	public function get_price($context = 'view') {
296
+        return wpinv_sanitize_amount($this->get_prop('price', $context));
297 297
 	}
298 298
 
299 299
 	/**
@@ -303,15 +303,15 @@  discard block
 block discarded – undo
303 303
 	 * @param  string $context View or edit context.
304 304
 	 * @return float
305 305
 	 */
306
-	public function get_initial_price( $context = 'view' ) {
306
+	public function get_initial_price($context = 'view') {
307 307
 
308
-		$price = (float) $this->get_price( $context );
308
+		$price = (float) $this->get_price($context);
309 309
 
310
-		if ( $this->has_free_trial() ) {
310
+		if ($this->has_free_trial()) {
311 311
 			$price = 0;
312 312
 		}
313 313
 
314
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
314
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_initial_item_price', $price, $this));
315 315
     }
316 316
 
317 317
     /**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 * @return string
323 323
 	 */
324 324
     public function get_the_price() {
325
-        return wpinv_price( $this->get_price() );
325
+        return wpinv_price($this->get_price());
326 326
 	}
327 327
 
328 328
 	/**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 * @return string
334 334
 	 */
335 335
     public function get_the_initial_price() {
336
-        return wpinv_price( $this->get_initial_price() );
336
+        return wpinv_price($this->get_initial_price());
337 337
     }
338 338
 
339 339
     /**
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	 * @param  string $context View or edit context.
344 344
 	 * @return string
345 345
 	 */
346
-	public function get_vat_rule( $context = 'view' ) {
347
-        return $this->get_prop( 'vat_rule', $context );
346
+	public function get_vat_rule($context = 'view') {
347
+        return $this->get_prop('vat_rule', $context);
348 348
     }
349 349
 
350 350
     /**
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 	 * @param  string $context View or edit context.
355 355
 	 * @return string
356 356
 	 */
357
-	public function get_vat_class( $context = 'view' ) {
358
-        return $this->get_prop( 'vat_class', $context );
357
+	public function get_vat_class($context = 'view') {
358
+        return $this->get_prop('vat_class', $context);
359 359
     }
360 360
 
361 361
     /**
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @param  string $context View or edit context.
366 366
 	 * @return string
367 367
 	 */
368
-	public function get_type( $context = 'view' ) {
369
-        return $this->get_prop( 'type', $context );
368
+	public function get_type($context = 'view') {
369
+        return $this->get_prop('type', $context);
370 370
     }
371 371
 
372 372
     /**
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	 * @param  string $context View or edit context.
377 377
 	 * @return string
378 378
 	 */
379
-	public function get_custom_id( $context = 'view' ) {
380
-        return $this->get_prop( 'custom_id', $context );
379
+	public function get_custom_id($context = 'view') {
380
+        return $this->get_prop('custom_id', $context);
381 381
     }
382 382
 
383 383
     /**
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 	 * @param  string $context View or edit context.
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_custom_name( $context = 'view' ) {
391
-        return $this->get_prop( 'custom_name', $context );
390
+	public function get_custom_name($context = 'view') {
391
+        return $this->get_prop('custom_name', $context);
392 392
     }
393 393
 
394 394
     /**
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
 	 * @param  string $context View or edit context.
399 399
 	 * @return string
400 400
 	 */
401
-	public function get_custom_singular_name( $context = 'view' ) {
402
-        return $this->get_prop( 'custom_singular_name', $context );
401
+	public function get_custom_singular_name($context = 'view') {
402
+        return $this->get_prop('custom_singular_name', $context);
403 403
     }
404 404
 
405 405
     /**
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
 	 * @param  string $context View or edit context.
410 410
 	 * @return int
411 411
 	 */
412
-	public function get_is_editable( $context = 'view' ) {
413
-        return (int) $this->get_prop( 'is_editable', $context );
412
+	public function get_is_editable($context = 'view') {
413
+        return (int) $this->get_prop('is_editable', $context);
414 414
     }
415 415
 
416 416
     /**
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 	 * @param  string $context View or edit context.
421 421
 	 * @return int
422 422
 	 */
423
-	public function get_editable( $context = 'view' ) {
424
-		return $this->get_is_editable( $context );
423
+	public function get_editable($context = 'view') {
424
+		return $this->get_is_editable($context);
425 425
     }
426 426
 
427 427
     /**
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @param  string $context View or edit context.
432 432
 	 * @return int
433 433
 	 */
434
-	public function get_is_dynamic_pricing( $context = 'view' ) {
435
-        return (int) $this->get_prop( 'is_dynamic_pricing', $context );
434
+	public function get_is_dynamic_pricing($context = 'view') {
435
+        return (int) $this->get_prop('is_dynamic_pricing', $context);
436 436
     }
437 437
 
438 438
     /**
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 	 * @param  string $context View or edit context.
443 443
 	 * @return float
444 444
 	 */
445
-	public function get_minimum_price( $context = 'view' ) {
446
-        return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
445
+	public function get_minimum_price($context = 'view') {
446
+        return wpinv_sanitize_amount($this->get_prop('minimum_price', $context));
447 447
     }
448 448
 
449 449
     /**
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param  string $context View or edit context.
454 454
 	 * @return int
455 455
 	 */
456
-	public function get_is_recurring( $context = 'view' ) {
457
-        return (int) $this->get_prop( 'is_recurring', $context );
456
+	public function get_is_recurring($context = 'view') {
457
+        return (int) $this->get_prop('is_recurring', $context);
458 458
 	}
459 459
 	
460 460
 	/**
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 	 * @param  string $context View or edit context.
465 465
 	 * @return float
466 466
 	 */
467
-	public function get_recurring_price( $context = 'view' ) {
468
-		$price = $this->get_price( $context );
469
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
467
+	public function get_recurring_price($context = 'view') {
468
+		$price = $this->get_price($context);
469
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_recurring_item_price', $price, $this->ID));
470 470
 	}
471 471
 
472 472
 	/**
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 * @return string
478 478
 	 */
479 479
     public function get_the_recurring_price() {
480
-        return wpinv_price( $this->get_recurring_price() );
480
+        return wpinv_price($this->get_recurring_price());
481 481
 	}
482 482
 
483 483
 	/**
@@ -498,15 +498,15 @@  discard block
 block discarded – undo
498 498
 		$period   = $this->get_recurring_period();
499 499
 		$interval = $this->get_recurring_interval();
500 500
 
501
-		if ( $this->has_free_trial() ) {
501
+		if ($this->has_free_trial()) {
502 502
 			$period   = $this->get_trial_period();
503 503
 			$interval = $this->get_trial_interval();
504 504
 		}
505 505
 
506
-		$period       = $periods[ $period ];
507
-		$interval     = empty( $interval ) ? 1 : $interval;
508
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
509
-        return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
506
+		$period       = $periods[$period];
507
+		$interval     = empty($interval) ? 1 : $interval;
508
+		$next_renewal = strtotime("+$interval $period", current_time('timestamp'));
509
+        return apply_filters('wpinv_get_first_renewal_date', $next_renewal, $this);
510 510
     }
511 511
 
512 512
     /**
@@ -516,14 +516,14 @@  discard block
 block discarded – undo
516 516
 	 * @param  bool $full Return abbreviation or in full.
517 517
 	 * @return string
518 518
 	 */
519
-	public function get_recurring_period( $full = false ) {
520
-        $period = $this->get_prop( 'recurring_period', 'view' );
519
+	public function get_recurring_period($full = false) {
520
+        $period = $this->get_prop('recurring_period', 'view');
521 521
 
522
-        if ( $full && ! is_bool( $full ) ) {
522
+        if ($full && !is_bool($full)) {
523 523
             $full = false;
524 524
         }
525 525
 
526
-        return getpaid_sanitize_recurring_period( $period, $full );
526
+        return getpaid_sanitize_recurring_period($period, $full);
527 527
     }
528 528
 
529 529
     /**
@@ -533,9 +533,9 @@  discard block
 block discarded – undo
533 533
 	 * @param  string $context View or edit context.
534 534
 	 * @return int
535 535
 	 */
536
-	public function get_recurring_interval( $context = 'view' ) {
537
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
538
-		return max( 1, $interval );
536
+	public function get_recurring_interval($context = 'view') {
537
+		$interval = absint($this->get_prop('recurring_interval', $context));
538
+		return max(1, $interval);
539 539
     }
540 540
 
541 541
     /**
@@ -545,8 +545,8 @@  discard block
 block discarded – undo
545 545
 	 * @param  string $context View or edit context.
546 546
 	 * @return int
547 547
 	 */
548
-	public function get_recurring_limit( $context = 'view' ) {
549
-        return (int) $this->get_prop( 'recurring_limit', $context );
548
+	public function get_recurring_limit($context = 'view') {
549
+        return (int) $this->get_prop('recurring_limit', $context);
550 550
     }
551 551
 
552 552
     /**
@@ -556,8 +556,8 @@  discard block
 block discarded – undo
556 556
 	 * @param  string $context View or edit context.
557 557
 	 * @return int
558 558
 	 */
559
-	public function get_is_free_trial( $context = 'view' ) {
560
-        return (int) $this->get_prop( 'is_free_trial', $context );
559
+	public function get_is_free_trial($context = 'view') {
560
+        return (int) $this->get_prop('is_free_trial', $context);
561 561
     }
562 562
 
563 563
     /**
@@ -567,8 +567,8 @@  discard block
 block discarded – undo
567 567
 	 * @param  string $context View or edit context.
568 568
 	 * @return int
569 569
 	 */
570
-	public function get_free_trial( $context = 'view' ) {
571
-        return $this->get_is_free_trial( $context );
570
+	public function get_free_trial($context = 'view') {
571
+        return $this->get_is_free_trial($context);
572 572
     }
573 573
 
574 574
     /**
@@ -578,14 +578,14 @@  discard block
 block discarded – undo
578 578
 	 * @param  bool $full Return abbreviation or in full.
579 579
 	 * @return string
580 580
 	 */
581
-	public function get_trial_period( $full = false ) {
582
-        $period = $this->get_prop( 'trial_period', 'view' );
581
+	public function get_trial_period($full = false) {
582
+        $period = $this->get_prop('trial_period', 'view');
583 583
 
584
-        if ( $full && ! is_bool( $full ) ) {
584
+        if ($full && !is_bool($full)) {
585 585
             $full = false;
586 586
         }
587 587
 
588
-        return getpaid_sanitize_recurring_period( $period, $full );
588
+        return getpaid_sanitize_recurring_period($period, $full);
589 589
     }
590 590
 
591 591
     /**
@@ -595,8 +595,8 @@  discard block
 block discarded – undo
595 595
 	 * @param  string $context View or edit context.
596 596
 	 * @return int
597 597
 	 */
598
-	public function get_trial_interval( $context = 'view' ) {
599
-        return (int) $this->get_prop( 'trial_interval', $context );
598
+	public function get_trial_interval($context = 'view') {
599
+        return (int) $this->get_prop('trial_interval', $context);
600 600
 	}
601 601
 	
602 602
 	/**
@@ -606,7 +606,7 @@  discard block
 block discarded – undo
606 606
 	 * @return string
607 607
 	 */
608 608
 	public function get_edit_url() {
609
-        return get_edit_post_link( $this->get_id(), 'edit' );
609
+        return get_edit_post_link($this->get_id(), 'edit');
610 610
 	}
611 611
 
612 612
 	/**
@@ -620,35 +620,35 @@  discard block
 block discarded – undo
620 620
 	 * @since 1.0.15
621 621
 	 * @return int
622 622
 	 */
623
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
623
+	public static function get_item_id_by_field($value, $field = 'custom_id', $type = '') {
624 624
 
625 625
 		// Trim the value.
626
-		$value = sanitize_text_field( $value );
627
-		if ( empty( $value ) ) {
626
+		$value = sanitize_text_field($value);
627
+		if (empty($value)) {
628 628
 			return 0;
629 629
 		}
630 630
 
631 631
         // Valid fields.
632
-        $fields = array( 'custom_id', 'name', 'slug' );
632
+        $fields = array('custom_id', 'name', 'slug');
633 633
 
634 634
 		// Ensure a field has been passed.
635
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
635
+		if (empty($field) || !in_array($field, $fields)) {
636 636
 			return 0;
637 637
 		}
638 638
 
639
-		if ( $field == 'name' ) {
639
+		if ($field == 'name') {
640 640
 			$field = 'slug';
641 641
 		}
642 642
 
643 643
 		// Maybe retrieve from the cache.
644
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
645
-		if ( ! empty( $item_id ) ) {
644
+		$item_id = wp_cache_get($value, "getpaid_{$type}_item_{$field}s_to_item_ids");
645
+		if (!empty($item_id)) {
646 646
 			return $item_id;
647 647
 		}
648 648
 
649 649
 		// Fetch from the db.
650 650
 		$items = array();
651
-		if ( $field == 'slug' ) {
651
+		if ($field == 'slug') {
652 652
 			$items = get_posts(
653 653
 				array(
654 654
 					'post_type'      => 'wpi_item',
@@ -659,7 +659,7 @@  discard block
 block discarded – undo
659 659
 			);
660 660
 		}
661 661
 
662
-		if ( $field =='custom_id' ) {
662
+		if ($field == 'custom_id') {
663 663
 			$items = get_posts(
664 664
 				array(
665 665
 					'post_type'      => 'wpi_item',
@@ -679,12 +679,12 @@  discard block
 block discarded – undo
679 679
 			);
680 680
 		}
681 681
 
682
-		if ( empty( $items ) ) {
682
+		if (empty($items)) {
683 683
 			return 0;
684 684
 		}
685 685
 
686 686
 		// Update the cache with our data
687
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
687
+		wp_cache_set($value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids");
688 688
 
689 689
 		return $items[0]->ID;
690 690
     }
@@ -692,19 +692,19 @@  discard block
 block discarded – undo
692 692
     /**
693 693
      * Margic method for retrieving a property.
694 694
      */
695
-    public function __get( $key ) {
695
+    public function __get($key) {
696 696
 
697 697
         // Check if we have a helper method for that.
698
-        if ( method_exists( $this, 'get_' . $key ) ) {
699
-            return call_user_func( array( $this, 'get_' . $key ) );
698
+        if (method_exists($this, 'get_' . $key)) {
699
+            return call_user_func(array($this, 'get_' . $key));
700 700
         }
701 701
 
702 702
         // Check if the key is in the associated $post object.
703
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
703
+        if (!empty($this->post) && isset($this->post->$key)) {
704 704
             return $this->post->$key;
705 705
         }
706 706
 
707
-        return $this->get_prop( $key );
707
+        return $this->get_prop($key);
708 708
 
709 709
     }
710 710
 
@@ -723,11 +723,11 @@  discard block
 block discarded – undo
723 723
 	 *
724 724
 	 * @since 1.0.19
725 725
 	 */
726
-	public function set_parent_id( $value ) {
727
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
726
+	public function set_parent_id($value) {
727
+		if ($value && ($value === $this->get_id() || !get_post($value))) {
728 728
 			return;
729 729
 		}
730
-		$this->set_prop( 'parent_id', absint( $value ) );
730
+		$this->set_prop('parent_id', absint($value));
731 731
 	}
732 732
 
733 733
     /**
@@ -737,10 +737,10 @@  discard block
 block discarded – undo
737 737
 	 * @param  string $status New status.
738 738
 	 * @return array details of change.
739 739
 	 */
740
-	public function set_status( $status ) {
740
+	public function set_status($status) {
741 741
         $old_status = $this->get_status();
742 742
 
743
-        $this->set_prop( 'status', $status );
743
+        $this->set_prop('status', $status);
744 744
 
745 745
 		return array(
746 746
 			'from' => $old_status,
@@ -753,8 +753,8 @@  discard block
 block discarded – undo
753 753
 	 *
754 754
 	 * @since 1.0.19
755 755
 	 */
756
-	public function set_version( $value ) {
757
-		$this->set_prop( 'version', $value );
756
+	public function set_version($value) {
757
+		$this->set_prop('version', $value);
758 758
     }
759 759
 
760 760
     /**
@@ -764,11 +764,11 @@  discard block
 block discarded – undo
764 764
 	 * @param string $value Value to set.
765 765
      * @return bool Whether or not the date was set.
766 766
 	 */
767
-	public function set_date_created( $value ) {
768
-        $date = strtotime( $value );
767
+	public function set_date_created($value) {
768
+        $date = strtotime($value);
769 769
 
770
-        if ( $date ) {
771
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
770
+        if ($date) {
771
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
772 772
             return true;
773 773
         }
774 774
 
@@ -783,11 +783,11 @@  discard block
 block discarded – undo
783 783
 	 * @param string $value Value to set.
784 784
      * @return bool Whether or not the date was set.
785 785
 	 */
786
-	public function set_date_modified( $value ) {
787
-        $date = strtotime( $value );
786
+	public function set_date_modified($value) {
787
+        $date = strtotime($value);
788 788
 
789
-        if ( $date ) {
790
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
789
+        if ($date) {
790
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
791 791
             return true;
792 792
         }
793 793
 
@@ -801,9 +801,9 @@  discard block
 block discarded – undo
801 801
 	 * @since 1.0.19
802 802
 	 * @param  string $value New name.
803 803
 	 */
804
-	public function set_name( $value ) {
805
-        $name = sanitize_text_field( $value );
806
-		$this->set_prop( 'name', $name );
804
+	public function set_name($value) {
805
+        $name = sanitize_text_field($value);
806
+		$this->set_prop('name', $name);
807 807
     }
808 808
 
809 809
     /**
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
 	 * @since 1.0.19
813 813
 	 * @param  string $value New name.
814 814
 	 */
815
-	public function set_title( $value ) {
816
-		$this->set_name( $value );
815
+	public function set_title($value) {
816
+		$this->set_name($value);
817 817
     }
818 818
 
819 819
     /**
@@ -822,9 +822,9 @@  discard block
 block discarded – undo
822 822
 	 * @since 1.0.19
823 823
 	 * @param  string $value New description.
824 824
 	 */
825
-	public function set_description( $value ) {
826
-		$description = wp_kses_post( wp_unslash( $value ) );
827
-		return $this->set_prop( 'description', $description );
825
+	public function set_description($value) {
826
+		$description = wp_kses_post(wp_unslash($value));
827
+		return $this->set_prop('description', $description);
828 828
     }
829 829
 
830 830
     /**
@@ -833,8 +833,8 @@  discard block
 block discarded – undo
833 833
 	 * @since 1.0.19
834 834
 	 * @param  string $value New description.
835 835
 	 */
836
-	public function set_excerpt( $value ) {
837
-		$this->set_description( $value );
836
+	public function set_excerpt($value) {
837
+		$this->set_description($value);
838 838
     }
839 839
 
840 840
     /**
@@ -843,8 +843,8 @@  discard block
 block discarded – undo
843 843
 	 * @since 1.0.19
844 844
 	 * @param  string $value New description.
845 845
 	 */
846
-	public function set_summary( $value ) {
847
-		$this->set_description( $value );
846
+	public function set_summary($value) {
847
+		$this->set_description($value);
848 848
     }
849 849
 
850 850
     /**
@@ -853,8 +853,8 @@  discard block
 block discarded – undo
853 853
 	 * @since 1.0.19
854 854
 	 * @param  int $value New author.
855 855
 	 */
856
-	public function set_author( $value ) {
857
-		$this->set_prop( 'author', (int) $value );
856
+	public function set_author($value) {
857
+		$this->set_prop('author', (int) $value);
858 858
 	}
859 859
 	
860 860
 	/**
@@ -863,8 +863,8 @@  discard block
 block discarded – undo
863 863
 	 * @since 1.0.19
864 864
 	 * @param  int $value New author.
865 865
 	 */
866
-	public function set_owner( $value ) {
867
-		$this->set_author( $value );
866
+	public function set_owner($value) {
867
+		$this->set_author($value);
868 868
     }
869 869
 
870 870
     /**
@@ -873,8 +873,8 @@  discard block
 block discarded – undo
873 873
 	 * @since 1.0.19
874 874
 	 * @param  float $value New price.
875 875
 	 */
876
-	public function set_price( $value ) {
877
-        $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
876
+	public function set_price($value) {
877
+        $this->set_prop('price', (float) wpinv_sanitize_amount($value));
878 878
     }
879 879
 
880 880
     /**
@@ -883,8 +883,8 @@  discard block
 block discarded – undo
883 883
 	 * @since 1.0.19
884 884
 	 * @param  string $value new rule.
885 885
 	 */
886
-	public function set_vat_rule( $value ) {
887
-        $this->set_prop( 'vat_rule', $value );
886
+	public function set_vat_rule($value) {
887
+        $this->set_prop('vat_rule', $value);
888 888
     }
889 889
 
890 890
     /**
@@ -893,8 +893,8 @@  discard block
 block discarded – undo
893 893
 	 * @since 1.0.19
894 894
 	 * @param  string $value new class.
895 895
 	 */
896
-	public function set_vat_class( $value ) {
897
-        $this->set_prop( 'vat_class', $value );
896
+	public function set_vat_class($value) {
897
+        $this->set_prop('vat_class', $value);
898 898
     }
899 899
 
900 900
     /**
@@ -904,13 +904,13 @@  discard block
 block discarded – undo
904 904
 	 * @param  string $value new item type.
905 905
 	 * @return string
906 906
 	 */
907
-	public function set_type( $value ) {
907
+	public function set_type($value) {
908 908
 
909
-        if ( empty( $value ) ) {
909
+        if (empty($value)) {
910 910
             $value = 'custom';
911 911
         }
912 912
 
913
-        $this->set_prop( 'type', $value );
913
+        $this->set_prop('type', $value);
914 914
     }
915 915
 
916 916
     /**
@@ -919,8 +919,8 @@  discard block
 block discarded – undo
919 919
 	 * @since 1.0.19
920 920
 	 * @param  string $value new custom id.
921 921
 	 */
922
-	public function set_custom_id( $value ) {
923
-        $this->set_prop( 'custom_id', $value );
922
+	public function set_custom_id($value) {
923
+        $this->set_prop('custom_id', $value);
924 924
     }
925 925
 
926 926
     /**
@@ -929,8 +929,8 @@  discard block
 block discarded – undo
929 929
 	 * @since 1.0.19
930 930
 	 * @param  string $value new custom name.
931 931
 	 */
932
-	public function set_custom_name( $value ) {
933
-        $this->set_prop( 'custom_name', $value );
932
+	public function set_custom_name($value) {
933
+        $this->set_prop('custom_name', $value);
934 934
     }
935 935
 
936 936
     /**
@@ -939,8 +939,8 @@  discard block
 block discarded – undo
939 939
 	 * @since 1.0.19
940 940
 	 * @param  string $value new custom singular name.
941 941
 	 */
942
-	public function set_custom_singular_name( $value ) {
943
-        $this->set_prop( 'custom_singular_name', $value );
942
+	public function set_custom_singular_name($value) {
943
+        $this->set_prop('custom_singular_name', $value);
944 944
     }
945 945
 
946 946
     /**
@@ -949,8 +949,8 @@  discard block
 block discarded – undo
949 949
 	 * @since 1.0.19
950 950
 	 * @param  int|bool $value whether or not the item is editable.
951 951
 	 */
952
-	public function set_is_editable( $value ) {
953
-		$this->set_prop( 'is_editable', (int) $value );
952
+	public function set_is_editable($value) {
953
+		$this->set_prop('is_editable', (int) $value);
954 954
     }
955 955
 
956 956
     /**
@@ -959,8 +959,8 @@  discard block
 block discarded – undo
959 959
 	 * @since 1.0.19
960 960
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
961 961
 	 */
962
-	public function set_is_dynamic_pricing( $value ) {
963
-        $this->set_prop( 'is_dynamic_pricing', (int) $value );
962
+	public function set_is_dynamic_pricing($value) {
963
+        $this->set_prop('is_dynamic_pricing', (int) $value);
964 964
     }
965 965
 
966 966
     /**
@@ -969,8 +969,8 @@  discard block
 block discarded – undo
969 969
 	 * @since 1.0.19
970 970
 	 * @param  float $value minimum price.
971 971
 	 */
972
-	public function set_minimum_price( $value ) {
973
-        $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
972
+	public function set_minimum_price($value) {
973
+        $this->set_prop('minimum_price', (float) wpinv_sanitize_amount($value));
974 974
     }
975 975
 
976 976
     /**
@@ -979,8 +979,8 @@  discard block
 block discarded – undo
979 979
 	 * @since 1.0.19
980 980
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
981 981
 	 */
982
-	public function set_is_recurring( $value ) {
983
-        $this->set_prop( 'is_recurring', (int) $value );
982
+	public function set_is_recurring($value) {
983
+        $this->set_prop('is_recurring', (int) $value);
984 984
     }
985 985
 
986 986
     /**
@@ -989,8 +989,8 @@  discard block
 block discarded – undo
989 989
 	 * @since 1.0.19
990 990
 	 * @param  string $value new period.
991 991
 	 */
992
-	public function set_recurring_period( $value ) {
993
-        $this->set_prop( 'recurring_period', $value );
992
+	public function set_recurring_period($value) {
993
+        $this->set_prop('recurring_period', $value);
994 994
     }
995 995
 
996 996
     /**
@@ -999,8 +999,8 @@  discard block
 block discarded – undo
999 999
 	 * @since 1.0.19
1000 1000
 	 * @param  int $value recurring interval.
1001 1001
 	 */
1002
-	public function set_recurring_interval( $value ) {
1003
-        return $this->set_prop( 'recurring_interval', (int) $value );
1002
+	public function set_recurring_interval($value) {
1003
+        return $this->set_prop('recurring_interval', (int) $value);
1004 1004
     }
1005 1005
 
1006 1006
     /**
@@ -1009,8 +1009,8 @@  discard block
 block discarded – undo
1009 1009
 	 * @param  int $value The recurring limit.
1010 1010
 	 * @return int
1011 1011
 	 */
1012
-	public function set_recurring_limit( $value ) {
1013
-        $this->set_prop( 'recurring_limit', (int) $value );
1012
+	public function set_recurring_limit($value) {
1013
+        $this->set_prop('recurring_limit', (int) $value);
1014 1014
     }
1015 1015
 
1016 1016
     /**
@@ -1019,8 +1019,8 @@  discard block
 block discarded – undo
1019 1019
 	 * @since 1.0.19
1020 1020
 	 * @param  int|bool $value whether or not it has a free trial.
1021 1021
 	 */
1022
-	public function set_is_free_trial( $value ) {
1023
-        $this->set_prop( 'is_free_trial', (int) $value );
1022
+	public function set_is_free_trial($value) {
1023
+        $this->set_prop('is_free_trial', (int) $value);
1024 1024
     }
1025 1025
 
1026 1026
     /**
@@ -1029,8 +1029,8 @@  discard block
 block discarded – undo
1029 1029
 	 * @since 1.0.19
1030 1030
 	 * @param  string $value trial period.
1031 1031
 	 */
1032
-	public function set_trial_period( $value ) {
1033
-        $this->set_prop( 'trial_period', $value );
1032
+	public function set_trial_period($value) {
1033
+        $this->set_prop('trial_period', $value);
1034 1034
     }
1035 1035
 
1036 1036
     /**
@@ -1039,8 +1039,8 @@  discard block
 block discarded – undo
1039 1039
 	 * @since 1.0.19
1040 1040
 	 * @param  int $value trial interval.
1041 1041
 	 */
1042
-	public function set_trial_interval( $value ) {
1043
-        $this->set_prop( 'trial_interval', $value );
1042
+	public function set_trial_interval($value) {
1043
+        $this->set_prop('trial_interval', $value);
1044 1044
     }
1045 1045
 
1046 1046
     /**
@@ -1049,11 +1049,11 @@  discard block
 block discarded – undo
1049 1049
      * @deprecated
1050 1050
 	 * @return int item id
1051 1051
      */
1052
-    public function create( $data = array() ) {
1052
+    public function create($data = array()) {
1053 1053
 
1054 1054
 		// Set the properties.
1055
-		if ( is_array( $data ) ) {
1056
-			$this->set_props( $data );
1055
+		if (is_array($data)) {
1056
+			$this->set_props($data);
1057 1057
 		}
1058 1058
 
1059 1059
 		// Save the item.
@@ -1067,8 +1067,8 @@  discard block
 block discarded – undo
1067 1067
      * @deprecated
1068 1068
 	 * @return int item id
1069 1069
      */
1070
-    public function update( $data = array() ) {
1071
-        return $this->create( $data );
1070
+    public function update($data = array()) {
1071
+        return $this->create($data);
1072 1072
     }
1073 1073
 
1074 1074
     /*
@@ -1108,7 +1108,7 @@  discard block
 block discarded – undo
1108 1108
 	 */
1109 1109
     public function has_free_trial() {
1110 1110
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1111
-        return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1111
+        return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this);
1112 1112
     }
1113 1113
 
1114 1114
     /**
@@ -1118,8 +1118,8 @@  discard block
 block discarded – undo
1118 1118
 	 * @return bool
1119 1119
 	 */
1120 1120
     public function is_free() {
1121
-        $is_free   = $this->get_price() == 0;
1122
-        return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1121
+        $is_free = $this->get_price() == 0;
1122
+        return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this);
1123 1123
     }
1124 1124
 
1125 1125
     /**
@@ -1128,9 +1128,9 @@  discard block
 block discarded – undo
1128 1128
 	 * @param array|string $status Status to check.
1129 1129
 	 * @return bool
1130 1130
 	 */
1131
-	public function has_status( $status ) {
1132
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1133
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1131
+	public function has_status($status) {
1132
+		$has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status;
1133
+		return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status);
1134 1134
     }
1135 1135
 
1136 1136
     /**
@@ -1139,9 +1139,9 @@  discard block
 block discarded – undo
1139 1139
 	 * @param array|string $type Type to check.
1140 1140
 	 * @return bool
1141 1141
 	 */
1142
-	public function is_type( $type ) {
1143
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1144
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1142
+	public function is_type($type) {
1143
+		$is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type;
1144
+		return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type);
1145 1145
 	}
1146 1146
 
1147 1147
     /**
@@ -1152,7 +1152,7 @@  discard block
 block discarded – undo
1152 1152
 	 */
1153 1153
     public function is_editable() {
1154 1154
         $is_editable = $this->get_is_editable();
1155
-        return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1155
+        return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this);
1156 1156
 	}
1157 1157
 
1158 1158
 	/**
@@ -1171,11 +1171,11 @@  discard block
 block discarded – undo
1171 1171
     public function can_purchase() {
1172 1172
         $can_purchase = $this->exists();
1173 1173
 
1174
-        if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) {
1174
+        if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') {
1175 1175
             $can_purchase = false;
1176 1176
         }
1177 1177
 
1178
-        return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this );
1178
+        return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this);
1179 1179
     }
1180 1180
 
1181 1181
     /**
@@ -1185,6 +1185,6 @@  discard block
 block discarded – undo
1185 1185
 	 * @return bool
1186 1186
 	 */
1187 1187
     public function supports_dynamic_pricing() {
1188
-        return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1188
+        return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this);
1189 1189
     }
1190 1190
 }
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 2 patches
Indentation   +2598 added lines, -2598 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'            => 0,
38
-		'status'               => 'wpi-pending',
39
-		'version'              => '',
40
-		'date_created'         => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'            => 0,
38
+        'status'               => 'wpi-pending',
39
+        'version'              => '',
40
+        'date_created'         => null,
41 41
         'date_modified'        => null,
42 42
         'due_date'             => null,
43 43
         'completed_date'       => null,
@@ -60,17 +60,17 @@  discard block
 block discarded – undo
60 60
         'state'                => null,
61 61
         'zip'                  => null,
62 62
         'company'              => null,
63
-		'company_id'           => null,
63
+        'company_id'           => null,
64 64
         'vat_number'           => null,
65 65
         'vat_rate'             => null,
66 66
         'address'              => null,
67 67
         'address_confirmed'    => false,
68 68
         'shipping'             => null,
69
-		'subtotal'             => 0,
69
+        'subtotal'             => 0,
70 70
         'total_discount'       => 0,
71 71
         'total_tax'            => 0,
72
-		'total_fees'           => 0,
73
-		'total'                => 0,
72
+        'total_fees'           => 0,
73
+        'total'                => 0,
74 74
         'fees'                 => array(),
75 75
         'discounts'            => array(),
76 76
         'taxes'                => array(),
@@ -82,22 +82,22 @@  discard block
 block discarded – undo
82 82
         'transaction_id'       => '',
83 83
         'currency'             => '',
84 84
         'disable_taxes'        => false,
85
-		'subscription_id'      => null,
86
-		'remote_subscription_id' => null,
87
-		'is_viewed'            => false,
88
-		'email_cc'             => '',
89
-		'template'             => 'quantity', // hours, amount only
90
-		'created_via'          => null,
85
+        'subscription_id'      => null,
86
+        'remote_subscription_id' => null,
87
+        'is_viewed'            => false,
88
+        'email_cc'             => '',
89
+        'template'             => 'quantity', // hours, amount only
90
+        'created_via'          => null,
91 91
     );
92 92
 
93 93
     /**
94
-	 * Stores meta in cache for future reads.
95
-	 *
96
-	 * A group must be set to to enable caching.
97
-	 *
98
-	 * @var string
99
-	 */
100
-	protected $cache_group = 'getpaid_invoices';
94
+     * Stores meta in cache for future reads.
95
+     *
96
+     * A group must be set to to enable caching.
97
+     *
98
+     * @var string
99
+     */
100
+    protected $cache_group = 'getpaid_invoices';
101 101
 
102 102
     /**
103 103
      * Stores a reference to the original WP_Post object
@@ -111,111 +111,111 @@  discard block
 block discarded – undo
111 111
      *
112 112
      * @var int
113 113
      */
114
-	protected $recurring_item = null;
114
+    protected $recurring_item = null;
115 115
 
116
-	/**
116
+    /**
117 117
      * Stores an array of item totals.
118
-	 *
119
-	 * e.g $totals['discount'] = array(
120
-	 * 		'initial'   => 10,
121
-	 * 		'recurring' => 10,
122
-	 * )
118
+     *
119
+     * e.g $totals['discount'] = array(
120
+     * 		'initial'   => 10,
121
+     * 		'recurring' => 10,
122
+     * )
123 123
      *
124 124
      * @var array
125 125
      */
126
-	protected $totals = array();
126
+    protected $totals = array();
127 127
 
128
-	/**
128
+    /**
129 129
      * Tax rate.
130
-	 *
130
+     *
131 131
      * @var float
132 132
      */
133
-	protected $tax_rate = 0;
133
+    protected $tax_rate = 0;
134 134
 
135
-	/**
136
-	 * Stores the status transition information.
137
-	 *
138
-	 * @since 1.0.19
139
-	 * @var bool|array
140
-	 */
141
-	protected $status_transition = false;
135
+    /**
136
+     * Stores the status transition information.
137
+     *
138
+     * @since 1.0.19
139
+     * @var bool|array
140
+     */
141
+    protected $status_transition = false;
142 142
 
143 143
     /**
144
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
145
-	 *
146
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
147
-	 */
144
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
145
+     *
146
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
147
+     */
148 148
     public function __construct( $invoice = 0 ) {
149 149
 
150 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 );
160
-
161
-			if ( isset( $invoice['ID'] ) ) {
162
-				$this->set_id( $invoice['ID'] );
163
-			}
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 );
171
-		} else {
172
-			$this->set_object_read( true );
173
-		}
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
+
161
+            if ( isset( $invoice['ID'] ) ) {
162
+                $this->set_id( $invoice['ID'] );
163
+            }
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 );
171
+        } else {
172
+            $this->set_object_read( true );
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 ) {
178
+        if ( $this->get_id() > 0 ) {
179 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
     }
185 185
 
186 186
     /**
187
-	 * Given an invoice key/number, it returns its id.
188
-	 *
189
-	 *
190
-	 * @static
191
-	 * @param string $value The invoice key or number
192
-	 * @param string $field Either key, transaction_id or number.
193
-	 * @since 1.0.15
194
-	 * @return int
195
-	 */
196
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
187
+     * Given an invoice key/number, it returns its id.
188
+     *
189
+     *
190
+     * @static
191
+     * @param string $value The invoice key or number
192
+     * @param string $field Either key, transaction_id or number.
193
+     * @since 1.0.15
194
+     * @return int
195
+     */
196
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
197 197
         global $wpdb;
198 198
 
199
-		// Trim the value.
200
-		$value = trim( $value );
199
+        // Trim the value.
200
+        $value = trim( $value );
201 201
 
202
-		if ( empty( $value ) ) {
203
-			return 0;
204
-		}
202
+        if ( empty( $value ) ) {
203
+            return 0;
204
+        }
205 205
 
206 206
         // Valid fields.
207 207
         $fields = array( 'key', 'number', 'transaction_id' );
208 208
 
209
-		// Ensure a field has been passed.
210
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
211
-			return 0;
212
-		}
209
+        // Ensure a field has been passed.
210
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
211
+            return 0;
212
+        }
213 213
 
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 ) {
217
-			return $invoice_id;
218
-		}
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 ) {
217
+            return $invoice_id;
218
+        }
219 219
 
220 220
         // Fetch from the db.
221 221
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -223,10 +223,10 @@  discard block
 block discarded – undo
223 223
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
224 224
         );
225 225
 
226
-		// Update the cache with our data
227
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
226
+        // Update the cache with our data
227
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
228 228
 
229
-		return $invoice_id;
229
+        return $invoice_id;
230 230
     }
231 231
 
232 232
     /**
@@ -252,83 +252,83 @@  discard block
 block discarded – undo
252 252
     */
253 253
 
254 254
     /**
255
-	 * Get parent invoice ID.
256
-	 *
257
-	 * @since 1.0.19
258
-	 * @param  string $context View or edit context.
259
-	 * @return int
260
-	 */
261
-	public function get_parent_id( $context = 'view' ) {
262
-		return (int) $this->get_prop( 'parent_id', $context );
255
+     * Get parent invoice ID.
256
+     *
257
+     * @since 1.0.19
258
+     * @param  string $context View or edit context.
259
+     * @return int
260
+     */
261
+    public function get_parent_id( $context = 'view' ) {
262
+        return (int) $this->get_prop( 'parent_id', $context );
263 263
     }
264 264
 
265 265
     /**
266
-	 * Get parent invoice.
267
-	 *
268
-	 * @since 1.0.19
269
-	 * @return WPInv_Invoice
270
-	 */
266
+     * Get parent invoice.
267
+     *
268
+     * @since 1.0.19
269
+     * @return WPInv_Invoice
270
+     */
271 271
     public function get_parent_payment() {
272 272
         return new WPInv_Invoice( $this->get_parent_id() );
273 273
     }
274 274
 
275 275
     /**
276
-	 * Alias for self::get_parent_payment().
277
-	 *
278
-	 * @since 1.0.19
279
-	 * @return WPInv_Invoice
280
-	 */
276
+     * Alias for self::get_parent_payment().
277
+     *
278
+     * @since 1.0.19
279
+     * @return WPInv_Invoice
280
+     */
281 281
     public function get_parent() {
282 282
         return $this->get_parent_payment();
283 283
     }
284 284
 
285 285
     /**
286
-	 * Get invoice status.
287
-	 *
288
-	 * @since 1.0.19
289
-	 * @param  string $context View or edit context.
290
-	 * @return string
291
-	 */
292
-	public function get_status( $context = 'view' ) {
293
-		return $this->get_prop( 'status', $context );
294
-	}
286
+     * Get invoice status.
287
+     *
288
+     * @since 1.0.19
289
+     * @param  string $context View or edit context.
290
+     * @return string
291
+     */
292
+    public function get_status( $context = 'view' ) {
293
+        return $this->get_prop( 'status', $context );
294
+    }
295 295
 	
296
-	/**
297
-	 * Retrieves an array of possible invoice statuses.
298
-	 *
299
-	 * @since 1.0.19
300
-	 * @return array
301
-	 */
302
-	public function get_all_statuses() {
303
-		return wpinv_get_invoice_statuses( true, true, $this );
304
-    }
305
-
306
-    /**
307
-	 * Get invoice status nice name.
308
-	 *
309
-	 * @since 1.0.19
310
-	 * @return string
311
-	 */
296
+    /**
297
+     * Retrieves an array of possible invoice statuses.
298
+     *
299
+     * @since 1.0.19
300
+     * @return array
301
+     */
302
+    public function get_all_statuses() {
303
+        return wpinv_get_invoice_statuses( true, true, $this );
304
+    }
305
+
306
+    /**
307
+     * Get invoice status nice name.
308
+     *
309
+     * @since 1.0.19
310
+     * @return string
311
+     */
312 312
     public function get_status_nicename() {
313
-		$statuses = $this->get_all_statuses();
313
+        $statuses = $this->get_all_statuses();
314 314
 
315 315
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
316 316
 
317 317
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
318 318
     }
319 319
 
320
-	/**
321
-	 * Retrieves the invoice status class
322
-	 *
323
-	 * @since  1.0.19
324
-	 * @return string
325
-	 */
326
-	public function get_status_class() {
327
-		$statuses = getpaid_get_invoice_status_classes();
328
-		return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
329
-	}
320
+    /**
321
+     * Retrieves the invoice status class
322
+     *
323
+     * @since  1.0.19
324
+     * @return string
325
+     */
326
+    public function get_status_class() {
327
+        $statuses = getpaid_get_invoice_status_classes();
328
+        return isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : 'badge-dark';
329
+    }
330 330
 
331
-	/**
331
+    /**
332 332
      * Retrieves the invoice status label html
333 333
      *
334 334
      * @since  1.0.0
@@ -336,263 +336,263 @@  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
-		return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
344
-	}
343
+        return "<span class='bsui'><span class='badge $class $status'>$status_label</span></span>";
344
+    }
345 345
 
346 346
     /**
347
-	 * Get plugin version when the invoice was created.
348
-	 *
349
-	 * @since 1.0.19
350
-	 * @param  string $context View or edit context.
351
-	 * @return string
352
-	 */
353
-	public function get_version( $context = 'view' ) {
354
-		return $this->get_prop( 'version', $context );
355
-	}
347
+     * Get plugin version when the invoice was created.
348
+     *
349
+     * @since 1.0.19
350
+     * @param  string $context View or edit context.
351
+     * @return string
352
+     */
353
+    public function get_version( $context = 'view' ) {
354
+        return $this->get_prop( 'version', $context );
355
+    }
356 356
 
357
-	/**
358
-	 * @deprecated
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 );
357
+    /**
358
+     * @deprecated
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 );
364 364
 
365
-		if ( $format ) {
366
-			return $formatted;
367
-		}
365
+        if ( $format ) {
366
+            return $formatted;
367
+        }
368 368
 
369
-		return empty( $formatted ) ? '' : $date;
369
+        return empty( $formatted ) ? '' : $date;
370 370
 
371 371
     }
372 372
 
373 373
     /**
374
-	 * Get date when the invoice was created.
375
-	 *
376
-	 * @since 1.0.19
377
-	 * @param  string $context View or edit context.
378
-	 * @return string
379
-	 */
380
-	public function get_date_created( $context = 'view' ) {
381
-		return $this->get_prop( 'date_created', $context );
382
-	}
374
+     * Get date when the invoice was created.
375
+     *
376
+     * @since 1.0.19
377
+     * @param  string $context View or edit context.
378
+     * @return string
379
+     */
380
+    public function get_date_created( $context = 'view' ) {
381
+        return $this->get_prop( 'date_created', $context );
382
+    }
383 383
 	
384
-	/**
385
-	 * Alias for self::get_date_created().
386
-	 *
387
-	 * @since 1.0.19
388
-	 * @param  string $context View or edit context.
389
-	 * @return string
390
-	 */
391
-	public function get_created_date( $context = 'view' ) {
392
-		return $this->get_date_created( $context );
393
-    }
394
-
395
-    /**
396
-	 * Get GMT date when the invoice was created.
397
-	 *
398
-	 * @since 1.0.19
399
-	 * @param  string $context View or edit context.
400
-	 * @return string
401
-	 */
402
-	public function get_date_created_gmt( $context = 'view' ) {
384
+    /**
385
+     * Alias for self::get_date_created().
386
+     *
387
+     * @since 1.0.19
388
+     * @param  string $context View or edit context.
389
+     * @return string
390
+     */
391
+    public function get_created_date( $context = 'view' ) {
392
+        return $this->get_date_created( $context );
393
+    }
394
+
395
+    /**
396
+     * Get GMT date when the invoice was created.
397
+     *
398
+     * @since 1.0.19
399
+     * @param  string $context View or edit context.
400
+     * @return string
401
+     */
402
+    public function get_date_created_gmt( $context = 'view' ) {
403 403
         $date = $this->get_date_created( $context );
404 404
 
405 405
         if ( $date ) {
406 406
             $date = get_gmt_from_date( $date );
407 407
         }
408
-		return $date;
408
+        return $date;
409 409
     }
410 410
 
411 411
     /**
412
-	 * Get date when the invoice was last modified.
413
-	 *
414
-	 * @since 1.0.19
415
-	 * @param  string $context View or edit context.
416
-	 * @return string
417
-	 */
418
-	public function get_date_modified( $context = 'view' ) {
419
-		return $this->get_prop( 'date_modified', $context );
420
-	}
412
+     * Get date when the invoice was last modified.
413
+     *
414
+     * @since 1.0.19
415
+     * @param  string $context View or edit context.
416
+     * @return string
417
+     */
418
+    public function get_date_modified( $context = 'view' ) {
419
+        return $this->get_prop( 'date_modified', $context );
420
+    }
421 421
 
422
-	/**
423
-	 * Alias for self::get_date_modified().
424
-	 *
425
-	 * @since 1.0.19
426
-	 * @param  string $context View or edit context.
427
-	 * @return string
428
-	 */
429
-	public function get_modified_date( $context = 'view' ) {
430
-		return $this->get_date_modified( $context );
422
+    /**
423
+     * Alias for self::get_date_modified().
424
+     *
425
+     * @since 1.0.19
426
+     * @param  string $context View or edit context.
427
+     * @return string
428
+     */
429
+    public function get_modified_date( $context = 'view' ) {
430
+        return $this->get_date_modified( $context );
431 431
     }
432 432
 
433 433
     /**
434
-	 * Get GMT date when the invoice was last modified.
435
-	 *
436
-	 * @since 1.0.19
437
-	 * @param  string $context View or edit context.
438
-	 * @return string
439
-	 */
440
-	public function get_date_modified_gmt( $context = 'view' ) {
434
+     * Get GMT date when the invoice was last modified.
435
+     *
436
+     * @since 1.0.19
437
+     * @param  string $context View or edit context.
438
+     * @return string
439
+     */
440
+    public function get_date_modified_gmt( $context = 'view' ) {
441 441
         $date = $this->get_date_modified( $context );
442 442
 
443 443
         if ( $date ) {
444 444
             $date = get_gmt_from_date( $date );
445 445
         }
446
-		return $date;
446
+        return $date;
447 447
     }
448 448
 
449 449
     /**
450
-	 * Get the invoice due date.
451
-	 *
452
-	 * @since 1.0.19
453
-	 * @param  string $context View or edit context.
454
-	 * @return string
455
-	 */
456
-	public function get_due_date( $context = 'view' ) {
457
-		return $this->get_prop( 'due_date', $context );
450
+     * Get the invoice due date.
451
+     *
452
+     * @since 1.0.19
453
+     * @param  string $context View or edit context.
454
+     * @return string
455
+     */
456
+    public function get_due_date( $context = 'view' ) {
457
+        return $this->get_prop( 'due_date', $context );
458 458
     }
459 459
 
460 460
     /**
461
-	 * Alias for self::get_due_date().
462
-	 *
463
-	 * @since 1.0.19
464
-	 * @param  string $context View or edit context.
465
-	 * @return string
466
-	 */
467
-	public function get_date_due( $context = 'view' ) {
468
-		return $this->get_due_date( $context );
461
+     * Alias for self::get_due_date().
462
+     *
463
+     * @since 1.0.19
464
+     * @param  string $context View or edit context.
465
+     * @return string
466
+     */
467
+    public function get_date_due( $context = 'view' ) {
468
+        return $this->get_due_date( $context );
469 469
     }
470 470
 
471 471
     /**
472
-	 * Get the invoice GMT due date.
473
-	 *
474
-	 * @since 1.0.19
475
-	 * @param  string $context View or edit context.
476
-	 * @return string
477
-	 */
478
-	public function get_due_date_gmt( $context = 'view' ) {
472
+     * Get the invoice GMT due date.
473
+     *
474
+     * @since 1.0.19
475
+     * @param  string $context View or edit context.
476
+     * @return string
477
+     */
478
+    public function get_due_date_gmt( $context = 'view' ) {
479 479
         $date = $this->get_due_date( $context );
480 480
 
481 481
         if ( $date ) {
482 482
             $date = get_gmt_from_date( $date );
483 483
         }
484
-		return $date;
484
+        return $date;
485 485
     }
486 486
 
487 487
     /**
488
-	 * Alias for self::get_due_date_gmt().
489
-	 *
490
-	 * @since 1.0.19
491
-	 * @param  string $context View or edit context.
492
-	 * @return string
493
-	 */
494
-	public function get_gmt_date_due( $context = 'view' ) {
495
-		return $this->get_due_date_gmt( $context );
488
+     * Alias for self::get_due_date_gmt().
489
+     *
490
+     * @since 1.0.19
491
+     * @param  string $context View or edit context.
492
+     * @return string
493
+     */
494
+    public function get_gmt_date_due( $context = 'view' ) {
495
+        return $this->get_due_date_gmt( $context );
496 496
     }
497 497
 
498 498
     /**
499
-	 * Get date when the invoice was completed.
500
-	 *
501
-	 * @since 1.0.19
502
-	 * @param  string $context View or edit context.
503
-	 * @return string
504
-	 */
505
-	public function get_completed_date( $context = 'view' ) {
506
-		return $this->get_prop( 'completed_date', $context );
499
+     * Get date when the invoice was completed.
500
+     *
501
+     * @since 1.0.19
502
+     * @param  string $context View or edit context.
503
+     * @return string
504
+     */
505
+    public function get_completed_date( $context = 'view' ) {
506
+        return $this->get_prop( 'completed_date', $context );
507 507
     }
508 508
 
509 509
     /**
510
-	 * Alias for self::get_completed_date().
511
-	 *
512
-	 * @since 1.0.19
513
-	 * @param  string $context View or edit context.
514
-	 * @return string
515
-	 */
516
-	public function get_date_completed( $context = 'view' ) {
517
-		return $this->get_completed_date( $context );
510
+     * Alias for self::get_completed_date().
511
+     *
512
+     * @since 1.0.19
513
+     * @param  string $context View or edit context.
514
+     * @return string
515
+     */
516
+    public function get_date_completed( $context = 'view' ) {
517
+        return $this->get_completed_date( $context );
518 518
     }
519 519
 
520 520
     /**
521
-	 * Get GMT date when the invoice was was completed.
522
-	 *
523
-	 * @since 1.0.19
524
-	 * @param  string $context View or edit context.
525
-	 * @return string
526
-	 */
527
-	public function get_completed_date_gmt( $context = 'view' ) {
521
+     * Get GMT date when the invoice was was completed.
522
+     *
523
+     * @since 1.0.19
524
+     * @param  string $context View or edit context.
525
+     * @return string
526
+     */
527
+    public function get_completed_date_gmt( $context = 'view' ) {
528 528
         $date = $this->get_completed_date( $context );
529 529
 
530 530
         if ( $date ) {
531 531
             $date = get_gmt_from_date( $date );
532 532
         }
533
-		return $date;
533
+        return $date;
534 534
     }
535 535
 
536 536
     /**
537
-	 * Alias for self::get_completed_date_gmt().
538
-	 *
539
-	 * @since 1.0.19
540
-	 * @param  string $context View or edit context.
541
-	 * @return string
542
-	 */
543
-	public function get_gmt_completed_date( $context = 'view' ) {
544
-		return $this->get_completed_date_gmt( $context );
537
+     * Alias for self::get_completed_date_gmt().
538
+     *
539
+     * @since 1.0.19
540
+     * @param  string $context View or edit context.
541
+     * @return string
542
+     */
543
+    public function get_gmt_completed_date( $context = 'view' ) {
544
+        return $this->get_completed_date_gmt( $context );
545 545
     }
546 546
 
547 547
     /**
548
-	 * Get the invoice number.
549
-	 *
550
-	 * @since 1.0.19
551
-	 * @param  string $context View or edit context.
552
-	 * @return string
553
-	 */
554
-	public function get_number( $context = 'view' ) {
555
-		$number = $this->get_prop( 'number', $context );
548
+     * Get the invoice number.
549
+     *
550
+     * @since 1.0.19
551
+     * @param  string $context View or edit context.
552
+     * @return string
553
+     */
554
+    public function get_number( $context = 'view' ) {
555
+        $number = $this->get_prop( 'number', $context );
556 556
 
557
-		if ( empty( $number ) ) {
558
-			$number = $this->generate_number();
559
-			$this->set_number( $this->generate_number() );
560
-		}
557
+        if ( empty( $number ) ) {
558
+            $number = $this->generate_number();
559
+            $this->set_number( $this->generate_number() );
560
+        }
561 561
 
562
-		return $number;
562
+        return $number;
563 563
     }
564 564
 
565
-	/**
566
-	 * Set the invoice number.
567
-	 *
568
-	 * @since 1.0.19
569
-	 */
570
-	public function maybe_set_number() {
565
+    /**
566
+     * Set the invoice number.
567
+     *
568
+     * @since 1.0.19
569
+     */
570
+    public function maybe_set_number() {
571 571
         $number = $this->get_number();
572 572
 
573 573
         if ( empty( $number ) || $this->get_id() == $number ) {
574
-			$this->set_number( $this->generate_number() );
574
+            $this->set_number( $this->generate_number() );
575 575
         }
576 576
 
577
-	}
577
+    }
578 578
 
579 579
     /**
580
-	 * Get the invoice key.
581
-	 *
582
-	 * @since 1.0.19
583
-	 * @param  string $context View or edit context.
584
-	 * @return string
585
-	 */
586
-	public function get_key( $context = 'view' ) {
580
+     * Get the invoice key.
581
+     *
582
+     * @since 1.0.19
583
+     * @param  string $context View or edit context.
584
+     * @return string
585
+     */
586
+    public function get_key( $context = 'view' ) {
587 587
         return $this->get_prop( 'key', $context );
588
-	}
589
-
590
-	/**
591
-	 * Set the invoice key.
592
-	 *
593
-	 * @since 1.0.19
594
-	 */
595
-	public function maybe_set_key() {
588
+    }
589
+
590
+    /**
591
+     * Set the invoice key.
592
+     *
593
+     * @since 1.0.19
594
+     */
595
+    public function maybe_set_key() {
596 596
         $key = $this->get_key();
597 597
 
598 598
         if ( empty( $key ) ) {
@@ -603,140 +603,140 @@  discard block
 block discarded – undo
603 603
     }
604 604
 
605 605
     /**
606
-	 * Get the invoice type.
607
-	 *
608
-	 * @since 1.0.19
609
-	 * @param  string $context View or edit context.
610
-	 * @return string
611
-	 */
612
-	public function get_type( $context = 'view' ) {
606
+     * Get the invoice type.
607
+     *
608
+     * @since 1.0.19
609
+     * @param  string $context View or edit context.
610
+     * @return string
611
+     */
612
+    public function get_type( $context = 'view' ) {
613 613
         return $this->get_prop( 'type', $context );
614
-	}
615
-
616
-	/**
617
-	 * Returns the post type name.
618
-	 *
619
-	 * @since 1.0.19
620
-	 * @return string
621
-	 */
622
-	public function get_invoice_quote_type() {
614
+    }
615
+
616
+    /**
617
+     * Returns the post type name.
618
+     *
619
+     * @since 1.0.19
620
+     * @return string
621
+     */
622
+    public function get_invoice_quote_type() {
623 623
         return getpaid_get_post_type_label( $this->get_post_type(), false );
624 624
     }
625 625
 
626 626
     /**
627
-	 * Get the invoice post type label.
628
-	 *
629
-	 * @since 1.0.19
630
-	 * @param  string $context View or edit context.
631
-	 * @return string
632
-	 */
633
-	public function get_label( $context = 'view' ) {
627
+     * Get the invoice post type label.
628
+     *
629
+     * @since 1.0.19
630
+     * @param  string $context View or edit context.
631
+     * @return string
632
+     */
633
+    public function get_label( $context = 'view' ) {
634 634
         return getpaid_get_post_type_label( $this->get_post_type( $context ), false );
635
-	}
636
-
637
-	/**
638
-	 * Get the invoice post type.
639
-	 *
640
-	 * @since 1.0.19
641
-	 * @param  string $context View or edit context.
642
-	 * @return string
643
-	 */
644
-	public function get_post_type( $context = 'view' ) {
635
+    }
636
+
637
+    /**
638
+     * Get the invoice post type.
639
+     *
640
+     * @since 1.0.19
641
+     * @param  string $context View or edit context.
642
+     * @return string
643
+     */
644
+    public function get_post_type( $context = 'view' ) {
645 645
         return $this->get_prop( 'post_type', $context );
646 646
     }
647 647
 
648 648
     /**
649
-	 * Get the invoice mode.
650
-	 *
651
-	 * @since 1.0.19
652
-	 * @param  string $context View or edit context.
653
-	 * @return string
654
-	 */
655
-	public function get_mode( $context = 'view' ) {
649
+     * Get the invoice mode.
650
+     *
651
+     * @since 1.0.19
652
+     * @param  string $context View or edit context.
653
+     * @return string
654
+     */
655
+    public function get_mode( $context = 'view' ) {
656 656
         return $this->get_prop( 'mode', $context );
657 657
     }
658 658
 
659 659
     /**
660
-	 * Get the invoice path.
661
-	 *
662
-	 * @since 1.0.19
663
-	 * @param  string $context View or edit context.
664
-	 * @return string
665
-	 */
666
-	public function get_path( $context = 'view' ) {
660
+     * Get the invoice path.
661
+     *
662
+     * @since 1.0.19
663
+     * @param  string $context View or edit context.
664
+     * @return string
665
+     */
666
+    public function get_path( $context = 'view' ) {
667 667
         $path   = $this->get_prop( 'path', $context );
668
-		$prefix = $this->get_type();
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 );
673
-		}
670
+        if ( 0 !== strpos( $path, $prefix ) ) {
671
+            $path = sanitize_title(  $prefix . '-' . $this->get_id()  );
672
+            $this->set_path( $path );
673
+        }
674 674
 
675
-		return $path;
675
+        return $path;
676 676
     }
677 677
 
678 678
     /**
679
-	 * Get the invoice name/title.
680
-	 *
681
-	 * @since 1.0.19
682
-	 * @param  string $context View or edit context.
683
-	 * @return string
684
-	 */
685
-	public function get_name( $context = 'view' ) {
679
+     * Get the invoice name/title.
680
+     *
681
+     * @since 1.0.19
682
+     * @param  string $context View or edit context.
683
+     * @return string
684
+     */
685
+    public function get_name( $context = 'view' ) {
686 686
         return $this->get_prop( 'title', $context );
687 687
     }
688 688
 
689 689
     /**
690
-	 * Alias of self::get_name().
691
-	 *
692
-	 * @since 1.0.19
693
-	 * @param  string $context View or edit context.
694
-	 * @return string
695
-	 */
696
-	public function get_title( $context = 'view' ) {
697
-		return $this->get_name( $context );
690
+     * Alias of self::get_name().
691
+     *
692
+     * @since 1.0.19
693
+     * @param  string $context View or edit context.
694
+     * @return string
695
+     */
696
+    public function get_title( $context = 'view' ) {
697
+        return $this->get_name( $context );
698 698
     }
699 699
 
700 700
     /**
701
-	 * Get the invoice description.
702
-	 *
703
-	 * @since 1.0.19
704
-	 * @param  string $context View or edit context.
705
-	 * @return string
706
-	 */
707
-	public function get_description( $context = 'view' ) {
708
-		return $this->get_prop( 'description', $context );
701
+     * Get the invoice description.
702
+     *
703
+     * @since 1.0.19
704
+     * @param  string $context View or edit context.
705
+     * @return string
706
+     */
707
+    public function get_description( $context = 'view' ) {
708
+        return $this->get_prop( 'description', $context );
709 709
     }
710 710
 
711 711
     /**
712
-	 * Alias of self::get_description().
713
-	 *
714
-	 * @since 1.0.19
715
-	 * @param  string $context View or edit context.
716
-	 * @return string
717
-	 */
718
-	public function get_excerpt( $context = 'view' ) {
719
-		return $this->get_description( $context );
712
+     * Alias of self::get_description().
713
+     *
714
+     * @since 1.0.19
715
+     * @param  string $context View or edit context.
716
+     * @return string
717
+     */
718
+    public function get_excerpt( $context = 'view' ) {
719
+        return $this->get_description( $context );
720 720
     }
721 721
 
722 722
     /**
723
-	 * Alias of self::get_description().
724
-	 *
725
-	 * @since 1.0.19
726
-	 * @param  string $context View or edit context.
727
-	 * @return string
728
-	 */
729
-	public function get_summary( $context = 'view' ) {
730
-		return $this->get_description( $context );
723
+     * Alias of self::get_description().
724
+     *
725
+     * @since 1.0.19
726
+     * @param  string $context View or edit context.
727
+     * @return string
728
+     */
729
+    public function get_summary( $context = 'view' ) {
730
+        return $this->get_description( $context );
731 731
     }
732 732
 
733 733
     /**
734
-	 * Returns the user info.
735
-	 *
736
-	 * @since 1.0.19
734
+     * Returns the user info.
735
+     *
736
+     * @since 1.0.19
737 737
      * @param  string $context View or edit context.
738
-	 * @return array
739
-	 */
738
+     * @return array
739
+     */
740 740
     public function get_user_info( $context = 'view' ) {
741 741
 
742 742
         $user_info = array(
@@ -751,669 +751,669 @@  discard block
 block discarded – undo
751 751
             'state'      => $this->get_state( $context ),
752 752
             'zip'        => $this->get_zip( $context ),
753 753
             'company'    => $this->get_company( $context ),
754
-			'company_id' => $this->get_company_id( $context ),
754
+            'company_id' => $this->get_company_id( $context ),
755 755
             'vat_number' => $this->get_vat_number( $context ),
756 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
 
763 763
     /**
764
-	 * Get the customer id.
765
-	 *
766
-	 * @since 1.0.19
767
-	 * @param  string $context View or edit context.
768
-	 * @return int
769
-	 */
770
-	public function get_author( $context = 'view' ) {
771
-		return (int) $this->get_prop( 'author', $context );
764
+     * Get the customer id.
765
+     *
766
+     * @since 1.0.19
767
+     * @param  string $context View or edit context.
768
+     * @return int
769
+     */
770
+    public function get_author( $context = 'view' ) {
771
+        return (int) $this->get_prop( 'author', $context );
772 772
     }
773 773
 
774 774
     /**
775
-	 * Alias of self::get_author().
776
-	 *
777
-	 * @since 1.0.19
778
-	 * @param  string $context View or edit context.
779
-	 * @return int
780
-	 */
781
-	public function get_user_id( $context = 'view' ) {
782
-		return $this->get_author( $context );
775
+     * Alias of self::get_author().
776
+     *
777
+     * @since 1.0.19
778
+     * @param  string $context View or edit context.
779
+     * @return int
780
+     */
781
+    public function get_user_id( $context = 'view' ) {
782
+        return $this->get_author( $context );
783 783
     }
784 784
 
785
-     /**
786
-	 * Alias of self::get_author().
787
-	 *
788
-	 * @since 1.0.19
789
-	 * @param  string $context View or edit context.
790
-	 * @return int
791
-	 */
792
-	public function get_customer_id( $context = 'view' ) {
793
-		return $this->get_author( $context );
785
+        /**
786
+         * Alias of self::get_author().
787
+         *
788
+         * @since 1.0.19
789
+         * @param  string $context View or edit context.
790
+         * @return int
791
+         */
792
+    public function get_customer_id( $context = 'view' ) {
793
+        return $this->get_author( $context );
794 794
     }
795 795
 
796 796
     /**
797
-	 * Get the customer's ip.
798
-	 *
799
-	 * @since 1.0.19
800
-	 * @param  string $context View or edit context.
801
-	 * @return string
802
-	 */
803
-	public function get_ip( $context = 'view' ) {
804
-		return $this->get_prop( 'user_ip', $context );
797
+     * Get the customer's ip.
798
+     *
799
+     * @since 1.0.19
800
+     * @param  string $context View or edit context.
801
+     * @return string
802
+     */
803
+    public function get_ip( $context = 'view' ) {
804
+        return $this->get_prop( 'user_ip', $context );
805 805
     }
806 806
 
807 807
     /**
808
-	 * Alias of self::get_ip().
809
-	 *
810
-	 * @since 1.0.19
811
-	 * @param  string $context View or edit context.
812
-	 * @return string
813
-	 */
814
-	public function get_user_ip( $context = 'view' ) {
815
-		return $this->get_ip( $context );
808
+     * Alias of self::get_ip().
809
+     *
810
+     * @since 1.0.19
811
+     * @param  string $context View or edit context.
812
+     * @return string
813
+     */
814
+    public function get_user_ip( $context = 'view' ) {
815
+        return $this->get_ip( $context );
816 816
     }
817 817
 
818
-     /**
819
-	 * Alias of self::get_ip().
820
-	 *
821
-	 * @since 1.0.19
822
-	 * @param  string $context View or edit context.
823
-	 * @return string
824
-	 */
825
-	public function get_customer_ip( $context = 'view' ) {
826
-		return $this->get_ip( $context );
818
+        /**
819
+         * Alias of self::get_ip().
820
+         *
821
+         * @since 1.0.19
822
+         * @param  string $context View or edit context.
823
+         * @return string
824
+         */
825
+    public function get_customer_ip( $context = 'view' ) {
826
+        return $this->get_ip( $context );
827 827
     }
828 828
 
829 829
     /**
830
-	 * Get the customer's first name.
831
-	 *
832
-	 * @since 1.0.19
833
-	 * @param  string $context View or edit context.
834
-	 * @return string
835
-	 */
836
-	public function get_first_name( $context = 'view' ) {
837
-		return $this->get_prop( 'first_name', $context );
830
+     * Get the customer's first name.
831
+     *
832
+     * @since 1.0.19
833
+     * @param  string $context View or edit context.
834
+     * @return string
835
+     */
836
+    public function get_first_name( $context = 'view' ) {
837
+        return $this->get_prop( 'first_name', $context );
838 838
     }
839 839
 
840 840
     /**
841
-	 * Alias of self::get_first_name().
842
-	 *
843
-	 * @since 1.0.19
844
-	 * @param  string $context View or edit context.
845
-	 * @return string
846
-	 */
847
-	public function get_user_first_name( $context = 'view' ) {
848
-		return $this->get_first_name( $context );
841
+     * Alias of self::get_first_name().
842
+     *
843
+     * @since 1.0.19
844
+     * @param  string $context View or edit context.
845
+     * @return string
846
+     */
847
+    public function get_user_first_name( $context = 'view' ) {
848
+        return $this->get_first_name( $context );
849 849
     }
850 850
 
851
-     /**
852
-	 * Alias of self::get_first_name().
853
-	 *
854
-	 * @since 1.0.19
855
-	 * @param  string $context View or edit context.
856
-	 * @return string
857
-	 */
858
-	public function get_customer_first_name( $context = 'view' ) {
859
-		return $this->get_first_name( $context );
851
+        /**
852
+         * Alias of self::get_first_name().
853
+         *
854
+         * @since 1.0.19
855
+         * @param  string $context View or edit context.
856
+         * @return string
857
+         */
858
+    public function get_customer_first_name( $context = 'view' ) {
859
+        return $this->get_first_name( $context );
860 860
     }
861 861
 
862 862
     /**
863
-	 * Get the customer's last name.
864
-	 *
865
-	 * @since 1.0.19
866
-	 * @param  string $context View or edit context.
867
-	 * @return string
868
-	 */
869
-	public function get_last_name( $context = 'view' ) {
870
-		return $this->get_prop( 'last_name', $context );
863
+     * Get the customer's last name.
864
+     *
865
+     * @since 1.0.19
866
+     * @param  string $context View or edit context.
867
+     * @return string
868
+     */
869
+    public function get_last_name( $context = 'view' ) {
870
+        return $this->get_prop( 'last_name', $context );
871 871
     }
872 872
 
873 873
     /**
874
-	 * Alias of self::get_last_name().
875
-	 *
876
-	 * @since 1.0.19
877
-	 * @param  string $context View or edit context.
878
-	 * @return string
879
-	 */
880
-	public function get_user_last_name( $context = 'view' ) {
881
-		return $this->get_last_name( $context );
874
+     * Alias of self::get_last_name().
875
+     *
876
+     * @since 1.0.19
877
+     * @param  string $context View or edit context.
878
+     * @return string
879
+     */
880
+    public function get_user_last_name( $context = 'view' ) {
881
+        return $this->get_last_name( $context );
882 882
     }
883 883
 
884 884
     /**
885
-	 * Alias of self::get_last_name().
886
-	 *
887
-	 * @since 1.0.19
888
-	 * @param  string $context View or edit context.
889
-	 * @return string
890
-	 */
891
-	public function get_customer_last_name( $context = 'view' ) {
892
-		return $this->get_last_name( $context );
885
+     * Alias of self::get_last_name().
886
+     *
887
+     * @since 1.0.19
888
+     * @param  string $context View or edit context.
889
+     * @return string
890
+     */
891
+    public function get_customer_last_name( $context = 'view' ) {
892
+        return $this->get_last_name( $context );
893 893
     }
894 894
 
895 895
     /**
896
-	 * Get the customer's full name.
897
-	 *
898
-	 * @since 1.0.19
899
-	 * @param  string $context View or edit context.
900
-	 * @return string
901
-	 */
902
-	public function get_full_name( $context = 'view' ) {
903
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
896
+     * Get the customer's full name.
897
+     *
898
+     * @since 1.0.19
899
+     * @param  string $context View or edit context.
900
+     * @return string
901
+     */
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
     /**
907
-	 * Alias of self::get_full_name().
908
-	 *
909
-	 * @since 1.0.19
910
-	 * @param  string $context View or edit context.
911
-	 * @return string
912
-	 */
913
-	public function get_user_full_name( $context = 'view' ) {
914
-		return $this->get_full_name( $context );
907
+     * Alias of self::get_full_name().
908
+     *
909
+     * @since 1.0.19
910
+     * @param  string $context View or edit context.
911
+     * @return string
912
+     */
913
+    public function get_user_full_name( $context = 'view' ) {
914
+        return $this->get_full_name( $context );
915 915
     }
916 916
 
917 917
     /**
918
-	 * Alias of self::get_full_name().
919
-	 *
920
-	 * @since 1.0.19
921
-	 * @param  string $context View or edit context.
922
-	 * @return string
923
-	 */
924
-	public function get_customer_full_name( $context = 'view' ) {
925
-		return $this->get_full_name( $context );
918
+     * Alias of self::get_full_name().
919
+     *
920
+     * @since 1.0.19
921
+     * @param  string $context View or edit context.
922
+     * @return string
923
+     */
924
+    public function get_customer_full_name( $context = 'view' ) {
925
+        return $this->get_full_name( $context );
926 926
     }
927 927
 
928 928
     /**
929
-	 * Get the customer's phone number.
930
-	 *
931
-	 * @since 1.0.19
932
-	 * @param  string $context View or edit context.
933
-	 * @return string
934
-	 */
935
-	public function get_phone( $context = 'view' ) {
936
-		return $this->get_prop( 'phone', $context );
929
+     * Get the customer's phone number.
930
+     *
931
+     * @since 1.0.19
932
+     * @param  string $context View or edit context.
933
+     * @return string
934
+     */
935
+    public function get_phone( $context = 'view' ) {
936
+        return $this->get_prop( 'phone', $context );
937 937
     }
938 938
 
939 939
     /**
940
-	 * Alias of self::get_phone().
941
-	 *
942
-	 * @since 1.0.19
943
-	 * @param  string $context View or edit context.
944
-	 * @return string
945
-	 */
946
-	public function get_phone_number( $context = 'view' ) {
947
-		return $this->get_phone( $context );
940
+     * Alias of self::get_phone().
941
+     *
942
+     * @since 1.0.19
943
+     * @param  string $context View or edit context.
944
+     * @return string
945
+     */
946
+    public function get_phone_number( $context = 'view' ) {
947
+        return $this->get_phone( $context );
948 948
     }
949 949
 
950 950
     /**
951
-	 * Alias of self::get_phone().
952
-	 *
953
-	 * @since 1.0.19
954
-	 * @param  string $context View or edit context.
955
-	 * @return string
956
-	 */
957
-	public function get_user_phone( $context = 'view' ) {
958
-		return $this->get_phone( $context );
959
-    }
960
-
951
+     * Alias of self::get_phone().
952
+     *
953
+     * @since 1.0.19
954
+     * @param  string $context View or edit context.
955
+     * @return string
956
+     */
957
+    public function get_user_phone( $context = 'view' ) {
958
+        return $this->get_phone( $context );
959
+    }
960
+
961
+    /**
962
+     * Alias of self::get_phone().
963
+     *
964
+     * @since 1.0.19
965
+     * @param  string $context View or edit context.
966
+     * @return string
967
+     */
968
+    public function get_customer_phone( $context = 'view' ) {
969
+        return $this->get_phone( $context );
970
+    }
971
+
972
+    /**
973
+     * Get the customer's email address.
974
+     *
975
+     * @since 1.0.19
976
+     * @param  string $context View or edit context.
977
+     * @return string
978
+     */
979
+    public function get_email( $context = 'view' ) {
980
+        return $this->get_prop( 'email', $context );
981
+    }
982
+
983
+    /**
984
+     * Alias of self::get_email().
985
+     *
986
+     * @since 1.0.19
987
+     * @param  string $context View or edit context.
988
+     * @return string
989
+     */
990
+    public function get_email_address( $context = 'view' ) {
991
+        return $this->get_email( $context );
992
+    }
993
+
994
+    /**
995
+     * Alias of self::get_email().
996
+     *
997
+     * @since 1.0.19
998
+     * @param  string $context View or edit context.
999
+     * @return string
1000
+     */
1001
+    public function get_user_email( $context = 'view' ) {
1002
+        return $this->get_email( $context );
1003
+    }
1004
+
1005
+    /**
1006
+     * Alias of self::get_email().
1007
+     *
1008
+     * @since 1.0.19
1009
+     * @param  string $context View or edit context.
1010
+     * @return string
1011
+     */
1012
+    public function get_customer_email( $context = 'view' ) {
1013
+        return $this->get_email( $context );
1014
+    }
1015
+
961 1016
     /**
962
-	 * Alias of self::get_phone().
963
-	 *
964
-	 * @since 1.0.19
965
-	 * @param  string $context View or edit context.
966
-	 * @return string
967
-	 */
968
-	public function get_customer_phone( $context = 'view' ) {
969
-		return $this->get_phone( $context );
1017
+     * Get the customer's country.
1018
+     *
1019
+     * @since 1.0.19
1020
+     * @param  string $context View or edit context.
1021
+     * @return string
1022
+     */
1023
+    public function get_country( $context = 'view' ) {
1024
+        $country = $this->get_prop( 'country', $context );
1025
+        return empty( $country ) ? wpinv_get_default_country() : $country;
970 1026
     }
971 1027
 
972 1028
     /**
973
-	 * Get the customer's email address.
974
-	 *
975
-	 * @since 1.0.19
976
-	 * @param  string $context View or edit context.
977
-	 * @return string
978
-	 */
979
-	public function get_email( $context = 'view' ) {
980
-		return $this->get_prop( 'email', $context );
1029
+     * Alias of self::get_country().
1030
+     *
1031
+     * @since 1.0.19
1032
+     * @param  string $context View or edit context.
1033
+     * @return string
1034
+     */
1035
+    public function get_user_country( $context = 'view' ) {
1036
+        return $this->get_country( $context );
981 1037
     }
982 1038
 
983 1039
     /**
984
-	 * Alias of self::get_email().
985
-	 *
986
-	 * @since 1.0.19
987
-	 * @param  string $context View or edit context.
988
-	 * @return string
989
-	 */
990
-	public function get_email_address( $context = 'view' ) {
991
-		return $this->get_email( $context );
1040
+     * Alias of self::get_country().
1041
+     *
1042
+     * @since 1.0.19
1043
+     * @param  string $context View or edit context.
1044
+     * @return string
1045
+     */
1046
+    public function get_customer_country( $context = 'view' ) {
1047
+        return $this->get_country( $context );
992 1048
     }
993 1049
 
994 1050
     /**
995
-	 * Alias of self::get_email().
996
-	 *
997
-	 * @since 1.0.19
998
-	 * @param  string $context View or edit context.
999
-	 * @return string
1000
-	 */
1001
-	public function get_user_email( $context = 'view' ) {
1002
-		return $this->get_email( $context );
1051
+     * Get the customer's state.
1052
+     *
1053
+     * @since 1.0.19
1054
+     * @param  string $context View or edit context.
1055
+     * @return string
1056
+     */
1057
+    public function get_state( $context = 'view' ) {
1058
+        $state = $this->get_prop( 'state', $context );
1059
+        return empty( $state ) ? wpinv_get_default_state() : $state;
1003 1060
     }
1004 1061
 
1005 1062
     /**
1006
-	 * Alias of self::get_email().
1007
-	 *
1008
-	 * @since 1.0.19
1009
-	 * @param  string $context View or edit context.
1010
-	 * @return string
1011
-	 */
1012
-	public function get_customer_email( $context = 'view' ) {
1013
-		return $this->get_email( $context );
1063
+     * Alias of self::get_state().
1064
+     *
1065
+     * @since 1.0.19
1066
+     * @param  string $context View or edit context.
1067
+     * @return string
1068
+     */
1069
+    public function get_user_state( $context = 'view' ) {
1070
+        return $this->get_state( $context );
1014 1071
     }
1015 1072
 
1016 1073
     /**
1017
-	 * Get the customer's country.
1018
-	 *
1019
-	 * @since 1.0.19
1020
-	 * @param  string $context View or edit context.
1021
-	 * @return string
1022
-	 */
1023
-	public function get_country( $context = 'view' ) {
1024
-		$country = $this->get_prop( 'country', $context );
1025
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1074
+     * Alias of self::get_state().
1075
+     *
1076
+     * @since 1.0.19
1077
+     * @param  string $context View or edit context.
1078
+     * @return string
1079
+     */
1080
+    public function get_customer_state( $context = 'view' ) {
1081
+        return $this->get_state( $context );
1026 1082
     }
1027 1083
 
1028 1084
     /**
1029
-	 * Alias of self::get_country().
1030
-	 *
1031
-	 * @since 1.0.19
1032
-	 * @param  string $context View or edit context.
1033
-	 * @return string
1034
-	 */
1035
-	public function get_user_country( $context = 'view' ) {
1036
-		return $this->get_country( $context );
1085
+     * Get the customer's city.
1086
+     *
1087
+     * @since 1.0.19
1088
+     * @param  string $context View or edit context.
1089
+     * @return string
1090
+     */
1091
+    public function get_city( $context = 'view' ) {
1092
+        return $this->get_prop( 'city', $context );
1037 1093
     }
1038 1094
 
1039 1095
     /**
1040
-	 * Alias of self::get_country().
1041
-	 *
1042
-	 * @since 1.0.19
1043
-	 * @param  string $context View or edit context.
1044
-	 * @return string
1045
-	 */
1046
-	public function get_customer_country( $context = 'view' ) {
1047
-		return $this->get_country( $context );
1096
+     * Alias of self::get_city().
1097
+     *
1098
+     * @since 1.0.19
1099
+     * @param  string $context View or edit context.
1100
+     * @return string
1101
+     */
1102
+    public function get_user_city( $context = 'view' ) {
1103
+        return $this->get_city( $context );
1104
+    }
1105
+
1106
+    /**
1107
+     * Alias of self::get_city().
1108
+     *
1109
+     * @since 1.0.19
1110
+     * @param  string $context View or edit context.
1111
+     * @return string
1112
+     */
1113
+    public function get_customer_city( $context = 'view' ) {
1114
+        return $this->get_city( $context );
1115
+    }
1116
+
1117
+    /**
1118
+     * Get the customer's zip.
1119
+     *
1120
+     * @since 1.0.19
1121
+     * @param  string $context View or edit context.
1122
+     * @return string
1123
+     */
1124
+    public function get_zip( $context = 'view' ) {
1125
+        return $this->get_prop( 'zip', $context );
1126
+    }
1127
+
1128
+    /**
1129
+     * Alias of self::get_zip().
1130
+     *
1131
+     * @since 1.0.19
1132
+     * @param  string $context View or edit context.
1133
+     * @return string
1134
+     */
1135
+    public function get_user_zip( $context = 'view' ) {
1136
+        return $this->get_zip( $context );
1137
+    }
1138
+
1139
+    /**
1140
+     * Alias of self::get_zip().
1141
+     *
1142
+     * @since 1.0.19
1143
+     * @param  string $context View or edit context.
1144
+     * @return string
1145
+     */
1146
+    public function get_customer_zip( $context = 'view' ) {
1147
+        return $this->get_zip( $context );
1148
+    }
1149
+
1150
+    /**
1151
+     * Get the customer's company.
1152
+     *
1153
+     * @since 1.0.19
1154
+     * @param  string $context View or edit context.
1155
+     * @return string
1156
+     */
1157
+    public function get_company( $context = 'view' ) {
1158
+        return $this->get_prop( 'company', $context );
1159
+    }
1160
+
1161
+    /**
1162
+     * Alias of self::get_company().
1163
+     *
1164
+     * @since 1.0.19
1165
+     * @param  string $context View or edit context.
1166
+     * @return string
1167
+     */
1168
+    public function get_user_company( $context = 'view' ) {
1169
+        return $this->get_company( $context );
1170
+    }
1171
+
1172
+    /**
1173
+     * Alias of self::get_company().
1174
+     *
1175
+     * @since 1.0.19
1176
+     * @param  string $context View or edit context.
1177
+     * @return string
1178
+     */
1179
+    public function get_customer_company( $context = 'view' ) {
1180
+        return $this->get_company( $context );
1181
+    }
1182
+
1183
+    /**
1184
+     * Get the customer's company id.
1185
+     *
1186
+     * @since 1.0.19
1187
+     * @param  string $context View or edit context.
1188
+     * @return string
1189
+     */
1190
+    public function get_company_id( $context = 'view' ) {
1191
+        return $this->get_prop( 'company_id', $context );
1192
+    }
1193
+
1194
+    /**
1195
+     * Get the customer's vat number.
1196
+     *
1197
+     * @since 1.0.19
1198
+     * @param  string $context View or edit context.
1199
+     * @return string
1200
+     */
1201
+    public function get_vat_number( $context = 'view' ) {
1202
+        return $this->get_prop( 'vat_number', $context );
1203
+    }
1204
+
1205
+    /**
1206
+     * Alias of self::get_vat_number().
1207
+     *
1208
+     * @since 1.0.19
1209
+     * @param  string $context View or edit context.
1210
+     * @return string
1211
+     */
1212
+    public function get_user_vat_number( $context = 'view' ) {
1213
+        return $this->get_vat_number( $context );
1048 1214
     }
1049 1215
 
1050 1216
     /**
1051
-	 * Get the customer's state.
1052
-	 *
1053
-	 * @since 1.0.19
1054
-	 * @param  string $context View or edit context.
1055
-	 * @return string
1056
-	 */
1057
-	public function get_state( $context = 'view' ) {
1058
-		$state = $this->get_prop( 'state', $context );
1059
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1217
+     * Alias of self::get_vat_number().
1218
+     *
1219
+     * @since 1.0.19
1220
+     * @param  string $context View or edit context.
1221
+     * @return string
1222
+     */
1223
+    public function get_customer_vat_number( $context = 'view' ) {
1224
+        return $this->get_vat_number( $context );
1060 1225
     }
1061 1226
 
1062 1227
     /**
1063
-	 * Alias of self::get_state().
1064
-	 *
1065
-	 * @since 1.0.19
1066
-	 * @param  string $context View or edit context.
1067
-	 * @return string
1068
-	 */
1069
-	public function get_user_state( $context = 'view' ) {
1070
-		return $this->get_state( $context );
1228
+     * Get the customer's vat rate.
1229
+     *
1230
+     * @since 1.0.19
1231
+     * @param  string $context View or edit context.
1232
+     * @return string
1233
+     */
1234
+    public function get_vat_rate( $context = 'view' ) {
1235
+        return $this->get_prop( 'vat_rate', $context );
1071 1236
     }
1072 1237
 
1073 1238
     /**
1074
-	 * Alias of self::get_state().
1075
-	 *
1076
-	 * @since 1.0.19
1077
-	 * @param  string $context View or edit context.
1078
-	 * @return string
1079
-	 */
1080
-	public function get_customer_state( $context = 'view' ) {
1081
-		return $this->get_state( $context );
1239
+     * Alias of self::get_vat_rate().
1240
+     *
1241
+     * @since 1.0.19
1242
+     * @param  string $context View or edit context.
1243
+     * @return string
1244
+     */
1245
+    public function get_user_vat_rate( $context = 'view' ) {
1246
+        return $this->get_vat_rate( $context );
1082 1247
     }
1083 1248
 
1084 1249
     /**
1085
-	 * Get the customer's city.
1086
-	 *
1087
-	 * @since 1.0.19
1088
-	 * @param  string $context View or edit context.
1089
-	 * @return string
1090
-	 */
1091
-	public function get_city( $context = 'view' ) {
1092
-		return $this->get_prop( 'city', $context );
1250
+     * Alias of self::get_vat_rate().
1251
+     *
1252
+     * @since 1.0.19
1253
+     * @param  string $context View or edit context.
1254
+     * @return string
1255
+     */
1256
+    public function get_customer_vat_rate( $context = 'view' ) {
1257
+        return $this->get_vat_rate( $context );
1093 1258
     }
1094 1259
 
1095 1260
     /**
1096
-	 * Alias of self::get_city().
1097
-	 *
1098
-	 * @since 1.0.19
1099
-	 * @param  string $context View or edit context.
1100
-	 * @return string
1101
-	 */
1102
-	public function get_user_city( $context = 'view' ) {
1103
-		return $this->get_city( $context );
1261
+     * Get the customer's address.
1262
+     *
1263
+     * @since 1.0.19
1264
+     * @param  string $context View or edit context.
1265
+     * @return string
1266
+     */
1267
+    public function get_address( $context = 'view' ) {
1268
+        return $this->get_prop( 'address', $context );
1104 1269
     }
1105 1270
 
1106 1271
     /**
1107
-	 * Alias of self::get_city().
1108
-	 *
1109
-	 * @since 1.0.19
1110
-	 * @param  string $context View or edit context.
1111
-	 * @return string
1112
-	 */
1113
-	public function get_customer_city( $context = 'view' ) {
1114
-		return $this->get_city( $context );
1272
+     * Alias of self::get_address().
1273
+     *
1274
+     * @since 1.0.19
1275
+     * @param  string $context View or edit context.
1276
+     * @return string
1277
+     */
1278
+    public function get_user_address( $context = 'view' ) {
1279
+        return $this->get_address( $context );
1115 1280
     }
1116 1281
 
1117 1282
     /**
1118
-	 * Get the customer's zip.
1119
-	 *
1120
-	 * @since 1.0.19
1121
-	 * @param  string $context View or edit context.
1122
-	 * @return string
1123
-	 */
1124
-	public function get_zip( $context = 'view' ) {
1125
-		return $this->get_prop( 'zip', $context );
1283
+     * Alias of self::get_address().
1284
+     *
1285
+     * @since 1.0.19
1286
+     * @param  string $context View or edit context.
1287
+     * @return string
1288
+     */
1289
+    public function get_customer_address( $context = 'view' ) {
1290
+        return $this->get_address( $context );
1126 1291
     }
1127 1292
 
1128 1293
     /**
1129
-	 * Alias of self::get_zip().
1130
-	 *
1131
-	 * @since 1.0.19
1132
-	 * @param  string $context View or edit context.
1133
-	 * @return string
1134
-	 */
1135
-	public function get_user_zip( $context = 'view' ) {
1136
-		return $this->get_zip( $context );
1294
+     * Get whether the customer has viewed the invoice or not.
1295
+     *
1296
+     * @since 1.0.19
1297
+     * @param  string $context View or edit context.
1298
+     * @return bool
1299
+     */
1300
+    public function get_is_viewed( $context = 'view' ) {
1301
+        return (bool) $this->get_prop( 'is_viewed', $context );
1137 1302
     }
1138 1303
 
1139 1304
     /**
1140
-	 * Alias of self::get_zip().
1141
-	 *
1142
-	 * @since 1.0.19
1143
-	 * @param  string $context View or edit context.
1144
-	 * @return string
1145
-	 */
1146
-	public function get_customer_zip( $context = 'view' ) {
1147
-		return $this->get_zip( $context );
1305
+     * Get other recipients for invoice communications.
1306
+     *
1307
+     * @since 1.0.19
1308
+     * @param  string $context View or edit context.
1309
+     * @return bool
1310
+     */
1311
+    public function get_email_cc( $context = 'view' ) {
1312
+        return $this->get_prop( 'email_cc', $context );
1148 1313
     }
1149 1314
 
1150 1315
     /**
1151
-	 * Get the customer's company.
1152
-	 *
1153
-	 * @since 1.0.19
1154
-	 * @param  string $context View or edit context.
1155
-	 * @return string
1156
-	 */
1157
-	public function get_company( $context = 'view' ) {
1158
-		return $this->get_prop( 'company', $context );
1316
+     * Get invoice template.
1317
+     *
1318
+     * @since 1.0.19
1319
+     * @param  string $context View or edit context.
1320
+     * @return bool
1321
+     */
1322
+    public function get_template( $context = 'view' ) {
1323
+        return $this->get_prop( 'template', $context );
1159 1324
     }
1160 1325
 
1161 1326
     /**
1162
-	 * Alias of self::get_company().
1163
-	 *
1164
-	 * @since 1.0.19
1165
-	 * @param  string $context View or edit context.
1166
-	 * @return string
1167
-	 */
1168
-	public function get_user_company( $context = 'view' ) {
1169
-		return $this->get_company( $context );
1327
+     * Get invoice source.
1328
+     *
1329
+     * @since 1.0.19
1330
+     * @param  string $context View or edit context.
1331
+     * @return bool
1332
+     */
1333
+    public function get_created_via( $context = 'view' ) {
1334
+        return $this->get_prop( 'created_via', $context );
1170 1335
     }
1171 1336
 
1172 1337
     /**
1173
-	 * Alias of self::get_company().
1174
-	 *
1175
-	 * @since 1.0.19
1176
-	 * @param  string $context View or edit context.
1177
-	 * @return string
1178
-	 */
1179
-	public function get_customer_company( $context = 'view' ) {
1180
-		return $this->get_company( $context );
1338
+     * Get whether the customer has confirmed their address.
1339
+     *
1340
+     * @since 1.0.19
1341
+     * @param  string $context View or edit context.
1342
+     * @return bool
1343
+     */
1344
+    public function get_address_confirmed( $context = 'view' ) {
1345
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1181 1346
     }
1182 1347
 
1183
-	/**
1184
-	 * Get the customer's company id.
1185
-	 *
1186
-	 * @since 1.0.19
1187
-	 * @param  string $context View or edit context.
1188
-	 * @return string
1189
-	 */
1190
-	public function get_company_id( $context = 'view' ) {
1191
-		return $this->get_prop( 'company_id', $context );
1348
+    /**
1349
+     * Alias of self::get_address_confirmed().
1350
+     *
1351
+     * @since 1.0.19
1352
+     * @param  string $context View or edit context.
1353
+     * @return bool
1354
+     */
1355
+    public function get_user_address_confirmed( $context = 'view' ) {
1356
+        return $this->get_address_confirmed( $context );
1192 1357
     }
1193 1358
 
1194 1359
     /**
1195
-	 * Get the customer's vat number.
1196
-	 *
1197
-	 * @since 1.0.19
1198
-	 * @param  string $context View or edit context.
1199
-	 * @return string
1200
-	 */
1201
-	public function get_vat_number( $context = 'view' ) {
1202
-		return $this->get_prop( 'vat_number', $context );
1360
+     * Alias of self::get_address().
1361
+     *
1362
+     * @since 1.0.19
1363
+     * @param  string $context View or edit context.
1364
+     * @return bool
1365
+     */
1366
+    public function get_customer_address_confirmed( $context = 'view' ) {
1367
+        return $this->get_address_confirmed( $context );
1203 1368
     }
1204 1369
 
1205 1370
     /**
1206
-	 * Alias of self::get_vat_number().
1207
-	 *
1208
-	 * @since 1.0.19
1209
-	 * @param  string $context View or edit context.
1210
-	 * @return string
1211
-	 */
1212
-	public function get_user_vat_number( $context = 'view' ) {
1213
-		return $this->get_vat_number( $context );
1371
+     * Get the shipping address.
1372
+     *
1373
+     * @since 1.0.19
1374
+     * @return array|false
1375
+     */
1376
+    public function get_shipping_address() {
1377
+
1378
+        $shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1379
+        return is_array( $shipping_address ) ? $shipping_address : false;
1214 1380
     }
1215 1381
 
1216 1382
     /**
1217
-	 * Alias of self::get_vat_number().
1218
-	 *
1219
-	 * @since 1.0.19
1220
-	 * @param  string $context View or edit context.
1221
-	 * @return string
1222
-	 */
1223
-	public function get_customer_vat_number( $context = 'view' ) {
1224
-		return $this->get_vat_number( $context );
1383
+     * Check if the invoice has a shipping address.
1384
+     */
1385
+    public function has_shipping_address() {
1386
+        return false !== $this->get_shipping_address();
1225 1387
     }
1226 1388
 
1227
-    /**
1228
-	 * Get the customer's vat rate.
1229
-	 *
1230
-	 * @since 1.0.19
1231
-	 * @param  string $context View or edit context.
1232
-	 * @return string
1233
-	 */
1234
-	public function get_vat_rate( $context = 'view' ) {
1235
-		return $this->get_prop( 'vat_rate', $context );
1236
-    }
1237
-
1238
-    /**
1239
-	 * Alias of self::get_vat_rate().
1240
-	 *
1241
-	 * @since 1.0.19
1242
-	 * @param  string $context View or edit context.
1243
-	 * @return string
1244
-	 */
1245
-	public function get_user_vat_rate( $context = 'view' ) {
1246
-		return $this->get_vat_rate( $context );
1247
-    }
1248
-
1249
-    /**
1250
-	 * Alias of self::get_vat_rate().
1251
-	 *
1252
-	 * @since 1.0.19
1253
-	 * @param  string $context View or edit context.
1254
-	 * @return string
1255
-	 */
1256
-	public function get_customer_vat_rate( $context = 'view' ) {
1257
-		return $this->get_vat_rate( $context );
1258
-    }
1259
-
1260
-    /**
1261
-	 * Get the customer's address.
1262
-	 *
1263
-	 * @since 1.0.19
1264
-	 * @param  string $context View or edit context.
1265
-	 * @return string
1266
-	 */
1267
-	public function get_address( $context = 'view' ) {
1268
-		return $this->get_prop( 'address', $context );
1269
-    }
1270
-
1271
-    /**
1272
-	 * Alias of self::get_address().
1273
-	 *
1274
-	 * @since 1.0.19
1275
-	 * @param  string $context View or edit context.
1276
-	 * @return string
1277
-	 */
1278
-	public function get_user_address( $context = 'view' ) {
1279
-		return $this->get_address( $context );
1280
-    }
1281
-
1282
-    /**
1283
-	 * Alias of self::get_address().
1284
-	 *
1285
-	 * @since 1.0.19
1286
-	 * @param  string $context View or edit context.
1287
-	 * @return string
1288
-	 */
1289
-	public function get_customer_address( $context = 'view' ) {
1290
-		return $this->get_address( $context );
1291
-    }
1292
-
1293
-    /**
1294
-	 * Get whether the customer has viewed the invoice or not.
1295
-	 *
1296
-	 * @since 1.0.19
1297
-	 * @param  string $context View or edit context.
1298
-	 * @return bool
1299
-	 */
1300
-	public function get_is_viewed( $context = 'view' ) {
1301
-		return (bool) $this->get_prop( 'is_viewed', $context );
1302
-	}
1303
-
1304
-	/**
1305
-	 * Get other recipients for invoice communications.
1306
-	 *
1307
-	 * @since 1.0.19
1308
-	 * @param  string $context View or edit context.
1309
-	 * @return bool
1310
-	 */
1311
-	public function get_email_cc( $context = 'view' ) {
1312
-		return $this->get_prop( 'email_cc', $context );
1313
-	}
1314
-
1315
-	/**
1316
-	 * Get invoice template.
1317
-	 *
1318
-	 * @since 1.0.19
1319
-	 * @param  string $context View or edit context.
1320
-	 * @return bool
1321
-	 */
1322
-	public function get_template( $context = 'view' ) {
1323
-		return $this->get_prop( 'template', $context );
1324
-	}
1325
-
1326
-	/**
1327
-	 * Get invoice source.
1328
-	 *
1329
-	 * @since 1.0.19
1330
-	 * @param  string $context View or edit context.
1331
-	 * @return bool
1332
-	 */
1333
-	public function get_created_via( $context = 'view' ) {
1334
-		return $this->get_prop( 'created_via', $context );
1335
-	}
1336
-
1337
-	/**
1338
-	 * Get whether the customer has confirmed their address.
1339
-	 *
1340
-	 * @since 1.0.19
1341
-	 * @param  string $context View or edit context.
1342
-	 * @return bool
1343
-	 */
1344
-	public function get_address_confirmed( $context = 'view' ) {
1345
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1346
-    }
1347
-
1348
-    /**
1349
-	 * Alias of self::get_address_confirmed().
1350
-	 *
1351
-	 * @since 1.0.19
1352
-	 * @param  string $context View or edit context.
1353
-	 * @return bool
1354
-	 */
1355
-	public function get_user_address_confirmed( $context = 'view' ) {
1356
-		return $this->get_address_confirmed( $context );
1357
-    }
1358
-
1359
-    /**
1360
-	 * Alias of self::get_address().
1361
-	 *
1362
-	 * @since 1.0.19
1363
-	 * @param  string $context View or edit context.
1364
-	 * @return bool
1365
-	 */
1366
-	public function get_customer_address_confirmed( $context = 'view' ) {
1367
-		return $this->get_address_confirmed( $context );
1368
-    }
1369
-
1370
-	/**
1371
-	 * Get the shipping address.
1372
-	 *
1373
-	 * @since 1.0.19
1374
-	 * @return array|false
1375
-	 */
1376
-	public function get_shipping_address() {
1377
-
1378
-		$shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1379
-		return is_array( $shipping_address ) ? $shipping_address : false;
1380
-    }
1381
-
1382
-	/**
1383
-	 * Check if the invoice has a shipping address.
1384
-	 */
1385
-	public function has_shipping_address() {
1386
-		return false !== $this->get_shipping_address();
1387
-    }
1388
-
1389
-	/**
1390
-	 * Get the shipping amount.
1391
-	 *
1392
-	 * @since 1.0.19
1393
-	 * @param  string $context View or edit context.
1394
-	 * @return float
1395
-	 */
1396
-	public function get_shipping( $context = 'view' ) {
1397
-
1398
-		if ( $context = 'view' ) {
1399
-			return floatval( $this->get_prop( 'shipping', $context ) );
1400
-		}
1389
+    /**
1390
+     * Get the shipping amount.
1391
+     *
1392
+     * @since 1.0.19
1393
+     * @param  string $context View or edit context.
1394
+     * @return float
1395
+     */
1396
+    public function get_shipping( $context = 'view' ) {
1397
+
1398
+        if ( $context = 'view' ) {
1399
+            return floatval( $this->get_prop( 'shipping', $context ) );
1400
+        }
1401 1401
  
1402
-		return $this->get_prop( 'shipping', $context );
1402
+        return $this->get_prop( 'shipping', $context );
1403 1403
     }
1404 1404
 
1405
-	public function has_shipping() {
1406
-		return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' );
1405
+    public function has_shipping() {
1406
+        return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' );
1407 1407
     }
1408 1408
 
1409 1409
     /**
1410
-	 * Get the invoice subtotal.
1411
-	 *
1412
-	 * @since 1.0.19
1413
-	 * @param  string $context View or edit context.
1414
-	 * @return float
1415
-	 */
1416
-	public function get_subtotal( $context = 'view' ) {
1410
+     * Get the invoice subtotal.
1411
+     *
1412
+     * @since 1.0.19
1413
+     * @param  string $context View or edit context.
1414
+     * @return float
1415
+     */
1416
+    public function get_subtotal( $context = 'view' ) {
1417 1417
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1418 1418
 
1419 1419
         // Backwards compatibility.
@@ -1425,198 +1425,198 @@  discard block
 block discarded – undo
1425 1425
     }
1426 1426
 
1427 1427
     /**
1428
-	 * Get the invoice discount total.
1429
-	 *
1430
-	 * @since 1.0.19
1431
-	 * @param  string $context View or edit context.
1432
-	 * @return float
1433
-	 */
1434
-	public function get_total_discount( $context = 'view' ) {
1435
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1428
+     * Get the invoice discount total.
1429
+     *
1430
+     * @since 1.0.19
1431
+     * @param  string $context View or edit context.
1432
+     * @return float
1433
+     */
1434
+    public function get_total_discount( $context = 'view' ) {
1435
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1436 1436
     }
1437 1437
 
1438 1438
     /**
1439
-	 * Get the invoice tax total.
1440
-	 *
1441
-	 * @since 1.0.19
1442
-	 * @param  string $context View or edit context.
1443
-	 * @return float
1444
-	 */
1445
-	public function get_total_tax( $context = 'view' ) {
1446
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1447
-	}
1439
+     * Get the invoice tax total.
1440
+     *
1441
+     * @since 1.0.19
1442
+     * @param  string $context View or edit context.
1443
+     * @return float
1444
+     */
1445
+    public function get_total_tax( $context = 'view' ) {
1446
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1447
+    }
1448 1448
 
1449
-	/**
1450
-	 * @deprecated
1451
-	 */
1452
-	public function get_final_tax( $currency = false ) {
1453
-		$tax = $this->get_total_tax();
1449
+    /**
1450
+     * @deprecated
1451
+     */
1452
+    public function get_final_tax( $currency = false ) {
1453
+        $tax = $this->get_total_tax();
1454 1454
 
1455 1455
         if ( $currency ) {
1456
-			return wpinv_price( $tax, $this->get_currency() );
1456
+            return wpinv_price( $tax, $this->get_currency() );
1457 1457
         }
1458 1458
 
1459 1459
         return $tax;
1460 1460
     }
1461 1461
 
1462 1462
     /**
1463
-	 * Get the invoice fees total.
1464
-	 *
1465
-	 * @since 1.0.19
1466
-	 * @param  string $context View or edit context.
1467
-	 * @return float
1468
-	 */
1469
-	public function get_total_fees( $context = 'view' ) {
1470
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1463
+     * Get the invoice fees total.
1464
+     *
1465
+     * @since 1.0.19
1466
+     * @param  string $context View or edit context.
1467
+     * @return float
1468
+     */
1469
+    public function get_total_fees( $context = 'view' ) {
1470
+        return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1471
+    }
1472
+
1473
+    /**
1474
+     * Alias for self::get_total_fees().
1475
+     *
1476
+     * @since 1.0.19
1477
+     * @param  string $context View or edit context.
1478
+     * @return float
1479
+     */
1480
+    public function get_fees_total( $context = 'view' ) {
1481
+        return $this->get_total_fees( $context );
1471 1482
     }
1472 1483
 
1473 1484
     /**
1474
-	 * Alias for self::get_total_fees().
1475
-	 *
1476
-	 * @since 1.0.19
1477
-	 * @param  string $context View or edit context.
1478
-	 * @return float
1479
-	 */
1480
-	public function get_fees_total( $context = 'view' ) {
1481
-		return $this->get_total_fees( $context );
1485
+     * Get the invoice total.
1486
+     *
1487
+     * @since 1.0.19
1488
+     * @return float
1489
+     */
1490
+    public function get_total( $context = 'view' ) {
1491
+        $total = $this->get_prop( 'total', $context );
1492
+
1493
+        if ( $this->has_shipping() && $context == 'view' ) {
1494
+            $total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1495
+        }
1496
+
1497
+        return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1482 1498
     }
1483 1499
 
1484 1500
     /**
1485
-	 * Get the invoice total.
1486
-	 *
1487
-	 * @since 1.0.19
1501
+     * Retrieves the non-recurring total of items.
1502
+     *
1503
+     * @since 2.3.0
1488 1504
      * @return float
1489
-	 */
1490
-	public function get_total( $context = 'view' ) {
1491
-		$total = $this->get_prop( 'total', $context );
1492
-
1493
-		if ( $this->has_shipping() && $context == 'view' ) {
1494
-			$total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1495
-		}
1496
-
1497
-		return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1498
-	}
1499
-
1500
-	/**
1501
-	 * Retrieves the non-recurring total of items.
1502
-	 *
1503
-	 * @since 2.3.0
1504
-	 * @return float
1505
-	 */
1506
-	public function get_non_recurring_total() {
1507
-
1508
-		$subtotal = 0;
1509
-		foreach ( $this->get_items() as $item ) {
1510
-			if ( ! $item->is_recurring() ) {
1511
-				$subtotal += $item->get_sub_total();
1512
-			}
1513
-		}
1514
-
1515
-		foreach ( $this->get_fees() as $fee ) {
1516
-			if ( empty( $fee['recurring_fee'] ) ) {
1517
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1518
-			}
1519
-		}
1520
-
1521
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1505
+     */
1506
+    public function get_non_recurring_total() {
1507
+
1508
+        $subtotal = 0;
1509
+        foreach ( $this->get_items() as $item ) {
1510
+            if ( ! $item->is_recurring() ) {
1511
+                $subtotal += $item->get_sub_total();
1512
+            }
1513
+        }
1514
+
1515
+        foreach ( $this->get_fees() as $fee ) {
1516
+            if ( empty( $fee['recurring_fee'] ) ) {
1517
+                $subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1518
+            }
1519
+        }
1520
+
1521
+        $subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1522 1522
         return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1523 1523
 
1524 1524
     }
1525 1525
 
1526
-	/**
1527
-	 * Get the invoice totals.
1528
-	 *
1529
-	 * @since 1.0.19
1526
+    /**
1527
+     * Get the invoice totals.
1528
+     *
1529
+     * @since 1.0.19
1530 1530
      * @return array
1531
-	 */
1532
-	public function get_totals() {
1533
-		return $this->totals;
1531
+     */
1532
+    public function get_totals() {
1533
+        return $this->totals;
1534 1534
     }
1535 1535
 
1536 1536
     /**
1537
-	 * Get the initial invoice total.
1538
-	 *
1539
-	 * @since 1.0.19
1537
+     * Get the initial invoice total.
1538
+     *
1539
+     * @since 1.0.19
1540 1540
      * @param  string $context View or edit context.
1541 1541
      * @return float
1542
-	 */
1542
+     */
1543 1543
     public function get_initial_total() {
1544 1544
 
1545
-		if ( empty( $this->totals ) ) {
1546
-			$this->recalculate_total();
1547
-		}
1545
+        if ( empty( $this->totals ) ) {
1546
+            $this->recalculate_total();
1547
+        }
1548 1548
 
1549
-		$tax      = $this->totals['tax']['initial'];
1550
-		$fee      = $this->totals['fee']['initial'];
1551
-		$discount = $this->totals['discount']['initial'];
1552
-		$subtotal = $this->totals['subtotal']['initial'];
1553
-		$total    = $tax + $fee - $discount + $subtotal;
1549
+        $tax      = $this->totals['tax']['initial'];
1550
+        $fee      = $this->totals['fee']['initial'];
1551
+        $discount = $this->totals['discount']['initial'];
1552
+        $subtotal = $this->totals['subtotal']['initial'];
1553
+        $total    = $tax + $fee - $discount + $subtotal;
1554 1554
 
1555
-		if ( 0 > $total ) {
1556
-			$total = 0;
1557
-		}
1555
+        if ( 0 > $total ) {
1556
+            $total = 0;
1557
+        }
1558 1558
 
1559
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1559
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1560 1560
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1561
-	}
1561
+    }
1562 1562
 
1563
-	/**
1564
-	 * Get the recurring invoice total.
1565
-	 *
1566
-	 * @since 1.0.19
1563
+    /**
1564
+     * Get the recurring invoice total.
1565
+     *
1566
+     * @since 1.0.19
1567 1567
      * @param  string $context View or edit context.
1568 1568
      * @return float
1569
-	 */
1569
+     */
1570 1570
     public function get_recurring_total() {
1571 1571
 
1572
-		if ( empty( $this->totals ) ) {
1573
-			$this->recalculate_total();
1574
-		}
1572
+        if ( empty( $this->totals ) ) {
1573
+            $this->recalculate_total();
1574
+        }
1575 1575
 
1576
-		$tax      = $this->totals['tax']['recurring'];
1577
-		$fee      = $this->totals['fee']['recurring'];
1578
-		$discount = $this->totals['discount']['recurring'];
1579
-		$subtotal = $this->totals['subtotal']['recurring'];
1580
-		$total    = $tax + $fee - $discount + $subtotal;
1576
+        $tax      = $this->totals['tax']['recurring'];
1577
+        $fee      = $this->totals['fee']['recurring'];
1578
+        $discount = $this->totals['discount']['recurring'];
1579
+        $subtotal = $this->totals['subtotal']['recurring'];
1580
+        $total    = $tax + $fee - $discount + $subtotal;
1581 1581
 
1582
-		if ( 0 > $total ) {
1583
-			$total = 0;
1584
-		}
1582
+        if ( 0 > $total ) {
1583
+            $total = 0;
1584
+        }
1585 1585
 
1586
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1586
+        $total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1587 1587
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1588
-	}
1588
+    }
1589 1589
 
1590
-	/**
1591
-	 * Returns recurring payment details.
1592
-	 *
1593
-	 * @since 1.0.19
1590
+    /**
1591
+     * Returns recurring payment details.
1592
+     *
1593
+     * @since 1.0.19
1594 1594
      * @param  string $field Optionally provide a field to return.
1595
-	 * @param string $currency Whether to include the currency.
1595
+     * @param string $currency Whether to include the currency.
1596 1596
      * @return float|string
1597
-	 */
1597
+     */
1598 1598
     public function get_recurring_details( $field = '', $currency = false ) {
1599 1599
 
1600
-		// Maybe recalculate totals.
1601
-		if ( empty( $this->totals ) ) {
1602
-			$this->recalculate_total();
1603
-		}
1600
+        // Maybe recalculate totals.
1601
+        if ( empty( $this->totals ) ) {
1602
+            $this->recalculate_total();
1603
+        }
1604 1604
 
1605
-		// Prepare recurring totals.
1605
+        // Prepare recurring totals.
1606 1606
         $data = apply_filters(
1607
-			'wpinv_get_invoice_recurring_details',
1608
-			array(
1609
-				'cart_details' => $this->get_cart_details(),
1610
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1611
-				'discount'     => $this->totals['discount']['recurring'],
1612
-				'tax'          => $this->totals['tax']['recurring'],
1613
-				'fee'          => $this->totals['fee']['recurring'],
1614
-				'total'        => $this->get_recurring_total(),
1615
-			),
1616
-			$this,
1617
-			$field,
1618
-			$currency
1619
-		);
1607
+            'wpinv_get_invoice_recurring_details',
1608
+            array(
1609
+                'cart_details' => $this->get_cart_details(),
1610
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1611
+                'discount'     => $this->totals['discount']['recurring'],
1612
+                'tax'          => $this->totals['tax']['recurring'],
1613
+                'fee'          => $this->totals['fee']['recurring'],
1614
+                'total'        => $this->get_recurring_total(),
1615
+            ),
1616
+            $this,
1617
+            $field,
1618
+            $currency
1619
+        );
1620 1620
 
1621 1621
         if ( isset( $data[$field] ) ) {
1622 1622
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1626,166 +1626,166 @@  discard block
 block discarded – undo
1626 1626
     }
1627 1627
 
1628 1628
     /**
1629
-	 * Get the invoice fees.
1630
-	 *
1631
-	 * @since 1.0.19
1632
-	 * @param  string $context View or edit context.
1633
-	 * @return array
1634
-	 */
1635
-	public function get_fees( $context = 'view' ) {
1636
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1629
+     * Get the invoice fees.
1630
+     *
1631
+     * @since 1.0.19
1632
+     * @param  string $context View or edit context.
1633
+     * @return array
1634
+     */
1635
+    public function get_fees( $context = 'view' ) {
1636
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1637 1637
     }
1638 1638
 
1639 1639
     /**
1640
-	 * Get the invoice discounts.
1641
-	 *
1642
-	 * @since 1.0.19
1643
-	 * @param  string $context View or edit context.
1644
-	 * @return array
1645
-	 */
1646
-	public function get_discounts( $context = 'view' ) {
1647
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1640
+     * Get the invoice discounts.
1641
+     *
1642
+     * @since 1.0.19
1643
+     * @param  string $context View or edit context.
1644
+     * @return array
1645
+     */
1646
+    public function get_discounts( $context = 'view' ) {
1647
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1648 1648
     }
1649 1649
 
1650 1650
     /**
1651
-	 * Get the invoice taxes.
1652
-	 *
1653
-	 * @since 1.0.19
1654
-	 * @param  string $context View or edit context.
1655
-	 * @return array
1656
-	 */
1657
-	public function get_taxes( $context = 'view' ) {
1658
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1651
+     * Get the invoice taxes.
1652
+     *
1653
+     * @since 1.0.19
1654
+     * @param  string $context View or edit context.
1655
+     * @return array
1656
+     */
1657
+    public function get_taxes( $context = 'view' ) {
1658
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1659 1659
     }
1660 1660
 
1661 1661
     /**
1662
-	 * Get the invoice items.
1663
-	 *
1664
-	 * @since 1.0.19
1665
-	 * @param  string $context View or edit context.
1666
-	 * @return GetPaid_Form_Item[]
1667
-	 */
1668
-	public function get_items( $context = 'view' ) {
1662
+     * Get the invoice items.
1663
+     *
1664
+     * @since 1.0.19
1665
+     * @param  string $context View or edit context.
1666
+     * @return GetPaid_Form_Item[]
1667
+     */
1668
+    public function get_items( $context = 'view' ) {
1669 1669
         return $this->get_prop( 'items', $context );
1670
-	}
1670
+    }
1671 1671
 
1672
-	/**
1673
-	 * Get the invoice item ids.
1674
-	 *
1675
-	 * @since 1.0.19
1676
-	 * @return string
1677
-	 */
1678
-	public function get_item_ids() {
1679
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1672
+    /**
1673
+     * Get the invoice item ids.
1674
+     *
1675
+     * @since 1.0.19
1676
+     * @return string
1677
+     */
1678
+    public function get_item_ids() {
1679
+        return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1680 1680
     }
1681 1681
 
1682 1682
     /**
1683
-	 * Get the invoice's payment form.
1684
-	 *
1685
-	 * @since 1.0.19
1686
-	 * @param  string $context View or edit context.
1687
-	 * @return int
1688
-	 */
1689
-	public function get_payment_form( $context = 'view' ) {
1690
-		return intval( $this->get_prop( 'payment_form', $context ) );
1683
+     * Get the invoice's payment form.
1684
+     *
1685
+     * @since 1.0.19
1686
+     * @param  string $context View or edit context.
1687
+     * @return int
1688
+     */
1689
+    public function get_payment_form( $context = 'view' ) {
1690
+        return intval( $this->get_prop( 'payment_form', $context ) );
1691 1691
     }
1692 1692
 
1693 1693
     /**
1694
-	 * Get the invoice's submission id.
1695
-	 *
1696
-	 * @since 1.0.19
1697
-	 * @param  string $context View or edit context.
1698
-	 * @return string
1699
-	 */
1700
-	public function get_submission_id( $context = 'view' ) {
1701
-		return $this->get_prop( 'submission_id', $context );
1694
+     * Get the invoice's submission id.
1695
+     *
1696
+     * @since 1.0.19
1697
+     * @param  string $context View or edit context.
1698
+     * @return string
1699
+     */
1700
+    public function get_submission_id( $context = 'view' ) {
1701
+        return $this->get_prop( 'submission_id', $context );
1702 1702
     }
1703 1703
 
1704 1704
     /**
1705
-	 * Get the invoice's discount code.
1706
-	 *
1707
-	 * @since 1.0.19
1708
-	 * @param  string $context View or edit context.
1709
-	 * @return string
1710
-	 */
1711
-	public function get_discount_code( $context = 'view' ) {
1712
-		return $this->get_prop( 'discount_code', $context );
1705
+     * Get the invoice's discount code.
1706
+     *
1707
+     * @since 1.0.19
1708
+     * @param  string $context View or edit context.
1709
+     * @return string
1710
+     */
1711
+    public function get_discount_code( $context = 'view' ) {
1712
+        return $this->get_prop( 'discount_code', $context );
1713 1713
     }
1714 1714
 
1715 1715
     /**
1716
-	 * Get the invoice's gateway.
1717
-	 *
1718
-	 * @since 1.0.19
1719
-	 * @param  string $context View or edit context.
1720
-	 * @return string
1721
-	 */
1722
-	public function get_gateway( $context = 'view' ) {
1723
-		return $this->get_prop( 'gateway', $context );
1716
+     * Get the invoice's gateway.
1717
+     *
1718
+     * @since 1.0.19
1719
+     * @param  string $context View or edit context.
1720
+     * @return string
1721
+     */
1722
+    public function get_gateway( $context = 'view' ) {
1723
+        return $this->get_prop( 'gateway', $context );
1724 1724
     }
1725 1725
 
1726 1726
     /**
1727
-	 * Get the invoice's gateway display title.
1728
-	 *
1729
-	 * @since 1.0.19
1730
-	 * @return string
1731
-	 */
1727
+     * Get the invoice's gateway display title.
1728
+     *
1729
+     * @since 1.0.19
1730
+     * @return string
1731
+     */
1732 1732
     public function get_gateway_title() {
1733 1733
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1734 1734
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1735 1735
     }
1736 1736
 
1737 1737
     /**
1738
-	 * Get the invoice's transaction id.
1739
-	 *
1740
-	 * @since 1.0.19
1741
-	 * @param  string $context View or edit context.
1742
-	 * @return string
1743
-	 */
1744
-	public function get_transaction_id( $context = 'view' ) {
1745
-		return $this->get_prop( 'transaction_id', $context );
1738
+     * Get the invoice's transaction id.
1739
+     *
1740
+     * @since 1.0.19
1741
+     * @param  string $context View or edit context.
1742
+     * @return string
1743
+     */
1744
+    public function get_transaction_id( $context = 'view' ) {
1745
+        return $this->get_prop( 'transaction_id', $context );
1746 1746
     }
1747 1747
 
1748 1748
     /**
1749
-	 * Get the invoice's currency.
1750
-	 *
1751
-	 * @since 1.0.19
1752
-	 * @param  string $context View or edit context.
1753
-	 * @return string
1754
-	 */
1755
-	public function get_currency( $context = 'view' ) {
1749
+     * Get the invoice's currency.
1750
+     *
1751
+     * @since 1.0.19
1752
+     * @param  string $context View or edit context.
1753
+     * @return string
1754
+     */
1755
+    public function get_currency( $context = 'view' ) {
1756 1756
         $currency = $this->get_prop( 'currency', $context );
1757 1757
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1758 1758
     }
1759 1759
 
1760 1760
     /**
1761
-	 * Checks if we are charging taxes for this invoice.
1762
-	 *
1763
-	 * @since 1.0.19
1764
-	 * @param  string $context View or edit context.
1765
-	 * @return bool
1766
-	 */
1767
-	public function get_disable_taxes( $context = 'view' ) {
1761
+     * Checks if we are charging taxes for this invoice.
1762
+     *
1763
+     * @since 1.0.19
1764
+     * @param  string $context View or edit context.
1765
+     * @return bool
1766
+     */
1767
+    public function get_disable_taxes( $context = 'view' ) {
1768 1768
         return (bool) $this->get_prop( 'disable_taxes', $context );
1769 1769
     }
1770 1770
 
1771 1771
     /**
1772
-	 * Retrieves the subscription id for an invoice.
1773
-	 *
1774
-	 * @since 1.0.19
1775
-	 * @param  string $context View or edit context.
1776
-	 * @return int
1777
-	 */
1772
+     * Retrieves the subscription id for an invoice.
1773
+     *
1774
+     * @since 1.0.19
1775
+     * @param  string $context View or edit context.
1776
+     * @return int
1777
+     */
1778 1778
     public function get_subscription_id( $context = 'view' ) {
1779
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1780
-	}
1781
-
1782
-	/**
1783
-	 * Retrieves the remote subscription id for an invoice.
1784
-	 *
1785
-	 * @since 1.0.19
1786
-	 * @param  string $context View or edit context.
1787
-	 * @return int
1788
-	 */
1779
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1780
+    }
1781
+
1782
+    /**
1783
+     * Retrieves the remote subscription id for an invoice.
1784
+     *
1785
+     * @since 1.0.19
1786
+     * @param  string $context View or edit context.
1787
+     * @return int
1788
+     */
1789 1789
     public function get_remote_subscription_id( $context = 'view' ) {
1790 1790
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1791 1791
 
@@ -1798,12 +1798,12 @@  discard block
 block discarded – undo
1798 1798
     }
1799 1799
 
1800 1800
     /**
1801
-	 * Retrieves the payment meta for an invoice.
1802
-	 *
1803
-	 * @since 1.0.19
1804
-	 * @param  string $context View or edit context.
1805
-	 * @return array
1806
-	 */
1801
+     * Retrieves the payment meta for an invoice.
1802
+     *
1803
+     * @since 1.0.19
1804
+     * @param  string $context View or edit context.
1805
+     * @return array
1806
+     */
1807 1807
     public function get_payment_meta( $context = 'view' ) {
1808 1808
 
1809 1809
         return array(
@@ -1823,31 +1823,31 @@  discard block
 block discarded – undo
1823 1823
     }
1824 1824
 
1825 1825
     /**
1826
-	 * Retrieves the cart details for an invoice.
1827
-	 *
1828
-	 * @since 1.0.19
1829
-	 * @return array
1830
-	 */
1826
+     * Retrieves the cart details for an invoice.
1827
+     *
1828
+     * @since 1.0.19
1829
+     * @return array
1830
+     */
1831 1831
     public function get_cart_details() {
1832 1832
         $items        = $this->get_items();
1833 1833
         $cart_details = array();
1834 1834
 
1835 1835
         foreach ( $items as $item ) {
1836
-			$item->invoice_id = $this->get_id();
1836
+            $item->invoice_id = $this->get_id();
1837 1837
             $cart_details[]   = $item->prepare_data_for_saving();
1838 1838
         }
1839 1839
 
1840 1840
         return $cart_details;
1841
-	}
1841
+    }
1842 1842
 
1843
-	/**
1844
-	 * Retrieves the recurring item.
1845
-	 *
1846
-	 * @return null|GetPaid_Form_Item|int
1847
-	 */
1848
-	public function get_recurring( $object = false ) {
1843
+    /**
1844
+     * Retrieves the recurring item.
1845
+     *
1846
+     * @return null|GetPaid_Form_Item|int
1847
+     */
1848
+    public function get_recurring( $object = false ) {
1849 1849
 
1850
-		// Are we returning an object?
1850
+        // Are we returning an object?
1851 1851
         if ( $object ) {
1852 1852
             return $this->get_item( $this->recurring_item );
1853 1853
         }
@@ -1855,114 +1855,114 @@  discard block
 block discarded – undo
1855 1855
         return $this->recurring_item;
1856 1856
     }
1857 1857
 
1858
-	/**
1859
-	 * Retrieves the subscription name.
1860
-	 *
1861
-	 * @since 1.0.19
1862
-	 * @return string
1863
-	 */
1864
-	public function get_subscription_name() {
1858
+    /**
1859
+     * Retrieves the subscription name.
1860
+     *
1861
+     * @since 1.0.19
1862
+     * @return string
1863
+     */
1864
+    public function get_subscription_name() {
1865 1865
 
1866
-		// Retrieve the recurring name
1866
+        // Retrieve the recurring name
1867 1867
         $item = $this->get_recurring( true );
1868 1868
 
1869
-		// Abort if it does not exist.
1869
+        // Abort if it does not exist.
1870 1870
         if ( empty( $item ) ) {
1871 1871
             return '';
1872 1872
         }
1873 1873
 
1874
-		// Return the item name.
1874
+        // Return the item name.
1875 1875
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1876
-	}
1877
-
1878
-	/**
1879
-	 * Retrieves the view url.
1880
-	 *
1881
-	 * @since 1.0.19
1882
-	 * @return string
1883
-	 */
1884
-	public function get_view_url() {
1876
+    }
1877
+
1878
+    /**
1879
+     * Retrieves the view url.
1880
+     *
1881
+     * @since 1.0.19
1882
+     * @return string
1883
+     */
1884
+    public function get_view_url() {
1885 1885
         $invoice_url = get_permalink( $this->get_id() );
1886
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1886
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1887 1887
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1888
-	}
1888
+    }
1889 1889
 
1890
-	/**
1891
-	 * Retrieves the payment url.
1892
-	 *
1893
-	 * @since 1.0.19
1894
-	 * @return string
1895
-	 */
1896
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1890
+    /**
1891
+     * Retrieves the payment url.
1892
+     *
1893
+     * @since 1.0.19
1894
+     * @return string
1895
+     */
1896
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1897 1897
 
1898
-		// Retrieve the checkout url.
1898
+        // Retrieve the checkout url.
1899 1899
         $pay_url = wpinv_get_checkout_uri();
1900 1900
 
1901
-		// Maybe force ssl.
1901
+        // Maybe force ssl.
1902 1902
         if ( is_ssl() ) {
1903 1903
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1904 1904
         }
1905 1905
 
1906
-		// Add the invoice key.
1907
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1906
+        // Add the invoice key.
1907
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1908 1908
 
1909
-		// (Maybe?) add a secret
1909
+        // (Maybe?) add a secret
1910 1910
         if ( $secret ) {
1911 1911
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1912 1912
         }
1913 1913
 
1914 1914
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1915
-	}
1915
+    }
1916 1916
 	
1917
-	/**
1918
-	 * Retrieves the receipt url.
1919
-	 *
1920
-	 * @since 1.0.19
1921
-	 * @return string
1922
-	 */
1923
-	public function get_receipt_url() {
1924
-
1925
-		// Retrieve the checkout url.
1917
+    /**
1918
+     * Retrieves the receipt url.
1919
+     *
1920
+     * @since 1.0.19
1921
+     * @return string
1922
+     */
1923
+    public function get_receipt_url() {
1924
+
1925
+        // Retrieve the checkout url.
1926 1926
         $receipt_url = wpinv_get_success_page_uri();
1927 1927
 
1928
-		// Maybe force ssl.
1928
+        // Maybe force ssl.
1929 1929
         if ( is_ssl() ) {
1930 1930
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1931 1931
         }
1932 1932
 
1933
-		// Add the invoice key.
1934
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1933
+        // Add the invoice key.
1934
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1935 1935
 
1936 1936
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1937
-	}
1937
+    }
1938 1938
 	
1939
-	/**
1940
-	 * Retrieves the default status.
1941
-	 *
1942
-	 * @since 1.0.19
1943
-	 * @return string
1944
-	 */
1945
-	public function get_default_status() {
1946
-
1947
-		$type   = $this->get_type();
1948
-		$status = "wpi-$type-pending";
1949
-		return str_replace( '-invoice', '', $status );
1950
-
1951
-	}
1952
-
1953
-    /**
1954
-	 * Magic method for accessing invoice properties.
1955
-	 *
1956
-	 * @since 1.0.15
1957
-	 * @access public
1958
-	 *
1959
-	 * @param string $key Discount data to retrieve
1960
-	 * @param  string $context View or edit context.
1961
-	 * @return mixed Value of the given invoice property (if set).
1962
-	 */
1963
-	public function get( $key, $context = 'view' ) {
1939
+    /**
1940
+     * Retrieves the default status.
1941
+     *
1942
+     * @since 1.0.19
1943
+     * @return string
1944
+     */
1945
+    public function get_default_status() {
1946
+
1947
+        $type   = $this->get_type();
1948
+        $status = "wpi-$type-pending";
1949
+        return str_replace( '-invoice', '', $status );
1950
+
1951
+    }
1952
+
1953
+    /**
1954
+     * Magic method for accessing invoice properties.
1955
+     *
1956
+     * @since 1.0.15
1957
+     * @access public
1958
+     *
1959
+     * @param string $key Discount data to retrieve
1960
+     * @param  string $context View or edit context.
1961
+     * @return mixed Value of the given invoice property (if set).
1962
+     */
1963
+    public function get( $key, $context = 'view' ) {
1964 1964
         return $this->get_prop( $key, $context );
1965
-	}
1965
+    }
1966 1966
 
1967 1967
     /*
1968 1968
 	|--------------------------------------------------------------------------
@@ -1975,130 +1975,130 @@  discard block
 block discarded – undo
1975 1975
     */
1976 1976
 
1977 1977
     /**
1978
-	 * Magic method for setting invoice properties.
1979
-	 *
1980
-	 * @since 1.0.19
1981
-	 * @access public
1982
-	 *
1983
-	 * @param string $key Discount data to retrieve
1984
-	 * @param  mixed $value new value.
1985
-	 * @return mixed Value of the given invoice property (if set).
1986
-	 */
1987
-	public function set( $key, $value ) {
1978
+     * Magic method for setting invoice properties.
1979
+     *
1980
+     * @since 1.0.19
1981
+     * @access public
1982
+     *
1983
+     * @param string $key Discount data to retrieve
1984
+     * @param  mixed $value new value.
1985
+     * @return mixed Value of the given invoice property (if set).
1986
+     */
1987
+    public function set( $key, $value ) {
1988 1988
 
1989 1989
         $setter = "set_$key";
1990 1990
         if ( is_callable( array( $this, $setter ) ) ) {
1991 1991
             $this->{$setter}( $value );
1992 1992
         }
1993 1993
 
1994
-	}
1994
+    }
1995 1995
 
1996
-	/**
1997
-	 * Sets item status.
1998
-	 *
1999
-	 * @since 1.0.19
2000
-	 * @param string $new_status    New status.
2001
-	 * @param string $note          Optional note to add.
2002
-	 * @param bool   $manual_update Is this a manual status change?.
2003
-	 * @return array details of change.
2004
-	 */
2005
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
2006
-		$old_status = $this->get_status();
1996
+    /**
1997
+     * Sets item status.
1998
+     *
1999
+     * @since 1.0.19
2000
+     * @param string $new_status    New status.
2001
+     * @param string $note          Optional note to add.
2002
+     * @param bool   $manual_update Is this a manual status change?.
2003
+     * @return array details of change.
2004
+     */
2005
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
2006
+        $old_status = $this->get_status();
2007 2007
 
2008
-		$statuses = $this->get_all_statuses();
2008
+        $statuses = $this->get_all_statuses();
2009 2009
 
2010
-		if ( isset( $statuses[ 'draft' ] ) ) {
2011
-			unset( $statuses[ 'draft' ] );
2012
-		}
2010
+        if ( isset( $statuses[ 'draft' ] ) ) {
2011
+            unset( $statuses[ 'draft' ] );
2012
+        }
2013 2013
 
2014
-		$this->set_prop( 'status', $new_status );
2014
+        $this->set_prop( 'status', $new_status );
2015 2015
 
2016
-		// If setting the status, ensure it's set to a valid status.
2017
-		if ( true === $this->object_read ) {
2016
+        // If setting the status, ensure it's set to a valid status.
2017
+        if ( true === $this->object_read ) {
2018 2018
 
2019
-			// Only allow valid new status.
2020
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
2021
-				$new_status = $this->get_default_status();
2022
-			}
2019
+            // Only allow valid new status.
2020
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
2021
+                $new_status = $this->get_default_status();
2022
+            }
2023 2023
 
2024
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2025
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2026
-				$old_status = $this->get_default_status();
2027
-			}
2024
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2025
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2026
+                $old_status = $this->get_default_status();
2027
+            }
2028 2028
 
2029
-			// Paid - Renewal (i.e when duplicating a parent invoice )
2030
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2031
-				$old_status = 'wpi-pending';
2032
-			}
2029
+            // Paid - Renewal (i.e when duplicating a parent invoice )
2030
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2031
+                $old_status = 'wpi-pending';
2032
+            }
2033 2033
 
2034
-			if ( $old_status !== $new_status ) {
2035
-				$this->status_transition = array(
2036
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2037
-					'to'     => $new_status,
2038
-					'note'   => $note,
2039
-					'manual' => (bool) $manual_update,
2040
-				);
2034
+            if ( $old_status !== $new_status ) {
2035
+                $this->status_transition = array(
2036
+                    'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2037
+                    'to'     => $new_status,
2038
+                    'note'   => $note,
2039
+                    'manual' => (bool) $manual_update,
2040
+                );
2041 2041
 
2042
-				if ( $manual_update ) {
2043
-					do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
2044
-				}
2042
+                if ( $manual_update ) {
2043
+                    do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
2044
+                }
2045 2045
 
2046
-				$this->maybe_set_date_paid();
2046
+                $this->maybe_set_date_paid();
2047 2047
 
2048
-			}
2048
+            }
2049 2049
 
2050
-		}
2050
+        }
2051 2051
 
2052
-		return array(
2053
-			'from' => $old_status,
2054
-			'to'   => $new_status,
2055
-		);
2056
-	}
2052
+        return array(
2053
+            'from' => $old_status,
2054
+            'to'   => $new_status,
2055
+        );
2056
+    }
2057 2057
 
2058
-	/**
2059
-	 * Maybe set date paid.
2060
-	 *
2061
-	 * Sets the date paid variable when transitioning to the payment complete
2062
-	 * order status.
2063
-	 *
2064
-	 * @since 1.0.19
2065
-	 */
2066
-	public function maybe_set_date_paid() {
2058
+    /**
2059
+     * Maybe set date paid.
2060
+     *
2061
+     * Sets the date paid variable when transitioning to the payment complete
2062
+     * order status.
2063
+     *
2064
+     * @since 1.0.19
2065
+     */
2066
+    public function maybe_set_date_paid() {
2067 2067
 
2068
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2069
-			$this->set_date_completed( current_time( 'mysql' ) );
2070
-		}
2071
-	}
2068
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2069
+            $this->set_date_completed( current_time( 'mysql' ) );
2070
+        }
2071
+    }
2072 2072
 
2073 2073
     /**
2074
-	 * Set parent invoice ID.
2075
-	 *
2076
-	 * @since 1.0.19
2077
-	 */
2078
-	public function set_parent_id( $value ) {
2079
-		if ( $value && ( $value === $this->get_id() ) ) {
2080
-			return;
2081
-		}
2082
-		$this->set_prop( 'parent_id', absint( $value ) );
2074
+     * Set parent invoice ID.
2075
+     *
2076
+     * @since 1.0.19
2077
+     */
2078
+    public function set_parent_id( $value ) {
2079
+        if ( $value && ( $value === $this->get_id() ) ) {
2080
+            return;
2081
+        }
2082
+        $this->set_prop( 'parent_id', absint( $value ) );
2083 2083
     }
2084 2084
 
2085 2085
     /**
2086
-	 * Set plugin version when the invoice was created.
2087
-	 *
2088
-	 * @since 1.0.19
2089
-	 */
2090
-	public function set_version( $value ) {
2091
-		$this->set_prop( 'version', $value );
2086
+     * Set plugin version when the invoice was created.
2087
+     *
2088
+     * @since 1.0.19
2089
+     */
2090
+    public function set_version( $value ) {
2091
+        $this->set_prop( 'version', $value );
2092 2092
     }
2093
-
2094
-    /**
2095
-	 * Set date when the invoice was created.
2096
-	 *
2097
-	 * @since 1.0.19
2098
-	 * @param string $value Value to set.
2093
+
2094
+    /**
2095
+     * Set date when the invoice was created.
2096
+     *
2097
+     * @since 1.0.19
2098
+     * @param string $value Value to set.
2099 2099
      * @return bool Whether or not the date was set.
2100
-	 */
2101
-	public function set_date_created( $value ) {
2100
+     */
2101
+    public function set_date_created( $value ) {
2102 2102
         $date = strtotime( $value );
2103 2103
 
2104 2104
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2106,19 +2106,19 @@  discard block
 block discarded – undo
2106 2106
             return true;
2107 2107
         }
2108 2108
 
2109
-		$this->set_prop( 'date_created', '' );
2110
-		return false;
2109
+        $this->set_prop( 'date_created', '' );
2110
+        return false;
2111 2111
 
2112 2112
     }
2113 2113
 
2114 2114
     /**
2115
-	 * Set date invoice due date.
2116
-	 *
2117
-	 * @since 1.0.19
2118
-	 * @param string $value Value to set.
2115
+     * Set date invoice due date.
2116
+     *
2117
+     * @since 1.0.19
2118
+     * @param string $value Value to set.
2119 2119
      * @return bool Whether or not the date was set.
2120
-	 */
2121
-	public function set_due_date( $value ) {
2120
+     */
2121
+    public function set_due_date( $value ) {
2122 2122
         $date = strtotime( $value );
2123 2123
 
2124 2124
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2126,29 +2126,29 @@  discard block
 block discarded – undo
2126 2126
             return true;
2127 2127
         }
2128 2128
 
2129
-		$this->set_prop( 'due_date', '' );
2129
+        $this->set_prop( 'due_date', '' );
2130 2130
         return false;
2131 2131
 
2132 2132
     }
2133 2133
 
2134 2134
     /**
2135
-	 * Alias of self::set_due_date().
2136
-	 *
2137
-	 * @since 1.0.19
2138
-	 * @param  string $value New name.
2139
-	 */
2140
-	public function set_date_due( $value ) {
2141
-		$this->set_due_date( $value );
2135
+     * Alias of self::set_due_date().
2136
+     *
2137
+     * @since 1.0.19
2138
+     * @param  string $value New name.
2139
+     */
2140
+    public function set_date_due( $value ) {
2141
+        $this->set_due_date( $value );
2142 2142
     }
2143 2143
 
2144 2144
     /**
2145
-	 * Set date invoice was completed.
2146
-	 *
2147
-	 * @since 1.0.19
2148
-	 * @param string $value Value to set.
2145
+     * Set date invoice was completed.
2146
+     *
2147
+     * @since 1.0.19
2148
+     * @param string $value Value to set.
2149 2149
      * @return bool Whether or not the date was set.
2150
-	 */
2151
-	public function set_completed_date( $value ) {
2150
+     */
2151
+    public function set_completed_date( $value ) {
2152 2152
         $date = strtotime( $value );
2153 2153
 
2154 2154
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -2156,29 +2156,29 @@  discard block
 block discarded – undo
2156 2156
             return true;
2157 2157
         }
2158 2158
 
2159
-		$this->set_prop( 'completed_date', '' );
2159
+        $this->set_prop( 'completed_date', '' );
2160 2160
         return false;
2161 2161
 
2162 2162
     }
2163 2163
 
2164 2164
     /**
2165
-	 * Alias of self::set_completed_date().
2166
-	 *
2167
-	 * @since 1.0.19
2168
-	 * @param  string $value New name.
2169
-	 */
2170
-	public function set_date_completed( $value ) {
2171
-		$this->set_completed_date( $value );
2165
+     * Alias of self::set_completed_date().
2166
+     *
2167
+     * @since 1.0.19
2168
+     * @param  string $value New name.
2169
+     */
2170
+    public function set_date_completed( $value ) {
2171
+        $this->set_completed_date( $value );
2172 2172
     }
2173 2173
 
2174 2174
     /**
2175
-	 * Set date when the invoice was last modified.
2176
-	 *
2177
-	 * @since 1.0.19
2178
-	 * @param string $value Value to set.
2175
+     * Set date when the invoice was last modified.
2176
+     *
2177
+     * @since 1.0.19
2178
+     * @param string $value Value to set.
2179 2179
      * @return bool Whether or not the date was set.
2180
-	 */
2181
-	public function set_date_modified( $value ) {
2180
+     */
2181
+    public function set_date_modified( $value ) {
2182 2182
         $date = strtotime( $value );
2183 2183
 
2184 2184
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2186,813 +2186,813 @@  discard block
 block discarded – undo
2186 2186
             return true;
2187 2187
         }
2188 2188
 
2189
-		$this->set_prop( 'date_modified', '' );
2189
+        $this->set_prop( 'date_modified', '' );
2190 2190
         return false;
2191 2191
 
2192 2192
     }
2193 2193
 
2194 2194
     /**
2195
-	 * Set the invoice number.
2196
-	 *
2197
-	 * @since 1.0.19
2198
-	 * @param  string $value New number.
2199
-	 */
2200
-	public function set_number( $value ) {
2195
+     * Set the invoice number.
2196
+     *
2197
+     * @since 1.0.19
2198
+     * @param  string $value New number.
2199
+     */
2200
+    public function set_number( $value ) {
2201 2201
         $number = sanitize_text_field( $value );
2202
-		$this->set_prop( 'number', $number );
2202
+        $this->set_prop( 'number', $number );
2203 2203
     }
2204 2204
 
2205 2205
     /**
2206
-	 * Set the invoice type.
2207
-	 *
2208
-	 * @since 1.0.19
2209
-	 * @param  string $value Type.
2210
-	 */
2211
-	public function set_type( $value ) {
2206
+     * Set the invoice type.
2207
+     *
2208
+     * @since 1.0.19
2209
+     * @param  string $value Type.
2210
+     */
2211
+    public function set_type( $value ) {
2212 2212
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2213
-		$this->set_prop( 'type', $type );
2214
-	}
2213
+        $this->set_prop( 'type', $type );
2214
+    }
2215 2215
 
2216 2216
     /**
2217
-	 * Set the invoice post type.
2218
-	 *
2219
-	 * @since 1.0.19
2220
-	 * @param  string $value Post type.
2221
-	 */
2222
-	public function set_post_type( $value ) {
2217
+     * Set the invoice post type.
2218
+     *
2219
+     * @since 1.0.19
2220
+     * @param  string $value Post type.
2221
+     */
2222
+    public function set_post_type( $value ) {
2223 2223
         if ( getpaid_is_invoice_post_type( $value ) ) {
2224
-			$this->set_type( $value );
2224
+            $this->set_type( $value );
2225 2225
             $this->set_prop( 'post_type', $value );
2226 2226
         }
2227 2227
     }
2228 2228
 
2229 2229
     /**
2230
-	 * Set the invoice key.
2231
-	 *
2232
-	 * @since 1.0.19
2233
-	 * @param  string $value New key.
2234
-	 */
2235
-	public function set_key( $value ) {
2230
+     * Set the invoice key.
2231
+     *
2232
+     * @since 1.0.19
2233
+     * @param  string $value New key.
2234
+     */
2235
+    public function set_key( $value ) {
2236 2236
         $key = sanitize_text_field( $value );
2237
-		$this->set_prop( 'key', $key );
2237
+        $this->set_prop( 'key', $key );
2238 2238
     }
2239 2239
 
2240 2240
     /**
2241
-	 * Set the invoice mode.
2242
-	 *
2243
-	 * @since 1.0.19
2244
-	 * @param  string $value mode.
2245
-	 */
2246
-	public function set_mode( $value ) {
2241
+     * Set the invoice mode.
2242
+     *
2243
+     * @since 1.0.19
2244
+     * @param  string $value mode.
2245
+     */
2246
+    public function set_mode( $value ) {
2247 2247
         if ( in_array( $value, array( 'live', 'test' ) ) ) {
2248 2248
             $this->set_prop( 'mode', $value );
2249 2249
         }
2250 2250
     }
2251 2251
 
2252 2252
     /**
2253
-	 * Set the invoice path.
2254
-	 *
2255
-	 * @since 1.0.19
2256
-	 * @param  string $value path.
2257
-	 */
2258
-	public function set_path( $value ) {
2253
+     * Set the invoice path.
2254
+     *
2255
+     * @since 1.0.19
2256
+     * @param  string $value path.
2257
+     */
2258
+    public function set_path( $value ) {
2259 2259
         $this->set_prop( 'path', $value );
2260 2260
     }
2261 2261
 
2262 2262
     /**
2263
-	 * Set the invoice name.
2264
-	 *
2265
-	 * @since 1.0.19
2266
-	 * @param  string $value New name.
2267
-	 */
2268
-	public function set_name( $value ) {
2263
+     * Set the invoice name.
2264
+     *
2265
+     * @since 1.0.19
2266
+     * @param  string $value New name.
2267
+     */
2268
+    public function set_name( $value ) {
2269 2269
         $name = sanitize_text_field( $value );
2270
-		$this->set_prop( 'name', $name );
2270
+        $this->set_prop( 'name', $name );
2271 2271
     }
2272 2272
 
2273 2273
     /**
2274
-	 * Alias of self::set_name().
2275
-	 *
2276
-	 * @since 1.0.19
2277
-	 * @param  string $value New name.
2278
-	 */
2279
-	public function set_title( $value ) {
2280
-		$this->set_name( $value );
2274
+     * Alias of self::set_name().
2275
+     *
2276
+     * @since 1.0.19
2277
+     * @param  string $value New name.
2278
+     */
2279
+    public function set_title( $value ) {
2280
+        $this->set_name( $value );
2281 2281
     }
2282 2282
 
2283 2283
     /**
2284
-	 * Set the invoice description.
2285
-	 *
2286
-	 * @since 1.0.19
2287
-	 * @param  string $value New description.
2288
-	 */
2289
-	public function set_description( $value ) {
2284
+     * Set the invoice description.
2285
+     *
2286
+     * @since 1.0.19
2287
+     * @param  string $value New description.
2288
+     */
2289
+    public function set_description( $value ) {
2290 2290
         $description = wp_kses_post( $value );
2291
-		$this->set_prop( 'description', $description );
2291
+        $this->set_prop( 'description', $description );
2292
+    }
2293
+
2294
+    /**
2295
+     * Alias of self::set_description().
2296
+     *
2297
+     * @since 1.0.19
2298
+     * @param  string $value New description.
2299
+     */
2300
+    public function set_excerpt( $value ) {
2301
+        $this->set_description( $value );
2302
+    }
2303
+
2304
+    /**
2305
+     * Alias of self::set_description().
2306
+     *
2307
+     * @since 1.0.19
2308
+     * @param  string $value New description.
2309
+     */
2310
+    public function set_summary( $value ) {
2311
+        $this->set_description( $value );
2312
+    }
2313
+
2314
+    /**
2315
+     * Set the receiver of the invoice.
2316
+     *
2317
+     * @since 1.0.19
2318
+     * @param  int $value New author.
2319
+     */
2320
+    public function set_author( $value ) {
2321
+        $user = get_user_by( 'id', (int) $value );
2322
+
2323
+        if ( $user && $user->ID ) {
2324
+            $this->set_prop( 'author', $user->ID );
2325
+            $this->set_prop( 'email', $user->user_email );
2326
+        }
2327
+
2328
+    }
2329
+
2330
+    /**
2331
+     * Alias of self::set_author().
2332
+     *
2333
+     * @since 1.0.19
2334
+     * @param  int $value New user id.
2335
+     */
2336
+    public function set_user_id( $value ) {
2337
+        $this->set_author( $value );
2338
+    }
2339
+
2340
+    /**
2341
+     * Alias of self::set_author().
2342
+     *
2343
+     * @since 1.0.19
2344
+     * @param  int $value New user id.
2345
+     */
2346
+    public function set_customer_id( $value ) {
2347
+        $this->set_author( $value );
2348
+    }
2349
+
2350
+    /**
2351
+     * Set the customer's ip.
2352
+     *
2353
+     * @since 1.0.19
2354
+     * @param  string $value ip address.
2355
+     */
2356
+    public function set_ip( $value ) {
2357
+        $this->set_prop( 'ip', $value );
2358
+    }
2359
+
2360
+    /**
2361
+     * Alias of self::set_ip().
2362
+     *
2363
+     * @since 1.0.19
2364
+     * @param  string $value ip address.
2365
+     */
2366
+    public function set_user_ip( $value ) {
2367
+        $this->set_ip( $value );
2368
+    }
2369
+
2370
+    /**
2371
+     * Set the customer's first name.
2372
+     *
2373
+     * @since 1.0.19
2374
+     * @param  string $value first name.
2375
+     */
2376
+    public function set_first_name( $value ) {
2377
+        $this->set_prop( 'first_name', $value );
2378
+    }
2379
+
2380
+    /**
2381
+     * Alias of self::set_first_name().
2382
+     *
2383
+     * @since 1.0.19
2384
+     * @param  string $value first name.
2385
+     */
2386
+    public function set_user_first_name( $value ) {
2387
+        $this->set_first_name( $value );
2388
+    }
2389
+
2390
+    /**
2391
+     * Alias of self::set_first_name().
2392
+     *
2393
+     * @since 1.0.19
2394
+     * @param  string $value first name.
2395
+     */
2396
+    public function set_customer_first_name( $value ) {
2397
+        $this->set_first_name( $value );
2398
+    }
2399
+
2400
+    /**
2401
+     * Set the customer's last name.
2402
+     *
2403
+     * @since 1.0.19
2404
+     * @param  string $value last name.
2405
+     */
2406
+    public function set_last_name( $value ) {
2407
+        $this->set_prop( 'last_name', $value );
2408
+    }
2409
+
2410
+    /**
2411
+     * Alias of self::set_last_name().
2412
+     *
2413
+     * @since 1.0.19
2414
+     * @param  string $value last name.
2415
+     */
2416
+    public function set_user_last_name( $value ) {
2417
+        $this->set_last_name( $value );
2418
+    }
2419
+
2420
+    /**
2421
+     * Alias of self::set_last_name().
2422
+     *
2423
+     * @since 1.0.19
2424
+     * @param  string $value last name.
2425
+     */
2426
+    public function set_customer_last_name( $value ) {
2427
+        $this->set_last_name( $value );
2428
+    }
2429
+
2430
+    /**
2431
+     * Set the customer's phone number.
2432
+     *
2433
+     * @since 1.0.19
2434
+     * @param  string $value phone.
2435
+     */
2436
+    public function set_phone( $value ) {
2437
+        $this->set_prop( 'phone', $value );
2292 2438
     }
2293 2439
 
2294 2440
     /**
2295
-	 * Alias of self::set_description().
2296
-	 *
2297
-	 * @since 1.0.19
2298
-	 * @param  string $value New description.
2299
-	 */
2300
-	public function set_excerpt( $value ) {
2301
-		$this->set_description( $value );
2441
+     * Alias of self::set_phone().
2442
+     *
2443
+     * @since 1.0.19
2444
+     * @param  string $value phone.
2445
+     */
2446
+    public function set_user_phone( $value ) {
2447
+        $this->set_phone( $value );
2302 2448
     }
2303 2449
 
2304 2450
     /**
2305
-	 * Alias of self::set_description().
2306
-	 *
2307
-	 * @since 1.0.19
2308
-	 * @param  string $value New description.
2309
-	 */
2310
-	public function set_summary( $value ) {
2311
-		$this->set_description( $value );
2451
+     * Alias of self::set_phone().
2452
+     *
2453
+     * @since 1.0.19
2454
+     * @param  string $value phone.
2455
+     */
2456
+    public function set_customer_phone( $value ) {
2457
+        $this->set_phone( $value );
2312 2458
     }
2313 2459
 
2314 2460
     /**
2315
-	 * Set the receiver of the invoice.
2316
-	 *
2317
-	 * @since 1.0.19
2318
-	 * @param  int $value New author.
2319
-	 */
2320
-	public function set_author( $value ) {
2321
-		$user = get_user_by( 'id', (int) $value );
2461
+     * Alias of self::set_phone().
2462
+     *
2463
+     * @since 1.0.19
2464
+     * @param  string $value phone.
2465
+     */
2466
+    public function set_phone_number( $value ) {
2467
+        $this->set_phone( $value );
2468
+    }
2322 2469
 
2323
-		if ( $user && $user->ID ) {
2324
-			$this->set_prop( 'author', $user->ID );
2325
-			$this->set_prop( 'email', $user->user_email );
2326
-		}
2470
+    /**
2471
+     * Set the customer's email address.
2472
+     *
2473
+     * @since 1.0.19
2474
+     * @param  string $value email address.
2475
+     */
2476
+    public function set_email( $value ) {
2477
+        $this->set_prop( 'email', $value );
2478
+    }
2327 2479
 
2480
+    /**
2481
+     * Alias of self::set_email().
2482
+     *
2483
+     * @since 1.0.19
2484
+     * @param  string $value email address.
2485
+     */
2486
+    public function set_user_email( $value ) {
2487
+        $this->set_email( $value );
2328 2488
     }
2329 2489
 
2330 2490
     /**
2331
-	 * Alias of self::set_author().
2332
-	 *
2333
-	 * @since 1.0.19
2334
-	 * @param  int $value New user id.
2335
-	 */
2336
-	public function set_user_id( $value ) {
2337
-		$this->set_author( $value );
2491
+     * Alias of self::set_email().
2492
+     *
2493
+     * @since 1.0.19
2494
+     * @param  string $value email address.
2495
+     */
2496
+    public function set_email_address( $value ) {
2497
+        $this->set_email( $value );
2338 2498
     }
2339 2499
 
2340 2500
     /**
2341
-	 * Alias of self::set_author().
2342
-	 *
2343
-	 * @since 1.0.19
2344
-	 * @param  int $value New user id.
2345
-	 */
2346
-	public function set_customer_id( $value ) {
2347
-		$this->set_author( $value );
2501
+     * Alias of self::set_email().
2502
+     *
2503
+     * @since 1.0.19
2504
+     * @param  string $value email address.
2505
+     */
2506
+    public function set_customer_email( $value ) {
2507
+        $this->set_email( $value );
2348 2508
     }
2349 2509
 
2350 2510
     /**
2351
-	 * Set the customer's ip.
2352
-	 *
2353
-	 * @since 1.0.19
2354
-	 * @param  string $value ip address.
2355
-	 */
2356
-	public function set_ip( $value ) {
2357
-		$this->set_prop( 'ip', $value );
2511
+     * Set the customer's country.
2512
+     *
2513
+     * @since 1.0.19
2514
+     * @param  string $value country.
2515
+     */
2516
+    public function set_country( $value ) {
2517
+        $this->set_prop( 'country', $value );
2358 2518
     }
2359 2519
 
2360 2520
     /**
2361
-	 * Alias of self::set_ip().
2362
-	 *
2363
-	 * @since 1.0.19
2364
-	 * @param  string $value ip address.
2365
-	 */
2366
-	public function set_user_ip( $value ) {
2367
-		$this->set_ip( $value );
2521
+     * Alias of self::set_country().
2522
+     *
2523
+     * @since 1.0.19
2524
+     * @param  string $value country.
2525
+     */
2526
+    public function set_user_country( $value ) {
2527
+        $this->set_country( $value );
2368 2528
     }
2369 2529
 
2370 2530
     /**
2371
-	 * Set the customer's first name.
2372
-	 *
2373
-	 * @since 1.0.19
2374
-	 * @param  string $value first name.
2375
-	 */
2376
-	public function set_first_name( $value ) {
2377
-		$this->set_prop( 'first_name', $value );
2531
+     * Alias of self::set_country().
2532
+     *
2533
+     * @since 1.0.19
2534
+     * @param  string $value country.
2535
+     */
2536
+    public function set_customer_country( $value ) {
2537
+        $this->set_country( $value );
2378 2538
     }
2379 2539
 
2380 2540
     /**
2381
-	 * Alias of self::set_first_name().
2382
-	 *
2383
-	 * @since 1.0.19
2384
-	 * @param  string $value first name.
2385
-	 */
2386
-	public function set_user_first_name( $value ) {
2387
-		$this->set_first_name( $value );
2541
+     * Set the customer's state.
2542
+     *
2543
+     * @since 1.0.19
2544
+     * @param  string $value state.
2545
+     */
2546
+    public function set_state( $value ) {
2547
+        $this->set_prop( 'state', $value );
2388 2548
     }
2389 2549
 
2390 2550
     /**
2391
-	 * Alias of self::set_first_name().
2392
-	 *
2393
-	 * @since 1.0.19
2394
-	 * @param  string $value first name.
2395
-	 */
2396
-	public function set_customer_first_name( $value ) {
2397
-		$this->set_first_name( $value );
2551
+     * Alias of self::set_state().
2552
+     *
2553
+     * @since 1.0.19
2554
+     * @param  string $value state.
2555
+     */
2556
+    public function set_user_state( $value ) {
2557
+        $this->set_state( $value );
2398 2558
     }
2399 2559
 
2400 2560
     /**
2401
-	 * Set the customer's last name.
2402
-	 *
2403
-	 * @since 1.0.19
2404
-	 * @param  string $value last name.
2405
-	 */
2406
-	public function set_last_name( $value ) {
2407
-		$this->set_prop( 'last_name', $value );
2561
+     * Alias of self::set_state().
2562
+     *
2563
+     * @since 1.0.19
2564
+     * @param  string $value state.
2565
+     */
2566
+    public function set_customer_state( $value ) {
2567
+        $this->set_state( $value );
2408 2568
     }
2409 2569
 
2410 2570
     /**
2411
-	 * Alias of self::set_last_name().
2412
-	 *
2413
-	 * @since 1.0.19
2414
-	 * @param  string $value last name.
2415
-	 */
2416
-	public function set_user_last_name( $value ) {
2417
-		$this->set_last_name( $value );
2571
+     * Set the customer's city.
2572
+     *
2573
+     * @since 1.0.19
2574
+     * @param  string $value city.
2575
+     */
2576
+    public function set_city( $value ) {
2577
+        $this->set_prop( 'city', $value );
2418 2578
     }
2419 2579
 
2420 2580
     /**
2421
-	 * Alias of self::set_last_name().
2422
-	 *
2423
-	 * @since 1.0.19
2424
-	 * @param  string $value last name.
2425
-	 */
2426
-	public function set_customer_last_name( $value ) {
2427
-		$this->set_last_name( $value );
2581
+     * Alias of self::set_city().
2582
+     *
2583
+     * @since 1.0.19
2584
+     * @param  string $value city.
2585
+     */
2586
+    public function set_user_city( $value ) {
2587
+        $this->set_city( $value );
2428 2588
     }
2429 2589
 
2430 2590
     /**
2431
-	 * Set the customer's phone number.
2432
-	 *
2433
-	 * @since 1.0.19
2434
-	 * @param  string $value phone.
2435
-	 */
2436
-	public function set_phone( $value ) {
2437
-		$this->set_prop( 'phone', $value );
2591
+     * Alias of self::set_city().
2592
+     *
2593
+     * @since 1.0.19
2594
+     * @param  string $value city.
2595
+     */
2596
+    public function set_customer_city( $value ) {
2597
+        $this->set_city( $value );
2438 2598
     }
2439 2599
 
2440 2600
     /**
2441
-	 * Alias of self::set_phone().
2442
-	 *
2443
-	 * @since 1.0.19
2444
-	 * @param  string $value phone.
2445
-	 */
2446
-	public function set_user_phone( $value ) {
2447
-		$this->set_phone( $value );
2601
+     * Set the customer's zip code.
2602
+     *
2603
+     * @since 1.0.19
2604
+     * @param  string $value zip.
2605
+     */
2606
+    public function set_zip( $value ) {
2607
+        $this->set_prop( 'zip', $value );
2448 2608
     }
2449 2609
 
2450 2610
     /**
2451
-	 * Alias of self::set_phone().
2452
-	 *
2453
-	 * @since 1.0.19
2454
-	 * @param  string $value phone.
2455
-	 */
2456
-	public function set_customer_phone( $value ) {
2457
-		$this->set_phone( $value );
2611
+     * Alias of self::set_zip().
2612
+     *
2613
+     * @since 1.0.19
2614
+     * @param  string $value zip.
2615
+     */
2616
+    public function set_user_zip( $value ) {
2617
+        $this->set_zip( $value );
2458 2618
     }
2459 2619
 
2460 2620
     /**
2461
-	 * Alias of self::set_phone().
2462
-	 *
2463
-	 * @since 1.0.19
2464
-	 * @param  string $value phone.
2465
-	 */
2466
-	public function set_phone_number( $value ) {
2467
-		$this->set_phone( $value );
2621
+     * Alias of self::set_zip().
2622
+     *
2623
+     * @since 1.0.19
2624
+     * @param  string $value zip.
2625
+     */
2626
+    public function set_customer_zip( $value ) {
2627
+        $this->set_zip( $value );
2468 2628
     }
2469 2629
 
2470 2630
     /**
2471
-	 * Set the customer's email address.
2472
-	 *
2473
-	 * @since 1.0.19
2474
-	 * @param  string $value email address.
2475
-	 */
2476
-	public function set_email( $value ) {
2477
-		$this->set_prop( 'email', $value );
2631
+     * Set the customer's company.
2632
+     *
2633
+     * @since 1.0.19
2634
+     * @param  string $value company.
2635
+     */
2636
+    public function set_company( $value ) {
2637
+        $this->set_prop( 'company', $value );
2478 2638
     }
2479 2639
 
2480 2640
     /**
2481
-	 * Alias of self::set_email().
2482
-	 *
2483
-	 * @since 1.0.19
2484
-	 * @param  string $value email address.
2485
-	 */
2486
-	public function set_user_email( $value ) {
2487
-		$this->set_email( $value );
2641
+     * Alias of self::set_company().
2642
+     *
2643
+     * @since 1.0.19
2644
+     * @param  string $value company.
2645
+     */
2646
+    public function set_user_company( $value ) {
2647
+        $this->set_company( $value );
2488 2648
     }
2489 2649
 
2490 2650
     /**
2491
-	 * Alias of self::set_email().
2492
-	 *
2493
-	 * @since 1.0.19
2494
-	 * @param  string $value email address.
2495
-	 */
2496
-	public function set_email_address( $value ) {
2497
-		$this->set_email( $value );
2651
+     * Alias of self::set_company().
2652
+     *
2653
+     * @since 1.0.19
2654
+     * @param  string $value company.
2655
+     */
2656
+    public function set_customer_company( $value ) {
2657
+        $this->set_company( $value );
2498 2658
     }
2499 2659
 
2500 2660
     /**
2501
-	 * Alias of self::set_email().
2502
-	 *
2503
-	 * @since 1.0.19
2504
-	 * @param  string $value email address.
2505
-	 */
2506
-	public function set_customer_email( $value ) {
2507
-		$this->set_email( $value );
2661
+     * Set the customer's company id.
2662
+     *
2663
+     * @since 1.0.19
2664
+     * @param  string $value company id.
2665
+     */
2666
+    public function set_company_id( $value ) {
2667
+        $this->set_prop( 'company_id', $value );
2508 2668
     }
2509 2669
 
2510 2670
     /**
2511
-	 * Set the customer's country.
2512
-	 *
2513
-	 * @since 1.0.19
2514
-	 * @param  string $value country.
2515
-	 */
2516
-	public function set_country( $value ) {
2517
-		$this->set_prop( 'country', $value );
2671
+     * Set the customer's var number.
2672
+     *
2673
+     * @since 1.0.19
2674
+     * @param  string $value var number.
2675
+     */
2676
+    public function set_vat_number( $value ) {
2677
+        $this->set_prop( 'vat_number', $value );
2518 2678
     }
2519 2679
 
2520 2680
     /**
2521
-	 * Alias of self::set_country().
2522
-	 *
2523
-	 * @since 1.0.19
2524
-	 * @param  string $value country.
2525
-	 */
2526
-	public function set_user_country( $value ) {
2527
-		$this->set_country( $value );
2681
+     * Alias of self::set_vat_number().
2682
+     *
2683
+     * @since 1.0.19
2684
+     * @param  string $value var number.
2685
+     */
2686
+    public function set_user_vat_number( $value ) {
2687
+        $this->set_vat_number( $value );
2528 2688
     }
2529 2689
 
2530 2690
     /**
2531
-	 * Alias of self::set_country().
2532
-	 *
2533
-	 * @since 1.0.19
2534
-	 * @param  string $value country.
2535
-	 */
2536
-	public function set_customer_country( $value ) {
2537
-		$this->set_country( $value );
2691
+     * Alias of self::set_vat_number().
2692
+     *
2693
+     * @since 1.0.19
2694
+     * @param  string $value var number.
2695
+     */
2696
+    public function set_customer_vat_number( $value ) {
2697
+        $this->set_vat_number( $value );
2538 2698
     }
2539 2699
 
2540 2700
     /**
2541
-	 * Set the customer's state.
2542
-	 *
2543
-	 * @since 1.0.19
2544
-	 * @param  string $value state.
2545
-	 */
2546
-	public function set_state( $value ) {
2547
-		$this->set_prop( 'state', $value );
2701
+     * Set the customer's vat rate.
2702
+     *
2703
+     * @since 1.0.19
2704
+     * @param  string $value var rate.
2705
+     */
2706
+    public function set_vat_rate( $value ) {
2707
+        $this->set_prop( 'vat_rate', $value );
2548 2708
     }
2549 2709
 
2550 2710
     /**
2551
-	 * Alias of self::set_state().
2552
-	 *
2553
-	 * @since 1.0.19
2554
-	 * @param  string $value state.
2555
-	 */
2556
-	public function set_user_state( $value ) {
2557
-		$this->set_state( $value );
2711
+     * Alias of self::set_vat_rate().
2712
+     *
2713
+     * @since 1.0.19
2714
+     * @param  string $value var number.
2715
+     */
2716
+    public function set_user_vat_rate( $value ) {
2717
+        $this->set_vat_rate( $value );
2558 2718
     }
2559 2719
 
2560 2720
     /**
2561
-	 * Alias of self::set_state().
2562
-	 *
2563
-	 * @since 1.0.19
2564
-	 * @param  string $value state.
2565
-	 */
2566
-	public function set_customer_state( $value ) {
2567
-		$this->set_state( $value );
2721
+     * Alias of self::set_vat_rate().
2722
+     *
2723
+     * @since 1.0.19
2724
+     * @param  string $value var number.
2725
+     */
2726
+    public function set_customer_vat_rate( $value ) {
2727
+        $this->set_vat_rate( $value );
2568 2728
     }
2569 2729
 
2570 2730
     /**
2571
-	 * Set the customer's city.
2572
-	 *
2573
-	 * @since 1.0.19
2574
-	 * @param  string $value city.
2575
-	 */
2576
-	public function set_city( $value ) {
2577
-		$this->set_prop( 'city', $value );
2731
+     * Set the customer's address.
2732
+     *
2733
+     * @since 1.0.19
2734
+     * @param  string $value address.
2735
+     */
2736
+    public function set_address( $value ) {
2737
+        $this->set_prop( 'address', $value );
2578 2738
     }
2579 2739
 
2580 2740
     /**
2581
-	 * Alias of self::set_city().
2582
-	 *
2583
-	 * @since 1.0.19
2584
-	 * @param  string $value city.
2585
-	 */
2586
-	public function set_user_city( $value ) {
2587
-		$this->set_city( $value );
2741
+     * Alias of self::set_address().
2742
+     *
2743
+     * @since 1.0.19
2744
+     * @param  string $value address.
2745
+     */
2746
+    public function set_user_address( $value ) {
2747
+        $this->set_address( $value );
2588 2748
     }
2589 2749
 
2590 2750
     /**
2591
-	 * Alias of self::set_city().
2592
-	 *
2593
-	 * @since 1.0.19
2594
-	 * @param  string $value city.
2595
-	 */
2596
-	public function set_customer_city( $value ) {
2597
-		$this->set_city( $value );
2751
+     * Alias of self::set_address().
2752
+     *
2753
+     * @since 1.0.19
2754
+     * @param  string $value address.
2755
+     */
2756
+    public function set_customer_address( $value ) {
2757
+        $this->set_address( $value );
2598 2758
     }
2599 2759
 
2600 2760
     /**
2601
-	 * Set the customer's zip code.
2602
-	 *
2603
-	 * @since 1.0.19
2604
-	 * @param  string $value zip.
2605
-	 */
2606
-	public function set_zip( $value ) {
2607
-		$this->set_prop( 'zip', $value );
2761
+     * Set whether the customer has viewed the invoice or not.
2762
+     *
2763
+     * @since 1.0.19
2764
+     * @param  int|bool $value confirmed.
2765
+     */
2766
+    public function set_is_viewed( $value ) {
2767
+        $this->set_prop( 'is_viewed', $value );
2608 2768
     }
2609 2769
 
2610 2770
     /**
2611
-	 * Alias of self::set_zip().
2612
-	 *
2613
-	 * @since 1.0.19
2614
-	 * @param  string $value zip.
2615
-	 */
2616
-	public function set_user_zip( $value ) {
2617
-		$this->set_zip( $value );
2771
+     * Set extra email recipients.
2772
+     *
2773
+     * @since 1.0.19
2774
+     * @param  string $value email recipients.
2775
+     */
2776
+    public function set_email_cc( $value ) {
2777
+        $this->set_prop( 'email_cc', $value );
2618 2778
     }
2619 2779
 
2620 2780
     /**
2621
-	 * Alias of self::set_zip().
2622
-	 *
2623
-	 * @since 1.0.19
2624
-	 * @param  string $value zip.
2625
-	 */
2626
-	public function set_customer_zip( $value ) {
2627
-		$this->set_zip( $value );
2781
+     * Set the invoice template.
2782
+     *
2783
+     * @since 1.0.19
2784
+     * @param  string $value template.
2785
+     */
2786
+    public function set_template( $value ) {
2787
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2788
+            $this->set_prop( 'template', $value );
2789
+        }
2628 2790
     }
2629 2791
 
2630 2792
     /**
2631
-	 * Set the customer's company.
2632
-	 *
2633
-	 * @since 1.0.19
2634
-	 * @param  string $value company.
2635
-	 */
2636
-	public function set_company( $value ) {
2637
-		$this->set_prop( 'company', $value );
2793
+     * Set the invoice source.
2794
+     *
2795
+     * @since 1.0.19
2796
+     * @param  string $value source.
2797
+     * @deprecated
2798
+     */
2799
+    public function created_via( $value ) {
2800
+        $this->set_created_via( sanitize_text_field( $value ) );
2638 2801
     }
2639 2802
 
2640 2803
     /**
2641
-	 * Alias of self::set_company().
2642
-	 *
2643
-	 * @since 1.0.19
2644
-	 * @param  string $value company.
2645
-	 */
2646
-	public function set_user_company( $value ) {
2647
-		$this->set_company( $value );
2804
+     * Set the invoice source.
2805
+     *
2806
+     * @since 1.0.19
2807
+     * @param  string $value source.
2808
+     */
2809
+    public function set_created_via( $value ) {
2810
+        $this->set_prop( 'created_via', sanitize_text_field( $value ) );
2648 2811
     }
2649 2812
 
2650 2813
     /**
2651
-	 * Alias of self::set_company().
2652
-	 *
2653
-	 * @since 1.0.19
2654
-	 * @param  string $value company.
2655
-	 */
2656
-	public function set_customer_company( $value ) {
2657
-		$this->set_company( $value );
2658
-    }
2659
-
2660
-	/**
2661
-	 * Set the customer's company id.
2662
-	 *
2663
-	 * @since 1.0.19
2664
-	 * @param  string $value company id.
2665
-	 */
2666
-	public function set_company_id( $value ) {
2667
-		$this->set_prop( 'company_id', $value );
2814
+     * Set the customer's address confirmed status.
2815
+     *
2816
+     * @since 1.0.19
2817
+     * @param  int|bool $value confirmed.
2818
+     */
2819
+    public function set_address_confirmed( $value ) {
2820
+        $this->set_prop( 'address_confirmed', $value );
2668 2821
     }
2669 2822
 
2670 2823
     /**
2671
-	 * Set the customer's var number.
2672
-	 *
2673
-	 * @since 1.0.19
2674
-	 * @param  string $value var number.
2675
-	 */
2676
-	public function set_vat_number( $value ) {
2677
-		$this->set_prop( 'vat_number', $value );
2824
+     * Alias of self::set_address_confirmed().
2825
+     *
2826
+     * @since 1.0.19
2827
+     * @param  int|bool $value confirmed.
2828
+     */
2829
+    public function set_user_address_confirmed( $value ) {
2830
+        $this->set_address_confirmed( $value );
2678 2831
     }
2679 2832
 
2680 2833
     /**
2681
-	 * Alias of self::set_vat_number().
2682
-	 *
2683
-	 * @since 1.0.19
2684
-	 * @param  string $value var number.
2685
-	 */
2686
-	public function set_user_vat_number( $value ) {
2687
-		$this->set_vat_number( $value );
2834
+     * Alias of self::set_address_confirmed().
2835
+     *
2836
+     * @since 1.0.19
2837
+     * @param  int|bool $value confirmed.
2838
+     */
2839
+    public function set_customer_address_confirmed( $value ) {
2840
+        $this->set_address_confirmed( $value );
2688 2841
     }
2689 2842
 
2690 2843
     /**
2691
-	 * Alias of self::set_vat_number().
2692
-	 *
2693
-	 * @since 1.0.19
2694
-	 * @param  string $value var number.
2695
-	 */
2696
-	public function set_customer_vat_number( $value ) {
2697
-		$this->set_vat_number( $value );
2844
+     * Set the shipping fee
2845
+     *
2846
+     * @since 1.0.19
2847
+     * @param  float $value shipping amount.
2848
+     */
2849
+    public function set_shipping( $value ) {
2850
+
2851
+        if ( ! is_numeric( $value ) ) {
2852
+            return $this->set_prop( 'shipping', null );
2853
+        }
2854
+
2855
+        $this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2698 2856
     }
2699 2857
 
2700 2858
     /**
2701
-	 * Set the customer's vat rate.
2702
-	 *
2703
-	 * @since 1.0.19
2704
-	 * @param  string $value var rate.
2705
-	 */
2706
-	public function set_vat_rate( $value ) {
2707
-		$this->set_prop( 'vat_rate', $value );
2859
+     * Set the invoice sub total.
2860
+     *
2861
+     * @since 1.0.19
2862
+     * @param  float $value sub total.
2863
+     */
2864
+    public function set_subtotal( $value ) {
2865
+        $this->set_prop( 'subtotal', max( 0, $value ) );
2708 2866
     }
2709 2867
 
2710
-    /**
2711
-	 * Alias of self::set_vat_rate().
2712
-	 *
2713
-	 * @since 1.0.19
2714
-	 * @param  string $value var number.
2715
-	 */
2716
-	public function set_user_vat_rate( $value ) {
2717
-		$this->set_vat_rate( $value );
2718
-    }
2719
-
2720
-    /**
2721
-	 * Alias of self::set_vat_rate().
2722
-	 *
2723
-	 * @since 1.0.19
2724
-	 * @param  string $value var number.
2725
-	 */
2726
-	public function set_customer_vat_rate( $value ) {
2727
-		$this->set_vat_rate( $value );
2728
-    }
2729
-
2730
-    /**
2731
-	 * Set the customer's address.
2732
-	 *
2733
-	 * @since 1.0.19
2734
-	 * @param  string $value address.
2735
-	 */
2736
-	public function set_address( $value ) {
2737
-		$this->set_prop( 'address', $value );
2738
-    }
2739
-
2740
-    /**
2741
-	 * Alias of self::set_address().
2742
-	 *
2743
-	 * @since 1.0.19
2744
-	 * @param  string $value address.
2745
-	 */
2746
-	public function set_user_address( $value ) {
2747
-		$this->set_address( $value );
2748
-    }
2749
-
2750
-    /**
2751
-	 * Alias of self::set_address().
2752
-	 *
2753
-	 * @since 1.0.19
2754
-	 * @param  string $value address.
2755
-	 */
2756
-	public function set_customer_address( $value ) {
2757
-		$this->set_address( $value );
2758
-    }
2759
-
2760
-    /**
2761
-	 * Set whether the customer has viewed the invoice or not.
2762
-	 *
2763
-	 * @since 1.0.19
2764
-	 * @param  int|bool $value confirmed.
2765
-	 */
2766
-	public function set_is_viewed( $value ) {
2767
-		$this->set_prop( 'is_viewed', $value );
2768
-	}
2769
-
2770
-	/**
2771
-	 * Set extra email recipients.
2772
-	 *
2773
-	 * @since 1.0.19
2774
-	 * @param  string $value email recipients.
2775
-	 */
2776
-	public function set_email_cc( $value ) {
2777
-		$this->set_prop( 'email_cc', $value );
2778
-	}
2779
-
2780
-	/**
2781
-	 * Set the invoice template.
2782
-	 *
2783
-	 * @since 1.0.19
2784
-	 * @param  string $value template.
2785
-	 */
2786
-	public function set_template( $value ) {
2787
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2788
-			$this->set_prop( 'template', $value );
2789
-		}
2790
-	}
2791
-
2792
-	/**
2793
-	 * Set the invoice source.
2794
-	 *
2795
-	 * @since 1.0.19
2796
-	 * @param  string $value source.
2797
-	 * @deprecated
2798
-	 */
2799
-	public function created_via( $value ) {
2800
-		$this->set_created_via( sanitize_text_field( $value ) );
2801
-	}
2802
-
2803
-	/**
2804
-	 * Set the invoice source.
2805
-	 *
2806
-	 * @since 1.0.19
2807
-	 * @param  string $value source.
2808
-	 */
2809
-	public function set_created_via( $value ) {
2810
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2811
-	}
2812
-
2813
-	/**
2814
-	 * Set the customer's address confirmed status.
2815
-	 *
2816
-	 * @since 1.0.19
2817
-	 * @param  int|bool $value confirmed.
2818
-	 */
2819
-	public function set_address_confirmed( $value ) {
2820
-		$this->set_prop( 'address_confirmed', $value );
2821
-    }
2822
-
2823
-    /**
2824
-	 * Alias of self::set_address_confirmed().
2825
-	 *
2826
-	 * @since 1.0.19
2827
-	 * @param  int|bool $value confirmed.
2828
-	 */
2829
-	public function set_user_address_confirmed( $value ) {
2830
-		$this->set_address_confirmed( $value );
2831
-    }
2832
-
2833
-    /**
2834
-	 * Alias of self::set_address_confirmed().
2835
-	 *
2836
-	 * @since 1.0.19
2837
-	 * @param  int|bool $value confirmed.
2838
-	 */
2839
-	public function set_customer_address_confirmed( $value ) {
2840
-		$this->set_address_confirmed( $value );
2841
-    }
2842
-
2843
-    /**
2844
-	 * Set the shipping fee
2845
-	 *
2846
-	 * @since 1.0.19
2847
-	 * @param  float $value shipping amount.
2848
-	 */
2849
-	public function set_shipping( $value ) {
2850
-
2851
-		if ( ! is_numeric( $value ) ) {
2852
-			return $this->set_prop( 'shipping', null );
2853
-		}
2854
-
2855
-		$this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2856
-	}
2857
-
2858
-	/**
2859
-	 * Set the invoice sub total.
2860
-	 *
2861
-	 * @since 1.0.19
2862
-	 * @param  float $value sub total.
2863
-	 */
2864
-	public function set_subtotal( $value ) {
2865
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2866
-	}
2867
-
2868
-	/**
2869
-	 * Set the invoice total.
2870
-	 *
2871
-	 * @since 1.0.19
2872
-	 * @param  float $value sub total.
2873
-	 */
2874
-	public function set_total( $value ) {
2875
-		$this->set_prop( 'total', max( 0, $value ) );
2868
+    /**
2869
+     * Set the invoice total.
2870
+     *
2871
+     * @since 1.0.19
2872
+     * @param  float $value sub total.
2873
+     */
2874
+    public function set_total( $value ) {
2875
+        $this->set_prop( 'total', max( 0, $value ) );
2876 2876
     }
2877 2877
 
2878 2878
     /**
2879
-	 * Set the invoice discount amount.
2880
-	 *
2881
-	 * @since 1.0.19
2882
-	 * @param  float $value discount total.
2883
-	 */
2884
-	public function set_total_discount( $value ) {
2885
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2879
+     * Set the invoice discount amount.
2880
+     *
2881
+     * @since 1.0.19
2882
+     * @param  float $value discount total.
2883
+     */
2884
+    public function set_total_discount( $value ) {
2885
+        $this->set_prop( 'total_discount', max( 0, $value ) );
2886 2886
     }
2887 2887
 
2888 2888
     /**
2889
-	 * Alias of self::set_total_discount().
2890
-	 *
2891
-	 * @since 1.0.19
2892
-	 * @param  float $value discount total.
2893
-	 */
2894
-	public function set_discount( $value ) {
2895
-		$this->set_total_discount( $value );
2889
+     * Alias of self::set_total_discount().
2890
+     *
2891
+     * @since 1.0.19
2892
+     * @param  float $value discount total.
2893
+     */
2894
+    public function set_discount( $value ) {
2895
+        $this->set_total_discount( $value );
2896 2896
     }
2897 2897
 
2898 2898
     /**
2899
-	 * Set the invoice tax amount.
2900
-	 *
2901
-	 * @since 1.0.19
2902
-	 * @param  float $value tax total.
2903
-	 */
2904
-	public function set_total_tax( $value ) {
2905
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2899
+     * Set the invoice tax amount.
2900
+     *
2901
+     * @since 1.0.19
2902
+     * @param  float $value tax total.
2903
+     */
2904
+    public function set_total_tax( $value ) {
2905
+        $this->set_prop( 'total_tax', max( 0, $value ) );
2906 2906
     }
2907 2907
 
2908 2908
     /**
2909
-	 * Alias of self::set_total_tax().
2910
-	 *
2911
-	 * @since 1.0.19
2912
-	 * @param  float $value tax total.
2913
-	 */
2914
-	public function set_tax_total( $value ) {
2915
-		$this->set_total_tax( $value );
2909
+     * Alias of self::set_total_tax().
2910
+     *
2911
+     * @since 1.0.19
2912
+     * @param  float $value tax total.
2913
+     */
2914
+    public function set_tax_total( $value ) {
2915
+        $this->set_total_tax( $value );
2916 2916
     }
2917 2917
 
2918 2918
     /**
2919
-	 * Set the invoice fees amount.
2920
-	 *
2921
-	 * @since 1.0.19
2922
-	 * @param  float $value fees total.
2923
-	 */
2924
-	public function set_total_fees( $value ) {
2925
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2919
+     * Set the invoice fees amount.
2920
+     *
2921
+     * @since 1.0.19
2922
+     * @param  float $value fees total.
2923
+     */
2924
+    public function set_total_fees( $value ) {
2925
+        $this->set_prop( 'total_fees', max( 0, $value ) );
2926 2926
     }
2927 2927
 
2928 2928
     /**
2929
-	 * Alias of self::set_total_fees().
2930
-	 *
2931
-	 * @since 1.0.19
2932
-	 * @param  float $value fees total.
2933
-	 */
2934
-	public function set_fees_total( $value ) {
2935
-		$this->set_total_fees( $value );
2929
+     * Alias of self::set_total_fees().
2930
+     *
2931
+     * @since 1.0.19
2932
+     * @param  float $value fees total.
2933
+     */
2934
+    public function set_fees_total( $value ) {
2935
+        $this->set_total_fees( $value );
2936 2936
     }
2937 2937
 
2938 2938
     /**
2939
-	 * Set the invoice fees.
2940
-	 *
2941
-	 * @since 1.0.19
2942
-	 * @param  array $value fees.
2943
-	 */
2944
-	public function set_fees( $value ) {
2939
+     * Set the invoice fees.
2940
+     *
2941
+     * @since 1.0.19
2942
+     * @param  array $value fees.
2943
+     */
2944
+    public function set_fees( $value ) {
2945 2945
 
2946
-		if ( ! is_array( $value ) ) {
2947
-			$value = array();
2948
-		}
2946
+        if ( ! is_array( $value ) ) {
2947
+            $value = array();
2948
+        }
2949 2949
 
2950
-		$this->set_prop( 'fees', $value );
2950
+        $this->set_prop( 'fees', $value );
2951 2951
 
2952 2952
     }
2953 2953
 
2954 2954
     /**
2955
-	 * Set the invoice taxes.
2956
-	 *
2957
-	 * @since 1.0.19
2958
-	 * @param  array $value taxes.
2959
-	 */
2960
-	public function set_taxes( $value ) {
2955
+     * Set the invoice taxes.
2956
+     *
2957
+     * @since 1.0.19
2958
+     * @param  array $value taxes.
2959
+     */
2960
+    public function set_taxes( $value ) {
2961 2961
 
2962
-		if ( ! is_array( $value ) ) {
2963
-			$value = array();
2964
-		}
2962
+        if ( ! is_array( $value ) ) {
2963
+            $value = array();
2964
+        }
2965 2965
 
2966
-		$this->set_prop( 'taxes', $value );
2966
+        $this->set_prop( 'taxes', $value );
2967 2967
 
2968 2968
     }
2969 2969
 
2970 2970
     /**
2971
-	 * Set the invoice discounts.
2972
-	 *
2973
-	 * @since 1.0.19
2974
-	 * @param  array $value discounts.
2975
-	 */
2976
-	public function set_discounts( $value ) {
2971
+     * Set the invoice discounts.
2972
+     *
2973
+     * @since 1.0.19
2974
+     * @param  array $value discounts.
2975
+     */
2976
+    public function set_discounts( $value ) {
2977 2977
 
2978
-		if ( ! is_array( $value ) ) {
2979
-			$value = array();
2980
-		}
2978
+        if ( ! is_array( $value ) ) {
2979
+            $value = array();
2980
+        }
2981 2981
 
2982
-		$this->set_prop( 'discounts', $value );
2982
+        $this->set_prop( 'discounts', $value );
2983 2983
     }
2984 2984
 
2985 2985
     /**
2986
-	 * Set the invoice items.
2987
-	 *
2988
-	 * @since 1.0.19
2989
-	 * @param  GetPaid_Form_Item[] $value items.
2990
-	 */
2991
-	public function set_items( $value ) {
2986
+     * Set the invoice items.
2987
+     *
2988
+     * @since 1.0.19
2989
+     * @param  GetPaid_Form_Item[] $value items.
2990
+     */
2991
+    public function set_items( $value ) {
2992 2992
 
2993 2993
         // Remove existing items.
2994 2994
         $this->set_prop( 'items', array() );
2995
-		$this->recurring_item = null;
2995
+        $this->recurring_item = null;
2996 2996
 
2997 2997
         // Ensure that we have an array.
2998 2998
         if ( ! is_array( $value ) ) {
@@ -3006,95 +3006,95 @@  discard block
 block discarded – undo
3006 3006
     }
3007 3007
 
3008 3008
     /**
3009
-	 * Set the payment form.
3010
-	 *
3011
-	 * @since 1.0.19
3012
-	 * @param  int $value payment form.
3013
-	 */
3014
-	public function set_payment_form( $value ) {
3015
-		$this->set_prop( 'payment_form', $value );
3009
+     * Set the payment form.
3010
+     *
3011
+     * @since 1.0.19
3012
+     * @param  int $value payment form.
3013
+     */
3014
+    public function set_payment_form( $value ) {
3015
+        $this->set_prop( 'payment_form', $value );
3016 3016
     }
3017 3017
 
3018 3018
     /**
3019
-	 * Set the submission id.
3020
-	 *
3021
-	 * @since 1.0.19
3022
-	 * @param  string $value submission id.
3023
-	 */
3024
-	public function set_submission_id( $value ) {
3025
-		$this->set_prop( 'submission_id', $value );
3019
+     * Set the submission id.
3020
+     *
3021
+     * @since 1.0.19
3022
+     * @param  string $value submission id.
3023
+     */
3024
+    public function set_submission_id( $value ) {
3025
+        $this->set_prop( 'submission_id', $value );
3026 3026
     }
3027 3027
 
3028 3028
     /**
3029
-	 * Set the discount code.
3030
-	 *
3031
-	 * @since 1.0.19
3032
-	 * @param  string $value discount code.
3033
-	 */
3034
-	public function set_discount_code( $value ) {
3035
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3029
+     * Set the discount code.
3030
+     *
3031
+     * @since 1.0.19
3032
+     * @param  string $value discount code.
3033
+     */
3034
+    public function set_discount_code( $value ) {
3035
+        $this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3036 3036
     }
3037 3037
 
3038 3038
     /**
3039
-	 * Set the gateway.
3040
-	 *
3041
-	 * @since 1.0.19
3042
-	 * @param  string $value gateway.
3043
-	 */
3044
-	public function set_gateway( $value ) {
3045
-		$this->set_prop( 'gateway', $value );
3039
+     * Set the gateway.
3040
+     *
3041
+     * @since 1.0.19
3042
+     * @param  string $value gateway.
3043
+     */
3044
+    public function set_gateway( $value ) {
3045
+        $this->set_prop( 'gateway', $value );
3046 3046
     }
3047 3047
 
3048 3048
     /**
3049
-	 * Set the transaction id.
3050
-	 *
3051
-	 * @since 1.0.19
3052
-	 * @param  string $value transaction id.
3053
-	 */
3054
-	public function set_transaction_id( $value ) {
3055
-		if ( ! empty( $value ) ) {
3056
-			$this->set_prop( 'transaction_id', $value );
3057
-		}
3049
+     * Set the transaction id.
3050
+     *
3051
+     * @since 1.0.19
3052
+     * @param  string $value transaction id.
3053
+     */
3054
+    public function set_transaction_id( $value ) {
3055
+        if ( ! empty( $value ) ) {
3056
+            $this->set_prop( 'transaction_id', $value );
3057
+        }
3058 3058
     }
3059 3059
 
3060 3060
     /**
3061
-	 * Set the currency id.
3062
-	 *
3063
-	 * @since 1.0.19
3064
-	 * @param  string $value currency id.
3065
-	 */
3066
-	public function set_currency( $value ) {
3067
-		$this->set_prop( 'currency', $value );
3061
+     * Set the currency id.
3062
+     *
3063
+     * @since 1.0.19
3064
+     * @param  string $value currency id.
3065
+     */
3066
+    public function set_currency( $value ) {
3067
+        $this->set_prop( 'currency', $value );
3068 3068
     }
3069 3069
 
3070
-	/**
3071
-	 * Set whether to disable taxes.
3072
-	 *
3073
-	 * @since 1.0.19
3074
-	 * @param  bool $value value.
3075
-	 */
3076
-	public function set_disable_taxes( $value ) {
3077
-		$this->set_prop( 'disable_taxes', (bool) $value );
3078
-	}
3070
+    /**
3071
+     * Set whether to disable taxes.
3072
+     *
3073
+     * @since 1.0.19
3074
+     * @param  bool $value value.
3075
+     */
3076
+    public function set_disable_taxes( $value ) {
3077
+        $this->set_prop( 'disable_taxes', (bool) $value );
3078
+    }
3079 3079
 
3080 3080
     /**
3081
-	 * Set the subscription id.
3082
-	 *
3083
-	 * @since 1.0.19
3084
-	 * @param  string $value subscription id.
3085
-	 */
3086
-	public function set_subscription_id( $value ) {
3087
-		$this->set_prop( 'subscription_id', $value );
3088
-	}
3081
+     * Set the subscription id.
3082
+     *
3083
+     * @since 1.0.19
3084
+     * @param  string $value subscription id.
3085
+     */
3086
+    public function set_subscription_id( $value ) {
3087
+        $this->set_prop( 'subscription_id', $value );
3088
+    }
3089 3089
 	
3090
-	/**
3091
-	 * Set the remote subscription id.
3092
-	 *
3093
-	 * @since 1.0.19
3094
-	 * @param  string $value subscription id.
3095
-	 */
3096
-	public function set_remote_subscription_id( $value ) {
3097
-		$this->set_prop( 'remote_subscription_id', $value );
3090
+    /**
3091
+     * Set the remote subscription id.
3092
+     *
3093
+     * @since 1.0.19
3094
+     * @param  string $value subscription id.
3095
+     */
3096
+    public function set_remote_subscription_id( $value ) {
3097
+        $this->set_prop( 'remote_subscription_id', $value );
3098 3098
     }
3099 3099
 
3100 3100
     /*
@@ -3133,24 +3133,24 @@  discard block
 block discarded – undo
3133 3133
      */
3134 3134
     public function is_taxable() {
3135 3135
         return ! $this->get_disable_taxes();
3136
-	}
3136
+    }
3137 3137
 
3138
-	/**
3139
-	 * @deprecated
3140
-	 */
3141
-	public function has_vat() {
3138
+    /**
3139
+     * @deprecated
3140
+     */
3141
+    public function has_vat() {
3142 3142
         return $this->is_taxable();
3143
-	}
3143
+    }
3144 3144
 
3145
-	/**
3146
-	 * Checks to see if the invoice requires payment.
3147
-	 */
3148
-	public function is_free() {
3145
+    /**
3146
+     * Checks to see if the invoice requires payment.
3147
+     */
3148
+    public function is_free() {
3149 3149
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3150 3150
 
3151
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3152
-			$is_free = false;
3153
-		}
3151
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3152
+            $is_free = false;
3153
+        }
3154 3154
 
3155 3155
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3156 3156
     }
@@ -3161,46 +3161,46 @@  discard block
 block discarded – undo
3161 3161
     public function is_paid() {
3162 3162
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3163 3163
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3164
-	}
3164
+    }
3165 3165
 
3166
-	/**
3166
+    /**
3167 3167
      * Checks if the invoice needs payment.
3168 3168
      */
3169
-	public function needs_payment() {
3170
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3169
+    public function needs_payment() {
3170
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3171 3171
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3172 3172
     }
3173 3173
   
3174
-	/**
3174
+    /**
3175 3175
      * Checks if the invoice is refunded.
3176 3176
      */
3177
-	public function is_refunded() {
3177
+    public function is_refunded() {
3178 3178
         $is_refunded = $this->has_status( 'wpi-refunded' );
3179 3179
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3180
-	}
3180
+    }
3181 3181
 
3182
-	/**
3182
+    /**
3183 3183
      * Checks if the invoice is held.
3184 3184
      */
3185
-	public function is_held() {
3185
+    public function is_held() {
3186 3186
         $is_held = $this->has_status( 'wpi-onhold' );
3187 3187
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3188
-	}
3188
+    }
3189 3189
 
3190
-	/**
3190
+    /**
3191 3191
      * Checks if the invoice is due.
3192 3192
      */
3193
-	public function is_due() {
3194
-		$due_date = $this->get_due_date();
3195
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3196
-	}
3193
+    public function is_due() {
3194
+        $due_date = $this->get_due_date();
3195
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3196
+    }
3197 3197
 
3198
-	/**
3198
+    /**
3199 3199
      * Checks if the invoice is draft.
3200 3200
      */
3201
-	public function is_draft() {
3201
+    public function is_draft() {
3202 3202
         return $this->has_status( 'draft, auto-draft' );
3203
-	}
3203
+    }
3204 3204
 
3205 3205
     /**
3206 3206
      * Checks if the invoice has a given status.
@@ -3208,9 +3208,9 @@  discard block
 block discarded – undo
3208 3208
     public function has_status( $status ) {
3209 3209
         $status = wpinv_parse_list( $status );
3210 3210
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3211
-	}
3211
+    }
3212 3212
 
3213
-	/**
3213
+    /**
3214 3214
      * Checks if the invoice is of a given type.
3215 3215
      */
3216 3216
     public function is_type( $type ) {
@@ -3233,25 +3233,25 @@  discard block
 block discarded – undo
3233 3233
      */
3234 3234
     public function has_free_trial() {
3235 3235
         return $this->is_recurring() && 0 == $this->get_initial_total();
3236
-	}
3236
+    }
3237 3237
 
3238
-	/**
3238
+    /**
3239 3239
      * @deprecated
3240 3240
      */
3241 3241
     public function is_free_trial() {
3242 3242
         $this->has_free_trial();
3243 3243
     }
3244 3244
 
3245
-	/**
3245
+    /**
3246 3246
      * Check if the initial payment if 0.
3247 3247
      *
3248 3248
      */
3249
-	public function is_initial_free() {
3249
+    public function is_initial_free() {
3250 3250
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3251 3251
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3252 3252
     }
3253 3253
 	
3254
-	/**
3254
+    /**
3255 3255
      * Check if the recurring item has a free trial.
3256 3256
      *
3257 3257
      */
@@ -3264,21 +3264,21 @@  discard block
 block discarded – undo
3264 3264
 
3265 3265
         $item = $this->get_recurring( true );
3266 3266
         return $item->has_free_trial();
3267
-	}
3267
+    }
3268 3268
 
3269
-	/**
3269
+    /**
3270 3270
      * Check if the free trial is a result of a discount.
3271 3271
      */
3272 3272
     public function is_free_trial_from_discount() {
3273
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3274
-	}
3273
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3274
+    }
3275 3275
 	
3276
-	/**
3276
+    /**
3277 3277
      * @deprecated
3278 3278
      */
3279 3279
     public function discount_first_payment_only() {
3280 3280
 
3281
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3281
+        $discount = wpinv_get_discount_obj( $this->get_discount_code() );
3282 3282
         if ( ! $discount->exists() || ! $this->is_recurring() ) {
3283 3283
             return true;
3284 3284
         }
@@ -3303,147 +3303,147 @@  discard block
 block discarded – undo
3303 3303
      */
3304 3304
     public function add_item( $item ) {
3305 3305
 
3306
-		if ( is_array( $item ) ) {
3307
-			$item = $this->process_array_item( $item );
3308
-		}
3306
+        if ( is_array( $item ) ) {
3307
+            $item = $this->process_array_item( $item );
3308
+        }
3309 3309
 
3310
-		if ( is_numeric( $item ) ) {
3311
-			$item = new GetPaid_Form_Item( $item );
3312
-		}
3310
+        if ( is_numeric( $item ) ) {
3311
+            $item = new GetPaid_Form_Item( $item );
3312
+        }
3313 3313
 
3314 3314
         // Make sure that it is available for purchase.
3315
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3316
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3315
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3316
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3317 3317
         }
3318 3318
 
3319 3319
         // Do we have a recurring item?
3320
-		if ( $item->is_recurring() ) {
3321
-			$this->recurring_item = $item->get_id();
3320
+        if ( $item->is_recurring() ) {
3321
+            $this->recurring_item = $item->get_id();
3322 3322
         }
3323 3323
 
3324 3324
         // Invoice id.
3325 3325
         $item->invoice_id = (int) $this->get_id();
3326 3326
 
3327
-		// Remove duplicates.
3328
-		$this->remove_item( $item->get_id() );
3327
+        // Remove duplicates.
3328
+        $this->remove_item( $item->get_id() );
3329 3329
 
3330
-		if ( 0 == $item->get_quantity() ) {
3331
-			return;
3332
-		}
3330
+        if ( 0 == $item->get_quantity() ) {
3331
+            return;
3332
+        }
3333 3333
 
3334
-		// Retrieve all items.
3334
+        // Retrieve all items.
3335 3335
         $items   = $this->get_items();
3336 3336
 
3337
-		// Add new item.
3337
+        // Add new item.
3338 3338
         $items[] = $item;
3339 3339
 
3340 3340
         $this->set_prop( 'items', $items );
3341 3341
 
3342
-		return true;
3343
-	}
3342
+        return true;
3343
+    }
3344 3344
 
3345
-	/**
3346
-	 * Converts an array to an item.
3347
-	 *
3348
-	 * @since 1.0.19
3349
-	 * @return GetPaid_Form_Item
3350
-	 */
3351
-	protected function process_array_item( $array ) {
3345
+    /**
3346
+     * Converts an array to an item.
3347
+     *
3348
+     * @since 1.0.19
3349
+     * @return GetPaid_Form_Item
3350
+     */
3351
+    protected function process_array_item( $array ) {
3352 3352
 
3353
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3354
-		$item    = new GetPaid_Form_Item( $item_id );
3353
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3354
+        $item    = new GetPaid_Form_Item( $item_id );
3355 3355
 
3356
-		// Set item data.
3357
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3358
-			if ( isset( $array[ "item_$key" ] ) ) {
3359
-				$method = "set_$key";
3360
-				$item->$method( $array[ "item_$key" ] );
3361
-			}
3362
-		}
3356
+        // Set item data.
3357
+        foreach ( array( 'name', 'price', 'description' ) as $key ) {
3358
+            if ( isset( $array[ "item_$key" ] ) ) {
3359
+                $method = "set_$key";
3360
+                $item->$method( $array[ "item_$key" ] );
3361
+            }
3362
+        }
3363 3363
 
3364
-		if ( isset( $array['quantity'] ) ) {
3365
-			$item->set_quantity( $array['quantity'] );
3366
-		}
3364
+        if ( isset( $array['quantity'] ) ) {
3365
+            $item->set_quantity( $array['quantity'] );
3366
+        }
3367 3367
 
3368
-		// Set item meta.
3369
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3370
-			$item->set_item_meta( $array['meta'] );
3371
-		}
3368
+        // Set item meta.
3369
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3370
+            $item->set_item_meta( $array['meta'] );
3371
+        }
3372 3372
 
3373
-		return $item;
3373
+        return $item;
3374 3374
 
3375
-	}
3375
+    }
3376 3376
 
3377 3377
     /**
3378
-	 * Retrieves a specific item.
3379
-	 *
3380
-	 * @since 1.0.19
3381
-	 * @return GetPaid_Form_Item|null
3382
-	 */
3383
-	public function get_item( $item_id ) {
3378
+     * Retrieves a specific item.
3379
+     *
3380
+     * @since 1.0.19
3381
+     * @return GetPaid_Form_Item|null
3382
+     */
3383
+    public function get_item( $item_id ) {
3384 3384
 
3385
-		foreach ( $this->get_items() as $item ) {
3386
-			if ( (int) $item_id == $item->get_id() ) {
3387
-				return $item;
3388
-			}
3389
-		}
3385
+        foreach ( $this->get_items() as $item ) {
3386
+            if ( (int) $item_id == $item->get_id() ) {
3387
+                return $item;
3388
+            }
3389
+        }
3390 3390
 
3391
-		return null;
3391
+        return null;
3392 3392
     }
3393 3393
 
3394 3394
     /**
3395
-	 * Removes a specific item.
3396
-	 *
3397
-	 * @since 1.0.19
3398
-	 */
3399
-	public function remove_item( $item_id ) {
3400
-		$items   = $this->get_items();
3401
-		$item_id = (int) $item_id;
3395
+     * Removes a specific item.
3396
+     *
3397
+     * @since 1.0.19
3398
+     */
3399
+    public function remove_item( $item_id ) {
3400
+        $items   = $this->get_items();
3401
+        $item_id = (int) $item_id;
3402 3402
 
3403
-		foreach ( $items as $index => $item ) {
3404
-			if ( (int) $item_id == $item->get_id() ) {
3405
-				unset( $items[ $index ] );
3406
-				$this->set_prop( 'items', $items );
3403
+        foreach ( $items as $index => $item ) {
3404
+            if ( (int) $item_id == $item->get_id() ) {
3405
+                unset( $items[ $index ] );
3406
+                $this->set_prop( 'items', $items );
3407 3407
 
3408
-				if ( $item_id == $this->recurring_item ) {
3409
-					$this->recurring_item = null;
3410
-				}
3408
+                if ( $item_id == $this->recurring_item ) {
3409
+                    $this->recurring_item = null;
3410
+                }
3411 3411
 
3412
-			}
3413
-		}
3412
+            }
3413
+        }
3414 3414
 
3415 3415
     }
3416 3416
 
3417 3417
     /**
3418
-	 * Adds a fee to the invoice.
3419
-	 *
3420
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3421
-	 * @since 1.0.19
3422
-	 */
3418
+     * Adds a fee to the invoice.
3419
+     *
3420
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3421
+     * @since 1.0.19
3422
+     */
3423 3423
     public function add_fee( $fee ) {
3424 3424
 
3425
-		$fees                 = $this->get_fees();
3426
-		$fees[ $fee['name'] ] = $fee;
3427
-		$this->set_prop( 'fees', $fees );
3425
+        $fees                 = $this->get_fees();
3426
+        $fees[ $fee['name'] ] = $fee;
3427
+        $this->set_prop( 'fees', $fees );
3428 3428
 
3429 3429
     }
3430 3430
 
3431 3431
     /**
3432
-	 * Retrieves a specific fee.
3433
-	 *
3434
-	 * @since 1.0.19
3435
-	 */
3436
-	public function get_fee( $fee ) {
3432
+     * Retrieves a specific fee.
3433
+     *
3434
+     * @since 1.0.19
3435
+     */
3436
+    public function get_fee( $fee ) {
3437 3437
         $fees = $this->get_fees();
3438
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3438
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3439 3439
     }
3440 3440
 
3441 3441
     /**
3442
-	 * Removes a specific fee.
3443
-	 *
3444
-	 * @since 1.0.19
3445
-	 */
3446
-	public function remove_fee( $fee ) {
3442
+     * Removes a specific fee.
3443
+     *
3444
+     * @since 1.0.19
3445
+     */
3446
+    public function remove_fee( $fee ) {
3447 3447
         $fees = $this->get_fees();
3448 3448
         if ( isset( $fees[ $fee ] ) ) {
3449 3449
             unset( $fees[ $fee ] );
@@ -3451,55 +3451,55 @@  discard block
 block discarded – undo
3451 3451
         }
3452 3452
     }
3453 3453
 
3454
-	/**
3455
-	 * Adds a discount to the invoice.
3456
-	 *
3457
-	 * @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.
3458
-	 * @since 1.0.19
3459
-	 */
3460
-	public function add_discount( $discount ) {
3454
+    /**
3455
+     * Adds a discount to the invoice.
3456
+     *
3457
+     * @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.
3458
+     * @since 1.0.19
3459
+     */
3460
+    public function add_discount( $discount ) {
3461 3461
 
3462
-		$discounts = $this->get_discounts();
3463
-		$discounts[ $discount['name'] ] = $discount;
3464
-		$this->set_prop( 'discounts', $discounts );
3462
+        $discounts = $this->get_discounts();
3463
+        $discounts[ $discount['name'] ] = $discount;
3464
+        $this->set_prop( 'discounts', $discounts );
3465 3465
 
3466
-	}
3466
+    }
3467 3467
 
3468 3468
     /**
3469
-	 * Retrieves a specific discount.
3470
-	 *
3471
-	 * @since 1.0.19
3472
-	 * @return float
3473
-	 */
3474
-	public function get_discount( $discount = false ) {
3469
+     * Retrieves a specific discount.
3470
+     *
3471
+     * @since 1.0.19
3472
+     * @return float
3473
+     */
3474
+    public function get_discount( $discount = false ) {
3475 3475
 
3476
-		// Backwards compatibilty.
3477
-		if ( empty( $discount ) ) {
3478
-			return $this->get_total_discount();
3479
-		}
3476
+        // Backwards compatibilty.
3477
+        if ( empty( $discount ) ) {
3478
+            return $this->get_total_discount();
3479
+        }
3480 3480
 
3481 3481
         $discounts = $this->get_discounts();
3482
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3482
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3483 3483
     }
3484 3484
 
3485 3485
     /**
3486
-	 * Removes a specific discount.
3487
-	 *
3488
-	 * @since 1.0.19
3489
-	 */
3490
-	public function remove_discount( $discount ) {
3486
+     * Removes a specific discount.
3487
+     *
3488
+     * @since 1.0.19
3489
+     */
3490
+    public function remove_discount( $discount ) {
3491 3491
         $discounts = $this->get_discounts();
3492 3492
         if ( isset( $discounts[ $discount ] ) ) {
3493 3493
             unset( $discounts[ $discount ] );
3494 3494
             $this->set_prop( 'discounts', $discounts );
3495 3495
         }
3496 3496
 
3497
-		if ( 'discount_code' == $discount ) {
3498
-			foreach ( $this->get_items() as $item ) {
3499
-				$item->item_discount           = 0;
3500
-				$item->recurring_item_discount = 0;
3501
-			}
3502
-		}
3497
+        if ( 'discount_code' == $discount ) {
3498
+            foreach ( $this->get_items() as $item ) {
3499
+                $item->item_discount           = 0;
3500
+                $item->recurring_item_discount = 0;
3501
+            }
3502
+        }
3503 3503
 
3504 3504
     }
3505 3505
 
@@ -3512,34 +3512,34 @@  discard block
 block discarded – undo
3512 3512
         if ( $this->is_taxable() ) {
3513 3513
 
3514 3514
             $taxes                 = $this->get_taxes();
3515
-			$taxes[ $tax['name'] ] = $tax;
3516
-			$this->set_prop( 'taxes', $tax );
3515
+            $taxes[ $tax['name'] ] = $tax;
3516
+            $this->set_prop( 'taxes', $tax );
3517 3517
 
3518 3518
         }
3519 3519
     }
3520 3520
 
3521 3521
     /**
3522
-	 * Retrieves a specific tax.
3523
-	 *
3524
-	 * @since 1.0.19
3525
-	 */
3526
-	public function get_tax( $tax = null ) {
3522
+     * Retrieves a specific tax.
3523
+     *
3524
+     * @since 1.0.19
3525
+     */
3526
+    public function get_tax( $tax = null ) {
3527 3527
 
3528
-		// Backwards compatility.
3529
-		if ( empty( $tax ) ) {
3530
-			return $this->get_total_tax();
3531
-		}
3528
+        // Backwards compatility.
3529
+        if ( empty( $tax ) ) {
3530
+            return $this->get_total_tax();
3531
+        }
3532 3532
 
3533 3533
         $taxes = $this->get_taxes();
3534
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3534
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3535 3535
     }
3536 3536
 
3537 3537
     /**
3538
-	 * Removes a specific tax.
3539
-	 *
3540
-	 * @since 1.0.19
3541
-	 */
3542
-	public function remove_tax( $tax ) {
3538
+     * Removes a specific tax.
3539
+     *
3540
+     * @since 1.0.19
3541
+     */
3542
+    public function remove_tax( $tax ) {
3543 3543
         $taxes = $this->get_taxes();
3544 3544
         if ( isset( $taxes[ $tax ] ) ) {
3545 3545
             unset( $taxes[ $tax ] );
@@ -3548,185 +3548,185 @@  discard block
 block discarded – undo
3548 3548
     }
3549 3549
 
3550 3550
     /**
3551
-	 * Recalculates the invoice subtotal.
3552
-	 *
3553
-	 * @since 1.0.19
3554
-	 * @return float The recalculated subtotal
3555
-	 */
3556
-	public function recalculate_subtotal() {
3551
+     * Recalculates the invoice subtotal.
3552
+     *
3553
+     * @since 1.0.19
3554
+     * @return float The recalculated subtotal
3555
+     */
3556
+    public function recalculate_subtotal() {
3557 3557
         $items     = $this->get_items();
3558
-		$subtotal  = 0;
3559
-		$recurring = 0;
3558
+        $subtotal  = 0;
3559
+        $recurring = 0;
3560 3560
 
3561 3561
         foreach ( $items as $item ) {
3562
-			$subtotal  += $item->get_sub_total( 'edit' );
3563
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3562
+            $subtotal  += $item->get_sub_total( 'edit' );
3563
+            $recurring += $item->get_recurring_sub_total( 'edit' );
3564 3564
         }
3565 3565
 
3566
-		if ( wpinv_prices_include_tax() ) {
3567
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3568
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3569
-		}
3566
+        if ( wpinv_prices_include_tax() ) {
3567
+            $subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3568
+            $recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3569
+        }
3570 3570
 
3571
-		$current = $this->is_renewal() ? $recurring : $subtotal;
3572
-		$this->set_subtotal( $current );
3571
+        $current = $this->is_renewal() ? $recurring : $subtotal;
3572
+        $this->set_subtotal( $current );
3573 3573
 
3574
-		$this->totals['subtotal'] = array(
3575
-			'initial'   => $subtotal,
3576
-			'recurring' => $recurring,
3577
-		);
3574
+        $this->totals['subtotal'] = array(
3575
+            'initial'   => $subtotal,
3576
+            'recurring' => $recurring,
3577
+        );
3578 3578
 
3579 3579
         return $current;
3580 3580
     }
3581 3581
 
3582 3582
     /**
3583
-	 * Recalculates the invoice discount total.
3584
-	 *
3585
-	 * @since 1.0.19
3586
-	 * @return float The recalculated discount
3587
-	 */
3588
-	public function recalculate_total_discount() {
3583
+     * Recalculates the invoice discount total.
3584
+     *
3585
+     * @since 1.0.19
3586
+     * @return float The recalculated discount
3587
+     */
3588
+    public function recalculate_total_discount() {
3589 3589
         $discounts = $this->get_discounts();
3590
-		$discount  = 0;
3591
-		$recurring = 0;
3590
+        $discount  = 0;
3591
+        $recurring = 0;
3592 3592
 
3593 3593
         foreach ( $discounts as $data ) {
3594
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3595
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3596
-		}
3594
+            $discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3595
+            $recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3596
+        }
3597 3597
 
3598
-		$current = $this->is_renewal() ? $recurring : $discount;
3598
+        $current = $this->is_renewal() ? $recurring : $discount;
3599 3599
 
3600
-		$this->set_total_discount( $current );
3600
+        $this->set_total_discount( $current );
3601 3601
 
3602
-		$this->totals['discount'] = array(
3603
-			'initial'   => $discount,
3604
-			'recurring' => $recurring,
3605
-		);
3602
+        $this->totals['discount'] = array(
3603
+            'initial'   => $discount,
3604
+            'recurring' => $recurring,
3605
+        );
3606 3606
 
3607
-		return $current;
3607
+        return $current;
3608 3608
 
3609 3609
     }
3610 3610
 
3611 3611
     /**
3612
-	 * Recalculates the invoice tax total.
3613
-	 *
3614
-	 * @since 1.0.19
3615
-	 * @return float The recalculated tax
3616
-	 */
3617
-	public function recalculate_total_tax() {
3612
+     * Recalculates the invoice tax total.
3613
+     *
3614
+     * @since 1.0.19
3615
+     * @return float The recalculated tax
3616
+     */
3617
+    public function recalculate_total_tax() {
3618 3618
 
3619
-		// Maybe disable taxes.
3620
-		$vat_number = $this->get_vat_number();
3621
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3619
+        // Maybe disable taxes.
3620
+        $vat_number = $this->get_vat_number();
3621
+        $skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3622 3622
 
3623
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3624
-			$skip_tax = false;
3625
-		}
3623
+        if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3624
+            $skip_tax = false;
3625
+        }
3626 3626
 
3627
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax   ) {
3627
+        if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax   ) {
3628 3628
 
3629
-			$this->totals['tax'] = array(
3630
-				'initial'   => 0,
3631
-				'recurring' => 0,
3632
-			);
3629
+            $this->totals['tax'] = array(
3630
+                'initial'   => 0,
3631
+                'recurring' => 0,
3632
+            );
3633 3633
 
3634
-			$this->tax_rate = 0;
3634
+            $this->tax_rate = 0;
3635 3635
 
3636
-			$this->set_taxes( array() );
3637
-			$current = 0;
3638
-		} else {
3636
+            $this->set_taxes( array() );
3637
+            $current = 0;
3638
+        } else {
3639 3639
 
3640
-			$item_taxes = array();
3640
+            $item_taxes = array();
3641 3641
 
3642
-			foreach ( $this->get_items() as $item ) {
3643
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3644
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3645
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3646
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3647
-				foreach ( $taxes as $name => $amount ) {
3648
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3649
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3642
+            foreach ( $this->get_items() as $item ) {
3643
+                $rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3644
+                $rates    = getpaid_filter_item_tax_rates( $item, $rates );
3645
+                $taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3646
+                $r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3647
+                foreach ( $taxes as $name => $amount ) {
3648
+                    $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3649
+                    $tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3650 3650
 
3651
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3652
-						$item_taxes[ $name ] = $tax;
3653
-						continue;
3654
-					}
3651
+                    if ( ! isset( $item_taxes[ $name ] ) ) {
3652
+                        $item_taxes[ $name ] = $tax;
3653
+                        continue;
3654
+                    }
3655 3655
 
3656
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3657
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3656
+                    $item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3657
+                    $item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3658 3658
 
3659
-				}
3659
+                }
3660 3660
 
3661
-			}
3661
+            }
3662 3662
 
3663
-			$item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3664
-			$this->set_taxes( $item_taxes );
3663
+            $item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3664
+            $this->set_taxes( $item_taxes );
3665 3665
 
3666
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3667
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3666
+            $initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3667
+            $recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3668 3668
 
3669
-			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3669
+            $current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3670 3670
 
3671
-			$this->totals['tax'] = array(
3672
-				'initial'   => $initial_tax,
3673
-				'recurring' => $recurring_tax,
3674
-			);
3671
+            $this->totals['tax'] = array(
3672
+                'initial'   => $initial_tax,
3673
+                'recurring' => $recurring_tax,
3674
+            );
3675 3675
 
3676
-		}
3676
+        }
3677 3677
 
3678
-		$this->set_total_tax( $current );
3678
+        $this->set_total_tax( $current );
3679 3679
 
3680
-		return $current;
3680
+        return $current;
3681 3681
 
3682 3682
     }
3683 3683
 
3684 3684
     /**
3685
-	 * Recalculates the invoice fees total.
3686
-	 *
3687
-	 * @since 1.0.19
3688
-	 * @return float The recalculated fee
3689
-	 */
3690
-	public function recalculate_total_fees() {
3691
-		$fees      = $this->get_fees();
3692
-		$fee       = 0;
3693
-		$recurring = 0;
3685
+     * Recalculates the invoice fees total.
3686
+     *
3687
+     * @since 1.0.19
3688
+     * @return float The recalculated fee
3689
+     */
3690
+    public function recalculate_total_fees() {
3691
+        $fees      = $this->get_fees();
3692
+        $fee       = 0;
3693
+        $recurring = 0;
3694 3694
 
3695 3695
         foreach ( $fees as $data ) {
3696
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3697
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3698
-		}
3696
+            $fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3697
+            $recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3698
+        }
3699 3699
 
3700
-		$current = $this->is_renewal() ? $recurring : $fee;
3701
-		$this->set_total_fees( $current );
3700
+        $current = $this->is_renewal() ? $recurring : $fee;
3701
+        $this->set_total_fees( $current );
3702 3702
 
3703
-		$this->totals['fee'] = array(
3704
-			'initial'   => $fee,
3705
-			'recurring' => $recurring,
3706
-		);
3703
+        $this->totals['fee'] = array(
3704
+            'initial'   => $fee,
3705
+            'recurring' => $recurring,
3706
+        );
3707 3707
 
3708 3708
         $this->set_total_fees( $fee );
3709 3709
         return $current;
3710 3710
     }
3711 3711
 
3712 3712
     /**
3713
-	 * Recalculates the invoice total.
3714
-	 *
3715
-	 * @since 1.0.19
3713
+     * Recalculates the invoice total.
3714
+     *
3715
+     * @since 1.0.19
3716 3716
      * @return float The invoice total
3717
-	 */
3718
-	public function recalculate_total() {
3717
+     */
3718
+    public function recalculate_total() {
3719 3719
         $this->recalculate_total_fees();
3720 3720
         $this->recalculate_total_discount();
3721
-		$this->recalculate_total_tax();
3722
-		$this->recalculate_subtotal();
3723
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3724
-		return $this->get_total();
3725
-	}
3726
-
3727
-	/**
3728
-	 * @deprecated
3729
-	 */
3721
+        $this->recalculate_total_tax();
3722
+        $this->recalculate_subtotal();
3723
+        $this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3724
+        return $this->get_total();
3725
+    }
3726
+
3727
+    /**
3728
+     * @deprecated
3729
+     */
3730 3730
     public function recalculate_totals() {
3731 3731
         $this->recalculate_total();
3732 3732
         $this->save( true );
@@ -3740,22 +3740,22 @@  discard block
 block discarded – undo
3740 3740
         return $this->get_data();
3741 3741
     }
3742 3742
 
3743
-	/**
3743
+    /**
3744 3744
      * Adds a system note to an invoice.
3745 3745
      *
3746 3746
      * @param string $note The note being added.
3747
-	 * @return int|false The new note's ID on success, false on failure.
3747
+     * @return int|false The new note's ID on success, false on failure.
3748 3748
      *
3749 3749
      */
3750 3750
     public function add_system_note( $note ) {
3751
-		return $this->add_note( $note, false, false, true );
3752
-	}
3751
+        return $this->add_note( $note, false, false, true );
3752
+    }
3753 3753
 
3754 3754
     /**
3755 3755
      * Adds a note to an invoice.
3756 3756
      *
3757 3757
      * @param string $note The note being added.
3758
-	 * @return int|false The new note's ID on success, false on failure.
3758
+     * @return int|false The new note's ID on success, false on failure.
3759 3759
      *
3760 3760
      */
3761 3761
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3765,21 +3765,21 @@  discard block
 block discarded – undo
3765 3765
             return false;
3766 3766
         }
3767 3767
 
3768
-		$author       = 'System';
3769
-		$author_email = '[email protected]';
3768
+        $author       = 'System';
3769
+        $author_email = '[email protected]';
3770 3770
 
3771
-		// If this is an admin comment or it has been added by the user.
3772
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3773
-			$user         = get_user_by( 'id', get_current_user_id() );
3771
+        // If this is an admin comment or it has been added by the user.
3772
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3773
+            $user         = get_user_by( 'id', get_current_user_id() );
3774 3774
             $author       = $user->display_name;
3775 3775
             $author_email = $user->user_email;
3776
-		}
3776
+        }
3777 3777
 
3778
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3778
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3779 3779
 
3780
-	}
3780
+    }
3781 3781
 
3782
-	/**
3782
+    /**
3783 3783
      * Generates a unique key for the invoice.
3784 3784
      */
3785 3785
     public function generate_key( $string = '' ) {
@@ -3799,113 +3799,113 @@  discard block
 block discarded – undo
3799 3799
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3800 3800
         }
3801 3801
 
3802
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3803
-
3804
-	}
3805
-
3806
-	/**
3807
-	 * Handle the status transition.
3808
-	 */
3809
-	protected function status_transition() {
3810
-		$status_transition = $this->status_transition;
3811
-
3812
-		// Reset status transition variable.
3813
-		$this->status_transition = false;
3802
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3814 3803
 
3815
-		if ( $status_transition ) {
3816
-			try {
3817
-
3818
-				// Fire a hook for the status change.
3819
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3820
-
3821
-				// @deprecated this is deprecated and will be removed in the future.
3822
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3823
-
3824
-				if ( ! empty( $status_transition['from'] ) ) {
3825
-
3826
-					/* translators: 1: old invoice status 2: new invoice status */
3827
-					$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  ) );
3828
-
3829
-					// Fire another hook.
3830
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3831
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3832
-
3833
-					// @deprecated this is deprecated and will be removed in the future.
3834
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3835
-
3836
-					// Note the transition occurred.
3837
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3838
-
3839
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3840
-					if (
3841
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3842
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3843
-					) {
3844
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3845
-					}
3846
-
3847
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3848
-					if (
3849
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3850
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3851
-					) {
3852
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3853
-					}
3854
-				} else {
3855
-					/* translators: %s: new invoice status */
3856
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3857
-
3858
-					// Note the transition occurred.
3859
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3804
+    }
3860 3805
 
3861
-				}
3862
-			} catch ( Exception $e ) {
3863
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3864
-			}
3865
-		}
3866
-	}
3806
+    /**
3807
+     * Handle the status transition.
3808
+     */
3809
+    protected function status_transition() {
3810
+        $status_transition = $this->status_transition;
3811
+
3812
+        // Reset status transition variable.
3813
+        $this->status_transition = false;
3814
+
3815
+        if ( $status_transition ) {
3816
+            try {
3817
+
3818
+                // Fire a hook for the status change.
3819
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3820
+
3821
+                // @deprecated this is deprecated and will be removed in the future.
3822
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3823
+
3824
+                if ( ! empty( $status_transition['from'] ) ) {
3825
+
3826
+                    /* translators: 1: old invoice status 2: new invoice status */
3827
+                    $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  ) );
3828
+
3829
+                    // Fire another hook.
3830
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3831
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3832
+
3833
+                    // @deprecated this is deprecated and will be removed in the future.
3834
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3835
+
3836
+                    // Note the transition occurred.
3837
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3838
+
3839
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3840
+                    if (
3841
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3842
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3843
+                    ) {
3844
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3845
+                    }
3846
+
3847
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3848
+                    if (
3849
+                        in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3850
+                        && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3851
+                    ) {
3852
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3853
+                    }
3854
+                } else {
3855
+                    /* translators: %s: new invoice status */
3856
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3857
+
3858
+                    // Note the transition occurred.
3859
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3860
+
3861
+                }
3862
+            } catch ( Exception $e ) {
3863
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3864
+            }
3865
+        }
3866
+    }
3867 3867
 
3868
-	/**
3869
-	 * Updates an invoice status.
3870
-	 */
3871
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3868
+    /**
3869
+     * Updates an invoice status.
3870
+     */
3871
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3872 3872
 
3873
-		// Fires before updating a status.
3874
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3873
+        // Fires before updating a status.
3874
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3875 3875
 
3876
-		// Update the status.
3877
-		$this->set_status( $new_status, $note, $manual );
3876
+        // Update the status.
3877
+        $this->set_status( $new_status, $note, $manual );
3878 3878
 
3879
-		// Save the order.
3880
-		return $this->save();
3879
+        // Save the order.
3880
+        return $this->save();
3881 3881
 
3882
-	}
3882
+    }
3883 3883
 
3884
-	/**
3885
-	 * @deprecated
3886
-	 */
3887
-	public function refresh_item_ids() {
3884
+    /**
3885
+     * @deprecated
3886
+     */
3887
+    public function refresh_item_ids() {
3888 3888
         $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
3889 3889
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3890
-	}
3890
+    }
3891 3891
 
3892
-	/**
3893
-	 * @deprecated
3894
-	 */
3895
-	public function update_items( $temp = false ) {
3892
+    /**
3893
+     * @deprecated
3894
+     */
3895
+    public function update_items( $temp = false ) {
3896 3896
 
3897
-		$this->set_items( $this->get_items() );
3897
+        $this->set_items( $this->get_items() );
3898 3898
 
3899
-		if ( ! $temp ) {
3900
-			$this->save();
3901
-		}
3899
+        if ( ! $temp ) {
3900
+            $this->save();
3901
+        }
3902 3902
 
3903 3903
         return $this;
3904
-	}
3904
+    }
3905 3905
 
3906
-	/**
3907
-	 * @deprecated
3908
-	 */
3906
+    /**
3907
+     * @deprecated
3908
+     */
3909 3909
     public function validate_discount() {
3910 3910
 
3911 3911
         $discount_code = $this->get_discount_code();
@@ -3921,93 +3921,93 @@  discard block
 block discarded – undo
3921 3921
 
3922 3922
     }
3923 3923
 
3924
-	/**
3925
-	 * Refunds an invoice.
3926
-	 */
3924
+    /**
3925
+     * Refunds an invoice.
3926
+     */
3927 3927
     public function refund() {
3928
-		$this->set_status( 'wpi-refunded' );
3928
+        $this->set_status( 'wpi-refunded' );
3929 3929
         $this->save();
3930
-	}
3930
+    }
3931 3931
 
3932
-	/**
3933
-	 * Marks an invoice as paid.
3934
-	 * 
3935
-	 * @param string $transaction_id
3936
-	 */
3932
+    /**
3933
+     * Marks an invoice as paid.
3934
+     * 
3935
+     * @param string $transaction_id
3936
+     */
3937 3937
     public function mark_paid( $transaction_id = null, $note = '' ) {
3938 3938
 
3939
-		// Set the transaction id.
3940
-		if ( empty( $transaction_id ) ) {
3941
-			$transaction_id = $this->generate_key('trans_');
3942
-		}
3939
+        // Set the transaction id.
3940
+        if ( empty( $transaction_id ) ) {
3941
+            $transaction_id = $this->generate_key('trans_');
3942
+        }
3943 3943
 
3944
-		if ( ! $this->get_transaction_id() ) {
3945
-			$this->set_transaction_id( $transaction_id );
3946
-		}
3944
+        if ( ! $this->get_transaction_id() ) {
3945
+            $this->set_transaction_id( $transaction_id );
3946
+        }
3947 3947
 
3948
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3949
-			return $this->save();
3950
-		}
3948
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3949
+            return $this->save();
3950
+        }
3951 3951
 
3952
-		// Set the completed date.
3953
-		$this->set_date_completed( current_time( 'mysql' ) );
3952
+        // Set the completed date.
3953
+        $this->set_date_completed( current_time( 'mysql' ) );
3954 3954
 
3955
-		// Set the new status.
3956
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
3957
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
3955
+        // Set the new status.
3956
+        $gateway = sanitize_text_field( $this->get_gateway_title() );
3957
+        if ( $this->is_renewal() || ! $this->is_parent() ) {
3958 3958
 
3959
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3960
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3959
+            $_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3960
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3961 3961
 
3962
-			if ( 'none' == $this->get_gateway() ) {
3963
-				$_note = $note;
3964
-			}
3962
+            if ( 'none' == $this->get_gateway() ) {
3963
+                $_note = $note;
3964
+            }
3965 3965
 
3966
-			$this->set_status( 'wpi-renewal', $_note );
3966
+            $this->set_status( 'wpi-renewal', $_note );
3967 3967
 
3968
-		} else {
3968
+        } else {
3969 3969
 
3970
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3971
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3970
+            $_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3971
+            $_note = $_note . empty( $note ) ? '' : " ($note)";
3972 3972
 
3973
-			if ( 'none' == $this->get_gateway() ) {
3974
-				$_note = $note;
3975
-			}
3973
+            if ( 'none' == $this->get_gateway() ) {
3974
+                $_note = $note;
3975
+            }
3976 3976
 
3977
-			$this->set_status( 'publish', $_note );
3977
+            $this->set_status( 'publish', $_note );
3978 3978
 
3979
-		}
3979
+        }
3980 3980
 
3981
-		// Set checkout mode.
3982
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3983
-		$this->set_mode( $mode );
3981
+        // Set checkout mode.
3982
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3983
+        $this->set_mode( $mode );
3984 3984
 
3985
-		// Save the invoice.
3985
+        // Save the invoice.
3986 3986
         $this->save();
3987
-	}
3988
-
3989
-	/**
3990
-	 * Save data to the database.
3991
-	 *
3992
-	 * @since 1.0.19
3993
-	 * @return int invoice ID
3994
-	 */
3995
-	public function save() {
3996
-		$this->maybe_set_date_paid();
3997
-		$this->maybe_set_key();
3998
-		parent::save();
3999
-		$this->clear_cache();
4000
-		$this->status_transition();
4001
-		return $this->get_id();
4002
-	}
4003
-
4004
-	/**
3987
+    }
3988
+
3989
+    /**
3990
+     * Save data to the database.
3991
+     *
3992
+     * @since 1.0.19
3993
+     * @return int invoice ID
3994
+     */
3995
+    public function save() {
3996
+        $this->maybe_set_date_paid();
3997
+        $this->maybe_set_key();
3998
+        parent::save();
3999
+        $this->clear_cache();
4000
+        $this->status_transition();
4001
+        return $this->get_id();
4002
+    }
4003
+
4004
+    /**
4005 4005
      * Clears the subscription's cache.
4006 4006
      */
4007 4007
     public function clear_cache() {
4008
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4009
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4010
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4011
-	}
4008
+        wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4009
+        wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4010
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4011
+    }
4012 4012
 
4013 4013
 }
Please login to merge, or discard this patch.
Spacing   +804 added lines, -804 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
 	/**
@@ -1375,8 +1375,8 @@  discard block
 block discarded – undo
1375 1375
 	 */
1376 1376
 	public function get_shipping_address() {
1377 1377
 
1378
-		$shipping_address = get_post_meta( $this->get_id(), 'shipping_address', true );
1379
-		return is_array( $shipping_address ) ? $shipping_address : false;
1378
+		$shipping_address = get_post_meta($this->get_id(), 'shipping_address', true);
1379
+		return is_array($shipping_address) ? $shipping_address : false;
1380 1380
     }
1381 1381
 
1382 1382
 	/**
@@ -1393,17 +1393,17 @@  discard block
 block discarded – undo
1393 1393
 	 * @param  string $context View or edit context.
1394 1394
 	 * @return float
1395 1395
 	 */
1396
-	public function get_shipping( $context = 'view' ) {
1396
+	public function get_shipping($context = 'view') {
1397 1397
 
1398
-		if ( $context = 'view' ) {
1399
-			return floatval( $this->get_prop( 'shipping', $context ) );
1398
+		if ($context = 'view') {
1399
+			return floatval($this->get_prop('shipping', $context));
1400 1400
 		}
1401 1401
  
1402
-		return $this->get_prop( 'shipping', $context );
1402
+		return $this->get_prop('shipping', $context);
1403 1403
     }
1404 1404
 
1405 1405
 	public function has_shipping() {
1406
-		return defined( 'GETPAID_SHIPPING_CALCULATOR_VERSION' ) && null !== $this->get_prop( 'shipping', 'edit' );
1406
+		return defined('GETPAID_SHIPPING_CALCULATOR_VERSION') && null !== $this->get_prop('shipping', 'edit');
1407 1407
     }
1408 1408
 
1409 1409
     /**
@@ -1413,12 +1413,12 @@  discard block
 block discarded – undo
1413 1413
 	 * @param  string $context View or edit context.
1414 1414
 	 * @return float
1415 1415
 	 */
1416
-	public function get_subtotal( $context = 'view' ) {
1417
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1416
+	public function get_subtotal($context = 'view') {
1417
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1418 1418
 
1419 1419
         // Backwards compatibility.
1420
-        if ( is_bool( $context ) && $context ) {
1421
-            return wpinv_price( $subtotal, $this->get_currency() );
1420
+        if (is_bool($context) && $context) {
1421
+            return wpinv_price($subtotal, $this->get_currency());
1422 1422
         }
1423 1423
 
1424 1424
         return $subtotal;
@@ -1431,8 +1431,8 @@  discard block
 block discarded – undo
1431 1431
 	 * @param  string $context View or edit context.
1432 1432
 	 * @return float
1433 1433
 	 */
1434
-	public function get_total_discount( $context = 'view' ) {
1435
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_discount', $context ) ) );
1434
+	public function get_total_discount($context = 'view') {
1435
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_discount', $context)));
1436 1436
     }
1437 1437
 
1438 1438
     /**
@@ -1442,18 +1442,18 @@  discard block
 block discarded – undo
1442 1442
 	 * @param  string $context View or edit context.
1443 1443
 	 * @return float
1444 1444
 	 */
1445
-	public function get_total_tax( $context = 'view' ) {
1446
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_tax', $context ) ) );
1445
+	public function get_total_tax($context = 'view') {
1446
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_tax', $context)));
1447 1447
 	}
1448 1448
 
1449 1449
 	/**
1450 1450
 	 * @deprecated
1451 1451
 	 */
1452
-	public function get_final_tax( $currency = false ) {
1452
+	public function get_final_tax($currency = false) {
1453 1453
 		$tax = $this->get_total_tax();
1454 1454
 
1455
-        if ( $currency ) {
1456
-			return wpinv_price( $tax, $this->get_currency() );
1455
+        if ($currency) {
1456
+			return wpinv_price($tax, $this->get_currency());
1457 1457
         }
1458 1458
 
1459 1459
         return $tax;
@@ -1466,8 +1466,8 @@  discard block
 block discarded – undo
1466 1466
 	 * @param  string $context View or edit context.
1467 1467
 	 * @return float
1468 1468
 	 */
1469
-	public function get_total_fees( $context = 'view' ) {
1470
-		return wpinv_round_amount( wpinv_sanitize_amount( $this->get_prop( 'total_fees', $context ) ) );
1469
+	public function get_total_fees($context = 'view') {
1470
+		return wpinv_round_amount(wpinv_sanitize_amount($this->get_prop('total_fees', $context)));
1471 1471
     }
1472 1472
 
1473 1473
     /**
@@ -1477,8 +1477,8 @@  discard block
 block discarded – undo
1477 1477
 	 * @param  string $context View or edit context.
1478 1478
 	 * @return float
1479 1479
 	 */
1480
-	public function get_fees_total( $context = 'view' ) {
1481
-		return $this->get_total_fees( $context );
1480
+	public function get_fees_total($context = 'view') {
1481
+		return $this->get_total_fees($context);
1482 1482
     }
1483 1483
 
1484 1484
     /**
@@ -1487,14 +1487,14 @@  discard block
 block discarded – undo
1487 1487
 	 * @since 1.0.19
1488 1488
      * @return float
1489 1489
 	 */
1490
-	public function get_total( $context = 'view' ) {
1491
-		$total = $this->get_prop( 'total', $context );
1490
+	public function get_total($context = 'view') {
1491
+		$total = $this->get_prop('total', $context);
1492 1492
 
1493
-		if ( $this->has_shipping() && $context == 'view' ) {
1494
-			$total = $this->get_prop( 'total', $context ) + $this->get_shipping( $context );
1493
+		if ($this->has_shipping() && $context == 'view') {
1494
+			$total = $this->get_prop('total', $context) + $this->get_shipping($context);
1495 1495
 		}
1496 1496
 
1497
-		return wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1497
+		return wpinv_round_amount(wpinv_sanitize_amount($total));
1498 1498
 	}
1499 1499
 
1500 1500
 	/**
@@ -1506,20 +1506,20 @@  discard block
 block discarded – undo
1506 1506
 	public function get_non_recurring_total() {
1507 1507
 
1508 1508
 		$subtotal = 0;
1509
-		foreach ( $this->get_items() as $item ) {
1510
-			if ( ! $item->is_recurring() ) {
1509
+		foreach ($this->get_items() as $item) {
1510
+			if (!$item->is_recurring()) {
1511 1511
 				$subtotal += $item->get_sub_total();
1512 1512
 			}
1513 1513
 		}
1514 1514
 
1515
-		foreach ( $this->get_fees() as $fee ) {
1516
-			if ( empty( $fee['recurring_fee'] ) ) {
1517
-				$subtotal += wpinv_sanitize_amount( $fee['initial_fee'] );
1515
+		foreach ($this->get_fees() as $fee) {
1516
+			if (empty($fee['recurring_fee'])) {
1517
+				$subtotal += wpinv_sanitize_amount($fee['initial_fee']);
1518 1518
 			}
1519 1519
 		}
1520 1520
 
1521
-		$subtotal = wpinv_round_amount( wpinv_sanitize_amount( $subtotal ) );
1522
-        return apply_filters( 'wpinv_get_non_recurring_invoice_total', $subtotal, $this );
1521
+		$subtotal = wpinv_round_amount(wpinv_sanitize_amount($subtotal));
1522
+        return apply_filters('wpinv_get_non_recurring_invoice_total', $subtotal, $this);
1523 1523
 
1524 1524
     }
1525 1525
 
@@ -1542,7 +1542,7 @@  discard block
 block discarded – undo
1542 1542
 	 */
1543 1543
     public function get_initial_total() {
1544 1544
 
1545
-		if ( empty( $this->totals ) ) {
1545
+		if (empty($this->totals)) {
1546 1546
 			$this->recalculate_total();
1547 1547
 		}
1548 1548
 
@@ -1552,12 +1552,12 @@  discard block
 block discarded – undo
1552 1552
 		$subtotal = $this->totals['subtotal']['initial'];
1553 1553
 		$total    = $tax + $fee - $discount + $subtotal;
1554 1554
 
1555
-		if ( 0 > $total ) {
1555
+		if (0 > $total) {
1556 1556
 			$total = 0;
1557 1557
 		}
1558 1558
 
1559
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1560
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1559
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1560
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1561 1561
 	}
1562 1562
 
1563 1563
 	/**
@@ -1569,7 +1569,7 @@  discard block
 block discarded – undo
1569 1569
 	 */
1570 1570
     public function get_recurring_total() {
1571 1571
 
1572
-		if ( empty( $this->totals ) ) {
1572
+		if (empty($this->totals)) {
1573 1573
 			$this->recalculate_total();
1574 1574
 		}
1575 1575
 
@@ -1579,12 +1579,12 @@  discard block
 block discarded – undo
1579 1579
 		$subtotal = $this->totals['subtotal']['recurring'];
1580 1580
 		$total    = $tax + $fee - $discount + $subtotal;
1581 1581
 
1582
-		if ( 0 > $total ) {
1582
+		if (0 > $total) {
1583 1583
 			$total = 0;
1584 1584
 		}
1585 1585
 
1586
-		$total = wpinv_round_amount( wpinv_sanitize_amount( $total ) );
1587
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1586
+		$total = wpinv_round_amount(wpinv_sanitize_amount($total));
1587
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1588 1588
 	}
1589 1589
 
1590 1590
 	/**
@@ -1595,10 +1595,10 @@  discard block
 block discarded – undo
1595 1595
 	 * @param string $currency Whether to include the currency.
1596 1596
      * @return float|string
1597 1597
 	 */
1598
-    public function get_recurring_details( $field = '', $currency = false ) {
1598
+    public function get_recurring_details($field = '', $currency = false) {
1599 1599
 
1600 1600
 		// Maybe recalculate totals.
1601
-		if ( empty( $this->totals ) ) {
1601
+		if (empty($this->totals)) {
1602 1602
 			$this->recalculate_total();
1603 1603
 		}
1604 1604
 
@@ -1618,8 +1618,8 @@  discard block
 block discarded – undo
1618 1618
 			$currency
1619 1619
 		);
1620 1620
 
1621
-        if ( isset( $data[$field] ) ) {
1622
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1621
+        if (isset($data[$field])) {
1622
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1623 1623
         }
1624 1624
 
1625 1625
         return $data;
@@ -1632,8 +1632,8 @@  discard block
 block discarded – undo
1632 1632
 	 * @param  string $context View or edit context.
1633 1633
 	 * @return array
1634 1634
 	 */
1635
-	public function get_fees( $context = 'view' ) {
1636
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1635
+	public function get_fees($context = 'view') {
1636
+		return wpinv_parse_list($this->get_prop('fees', $context));
1637 1637
     }
1638 1638
 
1639 1639
     /**
@@ -1643,8 +1643,8 @@  discard block
 block discarded – undo
1643 1643
 	 * @param  string $context View or edit context.
1644 1644
 	 * @return array
1645 1645
 	 */
1646
-	public function get_discounts( $context = 'view' ) {
1647
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1646
+	public function get_discounts($context = 'view') {
1647
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1648 1648
     }
1649 1649
 
1650 1650
     /**
@@ -1654,8 +1654,8 @@  discard block
 block discarded – undo
1654 1654
 	 * @param  string $context View or edit context.
1655 1655
 	 * @return array
1656 1656
 	 */
1657
-	public function get_taxes( $context = 'view' ) {
1658
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1657
+	public function get_taxes($context = 'view') {
1658
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1659 1659
     }
1660 1660
 
1661 1661
     /**
@@ -1665,8 +1665,8 @@  discard block
 block discarded – undo
1665 1665
 	 * @param  string $context View or edit context.
1666 1666
 	 * @return GetPaid_Form_Item[]
1667 1667
 	 */
1668
-	public function get_items( $context = 'view' ) {
1669
-        return $this->get_prop( 'items', $context );
1668
+	public function get_items($context = 'view') {
1669
+        return $this->get_prop('items', $context);
1670 1670
 	}
1671 1671
 
1672 1672
 	/**
@@ -1676,7 +1676,7 @@  discard block
 block discarded – undo
1676 1676
 	 * @return string
1677 1677
 	 */
1678 1678
 	public function get_item_ids() {
1679
-		return implode( ', ', wp_list_pluck( $this->get_cart_details(), 'item_id' ) );
1679
+		return implode(', ', wp_list_pluck($this->get_cart_details(), 'item_id'));
1680 1680
     }
1681 1681
 
1682 1682
     /**
@@ -1686,8 +1686,8 @@  discard block
 block discarded – undo
1686 1686
 	 * @param  string $context View or edit context.
1687 1687
 	 * @return int
1688 1688
 	 */
1689
-	public function get_payment_form( $context = 'view' ) {
1690
-		return intval( $this->get_prop( 'payment_form', $context ) );
1689
+	public function get_payment_form($context = 'view') {
1690
+		return intval($this->get_prop('payment_form', $context));
1691 1691
     }
1692 1692
 
1693 1693
     /**
@@ -1697,8 +1697,8 @@  discard block
 block discarded – undo
1697 1697
 	 * @param  string $context View or edit context.
1698 1698
 	 * @return string
1699 1699
 	 */
1700
-	public function get_submission_id( $context = 'view' ) {
1701
-		return $this->get_prop( 'submission_id', $context );
1700
+	public function get_submission_id($context = 'view') {
1701
+		return $this->get_prop('submission_id', $context);
1702 1702
     }
1703 1703
 
1704 1704
     /**
@@ -1708,8 +1708,8 @@  discard block
 block discarded – undo
1708 1708
 	 * @param  string $context View or edit context.
1709 1709
 	 * @return string
1710 1710
 	 */
1711
-	public function get_discount_code( $context = 'view' ) {
1712
-		return $this->get_prop( 'discount_code', $context );
1711
+	public function get_discount_code($context = 'view') {
1712
+		return $this->get_prop('discount_code', $context);
1713 1713
     }
1714 1714
 
1715 1715
     /**
@@ -1719,8 +1719,8 @@  discard block
 block discarded – undo
1719 1719
 	 * @param  string $context View or edit context.
1720 1720
 	 * @return string
1721 1721
 	 */
1722
-	public function get_gateway( $context = 'view' ) {
1723
-		return $this->get_prop( 'gateway', $context );
1722
+	public function get_gateway($context = 'view') {
1723
+		return $this->get_prop('gateway', $context);
1724 1724
     }
1725 1725
 
1726 1726
     /**
@@ -1730,8 +1730,8 @@  discard block
 block discarded – undo
1730 1730
 	 * @return string
1731 1731
 	 */
1732 1732
     public function get_gateway_title() {
1733
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1734
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1733
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1734
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1735 1735
     }
1736 1736
 
1737 1737
     /**
@@ -1741,8 +1741,8 @@  discard block
 block discarded – undo
1741 1741
 	 * @param  string $context View or edit context.
1742 1742
 	 * @return string
1743 1743
 	 */
1744
-	public function get_transaction_id( $context = 'view' ) {
1745
-		return $this->get_prop( 'transaction_id', $context );
1744
+	public function get_transaction_id($context = 'view') {
1745
+		return $this->get_prop('transaction_id', $context);
1746 1746
     }
1747 1747
 
1748 1748
     /**
@@ -1752,9 +1752,9 @@  discard block
 block discarded – undo
1752 1752
 	 * @param  string $context View or edit context.
1753 1753
 	 * @return string
1754 1754
 	 */
1755
-	public function get_currency( $context = 'view' ) {
1756
-        $currency = $this->get_prop( 'currency', $context );
1757
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1755
+	public function get_currency($context = 'view') {
1756
+        $currency = $this->get_prop('currency', $context);
1757
+        return empty($currency) ? wpinv_get_currency() : $currency;
1758 1758
     }
1759 1759
 
1760 1760
     /**
@@ -1764,8 +1764,8 @@  discard block
 block discarded – undo
1764 1764
 	 * @param  string $context View or edit context.
1765 1765
 	 * @return bool
1766 1766
 	 */
1767
-	public function get_disable_taxes( $context = 'view' ) {
1768
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1767
+	public function get_disable_taxes($context = 'view') {
1768
+        return (bool) $this->get_prop('disable_taxes', $context);
1769 1769
     }
1770 1770
 
1771 1771
     /**
@@ -1775,8 +1775,8 @@  discard block
 block discarded – undo
1775 1775
 	 * @param  string $context View or edit context.
1776 1776
 	 * @return int
1777 1777
 	 */
1778
-    public function get_subscription_id( $context = 'view' ) {
1779
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1778
+    public function get_subscription_id($context = 'view') {
1779
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1780 1780
 	}
1781 1781
 
1782 1782
 	/**
@@ -1786,12 +1786,12 @@  discard block
 block discarded – undo
1786 1786
 	 * @param  string $context View or edit context.
1787 1787
 	 * @return int
1788 1788
 	 */
1789
-    public function get_remote_subscription_id( $context = 'view' ) {
1790
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1789
+    public function get_remote_subscription_id($context = 'view') {
1790
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1791 1791
 
1792
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1792
+        if (empty($subscription_id) && $this->is_renewal()) {
1793 1793
             $parent = $this->get_parent();
1794
-            return $parent->get_remote_subscription_id( $context );
1794
+            return $parent->get_remote_subscription_id($context);
1795 1795
         }
1796 1796
 
1797 1797
         return $subscription_id;
@@ -1804,20 +1804,20 @@  discard block
 block discarded – undo
1804 1804
 	 * @param  string $context View or edit context.
1805 1805
 	 * @return array
1806 1806
 	 */
1807
-    public function get_payment_meta( $context = 'view' ) {
1807
+    public function get_payment_meta($context = 'view') {
1808 1808
 
1809 1809
         return array(
1810
-            'price'        => $this->get_total( $context ),
1811
-            'date'         => $this->get_date_created( $context ),
1812
-            'user_email'   => $this->get_email( $context ),
1813
-            'invoice_key'  => $this->get_key( $context ),
1814
-            'currency'     => $this->get_currency( $context ),
1815
-            'items'        => $this->get_items( $context ),
1816
-            'user_info'    => $this->get_user_info( $context ),
1810
+            'price'        => $this->get_total($context),
1811
+            'date'         => $this->get_date_created($context),
1812
+            'user_email'   => $this->get_email($context),
1813
+            'invoice_key'  => $this->get_key($context),
1814
+            'currency'     => $this->get_currency($context),
1815
+            'items'        => $this->get_items($context),
1816
+            'user_info'    => $this->get_user_info($context),
1817 1817
             'cart_details' => $this->get_cart_details(),
1818
-            'status'       => $this->get_status( $context ),
1819
-            'fees'         => $this->get_fees( $context ),
1820
-            'taxes'        => $this->get_taxes( $context ),
1818
+            'status'       => $this->get_status($context),
1819
+            'fees'         => $this->get_fees($context),
1820
+            'taxes'        => $this->get_taxes($context),
1821 1821
         );
1822 1822
 
1823 1823
     }
@@ -1832,9 +1832,9 @@  discard block
 block discarded – undo
1832 1832
         $items        = $this->get_items();
1833 1833
         $cart_details = array();
1834 1834
 
1835
-        foreach ( $items as $item ) {
1835
+        foreach ($items as $item) {
1836 1836
 			$item->invoice_id = $this->get_id();
1837
-            $cart_details[]   = $item->prepare_data_for_saving();
1837
+            $cart_details[] = $item->prepare_data_for_saving();
1838 1838
         }
1839 1839
 
1840 1840
         return $cart_details;
@@ -1845,11 +1845,11 @@  discard block
 block discarded – undo
1845 1845
 	 *
1846 1846
 	 * @return null|GetPaid_Form_Item|int
1847 1847
 	 */
1848
-	public function get_recurring( $object = false ) {
1848
+	public function get_recurring($object = false) {
1849 1849
 
1850 1850
 		// Are we returning an object?
1851
-        if ( $object ) {
1852
-            return $this->get_item( $this->recurring_item );
1851
+        if ($object) {
1852
+            return $this->get_item($this->recurring_item);
1853 1853
         }
1854 1854
 
1855 1855
         return $this->recurring_item;
@@ -1864,15 +1864,15 @@  discard block
 block discarded – undo
1864 1864
 	public function get_subscription_name() {
1865 1865
 
1866 1866
 		// Retrieve the recurring name
1867
-        $item = $this->get_recurring( true );
1867
+        $item = $this->get_recurring(true);
1868 1868
 
1869 1869
 		// Abort if it does not exist.
1870
-        if ( empty( $item ) ) {
1870
+        if (empty($item)) {
1871 1871
             return '';
1872 1872
         }
1873 1873
 
1874 1874
 		// Return the item name.
1875
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1875
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1876 1876
 	}
1877 1877
 
1878 1878
 	/**
@@ -1882,9 +1882,9 @@  discard block
 block discarded – undo
1882 1882
 	 * @return string
1883 1883
 	 */
1884 1884
 	public function get_view_url() {
1885
-        $invoice_url = get_permalink( $this->get_id() );
1886
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1887
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1885
+        $invoice_url = get_permalink($this->get_id());
1886
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1887
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1888 1888
 	}
1889 1889
 
1890 1890
 	/**
@@ -1893,25 +1893,25 @@  discard block
 block discarded – undo
1893 1893
 	 * @since 1.0.19
1894 1894
 	 * @return string
1895 1895
 	 */
1896
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1896
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1897 1897
 
1898 1898
 		// Retrieve the checkout url.
1899 1899
         $pay_url = wpinv_get_checkout_uri();
1900 1900
 
1901 1901
 		// Maybe force ssl.
1902
-        if ( is_ssl() ) {
1903
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1902
+        if (is_ssl()) {
1903
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1904 1904
         }
1905 1905
 
1906 1906
 		// Add the invoice key.
1907
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1907
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1908 1908
 
1909 1909
 		// (Maybe?) add a secret
1910
-        if ( $secret ) {
1911
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1910
+        if ($secret) {
1911
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1912 1912
         }
1913 1913
 
1914
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1914
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1915 1915
 	}
1916 1916
 	
1917 1917
 	/**
@@ -1926,14 +1926,14 @@  discard block
 block discarded – undo
1926 1926
         $receipt_url = wpinv_get_success_page_uri();
1927 1927
 
1928 1928
 		// Maybe force ssl.
1929
-        if ( is_ssl() ) {
1930
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1929
+        if (is_ssl()) {
1930
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1931 1931
         }
1932 1932
 
1933 1933
 		// Add the invoice key.
1934
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1934
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1935 1935
 
1936
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1936
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1937 1937
 	}
1938 1938
 	
1939 1939
 	/**
@@ -1946,7 +1946,7 @@  discard block
 block discarded – undo
1946 1946
 
1947 1947
 		$type   = $this->get_type();
1948 1948
 		$status = "wpi-$type-pending";
1949
-		return str_replace( '-invoice', '', $status );
1949
+		return str_replace('-invoice', '', $status);
1950 1950
 
1951 1951
 	}
1952 1952
 
@@ -1960,8 +1960,8 @@  discard block
 block discarded – undo
1960 1960
 	 * @param  string $context View or edit context.
1961 1961
 	 * @return mixed Value of the given invoice property (if set).
1962 1962
 	 */
1963
-	public function get( $key, $context = 'view' ) {
1964
-        return $this->get_prop( $key, $context );
1963
+	public function get($key, $context = 'view') {
1964
+        return $this->get_prop($key, $context);
1965 1965
 	}
1966 1966
 
1967 1967
     /*
@@ -1984,11 +1984,11 @@  discard block
 block discarded – undo
1984 1984
 	 * @param  mixed $value new value.
1985 1985
 	 * @return mixed Value of the given invoice property (if set).
1986 1986
 	 */
1987
-	public function set( $key, $value ) {
1987
+	public function set($key, $value) {
1988 1988
 
1989 1989
         $setter = "set_$key";
1990
-        if ( is_callable( array( $this, $setter ) ) ) {
1991
-            $this->{$setter}( $value );
1990
+        if (is_callable(array($this, $setter))) {
1991
+            $this->{$setter}($value);
1992 1992
         }
1993 1993
 
1994 1994
 	}
@@ -2002,45 +2002,45 @@  discard block
 block discarded – undo
2002 2002
 	 * @param bool   $manual_update Is this a manual status change?.
2003 2003
 	 * @return array details of change.
2004 2004
 	 */
2005
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
2005
+	public function set_status($new_status, $note = '', $manual_update = false) {
2006 2006
 		$old_status = $this->get_status();
2007 2007
 
2008 2008
 		$statuses = $this->get_all_statuses();
2009 2009
 
2010
-		if ( isset( $statuses[ 'draft' ] ) ) {
2011
-			unset( $statuses[ 'draft' ] );
2010
+		if (isset($statuses['draft'])) {
2011
+			unset($statuses['draft']);
2012 2012
 		}
2013 2013
 
2014
-		$this->set_prop( 'status', $new_status );
2014
+		$this->set_prop('status', $new_status);
2015 2015
 
2016 2016
 		// If setting the status, ensure it's set to a valid status.
2017
-		if ( true === $this->object_read ) {
2017
+		if (true === $this->object_read) {
2018 2018
 
2019 2019
 			// Only allow valid new status.
2020
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
2020
+			if (!array_key_exists($new_status, $statuses)) {
2021 2021
 				$new_status = $this->get_default_status();
2022 2022
 			}
2023 2023
 
2024 2024
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
2025
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
2025
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
2026 2026
 				$old_status = $this->get_default_status();
2027 2027
 			}
2028 2028
 
2029 2029
 			// Paid - Renewal (i.e when duplicating a parent invoice )
2030
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
2030
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
2031 2031
 				$old_status = 'wpi-pending';
2032 2032
 			}
2033 2033
 
2034
-			if ( $old_status !== $new_status ) {
2034
+			if ($old_status !== $new_status) {
2035 2035
 				$this->status_transition = array(
2036
-					'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
2036
+					'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
2037 2037
 					'to'     => $new_status,
2038 2038
 					'note'   => $note,
2039 2039
 					'manual' => (bool) $manual_update,
2040 2040
 				);
2041 2041
 
2042
-				if ( $manual_update ) {
2043
-					do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
2042
+				if ($manual_update) {
2043
+					do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
2044 2044
 				}
2045 2045
 
2046 2046
 				$this->maybe_set_date_paid();
@@ -2065,8 +2065,8 @@  discard block
 block discarded – undo
2065 2065
 	 */
2066 2066
 	public function maybe_set_date_paid() {
2067 2067
 
2068
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
2069
-			$this->set_date_completed( current_time( 'mysql' ) );
2068
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
2069
+			$this->set_date_completed(current_time('mysql'));
2070 2070
 		}
2071 2071
 	}
2072 2072
 
@@ -2075,11 +2075,11 @@  discard block
 block discarded – undo
2075 2075
 	 *
2076 2076
 	 * @since 1.0.19
2077 2077
 	 */
2078
-	public function set_parent_id( $value ) {
2079
-		if ( $value && ( $value === $this->get_id() ) ) {
2078
+	public function set_parent_id($value) {
2079
+		if ($value && ($value === $this->get_id())) {
2080 2080
 			return;
2081 2081
 		}
2082
-		$this->set_prop( 'parent_id', absint( $value ) );
2082
+		$this->set_prop('parent_id', absint($value));
2083 2083
     }
2084 2084
 
2085 2085
     /**
@@ -2087,8 +2087,8 @@  discard block
 block discarded – undo
2087 2087
 	 *
2088 2088
 	 * @since 1.0.19
2089 2089
 	 */
2090
-	public function set_version( $value ) {
2091
-		$this->set_prop( 'version', $value );
2090
+	public function set_version($value) {
2091
+		$this->set_prop('version', $value);
2092 2092
     }
2093 2093
 
2094 2094
     /**
@@ -2098,15 +2098,15 @@  discard block
 block discarded – undo
2098 2098
 	 * @param string $value Value to set.
2099 2099
      * @return bool Whether or not the date was set.
2100 2100
 	 */
2101
-	public function set_date_created( $value ) {
2102
-        $date = strtotime( $value );
2101
+	public function set_date_created($value) {
2102
+        $date = strtotime($value);
2103 2103
 
2104
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2105
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
2104
+        if ($date && $value !== '0000-00-00 00:00:00') {
2105
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
2106 2106
             return true;
2107 2107
         }
2108 2108
 
2109
-		$this->set_prop( 'date_created', '' );
2109
+		$this->set_prop('date_created', '');
2110 2110
 		return false;
2111 2111
 
2112 2112
     }
@@ -2118,15 +2118,15 @@  discard block
 block discarded – undo
2118 2118
 	 * @param string $value Value to set.
2119 2119
      * @return bool Whether or not the date was set.
2120 2120
 	 */
2121
-	public function set_due_date( $value ) {
2122
-        $date = strtotime( $value );
2121
+	public function set_due_date($value) {
2122
+        $date = strtotime($value);
2123 2123
 
2124
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2125
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
2124
+        if ($date && $value !== '0000-00-00 00:00:00') {
2125
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
2126 2126
             return true;
2127 2127
         }
2128 2128
 
2129
-		$this->set_prop( 'due_date', '' );
2129
+		$this->set_prop('due_date', '');
2130 2130
         return false;
2131 2131
 
2132 2132
     }
@@ -2137,8 +2137,8 @@  discard block
 block discarded – undo
2137 2137
 	 * @since 1.0.19
2138 2138
 	 * @param  string $value New name.
2139 2139
 	 */
2140
-	public function set_date_due( $value ) {
2141
-		$this->set_due_date( $value );
2140
+	public function set_date_due($value) {
2141
+		$this->set_due_date($value);
2142 2142
     }
2143 2143
 
2144 2144
     /**
@@ -2148,15 +2148,15 @@  discard block
 block discarded – undo
2148 2148
 	 * @param string $value Value to set.
2149 2149
      * @return bool Whether or not the date was set.
2150 2150
 	 */
2151
-	public function set_completed_date( $value ) {
2152
-        $date = strtotime( $value );
2151
+	public function set_completed_date($value) {
2152
+        $date = strtotime($value);
2153 2153
 
2154
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
2155
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2154
+        if ($date && $value !== '0000-00-00 00:00:00') {
2155
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2156 2156
             return true;
2157 2157
         }
2158 2158
 
2159
-		$this->set_prop( 'completed_date', '' );
2159
+		$this->set_prop('completed_date', '');
2160 2160
         return false;
2161 2161
 
2162 2162
     }
@@ -2167,8 +2167,8 @@  discard block
 block discarded – undo
2167 2167
 	 * @since 1.0.19
2168 2168
 	 * @param  string $value New name.
2169 2169
 	 */
2170
-	public function set_date_completed( $value ) {
2171
-		$this->set_completed_date( $value );
2170
+	public function set_date_completed($value) {
2171
+		$this->set_completed_date($value);
2172 2172
     }
2173 2173
 
2174 2174
     /**
@@ -2178,15 +2178,15 @@  discard block
 block discarded – undo
2178 2178
 	 * @param string $value Value to set.
2179 2179
      * @return bool Whether or not the date was set.
2180 2180
 	 */
2181
-	public function set_date_modified( $value ) {
2182
-        $date = strtotime( $value );
2181
+	public function set_date_modified($value) {
2182
+        $date = strtotime($value);
2183 2183
 
2184
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2185
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2184
+        if ($date && $value !== '0000-00-00 00:00:00') {
2185
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2186 2186
             return true;
2187 2187
         }
2188 2188
 
2189
-		$this->set_prop( 'date_modified', '' );
2189
+		$this->set_prop('date_modified', '');
2190 2190
         return false;
2191 2191
 
2192 2192
     }
@@ -2197,9 +2197,9 @@  discard block
 block discarded – undo
2197 2197
 	 * @since 1.0.19
2198 2198
 	 * @param  string $value New number.
2199 2199
 	 */
2200
-	public function set_number( $value ) {
2201
-        $number = sanitize_text_field( $value );
2202
-		$this->set_prop( 'number', $number );
2200
+	public function set_number($value) {
2201
+        $number = sanitize_text_field($value);
2202
+		$this->set_prop('number', $number);
2203 2203
     }
2204 2204
 
2205 2205
     /**
@@ -2208,9 +2208,9 @@  discard block
 block discarded – undo
2208 2208
 	 * @since 1.0.19
2209 2209
 	 * @param  string $value Type.
2210 2210
 	 */
2211
-	public function set_type( $value ) {
2212
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2213
-		$this->set_prop( 'type', $type );
2211
+	public function set_type($value) {
2212
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2213
+		$this->set_prop('type', $type);
2214 2214
 	}
2215 2215
 
2216 2216
     /**
@@ -2219,10 +2219,10 @@  discard block
 block discarded – undo
2219 2219
 	 * @since 1.0.19
2220 2220
 	 * @param  string $value Post type.
2221 2221
 	 */
2222
-	public function set_post_type( $value ) {
2223
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2224
-			$this->set_type( $value );
2225
-            $this->set_prop( 'post_type', $value );
2222
+	public function set_post_type($value) {
2223
+        if (getpaid_is_invoice_post_type($value)) {
2224
+			$this->set_type($value);
2225
+            $this->set_prop('post_type', $value);
2226 2226
         }
2227 2227
     }
2228 2228
 
@@ -2232,9 +2232,9 @@  discard block
 block discarded – undo
2232 2232
 	 * @since 1.0.19
2233 2233
 	 * @param  string $value New key.
2234 2234
 	 */
2235
-	public function set_key( $value ) {
2236
-        $key = sanitize_text_field( $value );
2237
-		$this->set_prop( 'key', $key );
2235
+	public function set_key($value) {
2236
+        $key = sanitize_text_field($value);
2237
+		$this->set_prop('key', $key);
2238 2238
     }
2239 2239
 
2240 2240
     /**
@@ -2243,9 +2243,9 @@  discard block
 block discarded – undo
2243 2243
 	 * @since 1.0.19
2244 2244
 	 * @param  string $value mode.
2245 2245
 	 */
2246
-	public function set_mode( $value ) {
2247
-        if ( in_array( $value, array( 'live', 'test' ) ) ) {
2248
-            $this->set_prop( 'mode', $value );
2246
+	public function set_mode($value) {
2247
+        if (in_array($value, array('live', 'test'))) {
2248
+            $this->set_prop('mode', $value);
2249 2249
         }
2250 2250
     }
2251 2251
 
@@ -2255,8 +2255,8 @@  discard block
 block discarded – undo
2255 2255
 	 * @since 1.0.19
2256 2256
 	 * @param  string $value path.
2257 2257
 	 */
2258
-	public function set_path( $value ) {
2259
-        $this->set_prop( 'path', $value );
2258
+	public function set_path($value) {
2259
+        $this->set_prop('path', $value);
2260 2260
     }
2261 2261
 
2262 2262
     /**
@@ -2265,9 +2265,9 @@  discard block
 block discarded – undo
2265 2265
 	 * @since 1.0.19
2266 2266
 	 * @param  string $value New name.
2267 2267
 	 */
2268
-	public function set_name( $value ) {
2269
-        $name = sanitize_text_field( $value );
2270
-		$this->set_prop( 'name', $name );
2268
+	public function set_name($value) {
2269
+        $name = sanitize_text_field($value);
2270
+		$this->set_prop('name', $name);
2271 2271
     }
2272 2272
 
2273 2273
     /**
@@ -2276,8 +2276,8 @@  discard block
 block discarded – undo
2276 2276
 	 * @since 1.0.19
2277 2277
 	 * @param  string $value New name.
2278 2278
 	 */
2279
-	public function set_title( $value ) {
2280
-		$this->set_name( $value );
2279
+	public function set_title($value) {
2280
+		$this->set_name($value);
2281 2281
     }
2282 2282
 
2283 2283
     /**
@@ -2286,9 +2286,9 @@  discard block
 block discarded – undo
2286 2286
 	 * @since 1.0.19
2287 2287
 	 * @param  string $value New description.
2288 2288
 	 */
2289
-	public function set_description( $value ) {
2290
-        $description = wp_kses_post( $value );
2291
-		$this->set_prop( 'description', $description );
2289
+	public function set_description($value) {
2290
+        $description = wp_kses_post($value);
2291
+		$this->set_prop('description', $description);
2292 2292
     }
2293 2293
 
2294 2294
     /**
@@ -2297,8 +2297,8 @@  discard block
 block discarded – undo
2297 2297
 	 * @since 1.0.19
2298 2298
 	 * @param  string $value New description.
2299 2299
 	 */
2300
-	public function set_excerpt( $value ) {
2301
-		$this->set_description( $value );
2300
+	public function set_excerpt($value) {
2301
+		$this->set_description($value);
2302 2302
     }
2303 2303
 
2304 2304
     /**
@@ -2307,8 +2307,8 @@  discard block
 block discarded – undo
2307 2307
 	 * @since 1.0.19
2308 2308
 	 * @param  string $value New description.
2309 2309
 	 */
2310
-	public function set_summary( $value ) {
2311
-		$this->set_description( $value );
2310
+	public function set_summary($value) {
2311
+		$this->set_description($value);
2312 2312
     }
2313 2313
 
2314 2314
     /**
@@ -2317,12 +2317,12 @@  discard block
 block discarded – undo
2317 2317
 	 * @since 1.0.19
2318 2318
 	 * @param  int $value New author.
2319 2319
 	 */
2320
-	public function set_author( $value ) {
2321
-		$user = get_user_by( 'id', (int) $value );
2320
+	public function set_author($value) {
2321
+		$user = get_user_by('id', (int) $value);
2322 2322
 
2323
-		if ( $user && $user->ID ) {
2324
-			$this->set_prop( 'author', $user->ID );
2325
-			$this->set_prop( 'email', $user->user_email );
2323
+		if ($user && $user->ID) {
2324
+			$this->set_prop('author', $user->ID);
2325
+			$this->set_prop('email', $user->user_email);
2326 2326
 		}
2327 2327
 
2328 2328
     }
@@ -2333,8 +2333,8 @@  discard block
 block discarded – undo
2333 2333
 	 * @since 1.0.19
2334 2334
 	 * @param  int $value New user id.
2335 2335
 	 */
2336
-	public function set_user_id( $value ) {
2337
-		$this->set_author( $value );
2336
+	public function set_user_id($value) {
2337
+		$this->set_author($value);
2338 2338
     }
2339 2339
 
2340 2340
     /**
@@ -2343,8 +2343,8 @@  discard block
 block discarded – undo
2343 2343
 	 * @since 1.0.19
2344 2344
 	 * @param  int $value New user id.
2345 2345
 	 */
2346
-	public function set_customer_id( $value ) {
2347
-		$this->set_author( $value );
2346
+	public function set_customer_id($value) {
2347
+		$this->set_author($value);
2348 2348
     }
2349 2349
 
2350 2350
     /**
@@ -2353,8 +2353,8 @@  discard block
 block discarded – undo
2353 2353
 	 * @since 1.0.19
2354 2354
 	 * @param  string $value ip address.
2355 2355
 	 */
2356
-	public function set_ip( $value ) {
2357
-		$this->set_prop( 'ip', $value );
2356
+	public function set_ip($value) {
2357
+		$this->set_prop('ip', $value);
2358 2358
     }
2359 2359
 
2360 2360
     /**
@@ -2363,8 +2363,8 @@  discard block
 block discarded – undo
2363 2363
 	 * @since 1.0.19
2364 2364
 	 * @param  string $value ip address.
2365 2365
 	 */
2366
-	public function set_user_ip( $value ) {
2367
-		$this->set_ip( $value );
2366
+	public function set_user_ip($value) {
2367
+		$this->set_ip($value);
2368 2368
     }
2369 2369
 
2370 2370
     /**
@@ -2373,8 +2373,8 @@  discard block
 block discarded – undo
2373 2373
 	 * @since 1.0.19
2374 2374
 	 * @param  string $value first name.
2375 2375
 	 */
2376
-	public function set_first_name( $value ) {
2377
-		$this->set_prop( 'first_name', $value );
2376
+	public function set_first_name($value) {
2377
+		$this->set_prop('first_name', $value);
2378 2378
     }
2379 2379
 
2380 2380
     /**
@@ -2383,8 +2383,8 @@  discard block
 block discarded – undo
2383 2383
 	 * @since 1.0.19
2384 2384
 	 * @param  string $value first name.
2385 2385
 	 */
2386
-	public function set_user_first_name( $value ) {
2387
-		$this->set_first_name( $value );
2386
+	public function set_user_first_name($value) {
2387
+		$this->set_first_name($value);
2388 2388
     }
2389 2389
 
2390 2390
     /**
@@ -2393,8 +2393,8 @@  discard block
 block discarded – undo
2393 2393
 	 * @since 1.0.19
2394 2394
 	 * @param  string $value first name.
2395 2395
 	 */
2396
-	public function set_customer_first_name( $value ) {
2397
-		$this->set_first_name( $value );
2396
+	public function set_customer_first_name($value) {
2397
+		$this->set_first_name($value);
2398 2398
     }
2399 2399
 
2400 2400
     /**
@@ -2403,8 +2403,8 @@  discard block
 block discarded – undo
2403 2403
 	 * @since 1.0.19
2404 2404
 	 * @param  string $value last name.
2405 2405
 	 */
2406
-	public function set_last_name( $value ) {
2407
-		$this->set_prop( 'last_name', $value );
2406
+	public function set_last_name($value) {
2407
+		$this->set_prop('last_name', $value);
2408 2408
     }
2409 2409
 
2410 2410
     /**
@@ -2413,8 +2413,8 @@  discard block
 block discarded – undo
2413 2413
 	 * @since 1.0.19
2414 2414
 	 * @param  string $value last name.
2415 2415
 	 */
2416
-	public function set_user_last_name( $value ) {
2417
-		$this->set_last_name( $value );
2416
+	public function set_user_last_name($value) {
2417
+		$this->set_last_name($value);
2418 2418
     }
2419 2419
 
2420 2420
     /**
@@ -2423,8 +2423,8 @@  discard block
 block discarded – undo
2423 2423
 	 * @since 1.0.19
2424 2424
 	 * @param  string $value last name.
2425 2425
 	 */
2426
-	public function set_customer_last_name( $value ) {
2427
-		$this->set_last_name( $value );
2426
+	public function set_customer_last_name($value) {
2427
+		$this->set_last_name($value);
2428 2428
     }
2429 2429
 
2430 2430
     /**
@@ -2433,8 +2433,8 @@  discard block
 block discarded – undo
2433 2433
 	 * @since 1.0.19
2434 2434
 	 * @param  string $value phone.
2435 2435
 	 */
2436
-	public function set_phone( $value ) {
2437
-		$this->set_prop( 'phone', $value );
2436
+	public function set_phone($value) {
2437
+		$this->set_prop('phone', $value);
2438 2438
     }
2439 2439
 
2440 2440
     /**
@@ -2443,8 +2443,8 @@  discard block
 block discarded – undo
2443 2443
 	 * @since 1.0.19
2444 2444
 	 * @param  string $value phone.
2445 2445
 	 */
2446
-	public function set_user_phone( $value ) {
2447
-		$this->set_phone( $value );
2446
+	public function set_user_phone($value) {
2447
+		$this->set_phone($value);
2448 2448
     }
2449 2449
 
2450 2450
     /**
@@ -2453,8 +2453,8 @@  discard block
 block discarded – undo
2453 2453
 	 * @since 1.0.19
2454 2454
 	 * @param  string $value phone.
2455 2455
 	 */
2456
-	public function set_customer_phone( $value ) {
2457
-		$this->set_phone( $value );
2456
+	public function set_customer_phone($value) {
2457
+		$this->set_phone($value);
2458 2458
     }
2459 2459
 
2460 2460
     /**
@@ -2463,8 +2463,8 @@  discard block
 block discarded – undo
2463 2463
 	 * @since 1.0.19
2464 2464
 	 * @param  string $value phone.
2465 2465
 	 */
2466
-	public function set_phone_number( $value ) {
2467
-		$this->set_phone( $value );
2466
+	public function set_phone_number($value) {
2467
+		$this->set_phone($value);
2468 2468
     }
2469 2469
 
2470 2470
     /**
@@ -2473,8 +2473,8 @@  discard block
 block discarded – undo
2473 2473
 	 * @since 1.0.19
2474 2474
 	 * @param  string $value email address.
2475 2475
 	 */
2476
-	public function set_email( $value ) {
2477
-		$this->set_prop( 'email', $value );
2476
+	public function set_email($value) {
2477
+		$this->set_prop('email', $value);
2478 2478
     }
2479 2479
 
2480 2480
     /**
@@ -2483,8 +2483,8 @@  discard block
 block discarded – undo
2483 2483
 	 * @since 1.0.19
2484 2484
 	 * @param  string $value email address.
2485 2485
 	 */
2486
-	public function set_user_email( $value ) {
2487
-		$this->set_email( $value );
2486
+	public function set_user_email($value) {
2487
+		$this->set_email($value);
2488 2488
     }
2489 2489
 
2490 2490
     /**
@@ -2493,8 +2493,8 @@  discard block
 block discarded – undo
2493 2493
 	 * @since 1.0.19
2494 2494
 	 * @param  string $value email address.
2495 2495
 	 */
2496
-	public function set_email_address( $value ) {
2497
-		$this->set_email( $value );
2496
+	public function set_email_address($value) {
2497
+		$this->set_email($value);
2498 2498
     }
2499 2499
 
2500 2500
     /**
@@ -2503,8 +2503,8 @@  discard block
 block discarded – undo
2503 2503
 	 * @since 1.0.19
2504 2504
 	 * @param  string $value email address.
2505 2505
 	 */
2506
-	public function set_customer_email( $value ) {
2507
-		$this->set_email( $value );
2506
+	public function set_customer_email($value) {
2507
+		$this->set_email($value);
2508 2508
     }
2509 2509
 
2510 2510
     /**
@@ -2513,8 +2513,8 @@  discard block
 block discarded – undo
2513 2513
 	 * @since 1.0.19
2514 2514
 	 * @param  string $value country.
2515 2515
 	 */
2516
-	public function set_country( $value ) {
2517
-		$this->set_prop( 'country', $value );
2516
+	public function set_country($value) {
2517
+		$this->set_prop('country', $value);
2518 2518
     }
2519 2519
 
2520 2520
     /**
@@ -2523,8 +2523,8 @@  discard block
 block discarded – undo
2523 2523
 	 * @since 1.0.19
2524 2524
 	 * @param  string $value country.
2525 2525
 	 */
2526
-	public function set_user_country( $value ) {
2527
-		$this->set_country( $value );
2526
+	public function set_user_country($value) {
2527
+		$this->set_country($value);
2528 2528
     }
2529 2529
 
2530 2530
     /**
@@ -2533,8 +2533,8 @@  discard block
 block discarded – undo
2533 2533
 	 * @since 1.0.19
2534 2534
 	 * @param  string $value country.
2535 2535
 	 */
2536
-	public function set_customer_country( $value ) {
2537
-		$this->set_country( $value );
2536
+	public function set_customer_country($value) {
2537
+		$this->set_country($value);
2538 2538
     }
2539 2539
 
2540 2540
     /**
@@ -2543,8 +2543,8 @@  discard block
 block discarded – undo
2543 2543
 	 * @since 1.0.19
2544 2544
 	 * @param  string $value state.
2545 2545
 	 */
2546
-	public function set_state( $value ) {
2547
-		$this->set_prop( 'state', $value );
2546
+	public function set_state($value) {
2547
+		$this->set_prop('state', $value);
2548 2548
     }
2549 2549
 
2550 2550
     /**
@@ -2553,8 +2553,8 @@  discard block
 block discarded – undo
2553 2553
 	 * @since 1.0.19
2554 2554
 	 * @param  string $value state.
2555 2555
 	 */
2556
-	public function set_user_state( $value ) {
2557
-		$this->set_state( $value );
2556
+	public function set_user_state($value) {
2557
+		$this->set_state($value);
2558 2558
     }
2559 2559
 
2560 2560
     /**
@@ -2563,8 +2563,8 @@  discard block
 block discarded – undo
2563 2563
 	 * @since 1.0.19
2564 2564
 	 * @param  string $value state.
2565 2565
 	 */
2566
-	public function set_customer_state( $value ) {
2567
-		$this->set_state( $value );
2566
+	public function set_customer_state($value) {
2567
+		$this->set_state($value);
2568 2568
     }
2569 2569
 
2570 2570
     /**
@@ -2573,8 +2573,8 @@  discard block
 block discarded – undo
2573 2573
 	 * @since 1.0.19
2574 2574
 	 * @param  string $value city.
2575 2575
 	 */
2576
-	public function set_city( $value ) {
2577
-		$this->set_prop( 'city', $value );
2576
+	public function set_city($value) {
2577
+		$this->set_prop('city', $value);
2578 2578
     }
2579 2579
 
2580 2580
     /**
@@ -2583,8 +2583,8 @@  discard block
 block discarded – undo
2583 2583
 	 * @since 1.0.19
2584 2584
 	 * @param  string $value city.
2585 2585
 	 */
2586
-	public function set_user_city( $value ) {
2587
-		$this->set_city( $value );
2586
+	public function set_user_city($value) {
2587
+		$this->set_city($value);
2588 2588
     }
2589 2589
 
2590 2590
     /**
@@ -2593,8 +2593,8 @@  discard block
 block discarded – undo
2593 2593
 	 * @since 1.0.19
2594 2594
 	 * @param  string $value city.
2595 2595
 	 */
2596
-	public function set_customer_city( $value ) {
2597
-		$this->set_city( $value );
2596
+	public function set_customer_city($value) {
2597
+		$this->set_city($value);
2598 2598
     }
2599 2599
 
2600 2600
     /**
@@ -2603,8 +2603,8 @@  discard block
 block discarded – undo
2603 2603
 	 * @since 1.0.19
2604 2604
 	 * @param  string $value zip.
2605 2605
 	 */
2606
-	public function set_zip( $value ) {
2607
-		$this->set_prop( 'zip', $value );
2606
+	public function set_zip($value) {
2607
+		$this->set_prop('zip', $value);
2608 2608
     }
2609 2609
 
2610 2610
     /**
@@ -2613,8 +2613,8 @@  discard block
 block discarded – undo
2613 2613
 	 * @since 1.0.19
2614 2614
 	 * @param  string $value zip.
2615 2615
 	 */
2616
-	public function set_user_zip( $value ) {
2617
-		$this->set_zip( $value );
2616
+	public function set_user_zip($value) {
2617
+		$this->set_zip($value);
2618 2618
     }
2619 2619
 
2620 2620
     /**
@@ -2623,8 +2623,8 @@  discard block
 block discarded – undo
2623 2623
 	 * @since 1.0.19
2624 2624
 	 * @param  string $value zip.
2625 2625
 	 */
2626
-	public function set_customer_zip( $value ) {
2627
-		$this->set_zip( $value );
2626
+	public function set_customer_zip($value) {
2627
+		$this->set_zip($value);
2628 2628
     }
2629 2629
 
2630 2630
     /**
@@ -2633,8 +2633,8 @@  discard block
 block discarded – undo
2633 2633
 	 * @since 1.0.19
2634 2634
 	 * @param  string $value company.
2635 2635
 	 */
2636
-	public function set_company( $value ) {
2637
-		$this->set_prop( 'company', $value );
2636
+	public function set_company($value) {
2637
+		$this->set_prop('company', $value);
2638 2638
     }
2639 2639
 
2640 2640
     /**
@@ -2643,8 +2643,8 @@  discard block
 block discarded – undo
2643 2643
 	 * @since 1.0.19
2644 2644
 	 * @param  string $value company.
2645 2645
 	 */
2646
-	public function set_user_company( $value ) {
2647
-		$this->set_company( $value );
2646
+	public function set_user_company($value) {
2647
+		$this->set_company($value);
2648 2648
     }
2649 2649
 
2650 2650
     /**
@@ -2653,8 +2653,8 @@  discard block
 block discarded – undo
2653 2653
 	 * @since 1.0.19
2654 2654
 	 * @param  string $value company.
2655 2655
 	 */
2656
-	public function set_customer_company( $value ) {
2657
-		$this->set_company( $value );
2656
+	public function set_customer_company($value) {
2657
+		$this->set_company($value);
2658 2658
     }
2659 2659
 
2660 2660
 	/**
@@ -2663,8 +2663,8 @@  discard block
 block discarded – undo
2663 2663
 	 * @since 1.0.19
2664 2664
 	 * @param  string $value company id.
2665 2665
 	 */
2666
-	public function set_company_id( $value ) {
2667
-		$this->set_prop( 'company_id', $value );
2666
+	public function set_company_id($value) {
2667
+		$this->set_prop('company_id', $value);
2668 2668
     }
2669 2669
 
2670 2670
     /**
@@ -2673,8 +2673,8 @@  discard block
 block discarded – undo
2673 2673
 	 * @since 1.0.19
2674 2674
 	 * @param  string $value var number.
2675 2675
 	 */
2676
-	public function set_vat_number( $value ) {
2677
-		$this->set_prop( 'vat_number', $value );
2676
+	public function set_vat_number($value) {
2677
+		$this->set_prop('vat_number', $value);
2678 2678
     }
2679 2679
 
2680 2680
     /**
@@ -2683,8 +2683,8 @@  discard block
 block discarded – undo
2683 2683
 	 * @since 1.0.19
2684 2684
 	 * @param  string $value var number.
2685 2685
 	 */
2686
-	public function set_user_vat_number( $value ) {
2687
-		$this->set_vat_number( $value );
2686
+	public function set_user_vat_number($value) {
2687
+		$this->set_vat_number($value);
2688 2688
     }
2689 2689
 
2690 2690
     /**
@@ -2693,8 +2693,8 @@  discard block
 block discarded – undo
2693 2693
 	 * @since 1.0.19
2694 2694
 	 * @param  string $value var number.
2695 2695
 	 */
2696
-	public function set_customer_vat_number( $value ) {
2697
-		$this->set_vat_number( $value );
2696
+	public function set_customer_vat_number($value) {
2697
+		$this->set_vat_number($value);
2698 2698
     }
2699 2699
 
2700 2700
     /**
@@ -2703,8 +2703,8 @@  discard block
 block discarded – undo
2703 2703
 	 * @since 1.0.19
2704 2704
 	 * @param  string $value var rate.
2705 2705
 	 */
2706
-	public function set_vat_rate( $value ) {
2707
-		$this->set_prop( 'vat_rate', $value );
2706
+	public function set_vat_rate($value) {
2707
+		$this->set_prop('vat_rate', $value);
2708 2708
     }
2709 2709
 
2710 2710
     /**
@@ -2713,8 +2713,8 @@  discard block
 block discarded – undo
2713 2713
 	 * @since 1.0.19
2714 2714
 	 * @param  string $value var number.
2715 2715
 	 */
2716
-	public function set_user_vat_rate( $value ) {
2717
-		$this->set_vat_rate( $value );
2716
+	public function set_user_vat_rate($value) {
2717
+		$this->set_vat_rate($value);
2718 2718
     }
2719 2719
 
2720 2720
     /**
@@ -2723,8 +2723,8 @@  discard block
 block discarded – undo
2723 2723
 	 * @since 1.0.19
2724 2724
 	 * @param  string $value var number.
2725 2725
 	 */
2726
-	public function set_customer_vat_rate( $value ) {
2727
-		$this->set_vat_rate( $value );
2726
+	public function set_customer_vat_rate($value) {
2727
+		$this->set_vat_rate($value);
2728 2728
     }
2729 2729
 
2730 2730
     /**
@@ -2733,8 +2733,8 @@  discard block
 block discarded – undo
2733 2733
 	 * @since 1.0.19
2734 2734
 	 * @param  string $value address.
2735 2735
 	 */
2736
-	public function set_address( $value ) {
2737
-		$this->set_prop( 'address', $value );
2736
+	public function set_address($value) {
2737
+		$this->set_prop('address', $value);
2738 2738
     }
2739 2739
 
2740 2740
     /**
@@ -2743,8 +2743,8 @@  discard block
 block discarded – undo
2743 2743
 	 * @since 1.0.19
2744 2744
 	 * @param  string $value address.
2745 2745
 	 */
2746
-	public function set_user_address( $value ) {
2747
-		$this->set_address( $value );
2746
+	public function set_user_address($value) {
2747
+		$this->set_address($value);
2748 2748
     }
2749 2749
 
2750 2750
     /**
@@ -2753,8 +2753,8 @@  discard block
 block discarded – undo
2753 2753
 	 * @since 1.0.19
2754 2754
 	 * @param  string $value address.
2755 2755
 	 */
2756
-	public function set_customer_address( $value ) {
2757
-		$this->set_address( $value );
2756
+	public function set_customer_address($value) {
2757
+		$this->set_address($value);
2758 2758
     }
2759 2759
 
2760 2760
     /**
@@ -2763,8 +2763,8 @@  discard block
 block discarded – undo
2763 2763
 	 * @since 1.0.19
2764 2764
 	 * @param  int|bool $value confirmed.
2765 2765
 	 */
2766
-	public function set_is_viewed( $value ) {
2767
-		$this->set_prop( 'is_viewed', $value );
2766
+	public function set_is_viewed($value) {
2767
+		$this->set_prop('is_viewed', $value);
2768 2768
 	}
2769 2769
 
2770 2770
 	/**
@@ -2773,8 +2773,8 @@  discard block
 block discarded – undo
2773 2773
 	 * @since 1.0.19
2774 2774
 	 * @param  string $value email recipients.
2775 2775
 	 */
2776
-	public function set_email_cc( $value ) {
2777
-		$this->set_prop( 'email_cc', $value );
2776
+	public function set_email_cc($value) {
2777
+		$this->set_prop('email_cc', $value);
2778 2778
 	}
2779 2779
 
2780 2780
 	/**
@@ -2783,9 +2783,9 @@  discard block
 block discarded – undo
2783 2783
 	 * @since 1.0.19
2784 2784
 	 * @param  string $value template.
2785 2785
 	 */
2786
-	public function set_template( $value ) {
2787
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2788
-			$this->set_prop( 'template', $value );
2786
+	public function set_template($value) {
2787
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2788
+			$this->set_prop('template', $value);
2789 2789
 		}
2790 2790
 	}
2791 2791
 
@@ -2796,8 +2796,8 @@  discard block
 block discarded – undo
2796 2796
 	 * @param  string $value source.
2797 2797
 	 * @deprecated
2798 2798
 	 */
2799
-	public function created_via( $value ) {
2800
-		$this->set_created_via( sanitize_text_field( $value ) );
2799
+	public function created_via($value) {
2800
+		$this->set_created_via(sanitize_text_field($value));
2801 2801
 	}
2802 2802
 
2803 2803
 	/**
@@ -2806,8 +2806,8 @@  discard block
 block discarded – undo
2806 2806
 	 * @since 1.0.19
2807 2807
 	 * @param  string $value source.
2808 2808
 	 */
2809
-	public function set_created_via( $value ) {
2810
-		$this->set_prop( 'created_via', sanitize_text_field( $value ) );
2809
+	public function set_created_via($value) {
2810
+		$this->set_prop('created_via', sanitize_text_field($value));
2811 2811
 	}
2812 2812
 
2813 2813
 	/**
@@ -2816,8 +2816,8 @@  discard block
 block discarded – undo
2816 2816
 	 * @since 1.0.19
2817 2817
 	 * @param  int|bool $value confirmed.
2818 2818
 	 */
2819
-	public function set_address_confirmed( $value ) {
2820
-		$this->set_prop( 'address_confirmed', $value );
2819
+	public function set_address_confirmed($value) {
2820
+		$this->set_prop('address_confirmed', $value);
2821 2821
     }
2822 2822
 
2823 2823
     /**
@@ -2826,8 +2826,8 @@  discard block
 block discarded – undo
2826 2826
 	 * @since 1.0.19
2827 2827
 	 * @param  int|bool $value confirmed.
2828 2828
 	 */
2829
-	public function set_user_address_confirmed( $value ) {
2830
-		$this->set_address_confirmed( $value );
2829
+	public function set_user_address_confirmed($value) {
2830
+		$this->set_address_confirmed($value);
2831 2831
     }
2832 2832
 
2833 2833
     /**
@@ -2836,8 +2836,8 @@  discard block
 block discarded – undo
2836 2836
 	 * @since 1.0.19
2837 2837
 	 * @param  int|bool $value confirmed.
2838 2838
 	 */
2839
-	public function set_customer_address_confirmed( $value ) {
2840
-		$this->set_address_confirmed( $value );
2839
+	public function set_customer_address_confirmed($value) {
2840
+		$this->set_address_confirmed($value);
2841 2841
     }
2842 2842
 
2843 2843
     /**
@@ -2846,13 +2846,13 @@  discard block
 block discarded – undo
2846 2846
 	 * @since 1.0.19
2847 2847
 	 * @param  float $value shipping amount.
2848 2848
 	 */
2849
-	public function set_shipping( $value ) {
2849
+	public function set_shipping($value) {
2850 2850
 
2851
-		if ( ! is_numeric( $value ) ) {
2852
-			return $this->set_prop( 'shipping', null );
2851
+		if (!is_numeric($value)) {
2852
+			return $this->set_prop('shipping', null);
2853 2853
 		}
2854 2854
 
2855
-		$this->set_prop( 'shipping', max( 0, floatval( $value ) ) );
2855
+		$this->set_prop('shipping', max(0, floatval($value)));
2856 2856
 	}
2857 2857
 
2858 2858
 	/**
@@ -2861,8 +2861,8 @@  discard block
 block discarded – undo
2861 2861
 	 * @since 1.0.19
2862 2862
 	 * @param  float $value sub total.
2863 2863
 	 */
2864
-	public function set_subtotal( $value ) {
2865
-		$this->set_prop( 'subtotal', max( 0, $value ) );
2864
+	public function set_subtotal($value) {
2865
+		$this->set_prop('subtotal', max(0, $value));
2866 2866
 	}
2867 2867
 
2868 2868
 	/**
@@ -2871,8 +2871,8 @@  discard block
 block discarded – undo
2871 2871
 	 * @since 1.0.19
2872 2872
 	 * @param  float $value sub total.
2873 2873
 	 */
2874
-	public function set_total( $value ) {
2875
-		$this->set_prop( 'total', max( 0, $value ) );
2874
+	public function set_total($value) {
2875
+		$this->set_prop('total', max(0, $value));
2876 2876
     }
2877 2877
 
2878 2878
     /**
@@ -2881,8 +2881,8 @@  discard block
 block discarded – undo
2881 2881
 	 * @since 1.0.19
2882 2882
 	 * @param  float $value discount total.
2883 2883
 	 */
2884
-	public function set_total_discount( $value ) {
2885
-		$this->set_prop( 'total_discount', max( 0, $value ) );
2884
+	public function set_total_discount($value) {
2885
+		$this->set_prop('total_discount', max(0, $value));
2886 2886
     }
2887 2887
 
2888 2888
     /**
@@ -2891,8 +2891,8 @@  discard block
 block discarded – undo
2891 2891
 	 * @since 1.0.19
2892 2892
 	 * @param  float $value discount total.
2893 2893
 	 */
2894
-	public function set_discount( $value ) {
2895
-		$this->set_total_discount( $value );
2894
+	public function set_discount($value) {
2895
+		$this->set_total_discount($value);
2896 2896
     }
2897 2897
 
2898 2898
     /**
@@ -2901,8 +2901,8 @@  discard block
 block discarded – undo
2901 2901
 	 * @since 1.0.19
2902 2902
 	 * @param  float $value tax total.
2903 2903
 	 */
2904
-	public function set_total_tax( $value ) {
2905
-		$this->set_prop( 'total_tax', max( 0, $value ) );
2904
+	public function set_total_tax($value) {
2905
+		$this->set_prop('total_tax', max(0, $value));
2906 2906
     }
2907 2907
 
2908 2908
     /**
@@ -2911,8 +2911,8 @@  discard block
 block discarded – undo
2911 2911
 	 * @since 1.0.19
2912 2912
 	 * @param  float $value tax total.
2913 2913
 	 */
2914
-	public function set_tax_total( $value ) {
2915
-		$this->set_total_tax( $value );
2914
+	public function set_tax_total($value) {
2915
+		$this->set_total_tax($value);
2916 2916
     }
2917 2917
 
2918 2918
     /**
@@ -2921,8 +2921,8 @@  discard block
 block discarded – undo
2921 2921
 	 * @since 1.0.19
2922 2922
 	 * @param  float $value fees total.
2923 2923
 	 */
2924
-	public function set_total_fees( $value ) {
2925
-		$this->set_prop( 'total_fees', max( 0, $value ) );
2924
+	public function set_total_fees($value) {
2925
+		$this->set_prop('total_fees', max(0, $value));
2926 2926
     }
2927 2927
 
2928 2928
     /**
@@ -2931,8 +2931,8 @@  discard block
 block discarded – undo
2931 2931
 	 * @since 1.0.19
2932 2932
 	 * @param  float $value fees total.
2933 2933
 	 */
2934
-	public function set_fees_total( $value ) {
2935
-		$this->set_total_fees( $value );
2934
+	public function set_fees_total($value) {
2935
+		$this->set_total_fees($value);
2936 2936
     }
2937 2937
 
2938 2938
     /**
@@ -2941,13 +2941,13 @@  discard block
 block discarded – undo
2941 2941
 	 * @since 1.0.19
2942 2942
 	 * @param  array $value fees.
2943 2943
 	 */
2944
-	public function set_fees( $value ) {
2944
+	public function set_fees($value) {
2945 2945
 
2946
-		if ( ! is_array( $value ) ) {
2946
+		if (!is_array($value)) {
2947 2947
 			$value = array();
2948 2948
 		}
2949 2949
 
2950
-		$this->set_prop( 'fees', $value );
2950
+		$this->set_prop('fees', $value);
2951 2951
 
2952 2952
     }
2953 2953
 
@@ -2957,13 +2957,13 @@  discard block
 block discarded – undo
2957 2957
 	 * @since 1.0.19
2958 2958
 	 * @param  array $value taxes.
2959 2959
 	 */
2960
-	public function set_taxes( $value ) {
2960
+	public function set_taxes($value) {
2961 2961
 
2962
-		if ( ! is_array( $value ) ) {
2962
+		if (!is_array($value)) {
2963 2963
 			$value = array();
2964 2964
 		}
2965 2965
 
2966
-		$this->set_prop( 'taxes', $value );
2966
+		$this->set_prop('taxes', $value);
2967 2967
 
2968 2968
     }
2969 2969
 
@@ -2973,13 +2973,13 @@  discard block
 block discarded – undo
2973 2973
 	 * @since 1.0.19
2974 2974
 	 * @param  array $value discounts.
2975 2975
 	 */
2976
-	public function set_discounts( $value ) {
2976
+	public function set_discounts($value) {
2977 2977
 
2978
-		if ( ! is_array( $value ) ) {
2978
+		if (!is_array($value)) {
2979 2979
 			$value = array();
2980 2980
 		}
2981 2981
 
2982
-		$this->set_prop( 'discounts', $value );
2982
+		$this->set_prop('discounts', $value);
2983 2983
     }
2984 2984
 
2985 2985
     /**
@@ -2988,19 +2988,19 @@  discard block
 block discarded – undo
2988 2988
 	 * @since 1.0.19
2989 2989
 	 * @param  GetPaid_Form_Item[] $value items.
2990 2990
 	 */
2991
-	public function set_items( $value ) {
2991
+	public function set_items($value) {
2992 2992
 
2993 2993
         // Remove existing items.
2994
-        $this->set_prop( 'items', array() );
2994
+        $this->set_prop('items', array());
2995 2995
 		$this->recurring_item = null;
2996 2996
 
2997 2997
         // Ensure that we have an array.
2998
-        if ( ! is_array( $value ) ) {
2998
+        if (!is_array($value)) {
2999 2999
             return;
3000 3000
         }
3001 3001
 
3002
-        foreach ( $value as $item ) {
3003
-            $this->add_item( $item );
3002
+        foreach ($value as $item) {
3003
+            $this->add_item($item);
3004 3004
         }
3005 3005
 
3006 3006
     }
@@ -3011,8 +3011,8 @@  discard block
 block discarded – undo
3011 3011
 	 * @since 1.0.19
3012 3012
 	 * @param  int $value payment form.
3013 3013
 	 */
3014
-	public function set_payment_form( $value ) {
3015
-		$this->set_prop( 'payment_form', $value );
3014
+	public function set_payment_form($value) {
3015
+		$this->set_prop('payment_form', $value);
3016 3016
     }
3017 3017
 
3018 3018
     /**
@@ -3021,8 +3021,8 @@  discard block
 block discarded – undo
3021 3021
 	 * @since 1.0.19
3022 3022
 	 * @param  string $value submission id.
3023 3023
 	 */
3024
-	public function set_submission_id( $value ) {
3025
-		$this->set_prop( 'submission_id', $value );
3024
+	public function set_submission_id($value) {
3025
+		$this->set_prop('submission_id', $value);
3026 3026
     }
3027 3027
 
3028 3028
     /**
@@ -3031,8 +3031,8 @@  discard block
 block discarded – undo
3031 3031
 	 * @since 1.0.19
3032 3032
 	 * @param  string $value discount code.
3033 3033
 	 */
3034
-	public function set_discount_code( $value ) {
3035
-		$this->set_prop( 'discount_code', sanitize_text_field( $value ) );
3034
+	public function set_discount_code($value) {
3035
+		$this->set_prop('discount_code', sanitize_text_field($value));
3036 3036
     }
3037 3037
 
3038 3038
     /**
@@ -3041,8 +3041,8 @@  discard block
 block discarded – undo
3041 3041
 	 * @since 1.0.19
3042 3042
 	 * @param  string $value gateway.
3043 3043
 	 */
3044
-	public function set_gateway( $value ) {
3045
-		$this->set_prop( 'gateway', $value );
3044
+	public function set_gateway($value) {
3045
+		$this->set_prop('gateway', $value);
3046 3046
     }
3047 3047
 
3048 3048
     /**
@@ -3051,9 +3051,9 @@  discard block
 block discarded – undo
3051 3051
 	 * @since 1.0.19
3052 3052
 	 * @param  string $value transaction id.
3053 3053
 	 */
3054
-	public function set_transaction_id( $value ) {
3055
-		if ( ! empty( $value ) ) {
3056
-			$this->set_prop( 'transaction_id', $value );
3054
+	public function set_transaction_id($value) {
3055
+		if (!empty($value)) {
3056
+			$this->set_prop('transaction_id', $value);
3057 3057
 		}
3058 3058
     }
3059 3059
 
@@ -3063,8 +3063,8 @@  discard block
 block discarded – undo
3063 3063
 	 * @since 1.0.19
3064 3064
 	 * @param  string $value currency id.
3065 3065
 	 */
3066
-	public function set_currency( $value ) {
3067
-		$this->set_prop( 'currency', $value );
3066
+	public function set_currency($value) {
3067
+		$this->set_prop('currency', $value);
3068 3068
     }
3069 3069
 
3070 3070
 	/**
@@ -3073,8 +3073,8 @@  discard block
 block discarded – undo
3073 3073
 	 * @since 1.0.19
3074 3074
 	 * @param  bool $value value.
3075 3075
 	 */
3076
-	public function set_disable_taxes( $value ) {
3077
-		$this->set_prop( 'disable_taxes', (bool) $value );
3076
+	public function set_disable_taxes($value) {
3077
+		$this->set_prop('disable_taxes', (bool) $value);
3078 3078
 	}
3079 3079
 
3080 3080
     /**
@@ -3083,8 +3083,8 @@  discard block
 block discarded – undo
3083 3083
 	 * @since 1.0.19
3084 3084
 	 * @param  string $value subscription id.
3085 3085
 	 */
3086
-	public function set_subscription_id( $value ) {
3087
-		$this->set_prop( 'subscription_id', $value );
3086
+	public function set_subscription_id($value) {
3087
+		$this->set_prop('subscription_id', $value);
3088 3088
 	}
3089 3089
 	
3090 3090
 	/**
@@ -3093,8 +3093,8 @@  discard block
 block discarded – undo
3093 3093
 	 * @since 1.0.19
3094 3094
 	 * @param  string $value subscription id.
3095 3095
 	 */
3096
-	public function set_remote_subscription_id( $value ) {
3097
-		$this->set_prop( 'remote_subscription_id', $value );
3096
+	public function set_remote_subscription_id($value) {
3097
+		$this->set_prop('remote_subscription_id', $value);
3098 3098
     }
3099 3099
 
3100 3100
     /*
@@ -3111,28 +3111,28 @@  discard block
 block discarded – undo
3111 3111
      */
3112 3112
     public function is_parent() {
3113 3113
         $parent = $this->get_parent_id();
3114
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
3114
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
3115 3115
     }
3116 3116
 
3117 3117
     /**
3118 3118
      * Checks if this is a renewal invoice.
3119 3119
      */
3120 3120
     public function is_renewal() {
3121
-        return $this->is_recurring() && ! $this->is_parent();
3121
+        return $this->is_recurring() && !$this->is_parent();
3122 3122
     }
3123 3123
 
3124 3124
     /**
3125 3125
      * Checks if this is a recurring invoice.
3126 3126
      */
3127 3127
     public function is_recurring() {
3128
-        return ! empty( $this->recurring_item );
3128
+        return !empty($this->recurring_item);
3129 3129
     }
3130 3130
 
3131 3131
     /**
3132 3132
      * Checks if this is a taxable invoice.
3133 3133
      */
3134 3134
     public function is_taxable() {
3135
-        return ! $this->get_disable_taxes();
3135
+        return !$this->get_disable_taxes();
3136 3136
 	}
3137 3137
 
3138 3138
 	/**
@@ -3146,45 +3146,45 @@  discard block
 block discarded – undo
3146 3146
 	 * Checks to see if the invoice requires payment.
3147 3147
 	 */
3148 3148
 	public function is_free() {
3149
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
3149
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
3150 3150
 
3151
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
3151
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
3152 3152
 			$is_free = false;
3153 3153
 		}
3154 3154
 
3155
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
3155
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
3156 3156
     }
3157 3157
 
3158 3158
     /**
3159 3159
      * Checks if the invoice is paid.
3160 3160
      */
3161 3161
     public function is_paid() {
3162
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
3163
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
3162
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
3163
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
3164 3164
 	}
3165 3165
 
3166 3166
 	/**
3167 3167
      * Checks if the invoice needs payment.
3168 3168
      */
3169 3169
 	public function needs_payment() {
3170
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
3171
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
3170
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
3171
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
3172 3172
     }
3173 3173
   
3174 3174
 	/**
3175 3175
      * Checks if the invoice is refunded.
3176 3176
      */
3177 3177
 	public function is_refunded() {
3178
-        $is_refunded = $this->has_status( 'wpi-refunded' );
3179
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
3178
+        $is_refunded = $this->has_status('wpi-refunded');
3179
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
3180 3180
 	}
3181 3181
 
3182 3182
 	/**
3183 3183
      * Checks if the invoice is held.
3184 3184
      */
3185 3185
 	public function is_held() {
3186
-        $is_held = $this->has_status( 'wpi-onhold' );
3187
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3186
+        $is_held = $this->has_status('wpi-onhold');
3187
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
3188 3188
 	}
3189 3189
 
3190 3190
 	/**
@@ -3192,30 +3192,30 @@  discard block
 block discarded – undo
3192 3192
      */
3193 3193
 	public function is_due() {
3194 3194
 		$due_date = $this->get_due_date();
3195
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3195
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3196 3196
 	}
3197 3197
 
3198 3198
 	/**
3199 3199
      * Checks if the invoice is draft.
3200 3200
      */
3201 3201
 	public function is_draft() {
3202
-        return $this->has_status( 'draft, auto-draft' );
3202
+        return $this->has_status('draft, auto-draft');
3203 3203
 	}
3204 3204
 
3205 3205
     /**
3206 3206
      * Checks if the invoice has a given status.
3207 3207
      */
3208
-    public function has_status( $status ) {
3209
-        $status = wpinv_parse_list( $status );
3210
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3208
+    public function has_status($status) {
3209
+        $status = wpinv_parse_list($status);
3210
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3211 3211
 	}
3212 3212
 
3213 3213
 	/**
3214 3214
      * Checks if the invoice is of a given type.
3215 3215
      */
3216
-    public function is_type( $type ) {
3217
-        $type = wpinv_parse_list( $type );
3218
-        return in_array( $this->get_type(), $type );
3216
+    public function is_type($type) {
3217
+        $type = wpinv_parse_list($type);
3218
+        return in_array($this->get_type(), $type);
3219 3219
     }
3220 3220
 
3221 3221
     /**
@@ -3247,8 +3247,8 @@  discard block
 block discarded – undo
3247 3247
      *
3248 3248
      */
3249 3249
 	public function is_initial_free() {
3250
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3251
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3250
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3251
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3252 3252
     }
3253 3253
 	
3254 3254
 	/**
@@ -3258,11 +3258,11 @@  discard block
 block discarded – undo
3258 3258
     public function item_has_free_trial() {
3259 3259
 
3260 3260
         // Ensure we have a recurring item.
3261
-        if ( ! $this->is_recurring() ) {
3261
+        if (!$this->is_recurring()) {
3262 3262
             return false;
3263 3263
         }
3264 3264
 
3265
-        $item = $this->get_recurring( true );
3265
+        $item = $this->get_recurring(true);
3266 3266
         return $item->has_free_trial();
3267 3267
 	}
3268 3268
 
@@ -3270,7 +3270,7 @@  discard block
 block discarded – undo
3270 3270
      * Check if the free trial is a result of a discount.
3271 3271
      */
3272 3272
     public function is_free_trial_from_discount() {
3273
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3273
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3274 3274
 	}
3275 3275
 	
3276 3276
 	/**
@@ -3278,12 +3278,12 @@  discard block
 block discarded – undo
3278 3278
      */
3279 3279
     public function discount_first_payment_only() {
3280 3280
 
3281
-		$discount = wpinv_get_discount_obj( $this->get_discount_code() );
3282
-        if ( ! $discount->exists() || ! $this->is_recurring() ) {
3281
+		$discount = wpinv_get_discount_obj($this->get_discount_code());
3282
+        if (!$discount->exists() || !$this->is_recurring()) {
3283 3283
             return true;
3284 3284
         }
3285 3285
 
3286
-        return ! $discount->get_is_recurring();
3286
+        return !$discount->get_is_recurring();
3287 3287
     }
3288 3288
 
3289 3289
     /*
@@ -3301,23 +3301,23 @@  discard block
 block discarded – undo
3301 3301
      * @param GetPaid_Form_Item|array $item
3302 3302
      * @return WP_Error|Bool
3303 3303
      */
3304
-    public function add_item( $item ) {
3304
+    public function add_item($item) {
3305 3305
 
3306
-		if ( is_array( $item ) ) {
3307
-			$item = $this->process_array_item( $item );
3306
+		if (is_array($item)) {
3307
+			$item = $this->process_array_item($item);
3308 3308
 		}
3309 3309
 
3310
-		if ( is_numeric( $item ) ) {
3311
-			$item = new GetPaid_Form_Item( $item );
3310
+		if (is_numeric($item)) {
3311
+			$item = new GetPaid_Form_Item($item);
3312 3312
 		}
3313 3313
 
3314 3314
         // Make sure that it is available for purchase.
3315
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3316
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3315
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3316
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3317 3317
         }
3318 3318
 
3319 3319
         // Do we have a recurring item?
3320
-		if ( $item->is_recurring() ) {
3320
+		if ($item->is_recurring()) {
3321 3321
 			$this->recurring_item = $item->get_id();
3322 3322
         }
3323 3323
 
@@ -3325,9 +3325,9 @@  discard block
 block discarded – undo
3325 3325
         $item->invoice_id = (int) $this->get_id();
3326 3326
 
3327 3327
 		// Remove duplicates.
3328
-		$this->remove_item( $item->get_id() );
3328
+		$this->remove_item($item->get_id());
3329 3329
 
3330
-		if ( 0 == $item->get_quantity() ) {
3330
+		if (0 == $item->get_quantity()) {
3331 3331
 			return;
3332 3332
 		}
3333 3333
 
@@ -3337,7 +3337,7 @@  discard block
 block discarded – undo
3337 3337
 		// Add new item.
3338 3338
         $items[] = $item;
3339 3339
 
3340
-        $this->set_prop( 'items', $items );
3340
+        $this->set_prop('items', $items);
3341 3341
 
3342 3342
 		return true;
3343 3343
 	}
@@ -3348,26 +3348,26 @@  discard block
 block discarded – undo
3348 3348
 	 * @since 1.0.19
3349 3349
 	 * @return GetPaid_Form_Item
3350 3350
 	 */
3351
-	protected function process_array_item( $array ) {
3351
+	protected function process_array_item($array) {
3352 3352
 
3353
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3354
-		$item    = new GetPaid_Form_Item( $item_id );
3353
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3354
+		$item    = new GetPaid_Form_Item($item_id);
3355 3355
 
3356 3356
 		// Set item data.
3357
-		foreach ( array( 'name', 'price', 'description' ) as $key ) {
3358
-			if ( isset( $array[ "item_$key" ] ) ) {
3357
+		foreach (array('name', 'price', 'description') as $key) {
3358
+			if (isset($array["item_$key"])) {
3359 3359
 				$method = "set_$key";
3360
-				$item->$method( $array[ "item_$key" ] );
3360
+				$item->$method($array["item_$key"]);
3361 3361
 			}
3362 3362
 		}
3363 3363
 
3364
-		if ( isset( $array['quantity'] ) ) {
3365
-			$item->set_quantity( $array['quantity'] );
3364
+		if (isset($array['quantity'])) {
3365
+			$item->set_quantity($array['quantity']);
3366 3366
 		}
3367 3367
 
3368 3368
 		// Set item meta.
3369
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3370
-			$item->set_item_meta( $array['meta'] );
3369
+		if (isset($array['meta']) && is_array($array['meta'])) {
3370
+			$item->set_item_meta($array['meta']);
3371 3371
 		}
3372 3372
 
3373 3373
 		return $item;
@@ -3380,10 +3380,10 @@  discard block
 block discarded – undo
3380 3380
 	 * @since 1.0.19
3381 3381
 	 * @return GetPaid_Form_Item|null
3382 3382
 	 */
3383
-	public function get_item( $item_id ) {
3383
+	public function get_item($item_id) {
3384 3384
 
3385
-		foreach ( $this->get_items() as $item ) {
3386
-			if ( (int) $item_id == $item->get_id() ) {
3385
+		foreach ($this->get_items() as $item) {
3386
+			if ((int) $item_id == $item->get_id()) {
3387 3387
 				return $item;
3388 3388
 			}
3389 3389
 		}
@@ -3396,16 +3396,16 @@  discard block
 block discarded – undo
3396 3396
 	 *
3397 3397
 	 * @since 1.0.19
3398 3398
 	 */
3399
-	public function remove_item( $item_id ) {
3399
+	public function remove_item($item_id) {
3400 3400
 		$items   = $this->get_items();
3401 3401
 		$item_id = (int) $item_id;
3402 3402
 
3403
-		foreach ( $items as $index => $item ) {
3404
-			if ( (int) $item_id == $item->get_id() ) {
3405
-				unset( $items[ $index ] );
3406
-				$this->set_prop( 'items', $items );
3403
+		foreach ($items as $index => $item) {
3404
+			if ((int) $item_id == $item->get_id()) {
3405
+				unset($items[$index]);
3406
+				$this->set_prop('items', $items);
3407 3407
 
3408
-				if ( $item_id == $this->recurring_item ) {
3408
+				if ($item_id == $this->recurring_item) {
3409 3409
 					$this->recurring_item = null;
3410 3410
 				}
3411 3411
 
@@ -3420,11 +3420,11 @@  discard block
 block discarded – undo
3420 3420
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3421 3421
 	 * @since 1.0.19
3422 3422
 	 */
3423
-    public function add_fee( $fee ) {
3423
+    public function add_fee($fee) {
3424 3424
 
3425 3425
 		$fees                 = $this->get_fees();
3426
-		$fees[ $fee['name'] ] = $fee;
3427
-		$this->set_prop( 'fees', $fees );
3426
+		$fees[$fee['name']] = $fee;
3427
+		$this->set_prop('fees', $fees);
3428 3428
 
3429 3429
     }
3430 3430
 
@@ -3433,9 +3433,9 @@  discard block
 block discarded – undo
3433 3433
 	 *
3434 3434
 	 * @since 1.0.19
3435 3435
 	 */
3436
-	public function get_fee( $fee ) {
3436
+	public function get_fee($fee) {
3437 3437
         $fees = $this->get_fees();
3438
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3438
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3439 3439
     }
3440 3440
 
3441 3441
     /**
@@ -3443,11 +3443,11 @@  discard block
 block discarded – undo
3443 3443
 	 *
3444 3444
 	 * @since 1.0.19
3445 3445
 	 */
3446
-	public function remove_fee( $fee ) {
3446
+	public function remove_fee($fee) {
3447 3447
         $fees = $this->get_fees();
3448
-        if ( isset( $fees[ $fee ] ) ) {
3449
-            unset( $fees[ $fee ] );
3450
-            $this->set_prop( 'fees', $fees );
3448
+        if (isset($fees[$fee])) {
3449
+            unset($fees[$fee]);
3450
+            $this->set_prop('fees', $fees);
3451 3451
         }
3452 3452
     }
3453 3453
 
@@ -3457,11 +3457,11 @@  discard block
 block discarded – undo
3457 3457
 	 * @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.
3458 3458
 	 * @since 1.0.19
3459 3459
 	 */
3460
-	public function add_discount( $discount ) {
3460
+	public function add_discount($discount) {
3461 3461
 
3462 3462
 		$discounts = $this->get_discounts();
3463
-		$discounts[ $discount['name'] ] = $discount;
3464
-		$this->set_prop( 'discounts', $discounts );
3463
+		$discounts[$discount['name']] = $discount;
3464
+		$this->set_prop('discounts', $discounts);
3465 3465
 
3466 3466
 	}
3467 3467
 
@@ -3471,15 +3471,15 @@  discard block
 block discarded – undo
3471 3471
 	 * @since 1.0.19
3472 3472
 	 * @return float
3473 3473
 	 */
3474
-	public function get_discount( $discount = false ) {
3474
+	public function get_discount($discount = false) {
3475 3475
 
3476 3476
 		// Backwards compatibilty.
3477
-		if ( empty( $discount ) ) {
3477
+		if (empty($discount)) {
3478 3478
 			return $this->get_total_discount();
3479 3479
 		}
3480 3480
 
3481 3481
         $discounts = $this->get_discounts();
3482
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3482
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3483 3483
     }
3484 3484
 
3485 3485
     /**
@@ -3487,15 +3487,15 @@  discard block
 block discarded – undo
3487 3487
 	 *
3488 3488
 	 * @since 1.0.19
3489 3489
 	 */
3490
-	public function remove_discount( $discount ) {
3490
+	public function remove_discount($discount) {
3491 3491
         $discounts = $this->get_discounts();
3492
-        if ( isset( $discounts[ $discount ] ) ) {
3493
-            unset( $discounts[ $discount ] );
3494
-            $this->set_prop( 'discounts', $discounts );
3492
+        if (isset($discounts[$discount])) {
3493
+            unset($discounts[$discount]);
3494
+            $this->set_prop('discounts', $discounts);
3495 3495
         }
3496 3496
 
3497
-		if ( 'discount_code' == $discount ) {
3498
-			foreach ( $this->get_items() as $item ) {
3497
+		if ('discount_code' == $discount) {
3498
+			foreach ($this->get_items() as $item) {
3499 3499
 				$item->item_discount           = 0;
3500 3500
 				$item->recurring_item_discount = 0;
3501 3501
 			}
@@ -3508,12 +3508,12 @@  discard block
 block discarded – undo
3508 3508
      *
3509 3509
      * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
3510 3510
      */
3511
-    public function add_tax( $tax ) {
3512
-        if ( $this->is_taxable() ) {
3511
+    public function add_tax($tax) {
3512
+        if ($this->is_taxable()) {
3513 3513
 
3514
-            $taxes                 = $this->get_taxes();
3515
-			$taxes[ $tax['name'] ] = $tax;
3516
-			$this->set_prop( 'taxes', $tax );
3514
+            $taxes = $this->get_taxes();
3515
+			$taxes[$tax['name']] = $tax;
3516
+			$this->set_prop('taxes', $tax);
3517 3517
 
3518 3518
         }
3519 3519
     }
@@ -3523,15 +3523,15 @@  discard block
 block discarded – undo
3523 3523
 	 *
3524 3524
 	 * @since 1.0.19
3525 3525
 	 */
3526
-	public function get_tax( $tax = null ) {
3526
+	public function get_tax($tax = null) {
3527 3527
 
3528 3528
 		// Backwards compatility.
3529
-		if ( empty( $tax ) ) {
3529
+		if (empty($tax)) {
3530 3530
 			return $this->get_total_tax();
3531 3531
 		}
3532 3532
 
3533 3533
         $taxes = $this->get_taxes();
3534
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3534
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3535 3535
     }
3536 3536
 
3537 3537
     /**
@@ -3539,11 +3539,11 @@  discard block
 block discarded – undo
3539 3539
 	 *
3540 3540
 	 * @since 1.0.19
3541 3541
 	 */
3542
-	public function remove_tax( $tax ) {
3542
+	public function remove_tax($tax) {
3543 3543
         $taxes = $this->get_taxes();
3544
-        if ( isset( $taxes[ $tax ] ) ) {
3545
-            unset( $taxes[ $tax ] );
3546
-            $this->set_prop( 'taxes', $taxes );
3544
+        if (isset($taxes[$tax])) {
3545
+            unset($taxes[$tax]);
3546
+            $this->set_prop('taxes', $taxes);
3547 3547
         }
3548 3548
     }
3549 3549
 
@@ -3554,22 +3554,22 @@  discard block
 block discarded – undo
3554 3554
 	 * @return float The recalculated subtotal
3555 3555
 	 */
3556 3556
 	public function recalculate_subtotal() {
3557
-        $items     = $this->get_items();
3557
+        $items = $this->get_items();
3558 3558
 		$subtotal  = 0;
3559 3559
 		$recurring = 0;
3560 3560
 
3561
-        foreach ( $items as $item ) {
3562
-			$subtotal  += $item->get_sub_total( 'edit' );
3563
-			$recurring += $item->get_recurring_sub_total( 'edit' );
3561
+        foreach ($items as $item) {
3562
+			$subtotal  += $item->get_sub_total('edit');
3563
+			$recurring += $item->get_recurring_sub_total('edit');
3564 3564
         }
3565 3565
 
3566
-		if ( wpinv_prices_include_tax() ) {
3567
-			$subtotal  = max( 0, $subtotal - $this->totals['tax']['initial'] );
3568
-			$recurring = max( 0, $recurring - $this->totals['tax']['recurring'] );
3566
+		if (wpinv_prices_include_tax()) {
3567
+			$subtotal  = max(0, $subtotal - $this->totals['tax']['initial']);
3568
+			$recurring = max(0, $recurring - $this->totals['tax']['recurring']);
3569 3569
 		}
3570 3570
 
3571 3571
 		$current = $this->is_renewal() ? $recurring : $subtotal;
3572
-		$this->set_subtotal( $current );
3572
+		$this->set_subtotal($current);
3573 3573
 
3574 3574
 		$this->totals['subtotal'] = array(
3575 3575
 			'initial'   => $subtotal,
@@ -3590,14 +3590,14 @@  discard block
 block discarded – undo
3590 3590
 		$discount  = 0;
3591 3591
 		$recurring = 0;
3592 3592
 
3593
-        foreach ( $discounts as $data ) {
3594
-			$discount  += wpinv_sanitize_amount( $data['initial_discount'] );
3595
-			$recurring += wpinv_sanitize_amount( $data['recurring_discount'] );
3593
+        foreach ($discounts as $data) {
3594
+			$discount  += wpinv_sanitize_amount($data['initial_discount']);
3595
+			$recurring += wpinv_sanitize_amount($data['recurring_discount']);
3596 3596
 		}
3597 3597
 
3598 3598
 		$current = $this->is_renewal() ? $recurring : $discount;
3599 3599
 
3600
-		$this->set_total_discount( $current );
3600
+		$this->set_total_discount($current);
3601 3601
 
3602 3602
 		$this->totals['discount'] = array(
3603 3603
 			'initial'   => $discount,
@@ -3618,13 +3618,13 @@  discard block
 block discarded – undo
3618 3618
 
3619 3619
 		// Maybe disable taxes.
3620 3620
 		$vat_number = $this->get_vat_number();
3621
-		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $this->get_country() ) && ! empty( $vat_number );
3621
+		$skip_tax   = GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($this->get_country()) && !empty($vat_number);
3622 3622
 
3623
-		if ( wpinv_is_base_country( $this->get_country() ) && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) {
3623
+		if (wpinv_is_base_country($this->get_country()) && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) {
3624 3624
 			$skip_tax = false;
3625 3625
 		}
3626 3626
 
3627
-		if ( ! wpinv_use_taxes() || $this->get_disable_taxes() || ! wpinv_is_country_taxable( $this->get_country() ) || $skip_tax   ) {
3627
+		if (!wpinv_use_taxes() || $this->get_disable_taxes() || !wpinv_is_country_taxable($this->get_country()) || $skip_tax) {
3628 3628
 
3629 3629
 			$this->totals['tax'] = array(
3630 3630
 				'initial'   => 0,
@@ -3633,38 +3633,38 @@  discard block
 block discarded – undo
3633 3633
 
3634 3634
 			$this->tax_rate = 0;
3635 3635
 
3636
-			$this->set_taxes( array() );
3636
+			$this->set_taxes(array());
3637 3637
 			$current = 0;
3638 3638
 		} else {
3639 3639
 
3640 3640
 			$item_taxes = array();
3641 3641
 
3642
-			foreach ( $this->get_items() as $item ) {
3643
-				$rates    = getpaid_get_item_tax_rates( $item, $this->get_country(), $this->get_state() );
3644
-				$rates    = getpaid_filter_item_tax_rates( $item, $rates );
3645
-				$taxes    = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, false ), $rates );
3646
-				$r_taxes  = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item, true ), $rates );
3647
-				foreach ( $taxes as $name => $amount ) {
3648
-					$recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0;
3649
-					$tax       = getpaid_prepare_item_tax( $item, $name, $amount, $recurring );
3650
-
3651
-					if ( ! isset( $item_taxes[ $name ] ) ) {
3652
-						$item_taxes[ $name ] = $tax;
3642
+			foreach ($this->get_items() as $item) {
3643
+				$rates    = getpaid_get_item_tax_rates($item, $this->get_country(), $this->get_state());
3644
+				$rates    = getpaid_filter_item_tax_rates($item, $rates);
3645
+				$taxes    = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, false), $rates);
3646
+				$r_taxes  = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item, true), $rates);
3647
+				foreach ($taxes as $name => $amount) {
3648
+					$recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0;
3649
+					$tax       = getpaid_prepare_item_tax($item, $name, $amount, $recurring);
3650
+
3651
+					if (!isset($item_taxes[$name])) {
3652
+						$item_taxes[$name] = $tax;
3653 3653
 						continue;
3654 3654
 					}
3655 3655
 
3656
-					$item_taxes[ $name ]['initial_tax']   += $tax['initial_tax'];
3657
-					$item_taxes[ $name ]['recurring_tax'] += $tax['recurring_tax'];
3656
+					$item_taxes[$name]['initial_tax']   += $tax['initial_tax'];
3657
+					$item_taxes[$name]['recurring_tax'] += $tax['recurring_tax'];
3658 3658
 
3659 3659
 				}
3660 3660
 
3661 3661
 			}
3662 3662
 
3663
-			$item_taxes = array_replace( $this->get_taxes(), $item_taxes );
3664
-			$this->set_taxes( $item_taxes );
3663
+			$item_taxes = array_replace($this->get_taxes(), $item_taxes);
3664
+			$this->set_taxes($item_taxes);
3665 3665
 
3666
-			$initial_tax   = array_sum( wp_list_pluck( $item_taxes, 'initial_tax' ) );
3667
-			$recurring_tax = array_sum( wp_list_pluck( $item_taxes, 'recurring_tax' ) );
3666
+			$initial_tax   = array_sum(wp_list_pluck($item_taxes, 'initial_tax'));
3667
+			$recurring_tax = array_sum(wp_list_pluck($item_taxes, 'recurring_tax'));
3668 3668
 
3669 3669
 			$current = $this->is_renewal() ? $recurring_tax : $initial_tax;
3670 3670
 
@@ -3675,7 +3675,7 @@  discard block
 block discarded – undo
3675 3675
 
3676 3676
 		}
3677 3677
 
3678
-		$this->set_total_tax( $current );
3678
+		$this->set_total_tax($current);
3679 3679
 
3680 3680
 		return $current;
3681 3681
 
@@ -3692,20 +3692,20 @@  discard block
 block discarded – undo
3692 3692
 		$fee       = 0;
3693 3693
 		$recurring = 0;
3694 3694
 
3695
-        foreach ( $fees as $data ) {
3696
-			$fee       += wpinv_sanitize_amount( $data['initial_fee'] );
3697
-			$recurring += wpinv_sanitize_amount( $data['recurring_fee'] );
3695
+        foreach ($fees as $data) {
3696
+			$fee       += wpinv_sanitize_amount($data['initial_fee']);
3697
+			$recurring += wpinv_sanitize_amount($data['recurring_fee']);
3698 3698
 		}
3699 3699
 
3700 3700
 		$current = $this->is_renewal() ? $recurring : $fee;
3701
-		$this->set_total_fees( $current );
3701
+		$this->set_total_fees($current);
3702 3702
 
3703 3703
 		$this->totals['fee'] = array(
3704 3704
 			'initial'   => $fee,
3705 3705
 			'recurring' => $recurring,
3706 3706
 		);
3707 3707
 
3708
-        $this->set_total_fees( $fee );
3708
+        $this->set_total_fees($fee);
3709 3709
         return $current;
3710 3710
     }
3711 3711
 
@@ -3720,7 +3720,7 @@  discard block
 block discarded – undo
3720 3720
         $this->recalculate_total_discount();
3721 3721
 		$this->recalculate_total_tax();
3722 3722
 		$this->recalculate_subtotal();
3723
-		$this->set_total( $this->get_total_tax( 'edit' ) + $this->get_total_fees( 'edit' ) + $this->get_subtotal( 'edit' ) - $this->get_total_discount( 'edit' ) );
3723
+		$this->set_total($this->get_total_tax('edit') + $this->get_total_fees('edit') + $this->get_subtotal('edit') - $this->get_total_discount('edit'));
3724 3724
 		return $this->get_total();
3725 3725
 	}
3726 3726
 
@@ -3729,7 +3729,7 @@  discard block
 block discarded – undo
3729 3729
 	 */
3730 3730
     public function recalculate_totals() {
3731 3731
         $this->recalculate_total();
3732
-        $this->save( true );
3732
+        $this->save(true);
3733 3733
         return $this;
3734 3734
     }
3735 3735
 
@@ -3747,8 +3747,8 @@  discard block
 block discarded – undo
3747 3747
 	 * @return int|false The new note's ID on success, false on failure.
3748 3748
      *
3749 3749
      */
3750
-    public function add_system_note( $note ) {
3751
-		return $this->add_note( $note, false, false, true );
3750
+    public function add_system_note($note) {
3751
+		return $this->add_note($note, false, false, true);
3752 3752
 	}
3753 3753
 
3754 3754
     /**
@@ -3758,10 +3758,10 @@  discard block
 block discarded – undo
3758 3758
 	 * @return int|false The new note's ID on success, false on failure.
3759 3759
      *
3760 3760
      */
3761
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3761
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3762 3762
 
3763 3763
         // Bail if no note specified or this invoice is not yet saved.
3764
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3764
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3765 3765
             return false;
3766 3766
         }
3767 3767
 
@@ -3769,23 +3769,23 @@  discard block
 block discarded – undo
3769 3769
 		$author_email = '[email protected]';
3770 3770
 
3771 3771
 		// If this is an admin comment or it has been added by the user.
3772
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3773
-			$user         = get_user_by( 'id', get_current_user_id() );
3772
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3773
+			$user = get_user_by('id', get_current_user_id());
3774 3774
             $author       = $user->display_name;
3775 3775
             $author_email = $user->user_email;
3776 3776
 		}
3777 3777
 
3778
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3778
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3779 3779
 
3780 3780
 	}
3781 3781
 
3782 3782
 	/**
3783 3783
      * Generates a unique key for the invoice.
3784 3784
      */
3785
-    public function generate_key( $string = '' ) {
3786
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3785
+    public function generate_key($string = '') {
3786
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3787 3787
         return strtolower(
3788
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3788
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3789 3789
         );
3790 3790
     }
3791 3791
 
@@ -3795,11 +3795,11 @@  discard block
 block discarded – undo
3795 3795
     public function generate_number() {
3796 3796
         $number = $this->get_id();
3797 3797
 
3798
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3799
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3798
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3799
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3800 3800
         }
3801 3801
 
3802
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3802
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3803 3803
 
3804 3804
 	}
3805 3805
 
@@ -3812,55 +3812,55 @@  discard block
 block discarded – undo
3812 3812
 		// Reset status transition variable.
3813 3813
 		$this->status_transition = false;
3814 3814
 
3815
-		if ( $status_transition ) {
3815
+		if ($status_transition) {
3816 3816
 			try {
3817 3817
 
3818 3818
 				// Fire a hook for the status change.
3819
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3819
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3820 3820
 
3821 3821
 				// @deprecated this is deprecated and will be removed in the future.
3822
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3822
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3823 3823
 
3824
-				if ( ! empty( $status_transition['from'] ) ) {
3824
+				if (!empty($status_transition['from'])) {
3825 3825
 
3826 3826
 					/* translators: 1: old invoice status 2: new invoice status */
3827
-					$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  ) );
3827
+					$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));
3828 3828
 
3829 3829
 					// Fire another hook.
3830
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3831
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3830
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3831
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3832 3832
 
3833 3833
 					// @deprecated this is deprecated and will be removed in the future.
3834
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3834
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3835 3835
 
3836 3836
 					// Note the transition occurred.
3837
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), false, $status_transition['manual'] );
3837
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), false, $status_transition['manual']);
3838 3838
 
3839 3839
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3840 3840
 					if (
3841
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3842
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3841
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3842
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3843 3843
 					) {
3844
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3844
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3845 3845
 					}
3846 3846
 
3847 3847
 					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3848 3848
 					if (
3849
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3850
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3849
+						in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3850
+						&& in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3851 3851
 					) {
3852
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3852
+						do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition);
3853 3853
 					}
3854 3854
 				} else {
3855 3855
 					/* translators: %s: new invoice status */
3856
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'], $this  ) );
3856
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to'], $this));
3857 3857
 
3858 3858
 					// Note the transition occurred.
3859
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3859
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3860 3860
 
3861 3861
 				}
3862
-			} catch ( Exception $e ) {
3863
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3862
+			} catch (Exception $e) {
3863
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3864 3864
 			}
3865 3865
 		}
3866 3866
 	}
@@ -3868,13 +3868,13 @@  discard block
 block discarded – undo
3868 3868
 	/**
3869 3869
 	 * Updates an invoice status.
3870 3870
 	 */
3871
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3871
+	public function update_status($new_status = false, $note = '', $manual = false) {
3872 3872
 
3873 3873
 		// Fires before updating a status.
3874
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3874
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3875 3875
 
3876 3876
 		// Update the status.
3877
-		$this->set_status( $new_status, $note, $manual );
3877
+		$this->set_status($new_status, $note, $manual);
3878 3878
 
3879 3879
 		// Save the order.
3880 3880
 		return $this->save();
@@ -3885,18 +3885,18 @@  discard block
 block discarded – undo
3885 3885
 	 * @deprecated
3886 3886
 	 */
3887 3887
 	public function refresh_item_ids() {
3888
-        $item_ids = implode( ',', array_unique( wp_list_pluck( $this->get_cart_details(), 'item_id' ) ) );
3889
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3888
+        $item_ids = implode(',', array_unique(wp_list_pluck($this->get_cart_details(), 'item_id')));
3889
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3890 3890
 	}
3891 3891
 
3892 3892
 	/**
3893 3893
 	 * @deprecated
3894 3894
 	 */
3895
-	public function update_items( $temp = false ) {
3895
+	public function update_items($temp = false) {
3896 3896
 
3897
-		$this->set_items( $this->get_items() );
3897
+		$this->set_items($this->get_items());
3898 3898
 
3899
-		if ( ! $temp ) {
3899
+		if (!$temp) {
3900 3900
 			$this->save();
3901 3901
 		}
3902 3902
 
@@ -3910,11 +3910,11 @@  discard block
 block discarded – undo
3910 3910
 
3911 3911
         $discount_code = $this->get_discount_code();
3912 3912
 
3913
-        if ( empty( $discount_code ) ) {
3913
+        if (empty($discount_code)) {
3914 3914
             return false;
3915 3915
         }
3916 3916
 
3917
-        $discount = wpinv_get_discount_obj( $discount_code );
3917
+        $discount = wpinv_get_discount_obj($discount_code);
3918 3918
 
3919 3919
         // Ensure it is active.
3920 3920
         return $discount->exists();
@@ -3925,7 +3925,7 @@  discard block
 block discarded – undo
3925 3925
 	 * Refunds an invoice.
3926 3926
 	 */
3927 3927
     public function refund() {
3928
-		$this->set_status( 'wpi-refunded' );
3928
+		$this->set_status('wpi-refunded');
3929 3929
         $this->save();
3930 3930
 	}
3931 3931
 
@@ -3934,53 +3934,53 @@  discard block
 block discarded – undo
3934 3934
 	 * 
3935 3935
 	 * @param string $transaction_id
3936 3936
 	 */
3937
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3937
+    public function mark_paid($transaction_id = null, $note = '') {
3938 3938
 
3939 3939
 		// Set the transaction id.
3940
-		if ( empty( $transaction_id ) ) {
3940
+		if (empty($transaction_id)) {
3941 3941
 			$transaction_id = $this->generate_key('trans_');
3942 3942
 		}
3943 3943
 
3944
-		if ( ! $this->get_transaction_id() ) {
3945
-			$this->set_transaction_id( $transaction_id );
3944
+		if (!$this->get_transaction_id()) {
3945
+			$this->set_transaction_id($transaction_id);
3946 3946
 		}
3947 3947
 
3948
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3948
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3949 3949
 			return $this->save();
3950 3950
 		}
3951 3951
 
3952 3952
 		// Set the completed date.
3953
-		$this->set_date_completed( current_time( 'mysql' ) );
3953
+		$this->set_date_completed(current_time('mysql'));
3954 3954
 
3955 3955
 		// Set the new status.
3956
-		$gateway = sanitize_text_field( $this->get_gateway_title() );
3957
-		if ( $this->is_renewal() || ! $this->is_parent() ) {
3956
+		$gateway = sanitize_text_field($this->get_gateway_title());
3957
+		if ($this->is_renewal() || !$this->is_parent()) {
3958 3958
 
3959
-			$_note = wp_sprintf( __( 'Renewed via %s', 'invoicing' ), $gateway );
3960
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3959
+			$_note = wp_sprintf(__('Renewed via %s', 'invoicing'), $gateway);
3960
+			$_note = $_note . empty($note) ? '' : " ($note)";
3961 3961
 
3962
-			if ( 'none' == $this->get_gateway() ) {
3962
+			if ('none' == $this->get_gateway()) {
3963 3963
 				$_note = $note;
3964 3964
 			}
3965 3965
 
3966
-			$this->set_status( 'wpi-renewal', $_note );
3966
+			$this->set_status('wpi-renewal', $_note);
3967 3967
 
3968 3968
 		} else {
3969 3969
 
3970
-			$_note = wp_sprintf( __( 'Paid via %s', 'invoicing' ), $gateway );
3971
-			$_note = $_note . empty( $note ) ? '' : " ($note)";
3970
+			$_note = wp_sprintf(__('Paid via %s', 'invoicing'), $gateway);
3971
+			$_note = $_note . empty($note) ? '' : " ($note)";
3972 3972
 
3973
-			if ( 'none' == $this->get_gateway() ) {
3973
+			if ('none' == $this->get_gateway()) {
3974 3974
 				$_note = $note;
3975 3975
 			}
3976 3976
 
3977
-			$this->set_status( 'publish', $_note );
3977
+			$this->set_status('publish', $_note);
3978 3978
 
3979 3979
 		}
3980 3980
 
3981 3981
 		// Set checkout mode.
3982
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3983
-		$this->set_mode( $mode );
3982
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3983
+		$this->set_mode($mode);
3984 3984
 
3985 3985
 		// Save the invoice.
3986 3986
         $this->save();
@@ -4005,9 +4005,9 @@  discard block
 block discarded – undo
4005 4005
      * Clears the subscription's cache.
4006 4006
      */
4007 4007
     public function clear_cache() {
4008
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
4009
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
4010
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
4008
+		wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
4009
+		wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
4010
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
4011 4011
 	}
4012 4012
 
4013 4013
 }
Please login to merge, or discard this patch.
includes/admin/subscriptions.php 2 patches
Indentation   +433 added lines, -433 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@  discard block
 block discarded – undo
14 14
  */
15 15
 function wpinv_subscriptions_page() {
16 16
 
17
-	?>
17
+    ?>
18 18
 
19 19
 	<div class="wrap">
20 20
 		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
@@ -22,27 +22,27 @@  discard block
 block discarded – undo
22 22
 
23 23
 			<?php
24 24
 
25
-				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
25
+                // Verify user permissions.
26
+                if ( ! wpinv_current_user_can_manage_invoicing() ) {
27 27
 
28
-					echo aui()->alert(
29
-						array(
30
-							'type'    => 'danger',
31
-							'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
-						)
33
-					);
28
+                    echo aui()->alert(
29
+                        array(
30
+                            'type'    => 'danger',
31
+                            'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
32
+                        )
33
+                    );
34 34
 
35
-				} else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
35
+                } else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
36 36
 
37
-					// Display a single subscription.
38
-					wpinv_recurring_subscription_details();
39
-				} else {
37
+                    // Display a single subscription.
38
+                    wpinv_recurring_subscription_details();
39
+                } else {
40 40
 
41
-					// Display a list of available subscriptions.
42
-					getpaid_print_subscriptions_list();
43
-				}
41
+                    // Display a list of available subscriptions.
42
+                    getpaid_print_subscriptions_list();
43
+                }
44 44
 
45
-			?>
45
+            ?>
46 46
 
47 47
 		</div>
48 48
 	</div>
@@ -59,10 +59,10 @@  discard block
 block discarded – undo
59 59
  */
60 60
 function getpaid_print_subscriptions_list() {
61 61
 
62
-	$subscribers_table = new WPInv_Subscriptions_List_Table();
63
-	$subscribers_table->prepare_items();
62
+    $subscribers_table = new WPInv_Subscriptions_List_Table();
63
+    $subscribers_table->prepare_items();
64 64
 
65
-	?>
65
+    ?>
66 66
 	<?php $subscribers_table->views(); ?>
67 67
 	<form id="subscribers-filter" class="bsui" method="get">
68 68
 		<input type="hidden" name="page" value="wpinv-subscriptions" />
@@ -81,41 +81,41 @@  discard block
 block discarded – undo
81 81
  */
82 82
 function wpinv_recurring_subscription_details() {
83 83
 
84
-	// Fetch the subscription.
85
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
86
-	if ( ! $sub->exists() ) {
84
+    // Fetch the subscription.
85
+    $sub = new WPInv_Subscription( (int) $_GET['id'] );
86
+    if ( ! $sub->exists() ) {
87 87
 
88
-		echo aui()->alert(
89
-			array(
90
-				'type'    => 'danger',
91
-				'content' => __( 'Subscription not found.', 'invoicing' ),
92
-			)
93
-		);
88
+        echo aui()->alert(
89
+            array(
90
+                'type'    => 'danger',
91
+                'content' => __( 'Subscription not found.', 'invoicing' ),
92
+            )
93
+        );
94 94
 
95
-		return;
96
-	}
95
+        return;
96
+    }
97 97
 
98
-	// Use metaboxes to display the subscription details.
99
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
100
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
98
+    // Use metaboxes to display the subscription details.
99
+    add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
100
+    add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
101 101
 
102
-	$subscription_id     = $sub->get_id();
103
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
104
-	$subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
102
+    $subscription_id     = $sub->get_id();
103
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
104
+    $subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
105 105
 
106
-	if ( 1 < count( $subscription_groups ) ) {
107
-		add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
108
-	}
106
+    if ( 1 < count( $subscription_groups ) ) {
107
+        add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
108
+    }
109 109
 
110
-	if ( ! empty( $subscription_group ) ) {
111
-		add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
112
-	}
110
+    if ( ! empty( $subscription_group ) ) {
111
+        add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
112
+    }
113 113
 
114
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
114
+    add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
115 115
 
116
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
116
+    do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
117 117
 
118
-	?>
118
+    ?>
119 119
 
120 120
 		<form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>">
121 121
 
@@ -155,45 +155,45 @@  discard block
 block discarded – undo
155 155
  */
156 156
 function getpaid_admin_subscription_details_metabox( $sub ) {
157 157
 
158
-	// Subscription items.
159
-	$subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
160
-	$items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
161
-
162
-	// Prepare subscription detail columns.
163
-	$fields = apply_filters(
164
-		'getpaid_subscription_admin_page_fields',
165
-		array(
166
-			'subscription'   => __( 'Subscription', 'invoicing' ),
167
-			'customer'       => __( 'Customer', 'invoicing' ),
168
-			'amount'         => __( 'Amount', 'invoicing' ),
169
-			'start_date'     => __( 'Start Date', 'invoicing' ),
170
-			'renews_on'      => __( 'Next Payment', 'invoicing' ),
171
-			'renewals'       => __( 'Payments', 'invoicing' ),
172
-			'item'           => _n( 'Item', 'Items', $items_count,  'invoicing' ),
173
-			'gateway'        => __( 'Payment Method', 'invoicing' ),
174
-			'profile_id'     => __( 'Profile ID', 'invoicing' ),
175
-			'status'         => __( 'Status', 'invoicing' ),
176
-		)
177
-	);
178
-
179
-	if ( ! $sub->is_active() ) {
180
-
181
-		if ( isset( $fields['renews_on'] ) ) {
182
-			unset( $fields['renews_on'] );
183
-		}
184
-
185
-		if ( isset( $fields['gateway'] ) ) {
186
-			unset( $fields['gateway'] );
187
-		}
188
-
189
-	}
190
-
191
-	$profile_id = $sub->get_profile_id();
192
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
193
-		unset( $fields['profile_id'] );
194
-	}
195
-
196
-	?>
158
+    // Subscription items.
159
+    $subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
160
+    $items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
161
+
162
+    // Prepare subscription detail columns.
163
+    $fields = apply_filters(
164
+        'getpaid_subscription_admin_page_fields',
165
+        array(
166
+            'subscription'   => __( 'Subscription', 'invoicing' ),
167
+            'customer'       => __( 'Customer', 'invoicing' ),
168
+            'amount'         => __( 'Amount', 'invoicing' ),
169
+            'start_date'     => __( 'Start Date', 'invoicing' ),
170
+            'renews_on'      => __( 'Next Payment', 'invoicing' ),
171
+            'renewals'       => __( 'Payments', 'invoicing' ),
172
+            'item'           => _n( 'Item', 'Items', $items_count,  'invoicing' ),
173
+            'gateway'        => __( 'Payment Method', 'invoicing' ),
174
+            'profile_id'     => __( 'Profile ID', 'invoicing' ),
175
+            'status'         => __( 'Status', 'invoicing' ),
176
+        )
177
+    );
178
+
179
+    if ( ! $sub->is_active() ) {
180
+
181
+        if ( isset( $fields['renews_on'] ) ) {
182
+            unset( $fields['renews_on'] );
183
+        }
184
+
185
+        if ( isset( $fields['gateway'] ) ) {
186
+            unset( $fields['gateway'] );
187
+        }
188
+
189
+    }
190
+
191
+    $profile_id = $sub->get_profile_id();
192
+    if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
193
+        unset( $fields['profile_id'] );
194
+    }
195
+
196
+    ?>
197 197
 
198 198
 		<table class="table table-borderless" style="font-size: 14px;">
199 199
 			<tbody>
@@ -227,20 +227,20 @@  discard block
 block discarded – undo
227 227
  */
228 228
 function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
229 229
 
230
-	$username = __( '(Missing User)', 'invoicing' );
230
+    $username = __( '(Missing User)', 'invoicing' );
231 231
 
232
-	$user = get_userdata( $subscription->get_customer_id() );
233
-	if ( $user ) {
232
+    $user = get_userdata( $subscription->get_customer_id() );
233
+    if ( $user ) {
234 234
 
235
-		$username = sprintf(
236
-			'<a href="user-edit.php?user_id=%s">%s</a>',
237
-			absint( $user->ID ),
238
-			! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
239
-		);
235
+        $username = sprintf(
236
+            '<a href="user-edit.php?user_id=%s">%s</a>',
237
+            absint( $user->ID ),
238
+            ! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
239
+        );
240 240
 
241
-	}
241
+    }
242 242
 
243
-	echo  $username;
243
+    echo  $username;
244 244
 }
245 245
 add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
246 246
 
@@ -250,8 +250,8 @@  discard block
 block discarded – undo
250 250
  * @param WPInv_Subscription $subscription
251 251
  */
252 252
 function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
253
-	$amount    = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) );
254
-	echo "<span>$amount</span>";
253
+    $amount    = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) );
254
+    echo "<span>$amount</span>";
255 255
 }
256 256
 add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
257 257
 
@@ -262,11 +262,11 @@  discard block
 block discarded – undo
262 262
  */
263 263
 function getpaid_admin_subscription_metabox_display_id( $subscription ) {
264 264
 
265
-	printf(
266
-		'<a href="%s">#%s</a>',
267
-		esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
268
-		absint( $subscription->get_id() )
269
-	);
265
+    printf(
266
+        '<a href="%s">#%s</a>',
267
+        esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
268
+        absint( $subscription->get_id() )
269
+    );
270 270
 
271 271
 }
272 272
 add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
  * @param WPInv_Subscription $subscription
278 278
  */
279 279
 function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
280
-	echo getpaid_format_date_value( $subscription->get_date_created() );
280
+    echo getpaid_format_date_value( $subscription->get_date_created() );
281 281
 }
282 282
 add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
283 283
 
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
  * @param WPInv_Subscription $subscription
288 288
  */
289 289
 function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
290
-	echo getpaid_format_date_value( $subscription->get_expiration() );
290
+    echo getpaid_format_date_value( $subscription->get_expiration() );
291 291
 }
292 292
 add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
293 293
 
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
  * @param WPInv_Subscription $subscription
298 298
  */
299 299
 function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
300
-	$max_bills = $subscription->get_bill_times();
301
-	echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
300
+    $max_bills = $subscription->get_bill_times();
301
+    echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
302 302
 }
303 303
 add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
304 304
 /**
@@ -309,13 +309,13 @@  discard block
 block discarded – undo
309 309
  */
310 310
 function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
311 311
 
312
-	if ( empty( $subscription_group ) ) {
313
-		echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() );
314
-		return;
315
-	}
312
+    if ( empty( $subscription_group ) ) {
313
+        echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() );
314
+        return;
315
+    }
316 316
 
317
-	$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
318
-	echo implode( ' | ', $markup );
317
+    $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
318
+    echo implode( ' | ', $markup );
319 319
 
320 320
 }
321 321
 add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
@@ -327,13 +327,13 @@  discard block
 block discarded – undo
327 327
  */
328 328
 function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
329 329
 
330
-	$gateway = $subscription->get_gateway();
330
+    $gateway = $subscription->get_gateway();
331 331
 
332
-	if ( ! empty( $gateway ) ) {
333
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
334
-	} else {
335
-		echo "&mdash;";
336
-	}
332
+    if ( ! empty( $gateway ) ) {
333
+        echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
334
+    } else {
335
+        echo "&mdash;";
336
+    }
337 337
 
338 338
 }
339 339
 add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
  * @param WPInv_Subscription $subscription
345 345
  */
346 346
 function getpaid_admin_subscription_metabox_display_status( $subscription ) {
347
-	echo $subscription->get_status_label_html();
347
+    echo $subscription->get_status_label_html();
348 348
 }
349 349
 add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
350 350
 
@@ -355,29 +355,29 @@  discard block
 block discarded – undo
355 355
  */
356 356
 function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
357 357
 
358
-	$profile_id = $subscription->get_profile_id();
359
-
360
-	$input = aui()->input(
361
-		array(
362
-			'type'        => 'text',
363
-			'id'          => 'wpinv_subscription_profile_id',
364
-			'name'        => 'wpinv_subscription_profile_id',
365
-			'label'       => __( 'Profile Id', 'invoicing' ),
366
-			'label_type'  => 'hidden',
367
-			'placeholder' => __( 'Profile Id', 'invoicing' ),
368
-			'value'       => esc_attr( $profile_id ),
369
-			'input_group_right' => '',
370
-			'no_wrap'     => true,
371
-		)
372
-	);
373
-
374
-	echo str_ireplace( 'form-control', 'regular-text', $input );
375
-
376
-	$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
377
-	if ( ! empty( $url ) ) {
378
-		$url = esc_url_raw( $url );
379
-		echo '&nbsp;<a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
380
-	}
358
+    $profile_id = $subscription->get_profile_id();
359
+
360
+    $input = aui()->input(
361
+        array(
362
+            'type'        => 'text',
363
+            'id'          => 'wpinv_subscription_profile_id',
364
+            'name'        => 'wpinv_subscription_profile_id',
365
+            'label'       => __( 'Profile Id', 'invoicing' ),
366
+            'label_type'  => 'hidden',
367
+            'placeholder' => __( 'Profile Id', 'invoicing' ),
368
+            'value'       => esc_attr( $profile_id ),
369
+            'input_group_right' => '',
370
+            'no_wrap'     => true,
371
+        )
372
+    );
373
+
374
+    echo str_ireplace( 'form-control', 'regular-text', $input );
375
+
376
+    $url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
377
+    if ( ! empty( $url ) ) {
378
+        $url = esc_url_raw( $url );
379
+        echo '&nbsp;<a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
380
+    }
381 381
 
382 382
 }
383 383
 add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
@@ -389,39 +389,39 @@  discard block
 block discarded – undo
389 389
  */
390 390
 function getpaid_admin_subscription_update_metabox( $subscription ) {
391 391
 
392
-	?>
392
+    ?>
393 393
 	<div class="mt-3">
394 394
 
395 395
 		<?php
396
-			echo aui()->select(
397
-				array(
398
-					'options'          => getpaid_get_subscription_statuses(),
399
-					'name'             => 'subscription_status',
400
-					'id'               => 'subscription_status_update_select',
401
-					'required'         => true,
402
-					'no_wrap'          => false,
403
-					'label'            => __( 'Subscription Status', 'invoicing' ),
404
-					'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
405
-					'select2'          => true,
406
-					'value'            => $subscription->get_status( 'edit' ),
407
-				)
408
-			);
409
-		?>
396
+            echo aui()->select(
397
+                array(
398
+                    'options'          => getpaid_get_subscription_statuses(),
399
+                    'name'             => 'subscription_status',
400
+                    'id'               => 'subscription_status_update_select',
401
+                    'required'         => true,
402
+                    'no_wrap'          => false,
403
+                    'label'            => __( 'Subscription Status', 'invoicing' ),
404
+                    'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
405
+                    'select2'          => true,
406
+                    'value'            => $subscription->get_status( 'edit' ),
407
+                )
408
+            );
409
+        ?>
410 410
 
411 411
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
412 412
 
413 413
 		<?php
414
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
414
+            submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
415 415
 
416
-			$url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
417
-			$anchor = __( 'Renew Subscription', 'invoicing' );
418
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
416
+            $url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
417
+            $anchor = __( 'Renew Subscription', 'invoicing' );
418
+            $title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
419 419
 
420
-			if ( $subscription->is_active() ) {
421
-				echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
422
-			}
420
+            if ( $subscription->is_active() ) {
421
+                echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
422
+            }
423 423
 
424
-	echo '</div></div>';
424
+    echo '</div></div>';
425 425
 }
426 426
 
427 427
 /**
@@ -432,33 +432,33 @@  discard block
 block discarded – undo
432 432
  */
433 433
 function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
434 434
 
435
-	$columns = apply_filters(
436
-		'getpaid_subscription_related_invoices_columns',
437
-		array(
438
-			'invoice'      => __( 'Invoice', 'invoicing' ),
439
-			'relationship' => __( 'Relationship', 'invoicing' ),
440
-			'date'         => __( 'Date', 'invoicing' ),
441
-			'status'       => __( 'Status', 'invoicing' ),
442
-			'total'        => __( 'Total', 'invoicing' ),
443
-		),
444
-		$subscription
445
-	);
446
-
447
-	// Prepare the invoices.
448
-	$payments = $subscription->get_child_payments( ! is_admin() );
449
-	$parent   = $subscription->get_parent_invoice();
450
-
451
-	if ( $parent->exists() ) {
452
-		$payments = array_merge( array( $parent ), $payments );
453
-	}
454
-
455
-	$table_class = 'w-100 bg-white';
456
-
457
-	if ( ! is_admin() ) {
458
-		$table_class = 'table table-bordered';
459
-	}
460
-
461
-	?>
435
+    $columns = apply_filters(
436
+        'getpaid_subscription_related_invoices_columns',
437
+        array(
438
+            'invoice'      => __( 'Invoice', 'invoicing' ),
439
+            'relationship' => __( 'Relationship', 'invoicing' ),
440
+            'date'         => __( 'Date', 'invoicing' ),
441
+            'status'       => __( 'Status', 'invoicing' ),
442
+            'total'        => __( 'Total', 'invoicing' ),
443
+        ),
444
+        $subscription
445
+    );
446
+
447
+    // Prepare the invoices.
448
+    $payments = $subscription->get_child_payments( ! is_admin() );
449
+    $parent   = $subscription->get_parent_invoice();
450
+
451
+    if ( $parent->exists() ) {
452
+        $payments = array_merge( array( $parent ), $payments );
453
+    }
454
+
455
+    $table_class = 'w-100 bg-white';
456
+
457
+    if ( ! is_admin() ) {
458
+        $table_class = 'table table-bordered';
459
+    }
460
+
461
+    ?>
462 462
 		<div class="m-0" style="overflow: auto;">
463 463
 
464 464
 			<table class="<?php echo $table_class; ?>">
@@ -466,14 +466,14 @@  discard block
 block discarded – undo
466 466
 				<thead>
467 467
 					<tr>
468 468
 						<?php
469
-							foreach ( $columns as $key => $label ) {
470
-								$key   = esc_attr( $key );
471
-								$label = esc_html( $label );
472
-								$class = 'text-left';
473
-
474
-								echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
475
-							}
476
-						?>
469
+                            foreach ( $columns as $key => $label ) {
470
+                                $key   = esc_attr( $key );
471
+                                $label = esc_html( $label );
472
+                                $class = 'text-left';
473
+
474
+                                echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
475
+                            }
476
+                        ?>
477 477
 					</tr>
478 478
 				</thead>
479 479
 
@@ -489,73 +489,73 @@  discard block
 block discarded – undo
489 489
 
490 490
 					<?php
491 491
 
492
-						foreach( $payments as $payment ) :
492
+                        foreach( $payments as $payment ) :
493 493
 
494
-							// Ensure that we have an invoice.
495
-							$payment = new WPInv_Invoice( $payment );
494
+                            // Ensure that we have an invoice.
495
+                            $payment = new WPInv_Invoice( $payment );
496 496
 
497
-							// Abort if the invoice is invalid...
498
-							if ( ! $payment->exists() ) {
499
-								continue;
500
-							}
497
+                            // Abort if the invoice is invalid...
498
+                            if ( ! $payment->exists() ) {
499
+                                continue;
500
+                            }
501 501
 
502
-							// ... or belongs to a different subscription.
503
-							if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
504
-								continue;
505
-							}
502
+                            // ... or belongs to a different subscription.
503
+                            if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
504
+                                continue;
505
+                            }
506 506
 
507
-							echo '<tr>';
507
+                            echo '<tr>';
508 508
 
509
-								foreach ( array_keys( $columns ) as $key ) {
509
+                                foreach ( array_keys( $columns ) as $key ) {
510 510
 
511
-									$class = 'text-left';
511
+                                    $class = 'text-left';
512 512
 
513
-									echo "<td class='p-2 $class'>";
513
+                                    echo "<td class='p-2 $class'>";
514 514
 
515
-										switch( $key ) {
515
+                                        switch( $key ) {
516 516
 
517
-											case 'total':
518
-												echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>';
519
-												break;
517
+                                            case 'total':
518
+                                                echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>';
519
+                                                break;
520 520
 
521
-											case 'relationship':
522
-												echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
523
-												break;
521
+                                            case 'relationship':
522
+                                                echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
523
+                                                break;
524 524
 
525
-											case 'date':
526
-												echo getpaid_format_date_value( $payment->get_date_created() );
527
-												break;
525
+                                            case 'date':
526
+                                                echo getpaid_format_date_value( $payment->get_date_created() );
527
+                                                break;
528 528
 
529
-											case 'status':
529
+                                            case 'status':
530 530
 
531
-												$status = $payment->get_status_nicename();
532
-												if ( is_admin() ) {
533
-													$status = $payment->get_status_label_html();
534
-												}
531
+                                                $status = $payment->get_status_nicename();
532
+                                                if ( is_admin() ) {
533
+                                                    $status = $payment->get_status_label_html();
534
+                                                }
535 535
 
536
-												echo $status;
537
-												break;
536
+                                                echo $status;
537
+                                                break;
538 538
 
539
-											case 'invoice':
540
-												$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
539
+                                            case 'invoice':
540
+                                                $link    = esc_url( get_edit_post_link( $payment->get_id() ) );
541 541
 
542
-												if ( ! is_admin() ) {
543
-													$link = esc_url( $payment->get_view_url() );
544
-												}
542
+                                                if ( ! is_admin() ) {
543
+                                                    $link = esc_url( $payment->get_view_url() );
544
+                                                }
545 545
 
546
-												$invoice = esc_html( $payment->get_number() );
547
-												echo "<a href='$link'>$invoice</a>";
548
-												break;
549
-										}
546
+                                                $invoice = esc_html( $payment->get_number() );
547
+                                                echo "<a href='$link'>$invoice</a>";
548
+                                                break;
549
+                                        }
550 550
 
551
-									echo '</td>';
551
+                                    echo '</td>';
552 552
 
553
-								}
553
+                                }
554 554
 
555
-							echo '</tr>';
555
+                            echo '</tr>';
556 556
 
557
-						endforeach;
558
-					?>
557
+                        endforeach;
558
+                    ?>
559 559
 
560 560
 				</tbody>
561 561
 
@@ -573,42 +573,42 @@  discard block
 block discarded – undo
573 573
  */
574 574
 function getpaid_admin_subscription_item_details_metabox( $subscription ) {
575 575
 
576
-	// Fetch the subscription group.
577
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
576
+    // Fetch the subscription group.
577
+    $subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
578 578
 
579
-	if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
580
-		return;
581
-	}
579
+    if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
580
+        return;
581
+    }
582 582
 
583
-	// Prepare table columns.
584
-	$columns = apply_filters(
585
-		'getpaid_subscription_item_details_columns',
586
-		array(
587
-			'item_name'    => __( 'Item', 'invoicing' ),
588
-			'price'        => __( 'Price', 'invoicing' ),
589
-			'tax'          => __( 'Tax', 'invoicing' ),
590
-			'discount'     => __( 'Discount', 'invoicing' ),
591
-			//'initial'      => __( 'Initial Amount', 'invoicing' ),
592
-			'recurring'    => __( 'Subtotal', 'invoicing' ),
593
-		),
594
-		$subscription
595
-	);
583
+    // Prepare table columns.
584
+    $columns = apply_filters(
585
+        'getpaid_subscription_item_details_columns',
586
+        array(
587
+            'item_name'    => __( 'Item', 'invoicing' ),
588
+            'price'        => __( 'Price', 'invoicing' ),
589
+            'tax'          => __( 'Tax', 'invoicing' ),
590
+            'discount'     => __( 'Discount', 'invoicing' ),
591
+            //'initial'      => __( 'Initial Amount', 'invoicing' ),
592
+            'recurring'    => __( 'Subtotal', 'invoicing' ),
593
+        ),
594
+        $subscription
595
+    );
596 596
 
597
-	// Prepare the invoices.
597
+    // Prepare the invoices.
598 598
 
599
-	$invoice = $subscription->get_parent_invoice();
599
+    $invoice = $subscription->get_parent_invoice();
600 600
 
601
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
602
-		unset( $columns['tax'] );
603
-	}
601
+    if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
602
+        unset( $columns['tax'] );
603
+    }
604 604
 
605
-	$table_class = 'w-100 bg-white';
605
+    $table_class = 'w-100 bg-white';
606 606
 
607
-	if ( ! is_admin() ) {
608
-		$table_class = 'table table-bordered';
609
-	}
607
+    if ( ! is_admin() ) {
608
+        $table_class = 'table table-bordered';
609
+    }
610 610
 
611
-	?>
611
+    ?>
612 612
 		<div class="m-0" style="overflow: auto;">
613 613
 
614 614
 			<table class="<?php echo $table_class; ?>">
@@ -617,14 +617,14 @@  discard block
 block discarded – undo
617 617
 					<tr>
618 618
 						<?php
619 619
 
620
-							foreach ( $columns as $key => $label ) {
621
-								$key   = esc_attr( $key );
622
-								$label = esc_html( $label );
623
-								$class = 'text-left';
620
+                            foreach ( $columns as $key => $label ) {
621
+                                $key   = esc_attr( $key );
622
+                                $label = esc_html( $label );
623
+                                $class = 'text-left';
624 624
 
625
-								echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
626
-							}
627
-						?>
625
+                                echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
626
+                            }
627
+                        ?>
628 628
 					</tr>
629 629
 				</thead>
630 630
 
@@ -632,106 +632,106 @@  discard block
 block discarded – undo
632 632
 
633 633
 					<?php
634 634
 
635
-						foreach( $subscription_group['items'] as $subscription_group_item ) :
635
+                        foreach( $subscription_group['items'] as $subscription_group_item ) :
636 636
 
637
-							echo '<tr>';
637
+                            echo '<tr>';
638 638
 
639
-								foreach ( array_keys( $columns ) as $key ) {
639
+                                foreach ( array_keys( $columns ) as $key ) {
640 640
 
641
-									$class = 'text-left';
641
+                                    $class = 'text-left';
642 642
 
643
-									echo "<td class='p-2 $class'>";
643
+                                    echo "<td class='p-2 $class'>";
644 644
 
645
-										switch( $key ) {
645
+                                        switch( $key ) {
646 646
 
647
-											case 'item_name':
648
-												$item_name = get_the_title( $subscription_group_item['item_id'] );
649
-												$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
647
+                                            case 'item_name':
648
+                                                $item_name = get_the_title( $subscription_group_item['item_id'] );
649
+                                                $item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
650 650
 
651
-												if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
652
-													echo esc_html( $item_name );
653
-												} else {
654
-													printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
655
-												}
651
+                                                if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
652
+                                                    echo esc_html( $item_name );
653
+                                                } else {
654
+                                                    printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
655
+                                                }
656 656
 
657
-												break;
657
+                                                break;
658 658
 
659
-											case 'price':
660
-												echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() );
661
-												break;
659
+                                            case 'price':
660
+                                                echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() );
661
+                                                break;
662 662
 
663
-											case 'tax':
664
-												echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() );
665
-												break;
663
+                                            case 'tax':
664
+                                                echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() );
665
+                                                break;
666 666
 
667
-											case 'discount':
668
-												echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() );
669
-												break;
667
+                                            case 'discount':
668
+                                                echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() );
669
+                                                break;
670 670
 
671
-											case 'initial':
672
-												echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
673
-												break;
671
+                                            case 'initial':
672
+                                                echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
673
+                                                break;
674 674
 
675
-											case 'recurring':
676
-												echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>';
677
-												break;
675
+                                            case 'recurring':
676
+                                                echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>';
677
+                                                break;
678 678
 
679
-										}
679
+                                        }
680 680
 
681
-									echo '</td>';
681
+                                    echo '</td>';
682 682
 
683
-								}
683
+                                }
684 684
 
685
-							echo '</tr>';
685
+                            echo '</tr>';
686 686
 
687
-						endforeach;
687
+                        endforeach;
688 688
 
689
-						foreach( $subscription_group['fees'] as $subscription_group_fee ) :
689
+                        foreach( $subscription_group['fees'] as $subscription_group_fee ) :
690 690
 
691
-							echo '<tr>';
691
+                            echo '<tr>';
692 692
 
693
-								foreach ( array_keys( $columns ) as $key ) {
693
+                                foreach ( array_keys( $columns ) as $key ) {
694 694
 
695
-									$class = 'text-left';
695
+                                    $class = 'text-left';
696 696
 
697
-									echo "<td class='p-2 $class'>";
697
+                                    echo "<td class='p-2 $class'>";
698 698
 
699
-										switch( $key ) {
699
+                                        switch( $key ) {
700 700
 
701
-											case 'item_name':
702
-												echo esc_html( $subscription_group_fee['name'] );
703
-												break;
701
+                                            case 'item_name':
702
+                                                echo esc_html( $subscription_group_fee['name'] );
703
+                                                break;
704 704
 
705
-											case 'price':
706
-												echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
707
-												break;
705
+                                            case 'price':
706
+                                                echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
707
+                                                break;
708 708
 
709
-											case 'tax':
710
-												echo "&mdash;";
711
-												break;
709
+                                            case 'tax':
710
+                                                echo "&mdash;";
711
+                                                break;
712 712
 
713
-											case 'discount':
714
-												echo "&mdash;";
715
-												break;
713
+                                            case 'discount':
714
+                                                echo "&mdash;";
715
+                                                break;
716 716
 
717
-											case 'initial':
718
-												echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
719
-												break;
717
+                                            case 'initial':
718
+                                                echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
719
+                                                break;
720 720
 
721
-											case 'recurring':
722
-												echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>';
723
-												break;
721
+                                            case 'recurring':
722
+                                                echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>';
723
+                                                break;
724 724
 
725
-										}
725
+                                        }
726 726
 
727
-									echo '</td>';
727
+                                    echo '</td>';
728 728
 
729
-								}
729
+                                }
730 730
 
731
-							echo '</tr>';
731
+                            echo '</tr>';
732 732
 
733
-						endforeach;
734
-					?>
733
+                        endforeach;
734
+                    ?>
735 735
 
736 736
 				</tbody>
737 737
 
@@ -750,38 +750,38 @@  discard block
 block discarded – undo
750 750
  */
751 751
 function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
752 752
 
753
-	// Fetch the subscription groups.
754
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
755
-
756
-	if ( empty( $subscription_groups ) ) {
757
-		return;
758
-	}
759
-
760
-	// Prepare table columns.
761
-	$columns = apply_filters(
762
-		'getpaid_subscription_related_subscriptions_columns',
763
-		array(
764
-			'subscription'      => __( 'Subscription', 'invoicing' ),
765
-			'start_date'        => __( 'Start Date', 'invoicing' ),
766
-			'renewal_date'      => __( 'Next Payment', 'invoicing' ),
767
-			'renewals'          => __( 'Payments', 'invoicing' ),
768
-			'item'              => __( 'Items', 'invoicing' ),
769
-			'status'            => __( 'Status', 'invoicing' ),
770
-		),
771
-		$subscription
772
-	);
773
-
774
-	if ( $subscription->get_status() == 'pending' ) {
775
-		unset( $columns['start_date'], $columns['renewal_date'] );
776
-	}
777
-
778
-	$table_class = 'w-100 bg-white';
779
-
780
-	if ( ! is_admin() ) {
781
-		$table_class = 'table table-bordered';
782
-	}
783
-
784
-	?>
753
+    // Fetch the subscription groups.
754
+    $subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
755
+
756
+    if ( empty( $subscription_groups ) ) {
757
+        return;
758
+    }
759
+
760
+    // Prepare table columns.
761
+    $columns = apply_filters(
762
+        'getpaid_subscription_related_subscriptions_columns',
763
+        array(
764
+            'subscription'      => __( 'Subscription', 'invoicing' ),
765
+            'start_date'        => __( 'Start Date', 'invoicing' ),
766
+            'renewal_date'      => __( 'Next Payment', 'invoicing' ),
767
+            'renewals'          => __( 'Payments', 'invoicing' ),
768
+            'item'              => __( 'Items', 'invoicing' ),
769
+            'status'            => __( 'Status', 'invoicing' ),
770
+        ),
771
+        $subscription
772
+    );
773
+
774
+    if ( $subscription->get_status() == 'pending' ) {
775
+        unset( $columns['start_date'], $columns['renewal_date'] );
776
+    }
777
+
778
+    $table_class = 'w-100 bg-white';
779
+
780
+    if ( ! is_admin() ) {
781
+        $table_class = 'table table-bordered';
782
+    }
783
+
784
+    ?>
785 785
 		<div class="m-0" style="overflow: auto;">
786 786
 
787 787
 			<table class="<?php echo $table_class; ?>">
@@ -790,14 +790,14 @@  discard block
 block discarded – undo
790 790
 					<tr>
791 791
 						<?php
792 792
 
793
-							foreach ( $columns as $key => $label ) {
794
-								$key   = esc_attr( $key );
795
-								$label = esc_html( $label );
796
-								$class = 'text-left';
793
+                            foreach ( $columns as $key => $label ) {
794
+                                $key   = esc_attr( $key );
795
+                                $label = esc_html( $label );
796
+                                $class = 'text-left';
797 797
 
798
-								echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
799
-							}
800
-						?>
798
+                                echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
799
+                            }
800
+                        ?>
801 801
 					</tr>
802 802
 				</thead>
803 803
 
@@ -805,74 +805,74 @@  discard block
 block discarded – undo
805 805
 
806 806
 					<?php
807 807
 
808
-						foreach( $subscription_groups as $subscription_group ) :
808
+                        foreach( $subscription_groups as $subscription_group ) :
809 809
 
810
-							// Do not list current subscription.
811
-							if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
812
-								continue;
813
-							}
810
+                            // Do not list current subscription.
811
+                            if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
812
+                                continue;
813
+                            }
814 814
 
815
-							// Ensure the subscription exists.
816
-							$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
815
+                            // Ensure the subscription exists.
816
+                            $_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
817 817
 
818
-							if ( ! $_suscription->exists() ) {
819
-								continue;
820
-							}
818
+                            if ( ! $_suscription->exists() ) {
819
+                                continue;
820
+                            }
821 821
 
822
-							echo '<tr>';
822
+                            echo '<tr>';
823 823
 
824
-								foreach ( array_keys( $columns ) as $key ) {
824
+                                foreach ( array_keys( $columns ) as $key ) {
825 825
 
826
-									$class = 'text-left';
826
+                                    $class = 'text-left';
827 827
 
828
-									echo "<td class='p-2 $class'>";
828
+                                    echo "<td class='p-2 $class'>";
829 829
 
830
-										switch( $key ) {
830
+                                        switch( $key ) {
831 831
 
832
-											case 'status':
833
-												echo $_suscription->get_status_label_html();
834
-												break;
832
+                                            case 'status':
833
+                                                echo $_suscription->get_status_label_html();
834
+                                                break;
835 835
 
836
-											case 'item':
837
-												$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
838
-												echo implode( ' | ', $markup );
839
-												break;
836
+                                            case 'item':
837
+                                                $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
838
+                                                echo implode( ' | ', $markup );
839
+                                                break;
840 840
 
841
-											case 'renewals':
842
-												$max_bills = $_suscription->get_bill_times();
843
-												echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
844
-												break;
841
+                                            case 'renewals':
842
+                                                $max_bills = $_suscription->get_bill_times();
843
+                                                echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
844
+                                                break;
845 845
 
846
-											case 'renewal_date':
847
-												echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "&mdash;";
848
-												break;
846
+                                            case 'renewal_date':
847
+                                                echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "&mdash;";
848
+                                                break;
849 849
 
850
-											case 'start_date':
851
-												echo 'pending' == $_suscription->get_status() ? "&mdash;" : getpaid_format_date_value( $_suscription->get_date_created() );
852
-												break;
850
+                                            case 'start_date':
851
+                                                echo 'pending' == $_suscription->get_status() ? "&mdash;" : getpaid_format_date_value( $_suscription->get_date_created() );
852
+                                                break;
853 853
 
854
-											case 'subscription':
855
-												$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
856
-												printf(
857
-													'%1$s#%2$s%3$s',
858
-													'<a href="' . esc_url( $url ) . '">',
859
-													'<strong>' . intval( $_suscription->get_id() ) . '</strong>',
860
-													'</a>'
861
-												);
854
+                                            case 'subscription':
855
+                                                $url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
856
+                                                printf(
857
+                                                    '%1$s#%2$s%3$s',
858
+                                                    '<a href="' . esc_url( $url ) . '">',
859
+                                                    '<strong>' . intval( $_suscription->get_id() ) . '</strong>',
860
+                                                    '</a>'
861
+                                                );
862 862
 
863
-												echo WPInv_Subscriptions_List_Table::column_amount( $_suscription );
864
-												break;
863
+                                                echo WPInv_Subscriptions_List_Table::column_amount( $_suscription );
864
+                                                break;
865 865
 
866
-										}
866
+                                        }
867 867
 
868
-									echo '</td>';
868
+                                    echo '</td>';
869 869
 
870
-								}
870
+                                }
871 871
 
872
-							echo '</tr>';
872
+                            echo '</tr>';
873 873
 
874
-						endforeach;
875
-					?>
874
+                        endforeach;
875
+                    ?>
876 876
 
877 877
 				</tbody>
878 878
 
Please login to merge, or discard this patch.
Spacing   +198 added lines, -198 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
  * Contains functions that display the subscriptions admin page.
4 4
  */
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 /**
9 9
  * Render the Subscriptions page
@@ -17,22 +17,22 @@  discard block
 block discarded – undo
17 17
 	?>
18 18
 
19 19
 	<div class="wrap">
20
-		<h1><?php echo esc_html( get_admin_page_title() ); ?></h1>
20
+		<h1><?php echo esc_html(get_admin_page_title()); ?></h1>
21 21
 		<div class="bsui">
22 22
 
23 23
 			<?php
24 24
 
25 25
 				// Verify user permissions.
26
-				if ( ! wpinv_current_user_can_manage_invoicing() ) {
26
+				if (!wpinv_current_user_can_manage_invoicing()) {
27 27
 
28 28
 					echo aui()->alert(
29 29
 						array(
30 30
 							'type'    => 'danger',
31
-							'content' => __( 'You are not permitted to view this page.', 'invoicing' ),
31
+							'content' => __('You are not permitted to view this page.', 'invoicing'),
32 32
 						)
33 33
 					);
34 34
 
35
-				} else if ( ! empty( $_GET['id'] ) && is_numeric( $_GET['id'] ) ) {
35
+				} else if (!empty($_GET['id']) && is_numeric($_GET['id'])) {
36 36
 
37 37
 					// Display a single subscription.
38 38
 					wpinv_recurring_subscription_details();
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	<?php $subscribers_table->views(); ?>
67 67
 	<form id="subscribers-filter" class="bsui" method="get">
68 68
 		<input type="hidden" name="page" value="wpinv-subscriptions" />
69
-		<?php $subscribers_table->search_box( __( 'Search Subscriptions', 'invoicing' ), 'getpaid-search-subscriptions' ); ?>
69
+		<?php $subscribers_table->search_box(__('Search Subscriptions', 'invoicing'), 'getpaid-search-subscriptions'); ?>
70 70
 		<?php $subscribers_table->display(); ?>
71 71
 	</form>
72 72
 	<?php
@@ -82,13 +82,13 @@  discard block
 block discarded – undo
82 82
 function wpinv_recurring_subscription_details() {
83 83
 
84 84
 	// Fetch the subscription.
85
-	$sub = new WPInv_Subscription( (int) $_GET['id'] );
86
-	if ( ! $sub->exists() ) {
85
+	$sub = new WPInv_Subscription((int) $_GET['id']);
86
+	if (!$sub->exists()) {
87 87
 
88 88
 		echo aui()->alert(
89 89
 			array(
90 90
 				'type'    => 'danger',
91
-				'content' => __( 'Subscription not found.', 'invoicing' ),
91
+				'content' => __('Subscription not found.', 'invoicing'),
92 92
 			)
93 93
 		);
94 94
 
@@ -96,45 +96,45 @@  discard block
 block discarded – undo
96 96
 	}
97 97
 
98 98
 	// Use metaboxes to display the subscription details.
99
-	add_meta_box( 'getpaid_admin_subscription_details_metabox', __( 'Subscription Details', 'invoicing' ), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high' );
100
-	add_meta_box( 'getpaid_admin_subscription_update_metabox', __( 'Change Status', 'invoicing' ), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side' );
99
+	add_meta_box('getpaid_admin_subscription_details_metabox', __('Subscription Details', 'invoicing'), 'getpaid_admin_subscription_details_metabox', get_current_screen(), 'normal', 'high');
100
+	add_meta_box('getpaid_admin_subscription_update_metabox', __('Change Status', 'invoicing'), 'getpaid_admin_subscription_update_metabox', get_current_screen(), 'side');
101 101
 
102 102
 	$subscription_id     = $sub->get_id();
103
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $sub->get_parent_invoice_id() );
104
-	$subscription_group  = wp_list_filter( $subscription_groups, compact( 'subscription_id' ) );
103
+	$subscription_groups = getpaid_get_invoice_subscription_groups($sub->get_parent_invoice_id());
104
+	$subscription_group  = wp_list_filter($subscription_groups, compact('subscription_id'));
105 105
 
106
-	if ( 1 < count( $subscription_groups ) ) {
107
-		add_meta_box( 'getpaid_admin_subscription_related_subscriptions_metabox', __( 'Related Subscriptions', 'invoicing' ), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced' );
106
+	if (1 < count($subscription_groups)) {
107
+		add_meta_box('getpaid_admin_subscription_related_subscriptions_metabox', __('Related Subscriptions', 'invoicing'), 'getpaid_admin_subscription_related_subscriptions_metabox', get_current_screen(), 'advanced');
108 108
 	}
109 109
 
110
-	if ( ! empty( $subscription_group ) ) {
111
-		add_meta_box( 'getpaid_admin_subscription_item_details_metabox', __( 'Subscription Items', 'invoicing' ), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low' );
110
+	if (!empty($subscription_group)) {
111
+		add_meta_box('getpaid_admin_subscription_item_details_metabox', __('Subscription Items', 'invoicing'), 'getpaid_admin_subscription_item_details_metabox', get_current_screen(), 'normal', 'low');
112 112
 	}
113 113
 
114
-	add_meta_box( 'getpaid_admin_subscription_invoice_details_metabox', __( 'Related Invoices', 'invoicing' ), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced' );
114
+	add_meta_box('getpaid_admin_subscription_invoice_details_metabox', __('Related Invoices', 'invoicing'), 'getpaid_admin_subscription_invoice_details_metabox', get_current_screen(), 'advanced');
115 115
 
116
-	do_action( 'getpaid_admin_single_subscription_register_metabox', $sub );
116
+	do_action('getpaid_admin_single_subscription_register_metabox', $sub);
117 117
 
118 118
 	?>
119 119
 
120
-		<form method="post" action="<?php echo admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $sub->get_id() ) ); ?>">
120
+		<form method="post" action="<?php echo admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($sub->get_id())); ?>">
121 121
 
122
-			<?php wp_nonce_field( 'getpaid-nonce', 'getpaid-nonce' ); ?>
123
-			<?php wp_nonce_field( 'meta-box-order', 'meta-box-order-nonce', false ); ?>
124
-			<?php wp_nonce_field( 'closedpostboxes', 'closedpostboxesnonce', false ); ?>
122
+			<?php wp_nonce_field('getpaid-nonce', 'getpaid-nonce'); ?>
123
+			<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); ?>
124
+			<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); ?>
125 125
 			<input type="hidden" name="getpaid-admin-action" value="update_single_subscription" />
126
-			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id() ;?>" />
126
+			<input type="hidden" name="subscription_id" value="<?php echo (int) $sub->get_id(); ?>" />
127 127
 
128 128
 			<div id="poststuff">
129 129
 				<div id="post-body" class="metabox-holder columns-<?php echo 1 == get_current_screen()->get_columns() ? '1' : '2'; ?>">
130 130
 
131 131
 					<div id="postbox-container-1" class="postbox-container">
132
-						<?php do_meta_boxes( get_current_screen(), 'side', $sub ); ?>
132
+						<?php do_meta_boxes(get_current_screen(), 'side', $sub); ?>
133 133
 					</div>
134 134
 
135 135
 					<div id="postbox-container-2" class="postbox-container">
136
-						<?php do_meta_boxes( get_current_screen(), 'normal', $sub ); ?>
137
-						<?php do_meta_boxes( get_current_screen(), 'advanced', $sub ); ?>
136
+						<?php do_meta_boxes(get_current_screen(), 'normal', $sub); ?>
137
+						<?php do_meta_boxes(get_current_screen(), 'advanced', $sub); ?>
138 138
 					</div>
139 139
 
140 140
 				</div>
@@ -153,44 +153,44 @@  discard block
 block discarded – undo
153 153
  *
154 154
  * @param WPInv_Subscription $sub
155 155
  */
156
-function getpaid_admin_subscription_details_metabox( $sub ) {
156
+function getpaid_admin_subscription_details_metabox($sub) {
157 157
 
158 158
 	// Subscription items.
159
-	$subscription_group = getpaid_get_invoice_subscription_group( $sub->get_parent_invoice_id(), $sub->get_id() );
160
-	$items_count        = empty( $subscription_group ) ? 1 : count( $subscription_group['items'] );
159
+	$subscription_group = getpaid_get_invoice_subscription_group($sub->get_parent_invoice_id(), $sub->get_id());
160
+	$items_count        = empty($subscription_group) ? 1 : count($subscription_group['items']);
161 161
 
162 162
 	// Prepare subscription detail columns.
163 163
 	$fields = apply_filters(
164 164
 		'getpaid_subscription_admin_page_fields',
165 165
 		array(
166
-			'subscription'   => __( 'Subscription', 'invoicing' ),
167
-			'customer'       => __( 'Customer', 'invoicing' ),
168
-			'amount'         => __( 'Amount', 'invoicing' ),
169
-			'start_date'     => __( 'Start Date', 'invoicing' ),
170
-			'renews_on'      => __( 'Next Payment', 'invoicing' ),
171
-			'renewals'       => __( 'Payments', 'invoicing' ),
172
-			'item'           => _n( 'Item', 'Items', $items_count,  'invoicing' ),
173
-			'gateway'        => __( 'Payment Method', 'invoicing' ),
174
-			'profile_id'     => __( 'Profile ID', 'invoicing' ),
175
-			'status'         => __( 'Status', 'invoicing' ),
166
+			'subscription'   => __('Subscription', 'invoicing'),
167
+			'customer'       => __('Customer', 'invoicing'),
168
+			'amount'         => __('Amount', 'invoicing'),
169
+			'start_date'     => __('Start Date', 'invoicing'),
170
+			'renews_on'      => __('Next Payment', 'invoicing'),
171
+			'renewals'       => __('Payments', 'invoicing'),
172
+			'item'           => _n('Item', 'Items', $items_count, 'invoicing'),
173
+			'gateway'        => __('Payment Method', 'invoicing'),
174
+			'profile_id'     => __('Profile ID', 'invoicing'),
175
+			'status'         => __('Status', 'invoicing'),
176 176
 		)
177 177
 	);
178 178
 
179
-	if ( ! $sub->is_active() ) {
179
+	if (!$sub->is_active()) {
180 180
 
181
-		if ( isset( $fields['renews_on'] ) ) {
182
-			unset( $fields['renews_on'] );
181
+		if (isset($fields['renews_on'])) {
182
+			unset($fields['renews_on']);
183 183
 		}
184 184
 
185
-		if ( isset( $fields['gateway'] ) ) {
186
-			unset( $fields['gateway'] );
185
+		if (isset($fields['gateway'])) {
186
+			unset($fields['gateway']);
187 187
 		}
188 188
 
189 189
 	}
190 190
 
191 191
 	$profile_id = $sub->get_profile_id();
192
-	if ( empty( $profile_id ) && isset( $fields['profile_id'] ) ) {
193
-		unset( $fields['profile_id'] );
192
+	if (empty($profile_id) && isset($fields['profile_id'])) {
193
+		unset($fields['profile_id']);
194 194
 	}
195 195
 
196 196
 	?>
@@ -198,16 +198,16 @@  discard block
 block discarded – undo
198 198
 		<table class="table table-borderless" style="font-size: 14px;">
199 199
 			<tbody>
200 200
 
201
-				<?php foreach ( $fields as $key => $label ) : ?>
201
+				<?php foreach ($fields as $key => $label) : ?>
202 202
 
203
-					<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>">
203
+					<tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>">
204 204
 
205 205
 						<th class="w-25" style="font-weight: 500;">
206
-							<?php echo esc_html( $label ); ?>
206
+							<?php echo esc_html($label); ?>
207 207
 						</th>
208 208
 
209 209
 						<td class="w-75 text-muted">
210
-							<?php do_action( 'getpaid_subscription_admin_display_' . sanitize_key( $key ), $sub, $subscription_group ); ?>
210
+							<?php do_action('getpaid_subscription_admin_display_' . sanitize_key($key), $sub, $subscription_group); ?>
211 211
 						</td>
212 212
 
213 213
 					</tr>
@@ -225,135 +225,135 @@  discard block
 block discarded – undo
225 225
  *
226 226
  * @param WPInv_Subscription $subscription
227 227
  */
228
-function getpaid_admin_subscription_metabox_display_customer( $subscription ) {
228
+function getpaid_admin_subscription_metabox_display_customer($subscription) {
229 229
 
230
-	$username = __( '(Missing User)', 'invoicing' );
230
+	$username = __('(Missing User)', 'invoicing');
231 231
 
232
-	$user = get_userdata( $subscription->get_customer_id() );
233
-	if ( $user ) {
232
+	$user = get_userdata($subscription->get_customer_id());
233
+	if ($user) {
234 234
 
235 235
 		$username = sprintf(
236 236
 			'<a href="user-edit.php?user_id=%s">%s</a>',
237
-			absint( $user->ID ),
238
-			! empty( $user->display_name ) ? esc_html( $user->display_name ) : sanitize_email( $user->user_email )
237
+			absint($user->ID),
238
+			!empty($user->display_name) ? esc_html($user->display_name) : sanitize_email($user->user_email)
239 239
 		);
240 240
 
241 241
 	}
242 242
 
243 243
 	echo  $username;
244 244
 }
245
-add_action( 'getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer' );
245
+add_action('getpaid_subscription_admin_display_customer', 'getpaid_admin_subscription_metabox_display_customer');
246 246
 
247 247
 /**
248 248
  * Displays the subscription amount.
249 249
  *
250 250
  * @param WPInv_Subscription $subscription
251 251
  */
252
-function getpaid_admin_subscription_metabox_display_amount( $subscription ) {
253
-	$amount    = wp_kses_post( getpaid_get_formatted_subscription_amount( $subscription ) );
252
+function getpaid_admin_subscription_metabox_display_amount($subscription) {
253
+	$amount = wp_kses_post(getpaid_get_formatted_subscription_amount($subscription));
254 254
 	echo "<span>$amount</span>";
255 255
 }
256
-add_action( 'getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount' );
256
+add_action('getpaid_subscription_admin_display_amount', 'getpaid_admin_subscription_metabox_display_amount');
257 257
 
258 258
 /**
259 259
  * Displays the subscription id.
260 260
  *
261 261
  * @param WPInv_Subscription $subscription
262 262
  */
263
-function getpaid_admin_subscription_metabox_display_id( $subscription ) {
263
+function getpaid_admin_subscription_metabox_display_id($subscription) {
264 264
 
265 265
 	printf(
266 266
 		'<a href="%s">#%s</a>',
267
-		esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $subscription->get_id() ) ) ),
268
-		absint( $subscription->get_id() )
267
+		esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($subscription->get_id()))),
268
+		absint($subscription->get_id())
269 269
 	);
270 270
 
271 271
 }
272
-add_action( 'getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id' );
272
+add_action('getpaid_subscription_admin_display_subscription', 'getpaid_admin_subscription_metabox_display_id');
273 273
 
274 274
 /**
275 275
  * Displays the subscription renewal date.
276 276
  *
277 277
  * @param WPInv_Subscription $subscription
278 278
  */
279
-function getpaid_admin_subscription_metabox_display_start_date( $subscription ) {
280
-	echo getpaid_format_date_value( $subscription->get_date_created() );
279
+function getpaid_admin_subscription_metabox_display_start_date($subscription) {
280
+	echo getpaid_format_date_value($subscription->get_date_created());
281 281
 }
282
-add_action( 'getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date' );
282
+add_action('getpaid_subscription_admin_display_start_date', 'getpaid_admin_subscription_metabox_display_start_date');
283 283
 
284 284
 /**
285 285
  * Displays the subscription renewal date.
286 286
  *
287 287
  * @param WPInv_Subscription $subscription
288 288
  */
289
-function getpaid_admin_subscription_metabox_display_renews_on( $subscription ) {
290
-	echo getpaid_format_date_value( $subscription->get_expiration() );
289
+function getpaid_admin_subscription_metabox_display_renews_on($subscription) {
290
+	echo getpaid_format_date_value($subscription->get_expiration());
291 291
 }
292
-add_action( 'getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on' );
292
+add_action('getpaid_subscription_admin_display_renews_on', 'getpaid_admin_subscription_metabox_display_renews_on');
293 293
 
294 294
 /**
295 295
  * Displays the subscription renewal count.
296 296
  *
297 297
  * @param WPInv_Subscription $subscription
298 298
  */
299
-function getpaid_admin_subscription_metabox_display_renewals( $subscription ) {
299
+function getpaid_admin_subscription_metabox_display_renewals($subscription) {
300 300
 	$max_bills = $subscription->get_bill_times();
301
-	echo $subscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
301
+	echo $subscription->get_times_billed() . ' / ' . (empty($max_bills) ? "&infin;" : $max_bills);
302 302
 }
303
-add_action( 'getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals' );
303
+add_action('getpaid_subscription_admin_display_renewals', 'getpaid_admin_subscription_metabox_display_renewals');
304 304
 /**
305 305
  * Displays the subscription item.
306 306
  *
307 307
  * @param WPInv_Subscription $subscription
308 308
  * @param false|array $subscription_group
309 309
  */
310
-function getpaid_admin_subscription_metabox_display_item( $subscription, $subscription_group = false ) {
310
+function getpaid_admin_subscription_metabox_display_item($subscription, $subscription_group = false) {
311 311
 
312
-	if ( empty( $subscription_group ) ) {
313
-		echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() );
312
+	if (empty($subscription_group)) {
313
+		echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id());
314 314
 		return;
315 315
 	}
316 316
 
317
-	$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
318
-	echo implode( ' | ', $markup );
317
+	$markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items']));
318
+	echo implode(' | ', $markup);
319 319
 
320 320
 }
321
-add_action( 'getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2 );
321
+add_action('getpaid_subscription_admin_display_item', 'getpaid_admin_subscription_metabox_display_item', 10, 2);
322 322
 
323 323
 /**
324 324
  * Displays the subscription gateway.
325 325
  *
326 326
  * @param WPInv_Subscription $subscription
327 327
  */
328
-function getpaid_admin_subscription_metabox_display_gateway( $subscription ) {
328
+function getpaid_admin_subscription_metabox_display_gateway($subscription) {
329 329
 
330 330
 	$gateway = $subscription->get_gateway();
331 331
 
332
-	if ( ! empty( $gateway ) ) {
333
-		echo esc_html( wpinv_get_gateway_admin_label( $gateway ) );
332
+	if (!empty($gateway)) {
333
+		echo esc_html(wpinv_get_gateway_admin_label($gateway));
334 334
 	} else {
335 335
 		echo "&mdash;";
336 336
 	}
337 337
 
338 338
 }
339
-add_action( 'getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway' );
339
+add_action('getpaid_subscription_admin_display_gateway', 'getpaid_admin_subscription_metabox_display_gateway');
340 340
 
341 341
 /**
342 342
  * Displays the subscription status.
343 343
  *
344 344
  * @param WPInv_Subscription $subscription
345 345
  */
346
-function getpaid_admin_subscription_metabox_display_status( $subscription ) {
346
+function getpaid_admin_subscription_metabox_display_status($subscription) {
347 347
 	echo $subscription->get_status_label_html();
348 348
 }
349
-add_action( 'getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status' );
349
+add_action('getpaid_subscription_admin_display_status', 'getpaid_admin_subscription_metabox_display_status');
350 350
 
351 351
 /**
352 352
  * Displays the subscription profile id.
353 353
  *
354 354
  * @param WPInv_Subscription $subscription
355 355
  */
356
-function getpaid_admin_subscription_metabox_display_profile_id( $subscription ) {
356
+function getpaid_admin_subscription_metabox_display_profile_id($subscription) {
357 357
 
358 358
 	$profile_id = $subscription->get_profile_id();
359 359
 
@@ -362,32 +362,32 @@  discard block
 block discarded – undo
362 362
 			'type'        => 'text',
363 363
 			'id'          => 'wpinv_subscription_profile_id',
364 364
 			'name'        => 'wpinv_subscription_profile_id',
365
-			'label'       => __( 'Profile Id', 'invoicing' ),
365
+			'label'       => __('Profile Id', 'invoicing'),
366 366
 			'label_type'  => 'hidden',
367
-			'placeholder' => __( 'Profile Id', 'invoicing' ),
368
-			'value'       => esc_attr( $profile_id ),
367
+			'placeholder' => __('Profile Id', 'invoicing'),
368
+			'value'       => esc_attr($profile_id),
369 369
 			'input_group_right' => '',
370 370
 			'no_wrap'     => true,
371 371
 		)
372 372
 	);
373 373
 
374
-	echo str_ireplace( 'form-control', 'regular-text', $input );
374
+	echo str_ireplace('form-control', 'regular-text', $input);
375 375
 
376
-	$url = apply_filters( 'getpaid_remote_subscription_profile_url', '', $subscription );
377
-	if ( ! empty( $url ) ) {
378
-		$url = esc_url_raw( $url );
379
-		echo '&nbsp;<a href="' . $url . '" title="' . __( 'View in Gateway', 'invoicing' ) . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
376
+	$url = apply_filters('getpaid_remote_subscription_profile_url', '', $subscription);
377
+	if (!empty($url)) {
378
+		$url = esc_url_raw($url);
379
+		echo '&nbsp;<a href="' . $url . '" title="' . __('View in Gateway', 'invoicing') . '" target="_blank"><i class="fas fa-external-link-alt fa-xs fa-fw align-top"></i></a>';
380 380
 	}
381 381
 
382 382
 }
383
-add_action( 'getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id' );
383
+add_action('getpaid_subscription_admin_display_profile_id', 'getpaid_admin_subscription_metabox_display_profile_id');
384 384
 
385 385
 /**
386 386
  * Displays the subscriptions update metabox.
387 387
  *
388 388
  * @param WPInv_Subscription $subscription
389 389
  */
390
-function getpaid_admin_subscription_update_metabox( $subscription ) {
390
+function getpaid_admin_subscription_update_metabox($subscription) {
391 391
 
392 392
 	?>
393 393
 	<div class="mt-3">
@@ -400,10 +400,10 @@  discard block
 block discarded – undo
400 400
 					'id'               => 'subscription_status_update_select',
401 401
 					'required'         => true,
402 402
 					'no_wrap'          => false,
403
-					'label'            => __( 'Subscription Status', 'invoicing' ),
404
-					'help_text'        => __( 'Updating the status will trigger related actions and hooks', 'invoicing' ),
403
+					'label'            => __('Subscription Status', 'invoicing'),
404
+					'help_text'        => __('Updating the status will trigger related actions and hooks', 'invoicing'),
405 405
 					'select2'          => true,
406
-					'value'            => $subscription->get_status( 'edit' ),
406
+					'value'            => $subscription->get_status('edit'),
407 407
 				)
408 408
 			);
409 409
 		?>
@@ -411,13 +411,13 @@  discard block
 block discarded – undo
411 411
 		<div class="mt-2 px-3 py-2 bg-light border-top" style="margin: -12px;">
412 412
 
413 413
 		<?php
414
-			submit_button( __( 'Update', 'invoicing' ), 'primary', 'submit', false );
414
+			submit_button(__('Update', 'invoicing'), 'primary', 'submit', false);
415 415
 
416
-			$url    = esc_url( wp_nonce_url( add_query_arg( 'getpaid-admin-action', 'subscription_manual_renew' ), 'getpaid-nonce', 'getpaid-nonce' ) );
417
-			$anchor = __( 'Renew Subscription', 'invoicing' );
418
-			$title  = esc_attr__( 'Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing' );
416
+			$url    = esc_url(wp_nonce_url(add_query_arg('getpaid-admin-action', 'subscription_manual_renew'), 'getpaid-nonce', 'getpaid-nonce'));
417
+			$anchor = __('Renew Subscription', 'invoicing');
418
+			$title  = esc_attr__('Are you sure you want to extend the subscription and generate a new invoice that will be automatically marked as paid?', 'invoicing');
419 419
 
420
-			if ( $subscription->is_active() ) {
420
+			if ($subscription->is_active()) {
421 421
 				echo "<a href='$url' class='float-right text-muted' onclick='return confirm(\"$title\")'>$anchor</a>";
422 422
 			}
423 423
 
@@ -430,31 +430,31 @@  discard block
 block discarded – undo
430 430
  * @param WPInv_Subscription $subscription
431 431
  * @param bool $strict Whether or not to skip invoices of sibling subscriptions
432 432
  */
433
-function getpaid_admin_subscription_invoice_details_metabox( $subscription, $strict = true ) {
433
+function getpaid_admin_subscription_invoice_details_metabox($subscription, $strict = true) {
434 434
 
435 435
 	$columns = apply_filters(
436 436
 		'getpaid_subscription_related_invoices_columns',
437 437
 		array(
438
-			'invoice'      => __( 'Invoice', 'invoicing' ),
439
-			'relationship' => __( 'Relationship', 'invoicing' ),
440
-			'date'         => __( 'Date', 'invoicing' ),
441
-			'status'       => __( 'Status', 'invoicing' ),
442
-			'total'        => __( 'Total', 'invoicing' ),
438
+			'invoice'      => __('Invoice', 'invoicing'),
439
+			'relationship' => __('Relationship', 'invoicing'),
440
+			'date'         => __('Date', 'invoicing'),
441
+			'status'       => __('Status', 'invoicing'),
442
+			'total'        => __('Total', 'invoicing'),
443 443
 		),
444 444
 		$subscription
445 445
 	);
446 446
 
447 447
 	// Prepare the invoices.
448
-	$payments = $subscription->get_child_payments( ! is_admin() );
448
+	$payments = $subscription->get_child_payments(!is_admin());
449 449
 	$parent   = $subscription->get_parent_invoice();
450 450
 
451
-	if ( $parent->exists() ) {
452
-		$payments = array_merge( array( $parent ), $payments );
451
+	if ($parent->exists()) {
452
+		$payments = array_merge(array($parent), $payments);
453 453
 	}
454 454
 
455 455
 	$table_class = 'w-100 bg-white';
456 456
 
457
-	if ( ! is_admin() ) {
457
+	if (!is_admin()) {
458 458
 		$table_class = 'table table-bordered';
459 459
 	}
460 460
 
@@ -466,9 +466,9 @@  discard block
 block discarded – undo
466 466
 				<thead>
467 467
 					<tr>
468 468
 						<?php
469
-							foreach ( $columns as $key => $label ) {
470
-								$key   = esc_attr( $key );
471
-								$label = esc_html( $label );
469
+							foreach ($columns as $key => $label) {
470
+								$key   = esc_attr($key);
471
+								$label = esc_html($label);
472 472
 								$class = 'text-left';
473 473
 
474 474
 								echo "<th class='subscription-invoice-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
@@ -479,57 +479,57 @@  discard block
 block discarded – undo
479 479
 
480 480
 				<tbody>
481 481
 
482
-					<?php if ( empty( $payments ) ) : ?>
482
+					<?php if (empty($payments)) : ?>
483 483
 						<tr>
484 484
 							<td colspan="<?php echo count($columns); ?>" class="p-2 text-left text-muted">
485
-								<?php _e( 'This subscription has no invoices.', 'invoicing' ); ?>
485
+								<?php _e('This subscription has no invoices.', 'invoicing'); ?>
486 486
 							</td>
487 487
 						</tr>
488 488
 					<?php endif; ?>
489 489
 
490 490
 					<?php
491 491
 
492
-						foreach( $payments as $payment ) :
492
+						foreach ($payments as $payment) :
493 493
 
494 494
 							// Ensure that we have an invoice.
495
-							$payment = new WPInv_Invoice( $payment );
495
+							$payment = new WPInv_Invoice($payment);
496 496
 
497 497
 							// Abort if the invoice is invalid...
498
-							if ( ! $payment->exists() ) {
498
+							if (!$payment->exists()) {
499 499
 								continue;
500 500
 							}
501 501
 
502 502
 							// ... or belongs to a different subscription.
503
-							if ( $strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id() ) {
503
+							if ($strict && $payment->is_renewal() && $payment->get_subscription_id() && $payment->get_subscription_id() != $subscription->get_id()) {
504 504
 								continue;
505 505
 							}
506 506
 
507 507
 							echo '<tr>';
508 508
 
509
-								foreach ( array_keys( $columns ) as $key ) {
509
+								foreach (array_keys($columns) as $key) {
510 510
 
511 511
 									$class = 'text-left';
512 512
 
513 513
 									echo "<td class='p-2 $class'>";
514 514
 
515
-										switch( $key ) {
515
+										switch ($key) {
516 516
 
517 517
 											case 'total':
518
-												echo '<strong>' . wpinv_price( $payment->get_total(), $payment->get_currency() ) . '</strong>';
518
+												echo '<strong>' . wpinv_price($payment->get_total(), $payment->get_currency()) . '</strong>';
519 519
 												break;
520 520
 
521 521
 											case 'relationship':
522
-												echo $payment->is_renewal() ? __( 'Renewal Invoice', 'invoicing' ) : __( 'Initial Invoice', 'invoicing' );
522
+												echo $payment->is_renewal() ? __('Renewal Invoice', 'invoicing') : __('Initial Invoice', 'invoicing');
523 523
 												break;
524 524
 
525 525
 											case 'date':
526
-												echo getpaid_format_date_value( $payment->get_date_created() );
526
+												echo getpaid_format_date_value($payment->get_date_created());
527 527
 												break;
528 528
 
529 529
 											case 'status':
530 530
 
531 531
 												$status = $payment->get_status_nicename();
532
-												if ( is_admin() ) {
532
+												if (is_admin()) {
533 533
 													$status = $payment->get_status_label_html();
534 534
 												}
535 535
 
@@ -537,13 +537,13 @@  discard block
 block discarded – undo
537 537
 												break;
538 538
 
539 539
 											case 'invoice':
540
-												$link    = esc_url( get_edit_post_link( $payment->get_id() ) );
540
+												$link = esc_url(get_edit_post_link($payment->get_id()));
541 541
 
542
-												if ( ! is_admin() ) {
543
-													$link = esc_url( $payment->get_view_url() );
542
+												if (!is_admin()) {
543
+													$link = esc_url($payment->get_view_url());
544 544
 												}
545 545
 
546
-												$invoice = esc_html( $payment->get_number() );
546
+												$invoice = esc_html($payment->get_number());
547 547
 												echo "<a href='$link'>$invoice</a>";
548 548
 												break;
549 549
 										}
@@ -571,12 +571,12 @@  discard block
 block discarded – undo
571 571
  *
572 572
  * @param WPInv_Subscription $subscription
573 573
  */
574
-function getpaid_admin_subscription_item_details_metabox( $subscription ) {
574
+function getpaid_admin_subscription_item_details_metabox($subscription) {
575 575
 
576 576
 	// Fetch the subscription group.
577
-	$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_payment_id(), $subscription->get_id() );
577
+	$subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_payment_id(), $subscription->get_id());
578 578
 
579
-	if ( empty( $subscription_group ) || empty( $subscription_group['items'] ) ) {
579
+	if (empty($subscription_group) || empty($subscription_group['items'])) {
580 580
 		return;
581 581
 	}
582 582
 
@@ -584,12 +584,12 @@  discard block
 block discarded – undo
584 584
 	$columns = apply_filters(
585 585
 		'getpaid_subscription_item_details_columns',
586 586
 		array(
587
-			'item_name'    => __( 'Item', 'invoicing' ),
588
-			'price'        => __( 'Price', 'invoicing' ),
589
-			'tax'          => __( 'Tax', 'invoicing' ),
590
-			'discount'     => __( 'Discount', 'invoicing' ),
587
+			'item_name'    => __('Item', 'invoicing'),
588
+			'price'        => __('Price', 'invoicing'),
589
+			'tax'          => __('Tax', 'invoicing'),
590
+			'discount'     => __('Discount', 'invoicing'),
591 591
 			//'initial'      => __( 'Initial Amount', 'invoicing' ),
592
-			'recurring'    => __( 'Subtotal', 'invoicing' ),
592
+			'recurring'    => __('Subtotal', 'invoicing'),
593 593
 		),
594 594
 		$subscription
595 595
 	);
@@ -598,13 +598,13 @@  discard block
 block discarded – undo
598 598
 
599 599
 	$invoice = $subscription->get_parent_invoice();
600 600
 
601
-	if ( ( ! wpinv_use_taxes() || ! $invoice->is_taxable() ) && isset( $columns['tax'] ) ) {
602
-		unset( $columns['tax'] );
601
+	if ((!wpinv_use_taxes() || !$invoice->is_taxable()) && isset($columns['tax'])) {
602
+		unset($columns['tax']);
603 603
 	}
604 604
 
605 605
 	$table_class = 'w-100 bg-white';
606 606
 
607
-	if ( ! is_admin() ) {
607
+	if (!is_admin()) {
608 608
 		$table_class = 'table table-bordered';
609 609
 	}
610 610
 
@@ -617,9 +617,9 @@  discard block
 block discarded – undo
617 617
 					<tr>
618 618
 						<?php
619 619
 
620
-							foreach ( $columns as $key => $label ) {
621
-								$key   = esc_attr( $key );
622
-								$label = esc_html( $label );
620
+							foreach ($columns as $key => $label) {
621
+								$key   = esc_attr($key);
622
+								$label = esc_html($label);
623 623
 								$class = 'text-left';
624 624
 
625 625
 								echo "<th class='subscription-item-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
@@ -632,48 +632,48 @@  discard block
 block discarded – undo
632 632
 
633 633
 					<?php
634 634
 
635
-						foreach( $subscription_group['items'] as $subscription_group_item ) :
635
+						foreach ($subscription_group['items'] as $subscription_group_item) :
636 636
 
637 637
 							echo '<tr>';
638 638
 
639
-								foreach ( array_keys( $columns ) as $key ) {
639
+								foreach (array_keys($columns) as $key) {
640 640
 
641 641
 									$class = 'text-left';
642 642
 
643 643
 									echo "<td class='p-2 $class'>";
644 644
 
645
-										switch( $key ) {
645
+										switch ($key) {
646 646
 
647 647
 											case 'item_name':
648
-												$item_name = get_the_title( $subscription_group_item['item_id'] );
649
-												$item_name = empty( $item_name ) ? $subscription_group_item['item_name'] : $item_name;
648
+												$item_name = get_the_title($subscription_group_item['item_id']);
649
+												$item_name = empty($item_name) ? $subscription_group_item['item_name'] : $item_name;
650 650
 
651
-												if ( $invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity'] ) {
652
-													echo esc_html( $item_name );
651
+												if ($invoice->get_template() == 'amount' || 1 == (float) $subscription_group_item['quantity']) {
652
+													echo esc_html($item_name);
653 653
 												} else {
654
-													printf( '%1$s x %2$d', esc_html( $item_name ), (float) $subscription_group_item['quantity'] );
654
+													printf('%1$s x %2$d', esc_html($item_name), (float) $subscription_group_item['quantity']);
655 655
 												}
656 656
 
657 657
 												break;
658 658
 
659 659
 											case 'price':
660
-												echo wpinv_price( $subscription_group_item['item_price'], $invoice->get_currency() );
660
+												echo wpinv_price($subscription_group_item['item_price'], $invoice->get_currency());
661 661
 												break;
662 662
 
663 663
 											case 'tax':
664
-												echo wpinv_price( $subscription_group_item['tax'], $invoice->get_currency() );
664
+												echo wpinv_price($subscription_group_item['tax'], $invoice->get_currency());
665 665
 												break;
666 666
 
667 667
 											case 'discount':
668
-												echo wpinv_price( $subscription_group_item['discount'], $invoice->get_currency() );
668
+												echo wpinv_price($subscription_group_item['discount'], $invoice->get_currency());
669 669
 												break;
670 670
 
671 671
 											case 'initial':
672
-												echo wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() );
672
+												echo wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency());
673 673
 												break;
674 674
 
675 675
 											case 'recurring':
676
-												echo '<strong>' . wpinv_price( $subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency() ) . '</strong>';
676
+												echo '<strong>' . wpinv_price($subscription_group_item['price'] * $subscription_group_item['quantity'], $invoice->get_currency()) . '</strong>';
677 677
 												break;
678 678
 
679 679
 										}
@@ -686,24 +686,24 @@  discard block
 block discarded – undo
686 686
 
687 687
 						endforeach;
688 688
 
689
-						foreach( $subscription_group['fees'] as $subscription_group_fee ) :
689
+						foreach ($subscription_group['fees'] as $subscription_group_fee) :
690 690
 
691 691
 							echo '<tr>';
692 692
 
693
-								foreach ( array_keys( $columns ) as $key ) {
693
+								foreach (array_keys($columns) as $key) {
694 694
 
695 695
 									$class = 'text-left';
696 696
 
697 697
 									echo "<td class='p-2 $class'>";
698 698
 
699
-										switch( $key ) {
699
+										switch ($key) {
700 700
 
701 701
 											case 'item_name':
702
-												echo esc_html( $subscription_group_fee['name'] );
702
+												echo esc_html($subscription_group_fee['name']);
703 703
 												break;
704 704
 
705 705
 											case 'price':
706
-												echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
706
+												echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
707 707
 												break;
708 708
 
709 709
 											case 'tax':
@@ -715,11 +715,11 @@  discard block
 block discarded – undo
715 715
 												break;
716 716
 
717 717
 											case 'initial':
718
-												echo wpinv_price( $subscription_group_fee['initial_fee'], $invoice->get_currency() );
718
+												echo wpinv_price($subscription_group_fee['initial_fee'], $invoice->get_currency());
719 719
 												break;
720 720
 
721 721
 											case 'recurring':
722
-												echo '<strong>' . wpinv_price( $subscription_group_fee['recurring_fee'], $invoice->get_currency() ) . '</strong>';
722
+												echo '<strong>' . wpinv_price($subscription_group_fee['recurring_fee'], $invoice->get_currency()) . '</strong>';
723 723
 												break;
724 724
 
725 725
 										}
@@ -748,12 +748,12 @@  discard block
 block discarded – undo
748 748
  * @param WPInv_Subscription $subscription
749 749
  * @param bool $skip_current
750 750
  */
751
-function getpaid_admin_subscription_related_subscriptions_metabox( $subscription, $skip_current = true ) {
751
+function getpaid_admin_subscription_related_subscriptions_metabox($subscription, $skip_current = true) {
752 752
 
753 753
 	// Fetch the subscription groups.
754
-	$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_payment_id() );
754
+	$subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_payment_id());
755 755
 
756
-	if ( empty( $subscription_groups ) ) {
756
+	if (empty($subscription_groups)) {
757 757
 		return;
758 758
 	}
759 759
 
@@ -761,23 +761,23 @@  discard block
 block discarded – undo
761 761
 	$columns = apply_filters(
762 762
 		'getpaid_subscription_related_subscriptions_columns',
763 763
 		array(
764
-			'subscription'      => __( 'Subscription', 'invoicing' ),
765
-			'start_date'        => __( 'Start Date', 'invoicing' ),
766
-			'renewal_date'      => __( 'Next Payment', 'invoicing' ),
767
-			'renewals'          => __( 'Payments', 'invoicing' ),
768
-			'item'              => __( 'Items', 'invoicing' ),
769
-			'status'            => __( 'Status', 'invoicing' ),
764
+			'subscription'      => __('Subscription', 'invoicing'),
765
+			'start_date'        => __('Start Date', 'invoicing'),
766
+			'renewal_date'      => __('Next Payment', 'invoicing'),
767
+			'renewals'          => __('Payments', 'invoicing'),
768
+			'item'              => __('Items', 'invoicing'),
769
+			'status'            => __('Status', 'invoicing'),
770 770
 		),
771 771
 		$subscription
772 772
 	);
773 773
 
774
-	if ( $subscription->get_status() == 'pending' ) {
775
-		unset( $columns['start_date'], $columns['renewal_date'] );
774
+	if ($subscription->get_status() == 'pending') {
775
+		unset($columns['start_date'], $columns['renewal_date']);
776 776
 	}
777 777
 
778 778
 	$table_class = 'w-100 bg-white';
779 779
 
780
-	if ( ! is_admin() ) {
780
+	if (!is_admin()) {
781 781
 		$table_class = 'table table-bordered';
782 782
 	}
783 783
 
@@ -790,9 +790,9 @@  discard block
 block discarded – undo
790 790
 					<tr>
791 791
 						<?php
792 792
 
793
-							foreach ( $columns as $key => $label ) {
794
-								$key   = esc_attr( $key );
795
-								$label = esc_html( $label );
793
+							foreach ($columns as $key => $label) {
794
+								$key   = esc_attr($key);
795
+								$label = esc_html($label);
796 796
 								$class = 'text-left';
797 797
 
798 798
 								echo "<th class='related-subscription-field-$key bg-light p-2 $class color-dark font-weight-bold'>$label</th>";
@@ -805,62 +805,62 @@  discard block
 block discarded – undo
805 805
 
806 806
 					<?php
807 807
 
808
-						foreach( $subscription_groups as $subscription_group ) :
808
+						foreach ($subscription_groups as $subscription_group) :
809 809
 
810 810
 							// Do not list current subscription.
811
-							if ( $skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id() ) {
811
+							if ($skip_current && (int) $subscription_group['subscription_id'] === $subscription->get_id()) {
812 812
 								continue;
813 813
 							}
814 814
 
815 815
 							// Ensure the subscription exists.
816
-							$_suscription = new WPInv_Subscription( $subscription_group['subscription_id'] );
816
+							$_suscription = new WPInv_Subscription($subscription_group['subscription_id']);
817 817
 
818
-							if ( ! $_suscription->exists() ) {
818
+							if (!$_suscription->exists()) {
819 819
 								continue;
820 820
 							}
821 821
 
822 822
 							echo '<tr>';
823 823
 
824
-								foreach ( array_keys( $columns ) as $key ) {
824
+								foreach (array_keys($columns) as $key) {
825 825
 
826 826
 									$class = 'text-left';
827 827
 
828 828
 									echo "<td class='p-2 $class'>";
829 829
 
830
-										switch( $key ) {
830
+										switch ($key) {
831 831
 
832 832
 											case 'status':
833 833
 												echo $_suscription->get_status_label_html();
834 834
 												break;
835 835
 
836 836
 											case 'item':
837
-												$markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) );
838
-												echo implode( ' | ', $markup );
837
+												$markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items']));
838
+												echo implode(' | ', $markup);
839 839
 												break;
840 840
 
841 841
 											case 'renewals':
842 842
 												$max_bills = $_suscription->get_bill_times();
843
-												echo $_suscription->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
843
+												echo $_suscription->get_times_billed() . ' / ' . (empty($max_bills) ? "&infin;" : $max_bills);
844 844
 												break;
845 845
 
846 846
 											case 'renewal_date':
847
-												echo $_suscription->is_active() ? getpaid_format_date_value( $_suscription->get_expiration() ) : "&mdash;";
847
+												echo $_suscription->is_active() ? getpaid_format_date_value($_suscription->get_expiration()) : "&mdash;";
848 848
 												break;
849 849
 
850 850
 											case 'start_date':
851
-												echo 'pending' == $_suscription->get_status() ? "&mdash;" : getpaid_format_date_value( $_suscription->get_date_created() );
851
+												echo 'pending' == $_suscription->get_status() ? "&mdash;" : getpaid_format_date_value($_suscription->get_date_created());
852 852
 												break;
853 853
 
854 854
 											case 'subscription':
855
-												$url = is_admin() ? admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $_suscription->get_id() ) ) : $_suscription->get_view_url();
855
+												$url = is_admin() ? admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($_suscription->get_id())) : $_suscription->get_view_url();
856 856
 												printf(
857 857
 													'%1$s#%2$s%3$s',
858
-													'<a href="' . esc_url( $url ) . '">',
859
-													'<strong>' . intval( $_suscription->get_id() ) . '</strong>',
858
+													'<a href="' . esc_url($url) . '">',
859
+													'<strong>' . intval($_suscription->get_id()) . '</strong>',
860 860
 													'</a>'
861 861
 												);
862 862
 
863
-												echo WPInv_Subscriptions_List_Table::column_amount( $_suscription );
863
+												echo WPInv_Subscriptions_List_Table::column_amount($_suscription);
864 864
 												break;
865 865
 
866 866
 										}
Please login to merge, or discard this patch.