Passed
Pull Request — master (#412)
by Brian
04:08
created
includes/class-getpaid-payment-form-submission.php 1 patch
Indentation   +823 added lines, -823 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,890 +10,890 @@  discard block
 block discarded – undo
10 10
 class GetPaid_Payment_Form_Submission {
11 11
 
12 12
     /**
13
-	 * Submission ID
14
-	 *
15
-	 * @var string
16
-	 */
17
-	public $id = null;
13
+     * Submission ID
14
+     *
15
+     * @var string
16
+     */
17
+    public $id = null;
18 18
 
19
-	/**
20
-	 * Sets the associated payment form.
21
-	 *
22
-	 * @var GetPaid_Payment_Form
23
-	 */
19
+    /**
20
+     * Sets the associated payment form.
21
+     *
22
+     * @var GetPaid_Payment_Form
23
+     */
24 24
     protected $payment_form = null;
25 25
 
26 26
     /**
27
-	 * The country for the submission.
28
-	 *
29
-	 * @var string
30
-	 */
31
-	public $country = null;
32
-
33
-    /**
34
-	 * The state for the submission.
35
-	 *
36
-	 * @since 1.0.19
37
-	 * @var string
38
-	 */
39
-	public $state = null;
40
-
41
-	/**
42
-	 * The invoice associated with the submission.
43
-	 *
44
-	 * @var WPInv_Invoice
45
-	 */
46
-	protected $invoice = null;
47
-
48
-	/**
49
-	 * The discount associated with the submission.
50
-	 *
51
-	 * @var WPInv_Discount
52
-	 */
53
-	protected $discount = null;
54
-
55
-	/**
56
-	 * The raw submission data.
57
-	 *
58
-	 * @var array
59
-	 */
60
-	protected $data = null;
61
-
62
-	/**
63
-	 * Whether this submission contains a recurring item.
64
-	 *
65
-	 * @var bool
66
-	 */
67
-	public $has_recurring = false;
68
-
69
-	/**
70
-	 * The sub total amount for the submission.
71
-	 *
72
-	 * @var float
73
-	 */
74
-	public $subtotal_amount = 0;
75
-
76
-	/**
77
-	 * The total discount amount for the submission.
78
-	 *
79
-	 * @var float
80
-	 */
81
-	protected $total_discount_amount = 0;
82
-
83
-	/**
84
-	 * The total tax amount for the submission.
85
-	 *
86
-	 * @var float
87
-	 */
88
-	protected $total_tax_amount = 0;
89
-
90
-	/**
91
-	 * An array of fees for the submission.
92
-	 *
93
-	 * @var array
94
-	 */
95
-	protected $fees = array();
96
-
97
-	/**
98
-	 * The total fees amount for the submission.
99
-	 *
100
-	 * @var float
101
-	 */
102
-	protected $total_fees_amount = 0;
103
-
104
-	/**
105
-	 * An array of discounts for the submission.
106
-	 *
107
-	 * @var array
108
-	 */
109
-	protected $discounts = array();
110
-
111
-	/**
112
-	 * An array of taxes for the submission.
113
-	 *
114
-	 * @var array
115
-	 */
116
-	protected $taxes = array();
117
-
118
-	/**
119
-	 * An array of items for the submission.
120
-	 *
121
-	 * @var GetPaid_Form_Item[]
122
-	 */
123
-	protected $items = array();
124
-
125
-	/**
126
-	 * The last error.
127
-	 *
128
-	 * @var string
129
-	 */
130
-	public $last_error = null;
131
-
132
-	/**
133
-	 * Is the discount valid?
134
-	 *
135
-	 * @var bool
136
-	 */
137
-	public $is_discount_valid = true;
138
-
139
-	/**
140
-	 * Checks if we have a digital vat rule.
141
-	 *
142
-	 * @var bool
143
-	 */
144
-	public $has_digital = false;
145
-
146
-	/**
147
-	 * Checks if we require vat.
148
-	 *
149
-	 * @var bool
150
-	 */
151
-    public $requires_vat = false;
27
+     * The country for the submission.
28
+     *
29
+     * @var string
30
+     */
31
+    public $country = null;
152 32
 
153 33
     /**
154
-	 * Class constructor.
155
-	 *
156
-	 */
157
-	public function __construct() {
34
+     * The state for the submission.
35
+     *
36
+     * @since 1.0.19
37
+     * @var string
38
+     */
39
+    public $state = null;
158 40
 
159
-		// Set the state and country to the default state and country.
160
-		$this->country = wpinv_default_billing_country();
161
-		$this->state = wpinv_get_default_state();
41
+    /**
42
+     * The invoice associated with the submission.
43
+     *
44
+     * @var WPInv_Invoice
45
+     */
46
+    protected $invoice = null;
47
+
48
+    /**
49
+     * The discount associated with the submission.
50
+     *
51
+     * @var WPInv_Discount
52
+     */
53
+    protected $discount = null;
54
+
55
+    /**
56
+     * The raw submission data.
57
+     *
58
+     * @var array
59
+     */
60
+    protected $data = null;
61
+
62
+    /**
63
+     * Whether this submission contains a recurring item.
64
+     *
65
+     * @var bool
66
+     */
67
+    public $has_recurring = false;
68
+
69
+    /**
70
+     * The sub total amount for the submission.
71
+     *
72
+     * @var float
73
+     */
74
+    public $subtotal_amount = 0;
75
+
76
+    /**
77
+     * The total discount amount for the submission.
78
+     *
79
+     * @var float
80
+     */
81
+    protected $total_discount_amount = 0;
82
+
83
+    /**
84
+     * The total tax amount for the submission.
85
+     *
86
+     * @var float
87
+     */
88
+    protected $total_tax_amount = 0;
89
+
90
+    /**
91
+     * An array of fees for the submission.
92
+     *
93
+     * @var array
94
+     */
95
+    protected $fees = array();
96
+
97
+    /**
98
+     * The total fees amount for the submission.
99
+     *
100
+     * @var float
101
+     */
102
+    protected $total_fees_amount = 0;
103
+
104
+    /**
105
+     * An array of discounts for the submission.
106
+     *
107
+     * @var array
108
+     */
109
+    protected $discounts = array();
110
+
111
+    /**
112
+     * An array of taxes for the submission.
113
+     *
114
+     * @var array
115
+     */
116
+    protected $taxes = array();
117
+
118
+    /**
119
+     * An array of items for the submission.
120
+     *
121
+     * @var GetPaid_Form_Item[]
122
+     */
123
+    protected $items = array();
124
+
125
+    /**
126
+     * The last error.
127
+     *
128
+     * @var string
129
+     */
130
+    public $last_error = null;
131
+
132
+    /**
133
+     * Is the discount valid?
134
+     *
135
+     * @var bool
136
+     */
137
+    public $is_discount_valid = true;
138
+
139
+    /**
140
+     * Checks if we have a digital vat rule.
141
+     *
142
+     * @var bool
143
+     */
144
+    public $has_digital = false;
145
+
146
+    /**
147
+     * Checks if we require vat.
148
+     *
149
+     * @var bool
150
+     */
151
+    public $requires_vat = false;
162 152
 
163
-		// Do we have an actual submission?
164
-		if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
165
-			$this->load_data( $_POST );
166
-		}
167
-	}
153
+    /**
154
+     * Class constructor.
155
+     *
156
+     */
157
+    public function __construct() {
158
+
159
+        // Set the state and country to the default state and country.
160
+        $this->country = wpinv_default_billing_country();
161
+        $this->state = wpinv_get_default_state();
162
+
163
+        // Do we have an actual submission?
164
+        if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
165
+            $this->load_data( $_POST );
166
+        }
167
+    }
168 168
 
169
-	/**
170
-	 * Loads submission data.
171
-	 *
172
-	 * @param array $data
173
-	 */
174
-	public function load_data( $data ) {
169
+    /**
170
+     * Loads submission data.
171
+     *
172
+     * @param array $data
173
+     */
174
+    public function load_data( $data ) {
175 175
 
176
-		// Prepare submitted data...
177
-		$data = wp_unslash( $data );
176
+        // Prepare submitted data...
177
+        $data = wp_unslash( $data );
178 178
 
179
-		// Filter the data.
180
-		$data = apply_filters( 'getpaid_submission_data', $data, $this );
179
+        // Filter the data.
180
+        $data = apply_filters( 'getpaid_submission_data', $data, $this );
181 181
 
182
-		$this->data = $data;
182
+        $this->data = $data;
183 183
 
184
-		$this->id = md5( wp_json_encode( $data ) );
184
+        $this->id = md5( wp_json_encode( $data ) );
185 185
 
186
-		// Every submission needs an active payment form.
187
-		if ( empty( $data['form_id'] ) ) {
188
-			$this->last_error = __( 'Missing payment form', 'invoicing' );
186
+        // Every submission needs an active payment form.
187
+        if ( empty( $data['form_id'] ) ) {
188
+            $this->last_error = __( 'Missing payment form', 'invoicing' );
189 189
             return;
190
-		}
190
+        }
191 191
 
192
-		// Fetch the payment form.
193
-		$form = new GetPaid_Payment_Form( $data['form_id'] );
192
+        // Fetch the payment form.
193
+        $form = new GetPaid_Payment_Form( $data['form_id'] );
194 194
 
195
-		if ( ! $form->is_active() ) {
196
-			$this->last_error = __( 'Payment form not active', 'invoicing' );
197
-			return;
198
-		}
195
+        if ( ! $form->is_active() ) {
196
+            $this->last_error = __( 'Payment form not active', 'invoicing' );
197
+            return;
198
+        }
199 199
 
200
-		// Fetch the payment form.
201
-		$this->payment_form = $form;
200
+        // Fetch the payment form.
201
+        $this->payment_form = $form;
202 202
 
203
-		// For existing invoices, make sure that it is valid.
203
+        // For existing invoices, make sure that it is valid.
204 204
         if ( ! empty( $data['invoice_id'] ) ) {
205 205
             $invoice = wpinv_get_invoice( $data['invoice_id'] );
206 206
 
207 207
             if ( empty( $invoice ) ) {
208
-				$this->last_error = __( 'Invalid invoice', 'invoicing' );
208
+                $this->last_error = __( 'Invalid invoice', 'invoicing' );
209 209
                 return;
210
-			}
210
+            }
211 211
 
212
-			if ( $invoice->is_paid() ) {
213
-				$this->last_error = __( 'This invoice is already paid for.', 'invoicing' );
212
+            if ( $invoice->is_paid() ) {
213
+                $this->last_error = __( 'This invoice is already paid for.', 'invoicing' );
214 214
                 return;
215
-			}
215
+            }
216 216
 
217
-			$this->payment_form->set_items( $invoice->get_items() );
217
+            $this->payment_form->set_items( $invoice->get_items() );
218 218
 
219
-			$this->country = $invoice->get_country();
220
-			$this->state   = $invoice->get_state();
221
-			$this->invoice = $invoice;
219
+            $this->country = $invoice->get_country();
220
+            $this->state   = $invoice->get_state();
221
+            $this->invoice = $invoice;
222 222
 
223
-		// Default forms do not have items.
223
+        // Default forms do not have items.
224 224
         } else if ( $form->is_default() && isset( $data['getpaid-items'] ) ) {
225
-			$this->payment_form->set_items( wpinv_clean( $data['getpaid-items'] ) );
226
-		}
227
-
228
-		// User's country.
229
-		if ( ! empty( $data['wpinv_country'] ) ) {
230
-			$this->country = $data['wpinv_country'];
231
-		}
232
-
233
-		// User's state.
234
-		if ( ! empty( $data['wpinv_state'] ) ) {
235
-			$this->country = $data['wpinv_state'];
236
-		}
237
-
238
-		// Handle discounts.
239
-		$this->maybe_prepare_discount();
240
-
241
-		// Handle items.
242
-		$selected_items = array();
243
-		if ( ! empty( $data['getpaid-items'] ) ) {
244
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
245
-		}
246
-
247
-		foreach ( $this->payment_form->get_items() as $item ) {
248
-
249
-			// Continue if this is an optional item and it has not been selected.
250
-			if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
251
-				continue;
252
-			}
253
-
254
-			// (maybe) let customers change the quantities and prices.
255
-			if ( isset( $selected_items[ $item->get_id() ] ) ) {
256
-
257
-				// Maybe change the quantities.
258
-				if ( $item->allows_quantities() && is_numeric( $selected_items[ $item->get_id() ]['quantity'] ) ) {
259
-					$item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
260
-				}
261
-
262
-				// Maybe change the price.
263
-				if ( $item->user_can_set_their_price() ) {
264
-					$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
265
-
266
-					// But don't get lower than the minimum price.
267
-					if ( $price < $item->get_minimum_price() ) {
268
-						$price = $item->get_minimum_price();
269
-					}
270
-
271
-					$item->set_price( $price );
272
-
273
-				}
274
-
275
-			}
276
-
277
-			// Add the item to the form.
278
-			$this->add_item( $item );
279
-
280
-		}
281
-
282
-		// (Maybe) validate vat number.
283
-		$this->maybe_validate_vat();
284
-
285
-		// Fired when we are done processing a submission.
286
-		do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
287
-
288
-		// Remove invalid discount.
289
-		$this->maybe_remove_discount();
290
-
291
-	}
292
-
293
-    /**
294
-	 * Returns the payment form.
295
-	 *
296
-	 * @since 1.0.19
297
-	 * @return GetPaid_Payment_Form
298
-	 */
299
-	public function get_payment_form() {
300
-		return $this->payment_form;
301
-	}
302
-
303
-	/**
304
-	 * Returns the associated invoice.
305
-	 *
306
-	 * @since 1.0.19
307
-	 * @return WPInv_Invoice
308
-	 */
309
-	public function get_invoice() {
310
-		return $this->invoice;
311
-	}
312
-
313
-	/**
314
-	 * Checks whether there is an invoice associated with this submission.
315
-	 *
316
-	 * @since 1.0.19
317
-	 * @return bool
318
-	 */
319
-	public function has_invoice() {
320
-		return ! empty( $this->invoice );
321
-	}
322
-
323
-	/**
324
-	 * Retrieves the vat number.
325
-	 *
326
-	 * @since 1.0.19
327
-	 * @return string
328
-	 */
329
-	public function get_vat_number() {
330
-
331
-		// Retrieve from the posted data.
332
-		if ( ! empty( $this->data['wpinv_vat_number'] ) ) {
333
-			return wpinv_clean( $this->data['wpinv_vat_number'] );
334
-		}
335
-
336
-		// Retrieve from the invoice.
337
-		return $this->has_invoice() ? $this->invoice->get_vat_number() : '';
338
-	}
339
-
340
-	/**
341
-	 * Retrieves the company.
342
-	 *
343
-	 * @since 1.0.19
344
-	 * @return string
345
-	 */
346
-	public function get_company() {
347
-
348
-		// Retrieve from the posted data.
349
-		if ( ! empty( $this->data['wpinv_company'] ) ) {
350
-			return wpinv_clean( $this->data['wpinv_company'] );
351
-		}
352
-
353
-		// Retrieve from the invoice.
354
-		return $this->has_invoice() ? $this->invoice->get_company() : '';
355
-	}
356
-
357
-	/**
358
-	 * Returns the appropriate currency for the submission.
359
-	 *
360
-	 * @since 1.0.19
361
-	 * @return string
362
-	 */
363
-	public function get_currency() {
364
-		if ( $this->has_invoice() ) {
365
-			return $this->invoice->get_currency();
366
-		}
367
-		return wpinv_get_currency();
368
-    }
369
-
370
-    /**
371
-	 * Returns the raw submission data.
372
-	 *
373
-	 * @since 1.0.19
374
-	 * @return array
375
-	 */
376
-	public function get_data() {
377
-		return $this->data;
378
-	}
379
-
380
-	/**
381
-	 * Checks if a required field is set.
382
-	 *
383
-	 * @since 1.0.19
384
-	 */
385
-	public function is_required_field_set( $field ) {
386
-		return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
387
-	}
388
-
389
-	///////// Items //////////////
390
-
391
-	/**
392
-	 * Adds an item to the submission.
393
-	 *
394
-	 * @since 1.0.19
395
-	 * @param GetPaid_Form_Item $item
396
-	 */
397
-	public function add_item( $item ) {
398
-
399
-		// Make sure that it is available for purchase.
400
-		if ( ! $item->can_purchase() ) {
401
-			return;
402
-		}
403
-
404
-		// Do we have a recurring item?
405
-		if ( $item->is_recurring() ) {
406
-
407
-			if ( $this->has_recurring ) {
408
-				$this->last_error = __( 'You can only buy one recurring item at a time.', 'invoicing' );
409
-			}
410
-
411
-			$this->has_recurring = true;
412
-
413
-		}
414
-
415
-		$this->items[ $item->get_id() ] = $item;
416
-
417
-		$this->subtotal_amount += $item->get_sub_total();
418
-
419
-		$this->process_item_discount( $item );
420
-
421
-		$this->process_item_tax( $item );
422
-	}
423
-
424
-	/**
425
-	 * Retrieves a specific item.
426
-	 *
427
-	 * @since 1.0.19
428
-	 */
429
-	public function get_item( $item_id ) {
430
-		return isset( $this->items[ $item_id ] ) ? $this->items[ $item_id ] : null;
431
-	}
432
-
433
-	/**
434
-	 * Returns all items.
435
-	 *
436
-	 * @since 1.0.19
437
-	 * @return GetPaid_Form_Item[]
438
-	 */
439
-	public function get_items() {
440
-		return $this->items;
441
-	}
442
-
443
-	///////// TAXES //////////////
444
-
445
-	/**
446
-	 * Adds a tax to the submission.
447
-	 *
448
-	 * @since 1.0.19
449
-	 */
450
-	public function add_tax( $name, $amount, $recurring = false ) {
451
-		$amount = (float) wpinv_sanitize_amount( $amount );
452
-
453
-		$this->total_tax_amount += $amount;
454
-
455
-		if ( isset( $this->taxes[ $name ] ) ) {
456
-			$amount += $this->taxes[ $name ]['amount'];
457
-		}
458
-
459
-		$this->taxes[ $name ] = compact( 'amount', 'recurring' );
460
-
461
-	}
462
-
463
-	/**
464
-	 * Whether or not we'll use taxes for the submission.
465
-	 *
466
-	 * @since 1.0.19
467
-	 */
468
-	public function use_taxes() {
469
-
470
-		$use_taxes = wpinv_use_taxes();
471
-
472
-		if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) {
473
-			$use_taxes = false;
474
-		}
475
-
476
-		return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
477
-
478
-	}
479
-
480
-	/**
481
-	 * Maybe process tax.
482
-	 *
483
-	 * @since 1.0.19
484
-	 * @param GetPaid_Form_Item $item
485
-	 */
486
-	public function process_item_tax( $item ) {
487
-
488
-		// Abort early if we're not using taxes.
489
-		if ( ! $this->use_taxes() ) {
490
-			return;
491
-		}
492
-
493
-		$rate  = wpinv_get_tax_rate( $this->country, $this->state, $item->get_id() );
494
-		$price = $item->get_sub_total();
495
-
496
-		if ( wpinv_prices_include_tax() ) {
497
-			$item_tax = $price - ( $price - $price * $rate * 0.01 );
498
-		} else {
499
-			$item_tax = $price * $rate * 0.01;
500
-		}
501
-
502
-		$this->add_tax( 'Tax', $item_tax );
503
-
504
-	}
505
-
506
-	/**
507
-	 * Returns the total tax amount.
508
-	 *
509
-	 * @since 1.0.19
510
-	 */
511
-	public function get_total_tax() {
512
-		return $this->total_tax_amount;
513
-	}
514
-
515
-	/**
516
-	 * Retrieves a specific tax.
517
-	 *
518
-	 * @since 1.0.19
519
-	 */
520
-	public function get_tax( $name ) {
521
-		return isset( $this->taxes[ $name ] ) ? $this->taxes[ $name ]['amount'] : 0;
522
-	}
523
-
524
-	/**
525
-	 * Returns all taxes.
526
-	 *
527
-	 * @since 1.0.19
528
-	 */
529
-	public function get_taxes() {
530
-		return $this->taxes;
531
-	}
532
-
533
-	///////// DISCOUNTS //////////////
534
-
535
-	/**
536
-	 * Adds a discount to the submission.
537
-	 *
538
-	 * @since 1.0.19
539
-	 */
540
-	public function add_discount( $name, $amount, $recurring = false ) {
541
-		$amount = wpinv_sanitize_amount( $amount );
542
-
543
-		$this->total_discount_amount += $amount;
544
-
545
-		if ( isset( $this->discounts[ $name ] ) ) {
546
-			$amount += $this->discounts[ $name ]['amount'];
547
-		}
548
-
549
-		$this->discounts[ $name ] = compact( 'amount', 'recurring' );
550
-
551
-	}
552
-
553
-	/**
554
-	 * Removes a discount from the submission.
555
-	 *
556
-	 * @since 1.0.19
557
-	 */
558
-	public function remove_discount( $name ) {
559
-
560
-		if ( isset( $this->discounts[ $name ] ) ) {
561
-			$this->total_discount_amount -= $this->discounts[ $name ]['amount'];
562
-			unset( $this->discounts[ $name ] );
563
-		}
564
-
565
-	}
566
-
567
-	/**
568
-	 * Checks whether there is a discount code associated with this submission.
569
-	 *
570
-	 * @since 1.0.19
571
-	 * @return bool
572
-	 */
573
-	public function has_discount_code() {
574
-		return ! empty( $this->discount );
575
-	}
576
-
577
-	/**
578
-	 * Returns the discount code.
579
-	 *
580
-	 * @since 1.0.19
581
-	 * @return bool
582
-	 */
583
-	public function get_discount_code() {
584
-		return $this->has_discount_code() ? $this->discount->code : '';
585
-	}
586
-
587
-	/**
588
-	 * Prepares an item discount.
589
-	 *
590
-	 * @since 1.0.19
591
-	 */
592
-	public function maybe_prepare_discount() {
593
-
594
-		// Do we have a discount?
595
-		if ( empty( $this->data['discount'] ) ) {
596
-			return;
597
-		}
598
-
599
-		// Fetch the discount.
600
-		$discount = wpinv_get_discount_obj( $this->data['discount'] );
601
-
602
-		// Ensure it is active.
603
-        if ( ! $discount->exists() || ! $discount->is_active() || ! $discount->has_started() || $discount->is_expired() ) {
604
-			$this->is_discount_valid = false;
605
-			$this->last_error = __( 'Invalid or expired discount code', 'invoicing' );
606
-			return;
607
-		}
225
+            $this->payment_form->set_items( wpinv_clean( $data['getpaid-items'] ) );
226
+        }
227
+
228
+        // User's country.
229
+        if ( ! empty( $data['wpinv_country'] ) ) {
230
+            $this->country = $data['wpinv_country'];
231
+        }
232
+
233
+        // User's state.
234
+        if ( ! empty( $data['wpinv_state'] ) ) {
235
+            $this->country = $data['wpinv_state'];
236
+        }
237
+
238
+        // Handle discounts.
239
+        $this->maybe_prepare_discount();
240
+
241
+        // Handle items.
242
+        $selected_items = array();
243
+        if ( ! empty( $data['getpaid-items'] ) ) {
244
+            $selected_items = wpinv_clean( $data['getpaid-items'] );
245
+        }
246
+
247
+        foreach ( $this->payment_form->get_items() as $item ) {
248
+
249
+            // Continue if this is an optional item and it has not been selected.
250
+            if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
251
+                continue;
252
+            }
253
+
254
+            // (maybe) let customers change the quantities and prices.
255
+            if ( isset( $selected_items[ $item->get_id() ] ) ) {
256
+
257
+                // Maybe change the quantities.
258
+                if ( $item->allows_quantities() && is_numeric( $selected_items[ $item->get_id() ]['quantity'] ) ) {
259
+                    $item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
260
+                }
261
+
262
+                // Maybe change the price.
263
+                if ( $item->user_can_set_their_price() ) {
264
+                    $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
265
+
266
+                    // But don't get lower than the minimum price.
267
+                    if ( $price < $item->get_minimum_price() ) {
268
+                        $price = $item->get_minimum_price();
269
+                    }
270
+
271
+                    $item->set_price( $price );
272
+
273
+                }
274
+
275
+            }
276
+
277
+            // Add the item to the form.
278
+            $this->add_item( $item );
279
+
280
+        }
281
+
282
+        // (Maybe) validate vat number.
283
+        $this->maybe_validate_vat();
284
+
285
+        // Fired when we are done processing a submission.
286
+        do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
287
+
288
+        // Remove invalid discount.
289
+        $this->maybe_remove_discount();
290
+
291
+    }
292
+
293
+    /**
294
+     * Returns the payment form.
295
+     *
296
+     * @since 1.0.19
297
+     * @return GetPaid_Payment_Form
298
+     */
299
+    public function get_payment_form() {
300
+        return $this->payment_form;
301
+    }
302
+
303
+    /**
304
+     * Returns the associated invoice.
305
+     *
306
+     * @since 1.0.19
307
+     * @return WPInv_Invoice
308
+     */
309
+    public function get_invoice() {
310
+        return $this->invoice;
311
+    }
312
+
313
+    /**
314
+     * Checks whether there is an invoice associated with this submission.
315
+     *
316
+     * @since 1.0.19
317
+     * @return bool
318
+     */
319
+    public function has_invoice() {
320
+        return ! empty( $this->invoice );
321
+    }
322
+
323
+    /**
324
+     * Retrieves the vat number.
325
+     *
326
+     * @since 1.0.19
327
+     * @return string
328
+     */
329
+    public function get_vat_number() {
330
+
331
+        // Retrieve from the posted data.
332
+        if ( ! empty( $this->data['wpinv_vat_number'] ) ) {
333
+            return wpinv_clean( $this->data['wpinv_vat_number'] );
334
+        }
335
+
336
+        // Retrieve from the invoice.
337
+        return $this->has_invoice() ? $this->invoice->get_vat_number() : '';
338
+    }
339
+
340
+    /**
341
+     * Retrieves the company.
342
+     *
343
+     * @since 1.0.19
344
+     * @return string
345
+     */
346
+    public function get_company() {
347
+
348
+        // Retrieve from the posted data.
349
+        if ( ! empty( $this->data['wpinv_company'] ) ) {
350
+            return wpinv_clean( $this->data['wpinv_company'] );
351
+        }
352
+
353
+        // Retrieve from the invoice.
354
+        return $this->has_invoice() ? $this->invoice->get_company() : '';
355
+    }
356
+
357
+    /**
358
+     * Returns the appropriate currency for the submission.
359
+     *
360
+     * @since 1.0.19
361
+     * @return string
362
+     */
363
+    public function get_currency() {
364
+        if ( $this->has_invoice() ) {
365
+            return $this->invoice->get_currency();
366
+        }
367
+        return wpinv_get_currency();
368
+    }
369
+
370
+    /**
371
+     * Returns the raw submission data.
372
+     *
373
+     * @since 1.0.19
374
+     * @return array
375
+     */
376
+    public function get_data() {
377
+        return $this->data;
378
+    }
379
+
380
+    /**
381
+     * Checks if a required field is set.
382
+     *
383
+     * @since 1.0.19
384
+     */
385
+    public function is_required_field_set( $field ) {
386
+        return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
387
+    }
388
+
389
+    ///////// Items //////////////
390
+
391
+    /**
392
+     * Adds an item to the submission.
393
+     *
394
+     * @since 1.0.19
395
+     * @param GetPaid_Form_Item $item
396
+     */
397
+    public function add_item( $item ) {
398
+
399
+        // Make sure that it is available for purchase.
400
+        if ( ! $item->can_purchase() ) {
401
+            return;
402
+        }
403
+
404
+        // Do we have a recurring item?
405
+        if ( $item->is_recurring() ) {
406
+
407
+            if ( $this->has_recurring ) {
408
+                $this->last_error = __( 'You can only buy one recurring item at a time.', 'invoicing' );
409
+            }
410
+
411
+            $this->has_recurring = true;
412
+
413
+        }
414
+
415
+        $this->items[ $item->get_id() ] = $item;
416
+
417
+        $this->subtotal_amount += $item->get_sub_total();
418
+
419
+        $this->process_item_discount( $item );
420
+
421
+        $this->process_item_tax( $item );
422
+    }
423
+
424
+    /**
425
+     * Retrieves a specific item.
426
+     *
427
+     * @since 1.0.19
428
+     */
429
+    public function get_item( $item_id ) {
430
+        return isset( $this->items[ $item_id ] ) ? $this->items[ $item_id ] : null;
431
+    }
432
+
433
+    /**
434
+     * Returns all items.
435
+     *
436
+     * @since 1.0.19
437
+     * @return GetPaid_Form_Item[]
438
+     */
439
+    public function get_items() {
440
+        return $this->items;
441
+    }
442
+
443
+    ///////// TAXES //////////////
444
+
445
+    /**
446
+     * Adds a tax to the submission.
447
+     *
448
+     * @since 1.0.19
449
+     */
450
+    public function add_tax( $name, $amount, $recurring = false ) {
451
+        $amount = (float) wpinv_sanitize_amount( $amount );
452
+
453
+        $this->total_tax_amount += $amount;
454
+
455
+        if ( isset( $this->taxes[ $name ] ) ) {
456
+            $amount += $this->taxes[ $name ]['amount'];
457
+        }
458
+
459
+        $this->taxes[ $name ] = compact( 'amount', 'recurring' );
460
+
461
+    }
462
+
463
+    /**
464
+     * Whether or not we'll use taxes for the submission.
465
+     *
466
+     * @since 1.0.19
467
+     */
468
+    public function use_taxes() {
469
+
470
+        $use_taxes = wpinv_use_taxes();
471
+
472
+        if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) {
473
+            $use_taxes = false;
474
+        }
475
+
476
+        return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
608 477
 
609
-		// For single use discounts...
610
-		if ( $discount->is_single_use ) {
478
+    }
479
+
480
+    /**
481
+     * Maybe process tax.
482
+     *
483
+     * @since 1.0.19
484
+     * @param GetPaid_Form_Item $item
485
+     */
486
+    public function process_item_tax( $item ) {
487
+
488
+        // Abort early if we're not using taxes.
489
+        if ( ! $this->use_taxes() ) {
490
+            return;
491
+        }
492
+
493
+        $rate  = wpinv_get_tax_rate( $this->country, $this->state, $item->get_id() );
494
+        $price = $item->get_sub_total();
495
+
496
+        if ( wpinv_prices_include_tax() ) {
497
+            $item_tax = $price - ( $price - $price * $rate * 0.01 );
498
+        } else {
499
+            $item_tax = $price * $rate * 0.01;
500
+        }
501
+
502
+        $this->add_tax( 'Tax', $item_tax );
503
+
504
+    }
505
+
506
+    /**
507
+     * Returns the total tax amount.
508
+     *
509
+     * @since 1.0.19
510
+     */
511
+    public function get_total_tax() {
512
+        return $this->total_tax_amount;
513
+    }
514
+
515
+    /**
516
+     * Retrieves a specific tax.
517
+     *
518
+     * @since 1.0.19
519
+     */
520
+    public function get_tax( $name ) {
521
+        return isset( $this->taxes[ $name ] ) ? $this->taxes[ $name ]['amount'] : 0;
522
+    }
523
+
524
+    /**
525
+     * Returns all taxes.
526
+     *
527
+     * @since 1.0.19
528
+     */
529
+    public function get_taxes() {
530
+        return $this->taxes;
531
+    }
532
+
533
+    ///////// DISCOUNTS //////////////
534
+
535
+    /**
536
+     * Adds a discount to the submission.
537
+     *
538
+     * @since 1.0.19
539
+     */
540
+    public function add_discount( $name, $amount, $recurring = false ) {
541
+        $amount = wpinv_sanitize_amount( $amount );
542
+
543
+        $this->total_discount_amount += $amount;
544
+
545
+        if ( isset( $this->discounts[ $name ] ) ) {
546
+            $amount += $this->discounts[ $name ]['amount'];
547
+        }
548
+
549
+        $this->discounts[ $name ] = compact( 'amount', 'recurring' );
550
+
551
+    }
552
+
553
+    /**
554
+     * Removes a discount from the submission.
555
+     *
556
+     * @since 1.0.19
557
+     */
558
+    public function remove_discount( $name ) {
559
+
560
+        if ( isset( $this->discounts[ $name ] ) ) {
561
+            $this->total_discount_amount -= $this->discounts[ $name ]['amount'];
562
+            unset( $this->discounts[ $name ] );
563
+        }
564
+
565
+    }
611 566
 
612
-			if ( ! $this->has_billing_email() ) {
613
-				$this->is_discount_valid = false;
614
-				$this->last_error = __( 'You need to enter your billing email before applying this discount', 'invoicing' );
615
-				return;
616
-			}
567
+    /**
568
+     * Checks whether there is a discount code associated with this submission.
569
+     *
570
+     * @since 1.0.19
571
+     * @return bool
572
+     */
573
+    public function has_discount_code() {
574
+        return ! empty( $this->discount );
575
+    }
617 576
 
618
-			if ( ! $discount->is_valid_for_user( $this->get_billing_email() ) ) {
619
-				$this->is_discount_valid = false;
620
-				$this->last_error = __( 'You have already used this discount', 'invoicing' );
621
-				return;
622
-			}
577
+    /**
578
+     * Returns the discount code.
579
+     *
580
+     * @since 1.0.19
581
+     * @return bool
582
+     */
583
+    public function get_discount_code() {
584
+        return $this->has_discount_code() ? $this->discount->code : '';
585
+    }
623 586
 
624
-		}
587
+    /**
588
+     * Prepares an item discount.
589
+     *
590
+     * @since 1.0.19
591
+     */
592
+    public function maybe_prepare_discount() {
593
+
594
+        // Do we have a discount?
595
+        if ( empty( $this->data['discount'] ) ) {
596
+            return;
597
+        }
625 598
 
626
-		// Set the discount.
627
-		$this->discount = $discount;
599
+        // Fetch the discount.
600
+        $discount = wpinv_get_discount_obj( $this->data['discount'] );
628 601
 
629
-	}
602
+        // Ensure it is active.
603
+        if ( ! $discount->exists() || ! $discount->is_active() || ! $discount->has_started() || $discount->is_expired() ) {
604
+            $this->is_discount_valid = false;
605
+            $this->last_error = __( 'Invalid or expired discount code', 'invoicing' );
606
+            return;
607
+        }
630 608
 
631
-	/**
632
-	 * Removes an invalid discount code.
633
-	 *
634
-	 * @since 1.0.19
635
-	 */
636
-	public function maybe_remove_discount() {
609
+        // For single use discounts...
610
+        if ( $discount->is_single_use ) {
611
+
612
+            if ( ! $this->has_billing_email() ) {
613
+                $this->is_discount_valid = false;
614
+                $this->last_error = __( 'You need to enter your billing email before applying this discount', 'invoicing' );
615
+                return;
616
+            }
637 617
 
638
-		// Do we have a discount?
639
-		if ( empty( $this->has_discount_code() ) ) {
640
-			return;
641
-		}
618
+            if ( ! $discount->is_valid_for_user( $this->get_billing_email() ) ) {
619
+                $this->is_discount_valid = false;
620
+                $this->last_error = __( 'You have already used this discount', 'invoicing' );
621
+                return;
622
+            }
642 623
 
643
-		// Fetch the discount amount.
644
-		$amount = $this->get_discount( 'Discount' );
624
+        }
645 625
 
646
-		// Abort early if this is a "zero" discount.
647
-		if ( empty( $amount ) ) {
648
-			return;
649
-		}
626
+        // Set the discount.
627
+        $this->discount = $discount;
650 628
 
651
-		$total = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax();
629
+    }
652 630
 
653
-		if ( ! $this->discount->is_minimum_amount_met( $total ) ) {
654
-			$this->is_discount_valid = false;
631
+    /**
632
+     * Removes an invalid discount code.
633
+     *
634
+     * @since 1.0.19
635
+     */
636
+    public function maybe_remove_discount() {
637
+
638
+        // Do we have a discount?
639
+        if ( empty( $this->has_discount_code() ) ) {
640
+            return;
641
+        }
642
+
643
+        // Fetch the discount amount.
644
+        $amount = $this->get_discount( 'Discount' );
645
+
646
+        // Abort early if this is a "zero" discount.
647
+        if ( empty( $amount ) ) {
648
+            return;
649
+        }
650
+
651
+        $total = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax();
652
+
653
+        if ( ! $this->discount->is_minimum_amount_met( $total ) ) {
654
+            $this->is_discount_valid = false;
655 655
             $min = wpinv_price( wpinv_format_amount( $$this->discount->min_total ) );
656
-			$this->last_error = sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min );
656
+            $this->last_error = sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min );
657 657
         }
658 658
 
659 659
         if ( ! $this->discount->is_maximum_amount_met( $total ) ) {
660
-			$this->is_discount_valid = false;
660
+            $this->is_discount_valid = false;
661 661
             $max = wpinv_price( wpinv_format_amount( $$this->discount->max_total ) );
662
-			$this->last_error = sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max );
663
-		}
664
-
665
-		if ( ! $this->is_discount_valid ) {
666
-			$this->discount = null;
667
-			$this->remove_discount( 'Discount' );
668
-		}
669
-
670
-    }
671
-
672
-	/**
673
-	 * Maybe process discount.
674
-	 *
675
-	 * @since 1.0.19
676
-	 * @param GetPaid_Form_Item $item
677
-	 */
678
-	public function process_item_discount( $item ) {
679
-
680
-		// Abort early if there is no discount.
681
-		if ( ! $this->has_discount_code() ) {
682
-			return;
683
-		}
684
-
685
-		// Ensure that it is valid for this item.
686
-		if ( ! $this->discount->is_valid_for_items( array( $item->get_id() ) ) ) {
687
-			return;
688
-		}
689
-
690
-		// Fetch the discounted amount.
691
-		$discount = $this->discount->get_discounted_amount( $item->get_price() * $item->get_quantity() );
692
-
693
-		$this->add_discount( 'Discount', $discount, $this->discount->is_recurring() );
694
-
695
-	}
696
-
697
-	/**
698
-	 * Returns the total discount amount.
699
-	 *
700
-	 * @since 1.0.19
701
-	 */
702
-	public function get_total_discount() {
703
-		return $this->total_discount_amount;
704
-	}
705
-
706
-	/**
707
-	 * Gets a specific discount.
708
-	 *
709
-	 * @since 1.0.19
710
-	 */
711
-	public function get_discount( $name ) {
712
-		return isset( $this->discounts[ $name ] ) ? $this->discounts[ $name ]['amount'] : 0;
713
-	}
714
-
715
-	/**
716
-	 * Returns all discounts.
717
-	 *
718
-	 * @since 1.0.19
719
-	 */
720
-	public function get_discounts() {
721
-		return $this->discounts;
722
-	}
723
-
724
-	///////// FEES //////////////
725
-
726
-	/**
727
-	 * Adds a fee to the submission.
728
-	 *
729
-	 * @since 1.0.19
730
-	 */
731
-	public function add_fee( $name, $amount, $recurring = false ) {
732
-		$amount = wpinv_sanitize_amount( $amount );
733
-
734
-		$this->total_fees_amount += $amount;
735
-		if ( isset( $this->fees[ $name ] ) ) {
736
-			$amount += $this->fees[ $name ]['amount'];
737
-		}
738
-
739
-		$this->fees[ $name ] = compact( 'amount', 'recurring' );
740
-
741
-	}
742
-
743
-	/**
744
-	 * Returns the total fees amount.
745
-	 *
746
-	 * @since 1.0.19
747
-	 */
748
-	public function get_total_fees() {
749
-		return $this->total_fees_amount;
750
-	}
751
-
752
-	/**
753
-	 * Retrieves a specific fee.
754
-	 *
755
-	 * @since 1.0.19
756
-	 */
757
-	public function get_fee( $name ) {
758
-		return isset( $this->fees[ $name ] ) ? $this->fees[ $name ]['amount'] : 0;
759
-	}
760
-
761
-	/**
762
-	 * Returns all fees.
763
-	 *
764
-	 * @since 1.0.19
765
-	 */
766
-	public function get_fees() {
767
-		return $this->fees;
768
-	}
769
-
770
-	// MISC //
771
-
772
-	/**
773
-	 * Returns the total amount to collect for this submission.
774
-	 *
775
-	 * @since 1.0.19
776
-	 */
777
-	public function get_total() {
778
-		$total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
779
-		$total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this  );
780
-		return wpinv_sanitize_amount( $total );
781
-	}
782
-
783
-	/**
784
-	 * Whether payment details should be collected for this submission.
785
-	 *
786
-	 * @since 1.0.19
787
-	 */
788
-	public function get_payment_details() {
789
-		$collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
790
-
791
-		if ( $this->has_recurring ) {
792
-			$collect = true;
793
-		}
794
-
795
-		$collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this  );
796
-		return $collect;
797
-	}
798
-
799
-	/**
800
-	 * Returns the billing email of the user.
801
-	 *
802
-	 * @since 1.0.19
803
-	 */
804
-	public function get_billing_email() {
805
-		$billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email'];
806
-		return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this  );
807
-	}
808
-
809
-	/**
810
-	 * Checks if the submitter has a billing email.
811
-	 *
812
-	 * @since 1.0.19
813
-	 */
814
-	public function has_billing_email() {
815
-		$billing_email = $this->get_billing_email();
816
-		return ! empty( $billing_email );
817
-	}
818
-
819
-	/**
820
-	 * Validate VAT data.
821
-	 *
822
-	 * @since 1.0.19
823
-	 */
824
-	public function maybe_validate_vat() {
825
-
826
-		// Make sure that taxes are enabled.
827
-		if ( ! wpinv_use_taxes() ) {
828
-			return;
829
-		}
830
-
831
-		// Check if we have a digital VAT rule.
832
-		$has_digital = false;
833
-
834
-		foreach ( $this->get_items() as $item ) {
835
-
836
-			if ( 'digital' == $item->get_vat_rule() ) {
837
-				$has_digital = true;
838
-				break;
839
-			}
840
-
841
-		}
842
-
843
-		$this->has_digital = $has_digital;
844
-
845
-		// Check if we require vat.
846
-		$requires_vat = (
847
-			( getpaid_is_eu_state( $this->country ) && ( getpaid_is_eu_state( wpinv_get_default_country() ) || $has_digital ) )
848
-			|| ( getpaid_is_gst_country( $this->country ) && getpaid_is_gst_country( wpinv_get_default_country() ) )
849
-		);
850
-
851
-		$this->requires_vat = $requires_vat;
852
-
853
-		// Abort if we are not calculating the taxes.
854
-		if ( ! $has_digital && ! $requires_vat ) {
662
+            $this->last_error = sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max );
663
+        }
664
+
665
+        if ( ! $this->is_discount_valid ) {
666
+            $this->discount = null;
667
+            $this->remove_discount( 'Discount' );
668
+        }
669
+
670
+    }
671
+
672
+    /**
673
+     * Maybe process discount.
674
+     *
675
+     * @since 1.0.19
676
+     * @param GetPaid_Form_Item $item
677
+     */
678
+    public function process_item_discount( $item ) {
679
+
680
+        // Abort early if there is no discount.
681
+        if ( ! $this->has_discount_code() ) {
682
+            return;
683
+        }
684
+
685
+        // Ensure that it is valid for this item.
686
+        if ( ! $this->discount->is_valid_for_items( array( $item->get_id() ) ) ) {
687
+            return;
688
+        }
689
+
690
+        // Fetch the discounted amount.
691
+        $discount = $this->discount->get_discounted_amount( $item->get_price() * $item->get_quantity() );
692
+
693
+        $this->add_discount( 'Discount', $discount, $this->discount->is_recurring() );
694
+
695
+    }
696
+
697
+    /**
698
+     * Returns the total discount amount.
699
+     *
700
+     * @since 1.0.19
701
+     */
702
+    public function get_total_discount() {
703
+        return $this->total_discount_amount;
704
+    }
705
+
706
+    /**
707
+     * Gets a specific discount.
708
+     *
709
+     * @since 1.0.19
710
+     */
711
+    public function get_discount( $name ) {
712
+        return isset( $this->discounts[ $name ] ) ? $this->discounts[ $name ]['amount'] : 0;
713
+    }
714
+
715
+    /**
716
+     * Returns all discounts.
717
+     *
718
+     * @since 1.0.19
719
+     */
720
+    public function get_discounts() {
721
+        return $this->discounts;
722
+    }
723
+
724
+    ///////// FEES //////////////
725
+
726
+    /**
727
+     * Adds a fee to the submission.
728
+     *
729
+     * @since 1.0.19
730
+     */
731
+    public function add_fee( $name, $amount, $recurring = false ) {
732
+        $amount = wpinv_sanitize_amount( $amount );
733
+
734
+        $this->total_fees_amount += $amount;
735
+        if ( isset( $this->fees[ $name ] ) ) {
736
+            $amount += $this->fees[ $name ]['amount'];
737
+        }
738
+
739
+        $this->fees[ $name ] = compact( 'amount', 'recurring' );
740
+
741
+    }
742
+
743
+    /**
744
+     * Returns the total fees amount.
745
+     *
746
+     * @since 1.0.19
747
+     */
748
+    public function get_total_fees() {
749
+        return $this->total_fees_amount;
750
+    }
751
+
752
+    /**
753
+     * Retrieves a specific fee.
754
+     *
755
+     * @since 1.0.19
756
+     */
757
+    public function get_fee( $name ) {
758
+        return isset( $this->fees[ $name ] ) ? $this->fees[ $name ]['amount'] : 0;
759
+    }
760
+
761
+    /**
762
+     * Returns all fees.
763
+     *
764
+     * @since 1.0.19
765
+     */
766
+    public function get_fees() {
767
+        return $this->fees;
768
+    }
769
+
770
+    // MISC //
771
+
772
+    /**
773
+     * Returns the total amount to collect for this submission.
774
+     *
775
+     * @since 1.0.19
776
+     */
777
+    public function get_total() {
778
+        $total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
779
+        $total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this  );
780
+        return wpinv_sanitize_amount( $total );
781
+    }
782
+
783
+    /**
784
+     * Whether payment details should be collected for this submission.
785
+     *
786
+     * @since 1.0.19
787
+     */
788
+    public function get_payment_details() {
789
+        $collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
790
+
791
+        if ( $this->has_recurring ) {
792
+            $collect = true;
793
+        }
794
+
795
+        $collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this  );
796
+        return $collect;
797
+    }
798
+
799
+    /**
800
+     * Returns the billing email of the user.
801
+     *
802
+     * @since 1.0.19
803
+     */
804
+    public function get_billing_email() {
805
+        $billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email'];
806
+        return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this  );
807
+    }
808
+
809
+    /**
810
+     * Checks if the submitter has a billing email.
811
+     *
812
+     * @since 1.0.19
813
+     */
814
+    public function has_billing_email() {
815
+        $billing_email = $this->get_billing_email();
816
+        return ! empty( $billing_email );
817
+    }
818
+
819
+    /**
820
+     * Validate VAT data.
821
+     *
822
+     * @since 1.0.19
823
+     */
824
+    public function maybe_validate_vat() {
825
+
826
+        // Make sure that taxes are enabled.
827
+        if ( ! wpinv_use_taxes() ) {
855 828
             return;
856
-		}
829
+        }
830
+
831
+        // Check if we have a digital VAT rule.
832
+        $has_digital = false;
833
+
834
+        foreach ( $this->get_items() as $item ) {
835
+
836
+            if ( 'digital' == $item->get_vat_rule() ) {
837
+                $has_digital = true;
838
+                break;
839
+            }
840
+
841
+        }
842
+
843
+        $this->has_digital = $has_digital;
844
+
845
+        // Check if we require vat.
846
+        $requires_vat = (
847
+            ( getpaid_is_eu_state( $this->country ) && ( getpaid_is_eu_state( wpinv_get_default_country() ) || $has_digital ) )
848
+            || ( getpaid_is_gst_country( $this->country ) && getpaid_is_gst_country( wpinv_get_default_country() ) )
849
+        );
857 850
 
858
-		// Prepare variables.
859
-		$vat_number = $this->get_vat_number();
860
-		$company    = $this->get_company();
861
-		$ip_country = WPInv_EUVat::get_country_by_ip();
851
+        $this->requires_vat = $requires_vat;
852
+
853
+        // Abort if we are not calculating the taxes.
854
+        if ( ! $has_digital && ! $requires_vat ) {
855
+            return;
856
+        }
857
+
858
+        // Prepare variables.
859
+        $vat_number = $this->get_vat_number();
860
+        $company    = $this->get_company();
861
+        $ip_country = WPInv_EUVat::get_country_by_ip();
862 862
         $is_eu      = getpaid_is_eu_state( $this->country );
863 863
         $is_ip_eu   = getpaid_is_eu_state( $ip_country );
864
-		$is_non_eu  = ! $is_eu && ! $is_ip_eu;
865
-		$prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
864
+        $is_non_eu  = ! $is_eu && ! $is_ip_eu;
865
+        $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
866 866
 
867
-		// If we're preventing business to consumer purchases...
868
-		if ( ! empty( $prevent_b2c ) && ! $is_non_eu && ( empty( $vat_number ) || ! $requires_vat ) ) {
867
+        // If we're preventing business to consumer purchases...
868
+        if ( ! empty( $prevent_b2c ) && ! $is_non_eu && ( empty( $vat_number ) || ! $requires_vat ) ) {
869 869
 
870 870
             if ( $is_eu ) {
871
-				$this->last_error = wp_sprintf(
872
-					__( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
873
-					getpaid_vat_name()
874
-				);
871
+                $this->last_error = wp_sprintf(
872
+                    __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
873
+                    getpaid_vat_name()
874
+                );
875 875
             } else if ( $has_digital && $is_ip_eu ) {
876 876
 
877
-				$this->last_error = wp_sprintf(
878
-					__( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ),
879
-					getpaid_vat_name()
880
-				);
877
+                $this->last_error = wp_sprintf(
878
+                    __( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ),
879
+                    getpaid_vat_name()
880
+                );
881 881
 
882
-			}
882
+            }
883 883
 
884
-		}
884
+        }
885 885
 
886
-		// Abort if we are not validating vat.
887
-		if ( ! $is_eu || ! $requires_vat || empty( $vat_number ) ) {
886
+        // Abort if we are not validating vat.
887
+        if ( ! $is_eu || ! $requires_vat || empty( $vat_number ) ) {
888 888
             return;
889
-		}
889
+        }
890 890
 
891
-		$is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $this->country );
891
+        $is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $this->country );
892 892
 
893
-		if ( is_string( $is_valid ) ) {
894
-			$this->last_error = $is_valid;
895
-		}
893
+        if ( is_string( $is_valid ) ) {
894
+            $this->last_error = $is_valid;
895
+        }
896 896
 
897
-	}
897
+    }
898 898
 
899 899
 }
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 1 patch
Indentation   +2287 added lines, -2287 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'            => 0,
38
-		'status'               => 'wpi-pending',
39
-		'version'              => '',
40
-		'date_created'         => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'            => 0,
38
+        'status'               => 'wpi-pending',
39
+        'version'              => '',
40
+        'date_created'         => null,
41 41
         'date_modified'        => null,
42 42
         'due_date'             => null,
43 43
         'completed_date'       => null,
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
         'transaction_id'       => '',
80 80
         'currency'             => '',
81 81
         'disable_taxes'        => false,
82
-		'subscription_id'      => null,
83
-		'remote_subscription_id' => null,
84
-		'is_viewed'            => false,
85
-		'email_cc'             => '',
86
-		'template'             => 'quantity', // hours, amount only
82
+        'subscription_id'      => null,
83
+        'remote_subscription_id' => null,
84
+        'is_viewed'            => false,
85
+        'email_cc'             => '',
86
+        'template'             => 'quantity', // hours, amount only
87 87
     );
88 88
 
89 89
     /**
90
-	 * Stores meta in cache for future reads.
91
-	 *
92
-	 * A group must be set to to enable caching.
93
-	 *
94
-	 * @var string
95
-	 */
96
-	protected $cache_group = 'getpaid_invoices';
90
+     * Stores meta in cache for future reads.
91
+     *
92
+     * A group must be set to to enable caching.
93
+     *
94
+     * @var string
95
+     */
96
+    protected $cache_group = 'getpaid_invoices';
97 97
 
98 98
     /**
99 99
      * Stores a reference to the original WP_Post object
@@ -107,104 +107,104 @@  discard block
 block discarded – undo
107 107
      *
108 108
      * @var int
109 109
      */
110
-	protected $recurring_item = null;
110
+    protected $recurring_item = null;
111 111
 
112
-	/**
112
+    /**
113 113
      * Stores an array of item totals.
114
-	 *
115
-	 * e.g $totals['discount'] = array(
116
-	 * 		'initial'   => 10,
117
-	 * 		'recurring' => 10,
118
-	 * )
114
+     *
115
+     * e.g $totals['discount'] = array(
116
+     * 		'initial'   => 10,
117
+     * 		'recurring' => 10,
118
+     * )
119 119
      *
120 120
      * @var array
121 121
      */
122
-	protected $totals = array();
122
+    protected $totals = array();
123 123
 
124
-	/**
125
-	 * Stores the status transition information.
126
-	 *
127
-	 * @since 1.0.19
128
-	 * @var bool
129
-	 */
130
-	protected $status_transition = false;
124
+    /**
125
+     * Stores the status transition information.
126
+     *
127
+     * @since 1.0.19
128
+     * @var bool
129
+     */
130
+    protected $status_transition = false;
131 131
 
132 132
     /**
133
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
134
-	 *
135
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
136
-	 */
133
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
134
+     *
135
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
136
+     */
137 137
     public function __construct( $invoice = false ) {
138 138
 
139 139
         parent::__construct( $invoice );
140 140
 
141
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
142
-			$this->set_id( $invoice );
143
-		} elseif ( $invoice instanceof self ) {
144
-			$this->set_id( $invoice->get_id() );
145
-		} elseif ( ! empty( $invoice->ID ) ) {
146
-			$this->set_id( $invoice->ID );
147
-		} elseif ( is_array( $invoice ) ) {
148
-			$this->set_props( $invoice );
149
-
150
-			if ( isset( $invoice['ID'] ) ) {
151
-				$this->set_id( $invoice['ID'] );
152
-			}
153
-
154
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
155
-			$this->set_id( $invoice_id );
156
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
157
-			$this->set_id( $invoice_id );
158
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
159
-			$this->set_id( $invoice_id );
160
-		}else {
161
-			$this->set_object_read( true );
162
-		}
141
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
142
+            $this->set_id( $invoice );
143
+        } elseif ( $invoice instanceof self ) {
144
+            $this->set_id( $invoice->get_id() );
145
+        } elseif ( ! empty( $invoice->ID ) ) {
146
+            $this->set_id( $invoice->ID );
147
+        } elseif ( is_array( $invoice ) ) {
148
+            $this->set_props( $invoice );
149
+
150
+            if ( isset( $invoice['ID'] ) ) {
151
+                $this->set_id( $invoice['ID'] );
152
+            }
153
+
154
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
155
+            $this->set_id( $invoice_id );
156
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
157
+            $this->set_id( $invoice_id );
158
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
159
+            $this->set_id( $invoice_id );
160
+        }else {
161
+            $this->set_object_read( true );
162
+        }
163 163
 
164 164
         // Load the datastore.
165
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
165
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
166 166
 
167
-		if ( $this->get_id() > 0 ) {
167
+        if ( $this->get_id() > 0 ) {
168 168
             $this->post = get_post( $this->get_id() );
169 169
             $this->ID   = $this->get_id();
170
-			$this->data_store->read( $this );
170
+            $this->data_store->read( $this );
171 171
         }
172 172
 
173 173
     }
174 174
 
175 175
     /**
176
-	 * Given an invoice key/number, it returns its id.
177
-	 *
178
-	 *
179
-	 * @static
180
-	 * @param string $value The invoice key or number
181
-	 * @param string $field Either key, transaction_id or number.
182
-	 * @since 1.0.15
183
-	 * @return int
184
-	 */
185
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
176
+     * Given an invoice key/number, it returns its id.
177
+     *
178
+     *
179
+     * @static
180
+     * @param string $value The invoice key or number
181
+     * @param string $field Either key, transaction_id or number.
182
+     * @since 1.0.15
183
+     * @return int
184
+     */
185
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
186 186
         global $wpdb;
187 187
 
188
-		// Trim the value.
189
-		$value = trim( $value );
188
+        // Trim the value.
189
+        $value = trim( $value );
190 190
 
191
-		if ( empty( $value ) ) {
192
-			return 0;
193
-		}
191
+        if ( empty( $value ) ) {
192
+            return 0;
193
+        }
194 194
 
195 195
         // Valid fields.
196 196
         $fields = array( 'key', 'number', 'transaction_id' );
197 197
 
198
-		// Ensure a field has been passed.
199
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
200
-			return 0;
201
-		}
198
+        // Ensure a field has been passed.
199
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
200
+            return 0;
201
+        }
202 202
 
203
-		// Maybe retrieve from the cache.
204
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
205
-		if ( false !== $invoice_id ) {
206
-			return $invoice_id;
207
-		}
203
+        // Maybe retrieve from the cache.
204
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
205
+        if ( false !== $invoice_id ) {
206
+            return $invoice_id;
207
+        }
208 208
 
209 209
         // Fetch from the db.
210 210
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
213 213
         );
214 214
 
215
-		// Update the cache with our data
216
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
+        // Update the cache with our data
216
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
217 217
 
218
-		return $invoice_id;
218
+        return $invoice_id;
219 219
     }
220 220
 
221 221
     /**
@@ -241,80 +241,80 @@  discard block
 block discarded – undo
241 241
     */
242 242
 
243 243
     /**
244
-	 * Get parent invoice ID.
245
-	 *
246
-	 * @since 1.0.19
247
-	 * @param  string $context View or edit context.
248
-	 * @return int
249
-	 */
250
-	public function get_parent_id( $context = 'view' ) {
251
-		return (int) $this->get_prop( 'parent_id', $context );
244
+     * Get parent invoice ID.
245
+     *
246
+     * @since 1.0.19
247
+     * @param  string $context View or edit context.
248
+     * @return int
249
+     */
250
+    public function get_parent_id( $context = 'view' ) {
251
+        return (int) $this->get_prop( 'parent_id', $context );
252 252
     }
253 253
 
254 254
     /**
255
-	 * Get parent invoice.
256
-	 *
257
-	 * @since 1.0.19
258
-	 * @return WPInv_Invoice
259
-	 */
255
+     * Get parent invoice.
256
+     *
257
+     * @since 1.0.19
258
+     * @return WPInv_Invoice
259
+     */
260 260
     public function get_parent_payment() {
261 261
         return new WPInv_Invoice( $this->get_parent_id() );
262 262
     }
263 263
 
264 264
     /**
265
-	 * Alias for self::get_parent_payment().
266
-	 *
267
-	 * @since 1.0.19
268
-	 * @return WPInv_Invoice
269
-	 */
265
+     * Alias for self::get_parent_payment().
266
+     *
267
+     * @since 1.0.19
268
+     * @return WPInv_Invoice
269
+     */
270 270
     public function get_parent() {
271 271
         return $this->get_parent_payment();
272 272
     }
273 273
 
274 274
     /**
275
-	 * Get invoice status.
276
-	 *
277
-	 * @since 1.0.19
278
-	 * @param  string $context View or edit context.
279
-	 * @return string
280
-	 */
281
-	public function get_status( $context = 'view' ) {
282
-		return $this->get_prop( 'status', $context );
283
-	}
275
+     * Get invoice status.
276
+     *
277
+     * @since 1.0.19
278
+     * @param  string $context View or edit context.
279
+     * @return string
280
+     */
281
+    public function get_status( $context = 'view' ) {
282
+        return $this->get_prop( 'status', $context );
283
+    }
284 284
 	
285
-	/**
286
-	 * Retrieves an array of possible invoice statuses.
287
-	 *
288
-	 * @since 1.0.19
289
-	 * @return array
290
-	 */
291
-	public function get_all_statuses() {
292
-
293
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
294
-
295
-		// For backwards compatibility.
296
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
285
+    /**
286
+     * Retrieves an array of possible invoice statuses.
287
+     *
288
+     * @since 1.0.19
289
+     * @return array
290
+     */
291
+    public function get_all_statuses() {
292
+
293
+        $statuses = wpinv_get_invoice_statuses( true, true, $this );
294
+
295
+        // For backwards compatibility.
296
+        if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
297 297
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
298
-		}
298
+        }
299 299
 
300
-		return $statuses;
300
+        return $statuses;
301 301
     }
302 302
 
303 303
     /**
304
-	 * Get invoice status nice name.
305
-	 *
306
-	 * @since 1.0.19
307
-	 * @return string
308
-	 */
304
+     * Get invoice status nice name.
305
+     *
306
+     * @since 1.0.19
307
+     * @return string
308
+     */
309 309
     public function get_status_nicename() {
310
-		$statuses = $this->get_all_statuses();
310
+        $statuses = $this->get_all_statuses();
311 311
 
312 312
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
313 313
 
314 314
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
315 315
     }
316 316
 
317
-	/**
317
+    /**
318 318
      * Retrieves the invoice status label html
319 319
      *
320 320
      * @since  1.0.0
@@ -322,27 +322,27 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public function get_status_label_html() {
324 324
 
325
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
326
-		$status       = sanitize_html_class( $this->get_status() );
325
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
326
+        $status       = sanitize_html_class( $this->get_status() );
327 327
 
328
-		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
329
-	}
328
+        return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
329
+    }
330 330
 
331 331
     /**
332
-	 * Get plugin version when the invoice was created.
333
-	 *
334
-	 * @since 1.0.19
335
-	 * @param  string $context View or edit context.
336
-	 * @return string
337
-	 */
338
-	public function get_version( $context = 'view' ) {
339
-		return $this->get_prop( 'version', $context );
340
-	}
332
+     * Get plugin version when the invoice was created.
333
+     *
334
+     * @since 1.0.19
335
+     * @param  string $context View or edit context.
336
+     * @return string
337
+     */
338
+    public function get_version( $context = 'view' ) {
339
+        return $this->get_prop( 'version', $context );
340
+    }
341 341
 
342
-	/**
343
-	 * @deprecated
344
-	 */
345
-	public function get_invoice_date( $formatted = true ) {
342
+    /**
343
+     * @deprecated
344
+     */
345
+    public function get_invoice_date( $formatted = true ) {
346 346
         $date_completed = $this->get_date_completed();
347 347
         $invoice_date   = $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
348 348
 
@@ -359,228 +359,228 @@  discard block
 block discarded – undo
359 359
     }
360 360
 
361 361
     /**
362
-	 * Get date when the invoice was created.
363
-	 *
364
-	 * @since 1.0.19
365
-	 * @param  string $context View or edit context.
366
-	 * @return string
367
-	 */
368
-	public function get_date_created( $context = 'view' ) {
369
-		return $this->get_prop( 'date_created', $context );
370
-	}
362
+     * Get date when the invoice was created.
363
+     *
364
+     * @since 1.0.19
365
+     * @param  string $context View or edit context.
366
+     * @return string
367
+     */
368
+    public function get_date_created( $context = 'view' ) {
369
+        return $this->get_prop( 'date_created', $context );
370
+    }
371 371
 	
372
-	/**
373
-	 * Alias for self::get_date_created().
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_created_date( $context = 'view' ) {
380
-		return $this->get_date_created( $context );
381
-    }
382
-
383
-    /**
384
-	 * Get GMT date when the invoice was created.
385
-	 *
386
-	 * @since 1.0.19
387
-	 * @param  string $context View or edit context.
388
-	 * @return string
389
-	 */
390
-	public function get_date_created_gmt( $context = 'view' ) {
372
+    /**
373
+     * Alias for self::get_date_created().
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_created_date( $context = 'view' ) {
380
+        return $this->get_date_created( $context );
381
+    }
382
+
383
+    /**
384
+     * Get GMT date when the invoice was created.
385
+     *
386
+     * @since 1.0.19
387
+     * @param  string $context View or edit context.
388
+     * @return string
389
+     */
390
+    public function get_date_created_gmt( $context = 'view' ) {
391 391
         $date = $this->get_date_created( $context );
392 392
 
393 393
         if ( $date ) {
394 394
             $date = get_gmt_from_date( $date );
395 395
         }
396
-		return $date;
396
+        return $date;
397 397
     }
398 398
 
399 399
     /**
400
-	 * Get date when the invoice was last modified.
401
-	 *
402
-	 * @since 1.0.19
403
-	 * @param  string $context View or edit context.
404
-	 * @return string
405
-	 */
406
-	public function get_date_modified( $context = 'view' ) {
407
-		return $this->get_prop( 'date_modified', $context );
408
-	}
400
+     * Get date when the invoice was last modified.
401
+     *
402
+     * @since 1.0.19
403
+     * @param  string $context View or edit context.
404
+     * @return string
405
+     */
406
+    public function get_date_modified( $context = 'view' ) {
407
+        return $this->get_prop( 'date_modified', $context );
408
+    }
409 409
 
410
-	/**
411
-	 * Alias for self::get_date_modified().
412
-	 *
413
-	 * @since 1.0.19
414
-	 * @param  string $context View or edit context.
415
-	 * @return string
416
-	 */
417
-	public function get_modified_date( $context = 'view' ) {
418
-		return $this->get_date_modified( $context );
410
+    /**
411
+     * Alias for self::get_date_modified().
412
+     *
413
+     * @since 1.0.19
414
+     * @param  string $context View or edit context.
415
+     * @return string
416
+     */
417
+    public function get_modified_date( $context = 'view' ) {
418
+        return $this->get_date_modified( $context );
419 419
     }
420 420
 
421 421
     /**
422
-	 * Get GMT date when the invoice was last modified.
423
-	 *
424
-	 * @since 1.0.19
425
-	 * @param  string $context View or edit context.
426
-	 * @return string
427
-	 */
428
-	public function get_date_modified_gmt( $context = 'view' ) {
422
+     * Get GMT date when the invoice was last modified.
423
+     *
424
+     * @since 1.0.19
425
+     * @param  string $context View or edit context.
426
+     * @return string
427
+     */
428
+    public function get_date_modified_gmt( $context = 'view' ) {
429 429
         $date = $this->get_date_modified( $context );
430 430
 
431 431
         if ( $date ) {
432 432
             $date = get_gmt_from_date( $date );
433 433
         }
434
-		return $date;
434
+        return $date;
435 435
     }
436 436
 
437 437
     /**
438
-	 * Get the invoice due date.
439
-	 *
440
-	 * @since 1.0.19
441
-	 * @param  string $context View or edit context.
442
-	 * @return string
443
-	 */
444
-	public function get_due_date( $context = 'view' ) {
445
-		return $this->get_prop( 'due_date', $context );
438
+     * Get the invoice due date.
439
+     *
440
+     * @since 1.0.19
441
+     * @param  string $context View or edit context.
442
+     * @return string
443
+     */
444
+    public function get_due_date( $context = 'view' ) {
445
+        return $this->get_prop( 'due_date', $context );
446 446
     }
447 447
 
448 448
     /**
449
-	 * Alias for self::get_due_date().
450
-	 *
451
-	 * @since 1.0.19
452
-	 * @param  string $context View or edit context.
453
-	 * @return string
454
-	 */
455
-	public function get_date_due( $context = 'view' ) {
456
-		return $this->get_due_date( $context );
449
+     * Alias for self::get_due_date().
450
+     *
451
+     * @since 1.0.19
452
+     * @param  string $context View or edit context.
453
+     * @return string
454
+     */
455
+    public function get_date_due( $context = 'view' ) {
456
+        return $this->get_due_date( $context );
457 457
     }
458 458
 
459 459
     /**
460
-	 * Get the invoice GMT due date.
461
-	 *
462
-	 * @since 1.0.19
463
-	 * @param  string $context View or edit context.
464
-	 * @return string
465
-	 */
466
-	public function get_due_date_gmt( $context = 'view' ) {
460
+     * Get the invoice GMT due date.
461
+     *
462
+     * @since 1.0.19
463
+     * @param  string $context View or edit context.
464
+     * @return string
465
+     */
466
+    public function get_due_date_gmt( $context = 'view' ) {
467 467
         $date = $this->get_due_date( $context );
468 468
 
469 469
         if ( $date ) {
470 470
             $date = get_gmt_from_date( $date );
471 471
         }
472
-		return $date;
472
+        return $date;
473 473
     }
474 474
 
475 475
     /**
476
-	 * Alias for self::get_due_date_gmt().
477
-	 *
478
-	 * @since 1.0.19
479
-	 * @param  string $context View or edit context.
480
-	 * @return string
481
-	 */
482
-	public function get_gmt_date_due( $context = 'view' ) {
483
-		return $this->get_due_date_gmt( $context );
476
+     * Alias for self::get_due_date_gmt().
477
+     *
478
+     * @since 1.0.19
479
+     * @param  string $context View or edit context.
480
+     * @return string
481
+     */
482
+    public function get_gmt_date_due( $context = 'view' ) {
483
+        return $this->get_due_date_gmt( $context );
484 484
     }
485 485
 
486 486
     /**
487
-	 * Get date when the invoice was completed.
488
-	 *
489
-	 * @since 1.0.19
490
-	 * @param  string $context View or edit context.
491
-	 * @return string
492
-	 */
493
-	public function get_completed_date( $context = 'view' ) {
494
-		return $this->get_prop( 'completed_date', $context );
487
+     * Get date when the invoice was completed.
488
+     *
489
+     * @since 1.0.19
490
+     * @param  string $context View or edit context.
491
+     * @return string
492
+     */
493
+    public function get_completed_date( $context = 'view' ) {
494
+        return $this->get_prop( 'completed_date', $context );
495 495
     }
496 496
 
497 497
     /**
498
-	 * Alias for self::get_completed_date().
499
-	 *
500
-	 * @since 1.0.19
501
-	 * @param  string $context View or edit context.
502
-	 * @return string
503
-	 */
504
-	public function get_date_completed( $context = 'view' ) {
505
-		return $this->get_completed_date( $context );
498
+     * Alias for self::get_completed_date().
499
+     *
500
+     * @since 1.0.19
501
+     * @param  string $context View or edit context.
502
+     * @return string
503
+     */
504
+    public function get_date_completed( $context = 'view' ) {
505
+        return $this->get_completed_date( $context );
506 506
     }
507 507
 
508 508
     /**
509
-	 * Get GMT date when the invoice was was completed.
510
-	 *
511
-	 * @since 1.0.19
512
-	 * @param  string $context View or edit context.
513
-	 * @return string
514
-	 */
515
-	public function get_completed_date_gmt( $context = 'view' ) {
509
+     * Get GMT date when the invoice was was completed.
510
+     *
511
+     * @since 1.0.19
512
+     * @param  string $context View or edit context.
513
+     * @return string
514
+     */
515
+    public function get_completed_date_gmt( $context = 'view' ) {
516 516
         $date = $this->get_completed_date( $context );
517 517
 
518 518
         if ( $date ) {
519 519
             $date = get_gmt_from_date( $date );
520 520
         }
521
-		return $date;
521
+        return $date;
522 522
     }
523 523
 
524 524
     /**
525
-	 * Alias for self::get_completed_date_gmt().
526
-	 *
527
-	 * @since 1.0.19
528
-	 * @param  string $context View or edit context.
529
-	 * @return string
530
-	 */
531
-	public function get_gmt_completed_date( $context = 'view' ) {
532
-		return $this->get_completed_date_gmt( $context );
525
+     * Alias for self::get_completed_date_gmt().
526
+     *
527
+     * @since 1.0.19
528
+     * @param  string $context View or edit context.
529
+     * @return string
530
+     */
531
+    public function get_gmt_completed_date( $context = 'view' ) {
532
+        return $this->get_completed_date_gmt( $context );
533 533
     }
534 534
 
535 535
     /**
536
-	 * Get the invoice number.
537
-	 *
538
-	 * @since 1.0.19
539
-	 * @param  string $context View or edit context.
540
-	 * @return string
541
-	 */
542
-	public function get_number( $context = 'view' ) {
543
-		$number = $this->get_prop( 'number', $context );
536
+     * Get the invoice number.
537
+     *
538
+     * @since 1.0.19
539
+     * @param  string $context View or edit context.
540
+     * @return string
541
+     */
542
+    public function get_number( $context = 'view' ) {
543
+        $number = $this->get_prop( 'number', $context );
544 544
 
545
-		if ( empty( $number ) ) {
546
-			$number = $this->generate_number();
547
-			$this->set_number( $this->generate_number() );
548
-		}
545
+        if ( empty( $number ) ) {
546
+            $number = $this->generate_number();
547
+            $this->set_number( $this->generate_number() );
548
+        }
549 549
 
550
-		return $number;
550
+        return $number;
551 551
     }
552 552
 
553
-	/**
554
-	 * Set the invoice number.
555
-	 *
556
-	 * @since 1.0.19
557
-	 */
558
-	public function maybe_set_number() {
553
+    /**
554
+     * Set the invoice number.
555
+     *
556
+     * @since 1.0.19
557
+     */
558
+    public function maybe_set_number() {
559 559
         $number = $this->get_number();
560 560
 
561 561
         if ( empty( $number ) || $this->get_id() == $number ) {
562
-			$this->set_number( $this->generate_number() );
562
+            $this->set_number( $this->generate_number() );
563 563
         }
564 564
 
565
-	}
565
+    }
566 566
 
567 567
     /**
568
-	 * Get the invoice key.
569
-	 *
570
-	 * @since 1.0.19
571
-	 * @param  string $context View or edit context.
572
-	 * @return string
573
-	 */
574
-	public function get_key( $context = 'view' ) {
568
+     * Get the invoice key.
569
+     *
570
+     * @since 1.0.19
571
+     * @param  string $context View or edit context.
572
+     * @return string
573
+     */
574
+    public function get_key( $context = 'view' ) {
575 575
         return $this->get_prop( 'key', $context );
576
-	}
577
-
578
-	/**
579
-	 * Set the invoice key.
580
-	 *
581
-	 * @since 1.0.19
582
-	 */
583
-	public function maybe_set_key() {
576
+    }
577
+
578
+    /**
579
+     * Set the invoice key.
580
+     *
581
+     * @since 1.0.19
582
+     */
583
+    public function maybe_set_key() {
584 584
         $key = $this->get_key();
585 585
 
586 586
         if ( empty( $key ) ) {
@@ -591,126 +591,126 @@  discard block
 block discarded – undo
591 591
     }
592 592
 
593 593
     /**
594
-	 * Get the invoice type.
595
-	 *
596
-	 * @since 1.0.19
597
-	 * @param  string $context View or edit context.
598
-	 * @return string
599
-	 */
600
-	public function get_type( $context = 'view' ) {
594
+     * Get the invoice type.
595
+     *
596
+     * @since 1.0.19
597
+     * @param  string $context View or edit context.
598
+     * @return string
599
+     */
600
+    public function get_type( $context = 'view' ) {
601 601
         return $this->get_prop( 'type', $context );
602
-	}
602
+    }
603 603
 
604
-	/**
605
-	 * @deprecated
606
-	 */
607
-	public function get_invoice_quote_type() {
604
+    /**
605
+     * @deprecated
606
+     */
607
+    public function get_invoice_quote_type() {
608 608
         ucfirst( $this->get_type() );
609 609
     }
610 610
 
611 611
     /**
612
-	 * Get the invoice post type.
613
-	 *
614
-	 * @since 1.0.19
615
-	 * @param  string $context View or edit context.
616
-	 * @return string
617
-	 */
618
-	public function get_post_type( $context = 'view' ) {
612
+     * Get the invoice post type.
613
+     *
614
+     * @since 1.0.19
615
+     * @param  string $context View or edit context.
616
+     * @return string
617
+     */
618
+    public function get_post_type( $context = 'view' ) {
619 619
         return $this->get_prop( 'post_type', $context );
620 620
     }
621 621
 
622 622
     /**
623
-	 * Get the invoice mode.
624
-	 *
625
-	 * @since 1.0.19
626
-	 * @param  string $context View or edit context.
627
-	 * @return string
628
-	 */
629
-	public function get_mode( $context = 'view' ) {
623
+     * Get the invoice mode.
624
+     *
625
+     * @since 1.0.19
626
+     * @param  string $context View or edit context.
627
+     * @return string
628
+     */
629
+    public function get_mode( $context = 'view' ) {
630 630
         return $this->get_prop( 'mode', $context );
631 631
     }
632 632
 
633 633
     /**
634
-	 * Get the invoice path.
635
-	 *
636
-	 * @since 1.0.19
637
-	 * @param  string $context View or edit context.
638
-	 * @return string
639
-	 */
640
-	public function get_path( $context = 'view' ) {
634
+     * Get the invoice path.
635
+     *
636
+     * @since 1.0.19
637
+     * @param  string $context View or edit context.
638
+     * @return string
639
+     */
640
+    public function get_path( $context = 'view' ) {
641 641
         $path   = $this->get_prop( 'path', $context );
642
-		$prefix = wpinv_post_name_prefix( $this->get_post_type() );
642
+        $prefix = wpinv_post_name_prefix( $this->get_post_type() );
643 643
 
644
-		if ( 0 !== strpos( $path, $prefix ) ) {
645
-			$path = sanitize_title(  $prefix . $this->get_id()  );
646
-			$this->set_path( $path );
647
-		}
644
+        if ( 0 !== strpos( $path, $prefix ) ) {
645
+            $path = sanitize_title(  $prefix . $this->get_id()  );
646
+            $this->set_path( $path );
647
+        }
648 648
 
649
-		return $path;
649
+        return $path;
650 650
     }
651 651
 
652 652
     /**
653
-	 * Get the invoice name/title.
654
-	 *
655
-	 * @since 1.0.19
656
-	 * @param  string $context View or edit context.
657
-	 * @return string
658
-	 */
659
-	public function get_name( $context = 'view' ) {
653
+     * Get the invoice name/title.
654
+     *
655
+     * @since 1.0.19
656
+     * @param  string $context View or edit context.
657
+     * @return string
658
+     */
659
+    public function get_name( $context = 'view' ) {
660 660
         return $this->get_prop( 'title', $context );
661 661
     }
662 662
 
663 663
     /**
664
-	 * Alias of self::get_name().
665
-	 *
666
-	 * @since 1.0.19
667
-	 * @param  string $context View or edit context.
668
-	 * @return string
669
-	 */
670
-	public function get_title( $context = 'view' ) {
671
-		return $this->get_name( $context );
664
+     * Alias of self::get_name().
665
+     *
666
+     * @since 1.0.19
667
+     * @param  string $context View or edit context.
668
+     * @return string
669
+     */
670
+    public function get_title( $context = 'view' ) {
671
+        return $this->get_name( $context );
672 672
     }
673 673
 
674 674
     /**
675
-	 * Get the invoice description.
676
-	 *
677
-	 * @since 1.0.19
678
-	 * @param  string $context View or edit context.
679
-	 * @return string
680
-	 */
681
-	public function get_description( $context = 'view' ) {
682
-		return $this->get_prop( 'description', $context );
675
+     * Get the invoice description.
676
+     *
677
+     * @since 1.0.19
678
+     * @param  string $context View or edit context.
679
+     * @return string
680
+     */
681
+    public function get_description( $context = 'view' ) {
682
+        return $this->get_prop( 'description', $context );
683 683
     }
684 684
 
685 685
     /**
686
-	 * Alias of self::get_description().
687
-	 *
688
-	 * @since 1.0.19
689
-	 * @param  string $context View or edit context.
690
-	 * @return string
691
-	 */
692
-	public function get_excerpt( $context = 'view' ) {
693
-		return $this->get_description( $context );
686
+     * Alias of self::get_description().
687
+     *
688
+     * @since 1.0.19
689
+     * @param  string $context View or edit context.
690
+     * @return string
691
+     */
692
+    public function get_excerpt( $context = 'view' ) {
693
+        return $this->get_description( $context );
694 694
     }
695 695
 
696 696
     /**
697
-	 * Alias of self::get_description().
698
-	 *
699
-	 * @since 1.0.19
700
-	 * @param  string $context View or edit context.
701
-	 * @return string
702
-	 */
703
-	public function get_summary( $context = 'view' ) {
704
-		return $this->get_description( $context );
697
+     * Alias of self::get_description().
698
+     *
699
+     * @since 1.0.19
700
+     * @param  string $context View or edit context.
701
+     * @return string
702
+     */
703
+    public function get_summary( $context = 'view' ) {
704
+        return $this->get_description( $context );
705 705
     }
706 706
 
707 707
     /**
708
-	 * Returns the user info.
709
-	 *
710
-	 * @since 1.0.19
708
+     * Returns the user info.
709
+     *
710
+     * @since 1.0.19
711 711
      * @param  string $context View or edit context.
712
-	 * @return array
713
-	 */
712
+     * @return array
713
+     */
714 714
     public function get_user_info( $context = 'view' ) {
715 715
 
716 716
         $user_info = array(
@@ -727,605 +727,605 @@  discard block
 block discarded – undo
727 727
             'company'    => $this->get_company( $context ),
728 728
             'vat_number' => $this->get_vat_number( $context ),
729 729
             'discount'   => $this->get_discount_code( $context ),
730
-		);
730
+        );
731 731
 
732
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
732
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
733 733
 
734 734
     }
735 735
 
736 736
     /**
737
-	 * Get the customer id.
738
-	 *
739
-	 * @since 1.0.19
740
-	 * @param  string $context View or edit context.
741
-	 * @return int
742
-	 */
743
-	public function get_author( $context = 'view' ) {
744
-		return (int) $this->get_prop( 'author', $context );
737
+     * Get the customer id.
738
+     *
739
+     * @since 1.0.19
740
+     * @param  string $context View or edit context.
741
+     * @return int
742
+     */
743
+    public function get_author( $context = 'view' ) {
744
+        return (int) $this->get_prop( 'author', $context );
745 745
     }
746 746
 
747 747
     /**
748
-	 * Alias of self::get_author().
749
-	 *
750
-	 * @since 1.0.19
751
-	 * @param  string $context View or edit context.
752
-	 * @return int
753
-	 */
754
-	public function get_user_id( $context = 'view' ) {
755
-		return $this->get_author( $context );
748
+     * Alias of self::get_author().
749
+     *
750
+     * @since 1.0.19
751
+     * @param  string $context View or edit context.
752
+     * @return int
753
+     */
754
+    public function get_user_id( $context = 'view' ) {
755
+        return $this->get_author( $context );
756 756
     }
757 757
 
758
-     /**
759
-	 * Alias of self::get_author().
760
-	 *
761
-	 * @since 1.0.19
762
-	 * @param  string $context View or edit context.
763
-	 * @return int
764
-	 */
765
-	public function get_customer_id( $context = 'view' ) {
766
-		return $this->get_author( $context );
758
+        /**
759
+         * Alias of self::get_author().
760
+         *
761
+         * @since 1.0.19
762
+         * @param  string $context View or edit context.
763
+         * @return int
764
+         */
765
+    public function get_customer_id( $context = 'view' ) {
766
+        return $this->get_author( $context );
767 767
     }
768 768
 
769 769
     /**
770
-	 * Get the customer's ip.
771
-	 *
772
-	 * @since 1.0.19
773
-	 * @param  string $context View or edit context.
774
-	 * @return string
775
-	 */
776
-	public function get_ip( $context = 'view' ) {
777
-		return $this->get_prop( 'user_ip', $context );
770
+     * Get the customer's ip.
771
+     *
772
+     * @since 1.0.19
773
+     * @param  string $context View or edit context.
774
+     * @return string
775
+     */
776
+    public function get_ip( $context = 'view' ) {
777
+        return $this->get_prop( 'user_ip', $context );
778 778
     }
779 779
 
780 780
     /**
781
-	 * Alias of self::get_ip().
782
-	 *
783
-	 * @since 1.0.19
784
-	 * @param  string $context View or edit context.
785
-	 * @return string
786
-	 */
787
-	public function get_user_ip( $context = 'view' ) {
788
-		return $this->get_ip( $context );
781
+     * Alias of self::get_ip().
782
+     *
783
+     * @since 1.0.19
784
+     * @param  string $context View or edit context.
785
+     * @return string
786
+     */
787
+    public function get_user_ip( $context = 'view' ) {
788
+        return $this->get_ip( $context );
789
+    }
790
+
791
+        /**
792
+         * Alias of self::get_ip().
793
+         *
794
+         * @since 1.0.19
795
+         * @param  string $context View or edit context.
796
+         * @return string
797
+         */
798
+    public function get_customer_ip( $context = 'view' ) {
799
+        return $this->get_ip( $context );
800
+    }
801
+
802
+    /**
803
+     * Get the customer's first name.
804
+     *
805
+     * @since 1.0.19
806
+     * @param  string $context View or edit context.
807
+     * @return string
808
+     */
809
+    public function get_first_name( $context = 'view' ) {
810
+        return $this->get_prop( 'first_name', $context );
811
+    }
812
+
813
+    /**
814
+     * Alias of self::get_first_name().
815
+     *
816
+     * @since 1.0.19
817
+     * @param  string $context View or edit context.
818
+     * @return int
819
+     */
820
+    public function get_user_first_name( $context = 'view' ) {
821
+        return $this->get_first_name( $context );
822
+    }
823
+
824
+        /**
825
+         * Alias of self::get_first_name().
826
+         *
827
+         * @since 1.0.19
828
+         * @param  string $context View or edit context.
829
+         * @return int
830
+         */
831
+    public function get_customer_first_name( $context = 'view' ) {
832
+        return $this->get_first_name( $context );
833
+    }
834
+
835
+    /**
836
+     * Get the customer's last name.
837
+     *
838
+     * @since 1.0.19
839
+     * @param  string $context View or edit context.
840
+     * @return string
841
+     */
842
+    public function get_last_name( $context = 'view' ) {
843
+        return $this->get_prop( 'last_name', $context );
844
+    }
845
+
846
+    /**
847
+     * Alias of self::get_last_name().
848
+     *
849
+     * @since 1.0.19
850
+     * @param  string $context View or edit context.
851
+     * @return int
852
+     */
853
+    public function get_user_last_name( $context = 'view' ) {
854
+        return $this->get_last_name( $context );
855
+    }
856
+
857
+    /**
858
+     * Alias of self::get_last_name().
859
+     *
860
+     * @since 1.0.19
861
+     * @param  string $context View or edit context.
862
+     * @return int
863
+     */
864
+    public function get_customer_last_name( $context = 'view' ) {
865
+        return $this->get_last_name( $context );
866
+    }
867
+
868
+    /**
869
+     * Get the customer's full name.
870
+     *
871
+     * @since 1.0.19
872
+     * @param  string $context View or edit context.
873
+     * @return string
874
+     */
875
+    public function get_full_name( $context = 'view' ) {
876
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
877
+    }
878
+
879
+    /**
880
+     * Alias of self::get_full_name().
881
+     *
882
+     * @since 1.0.19
883
+     * @param  string $context View or edit context.
884
+     * @return int
885
+     */
886
+    public function get_user_full_name( $context = 'view' ) {
887
+        return $this->get_full_name( $context );
789 888
     }
790 889
 
791
-     /**
792
-	 * Alias of self::get_ip().
793
-	 *
794
-	 * @since 1.0.19
795
-	 * @param  string $context View or edit context.
796
-	 * @return string
797
-	 */
798
-	public function get_customer_ip( $context = 'view' ) {
799
-		return $this->get_ip( $context );
890
+    /**
891
+     * Alias of self::get_full_name().
892
+     *
893
+     * @since 1.0.19
894
+     * @param  string $context View or edit context.
895
+     * @return int
896
+     */
897
+    public function get_customer_full_name( $context = 'view' ) {
898
+        return $this->get_full_name( $context );
800 899
     }
801 900
 
802 901
     /**
803
-	 * Get the customer's first name.
804
-	 *
805
-	 * @since 1.0.19
806
-	 * @param  string $context View or edit context.
807
-	 * @return string
808
-	 */
809
-	public function get_first_name( $context = 'view' ) {
810
-		return $this->get_prop( 'first_name', $context );
902
+     * Get the customer's phone number.
903
+     *
904
+     * @since 1.0.19
905
+     * @param  string $context View or edit context.
906
+     * @return string
907
+     */
908
+    public function get_phone( $context = 'view' ) {
909
+        return $this->get_prop( 'phone', $context );
811 910
     }
812 911
 
813 912
     /**
814
-	 * Alias of self::get_first_name().
815
-	 *
816
-	 * @since 1.0.19
817
-	 * @param  string $context View or edit context.
818
-	 * @return int
819
-	 */
820
-	public function get_user_first_name( $context = 'view' ) {
821
-		return $this->get_first_name( $context );
913
+     * Alias of self::get_phone().
914
+     *
915
+     * @since 1.0.19
916
+     * @param  string $context View or edit context.
917
+     * @return int
918
+     */
919
+    public function get_phone_number( $context = 'view' ) {
920
+        return $this->get_phone( $context );
822 921
     }
823 922
 
824
-     /**
825
-	 * Alias of self::get_first_name().
826
-	 *
827
-	 * @since 1.0.19
828
-	 * @param  string $context View or edit context.
829
-	 * @return int
830
-	 */
831
-	public function get_customer_first_name( $context = 'view' ) {
832
-		return $this->get_first_name( $context );
923
+    /**
924
+     * Alias of self::get_phone().
925
+     *
926
+     * @since 1.0.19
927
+     * @param  string $context View or edit context.
928
+     * @return int
929
+     */
930
+    public function get_user_phone( $context = 'view' ) {
931
+        return $this->get_phone( $context );
833 932
     }
834 933
 
835 934
     /**
836
-	 * Get the customer's last name.
837
-	 *
838
-	 * @since 1.0.19
839
-	 * @param  string $context View or edit context.
840
-	 * @return string
841
-	 */
842
-	public function get_last_name( $context = 'view' ) {
843
-		return $this->get_prop( 'last_name', $context );
935
+     * Alias of self::get_phone().
936
+     *
937
+     * @since 1.0.19
938
+     * @param  string $context View or edit context.
939
+     * @return int
940
+     */
941
+    public function get_customer_phone( $context = 'view' ) {
942
+        return $this->get_phone( $context );
844 943
     }
845 944
 
846 945
     /**
847
-	 * Alias of self::get_last_name().
848
-	 *
849
-	 * @since 1.0.19
850
-	 * @param  string $context View or edit context.
851
-	 * @return int
852
-	 */
853
-	public function get_user_last_name( $context = 'view' ) {
854
-		return $this->get_last_name( $context );
946
+     * Get the customer's email address.
947
+     *
948
+     * @since 1.0.19
949
+     * @param  string $context View or edit context.
950
+     * @return string
951
+     */
952
+    public function get_email( $context = 'view' ) {
953
+        return $this->get_prop( 'email', $context );
855 954
     }
856 955
 
857 956
     /**
858
-	 * Alias of self::get_last_name().
859
-	 *
860
-	 * @since 1.0.19
861
-	 * @param  string $context View or edit context.
862
-	 * @return int
863
-	 */
864
-	public function get_customer_last_name( $context = 'view' ) {
865
-		return $this->get_last_name( $context );
957
+     * Alias of self::get_email().
958
+     *
959
+     * @since 1.0.19
960
+     * @param  string $context View or edit context.
961
+     * @return string
962
+     */
963
+    public function get_email_address( $context = 'view' ) {
964
+        return $this->get_email( $context );
866 965
     }
867 966
 
868 967
     /**
869
-	 * Get the customer's full name.
870
-	 *
871
-	 * @since 1.0.19
872
-	 * @param  string $context View or edit context.
873
-	 * @return string
874
-	 */
875
-	public function get_full_name( $context = 'view' ) {
876
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
968
+     * Alias of self::get_email().
969
+     *
970
+     * @since 1.0.19
971
+     * @param  string $context View or edit context.
972
+     * @return int
973
+     */
974
+    public function get_user_email( $context = 'view' ) {
975
+        return $this->get_email( $context );
877 976
     }
878 977
 
879 978
     /**
880
-	 * Alias of self::get_full_name().
881
-	 *
882
-	 * @since 1.0.19
883
-	 * @param  string $context View or edit context.
884
-	 * @return int
885
-	 */
886
-	public function get_user_full_name( $context = 'view' ) {
887
-		return $this->get_full_name( $context );
979
+     * Alias of self::get_email().
980
+     *
981
+     * @since 1.0.19
982
+     * @param  string $context View or edit context.
983
+     * @return int
984
+     */
985
+    public function get_customer_email( $context = 'view' ) {
986
+        return $this->get_email( $context );
888 987
     }
889 988
 
890 989
     /**
891
-	 * Alias of self::get_full_name().
892
-	 *
893
-	 * @since 1.0.19
894
-	 * @param  string $context View or edit context.
895
-	 * @return int
896
-	 */
897
-	public function get_customer_full_name( $context = 'view' ) {
898
-		return $this->get_full_name( $context );
990
+     * Get the customer's country.
991
+     *
992
+     * @since 1.0.19
993
+     * @param  string $context View or edit context.
994
+     * @return string
995
+     */
996
+    public function get_country( $context = 'view' ) {
997
+        $country = $this->get_prop( 'country', $context );
998
+        return empty( $country ) ? wpinv_get_default_country() : $country;
899 999
     }
900 1000
 
901 1001
     /**
902
-	 * Get the customer's phone number.
903
-	 *
904
-	 * @since 1.0.19
905
-	 * @param  string $context View or edit context.
906
-	 * @return string
907
-	 */
908
-	public function get_phone( $context = 'view' ) {
909
-		return $this->get_prop( 'phone', $context );
1002
+     * Alias of self::get_country().
1003
+     *
1004
+     * @since 1.0.19
1005
+     * @param  string $context View or edit context.
1006
+     * @return int
1007
+     */
1008
+    public function get_user_country( $context = 'view' ) {
1009
+        return $this->get_country( $context );
910 1010
     }
911 1011
 
912 1012
     /**
913
-	 * Alias of self::get_phone().
914
-	 *
915
-	 * @since 1.0.19
916
-	 * @param  string $context View or edit context.
917
-	 * @return int
918
-	 */
919
-	public function get_phone_number( $context = 'view' ) {
920
-		return $this->get_phone( $context );
1013
+     * Alias of self::get_country().
1014
+     *
1015
+     * @since 1.0.19
1016
+     * @param  string $context View or edit context.
1017
+     * @return int
1018
+     */
1019
+    public function get_customer_country( $context = 'view' ) {
1020
+        return $this->get_country( $context );
921 1021
     }
922 1022
 
923 1023
     /**
924
-	 * Alias of self::get_phone().
925
-	 *
926
-	 * @since 1.0.19
927
-	 * @param  string $context View or edit context.
928
-	 * @return int
929
-	 */
930
-	public function get_user_phone( $context = 'view' ) {
931
-		return $this->get_phone( $context );
1024
+     * Get the customer's state.
1025
+     *
1026
+     * @since 1.0.19
1027
+     * @param  string $context View or edit context.
1028
+     * @return string
1029
+     */
1030
+    public function get_state( $context = 'view' ) {
1031
+        $state = $this->get_prop( 'state', $context );
1032
+        return empty( $state ) ? wpinv_get_default_state() : $state;
932 1033
     }
933 1034
 
934 1035
     /**
935
-	 * Alias of self::get_phone().
936
-	 *
937
-	 * @since 1.0.19
938
-	 * @param  string $context View or edit context.
939
-	 * @return int
940
-	 */
941
-	public function get_customer_phone( $context = 'view' ) {
942
-		return $this->get_phone( $context );
1036
+     * Alias of self::get_state().
1037
+     *
1038
+     * @since 1.0.19
1039
+     * @param  string $context View or edit context.
1040
+     * @return int
1041
+     */
1042
+    public function get_user_state( $context = 'view' ) {
1043
+        return $this->get_state( $context );
943 1044
     }
944 1045
 
945 1046
     /**
946
-	 * Get the customer's email address.
947
-	 *
948
-	 * @since 1.0.19
949
-	 * @param  string $context View or edit context.
950
-	 * @return string
951
-	 */
952
-	public function get_email( $context = 'view' ) {
953
-		return $this->get_prop( 'email', $context );
1047
+     * Alias of self::get_state().
1048
+     *
1049
+     * @since 1.0.19
1050
+     * @param  string $context View or edit context.
1051
+     * @return int
1052
+     */
1053
+    public function get_customer_state( $context = 'view' ) {
1054
+        return $this->get_state( $context );
954 1055
     }
955 1056
 
956 1057
     /**
957
-	 * Alias of self::get_email().
958
-	 *
959
-	 * @since 1.0.19
960
-	 * @param  string $context View or edit context.
961
-	 * @return string
962
-	 */
963
-	public function get_email_address( $context = 'view' ) {
964
-		return $this->get_email( $context );
1058
+     * Get the customer's city.
1059
+     *
1060
+     * @since 1.0.19
1061
+     * @param  string $context View or edit context.
1062
+     * @return string
1063
+     */
1064
+    public function get_city( $context = 'view' ) {
1065
+        return $this->get_prop( 'city', $context );
965 1066
     }
966 1067
 
967 1068
     /**
968
-	 * Alias of self::get_email().
969
-	 *
970
-	 * @since 1.0.19
971
-	 * @param  string $context View or edit context.
972
-	 * @return int
973
-	 */
974
-	public function get_user_email( $context = 'view' ) {
975
-		return $this->get_email( $context );
1069
+     * Alias of self::get_city().
1070
+     *
1071
+     * @since 1.0.19
1072
+     * @param  string $context View or edit context.
1073
+     * @return string
1074
+     */
1075
+    public function get_user_city( $context = 'view' ) {
1076
+        return $this->get_city( $context );
976 1077
     }
977 1078
 
978 1079
     /**
979
-	 * Alias of self::get_email().
980
-	 *
981
-	 * @since 1.0.19
982
-	 * @param  string $context View or edit context.
983
-	 * @return int
984
-	 */
985
-	public function get_customer_email( $context = 'view' ) {
986
-		return $this->get_email( $context );
1080
+     * Alias of self::get_city().
1081
+     *
1082
+     * @since 1.0.19
1083
+     * @param  string $context View or edit context.
1084
+     * @return string
1085
+     */
1086
+    public function get_customer_city( $context = 'view' ) {
1087
+        return $this->get_city( $context );
987 1088
     }
988 1089
 
989 1090
     /**
990
-	 * Get the customer's country.
991
-	 *
992
-	 * @since 1.0.19
993
-	 * @param  string $context View or edit context.
994
-	 * @return string
995
-	 */
996
-	public function get_country( $context = 'view' ) {
997
-		$country = $this->get_prop( 'country', $context );
998
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1091
+     * Get the customer's zip.
1092
+     *
1093
+     * @since 1.0.19
1094
+     * @param  string $context View or edit context.
1095
+     * @return string
1096
+     */
1097
+    public function get_zip( $context = 'view' ) {
1098
+        return $this->get_prop( 'zip', $context );
999 1099
     }
1000 1100
 
1001 1101
     /**
1002
-	 * Alias of self::get_country().
1003
-	 *
1004
-	 * @since 1.0.19
1005
-	 * @param  string $context View or edit context.
1006
-	 * @return int
1007
-	 */
1008
-	public function get_user_country( $context = 'view' ) {
1009
-		return $this->get_country( $context );
1102
+     * Alias of self::get_zip().
1103
+     *
1104
+     * @since 1.0.19
1105
+     * @param  string $context View or edit context.
1106
+     * @return string
1107
+     */
1108
+    public function get_user_zip( $context = 'view' ) {
1109
+        return $this->get_zip( $context );
1010 1110
     }
1011 1111
 
1012 1112
     /**
1013
-	 * Alias of self::get_country().
1014
-	 *
1015
-	 * @since 1.0.19
1016
-	 * @param  string $context View or edit context.
1017
-	 * @return int
1018
-	 */
1019
-	public function get_customer_country( $context = 'view' ) {
1020
-		return $this->get_country( $context );
1113
+     * Alias of self::get_zip().
1114
+     *
1115
+     * @since 1.0.19
1116
+     * @param  string $context View or edit context.
1117
+     * @return string
1118
+     */
1119
+    public function get_customer_zip( $context = 'view' ) {
1120
+        return $this->get_zip( $context );
1021 1121
     }
1022 1122
 
1023 1123
     /**
1024
-	 * Get the customer's state.
1025
-	 *
1026
-	 * @since 1.0.19
1027
-	 * @param  string $context View or edit context.
1028
-	 * @return string
1029
-	 */
1030
-	public function get_state( $context = 'view' ) {
1031
-		$state = $this->get_prop( 'state', $context );
1032
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1124
+     * Get the customer's company.
1125
+     *
1126
+     * @since 1.0.19
1127
+     * @param  string $context View or edit context.
1128
+     * @return string
1129
+     */
1130
+    public function get_company( $context = 'view' ) {
1131
+        return $this->get_prop( 'company', $context );
1033 1132
     }
1034 1133
 
1035 1134
     /**
1036
-	 * Alias of self::get_state().
1037
-	 *
1038
-	 * @since 1.0.19
1039
-	 * @param  string $context View or edit context.
1040
-	 * @return int
1041
-	 */
1042
-	public function get_user_state( $context = 'view' ) {
1043
-		return $this->get_state( $context );
1135
+     * Alias of self::get_company().
1136
+     *
1137
+     * @since 1.0.19
1138
+     * @param  string $context View or edit context.
1139
+     * @return string
1140
+     */
1141
+    public function get_user_company( $context = 'view' ) {
1142
+        return $this->get_company( $context );
1044 1143
     }
1045 1144
 
1046 1145
     /**
1047
-	 * Alias of self::get_state().
1048
-	 *
1049
-	 * @since 1.0.19
1050
-	 * @param  string $context View or edit context.
1051
-	 * @return int
1052
-	 */
1053
-	public function get_customer_state( $context = 'view' ) {
1054
-		return $this->get_state( $context );
1146
+     * Alias of self::get_company().
1147
+     *
1148
+     * @since 1.0.19
1149
+     * @param  string $context View or edit context.
1150
+     * @return string
1151
+     */
1152
+    public function get_customer_company( $context = 'view' ) {
1153
+        return $this->get_company( $context );
1055 1154
     }
1056 1155
 
1057 1156
     /**
1058
-	 * Get the customer's city.
1059
-	 *
1060
-	 * @since 1.0.19
1061
-	 * @param  string $context View or edit context.
1062
-	 * @return string
1063
-	 */
1064
-	public function get_city( $context = 'view' ) {
1065
-		return $this->get_prop( 'city', $context );
1157
+     * Get the customer's vat number.
1158
+     *
1159
+     * @since 1.0.19
1160
+     * @param  string $context View or edit context.
1161
+     * @return string
1162
+     */
1163
+    public function get_vat_number( $context = 'view' ) {
1164
+        return $this->get_prop( 'vat_number', $context );
1066 1165
     }
1067 1166
 
1068 1167
     /**
1069
-	 * Alias of self::get_city().
1070
-	 *
1071
-	 * @since 1.0.19
1072
-	 * @param  string $context View or edit context.
1073
-	 * @return string
1074
-	 */
1075
-	public function get_user_city( $context = 'view' ) {
1076
-		return $this->get_city( $context );
1168
+     * Alias of self::get_vat_number().
1169
+     *
1170
+     * @since 1.0.19
1171
+     * @param  string $context View or edit context.
1172
+     * @return string
1173
+     */
1174
+    public function get_user_vat_number( $context = 'view' ) {
1175
+        return $this->get_vat_number( $context );
1077 1176
     }
1078 1177
 
1079 1178
     /**
1080
-	 * Alias of self::get_city().
1081
-	 *
1082
-	 * @since 1.0.19
1083
-	 * @param  string $context View or edit context.
1084
-	 * @return string
1085
-	 */
1086
-	public function get_customer_city( $context = 'view' ) {
1087
-		return $this->get_city( $context );
1179
+     * Alias of self::get_vat_number().
1180
+     *
1181
+     * @since 1.0.19
1182
+     * @param  string $context View or edit context.
1183
+     * @return string
1184
+     */
1185
+    public function get_customer_vat_number( $context = 'view' ) {
1186
+        return $this->get_vat_number( $context );
1088 1187
     }
1089 1188
 
1090 1189
     /**
1091
-	 * Get the customer's zip.
1092
-	 *
1093
-	 * @since 1.0.19
1094
-	 * @param  string $context View or edit context.
1095
-	 * @return string
1096
-	 */
1097
-	public function get_zip( $context = 'view' ) {
1098
-		return $this->get_prop( 'zip', $context );
1190
+     * Get the customer's vat rate.
1191
+     *
1192
+     * @since 1.0.19
1193
+     * @param  string $context View or edit context.
1194
+     * @return string
1195
+     */
1196
+    public function get_vat_rate( $context = 'view' ) {
1197
+        return $this->get_prop( 'vat_rate', $context );
1099 1198
     }
1100 1199
 
1101 1200
     /**
1102
-	 * Alias of self::get_zip().
1103
-	 *
1104
-	 * @since 1.0.19
1105
-	 * @param  string $context View or edit context.
1106
-	 * @return string
1107
-	 */
1108
-	public function get_user_zip( $context = 'view' ) {
1109
-		return $this->get_zip( $context );
1201
+     * Alias of self::get_vat_rate().
1202
+     *
1203
+     * @since 1.0.19
1204
+     * @param  string $context View or edit context.
1205
+     * @return string
1206
+     */
1207
+    public function get_user_vat_rate( $context = 'view' ) {
1208
+        return $this->get_vat_rate( $context );
1110 1209
     }
1111 1210
 
1112 1211
     /**
1113
-	 * Alias of self::get_zip().
1114
-	 *
1115
-	 * @since 1.0.19
1116
-	 * @param  string $context View or edit context.
1117
-	 * @return string
1118
-	 */
1119
-	public function get_customer_zip( $context = 'view' ) {
1120
-		return $this->get_zip( $context );
1212
+     * Alias of self::get_vat_rate().
1213
+     *
1214
+     * @since 1.0.19
1215
+     * @param  string $context View or edit context.
1216
+     * @return string
1217
+     */
1218
+    public function get_customer_vat_rate( $context = 'view' ) {
1219
+        return $this->get_vat_rate( $context );
1121 1220
     }
1122 1221
 
1123 1222
     /**
1124
-	 * Get the customer's company.
1125
-	 *
1126
-	 * @since 1.0.19
1127
-	 * @param  string $context View or edit context.
1128
-	 * @return string
1129
-	 */
1130
-	public function get_company( $context = 'view' ) {
1131
-		return $this->get_prop( 'company', $context );
1223
+     * Get the customer's address.
1224
+     *
1225
+     * @since 1.0.19
1226
+     * @param  string $context View or edit context.
1227
+     * @return string
1228
+     */
1229
+    public function get_address( $context = 'view' ) {
1230
+        return $this->get_prop( 'address', $context );
1132 1231
     }
1133 1232
 
1134 1233
     /**
1135
-	 * Alias of self::get_company().
1136
-	 *
1137
-	 * @since 1.0.19
1138
-	 * @param  string $context View or edit context.
1139
-	 * @return string
1140
-	 */
1141
-	public function get_user_company( $context = 'view' ) {
1142
-		return $this->get_company( $context );
1234
+     * Alias of self::get_address().
1235
+     *
1236
+     * @since 1.0.19
1237
+     * @param  string $context View or edit context.
1238
+     * @return string
1239
+     */
1240
+    public function get_user_address( $context = 'view' ) {
1241
+        return $this->get_address( $context );
1143 1242
     }
1144 1243
 
1145 1244
     /**
1146
-	 * Alias of self::get_company().
1147
-	 *
1148
-	 * @since 1.0.19
1149
-	 * @param  string $context View or edit context.
1150
-	 * @return string
1151
-	 */
1152
-	public function get_customer_company( $context = 'view' ) {
1153
-		return $this->get_company( $context );
1245
+     * Alias of self::get_address().
1246
+     *
1247
+     * @since 1.0.19
1248
+     * @param  string $context View or edit context.
1249
+     * @return string
1250
+     */
1251
+    public function get_customer_address( $context = 'view' ) {
1252
+        return $this->get_address( $context );
1154 1253
     }
1155 1254
 
1156 1255
     /**
1157
-	 * Get the customer's vat number.
1158
-	 *
1159
-	 * @since 1.0.19
1160
-	 * @param  string $context View or edit context.
1161
-	 * @return string
1162
-	 */
1163
-	public function get_vat_number( $context = 'view' ) {
1164
-		return $this->get_prop( 'vat_number', $context );
1256
+     * Get whether the customer has viewed the invoice or not.
1257
+     *
1258
+     * @since 1.0.19
1259
+     * @param  string $context View or edit context.
1260
+     * @return bool
1261
+     */
1262
+    public function get_is_viewed( $context = 'view' ) {
1263
+        return (bool) $this->get_prop( 'is_viewed', $context );
1165 1264
     }
1166 1265
 
1167 1266
     /**
1168
-	 * Alias of self::get_vat_number().
1169
-	 *
1170
-	 * @since 1.0.19
1171
-	 * @param  string $context View or edit context.
1172
-	 * @return string
1173
-	 */
1174
-	public function get_user_vat_number( $context = 'view' ) {
1175
-		return $this->get_vat_number( $context );
1267
+     * Get other recipients for invoice communications.
1268
+     *
1269
+     * @since 1.0.19
1270
+     * @param  string $context View or edit context.
1271
+     * @return bool
1272
+     */
1273
+    public function get_email_cc( $context = 'view' ) {
1274
+        return $this->get_prop( 'email_cc', $context );
1176 1275
     }
1177 1276
 
1178 1277
     /**
1179
-	 * Alias of self::get_vat_number().
1180
-	 *
1181
-	 * @since 1.0.19
1182
-	 * @param  string $context View or edit context.
1183
-	 * @return string
1184
-	 */
1185
-	public function get_customer_vat_number( $context = 'view' ) {
1186
-		return $this->get_vat_number( $context );
1278
+     * Get invoice template.
1279
+     *
1280
+     * @since 1.0.19
1281
+     * @param  string $context View or edit context.
1282
+     * @return bool
1283
+     */
1284
+    public function get_template( $context = 'view' ) {
1285
+        return $this->get_prop( 'template', $context );
1187 1286
     }
1188 1287
 
1189 1288
     /**
1190
-	 * Get the customer's vat rate.
1191
-	 *
1192
-	 * @since 1.0.19
1193
-	 * @param  string $context View or edit context.
1194
-	 * @return string
1195
-	 */
1196
-	public function get_vat_rate( $context = 'view' ) {
1197
-		return $this->get_prop( 'vat_rate', $context );
1289
+     * Get whether the customer has confirmed their address.
1290
+     *
1291
+     * @since 1.0.19
1292
+     * @param  string $context View or edit context.
1293
+     * @return bool
1294
+     */
1295
+    public function get_address_confirmed( $context = 'view' ) {
1296
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1198 1297
     }
1199 1298
 
1200 1299
     /**
1201
-	 * Alias of self::get_vat_rate().
1202
-	 *
1203
-	 * @since 1.0.19
1204
-	 * @param  string $context View or edit context.
1205
-	 * @return string
1206
-	 */
1207
-	public function get_user_vat_rate( $context = 'view' ) {
1208
-		return $this->get_vat_rate( $context );
1300
+     * Alias of self::get_address_confirmed().
1301
+     *
1302
+     * @since 1.0.19
1303
+     * @param  string $context View or edit context.
1304
+     * @return bool
1305
+     */
1306
+    public function get_user_address_confirmed( $context = 'view' ) {
1307
+        return $this->get_address_confirmed( $context );
1209 1308
     }
1210 1309
 
1211 1310
     /**
1212
-	 * Alias of self::get_vat_rate().
1213
-	 *
1214
-	 * @since 1.0.19
1215
-	 * @param  string $context View or edit context.
1216
-	 * @return string
1217
-	 */
1218
-	public function get_customer_vat_rate( $context = 'view' ) {
1219
-		return $this->get_vat_rate( $context );
1311
+     * Alias of self::get_address().
1312
+     *
1313
+     * @since 1.0.19
1314
+     * @param  string $context View or edit context.
1315
+     * @return bool
1316
+     */
1317
+    public function get_customer_address_confirmed( $context = 'view' ) {
1318
+        return $this->get_address_confirmed( $context );
1220 1319
     }
1221 1320
 
1222 1321
     /**
1223
-	 * Get the customer's address.
1224
-	 *
1225
-	 * @since 1.0.19
1226
-	 * @param  string $context View or edit context.
1227
-	 * @return string
1228
-	 */
1229
-	public function get_address( $context = 'view' ) {
1230
-		return $this->get_prop( 'address', $context );
1231
-    }
1232
-
1233
-    /**
1234
-	 * Alias of self::get_address().
1235
-	 *
1236
-	 * @since 1.0.19
1237
-	 * @param  string $context View or edit context.
1238
-	 * @return string
1239
-	 */
1240
-	public function get_user_address( $context = 'view' ) {
1241
-		return $this->get_address( $context );
1242
-    }
1243
-
1244
-    /**
1245
-	 * Alias of self::get_address().
1246
-	 *
1247
-	 * @since 1.0.19
1248
-	 * @param  string $context View or edit context.
1249
-	 * @return string
1250
-	 */
1251
-	public function get_customer_address( $context = 'view' ) {
1252
-		return $this->get_address( $context );
1253
-    }
1254
-
1255
-    /**
1256
-	 * Get whether the customer has viewed the invoice or not.
1257
-	 *
1258
-	 * @since 1.0.19
1259
-	 * @param  string $context View or edit context.
1260
-	 * @return bool
1261
-	 */
1262
-	public function get_is_viewed( $context = 'view' ) {
1263
-		return (bool) $this->get_prop( 'is_viewed', $context );
1264
-	}
1265
-
1266
-	/**
1267
-	 * Get other recipients for invoice communications.
1268
-	 *
1269
-	 * @since 1.0.19
1270
-	 * @param  string $context View or edit context.
1271
-	 * @return bool
1272
-	 */
1273
-	public function get_email_cc( $context = 'view' ) {
1274
-		return $this->get_prop( 'email_cc', $context );
1275
-	}
1276
-
1277
-	/**
1278
-	 * Get invoice template.
1279
-	 *
1280
-	 * @since 1.0.19
1281
-	 * @param  string $context View or edit context.
1282
-	 * @return bool
1283
-	 */
1284
-	public function get_template( $context = 'view' ) {
1285
-		return $this->get_prop( 'template', $context );
1286
-	}
1287
-
1288
-	/**
1289
-	 * Get whether the customer has confirmed their address.
1290
-	 *
1291
-	 * @since 1.0.19
1292
-	 * @param  string $context View or edit context.
1293
-	 * @return bool
1294
-	 */
1295
-	public function get_address_confirmed( $context = 'view' ) {
1296
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1297
-    }
1298
-
1299
-    /**
1300
-	 * Alias of self::get_address_confirmed().
1301
-	 *
1302
-	 * @since 1.0.19
1303
-	 * @param  string $context View or edit context.
1304
-	 * @return bool
1305
-	 */
1306
-	public function get_user_address_confirmed( $context = 'view' ) {
1307
-		return $this->get_address_confirmed( $context );
1308
-    }
1309
-
1310
-    /**
1311
-	 * Alias of self::get_address().
1312
-	 *
1313
-	 * @since 1.0.19
1314
-	 * @param  string $context View or edit context.
1315
-	 * @return bool
1316
-	 */
1317
-	public function get_customer_address_confirmed( $context = 'view' ) {
1318
-		return $this->get_address_confirmed( $context );
1319
-    }
1320
-
1321
-    /**
1322
-	 * Get the invoice subtotal.
1323
-	 *
1324
-	 * @since 1.0.19
1325
-	 * @param  string $context View or edit context.
1326
-	 * @return float
1327
-	 */
1328
-	public function get_subtotal( $context = 'view' ) {
1322
+     * Get the invoice subtotal.
1323
+     *
1324
+     * @since 1.0.19
1325
+     * @param  string $context View or edit context.
1326
+     * @return float
1327
+     */
1328
+    public function get_subtotal( $context = 'view' ) {
1329 1329
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1330 1330
 
1331 1331
         // Backwards compatibility.
@@ -1337,165 +1337,165 @@  discard block
 block discarded – undo
1337 1337
     }
1338 1338
 
1339 1339
     /**
1340
-	 * Get the invoice discount total.
1341
-	 *
1342
-	 * @since 1.0.19
1343
-	 * @param  string $context View or edit context.
1344
-	 * @return float
1345
-	 */
1346
-	public function get_total_discount( $context = 'view' ) {
1347
-		return (float) $this->get_prop( 'total_discount', $context );
1340
+     * Get the invoice discount total.
1341
+     *
1342
+     * @since 1.0.19
1343
+     * @param  string $context View or edit context.
1344
+     * @return float
1345
+     */
1346
+    public function get_total_discount( $context = 'view' ) {
1347
+        return (float) $this->get_prop( 'total_discount', $context );
1348 1348
     }
1349 1349
 
1350 1350
     /**
1351
-	 * Get the invoice tax total.
1352
-	 *
1353
-	 * @since 1.0.19
1354
-	 * @param  string $context View or edit context.
1355
-	 * @return float
1356
-	 */
1357
-	public function get_total_tax( $context = 'view' ) {
1358
-		return (float) $this->get_prop( 'total_tax', $context );
1359
-	}
1351
+     * Get the invoice tax total.
1352
+     *
1353
+     * @since 1.0.19
1354
+     * @param  string $context View or edit context.
1355
+     * @return float
1356
+     */
1357
+    public function get_total_tax( $context = 'view' ) {
1358
+        return (float) $this->get_prop( 'total_tax', $context );
1359
+    }
1360 1360
 
1361
-	/**
1362
-	 * @deprecated
1363
-	 */
1364
-	public function get_final_tax( $currency = false ) {
1365
-		$tax = $this->get_total_tax();
1361
+    /**
1362
+     * @deprecated
1363
+     */
1364
+    public function get_final_tax( $currency = false ) {
1365
+        $tax = $this->get_total_tax();
1366 1366
 
1367 1367
         if ( $currency ) {
1368
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1368
+            return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1369 1369
         }
1370 1370
 
1371 1371
         return $tax;
1372 1372
     }
1373 1373
 
1374 1374
     /**
1375
-	 * Get the invoice fees total.
1376
-	 *
1377
-	 * @since 1.0.19
1378
-	 * @param  string $context View or edit context.
1379
-	 * @return float
1380
-	 */
1381
-	public function get_total_fees( $context = 'view' ) {
1382
-		return (float) $this->get_prop( 'total_fees', $context );
1375
+     * Get the invoice fees total.
1376
+     *
1377
+     * @since 1.0.19
1378
+     * @param  string $context View or edit context.
1379
+     * @return float
1380
+     */
1381
+    public function get_total_fees( $context = 'view' ) {
1382
+        return (float) $this->get_prop( 'total_fees', $context );
1383 1383
     }
1384 1384
 
1385 1385
     /**
1386
-	 * Alias for self::get_total_fees().
1387
-	 *
1388
-	 * @since 1.0.19
1389
-	 * @param  string $context View or edit context.
1390
-	 * @return float
1391
-	 */
1392
-	public function get_fees_total( $context = 'view' ) {
1393
-		return $this->get_total_fees( $context );
1386
+     * Alias for self::get_total_fees().
1387
+     *
1388
+     * @since 1.0.19
1389
+     * @param  string $context View or edit context.
1390
+     * @return float
1391
+     */
1392
+    public function get_fees_total( $context = 'view' ) {
1393
+        return $this->get_total_fees( $context );
1394 1394
     }
1395 1395
 
1396 1396
     /**
1397
-	 * Get the invoice total.
1398
-	 *
1399
-	 * @since 1.0.19
1397
+     * Get the invoice total.
1398
+     *
1399
+     * @since 1.0.19
1400 1400
      * @return float
1401
-	 */
1402
-	public function get_total() {
1403
-		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1404
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1405
-	}
1401
+     */
1402
+    public function get_total() {
1403
+        $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1404
+        return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1405
+    }
1406 1406
 	
1407
-	/**
1408
-	 * Get the invoice totals.
1409
-	 *
1410
-	 * @since 1.0.19
1407
+    /**
1408
+     * Get the invoice totals.
1409
+     *
1410
+     * @since 1.0.19
1411 1411
      * @return float
1412
-	 */
1413
-	public function get_totals() {
1414
-		return $this->totals;
1412
+     */
1413
+    public function get_totals() {
1414
+        return $this->totals;
1415 1415
     }
1416 1416
 
1417 1417
     /**
1418
-	 * Get the initial invoice total.
1419
-	 *
1420
-	 * @since 1.0.19
1418
+     * Get the initial invoice total.
1419
+     *
1420
+     * @since 1.0.19
1421 1421
      * @param  string $context View or edit context.
1422 1422
      * @return float
1423
-	 */
1423
+     */
1424 1424
     public function get_initial_total() {
1425 1425
 
1426
-		if ( empty( $this->totals ) ) {
1427
-			$this->recalculate_total();
1428
-		}
1426
+        if ( empty( $this->totals ) ) {
1427
+            $this->recalculate_total();
1428
+        }
1429 1429
 
1430
-		$tax      = $this->totals['tax']['initial'];
1431
-		$fee      = $this->totals['fee']['initial'];
1432
-		$discount = $this->totals['discount']['initial'];
1433
-		$subtotal = $this->totals['subtotal']['initial'];
1434
-		$total    = $tax + $fee - $discount + $subtotal;
1430
+        $tax      = $this->totals['tax']['initial'];
1431
+        $fee      = $this->totals['fee']['initial'];
1432
+        $discount = $this->totals['discount']['initial'];
1433
+        $subtotal = $this->totals['subtotal']['initial'];
1434
+        $total    = $tax + $fee - $discount + $subtotal;
1435 1435
 
1436
-		if ( 0 > $total ) {
1437
-			$total = 0;
1438
-		}
1436
+        if ( 0 > $total ) {
1437
+            $total = 0;
1438
+        }
1439 1439
 
1440 1440
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1441
-	}
1441
+    }
1442 1442
 
1443
-	/**
1444
-	 * Get the recurring invoice total.
1445
-	 *
1446
-	 * @since 1.0.19
1443
+    /**
1444
+     * Get the recurring invoice total.
1445
+     *
1446
+     * @since 1.0.19
1447 1447
      * @param  string $context View or edit context.
1448 1448
      * @return float
1449
-	 */
1449
+     */
1450 1450
     public function get_recurring_total() {
1451 1451
 
1452
-		if ( empty( $this->totals ) ) {
1453
-			$this->recalculate_total();
1454
-		}
1452
+        if ( empty( $this->totals ) ) {
1453
+            $this->recalculate_total();
1454
+        }
1455 1455
 
1456
-		$tax      = $this->totals['tax']['recurring'];
1457
-		$fee      = $this->totals['fee']['recurring'];
1458
-		$discount = $this->totals['discount']['recurring'];
1459
-		$subtotal = $this->totals['subtotal']['recurring'];
1460
-		$total    = $tax + $fee - $discount + $subtotal;
1456
+        $tax      = $this->totals['tax']['recurring'];
1457
+        $fee      = $this->totals['fee']['recurring'];
1458
+        $discount = $this->totals['discount']['recurring'];
1459
+        $subtotal = $this->totals['subtotal']['recurring'];
1460
+        $total    = $tax + $fee - $discount + $subtotal;
1461 1461
 
1462
-		if ( 0 > $total ) {
1463
-			$total = 0;
1464
-		}
1462
+        if ( 0 > $total ) {
1463
+            $total = 0;
1464
+        }
1465 1465
 
1466 1466
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1467
-	}
1467
+    }
1468 1468
 
1469
-	/**
1470
-	 * Returns recurring payment details.
1471
-	 *
1472
-	 * @since 1.0.19
1469
+    /**
1470
+     * Returns recurring payment details.
1471
+     *
1472
+     * @since 1.0.19
1473 1473
      * @param  string $field Optionally provide a field to return.
1474
-	 * @param string $currency Whether to include the currency.
1474
+     * @param string $currency Whether to include the currency.
1475 1475
      * @return float
1476
-	 */
1476
+     */
1477 1477
     public function get_recurring_details( $field = '', $currency = false ) {
1478 1478
 
1479
-		// Maybe recalculate totals.
1480
-		if ( empty( $this->totals ) ) {
1481
-			$this->recalculate_total();
1482
-		}
1479
+        // Maybe recalculate totals.
1480
+        if ( empty( $this->totals ) ) {
1481
+            $this->recalculate_total();
1482
+        }
1483 1483
 
1484
-		// Prepare recurring totals.
1484
+        // Prepare recurring totals.
1485 1485
         $data = apply_filters(
1486
-			'wpinv_get_invoice_recurring_details',
1487
-			array(
1488
-				'cart_details' => $this->get_cart_details(),
1489
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1490
-				'discount'     => $this->totals['discount']['recurring'],
1491
-				'tax'          => $this->totals['tax']['recurring'],
1492
-				'fee'          => $this->totals['fee']['recurring'],
1493
-				'total'        => $this->get_recurring_total(),
1494
-			),
1495
-			$this,
1496
-			$field,
1497
-			$currency
1498
-		);
1486
+            'wpinv_get_invoice_recurring_details',
1487
+            array(
1488
+                'cart_details' => $this->get_cart_details(),
1489
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1490
+                'discount'     => $this->totals['discount']['recurring'],
1491
+                'tax'          => $this->totals['tax']['recurring'],
1492
+                'fee'          => $this->totals['fee']['recurring'],
1493
+                'total'        => $this->get_recurring_total(),
1494
+            ),
1495
+            $this,
1496
+            $field,
1497
+            $currency
1498
+        );
1499 1499
 
1500 1500
         if ( isset( $data[$field] ) ) {
1501 1501
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1505,156 +1505,156 @@  discard block
 block discarded – undo
1505 1505
     }
1506 1506
 
1507 1507
     /**
1508
-	 * Get the invoice fees.
1509
-	 *
1510
-	 * @since 1.0.19
1511
-	 * @param  string $context View or edit context.
1512
-	 * @return array
1513
-	 */
1514
-	public function get_fees( $context = 'view' ) {
1515
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1508
+     * Get the invoice fees.
1509
+     *
1510
+     * @since 1.0.19
1511
+     * @param  string $context View or edit context.
1512
+     * @return array
1513
+     */
1514
+    public function get_fees( $context = 'view' ) {
1515
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1516 1516
     }
1517 1517
 
1518 1518
     /**
1519
-	 * Get the invoice discounts.
1520
-	 *
1521
-	 * @since 1.0.19
1522
-	 * @param  string $context View or edit context.
1523
-	 * @return array
1524
-	 */
1525
-	public function get_discounts( $context = 'view' ) {
1526
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1519
+     * Get the invoice discounts.
1520
+     *
1521
+     * @since 1.0.19
1522
+     * @param  string $context View or edit context.
1523
+     * @return array
1524
+     */
1525
+    public function get_discounts( $context = 'view' ) {
1526
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1527 1527
     }
1528 1528
 
1529 1529
     /**
1530
-	 * Get the invoice taxes.
1531
-	 *
1532
-	 * @since 1.0.19
1533
-	 * @param  string $context View or edit context.
1534
-	 * @return array
1535
-	 */
1536
-	public function get_taxes( $context = 'view' ) {
1537
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1530
+     * Get the invoice taxes.
1531
+     *
1532
+     * @since 1.0.19
1533
+     * @param  string $context View or edit context.
1534
+     * @return array
1535
+     */
1536
+    public function get_taxes( $context = 'view' ) {
1537
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1538 1538
     }
1539 1539
 
1540 1540
     /**
1541
-	 * Get the invoice items.
1542
-	 *
1543
-	 * @since 1.0.19
1544
-	 * @param  string $context View or edit context.
1545
-	 * @return GetPaid_Form_Item[]
1546
-	 */
1547
-	public function get_items( $context = 'view' ) {
1541
+     * Get the invoice items.
1542
+     *
1543
+     * @since 1.0.19
1544
+     * @param  string $context View or edit context.
1545
+     * @return GetPaid_Form_Item[]
1546
+     */
1547
+    public function get_items( $context = 'view' ) {
1548 1548
         return $this->get_prop( 'items', $context );
1549 1549
     }
1550 1550
 
1551 1551
     /**
1552
-	 * Get the invoice's payment form.
1553
-	 *
1554
-	 * @since 1.0.19
1555
-	 * @param  string $context View or edit context.
1556
-	 * @return int
1557
-	 */
1558
-	public function get_payment_form( $context = 'view' ) {
1559
-		return intval( $this->get_prop( 'payment_form', $context ) );
1552
+     * Get the invoice's payment form.
1553
+     *
1554
+     * @since 1.0.19
1555
+     * @param  string $context View or edit context.
1556
+     * @return int
1557
+     */
1558
+    public function get_payment_form( $context = 'view' ) {
1559
+        return intval( $this->get_prop( 'payment_form', $context ) );
1560 1560
     }
1561 1561
 
1562 1562
     /**
1563
-	 * Get the invoice's submission id.
1564
-	 *
1565
-	 * @since 1.0.19
1566
-	 * @param  string $context View or edit context.
1567
-	 * @return string
1568
-	 */
1569
-	public function get_submission_id( $context = 'view' ) {
1570
-		return $this->get_prop( 'submission_id', $context );
1563
+     * Get the invoice's submission id.
1564
+     *
1565
+     * @since 1.0.19
1566
+     * @param  string $context View or edit context.
1567
+     * @return string
1568
+     */
1569
+    public function get_submission_id( $context = 'view' ) {
1570
+        return $this->get_prop( 'submission_id', $context );
1571 1571
     }
1572 1572
 
1573 1573
     /**
1574
-	 * Get the invoice's discount code.
1575
-	 *
1576
-	 * @since 1.0.19
1577
-	 * @param  string $context View or edit context.
1578
-	 * @return string
1579
-	 */
1580
-	public function get_discount_code( $context = 'view' ) {
1581
-		return $this->get_prop( 'discount_code', $context );
1574
+     * Get the invoice's discount code.
1575
+     *
1576
+     * @since 1.0.19
1577
+     * @param  string $context View or edit context.
1578
+     * @return string
1579
+     */
1580
+    public function get_discount_code( $context = 'view' ) {
1581
+        return $this->get_prop( 'discount_code', $context );
1582 1582
     }
1583 1583
 
1584 1584
     /**
1585
-	 * Get the invoice's gateway.
1586
-	 *
1587
-	 * @since 1.0.19
1588
-	 * @param  string $context View or edit context.
1589
-	 * @return string
1590
-	 */
1591
-	public function get_gateway( $context = 'view' ) {
1592
-		return $this->get_prop( 'gateway', $context );
1585
+     * Get the invoice's gateway.
1586
+     *
1587
+     * @since 1.0.19
1588
+     * @param  string $context View or edit context.
1589
+     * @return string
1590
+     */
1591
+    public function get_gateway( $context = 'view' ) {
1592
+        return $this->get_prop( 'gateway', $context );
1593 1593
     }
1594 1594
 
1595 1595
     /**
1596
-	 * Get the invoice's gateway display title.
1597
-	 *
1598
-	 * @since 1.0.19
1599
-	 * @return string
1600
-	 */
1596
+     * Get the invoice's gateway display title.
1597
+     *
1598
+     * @since 1.0.19
1599
+     * @return string
1600
+     */
1601 1601
     public function get_gateway_title() {
1602 1602
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1603 1603
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1604 1604
     }
1605 1605
 
1606 1606
     /**
1607
-	 * Get the invoice's transaction id.
1608
-	 *
1609
-	 * @since 1.0.19
1610
-	 * @param  string $context View or edit context.
1611
-	 * @return string
1612
-	 */
1613
-	public function get_transaction_id( $context = 'view' ) {
1614
-		return $this->get_prop( 'transaction_id', $context );
1607
+     * Get the invoice's transaction id.
1608
+     *
1609
+     * @since 1.0.19
1610
+     * @param  string $context View or edit context.
1611
+     * @return string
1612
+     */
1613
+    public function get_transaction_id( $context = 'view' ) {
1614
+        return $this->get_prop( 'transaction_id', $context );
1615 1615
     }
1616 1616
 
1617 1617
     /**
1618
-	 * Get the invoice's currency.
1619
-	 *
1620
-	 * @since 1.0.19
1621
-	 * @param  string $context View or edit context.
1622
-	 * @return string
1623
-	 */
1624
-	public function get_currency( $context = 'view' ) {
1618
+     * Get the invoice's currency.
1619
+     *
1620
+     * @since 1.0.19
1621
+     * @param  string $context View or edit context.
1622
+     * @return string
1623
+     */
1624
+    public function get_currency( $context = 'view' ) {
1625 1625
         $currency = $this->get_prop( 'currency', $context );
1626 1626
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1627 1627
     }
1628 1628
 
1629 1629
     /**
1630
-	 * Checks if we are charging taxes for this invoice.
1631
-	 *
1632
-	 * @since 1.0.19
1633
-	 * @param  string $context View or edit context.
1634
-	 * @return bool
1635
-	 */
1636
-	public function get_disable_taxes( $context = 'view' ) {
1630
+     * Checks if we are charging taxes for this invoice.
1631
+     *
1632
+     * @since 1.0.19
1633
+     * @param  string $context View or edit context.
1634
+     * @return bool
1635
+     */
1636
+    public function get_disable_taxes( $context = 'view' ) {
1637 1637
         return (bool) $this->get_prop( 'disable_taxes', $context );
1638 1638
     }
1639 1639
 
1640 1640
     /**
1641
-	 * Retrieves the subscription id for an invoice.
1642
-	 *
1643
-	 * @since 1.0.19
1644
-	 * @param  string $context View or edit context.
1645
-	 * @return int
1646
-	 */
1641
+     * Retrieves the subscription id for an invoice.
1642
+     *
1643
+     * @since 1.0.19
1644
+     * @param  string $context View or edit context.
1645
+     * @return int
1646
+     */
1647 1647
     public function get_subscription_id( $context = 'view' ) {
1648
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1649
-	}
1650
-
1651
-	/**
1652
-	 * Retrieves the remote subscription id for an invoice.
1653
-	 *
1654
-	 * @since 1.0.19
1655
-	 * @param  string $context View or edit context.
1656
-	 * @return int
1657
-	 */
1648
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1649
+    }
1650
+
1651
+    /**
1652
+     * Retrieves the remote subscription id for an invoice.
1653
+     *
1654
+     * @since 1.0.19
1655
+     * @param  string $context View or edit context.
1656
+     * @return int
1657
+     */
1658 1658
     public function get_remote_subscription_id( $context = 'view' ) {
1659 1659
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1660 1660
 
@@ -1667,12 +1667,12 @@  discard block
 block discarded – undo
1667 1667
     }
1668 1668
 
1669 1669
     /**
1670
-	 * Retrieves the payment meta for an invoice.
1671
-	 *
1672
-	 * @since 1.0.19
1673
-	 * @param  string $context View or edit context.
1674
-	 * @return array
1675
-	 */
1670
+     * Retrieves the payment meta for an invoice.
1671
+     *
1672
+     * @since 1.0.19
1673
+     * @param  string $context View or edit context.
1674
+     * @return array
1675
+     */
1676 1676
     public function get_payment_meta( $context = 'view' ) {
1677 1677
 
1678 1678
         return array(
@@ -1692,31 +1692,31 @@  discard block
 block discarded – undo
1692 1692
     }
1693 1693
 
1694 1694
     /**
1695
-	 * Retrieves the cart details for an invoice.
1696
-	 *
1697
-	 * @since 1.0.19
1698
-	 * @return array
1699
-	 */
1695
+     * Retrieves the cart details for an invoice.
1696
+     *
1697
+     * @since 1.0.19
1698
+     * @return array
1699
+     */
1700 1700
     public function get_cart_details() {
1701 1701
         $items        = $this->get_items();
1702 1702
         $cart_details = array();
1703 1703
 
1704 1704
         foreach ( $items as $item_id => $item ) {
1705
-			$item->invoice_id = $this->get_id();
1705
+            $item->invoice_id = $this->get_id();
1706 1706
             $cart_details[]   = $item->prepare_data_for_saving();
1707 1707
         }
1708 1708
 
1709 1709
         return $cart_details;
1710
-	}
1710
+    }
1711 1711
 
1712
-	/**
1713
-	 * Retrieves the recurring item.
1714
-	 *
1715
-	 * @return null|GetPaid_Form_Item|int
1716
-	 */
1717
-	public function get_recurring( $object = false ) {
1712
+    /**
1713
+     * Retrieves the recurring item.
1714
+     *
1715
+     * @return null|GetPaid_Form_Item|int
1716
+     */
1717
+    public function get_recurring( $object = false ) {
1718 1718
 
1719
-		// Are we returning an object?
1719
+        // Are we returning an object?
1720 1720
         if ( $object ) {
1721 1721
             return $this->get_item( $this->recurring_item );
1722 1722
         }
@@ -1724,100 +1724,100 @@  discard block
 block discarded – undo
1724 1724
         return $this->recurring_item;
1725 1725
     }
1726 1726
 
1727
-	/**
1728
-	 * Retrieves the subscription name.
1729
-	 *
1730
-	 * @since 1.0.19
1731
-	 * @return string
1732
-	 */
1733
-	public function get_subscription_name() {
1727
+    /**
1728
+     * Retrieves the subscription name.
1729
+     *
1730
+     * @since 1.0.19
1731
+     * @return string
1732
+     */
1733
+    public function get_subscription_name() {
1734 1734
 
1735
-		// Retrieve the recurring name
1735
+        // Retrieve the recurring name
1736 1736
         $item = $this->get_recurring( true );
1737 1737
 
1738
-		// Abort if it does not exist.
1738
+        // Abort if it does not exist.
1739 1739
         if ( empty( $item ) ) {
1740 1740
             return '';
1741 1741
         }
1742 1742
 
1743
-		// Return the item name.
1743
+        // Return the item name.
1744 1744
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1745
-	}
1746
-
1747
-	/**
1748
-	 * Retrieves the view url.
1749
-	 *
1750
-	 * @since 1.0.19
1751
-	 * @return string
1752
-	 */
1753
-	public function get_view_url() {
1745
+    }
1746
+
1747
+    /**
1748
+     * Retrieves the view url.
1749
+     *
1750
+     * @since 1.0.19
1751
+     * @return string
1752
+     */
1753
+    public function get_view_url() {
1754 1754
         $invoice_url = get_permalink( $this->get_id() );
1755
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1755
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1756 1756
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1757
-	}
1757
+    }
1758 1758
 
1759
-	/**
1760
-	 * Retrieves the payment url.
1761
-	 *
1762
-	 * @since 1.0.19
1763
-	 * @return string
1764
-	 */
1765
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1759
+    /**
1760
+     * Retrieves the payment url.
1761
+     *
1762
+     * @since 1.0.19
1763
+     * @return string
1764
+     */
1765
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1766 1766
 
1767
-		// Retrieve the checkout url.
1767
+        // Retrieve the checkout url.
1768 1768
         $pay_url = wpinv_get_checkout_uri();
1769 1769
 
1770
-		// Maybe force ssl.
1770
+        // Maybe force ssl.
1771 1771
         if ( is_ssl() ) {
1772 1772
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1773 1773
         }
1774 1774
 
1775
-		// Add the invoice key.
1776
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1775
+        // Add the invoice key.
1776
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1777 1777
 
1778
-		// (Maybe?) add a secret
1778
+        // (Maybe?) add a secret
1779 1779
         if ( $secret ) {
1780 1780
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1781 1781
         }
1782 1782
 
1783 1783
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1784
-	}
1784
+    }
1785 1785
 	
1786
-	/**
1787
-	 * Retrieves the receipt url.
1788
-	 *
1789
-	 * @since 1.0.19
1790
-	 * @return string
1791
-	 */
1792
-	public function get_receipt_url() {
1793
-
1794
-		// Retrieve the checkout url.
1786
+    /**
1787
+     * Retrieves the receipt url.
1788
+     *
1789
+     * @since 1.0.19
1790
+     * @return string
1791
+     */
1792
+    public function get_receipt_url() {
1793
+
1794
+        // Retrieve the checkout url.
1795 1795
         $receipt_url = wpinv_get_success_page_uri();
1796 1796
 
1797
-		// Maybe force ssl.
1797
+        // Maybe force ssl.
1798 1798
         if ( is_ssl() ) {
1799 1799
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1800 1800
         }
1801 1801
 
1802
-		// Add the invoice key.
1803
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1802
+        // Add the invoice key.
1803
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1804 1804
 
1805 1805
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1806 1806
     }
1807 1807
 
1808 1808
     /**
1809
-	 * Magic method for accessing invoice properties.
1810
-	 *
1811
-	 * @since 1.0.15
1812
-	 * @access public
1813
-	 *
1814
-	 * @param string $key Discount data to retrieve
1815
-	 * @param  string $context View or edit context.
1816
-	 * @return mixed Value of the given invoice property (if set).
1817
-	 */
1818
-	public function get( $key, $context = 'view' ) {
1809
+     * Magic method for accessing invoice properties.
1810
+     *
1811
+     * @since 1.0.15
1812
+     * @access public
1813
+     *
1814
+     * @param string $key Discount data to retrieve
1815
+     * @param  string $context View or edit context.
1816
+     * @return mixed Value of the given invoice property (if set).
1817
+     */
1818
+    public function get( $key, $context = 'view' ) {
1819 1819
         return $this->get_prop( $key, $context );
1820
-	}
1820
+    }
1821 1821
 
1822 1822
     /*
1823 1823
 	|--------------------------------------------------------------------------
@@ -1830,130 +1830,130 @@  discard block
 block discarded – undo
1830 1830
     */
1831 1831
 
1832 1832
     /**
1833
-	 * Magic method for setting invoice properties.
1834
-	 *
1835
-	 * @since 1.0.19
1836
-	 * @access public
1837
-	 *
1838
-	 * @param string $key Discount data to retrieve
1839
-	 * @param  mixed $value new value.
1840
-	 * @return mixed Value of the given invoice property (if set).
1841
-	 */
1842
-	public function set( $key, $value ) {
1833
+     * Magic method for setting invoice properties.
1834
+     *
1835
+     * @since 1.0.19
1836
+     * @access public
1837
+     *
1838
+     * @param string $key Discount data to retrieve
1839
+     * @param  mixed $value new value.
1840
+     * @return mixed Value of the given invoice property (if set).
1841
+     */
1842
+    public function set( $key, $value ) {
1843 1843
 
1844 1844
         $setter = "set_$key";
1845 1845
         if ( is_callable( array( $this, $setter ) ) ) {
1846 1846
             $this->{$setter}( $value );
1847 1847
         }
1848 1848
 
1849
-	}
1849
+    }
1850 1850
 
1851
-	/**
1852
-	 * Sets item status.
1853
-	 *
1854
-	 * @since 1.0.19
1855
-	 * @param string $new_status    New status.
1856
-	 * @param string $note          Optional note to add.
1857
-	 * @param bool   $manual_update Is this a manual status change?.
1858
-	 * @return array details of change.
1859
-	 */
1860
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1861
-		$old_status = $this->get_status();
1851
+    /**
1852
+     * Sets item status.
1853
+     *
1854
+     * @since 1.0.19
1855
+     * @param string $new_status    New status.
1856
+     * @param string $note          Optional note to add.
1857
+     * @param bool   $manual_update Is this a manual status change?.
1858
+     * @return array details of change.
1859
+     */
1860
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1861
+        $old_status = $this->get_status();
1862 1862
 
1863
-		$statuses = $this->get_all_statuses();
1863
+        $statuses = $this->get_all_statuses();
1864 1864
 
1865
-		if ( isset( $statuses[ 'draft' ] ) ) {
1866
-			unset( $statuses[ 'draft' ] );
1867
-		}
1865
+        if ( isset( $statuses[ 'draft' ] ) ) {
1866
+            unset( $statuses[ 'draft' ] );
1867
+        }
1868 1868
 
1869
-		$this->set_prop( 'status', $new_status );
1869
+        $this->set_prop( 'status', $new_status );
1870 1870
 
1871
-		// If setting the status, ensure it's set to a valid status.
1872
-		if ( true === $this->object_read ) {
1871
+        // If setting the status, ensure it's set to a valid status.
1872
+        if ( true === $this->object_read ) {
1873 1873
 
1874
-			// Only allow valid new status.
1875
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1876
-				$new_status = 'wpi-pending';
1877
-			}
1874
+            // Only allow valid new status.
1875
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1876
+                $new_status = 'wpi-pending';
1877
+            }
1878 1878
 
1879
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1880
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1881
-				$old_status = 'wpi-pending';
1882
-			}
1879
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1880
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1881
+                $old_status = 'wpi-pending';
1882
+            }
1883 1883
 
1884
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1885
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1886
-				$old_status = 'wpi-pending';
1887
-			}
1884
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1885
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1886
+                $old_status = 'wpi-pending';
1887
+            }
1888 1888
 
1889
-		}
1889
+        }
1890 1890
 
1891
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1892
-			$this->status_transition = array(
1893
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1894
-				'to'     => $new_status,
1895
-				'note'   => $note,
1896
-				'manual' => (bool) $manual_update,
1897
-			);
1891
+        if ( true === $this->object_read && $old_status !== $new_status ) {
1892
+            $this->status_transition = array(
1893
+                'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1894
+                'to'     => $new_status,
1895
+                'note'   => $note,
1896
+                'manual' => (bool) $manual_update,
1897
+            );
1898 1898
 
1899
-			if ( $manual_update ) {
1900
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1901
-			}
1899
+            if ( $manual_update ) {
1900
+                do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1901
+            }
1902 1902
 
1903
-			$this->maybe_set_date_paid();
1903
+            $this->maybe_set_date_paid();
1904 1904
 
1905
-		}
1905
+        }
1906 1906
 
1907
-		return array(
1908
-			'from' => $old_status,
1909
-			'to'   => $new_status,
1910
-		);
1911
-	}
1907
+        return array(
1908
+            'from' => $old_status,
1909
+            'to'   => $new_status,
1910
+        );
1911
+    }
1912 1912
 
1913
-	/**
1914
-	 * Maybe set date paid.
1915
-	 *
1916
-	 * Sets the date paid variable when transitioning to the payment complete
1917
-	 * order status.
1918
-	 *
1919
-	 * @since 1.0.19
1920
-	 */
1921
-	public function maybe_set_date_paid() {
1913
+    /**
1914
+     * Maybe set date paid.
1915
+     *
1916
+     * Sets the date paid variable when transitioning to the payment complete
1917
+     * order status.
1918
+     *
1919
+     * @since 1.0.19
1920
+     */
1921
+    public function maybe_set_date_paid() {
1922 1922
 
1923
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1924
-			$this->set_date_completed( current_time( 'mysql' ) );
1925
-		}
1926
-	}
1923
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1924
+            $this->set_date_completed( current_time( 'mysql' ) );
1925
+        }
1926
+    }
1927 1927
 
1928 1928
     /**
1929
-	 * Set parent invoice ID.
1930
-	 *
1931
-	 * @since 1.0.19
1932
-	 */
1933
-	public function set_parent_id( $value ) {
1934
-		if ( $value && ( $value === $this->get_id() ) ) {
1935
-			return;
1936
-		}
1937
-		$this->set_prop( 'parent_id', absint( $value ) );
1929
+     * Set parent invoice ID.
1930
+     *
1931
+     * @since 1.0.19
1932
+     */
1933
+    public function set_parent_id( $value ) {
1934
+        if ( $value && ( $value === $this->get_id() ) ) {
1935
+            return;
1936
+        }
1937
+        $this->set_prop( 'parent_id', absint( $value ) );
1938 1938
     }
1939 1939
 
1940 1940
     /**
1941
-	 * Set plugin version when the invoice was created.
1942
-	 *
1943
-	 * @since 1.0.19
1944
-	 */
1945
-	public function set_version( $value ) {
1946
-		$this->set_prop( 'version', $value );
1941
+     * Set plugin version when the invoice was created.
1942
+     *
1943
+     * @since 1.0.19
1944
+     */
1945
+    public function set_version( $value ) {
1946
+        $this->set_prop( 'version', $value );
1947 1947
     }
1948
-
1949
-    /**
1950
-	 * Set date when the invoice was created.
1951
-	 *
1952
-	 * @since 1.0.19
1953
-	 * @param string $value Value to set.
1948
+
1949
+    /**
1950
+     * Set date when the invoice was created.
1951
+     *
1952
+     * @since 1.0.19
1953
+     * @param string $value Value to set.
1954 1954
      * @return bool Whether or not the date was set.
1955
-	 */
1956
-	public function set_date_created( $value ) {
1955
+     */
1956
+    public function set_date_created( $value ) {
1957 1957
         $date = strtotime( $value );
1958 1958
 
1959 1959
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1966,13 +1966,13 @@  discard block
 block discarded – undo
1966 1966
     }
1967 1967
 
1968 1968
     /**
1969
-	 * Set date invoice due date.
1970
-	 *
1971
-	 * @since 1.0.19
1972
-	 * @param string $value Value to set.
1969
+     * Set date invoice due date.
1970
+     *
1971
+     * @since 1.0.19
1972
+     * @param string $value Value to set.
1973 1973
      * @return bool Whether or not the date was set.
1974
-	 */
1975
-	public function set_due_date( $value ) {
1974
+     */
1975
+    public function set_due_date( $value ) {
1976 1976
         $date = strtotime( $value );
1977 1977
 
1978 1978
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1980,29 +1980,29 @@  discard block
 block discarded – undo
1980 1980
             return true;
1981 1981
         }
1982 1982
 
1983
-		$this->set_prop( 'due_date', '' );
1983
+        $this->set_prop( 'due_date', '' );
1984 1984
         return false;
1985 1985
 
1986 1986
     }
1987 1987
 
1988 1988
     /**
1989
-	 * Alias of self::set_due_date().
1990
-	 *
1991
-	 * @since 1.0.19
1992
-	 * @param  string $value New name.
1993
-	 */
1994
-	public function set_date_due( $value ) {
1995
-		$this->set_due_date( $value );
1989
+     * Alias of self::set_due_date().
1990
+     *
1991
+     * @since 1.0.19
1992
+     * @param  string $value New name.
1993
+     */
1994
+    public function set_date_due( $value ) {
1995
+        $this->set_due_date( $value );
1996 1996
     }
1997 1997
 
1998 1998
     /**
1999
-	 * Set date invoice was completed.
2000
-	 *
2001
-	 * @since 1.0.19
2002
-	 * @param string $value Value to set.
1999
+     * Set date invoice was completed.
2000
+     *
2001
+     * @since 1.0.19
2002
+     * @param string $value Value to set.
2003 2003
      * @return bool Whether or not the date was set.
2004
-	 */
2005
-	public function set_completed_date( $value ) {
2004
+     */
2005
+    public function set_completed_date( $value ) {
2006 2006
         $date = strtotime( $value );
2007 2007
 
2008 2008
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -2010,29 +2010,29 @@  discard block
 block discarded – undo
2010 2010
             return true;
2011 2011
         }
2012 2012
 
2013
-		$this->set_prop( 'completed_date', '' );
2013
+        $this->set_prop( 'completed_date', '' );
2014 2014
         return false;
2015 2015
 
2016 2016
     }
2017 2017
 
2018 2018
     /**
2019
-	 * Alias of self::set_completed_date().
2020
-	 *
2021
-	 * @since 1.0.19
2022
-	 * @param  string $value New name.
2023
-	 */
2024
-	public function set_date_completed( $value ) {
2025
-		$this->set_completed_date( $value );
2019
+     * Alias of self::set_completed_date().
2020
+     *
2021
+     * @since 1.0.19
2022
+     * @param  string $value New name.
2023
+     */
2024
+    public function set_date_completed( $value ) {
2025
+        $this->set_completed_date( $value );
2026 2026
     }
2027 2027
 
2028 2028
     /**
2029
-	 * Set date when the invoice was last modified.
2030
-	 *
2031
-	 * @since 1.0.19
2032
-	 * @param string $value Value to set.
2029
+     * Set date when the invoice was last modified.
2030
+     *
2031
+     * @since 1.0.19
2032
+     * @param string $value Value to set.
2033 2033
      * @return bool Whether or not the date was set.
2034
-	 */
2035
-	public function set_date_modified( $value ) {
2034
+     */
2035
+    public function set_date_modified( $value ) {
2036 2036
         $date = strtotime( $value );
2037 2037
 
2038 2038
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2040,706 +2040,706 @@  discard block
 block discarded – undo
2040 2040
             return true;
2041 2041
         }
2042 2042
 
2043
-		$this->set_prop( 'date_modified', '' );
2043
+        $this->set_prop( 'date_modified', '' );
2044 2044
         return false;
2045 2045
 
2046 2046
     }
2047 2047
 
2048 2048
     /**
2049
-	 * Set the invoice number.
2050
-	 *
2051
-	 * @since 1.0.19
2052
-	 * @param  string $value New number.
2053
-	 */
2054
-	public function set_number( $value ) {
2049
+     * Set the invoice number.
2050
+     *
2051
+     * @since 1.0.19
2052
+     * @param  string $value New number.
2053
+     */
2054
+    public function set_number( $value ) {
2055 2055
         $number = sanitize_text_field( $value );
2056
-		$this->set_prop( 'number', $number );
2056
+        $this->set_prop( 'number', $number );
2057 2057
     }
2058 2058
 
2059 2059
     /**
2060
-	 * Set the invoice type.
2061
-	 *
2062
-	 * @since 1.0.19
2063
-	 * @param  string $value Type.
2064
-	 */
2065
-	public function set_type( $value ) {
2060
+     * Set the invoice type.
2061
+     *
2062
+     * @since 1.0.19
2063
+     * @param  string $value Type.
2064
+     */
2065
+    public function set_type( $value ) {
2066 2066
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2067
-		$this->set_prop( 'type', $type );
2068
-	}
2067
+        $this->set_prop( 'type', $type );
2068
+    }
2069 2069
 
2070 2070
     /**
2071
-	 * Set the invoice post type.
2072
-	 *
2073
-	 * @since 1.0.19
2074
-	 * @param  string $value Post type.
2075
-	 */
2076
-	public function set_post_type( $value ) {
2071
+     * Set the invoice post type.
2072
+     *
2073
+     * @since 1.0.19
2074
+     * @param  string $value Post type.
2075
+     */
2076
+    public function set_post_type( $value ) {
2077 2077
         if ( getpaid_is_invoice_post_type( $value ) ) {
2078
-			$this->set_type( $value );
2078
+            $this->set_type( $value );
2079 2079
             $this->set_prop( 'post_type', $value );
2080 2080
         }
2081 2081
     }
2082 2082
 
2083 2083
     /**
2084
-	 * Set the invoice key.
2085
-	 *
2086
-	 * @since 1.0.19
2087
-	 * @param  string $value New key.
2088
-	 */
2089
-	public function set_key( $value ) {
2084
+     * Set the invoice key.
2085
+     *
2086
+     * @since 1.0.19
2087
+     * @param  string $value New key.
2088
+     */
2089
+    public function set_key( $value ) {
2090 2090
         $key = sanitize_text_field( $value );
2091
-		$this->set_prop( 'key', $key );
2091
+        $this->set_prop( 'key', $key );
2092 2092
     }
2093 2093
 
2094 2094
     /**
2095
-	 * Set the invoice mode.
2096
-	 *
2097
-	 * @since 1.0.19
2098
-	 * @param  string $value mode.
2099
-	 */
2100
-	public function set_mode( $value ) {
2095
+     * Set the invoice mode.
2096
+     *
2097
+     * @since 1.0.19
2098
+     * @param  string $value mode.
2099
+     */
2100
+    public function set_mode( $value ) {
2101 2101
         if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2102 2102
             $this->set_prop( 'value', $value );
2103 2103
         }
2104 2104
     }
2105 2105
 
2106 2106
     /**
2107
-	 * Set the invoice path.
2108
-	 *
2109
-	 * @since 1.0.19
2110
-	 * @param  string $value path.
2111
-	 */
2112
-	public function set_path( $value ) {
2107
+     * Set the invoice path.
2108
+     *
2109
+     * @since 1.0.19
2110
+     * @param  string $value path.
2111
+     */
2112
+    public function set_path( $value ) {
2113 2113
         $this->set_prop( 'path', $value );
2114 2114
     }
2115 2115
 
2116 2116
     /**
2117
-	 * Set the invoice name.
2118
-	 *
2119
-	 * @since 1.0.19
2120
-	 * @param  string $value New name.
2121
-	 */
2122
-	public function set_name( $value ) {
2117
+     * Set the invoice name.
2118
+     *
2119
+     * @since 1.0.19
2120
+     * @param  string $value New name.
2121
+     */
2122
+    public function set_name( $value ) {
2123 2123
         $name = sanitize_text_field( $value );
2124
-		$this->set_prop( 'name', $name );
2124
+        $this->set_prop( 'name', $name );
2125 2125
     }
2126 2126
 
2127 2127
     /**
2128
-	 * Alias of self::set_name().
2129
-	 *
2130
-	 * @since 1.0.19
2131
-	 * @param  string $value New name.
2132
-	 */
2133
-	public function set_title( $value ) {
2134
-		$this->set_name( $value );
2128
+     * Alias of self::set_name().
2129
+     *
2130
+     * @since 1.0.19
2131
+     * @param  string $value New name.
2132
+     */
2133
+    public function set_title( $value ) {
2134
+        $this->set_name( $value );
2135 2135
     }
2136 2136
 
2137 2137
     /**
2138
-	 * Set the invoice description.
2139
-	 *
2140
-	 * @since 1.0.19
2141
-	 * @param  string $value New description.
2142
-	 */
2143
-	public function set_description( $value ) {
2138
+     * Set the invoice description.
2139
+     *
2140
+     * @since 1.0.19
2141
+     * @param  string $value New description.
2142
+     */
2143
+    public function set_description( $value ) {
2144 2144
         $description = wp_kses_post( $value );
2145
-		return $this->set_prop( 'description', $description );
2145
+        return $this->set_prop( 'description', $description );
2146 2146
     }
2147 2147
 
2148 2148
     /**
2149
-	 * Alias of self::set_description().
2150
-	 *
2151
-	 * @since 1.0.19
2152
-	 * @param  string $value New description.
2153
-	 */
2154
-	public function set_excerpt( $value ) {
2155
-		$this->set_description( $value );
2149
+     * Alias of self::set_description().
2150
+     *
2151
+     * @since 1.0.19
2152
+     * @param  string $value New description.
2153
+     */
2154
+    public function set_excerpt( $value ) {
2155
+        $this->set_description( $value );
2156 2156
     }
2157 2157
 
2158 2158
     /**
2159
-	 * Alias of self::set_description().
2160
-	 *
2161
-	 * @since 1.0.19
2162
-	 * @param  string $value New description.
2163
-	 */
2164
-	public function set_summary( $value ) {
2165
-		$this->set_description( $value );
2159
+     * Alias of self::set_description().
2160
+     *
2161
+     * @since 1.0.19
2162
+     * @param  string $value New description.
2163
+     */
2164
+    public function set_summary( $value ) {
2165
+        $this->set_description( $value );
2166 2166
     }
2167 2167
 
2168 2168
     /**
2169
-	 * Set the receiver of the invoice.
2170
-	 *
2171
-	 * @since 1.0.19
2172
-	 * @param  int $value New author.
2173
-	 */
2174
-	public function set_author( $value ) {
2175
-		$user = get_user_by( 'id', (int) $value );
2169
+     * Set the receiver of the invoice.
2170
+     *
2171
+     * @since 1.0.19
2172
+     * @param  int $value New author.
2173
+     */
2174
+    public function set_author( $value ) {
2175
+        $user = get_user_by( 'id', (int) $value );
2176 2176
 
2177
-		if ( $user && $user->ID ) {
2178
-			$this->set_prop( 'author', $user->ID );
2179
-			$this->set_prop( 'email', $user->user_email );
2180
-		}
2177
+        if ( $user && $user->ID ) {
2178
+            $this->set_prop( 'author', $user->ID );
2179
+            $this->set_prop( 'email', $user->user_email );
2180
+        }
2181 2181
 		
2182 2182
     }
2183 2183
 
2184 2184
     /**
2185
-	 * Alias of self::set_author().
2186
-	 *
2187
-	 * @since 1.0.19
2188
-	 * @param  int $value New user id.
2189
-	 */
2190
-	public function set_user_id( $value ) {
2191
-		$this->set_author( $value );
2185
+     * Alias of self::set_author().
2186
+     *
2187
+     * @since 1.0.19
2188
+     * @param  int $value New user id.
2189
+     */
2190
+    public function set_user_id( $value ) {
2191
+        $this->set_author( $value );
2192
+    }
2193
+
2194
+    /**
2195
+     * Alias of self::set_author().
2196
+     *
2197
+     * @since 1.0.19
2198
+     * @param  int $value New user id.
2199
+     */
2200
+    public function set_customer_id( $value ) {
2201
+        $this->set_author( $value );
2202
+    }
2203
+
2204
+    /**
2205
+     * Set the customer's ip.
2206
+     *
2207
+     * @since 1.0.19
2208
+     * @param  string $value ip address.
2209
+     */
2210
+    public function set_ip( $value ) {
2211
+        $this->set_prop( 'ip', $value );
2212
+    }
2213
+
2214
+    /**
2215
+     * Alias of self::set_ip().
2216
+     *
2217
+     * @since 1.0.19
2218
+     * @param  string $value ip address.
2219
+     */
2220
+    public function set_user_ip( $value ) {
2221
+        $this->set_ip( $value );
2192 2222
     }
2193 2223
 
2194 2224
     /**
2195
-	 * Alias of self::set_author().
2196
-	 *
2197
-	 * @since 1.0.19
2198
-	 * @param  int $value New user id.
2199
-	 */
2200
-	public function set_customer_id( $value ) {
2201
-		$this->set_author( $value );
2225
+     * Set the customer's first name.
2226
+     *
2227
+     * @since 1.0.19
2228
+     * @param  string $value first name.
2229
+     */
2230
+    public function set_first_name( $value ) {
2231
+        $this->set_prop( 'first_name', $value );
2202 2232
     }
2203 2233
 
2204 2234
     /**
2205
-	 * Set the customer's ip.
2206
-	 *
2207
-	 * @since 1.0.19
2208
-	 * @param  string $value ip address.
2209
-	 */
2210
-	public function set_ip( $value ) {
2211
-		$this->set_prop( 'ip', $value );
2235
+     * Alias of self::set_first_name().
2236
+     *
2237
+     * @since 1.0.19
2238
+     * @param  string $value first name.
2239
+     */
2240
+    public function set_user_first_name( $value ) {
2241
+        $this->set_first_name( $value );
2212 2242
     }
2213 2243
 
2214 2244
     /**
2215
-	 * Alias of self::set_ip().
2216
-	 *
2217
-	 * @since 1.0.19
2218
-	 * @param  string $value ip address.
2219
-	 */
2220
-	public function set_user_ip( $value ) {
2221
-		$this->set_ip( $value );
2245
+     * Alias of self::set_first_name().
2246
+     *
2247
+     * @since 1.0.19
2248
+     * @param  string $value first name.
2249
+     */
2250
+    public function set_customer_first_name( $value ) {
2251
+        $this->set_first_name( $value );
2222 2252
     }
2223 2253
 
2224 2254
     /**
2225
-	 * Set the customer's first name.
2226
-	 *
2227
-	 * @since 1.0.19
2228
-	 * @param  string $value first name.
2229
-	 */
2230
-	public function set_first_name( $value ) {
2231
-		$this->set_prop( 'first_name', $value );
2255
+     * Set the customer's last name.
2256
+     *
2257
+     * @since 1.0.19
2258
+     * @param  string $value last name.
2259
+     */
2260
+    public function set_last_name( $value ) {
2261
+        $this->set_prop( 'last_name', $value );
2232 2262
     }
2233 2263
 
2234 2264
     /**
2235
-	 * Alias of self::set_first_name().
2236
-	 *
2237
-	 * @since 1.0.19
2238
-	 * @param  string $value first name.
2239
-	 */
2240
-	public function set_user_first_name( $value ) {
2241
-		$this->set_first_name( $value );
2265
+     * Alias of self::set_last_name().
2266
+     *
2267
+     * @since 1.0.19
2268
+     * @param  string $value last name.
2269
+     */
2270
+    public function set_user_last_name( $value ) {
2271
+        $this->set_last_name( $value );
2242 2272
     }
2243 2273
 
2244 2274
     /**
2245
-	 * Alias of self::set_first_name().
2246
-	 *
2247
-	 * @since 1.0.19
2248
-	 * @param  string $value first name.
2249
-	 */
2250
-	public function set_customer_first_name( $value ) {
2251
-		$this->set_first_name( $value );
2275
+     * Alias of self::set_last_name().
2276
+     *
2277
+     * @since 1.0.19
2278
+     * @param  string $value last name.
2279
+     */
2280
+    public function set_customer_last_name( $value ) {
2281
+        $this->set_last_name( $value );
2252 2282
     }
2253 2283
 
2254 2284
     /**
2255
-	 * Set the customer's last name.
2256
-	 *
2257
-	 * @since 1.0.19
2258
-	 * @param  string $value last name.
2259
-	 */
2260
-	public function set_last_name( $value ) {
2261
-		$this->set_prop( 'last_name', $value );
2285
+     * Set the customer's phone number.
2286
+     *
2287
+     * @since 1.0.19
2288
+     * @param  string $value phone.
2289
+     */
2290
+    public function set_phone( $value ) {
2291
+        $this->set_prop( 'phone', $value );
2262 2292
     }
2263 2293
 
2264 2294
     /**
2265
-	 * Alias of self::set_last_name().
2266
-	 *
2267
-	 * @since 1.0.19
2268
-	 * @param  string $value last name.
2269
-	 */
2270
-	public function set_user_last_name( $value ) {
2271
-		$this->set_last_name( $value );
2295
+     * Alias of self::set_phone().
2296
+     *
2297
+     * @since 1.0.19
2298
+     * @param  string $value phone.
2299
+     */
2300
+    public function set_user_phone( $value ) {
2301
+        $this->set_phone( $value );
2272 2302
     }
2273 2303
 
2274 2304
     /**
2275
-	 * Alias of self::set_last_name().
2276
-	 *
2277
-	 * @since 1.0.19
2278
-	 * @param  string $value last name.
2279
-	 */
2280
-	public function set_customer_last_name( $value ) {
2281
-		$this->set_last_name( $value );
2305
+     * Alias of self::set_phone().
2306
+     *
2307
+     * @since 1.0.19
2308
+     * @param  string $value phone.
2309
+     */
2310
+    public function set_customer_phone( $value ) {
2311
+        $this->set_phone( $value );
2282 2312
     }
2283 2313
 
2284 2314
     /**
2285
-	 * Set the customer's phone number.
2286
-	 *
2287
-	 * @since 1.0.19
2288
-	 * @param  string $value phone.
2289
-	 */
2290
-	public function set_phone( $value ) {
2291
-		$this->set_prop( 'phone', $value );
2315
+     * Alias of self::set_phone().
2316
+     *
2317
+     * @since 1.0.19
2318
+     * @param  string $value phone.
2319
+     */
2320
+    public function set_phone_number( $value ) {
2321
+        $this->set_phone( $value );
2292 2322
     }
2293 2323
 
2294 2324
     /**
2295
-	 * Alias of self::set_phone().
2296
-	 *
2297
-	 * @since 1.0.19
2298
-	 * @param  string $value phone.
2299
-	 */
2300
-	public function set_user_phone( $value ) {
2301
-		$this->set_phone( $value );
2325
+     * Set the customer's email address.
2326
+     *
2327
+     * @since 1.0.19
2328
+     * @param  string $value email address.
2329
+     */
2330
+    public function set_email( $value ) {
2331
+        $this->set_prop( 'email', $value );
2302 2332
     }
2303 2333
 
2304 2334
     /**
2305
-	 * Alias of self::set_phone().
2306
-	 *
2307
-	 * @since 1.0.19
2308
-	 * @param  string $value phone.
2309
-	 */
2310
-	public function set_customer_phone( $value ) {
2311
-		$this->set_phone( $value );
2335
+     * Alias of self::set_email().
2336
+     *
2337
+     * @since 1.0.19
2338
+     * @param  string $value email address.
2339
+     */
2340
+    public function set_user_email( $value ) {
2341
+        $this->set_email( $value );
2312 2342
     }
2313 2343
 
2314 2344
     /**
2315
-	 * Alias of self::set_phone().
2316
-	 *
2317
-	 * @since 1.0.19
2318
-	 * @param  string $value phone.
2319
-	 */
2320
-	public function set_phone_number( $value ) {
2321
-		$this->set_phone( $value );
2345
+     * Alias of self::set_email().
2346
+     *
2347
+     * @since 1.0.19
2348
+     * @param  string $value email address.
2349
+     */
2350
+    public function set_email_address( $value ) {
2351
+        $this->set_email( $value );
2322 2352
     }
2323 2353
 
2324 2354
     /**
2325
-	 * Set the customer's email address.
2326
-	 *
2327
-	 * @since 1.0.19
2328
-	 * @param  string $value email address.
2329
-	 */
2330
-	public function set_email( $value ) {
2331
-		$this->set_prop( 'email', $value );
2355
+     * Alias of self::set_email().
2356
+     *
2357
+     * @since 1.0.19
2358
+     * @param  string $value email address.
2359
+     */
2360
+    public function set_customer_email( $value ) {
2361
+        $this->set_email( $value );
2332 2362
     }
2333 2363
 
2334 2364
     /**
2335
-	 * Alias of self::set_email().
2336
-	 *
2337
-	 * @since 1.0.19
2338
-	 * @param  string $value email address.
2339
-	 */
2340
-	public function set_user_email( $value ) {
2341
-		$this->set_email( $value );
2365
+     * Set the customer's country.
2366
+     *
2367
+     * @since 1.0.19
2368
+     * @param  string $value country.
2369
+     */
2370
+    public function set_country( $value ) {
2371
+        $this->set_prop( 'country', $value );
2342 2372
     }
2343 2373
 
2344 2374
     /**
2345
-	 * Alias of self::set_email().
2346
-	 *
2347
-	 * @since 1.0.19
2348
-	 * @param  string $value email address.
2349
-	 */
2350
-	public function set_email_address( $value ) {
2351
-		$this->set_email( $value );
2375
+     * Alias of self::set_country().
2376
+     *
2377
+     * @since 1.0.19
2378
+     * @param  string $value country.
2379
+     */
2380
+    public function set_user_country( $value ) {
2381
+        $this->set_country( $value );
2352 2382
     }
2353 2383
 
2354 2384
     /**
2355
-	 * Alias of self::set_email().
2356
-	 *
2357
-	 * @since 1.0.19
2358
-	 * @param  string $value email address.
2359
-	 */
2360
-	public function set_customer_email( $value ) {
2361
-		$this->set_email( $value );
2385
+     * Alias of self::set_country().
2386
+     *
2387
+     * @since 1.0.19
2388
+     * @param  string $value country.
2389
+     */
2390
+    public function set_customer_country( $value ) {
2391
+        $this->set_country( $value );
2362 2392
     }
2363 2393
 
2364 2394
     /**
2365
-	 * Set the customer's country.
2366
-	 *
2367
-	 * @since 1.0.19
2368
-	 * @param  string $value country.
2369
-	 */
2370
-	public function set_country( $value ) {
2371
-		$this->set_prop( 'country', $value );
2395
+     * Set the customer's state.
2396
+     *
2397
+     * @since 1.0.19
2398
+     * @param  string $value state.
2399
+     */
2400
+    public function set_state( $value ) {
2401
+        $this->set_prop( 'state', $value );
2372 2402
     }
2373 2403
 
2374 2404
     /**
2375
-	 * Alias of self::set_country().
2376
-	 *
2377
-	 * @since 1.0.19
2378
-	 * @param  string $value country.
2379
-	 */
2380
-	public function set_user_country( $value ) {
2381
-		$this->set_country( $value );
2405
+     * Alias of self::set_state().
2406
+     *
2407
+     * @since 1.0.19
2408
+     * @param  string $value state.
2409
+     */
2410
+    public function set_user_state( $value ) {
2411
+        $this->set_state( $value );
2382 2412
     }
2383 2413
 
2384 2414
     /**
2385
-	 * Alias of self::set_country().
2386
-	 *
2387
-	 * @since 1.0.19
2388
-	 * @param  string $value country.
2389
-	 */
2390
-	public function set_customer_country( $value ) {
2391
-		$this->set_country( $value );
2415
+     * Alias of self::set_state().
2416
+     *
2417
+     * @since 1.0.19
2418
+     * @param  string $value state.
2419
+     */
2420
+    public function set_customer_state( $value ) {
2421
+        $this->set_state( $value );
2392 2422
     }
2393 2423
 
2394 2424
     /**
2395
-	 * Set the customer's state.
2396
-	 *
2397
-	 * @since 1.0.19
2398
-	 * @param  string $value state.
2399
-	 */
2400
-	public function set_state( $value ) {
2401
-		$this->set_prop( 'state', $value );
2425
+     * Set the customer's city.
2426
+     *
2427
+     * @since 1.0.19
2428
+     * @param  string $value city.
2429
+     */
2430
+    public function set_city( $value ) {
2431
+        $this->set_prop( 'city', $value );
2402 2432
     }
2403 2433
 
2404 2434
     /**
2405
-	 * Alias of self::set_state().
2406
-	 *
2407
-	 * @since 1.0.19
2408
-	 * @param  string $value state.
2409
-	 */
2410
-	public function set_user_state( $value ) {
2411
-		$this->set_state( $value );
2435
+     * Alias of self::set_city().
2436
+     *
2437
+     * @since 1.0.19
2438
+     * @param  string $value city.
2439
+     */
2440
+    public function set_user_city( $value ) {
2441
+        $this->set_city( $value );
2412 2442
     }
2413 2443
 
2414 2444
     /**
2415
-	 * Alias of self::set_state().
2416
-	 *
2417
-	 * @since 1.0.19
2418
-	 * @param  string $value state.
2419
-	 */
2420
-	public function set_customer_state( $value ) {
2421
-		$this->set_state( $value );
2445
+     * Alias of self::set_city().
2446
+     *
2447
+     * @since 1.0.19
2448
+     * @param  string $value city.
2449
+     */
2450
+    public function set_customer_city( $value ) {
2451
+        $this->set_city( $value );
2422 2452
     }
2423 2453
 
2424 2454
     /**
2425
-	 * Set the customer's city.
2426
-	 *
2427
-	 * @since 1.0.19
2428
-	 * @param  string $value city.
2429
-	 */
2430
-	public function set_city( $value ) {
2431
-		$this->set_prop( 'city', $value );
2455
+     * Set the customer's zip code.
2456
+     *
2457
+     * @since 1.0.19
2458
+     * @param  string $value zip.
2459
+     */
2460
+    public function set_zip( $value ) {
2461
+        $this->set_prop( 'zip', $value );
2432 2462
     }
2433 2463
 
2434 2464
     /**
2435
-	 * Alias of self::set_city().
2436
-	 *
2437
-	 * @since 1.0.19
2438
-	 * @param  string $value city.
2439
-	 */
2440
-	public function set_user_city( $value ) {
2441
-		$this->set_city( $value );
2465
+     * Alias of self::set_zip().
2466
+     *
2467
+     * @since 1.0.19
2468
+     * @param  string $value zip.
2469
+     */
2470
+    public function set_user_zip( $value ) {
2471
+        $this->set_zip( $value );
2442 2472
     }
2443 2473
 
2444 2474
     /**
2445
-	 * Alias of self::set_city().
2446
-	 *
2447
-	 * @since 1.0.19
2448
-	 * @param  string $value city.
2449
-	 */
2450
-	public function set_customer_city( $value ) {
2451
-		$this->set_city( $value );
2475
+     * Alias of self::set_zip().
2476
+     *
2477
+     * @since 1.0.19
2478
+     * @param  string $value zip.
2479
+     */
2480
+    public function set_customer_zip( $value ) {
2481
+        $this->set_zip( $value );
2452 2482
     }
2453 2483
 
2454 2484
     /**
2455
-	 * Set the customer's zip code.
2456
-	 *
2457
-	 * @since 1.0.19
2458
-	 * @param  string $value zip.
2459
-	 */
2460
-	public function set_zip( $value ) {
2461
-		$this->set_prop( 'zip', $value );
2485
+     * Set the customer's company.
2486
+     *
2487
+     * @since 1.0.19
2488
+     * @param  string $value company.
2489
+     */
2490
+    public function set_company( $value ) {
2491
+        $this->set_prop( 'company', $value );
2462 2492
     }
2463 2493
 
2464 2494
     /**
2465
-	 * Alias of self::set_zip().
2466
-	 *
2467
-	 * @since 1.0.19
2468
-	 * @param  string $value zip.
2469
-	 */
2470
-	public function set_user_zip( $value ) {
2471
-		$this->set_zip( $value );
2495
+     * Alias of self::set_company().
2496
+     *
2497
+     * @since 1.0.19
2498
+     * @param  string $value company.
2499
+     */
2500
+    public function set_user_company( $value ) {
2501
+        $this->set_company( $value );
2472 2502
     }
2473 2503
 
2474 2504
     /**
2475
-	 * Alias of self::set_zip().
2476
-	 *
2477
-	 * @since 1.0.19
2478
-	 * @param  string $value zip.
2479
-	 */
2480
-	public function set_customer_zip( $value ) {
2481
-		$this->set_zip( $value );
2505
+     * Alias of self::set_company().
2506
+     *
2507
+     * @since 1.0.19
2508
+     * @param  string $value company.
2509
+     */
2510
+    public function set_customer_company( $value ) {
2511
+        $this->set_company( $value );
2482 2512
     }
2483 2513
 
2484 2514
     /**
2485
-	 * Set the customer's company.
2486
-	 *
2487
-	 * @since 1.0.19
2488
-	 * @param  string $value company.
2489
-	 */
2490
-	public function set_company( $value ) {
2491
-		$this->set_prop( 'company', $value );
2515
+     * Set the customer's var number.
2516
+     *
2517
+     * @since 1.0.19
2518
+     * @param  string $value var number.
2519
+     */
2520
+    public function set_vat_number( $value ) {
2521
+        $this->set_prop( 'vat_number', $value );
2492 2522
     }
2493 2523
 
2494 2524
     /**
2495
-	 * Alias of self::set_company().
2496
-	 *
2497
-	 * @since 1.0.19
2498
-	 * @param  string $value company.
2499
-	 */
2500
-	public function set_user_company( $value ) {
2501
-		$this->set_company( $value );
2525
+     * Alias of self::set_vat_number().
2526
+     *
2527
+     * @since 1.0.19
2528
+     * @param  string $value var number.
2529
+     */
2530
+    public function set_user_vat_number( $value ) {
2531
+        $this->set_vat_number( $value );
2502 2532
     }
2503 2533
 
2504 2534
     /**
2505
-	 * Alias of self::set_company().
2506
-	 *
2507
-	 * @since 1.0.19
2508
-	 * @param  string $value company.
2509
-	 */
2510
-	public function set_customer_company( $value ) {
2511
-		$this->set_company( $value );
2535
+     * Alias of self::set_vat_number().
2536
+     *
2537
+     * @since 1.0.19
2538
+     * @param  string $value var number.
2539
+     */
2540
+    public function set_customer_vat_number( $value ) {
2541
+        $this->set_vat_number( $value );
2512 2542
     }
2513 2543
 
2514 2544
     /**
2515
-	 * Set the customer's var number.
2516
-	 *
2517
-	 * @since 1.0.19
2518
-	 * @param  string $value var number.
2519
-	 */
2520
-	public function set_vat_number( $value ) {
2521
-		$this->set_prop( 'vat_number', $value );
2545
+     * Set the customer's vat rate.
2546
+     *
2547
+     * @since 1.0.19
2548
+     * @param  string $value var rate.
2549
+     */
2550
+    public function set_vat_rate( $value ) {
2551
+        $this->set_prop( 'vat_rate', $value );
2522 2552
     }
2523 2553
 
2524 2554
     /**
2525
-	 * Alias of self::set_vat_number().
2526
-	 *
2527
-	 * @since 1.0.19
2528
-	 * @param  string $value var number.
2529
-	 */
2530
-	public function set_user_vat_number( $value ) {
2531
-		$this->set_vat_number( $value );
2555
+     * Alias of self::set_vat_rate().
2556
+     *
2557
+     * @since 1.0.19
2558
+     * @param  string $value var number.
2559
+     */
2560
+    public function set_user_vat_rate( $value ) {
2561
+        $this->set_vat_rate( $value );
2532 2562
     }
2533 2563
 
2534 2564
     /**
2535
-	 * Alias of self::set_vat_number().
2536
-	 *
2537
-	 * @since 1.0.19
2538
-	 * @param  string $value var number.
2539
-	 */
2540
-	public function set_customer_vat_number( $value ) {
2541
-		$this->set_vat_number( $value );
2565
+     * Alias of self::set_vat_rate().
2566
+     *
2567
+     * @since 1.0.19
2568
+     * @param  string $value var number.
2569
+     */
2570
+    public function set_customer_vat_rate( $value ) {
2571
+        $this->set_vat_rate( $value );
2542 2572
     }
2543 2573
 
2544 2574
     /**
2545
-	 * Set the customer's vat rate.
2546
-	 *
2547
-	 * @since 1.0.19
2548
-	 * @param  string $value var rate.
2549
-	 */
2550
-	public function set_vat_rate( $value ) {
2551
-		$this->set_prop( 'vat_rate', $value );
2575
+     * Set the customer's address.
2576
+     *
2577
+     * @since 1.0.19
2578
+     * @param  string $value address.
2579
+     */
2580
+    public function set_address( $value ) {
2581
+        $this->set_prop( 'address', $value );
2552 2582
     }
2553 2583
 
2554 2584
     /**
2555
-	 * Alias of self::set_vat_rate().
2556
-	 *
2557
-	 * @since 1.0.19
2558
-	 * @param  string $value var number.
2559
-	 */
2560
-	public function set_user_vat_rate( $value ) {
2561
-		$this->set_vat_rate( $value );
2585
+     * Alias of self::set_address().
2586
+     *
2587
+     * @since 1.0.19
2588
+     * @param  string $value address.
2589
+     */
2590
+    public function set_user_address( $value ) {
2591
+        $this->set_address( $value );
2562 2592
     }
2563 2593
 
2564 2594
     /**
2565
-	 * Alias of self::set_vat_rate().
2566
-	 *
2567
-	 * @since 1.0.19
2568
-	 * @param  string $value var number.
2569
-	 */
2570
-	public function set_customer_vat_rate( $value ) {
2571
-		$this->set_vat_rate( $value );
2595
+     * Alias of self::set_address().
2596
+     *
2597
+     * @since 1.0.19
2598
+     * @param  string $value address.
2599
+     */
2600
+    public function set_customer_address( $value ) {
2601
+        $this->set_address( $value );
2572 2602
     }
2573 2603
 
2574 2604
     /**
2575
-	 * Set the customer's address.
2576
-	 *
2577
-	 * @since 1.0.19
2578
-	 * @param  string $value address.
2579
-	 */
2580
-	public function set_address( $value ) {
2581
-		$this->set_prop( 'address', $value );
2605
+     * Set whether the customer has viewed the invoice or not.
2606
+     *
2607
+     * @since 1.0.19
2608
+     * @param  int|bool $value confirmed.
2609
+     */
2610
+    public function set_is_viewed( $value ) {
2611
+        $this->set_prop( 'is_viewed', $value );
2582 2612
     }
2583 2613
 
2584 2614
     /**
2585
-	 * Alias of self::set_address().
2586
-	 *
2587
-	 * @since 1.0.19
2588
-	 * @param  string $value address.
2589
-	 */
2590
-	public function set_user_address( $value ) {
2591
-		$this->set_address( $value );
2615
+     * Set extra email recipients.
2616
+     *
2617
+     * @since 1.0.19
2618
+     * @param  string $value email recipients.
2619
+     */
2620
+    public function set_email_cc( $value ) {
2621
+        $this->set_prop( 'email_cc', $value );
2592 2622
     }
2593 2623
 
2594 2624
     /**
2595
-	 * Alias of self::set_address().
2596
-	 *
2597
-	 * @since 1.0.19
2598
-	 * @param  string $value address.
2599
-	 */
2600
-	public function set_customer_address( $value ) {
2601
-		$this->set_address( $value );
2625
+     * Set the invoice template.
2626
+     *
2627
+     * @since 1.0.19
2628
+     * @param  string $value email recipients.
2629
+     */
2630
+    public function set_template( $value ) {
2631
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2632
+            $this->set_prop( 'template', $value );
2633
+        }
2602 2634
     }
2603 2635
 
2604 2636
     /**
2605
-	 * Set whether the customer has viewed the invoice or not.
2606
-	 *
2607
-	 * @since 1.0.19
2608
-	 * @param  int|bool $value confirmed.
2609
-	 */
2610
-	public function set_is_viewed( $value ) {
2611
-		$this->set_prop( 'is_viewed', $value );
2612
-	}
2613
-
2614
-	/**
2615
-	 * Set extra email recipients.
2616
-	 *
2617
-	 * @since 1.0.19
2618
-	 * @param  string $value email recipients.
2619
-	 */
2620
-	public function set_email_cc( $value ) {
2621
-		$this->set_prop( 'email_cc', $value );
2622
-	}
2623
-
2624
-	/**
2625
-	 * Set the invoice template.
2626
-	 *
2627
-	 * @since 1.0.19
2628
-	 * @param  string $value email recipients.
2629
-	 */
2630
-	public function set_template( $value ) {
2631
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2632
-			$this->set_prop( 'template', $value );
2633
-		}
2634
-	}
2635
-
2636
-	/**
2637
-	 * Set the customer's address confirmed status.
2638
-	 *
2639
-	 * @since 1.0.19
2640
-	 * @param  int|bool $value confirmed.
2641
-	 */
2642
-	public function set_address_confirmed( $value ) {
2643
-		$this->set_prop( 'address_confirmed', $value );
2637
+     * Set the customer's address confirmed status.
2638
+     *
2639
+     * @since 1.0.19
2640
+     * @param  int|bool $value confirmed.
2641
+     */
2642
+    public function set_address_confirmed( $value ) {
2643
+        $this->set_prop( 'address_confirmed', $value );
2644 2644
     }
2645 2645
 
2646 2646
     /**
2647
-	 * Alias of self::set_address_confirmed().
2648
-	 *
2649
-	 * @since 1.0.19
2650
-	 * @param  int|bool $value confirmed.
2651
-	 */
2652
-	public function set_user_address_confirmed( $value ) {
2653
-		$this->set_address_confirmed( $value );
2647
+     * Alias of self::set_address_confirmed().
2648
+     *
2649
+     * @since 1.0.19
2650
+     * @param  int|bool $value confirmed.
2651
+     */
2652
+    public function set_user_address_confirmed( $value ) {
2653
+        $this->set_address_confirmed( $value );
2654 2654
     }
2655 2655
 
2656 2656
     /**
2657
-	 * Alias of self::set_address_confirmed().
2658
-	 *
2659
-	 * @since 1.0.19
2660
-	 * @param  int|bool $value confirmed.
2661
-	 */
2662
-	public function set_customer_address_confirmed( $value ) {
2663
-		$this->set_address_confirmed( $value );
2657
+     * Alias of self::set_address_confirmed().
2658
+     *
2659
+     * @since 1.0.19
2660
+     * @param  int|bool $value confirmed.
2661
+     */
2662
+    public function set_customer_address_confirmed( $value ) {
2663
+        $this->set_address_confirmed( $value );
2664 2664
     }
2665 2665
 
2666 2666
     /**
2667
-	 * Set the invoice sub total.
2668
-	 *
2669
-	 * @since 1.0.19
2670
-	 * @param  float $value sub total.
2671
-	 */
2672
-	public function set_subtotal( $value ) {
2673
-		$this->set_prop( 'subtotal', $value );
2667
+     * Set the invoice sub total.
2668
+     *
2669
+     * @since 1.0.19
2670
+     * @param  float $value sub total.
2671
+     */
2672
+    public function set_subtotal( $value ) {
2673
+        $this->set_prop( 'subtotal', $value );
2674 2674
     }
2675 2675
 
2676 2676
     /**
2677
-	 * Set the invoice discount amount.
2678
-	 *
2679
-	 * @since 1.0.19
2680
-	 * @param  float $value discount total.
2681
-	 */
2682
-	public function set_total_discount( $value ) {
2683
-		$this->set_prop( 'total_discount', $value );
2677
+     * Set the invoice discount amount.
2678
+     *
2679
+     * @since 1.0.19
2680
+     * @param  float $value discount total.
2681
+     */
2682
+    public function set_total_discount( $value ) {
2683
+        $this->set_prop( 'total_discount', $value );
2684 2684
     }
2685 2685
 
2686 2686
     /**
2687
-	 * Alias of self::set_total_discount().
2688
-	 *
2689
-	 * @since 1.0.19
2690
-	 * @param  float $value discount total.
2691
-	 */
2692
-	public function set_discount( $value ) {
2693
-		$this->set_total_discount( $value );
2687
+     * Alias of self::set_total_discount().
2688
+     *
2689
+     * @since 1.0.19
2690
+     * @param  float $value discount total.
2691
+     */
2692
+    public function set_discount( $value ) {
2693
+        $this->set_total_discount( $value );
2694 2694
     }
2695 2695
 
2696 2696
     /**
2697
-	 * Set the invoice tax amount.
2698
-	 *
2699
-	 * @since 1.0.19
2700
-	 * @param  float $value tax total.
2701
-	 */
2702
-	public function set_total_tax( $value ) {
2703
-		$this->set_prop( 'total_tax', $value );
2697
+     * Set the invoice tax amount.
2698
+     *
2699
+     * @since 1.0.19
2700
+     * @param  float $value tax total.
2701
+     */
2702
+    public function set_total_tax( $value ) {
2703
+        $this->set_prop( 'total_tax', $value );
2704 2704
     }
2705 2705
 
2706 2706
     /**
2707
-	 * Alias of self::set_total_tax().
2708
-	 *
2709
-	 * @since 1.0.19
2710
-	 * @param  float $value tax total.
2711
-	 */
2712
-	public function set_tax_total( $value ) {
2713
-		$this->set_total_tax( $value );
2707
+     * Alias of self::set_total_tax().
2708
+     *
2709
+     * @since 1.0.19
2710
+     * @param  float $value tax total.
2711
+     */
2712
+    public function set_tax_total( $value ) {
2713
+        $this->set_total_tax( $value );
2714 2714
     }
2715 2715
 
2716 2716
     /**
2717
-	 * Set the invoice fees amount.
2718
-	 *
2719
-	 * @since 1.0.19
2720
-	 * @param  float $value fees total.
2721
-	 */
2722
-	public function set_total_fees( $value ) {
2723
-		$this->set_prop( 'total_fees', $value );
2717
+     * Set the invoice fees amount.
2718
+     *
2719
+     * @since 1.0.19
2720
+     * @param  float $value fees total.
2721
+     */
2722
+    public function set_total_fees( $value ) {
2723
+        $this->set_prop( 'total_fees', $value );
2724 2724
     }
2725 2725
 
2726 2726
     /**
2727
-	 * Alias of self::set_total_fees().
2728
-	 *
2729
-	 * @since 1.0.19
2730
-	 * @param  float $value fees total.
2731
-	 */
2732
-	public function set_fees_total( $value ) {
2733
-		$this->set_total_fees( $value );
2727
+     * Alias of self::set_total_fees().
2728
+     *
2729
+     * @since 1.0.19
2730
+     * @param  float $value fees total.
2731
+     */
2732
+    public function set_fees_total( $value ) {
2733
+        $this->set_total_fees( $value );
2734 2734
     }
2735 2735
 
2736 2736
     /**
2737
-	 * Set the invoice fees.
2738
-	 *
2739
-	 * @since 1.0.19
2740
-	 * @param  array $value fees.
2741
-	 */
2742
-	public function set_fees( $value ) {
2737
+     * Set the invoice fees.
2738
+     *
2739
+     * @since 1.0.19
2740
+     * @param  array $value fees.
2741
+     */
2742
+    public function set_fees( $value ) {
2743 2743
 
2744 2744
         $this->set_prop( 'fees', array() );
2745 2745
 
@@ -2757,23 +2757,23 @@  discard block
 block discarded – undo
2757 2757
     }
2758 2758
 
2759 2759
     /**
2760
-	 * Set the invoice taxes.
2761
-	 *
2762
-	 * @since 1.0.19
2763
-	 * @param  array $value taxes.
2764
-	 */
2765
-	public function set_taxes( $value ) {
2766
-		$this->set_prop( 'taxes', $value );
2760
+     * Set the invoice taxes.
2761
+     *
2762
+     * @since 1.0.19
2763
+     * @param  array $value taxes.
2764
+     */
2765
+    public function set_taxes( $value ) {
2766
+        $this->set_prop( 'taxes', $value );
2767 2767
     }
2768 2768
 
2769 2769
     /**
2770
-	 * Set the invoice discounts.
2771
-	 *
2772
-	 * @since 1.0.19
2773
-	 * @param  array $value discounts.
2774
-	 */
2775
-	public function set_discounts( $value ) {
2776
-		$this->set_prop( 'discounts', array() );
2770
+     * Set the invoice discounts.
2771
+     *
2772
+     * @since 1.0.19
2773
+     * @param  array $value discounts.
2774
+     */
2775
+    public function set_discounts( $value ) {
2776
+        $this->set_prop( 'discounts', array() );
2777 2777
 
2778 2778
         // Ensure that we have an array.
2779 2779
         if ( ! is_array( $value ) ) {
@@ -2788,12 +2788,12 @@  discard block
 block discarded – undo
2788 2788
     }
2789 2789
 
2790 2790
     /**
2791
-	 * Set the invoice items.
2792
-	 *
2793
-	 * @since 1.0.19
2794
-	 * @param  GetPaid_Form_Item[] $value items.
2795
-	 */
2796
-	public function set_items( $value ) {
2791
+     * Set the invoice items.
2792
+     *
2793
+     * @since 1.0.19
2794
+     * @param  GetPaid_Form_Item[] $value items.
2795
+     */
2796
+    public function set_items( $value ) {
2797 2797
 
2798 2798
         // Remove existing items.
2799 2799
         $this->set_prop( 'items', array() );
@@ -2810,95 +2810,95 @@  discard block
 block discarded – undo
2810 2810
     }
2811 2811
 
2812 2812
     /**
2813
-	 * Set the payment form.
2814
-	 *
2815
-	 * @since 1.0.19
2816
-	 * @param  int $value payment form.
2817
-	 */
2818
-	public function set_payment_form( $value ) {
2819
-		$this->set_prop( 'payment_form', $value );
2813
+     * Set the payment form.
2814
+     *
2815
+     * @since 1.0.19
2816
+     * @param  int $value payment form.
2817
+     */
2818
+    public function set_payment_form( $value ) {
2819
+        $this->set_prop( 'payment_form', $value );
2820 2820
     }
2821 2821
 
2822 2822
     /**
2823
-	 * Set the submission id.
2824
-	 *
2825
-	 * @since 1.0.19
2826
-	 * @param  string $value submission id.
2827
-	 */
2828
-	public function set_submission_id( $value ) {
2829
-		$this->set_prop( 'submission_id', $value );
2823
+     * Set the submission id.
2824
+     *
2825
+     * @since 1.0.19
2826
+     * @param  string $value submission id.
2827
+     */
2828
+    public function set_submission_id( $value ) {
2829
+        $this->set_prop( 'submission_id', $value );
2830 2830
     }
2831 2831
 
2832 2832
     /**
2833
-	 * Set the discount code.
2834
-	 *
2835
-	 * @since 1.0.19
2836
-	 * @param  string $value discount code.
2837
-	 */
2838
-	public function set_discount_code( $value ) {
2839
-		$this->set_prop( 'discount_code', $value );
2833
+     * Set the discount code.
2834
+     *
2835
+     * @since 1.0.19
2836
+     * @param  string $value discount code.
2837
+     */
2838
+    public function set_discount_code( $value ) {
2839
+        $this->set_prop( 'discount_code', $value );
2840 2840
     }
2841 2841
 
2842 2842
     /**
2843
-	 * Set the gateway.
2844
-	 *
2845
-	 * @since 1.0.19
2846
-	 * @param  string $value gateway.
2847
-	 */
2848
-	public function set_gateway( $value ) {
2849
-		$this->set_prop( 'gateway', $value );
2843
+     * Set the gateway.
2844
+     *
2845
+     * @since 1.0.19
2846
+     * @param  string $value gateway.
2847
+     */
2848
+    public function set_gateway( $value ) {
2849
+        $this->set_prop( 'gateway', $value );
2850 2850
     }
2851 2851
 
2852 2852
     /**
2853
-	 * Set the transaction id.
2854
-	 *
2855
-	 * @since 1.0.19
2856
-	 * @param  string $value transaction id.
2857
-	 */
2858
-	public function set_transaction_id( $value ) {
2859
-		if ( ! empty( $value ) ) {
2860
-			$this->set_prop( 'transaction_id', $value );
2861
-		}
2853
+     * Set the transaction id.
2854
+     *
2855
+     * @since 1.0.19
2856
+     * @param  string $value transaction id.
2857
+     */
2858
+    public function set_transaction_id( $value ) {
2859
+        if ( ! empty( $value ) ) {
2860
+            $this->set_prop( 'transaction_id', $value );
2861
+        }
2862 2862
     }
2863 2863
 
2864 2864
     /**
2865
-	 * Set the currency id.
2866
-	 *
2867
-	 * @since 1.0.19
2868
-	 * @param  string $value currency id.
2869
-	 */
2870
-	public function set_currency( $value ) {
2871
-		$this->set_prop( 'currency', $value );
2865
+     * Set the currency id.
2866
+     *
2867
+     * @since 1.0.19
2868
+     * @param  string $value currency id.
2869
+     */
2870
+    public function set_currency( $value ) {
2871
+        $this->set_prop( 'currency', $value );
2872 2872
     }
2873 2873
 
2874
-	/**
2875
-	 * Set whether to disable taxes.
2876
-	 *
2877
-	 * @since 1.0.19
2878
-	 * @param  bool $value value.
2879
-	 */
2880
-	public function set_disable_taxes( $value ) {
2881
-		$this->set_prop( 'disable_taxes', (bool) $value );
2882
-	}
2874
+    /**
2875
+     * Set whether to disable taxes.
2876
+     *
2877
+     * @since 1.0.19
2878
+     * @param  bool $value value.
2879
+     */
2880
+    public function set_disable_taxes( $value ) {
2881
+        $this->set_prop( 'disable_taxes', (bool) $value );
2882
+    }
2883 2883
 
2884 2884
     /**
2885
-	 * Set the subscription id.
2886
-	 *
2887
-	 * @since 1.0.19
2888
-	 * @param  string $value subscription id.
2889
-	 */
2890
-	public function set_subscription_id( $value ) {
2891
-		$this->set_prop( 'subscription_id', $value );
2892
-	}
2885
+     * Set the subscription id.
2886
+     *
2887
+     * @since 1.0.19
2888
+     * @param  string $value subscription id.
2889
+     */
2890
+    public function set_subscription_id( $value ) {
2891
+        $this->set_prop( 'subscription_id', $value );
2892
+    }
2893 2893
 	
2894
-	/**
2895
-	 * Set the remote subscription id.
2896
-	 *
2897
-	 * @since 1.0.19
2898
-	 * @param  string $value subscription id.
2899
-	 */
2900
-	public function set_remote_subscription_id( $value ) {
2901
-		$this->set_prop( 'remote_subscription_id', $value );
2894
+    /**
2895
+     * Set the remote subscription id.
2896
+     *
2897
+     * @since 1.0.19
2898
+     * @param  string $value subscription id.
2899
+     */
2900
+    public function set_remote_subscription_id( $value ) {
2901
+        $this->set_prop( 'remote_subscription_id', $value );
2902 2902
     }
2903 2903
 
2904 2904
     /*
@@ -2937,12 +2937,12 @@  discard block
 block discarded – undo
2937 2937
      */
2938 2938
     public function is_taxable() {
2939 2939
         return ! $this->get_disable_taxes();
2940
-	}
2940
+    }
2941 2941
 
2942
-	/**
2943
-	 * @deprecated
2944
-	 */
2945
-	public function has_vat() {
2942
+    /**
2943
+     * @deprecated
2944
+     */
2945
+    public function has_vat() {
2946 2946
         global $wpinv_euvat, $wpi_country;
2947 2947
 
2948 2948
         $requires_vat = false;
@@ -2953,17 +2953,17 @@  discard block
 block discarded – undo
2953 2953
         }
2954 2954
 
2955 2955
         return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2956
-	}
2956
+    }
2957 2957
 
2958
-	/**
2959
-	 * Checks to see if the invoice requires payment.
2960
-	 */
2961
-	public function is_free() {
2958
+    /**
2959
+     * Checks to see if the invoice requires payment.
2960
+     */
2961
+    public function is_free() {
2962 2962
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2963 2963
 
2964
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2965
-			$is_free = false;
2966
-		}
2964
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2965
+            $is_free = false;
2966
+        }
2967 2967
 
2968 2968
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2969 2969
     }
@@ -2974,46 +2974,46 @@  discard block
 block discarded – undo
2974 2974
     public function is_paid() {
2975 2975
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2976 2976
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2977
-	}
2977
+    }
2978 2978
 
2979
-	/**
2979
+    /**
2980 2980
      * Checks if the invoice needs payment.
2981 2981
      */
2982
-	public function needs_payment() {
2983
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2982
+    public function needs_payment() {
2983
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2984 2984
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2985 2985
     }
2986 2986
 
2987
-	/**
2987
+    /**
2988 2988
      * Checks if the invoice is refunded.
2989 2989
      */
2990
-	public function is_refunded() {
2990
+    public function is_refunded() {
2991 2991
         $is_refunded = $this->has_status( 'wpi-refunded' );
2992 2992
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2993
-	}
2993
+    }
2994 2994
 
2995
-	/**
2995
+    /**
2996 2996
      * Checks if the invoice is held.
2997 2997
      */
2998
-	public function is_held() {
2998
+    public function is_held() {
2999 2999
         $is_held = $this->has_status( 'wpi-onhold' );
3000 3000
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3001
-	}
3001
+    }
3002 3002
 
3003
-	/**
3003
+    /**
3004 3004
      * Checks if the invoice is due.
3005 3005
      */
3006
-	public function is_due() {
3007
-		$due_date = $this->get_due_date();
3008
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3009
-	}
3006
+    public function is_due() {
3007
+        $due_date = $this->get_due_date();
3008
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3009
+    }
3010 3010
 
3011
-	/**
3011
+    /**
3012 3012
      * Checks if the invoice is draft.
3013 3013
      */
3014
-	public function is_draft() {
3014
+    public function is_draft() {
3015 3015
         return $this->has_status( 'draft, auto-draft' );
3016
-	}
3016
+    }
3017 3017
 
3018 3018
     /**
3019 3019
      * Checks if the invoice has a given status.
@@ -3021,9 +3021,9 @@  discard block
 block discarded – undo
3021 3021
     public function has_status( $status ) {
3022 3022
         $status = wpinv_parse_list( $status );
3023 3023
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3024
-	}
3024
+    }
3025 3025
 
3026
-	/**
3026
+    /**
3027 3027
      * Checks if the invoice is of a given type.
3028 3028
      */
3029 3029
     public function is_type( $type ) {
@@ -3046,25 +3046,25 @@  discard block
 block discarded – undo
3046 3046
      */
3047 3047
     public function has_free_trial() {
3048 3048
         return $this->is_recurring() && 0 == $this->get_initial_total();
3049
-	}
3049
+    }
3050 3050
 
3051
-	/**
3051
+    /**
3052 3052
      * @deprecated
3053 3053
      */
3054 3054
     public function is_free_trial() {
3055 3055
         $this->has_free_trial();
3056 3056
     }
3057 3057
 
3058
-	/**
3058
+    /**
3059 3059
      * Check if the initial payment if 0.
3060 3060
      *
3061 3061
      */
3062
-	public function is_initial_free() {
3062
+    public function is_initial_free() {
3063 3063
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3064 3064
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3065 3065
     }
3066 3066
 	
3067
-	/**
3067
+    /**
3068 3068
      * Check if the recurring item has a free trial.
3069 3069
      *
3070 3070
      */
@@ -3077,21 +3077,21 @@  discard block
 block discarded – undo
3077 3077
 
3078 3078
         $item = $this->get_recurring( true );
3079 3079
         return $item->has_free_trial();
3080
-	}
3080
+    }
3081 3081
 
3082
-	/**
3082
+    /**
3083 3083
      * Check if the free trial is a result of a discount.
3084 3084
      */
3085 3085
     public function is_free_trial_from_discount() {
3086
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3087
-	}
3086
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3087
+    }
3088 3088
 	
3089
-	/**
3089
+    /**
3090 3090
      * @deprecated
3091 3091
      */
3092 3092
     public function discount_first_payment_only() {
3093 3093
 
3094
-		$discount_code = $this->get_discount_code();
3094
+        $discount_code = $this->get_discount_code();
3095 3095
         if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3096 3096
             return true;
3097 3097
         }
@@ -3122,28 +3122,28 @@  discard block
 block discarded – undo
3122 3122
      */
3123 3123
     public function add_item( $item ) {
3124 3124
 
3125
-		if ( is_array( $item ) ) {
3126
-			$item = $this->process_array_item( $item );
3127
-		}
3125
+        if ( is_array( $item ) ) {
3126
+            $item = $this->process_array_item( $item );
3127
+        }
3128 3128
 
3129
-		if ( is_numeric( $item ) ) {
3130
-			$item = new GetPaid_Form_Item( $item );
3131
-		}
3129
+        if ( is_numeric( $item ) ) {
3130
+            $item = new GetPaid_Form_Item( $item );
3131
+        }
3132 3132
 
3133 3133
         // Make sure that it is available for purchase.
3134
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3135
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3134
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3135
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3136 3136
         }
3137 3137
 
3138 3138
         // Do we have a recurring item?
3139
-		if ( $item->is_recurring() ) {
3139
+        if ( $item->is_recurring() ) {
3140 3140
 
3141
-			// An invoice can only contain one recurring item.
3142
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3143
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3144
-			}
3141
+            // An invoice can only contain one recurring item.
3142
+            if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3143
+                return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3144
+            }
3145 3145
 
3146
-			$this->recurring_item = $item->get_id();
3146
+            $this->recurring_item = $item->get_id();
3147 3147
         }
3148 3148
 
3149 3149
         // Invoice id.
@@ -3154,60 +3154,60 @@  discard block
 block discarded – undo
3154 3154
         $items[ (int) $item->get_id() ] = $item;
3155 3155
 
3156 3156
         $this->set_prop( 'items', $items );
3157
-		return true;
3158
-	}
3157
+        return true;
3158
+    }
3159 3159
 	
3160
-	/**
3161
-	 * Converts an array to an item.
3162
-	 *
3163
-	 * @since 1.0.19
3164
-	 * @return GetPaid_Form_Item
3165
-	 */
3166
-	protected function process_array_item( $array ) {
3167
-
3168
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3169
-		$item    = new GetPaid_Form_Item( $item_id );
3170
-
3171
-		// Set item data.
3172
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3173
-			if ( isset( $array[ "item_$key" ] ) ) {
3174
-				$method = "set_$key";
3175
-				$item->$method( $array[ "item_$key" ] );
3176
-			}
3177
-		}
3178
-
3179
-		if ( isset( $array['quantity'] ) ) {
3180
-			$item->set_quantity( $array['quantity'] );
3181
-		}
3182
-
3183
-		// Set item meta.
3184
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3185
-			$item->set_item_meta( $array['meta'] );
3186
-		}
3187
-
3188
-		return $item;
3189
-
3190
-	}
3191
-
3192
-    /**
3193
-	 * Retrieves a specific item.
3194
-	 *
3195
-	 * @since 1.0.19
3196
-	 */
3197
-	public function get_item( $item_id ) {
3198
-		$items   = $this->get_items();
3199
-		$item_id = (int) $item_id;
3200
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3201
-    }
3202
-
3203
-    /**
3204
-	 * Removes a specific item.
3205
-	 *
3206
-	 * @since 1.0.19
3207
-	 */
3208
-	public function remove_item( $item_id ) {
3209
-		$items   = $this->get_items();
3210
-		$item_id = (int) $item_id;
3160
+    /**
3161
+     * Converts an array to an item.
3162
+     *
3163
+     * @since 1.0.19
3164
+     * @return GetPaid_Form_Item
3165
+     */
3166
+    protected function process_array_item( $array ) {
3167
+
3168
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3169
+        $item    = new GetPaid_Form_Item( $item_id );
3170
+
3171
+        // Set item data.
3172
+        foreach( array( 'name', 'price', 'description' ) as $key ) {
3173
+            if ( isset( $array[ "item_$key" ] ) ) {
3174
+                $method = "set_$key";
3175
+                $item->$method( $array[ "item_$key" ] );
3176
+            }
3177
+        }
3178
+
3179
+        if ( isset( $array['quantity'] ) ) {
3180
+            $item->set_quantity( $array['quantity'] );
3181
+        }
3182
+
3183
+        // Set item meta.
3184
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3185
+            $item->set_item_meta( $array['meta'] );
3186
+        }
3187
+
3188
+        return $item;
3189
+
3190
+    }
3191
+
3192
+    /**
3193
+     * Retrieves a specific item.
3194
+     *
3195
+     * @since 1.0.19
3196
+     */
3197
+    public function get_item( $item_id ) {
3198
+        $items   = $this->get_items();
3199
+        $item_id = (int) $item_id;
3200
+        return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3201
+    }
3202
+
3203
+    /**
3204
+     * Removes a specific item.
3205
+     *
3206
+     * @since 1.0.19
3207
+     */
3208
+    public function remove_item( $item_id ) {
3209
+        $items   = $this->get_items();
3210
+        $item_id = (int) $item_id;
3211 3211
 
3212 3212
         if ( $item_id == $this->recurring_item ) {
3213 3213
             $this->recurring_item = null;
@@ -3234,38 +3234,38 @@  discard block
 block discarded – undo
3234 3234
         if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3235 3235
 
3236 3236
             $amount = $fees[ $fee ]['amount'] += $amount;
3237
-			$fees[ $fee ] = array(
3238
-				'amount'    => $amount,
3237
+            $fees[ $fee ] = array(
3238
+                'amount'    => $amount,
3239 3239
                 'recurring' => (bool) $recurring,
3240 3240
             );
3241 3241
 
3242
-		} else {
3243
-			$fees[ $fee ] = array(
3242
+        } else {
3243
+            $fees[ $fee ] = array(
3244 3244
                 'amount'    => $amount,
3245 3245
                 'recurring' => (bool) $recurring,
3246 3246
             );
3247
-		}
3247
+        }
3248 3248
 
3249 3249
         $this->set_prop( 'fees', $fee );
3250 3250
 
3251 3251
     }
3252 3252
 
3253 3253
     /**
3254
-	 * Retrieves a specific fee.
3255
-	 *
3256
-	 * @since 1.0.19
3257
-	 */
3258
-	public function get_fee( $fee ) {
3254
+     * Retrieves a specific fee.
3255
+     *
3256
+     * @since 1.0.19
3257
+     */
3258
+    public function get_fee( $fee ) {
3259 3259
         $fees = $this->get_fees();
3260
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3260
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3261 3261
     }
3262 3262
 
3263 3263
     /**
3264
-	 * Removes a specific fee.
3265
-	 *
3266
-	 * @since 1.0.19
3267
-	 */
3268
-	public function remove_fee( $fee ) {
3264
+     * Removes a specific fee.
3265
+     *
3266
+     * @since 1.0.19
3267
+     */
3268
+    public function remove_fee( $fee ) {
3269 3269
         $fees = $this->get_fees();
3270 3270
         if ( isset( $fees[ $fee ] ) ) {
3271 3271
             unset( $fees[ $fee ] );
@@ -3288,44 +3288,44 @@  discard block
 block discarded – undo
3288 3288
         if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3289 3289
 
3290 3290
             $amount = $discounts[ $discount ]['amount'] += $amount;
3291
-			$discounts[ $discount ] = array(
3291
+            $discounts[ $discount ] = array(
3292 3292
                 'amount'    => $amount,
3293 3293
                 'recurring' => (bool) $recurring,
3294 3294
             );
3295 3295
 
3296
-		} else {
3297
-			$discounts[ $discount ] = array(
3296
+        } else {
3297
+            $discounts[ $discount ] = array(
3298 3298
                 'amount'    => $amount,
3299 3299
                 'recurring' => (bool) $recurring,
3300 3300
             );
3301
-		}
3301
+        }
3302 3302
 
3303 3303
         $this->set_prop( 'discounts', $discount );
3304 3304
 
3305 3305
     }
3306 3306
 
3307 3307
     /**
3308
-	 * Retrieves a specific discount.
3309
-	 *
3310
-	 * @since 1.0.19
3311
-	 */
3312
-	public function get_discount( $discount = false ) {
3308
+     * Retrieves a specific discount.
3309
+     *
3310
+     * @since 1.0.19
3311
+     */
3312
+    public function get_discount( $discount = false ) {
3313 3313
 
3314
-		// Backwards compatibilty.
3315
-		if ( empty( $discount ) ) {
3316
-			return $this->get_total_discount();
3317
-		}
3314
+        // Backwards compatibilty.
3315
+        if ( empty( $discount ) ) {
3316
+            return $this->get_total_discount();
3317
+        }
3318 3318
 
3319 3319
         $discounts = $this->get_discounts();
3320
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3320
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3321 3321
     }
3322 3322
 
3323 3323
     /**
3324
-	 * Removes a specific discount.
3325
-	 *
3326
-	 * @since 1.0.19
3327
-	 */
3328
-	public function remove_discount( $discount ) {
3324
+     * Removes a specific discount.
3325
+     *
3326
+     * @since 1.0.19
3327
+     */
3328
+    public function remove_discount( $discount ) {
3329 3329
         $discounts = $this->get_discounts();
3330 3330
         if ( isset( $discounts[ $discount ] ) ) {
3331 3331
             unset( $discounts[ $discount ] );
@@ -3351,44 +3351,44 @@  discard block
 block discarded – undo
3351 3351
         if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3352 3352
 
3353 3353
             $amount = $taxes[ $tax ]['amount'] += $amount;
3354
-			$taxes[ $tax ] = array(
3354
+            $taxes[ $tax ] = array(
3355 3355
                 'amount'    => $amount,
3356 3356
                 'recurring' => (bool) $recurring,
3357 3357
             );
3358 3358
 
3359
-		} else {
3360
-			$taxes[ $tax ] = array(
3359
+        } else {
3360
+            $taxes[ $tax ] = array(
3361 3361
                 'amount'    => $amount,
3362 3362
                 'recurring' => (bool) $recurring,
3363 3363
             );
3364
-		}
3364
+        }
3365 3365
 
3366 3366
         $this->set_prop( 'taxes', $tax );
3367 3367
 
3368 3368
     }
3369 3369
 
3370 3370
     /**
3371
-	 * Retrieves a specific tax.
3372
-	 *
3373
-	 * @since 1.0.19
3374
-	 */
3375
-	public function get_tax( $tax = null ) {
3371
+     * Retrieves a specific tax.
3372
+     *
3373
+     * @since 1.0.19
3374
+     */
3375
+    public function get_tax( $tax = null ) {
3376 3376
 
3377
-		// Backwards compatility.
3378
-		if ( empty( $tax ) ) {
3379
-			return $this->get_total_tax();
3380
-		}
3377
+        // Backwards compatility.
3378
+        if ( empty( $tax ) ) {
3379
+            return $this->get_total_tax();
3380
+        }
3381 3381
 
3382 3382
         $taxes = $this->get_taxes();
3383
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3383
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3384 3384
     }
3385 3385
 
3386 3386
     /**
3387
-	 * Removes a specific tax.
3388
-	 *
3389
-	 * @since 1.0.19
3390
-	 */
3391
-	public function remove_tax( $tax ) {
3387
+     * Removes a specific tax.
3388
+     *
3389
+     * @since 1.0.19
3390
+     */
3391
+    public function remove_tax( $tax ) {
3392 3392
         $taxes = $this->get_discounts();
3393 3393
         if ( isset( $taxes[ $tax ] ) ) {
3394 3394
             unset( $taxes[ $tax ] );
@@ -3397,160 +3397,160 @@  discard block
 block discarded – undo
3397 3397
     }
3398 3398
 
3399 3399
     /**
3400
-	 * Recalculates the invoice subtotal.
3401
-	 *
3402
-	 * @since 1.0.19
3403
-	 * @return float The recalculated subtotal
3404
-	 */
3405
-	public function recalculate_subtotal() {
3400
+     * Recalculates the invoice subtotal.
3401
+     *
3402
+     * @since 1.0.19
3403
+     * @return float The recalculated subtotal
3404
+     */
3405
+    public function recalculate_subtotal() {
3406 3406
         $items     = $this->get_items();
3407
-		$subtotal  = 0;
3408
-		$recurring = 0;
3407
+        $subtotal  = 0;
3408
+        $recurring = 0;
3409 3409
 
3410 3410
         foreach ( $items as $item ) {
3411
-			$subtotal  += $item->get_sub_total();
3412
-			$recurring += $item->get_recurring_sub_total();
3411
+            $subtotal  += $item->get_sub_total();
3412
+            $recurring += $item->get_recurring_sub_total();
3413 3413
         }
3414 3414
 
3415
-		if ( $this->is_renewal() ) {
3416
-			$this->set_subtotal( $recurring );
3417
-		} else {
3418
-			$this->set_subtotal( $subtotal );
3419
-		}
3415
+        if ( $this->is_renewal() ) {
3416
+            $this->set_subtotal( $recurring );
3417
+        } else {
3418
+            $this->set_subtotal( $subtotal );
3419
+        }
3420 3420
 
3421
-		$this->totals['subtotal'] = array(
3422
-			'initial'   => $subtotal,
3423
-			'recurring' => $recurring,
3424
-		);
3421
+        $this->totals['subtotal'] = array(
3422
+            'initial'   => $subtotal,
3423
+            'recurring' => $recurring,
3424
+        );
3425 3425
 
3426 3426
         return $this->is_renewal() ? $recurring : $subtotal;
3427 3427
     }
3428 3428
 
3429 3429
     /**
3430
-	 * Recalculates the invoice discount total.
3431
-	 *
3432
-	 * @since 1.0.19
3433
-	 * @return float The recalculated discount
3434
-	 */
3435
-	public function recalculate_total_discount() {
3430
+     * Recalculates the invoice discount total.
3431
+     *
3432
+     * @since 1.0.19
3433
+     * @return float The recalculated discount
3434
+     */
3435
+    public function recalculate_total_discount() {
3436 3436
         $discounts = $this->get_discounts();
3437
-		$discount  = 0;
3438
-		$recurring = 0;
3437
+        $discount  = 0;
3438
+        $recurring = 0;
3439 3439
 
3440 3440
         foreach ( $discounts as $data ) {
3441 3441
 
3442
-			if ( $data['recurring'] ) {
3443
-				$recurring += $data['amount'];
3444
-			} else {
3445
-				$discount += $data['amount'];
3446
-			}
3442
+            if ( $data['recurring'] ) {
3443
+                $recurring += $data['amount'];
3444
+            } else {
3445
+                $discount += $data['amount'];
3446
+            }
3447 3447
 
3448
-		}
3448
+        }
3449 3449
 
3450
-		if ( $this->is_renewal() ) {
3451
-			$this->set_total_discount( $recurring );
3452
-		} else {
3453
-			$this->set_total_discount( $discount );
3454
-		}
3450
+        if ( $this->is_renewal() ) {
3451
+            $this->set_total_discount( $recurring );
3452
+        } else {
3453
+            $this->set_total_discount( $discount );
3454
+        }
3455 3455
 
3456
-		$this->totals['discount'] = array(
3457
-			'initial'   => $discount,
3458
-			'recurring' => $recurring,
3459
-		);
3456
+        $this->totals['discount'] = array(
3457
+            'initial'   => $discount,
3458
+            'recurring' => $recurring,
3459
+        );
3460 3460
 
3461
-		return $this->is_renewal() ? $recurring : $discount;
3461
+        return $this->is_renewal() ? $recurring : $discount;
3462 3462
 
3463 3463
     }
3464 3464
 
3465 3465
     /**
3466
-	 * Recalculates the invoice tax total.
3467
-	 *
3468
-	 * @since 1.0.19
3469
-	 * @return float The recalculated tax
3470
-	 */
3471
-	public function recalculate_total_tax() {
3466
+     * Recalculates the invoice tax total.
3467
+     *
3468
+     * @since 1.0.19
3469
+     * @return float The recalculated tax
3470
+     */
3471
+    public function recalculate_total_tax() {
3472 3472
         $taxes     = $this->get_taxes();
3473
-		$tax       = 0;
3474
-		$recurring = 0;
3473
+        $tax       = 0;
3474
+        $recurring = 0;
3475 3475
 
3476 3476
         foreach ( $taxes as $data ) {
3477 3477
 
3478
-			if ( $data['recurring'] ) {
3479
-				$recurring += $data['amount'];
3480
-			} else {
3481
-				$tax += $data['amount'];
3482
-			}
3478
+            if ( $data['recurring'] ) {
3479
+                $recurring += $data['amount'];
3480
+            } else {
3481
+                $tax += $data['amount'];
3482
+            }
3483 3483
 
3484
-		}
3484
+        }
3485 3485
 
3486
-		if ( $this->is_renewal() ) {
3487
-			$this->set_total_tax( $recurring );
3488
-		} else {
3489
-			$this->set_total_tax( $tax );
3490
-		}
3486
+        if ( $this->is_renewal() ) {
3487
+            $this->set_total_tax( $recurring );
3488
+        } else {
3489
+            $this->set_total_tax( $tax );
3490
+        }
3491 3491
 
3492
-		$this->totals['tax'] = array(
3493
-			'initial'   => $tax,
3494
-			'recurring' => $recurring,
3495
-		);
3492
+        $this->totals['tax'] = array(
3493
+            'initial'   => $tax,
3494
+            'recurring' => $recurring,
3495
+        );
3496 3496
 
3497
-		return $this->is_renewal() ? $recurring : $tax;
3497
+        return $this->is_renewal() ? $recurring : $tax;
3498 3498
 
3499 3499
     }
3500 3500
 
3501 3501
     /**
3502
-	 * Recalculates the invoice fees total.
3503
-	 *
3504
-	 * @since 1.0.19
3505
-	 * @return float The recalculated fee
3506
-	 */
3507
-	public function recalculate_total_fees() {
3508
-		$fees      = $this->get_fees();
3509
-		$fee       = 0;
3510
-		$recurring = 0;
3502
+     * Recalculates the invoice fees total.
3503
+     *
3504
+     * @since 1.0.19
3505
+     * @return float The recalculated fee
3506
+     */
3507
+    public function recalculate_total_fees() {
3508
+        $fees      = $this->get_fees();
3509
+        $fee       = 0;
3510
+        $recurring = 0;
3511 3511
 
3512 3512
         foreach ( $fees as $data ) {
3513 3513
 
3514
-			if ( $data['recurring'] ) {
3515
-				$recurring += $data['amount'];
3516
-			} else {
3517
-				$fee += $data['amount'];
3518
-			}
3514
+            if ( $data['recurring'] ) {
3515
+                $recurring += $data['amount'];
3516
+            } else {
3517
+                $fee += $data['amount'];
3518
+            }
3519 3519
 
3520
-		}
3520
+        }
3521 3521
 
3522 3522
         if ( $this->is_renewal() ) {
3523
-			$this->set_total_fees( $recurring );
3524
-		} else {
3525
-			$this->set_total_fees( $fee );
3526
-		}
3523
+            $this->set_total_fees( $recurring );
3524
+        } else {
3525
+            $this->set_total_fees( $fee );
3526
+        }
3527 3527
 
3528
-		$this->totals['fee'] = array(
3529
-			'initial'   => $fee,
3530
-			'recurring' => $recurring,
3531
-		);
3528
+        $this->totals['fee'] = array(
3529
+            'initial'   => $fee,
3530
+            'recurring' => $recurring,
3531
+        );
3532 3532
 
3533 3533
         $this->set_total_fees( $fee );
3534 3534
         return $this->is_renewal() ? $recurring : $fee;
3535 3535
     }
3536 3536
 
3537 3537
     /**
3538
-	 * Recalculates the invoice total.
3539
-	 *
3540
-	 * @since 1.0.19
3538
+     * Recalculates the invoice total.
3539
+     *
3540
+     * @since 1.0.19
3541 3541
      * @return float The invoice total
3542
-	 */
3543
-	public function recalculate_total() {
3542
+     */
3543
+    public function recalculate_total() {
3544 3544
         $this->recalculate_subtotal();
3545 3545
         $this->recalculate_total_fees();
3546 3546
         $this->recalculate_total_discount();
3547 3547
         $this->recalculate_total_tax();
3548
-		return $this->get_total();
3549
-	}
3548
+        return $this->get_total();
3549
+    }
3550 3550
 
3551
-	/**
3552
-	 * @deprecated
3553
-	 */
3551
+    /**
3552
+     * @deprecated
3553
+     */
3554 3554
     public function recalculate_totals( $temp = false ) {
3555 3555
         $this->update_items( $temp );
3556 3556
         $this->save( true );
@@ -3568,7 +3568,7 @@  discard block
 block discarded – undo
3568 3568
      * Adds a note to an invoice.
3569 3569
      *
3570 3570
      * @param string $note The note being added.
3571
-	 * @return int|false The new note's ID on success, false on failure.
3571
+     * @return int|false The new note's ID on success, false on failure.
3572 3572
      *
3573 3573
      */
3574 3574
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3578,23 +3578,23 @@  discard block
 block discarded – undo
3578 3578
             return false;
3579 3579
         }
3580 3580
 
3581
-		// If this is an admin comment or it has been added by the user.
3582
-		if ( is_user_logged_in() && ( wpinv_current_user_can_manage_invoicing() || $added_by_user ) ) {
3583
-			$user         = get_user_by( 'id', get_current_user_id() );
3581
+        // If this is an admin comment or it has been added by the user.
3582
+        if ( is_user_logged_in() && ( wpinv_current_user_can_manage_invoicing() || $added_by_user ) ) {
3583
+            $user         = get_user_by( 'id', get_current_user_id() );
3584 3584
             $author       = $user->display_name;
3585 3585
             $author_email = $user->user_email;
3586
-		} 
3586
+        } 
3587 3587
 
3588
-		if ( $system ) {
3589
-			$author       = 'System';
3588
+        if ( $system ) {
3589
+            $author       = 'System';
3590 3590
             $author_email = '[email protected]';
3591
-		}
3591
+        }
3592 3592
 
3593
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3593
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3594 3594
 
3595
-	}
3595
+    }
3596 3596
 
3597
-	/**
3597
+    /**
3598 3598
      * Generates a unique key for the invoice.
3599 3599
      */
3600 3600
     public function generate_key( $string = '' ) {
@@ -3614,105 +3614,105 @@  discard block
 block discarded – undo
3614 3614
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3615 3615
         }
3616 3616
 
3617
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3617
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3618 3618
 
3619
-	}
3619
+    }
3620 3620
 
3621
-	/**
3622
-	 * Handle the status transition.
3623
-	 */
3624
-	protected function status_transition() {
3625
-		$status_transition = $this->status_transition;
3621
+    /**
3622
+     * Handle the status transition.
3623
+     */
3624
+    protected function status_transition() {
3625
+        $status_transition = $this->status_transition;
3626 3626
 
3627
-		// Reset status transition variable.
3628
-		$this->status_transition = false;
3627
+        // Reset status transition variable.
3628
+        $this->status_transition = false;
3629 3629
 
3630
-		if ( $status_transition ) {
3631
-			try {
3630
+        if ( $status_transition ) {
3631
+            try {
3632 3632
 
3633
-				// Fire a hook for the status change.
3634
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3633
+                // Fire a hook for the status change.
3634
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3635 3635
 
3636
-				// @deprecated this is deprecated and will be removed in the future.
3637
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3636
+                // @deprecated this is deprecated and will be removed in the future.
3637
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3638 3638
 
3639
-				if ( ! empty( $status_transition['from'] ) ) {
3639
+                if ( ! empty( $status_transition['from'] ) ) {
3640 3640
 
3641
-					/* translators: 1: old invoice status 2: new invoice status */
3642
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3641
+                    /* translators: 1: old invoice status 2: new invoice status */
3642
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3643 3643
 
3644
-					// Fire another hook.
3645
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3646
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3644
+                    // Fire another hook.
3645
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3646
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3647 3647
 
3648
-					// @deprecated this is deprecated and will be removed in the future.
3649
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3648
+                    // @deprecated this is deprecated and will be removed in the future.
3649
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3650 3650
 
3651
-					// Note the transition occurred.
3652
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3651
+                    // Note the transition occurred.
3652
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3653 3653
 
3654
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3655
-					if (
3656
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3657
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3658
-					) {
3659
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3660
-					}
3661
-				} else {
3662
-					/* translators: %s: new invoice status */
3663
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3654
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3655
+                    if (
3656
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3657
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3658
+                    ) {
3659
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3660
+                    }
3661
+                } else {
3662
+                    /* translators: %s: new invoice status */
3663
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3664 3664
 
3665
-					// Note the transition occurred.
3666
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3665
+                    // Note the transition occurred.
3666
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3667 3667
 
3668
-				}
3669
-			} catch ( Exception $e ) {
3670
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3671
-			}
3672
-		}
3673
-	}
3668
+                }
3669
+            } catch ( Exception $e ) {
3670
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3671
+            }
3672
+        }
3673
+    }
3674 3674
 
3675
-	/**
3676
-	 * Updates an invoice status.
3677
-	 */
3678
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3675
+    /**
3676
+     * Updates an invoice status.
3677
+     */
3678
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3679 3679
 
3680
-		// Fires before updating a status.
3681
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3680
+        // Fires before updating a status.
3681
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3682 3682
 
3683
-		// Update the status.
3684
-		$this->set_status( $new_status, $note, $manual );
3683
+        // Update the status.
3684
+        $this->set_status( $new_status, $note, $manual );
3685 3685
 
3686
-		// Save the order.
3687
-		return $this->save();
3686
+        // Save the order.
3687
+        return $this->save();
3688 3688
 
3689
-	}
3689
+    }
3690 3690
 
3691
-	/**
3692
-	 * @deprecated
3693
-	 */
3694
-	public function refresh_item_ids() {
3691
+    /**
3692
+     * @deprecated
3693
+     */
3694
+    public function refresh_item_ids() {
3695 3695
         $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3696 3696
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3697
-	}
3697
+    }
3698 3698
 
3699
-	/**
3700
-	 * @deprecated
3701
-	 */
3702
-	public function update_items( $temp = false ) {
3699
+    /**
3700
+     * @deprecated
3701
+     */
3702
+    public function update_items( $temp = false ) {
3703 3703
 
3704
-		$this->set_items( $this->get_items() );
3704
+        $this->set_items( $this->get_items() );
3705 3705
 
3706
-		if ( ! $temp ) {
3707
-			$this->save();
3708
-		}
3706
+        if ( ! $temp ) {
3707
+            $this->save();
3708
+        }
3709 3709
 
3710 3710
         return $this;
3711
-	}
3711
+    }
3712 3712
 
3713
-	/**
3714
-	 * @deprecated
3715
-	 */
3713
+    /**
3714
+     * @deprecated
3715
+     */
3716 3716
     public function validate_discount() {
3717 3717
 
3718 3718
         $discount_code = $this->get_discount_code();
@@ -3728,97 +3728,97 @@  discard block
 block discarded – undo
3728 3728
 
3729 3729
     }
3730 3730
 
3731
-	/**
3732
-	 * Refunds an invoice.
3733
-	 */
3731
+    /**
3732
+     * Refunds an invoice.
3733
+     */
3734 3734
     public function refund() {
3735
-		$this->set_status( 'wpi-refunded' );
3735
+        $this->set_status( 'wpi-refunded' );
3736 3736
         $this->save();
3737
-	}
3737
+    }
3738 3738
 
3739
-	/**
3740
-	 * Marks an invoice as paid.
3741
-	 * 
3742
-	 * @param string $transaction_id
3743
-	 */
3739
+    /**
3740
+     * Marks an invoice as paid.
3741
+     * 
3742
+     * @param string $transaction_id
3743
+     */
3744 3744
     public function mark_paid( $transaction_id = null, $note = '' ) {
3745 3745
 
3746
-		// Set the transaction id.
3747
-		if ( empty( $transaction_id ) ) {
3748
-			$transaction_id = $this->generate_key('trans_');
3749
-		}
3746
+        // Set the transaction id.
3747
+        if ( empty( $transaction_id ) ) {
3748
+            $transaction_id = $this->generate_key('trans_');
3749
+        }
3750 3750
 
3751
-		if ( ! $this->get_transaction_id() ) {
3752
-			$this->set_transaction_id( $transaction_id );
3753
-		}
3751
+        if ( ! $this->get_transaction_id() ) {
3752
+            $this->set_transaction_id( $transaction_id );
3753
+        }
3754 3754
 
3755
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3756
-			return $this->save();
3757
-		}
3755
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3756
+            return $this->save();
3757
+        }
3758 3758
 
3759
-		// Set the completed date.
3760
-		$this->set_date_completed( current_time( 'mysql' ) );
3759
+        // Set the completed date.
3760
+        $this->set_date_completed( current_time( 'mysql' ) );
3761 3761
 
3762
-		// Set the new status.
3763
-		if ( $this->is_renewal() ) {
3762
+        // Set the new status.
3763
+        if ( $this->is_renewal() ) {
3764 3764
 
3765
-			$_note = sprintf(
3766
-				__( 'Renewed via %s', 'invoicing' ),
3767
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3768
-			);
3765
+            $_note = sprintf(
3766
+                __( 'Renewed via %s', 'invoicing' ),
3767
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3768
+            );
3769 3769
 
3770
-			if ( 'none' == $this->get_gateway() ) {
3771
-				$_note = $note;
3772
-			}
3770
+            if ( 'none' == $this->get_gateway() ) {
3771
+                $_note = $note;
3772
+            }
3773 3773
 
3774
-			$this->set_status( 'wpi-renewal', $_note );
3774
+            $this->set_status( 'wpi-renewal', $_note );
3775 3775
 
3776
-		} else {
3776
+        } else {
3777 3777
 
3778
-			$_note = sprintf(
3779
-				__( 'Paid via %s', 'invoicing' ),
3780
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3781
-			);
3778
+            $_note = sprintf(
3779
+                __( 'Paid via %s', 'invoicing' ),
3780
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3781
+            );
3782 3782
 
3783
-			if ( 'none' == $this->get_gateway() ) {
3784
-				$_note = $note;
3785
-			}
3783
+            if ( 'none' == $this->get_gateway() ) {
3784
+                $_note = $note;
3785
+            }
3786 3786
 
3787
-			$this->set_status( 'publish',$_note );
3787
+            $this->set_status( 'publish',$_note );
3788 3788
 
3789
-		}
3789
+        }
3790 3790
 
3791
-		// Set checkout mode.
3792
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3793
-		$this->set_mode( $mode );
3791
+        // Set checkout mode.
3792
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3793
+        $this->set_mode( $mode );
3794 3794
 
3795
-		// Save the invoice.
3795
+        // Save the invoice.
3796 3796
         $this->save();
3797
-	}
3798
-
3799
-
3800
-	/**
3801
-	 * Save data to the database.
3802
-	 *
3803
-	 * @since 1.0.19
3804
-	 * @return int invoice ID
3805
-	 */
3806
-	public function save() {
3807
-		$this->maybe_set_date_paid();
3808
-		$this->maybe_set_key();
3809
-		parent::save();
3810
-		$this->clear_cache();
3811
-		$this->status_transition();
3812
-		return $this->get_id();
3813
-	}
3814
-
3815
-	/**
3797
+    }
3798
+
3799
+
3800
+    /**
3801
+     * Save data to the database.
3802
+     *
3803
+     * @since 1.0.19
3804
+     * @return int invoice ID
3805
+     */
3806
+    public function save() {
3807
+        $this->maybe_set_date_paid();
3808
+        $this->maybe_set_key();
3809
+        parent::save();
3810
+        $this->clear_cache();
3811
+        $this->status_transition();
3812
+        return $this->get_id();
3813
+    }
3814
+
3815
+    /**
3816 3816
      * Clears the subscription's cache.
3817 3817
      */
3818 3818
     public function clear_cache() {
3819
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3820
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3821
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3822
-	}
3819
+        wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3820
+        wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3821
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3822
+    }
3823 3823
 
3824 3824
 }
Please login to merge, or discard this patch.
includes/admin/class-getpaid-metaboxes.php 1 patch
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -12,181 +12,181 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Metaboxes {
14 14
 
15
-	/**
16
-	 * Only save metaboxes once.
17
-	 *
18
-	 * @var boolean
19
-	 */
20
-	private static $saved_meta_boxes = false;
21
-
22 15
     /**
23
-	 * Hook in methods.
24
-	 */
25
-	public static function init() {
26
-
27
-		// Register metaboxes.
28
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 );
29
-
30
-		// Remove metaboxes.
31
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
16
+     * Only save metaboxes once.
17
+     *
18
+     * @var boolean
19
+     */
20
+    private static $saved_meta_boxes = false;
32 21
 
33
-		// Rename metaboxes.
34
-		add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
35
-
36
-		// Save metaboxes.
37
-		add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
38
-	}
22
+    /**
23
+     * Hook in methods.
24
+     */
25
+    public static function init() {
39 26
 
40
-	/**
41
-	 * Register core metaboxes.
42
-	 */
43
-	public static function add_meta_boxes( $post_type, $post ) {
44
-		global $wpinv_euvat;
27
+        // Register metaboxes.
28
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::add_meta_boxes', 5, 2 );
45 29
 
46
-		// For invoices...
47
-		if ( $post_type == 'wpi_invoice' ) {
48
-			$invoice = new WPInv_Invoice( $post );
30
+        // Remove metaboxes.
31
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::remove_meta_boxes', 30 );
49 32
 
50
-			// Resend invoice.
51
-			if ( ! $invoice->is_draft() ) {
52
-				add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'GetPaid_Meta_Box_Resend_Invoice::output', 'wpi_invoice', 'side', 'low' );
53
-			}
33
+        // Rename metaboxes.
34
+        add_action( 'add_meta_boxes', 'GetPaid_Metaboxes::rename_meta_boxes', 45 );
54 35
 
55
-			// Subscriptions.
56
-			if ( $invoice->is_recurring() ) {
57
-				add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', 'wpi_invoice', 'side', 'high' );
58
-			}
36
+        // Save metaboxes.
37
+        add_action( 'save_post', 'GetPaid_Metaboxes::save_meta_boxes', 1, 2 );
38
+    }
59 39
 
60
-			// Invoice details.
61
-			add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default' );
40
+    /**
41
+     * Register core metaboxes.
42
+     */
43
+    public static function add_meta_boxes( $post_type, $post ) {
44
+        global $wpinv_euvat;
45
+
46
+        // For invoices...
47
+        if ( $post_type == 'wpi_invoice' ) {
48
+            $invoice = new WPInv_Invoice( $post );
49
+
50
+            // Resend invoice.
51
+            if ( ! $invoice->is_draft() ) {
52
+                add_meta_box( 'wpinv-mb-resend-invoice', __( 'Resend Invoice', 'invoicing' ), 'GetPaid_Meta_Box_Resend_Invoice::output', 'wpi_invoice', 'side', 'low' );
53
+            }
54
+
55
+            // Subscriptions.
56
+            if ( $invoice->is_recurring() ) {
57
+                add_meta_box( 'wpinv-mb-subscriptions', __( 'Subscription Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Subscription::output', 'wpi_invoice', 'side', 'high' );
58
+            }
59
+
60
+            // Invoice details.
61
+            add_meta_box( 'wpinv-details', __( 'Invoice Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Details::output', 'wpi_invoice', 'side', 'default' );
62 62
 			
63
-			// Payment details.
64
-			add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default' );
63
+            // Payment details.
64
+            add_meta_box( 'wpinv-payment-meta', __( 'Payment Meta', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Payment_Meta::output', 'wpi_invoice', 'side', 'default' );
65 65
 
66
-			// Billing details.
67
-			add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high' );
66
+            // Billing details.
67
+            add_meta_box( 'wpinv-address', __( 'Billing Details', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Address::output', 'wpi_invoice', 'normal', 'high' );
68 68
 			
69
-			// Invoice items.
70
-			add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high' );
69
+            // Invoice items.
70
+            add_meta_box( 'wpinv-items', __( 'Invoice Items', 'invoicing' ), 'GetPaid_Meta_Box_Invoice_Items::output', 'wpi_invoice', 'normal', 'high' );
71 71
 			
72
-			// Invoice notes.
73
-			add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
72
+            // Invoice notes.
73
+            add_meta_box( 'wpinv-notes', __( 'Invoice Notes', 'invoicing' ), 'WPInv_Meta_Box_Notes::output', 'wpi_invoice', 'normal', 'high' );
74 74
 
75
-			// Payment form information.
76
-			if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
77
-				add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' );
78
-			}
79
-		}
75
+            // Payment form information.
76
+            if ( ! empty( $post->ID ) && get_post_meta( $post->ID, 'payment_form_data', true ) ) {
77
+                add_meta_box( 'wpinv-invoice-payment-form-details', __( 'Payment Form Details', 'invoicing' ), 'WPInv_Meta_Box_Payment_Form::output_details', 'wpi_invoice', 'side', 'high' );
78
+            }
79
+        }
80 80
 
81
-		// For payment forms.
82
-		if ( $post_type == 'wpi_payment_form' ) {
81
+        // For payment forms.
82
+        if ( $post_type == 'wpi_payment_form' ) {
83 83
 
84
-			// Design payment form.
85
-			add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
84
+            // Design payment form.
85
+            add_meta_box( 'wpinv-payment-form-design', __( 'Payment Form', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form::output', 'wpi_payment_form', 'normal' );
86 86
 
87
-			// Payment form information.
88
-			add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
87
+            // Payment form information.
88
+            add_meta_box( 'wpinv-payment-form-info', __( 'Details', 'invoicing' ), 'GetPaid_Meta_Box_Payment_Form_Info::output', 'wpi_payment_form', 'side' );
89 89
 
90
-		}
90
+        }
91 91
 
92
-		// For invoice items.
93
-		if ( $post_type == 'wpi_item' ) {
92
+        // For invoice items.
93
+        if ( $post_type == 'wpi_item' ) {
94 94
 
95
-			// Item details.
96
-			add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
95
+            // Item details.
96
+            add_meta_box( 'wpinv_item_details', __( 'Item Details', 'invoicing' ), 'GetPaid_Meta_Box_Item_Details::output', 'wpi_item', 'normal', 'high' );
97 97
 
98
-			// If taxes are enabled, register the tax metabox.
99
-			if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) {
100
-				add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
101
-			}
98
+            // If taxes are enabled, register the tax metabox.
99
+            if ( $wpinv_euvat->allow_vat_rules() || $wpinv_euvat->allow_vat_classes() ) {
100
+                add_meta_box( 'wpinv_item_vat', __( 'VAT / Tax', 'invoicing' ), 'GetPaid_Meta_Box_Item_VAT::output', 'wpi_item', 'normal', 'high' );
101
+            }
102 102
 
103
-			// Item info.
104
-			add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
103
+            // Item info.
104
+            add_meta_box( 'wpinv_field_item_info', __( 'Item info', 'invoicing' ), 'GetPaid_Meta_Box_Item_Info::output', 'wpi_item', 'side', 'core' );
105 105
 
106
-		}
106
+        }
107 107
 
108
-		// For invoice discounts.
109
-		if ( $post_type == 'wpi_discount' ) {
110
-			add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
111
-		}
108
+        // For invoice discounts.
109
+        if ( $post_type == 'wpi_discount' ) {
110
+            add_meta_box( 'wpinv_discount_details', __( 'Discount Details', 'invoicing' ), 'GetPaid_Meta_Box_Discount_Details::output', 'wpi_discount', 'normal', 'high' );
111
+        }
112 112
 		
113 113
 
114
-	}
114
+    }
115 115
 
116
-	/**
117
-	 * Remove some metaboxes.
118
-	 */
119
-	public static function remove_meta_boxes() {
120
-		remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
121
-	}
116
+    /**
117
+     * Remove some metaboxes.
118
+     */
119
+    public static function remove_meta_boxes() {
120
+        remove_meta_box( 'wpseo_meta', 'wpi_invoice', 'normal' );
121
+    }
122 122
 
123
-	/**
124
-	 * Rename other metaboxes.
125
-	 */
126
-	public static function rename_meta_boxes() {
123
+    /**
124
+     * Rename other metaboxes.
125
+     */
126
+    public static function rename_meta_boxes() {
127 127
 		
128
-	}
129
-
130
-	/**
131
-	 * Check if we're saving, then trigger an action based on the post type.
132
-	 *
133
-	 * @param  int    $post_id Post ID.
134
-	 * @param  object $post Post object.
135
-	 */
136
-	public static function save_meta_boxes( $post_id, $post ) {
137
-		$post_id = absint( $post_id );
138
-
139
-		// Do not save for ajax requests.
140
-		if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
141
-			return;
142
-		}
143
-
144
-		// $post_id and $post are required
145
-		if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
146
-			return;
147
-		}
148
-
149
-		// Dont' save meta boxes for revisions or autosaves.
150
-		if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
151
-			return;
152
-		}
153
-
154
-		// Check the nonce.
155
-		if ( empty( $_POST['getpaid_meta_nonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['getpaid_meta_nonce'] ), 'getpaid_meta_nonce' ) ) {
156
-			return;
157
-		}
158
-
159
-		// Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
160
-		if ( empty( $_POST['post_ID'] ) || absint( $_POST['post_ID'] ) !== $post_id ) {
161
-			return;
162
-		}
163
-
164
-		// Check user has permission to edit.
165
-		if ( ! current_user_can( 'edit_post', $post_id ) ) {
166
-			return;
167
-		}
168
-
169
-		// Ensure this is our post type.
170
-		$post_types_map = array(
171
-			'wpi_invoice'      => 'GetPaid_Meta_Box_Invoice_Address',
172
-			'wpi_quote'        => 'GetPaid_Meta_Box_Invoice_Address',
173
-			'wpi_item'         => 'GetPaid_Meta_Box_Item_Details',
174
-			'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form',
175
-			'wpi_discount'     => 'GetPaid_Meta_Box_Discount_Details',
176
-		);
177
-
178
-		// Is this our post type?
179
-		if ( empty( $post->post_type ) || ! isset( $post_types_map[ $post->post_type ] ) ) {
180
-			return;
181
-		}
182
-
183
-		// We need this save event to run once to avoid potential endless loops.
184
-		self::$saved_meta_boxes = true;
128
+    }
129
+
130
+    /**
131
+     * Check if we're saving, then trigger an action based on the post type.
132
+     *
133
+     * @param  int    $post_id Post ID.
134
+     * @param  object $post Post object.
135
+     */
136
+    public static function save_meta_boxes( $post_id, $post ) {
137
+        $post_id = absint( $post_id );
138
+
139
+        // Do not save for ajax requests.
140
+        if ( ( defined( 'DOING_AJAX') && DOING_AJAX ) || isset( $_REQUEST['bulk_edit'] ) ) {
141
+            return;
142
+        }
143
+
144
+        // $post_id and $post are required
145
+        if ( empty( $post_id ) || empty( $post ) || self::$saved_meta_boxes ) {
146
+            return;
147
+        }
148
+
149
+        // Dont' save meta boxes for revisions or autosaves.
150
+        if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || is_int( wp_is_post_revision( $post ) ) || is_int( wp_is_post_autosave( $post ) ) ) {
151
+            return;
152
+        }
153
+
154
+        // Check the nonce.
155
+        if ( empty( $_POST['getpaid_meta_nonce'] ) || ! wp_verify_nonce( wp_unslash( $_POST['getpaid_meta_nonce'] ), 'getpaid_meta_nonce' ) ) {
156
+            return;
157
+        }
158
+
159
+        // Check the post being saved == the $post_id to prevent triggering this call for other save_post events.
160
+        if ( empty( $_POST['post_ID'] ) || absint( $_POST['post_ID'] ) !== $post_id ) {
161
+            return;
162
+        }
163
+
164
+        // Check user has permission to edit.
165
+        if ( ! current_user_can( 'edit_post', $post_id ) ) {
166
+            return;
167
+        }
168
+
169
+        // Ensure this is our post type.
170
+        $post_types_map = array(
171
+            'wpi_invoice'      => 'GetPaid_Meta_Box_Invoice_Address',
172
+            'wpi_quote'        => 'GetPaid_Meta_Box_Invoice_Address',
173
+            'wpi_item'         => 'GetPaid_Meta_Box_Item_Details',
174
+            'wpi_payment_form' => 'GetPaid_Meta_Box_Payment_Form',
175
+            'wpi_discount'     => 'GetPaid_Meta_Box_Discount_Details',
176
+        );
177
+
178
+        // Is this our post type?
179
+        if ( empty( $post->post_type ) || ! isset( $post_types_map[ $post->post_type ] ) ) {
180
+            return;
181
+        }
182
+
183
+        // We need this save event to run once to avoid potential endless loops.
184
+        self::$saved_meta_boxes = true;
185 185
 		
186
-		// Save the post.
187
-		$class = $post_types_map[ $post->post_type ];
188
-		$class::save( $post_id, $_POST, $post );
186
+        // Save the post.
187
+        $class = $post_types_map[ $post->post_type ];
188
+        $class::save( $post_id, $_POST, $post );
189 189
 
190
-	}
190
+    }
191 191
 
192 192
 }
Please login to merge, or discard this patch.
includes/class-getpaid-payment-form.php 1 patch
Indentation   +519 added lines, -519 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,55 +10,55 @@  discard block
 block discarded – undo
10 10
 class GetPaid_Payment_Form 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 = 'payment_form';
18 18
 
19 19
     /**
20
-	 * This is the name of this object type.
21
-	 *
22
-	 * @var string
23
-	 */
24
-	protected $object_type = 'payment_form';
20
+     * This is the name of this object type.
21
+     *
22
+     * @var string
23
+     */
24
+    protected $object_type = 'payment_form';
25 25
 
26 26
     /**
27
-	 * Form Data array. This is the core form data exposed in APIs.
28
-	 *
29
-	 * @since 1.0.19
30
-	 * @var array
31
-	 */
32
-	protected $data = array(
33
-		'status'               => 'draft',
34
-		'version'              => '',
35
-		'date_created'         => null,
27
+     * Form Data array. This is the core form data exposed in APIs.
28
+     *
29
+     * @since 1.0.19
30
+     * @var array
31
+     */
32
+    protected $data = array(
33
+        'status'               => 'draft',
34
+        'version'              => '',
35
+        'date_created'         => null,
36 36
         'date_modified'        => null,
37 37
         'name'                 => '',
38 38
         'author'               => 1,
39 39
         'elements'             => null,
40
-		'items'                => null,
41
-		'earned'               => 0,
42
-		'refunded'             => 0,
43
-		'cancelled'            => 0,
44
-		'failed'               => 0,
45
-	);
46
-
47
-    /**
48
-	 * Stores meta in cache for future reads.
49
-	 *
50
-	 * A group must be set to to enable caching.
51
-	 *
52
-	 * @var string
53
-	 */
54
-	protected $cache_group = 'getpaid_forms';
55
-
56
-	/**
57
-	 * Stores a reference to the invoice if the form is for an invoice..
58
-	 *
59
-	 * @var WPInv_Invoice
60
-	 */
61
-	public $invoice = 0;
40
+        'items'                => null,
41
+        'earned'               => 0,
42
+        'refunded'             => 0,
43
+        'cancelled'            => 0,
44
+        'failed'               => 0,
45
+    );
46
+
47
+    /**
48
+     * Stores meta in cache for future reads.
49
+     *
50
+     * A group must be set to to enable caching.
51
+     *
52
+     * @var string
53
+     */
54
+    protected $cache_group = 'getpaid_forms';
55
+
56
+    /**
57
+     * Stores a reference to the invoice if the form is for an invoice..
58
+     *
59
+     * @var WPInv_Invoice
60
+     */
61
+    public $invoice = 0;
62 62
 
63 63
     /**
64 64
      * Stores a reference to the original WP_Post object
@@ -68,35 +68,35 @@  discard block
 block discarded – undo
68 68
     protected $post = null;
69 69
 
70 70
     /**
71
-	 * Get the form if ID is passed, otherwise the form is new and empty.
72
-	 *
73
-	 * @param  int|object|GetPaid_Payment_Form|WP_Post $form Form to read.
74
-	 */
75
-	public function __construct( $form = 0 ) {
76
-		parent::__construct( $form );
71
+     * Get the form if ID is passed, otherwise the form is new and empty.
72
+     *
73
+     * @param  int|object|GetPaid_Payment_Form|WP_Post $form Form to read.
74
+     */
75
+    public function __construct( $form = 0 ) {
76
+        parent::__construct( $form );
77 77
 
78
-		if ( is_numeric( $form ) && $form > 0 ) {
79
-			$this->set_id( $form );
80
-		} elseif ( $form instanceof self ) {
78
+        if ( is_numeric( $form ) && $form > 0 ) {
79
+            $this->set_id( $form );
80
+        } elseif ( $form instanceof self ) {
81 81
 
82
-			$this->set_id( $form->get_id() );
83
-			$this->invoice = $form->invoice;
82
+            $this->set_id( $form->get_id() );
83
+            $this->invoice = $form->invoice;
84 84
 
85
-		} elseif ( ! empty( $form->ID ) ) {
86
-			$this->set_id( $form->ID );
87
-		} else {
88
-			$this->set_object_read( true );
89
-		}
85
+        } elseif ( ! empty( $form->ID ) ) {
86
+            $this->set_id( $form->ID );
87
+        } else {
88
+            $this->set_object_read( true );
89
+        }
90 90
 
91 91
         // Load the datastore.
92
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
92
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
93 93
 
94
-		if ( $this->get_id() > 0 ) {
94
+        if ( $this->get_id() > 0 ) {
95 95
             $this->post = get_post( $this->get_id() );
96
-			$this->data_store->read( $this );
96
+            $this->data_store->read( $this );
97 97
         }
98 98
 
99
-	}
99
+    }
100 100
 
101 101
     /*
102 102
 	|--------------------------------------------------------------------------
@@ -114,349 +114,349 @@  discard block
 block discarded – undo
114 114
     */
115 115
 
116 116
     /**
117
-	 * Get plugin version when the form was created.
118
-	 *
119
-	 * @since 1.0.19
120
-	 * @param  string $context View or edit context.
121
-	 * @return string
122
-	 */
123
-	public function get_version( $context = 'view' ) {
124
-		return $this->get_prop( 'version', $context );
117
+     * Get plugin version when the form was created.
118
+     *
119
+     * @since 1.0.19
120
+     * @param  string $context View or edit context.
121
+     * @return string
122
+     */
123
+    public function get_version( $context = 'view' ) {
124
+        return $this->get_prop( 'version', $context );
125 125
     }
126 126
 
127 127
     /**
128
-	 * Get date when the form was created.
129
-	 *
130
-	 * @since 1.0.19
131
-	 * @param  string $context View or edit context.
132
-	 * @return string
133
-	 */
134
-	public function get_date_created( $context = 'view' ) {
135
-		return $this->get_prop( 'date_created', $context );
128
+     * Get date when the form was created.
129
+     *
130
+     * @since 1.0.19
131
+     * @param  string $context View or edit context.
132
+     * @return string
133
+     */
134
+    public function get_date_created( $context = 'view' ) {
135
+        return $this->get_prop( 'date_created', $context );
136 136
     }
137 137
 
138 138
     /**
139
-	 * Get GMT date when the form was created.
140
-	 *
141
-	 * @since 1.0.19
142
-	 * @param  string $context View or edit context.
143
-	 * @return string
144
-	 */
145
-	public function get_date_created_gmt( $context = 'view' ) {
139
+     * Get GMT date when the form was created.
140
+     *
141
+     * @since 1.0.19
142
+     * @param  string $context View or edit context.
143
+     * @return string
144
+     */
145
+    public function get_date_created_gmt( $context = 'view' ) {
146 146
         $date = $this->get_date_created( $context );
147 147
 
148 148
         if ( $date ) {
149 149
             $date = get_gmt_from_date( $date );
150 150
         }
151
-		return $date;
151
+        return $date;
152 152
     }
153 153
 
154 154
     /**
155
-	 * Get date when the form was last modified.
156
-	 *
157
-	 * @since 1.0.19
158
-	 * @param  string $context View or edit context.
159
-	 * @return string
160
-	 */
161
-	public function get_date_modified( $context = 'view' ) {
162
-		return $this->get_prop( 'date_modified', $context );
155
+     * Get date when the form was last modified.
156
+     *
157
+     * @since 1.0.19
158
+     * @param  string $context View or edit context.
159
+     * @return string
160
+     */
161
+    public function get_date_modified( $context = 'view' ) {
162
+        return $this->get_prop( 'date_modified', $context );
163 163
     }
164 164
 
165 165
     /**
166
-	 * Get GMT date when the form was last modified.
167
-	 *
168
-	 * @since 1.0.19
169
-	 * @param  string $context View or edit context.
170
-	 * @return string
171
-	 */
172
-	public function get_date_modified_gmt( $context = 'view' ) {
166
+     * Get GMT date when the form was last modified.
167
+     *
168
+     * @since 1.0.19
169
+     * @param  string $context View or edit context.
170
+     * @return string
171
+     */
172
+    public function get_date_modified_gmt( $context = 'view' ) {
173 173
         $date = $this->get_date_modified( $context );
174 174
 
175 175
         if ( $date ) {
176 176
             $date = get_gmt_from_date( $date );
177 177
         }
178
-		return $date;
178
+        return $date;
179 179
     }
180 180
 
181 181
     /**
182
-	 * Get the form name.
183
-	 *
184
-	 * @since 1.0.19
185
-	 * @param  string $context View or edit context.
186
-	 * @return string
187
-	 */
188
-	public function get_name( $context = 'view' ) {
189
-		return $this->get_prop( 'name', $context );
182
+     * Get the form name.
183
+     *
184
+     * @since 1.0.19
185
+     * @param  string $context View or edit context.
186
+     * @return string
187
+     */
188
+    public function get_name( $context = 'view' ) {
189
+        return $this->get_prop( 'name', $context );
190 190
     }
191 191
 
192 192
     /**
193
-	 * Alias of self::get_name().
194
-	 *
195
-	 * @since 1.0.19
196
-	 * @param  string $context View or edit context.
197
-	 * @return string
198
-	 */
199
-	public function get_title( $context = 'view' ) {
200
-		return $this->get_name( $context );
201
-	}
193
+     * Alias of self::get_name().
194
+     *
195
+     * @since 1.0.19
196
+     * @param  string $context View or edit context.
197
+     * @return string
198
+     */
199
+    public function get_title( $context = 'view' ) {
200
+        return $this->get_name( $context );
201
+    }
202 202
 
203 203
     /**
204
-	 * Get the owner of the form.
205
-	 *
206
-	 * @since 1.0.19
207
-	 * @param  string $context View or edit context.
208
-	 * @return int
209
-	 */
210
-	public function get_author( $context = 'view' ) {
211
-		return (int) $this->get_prop( 'author', $context );
204
+     * Get the owner of the form.
205
+     *
206
+     * @since 1.0.19
207
+     * @param  string $context View or edit context.
208
+     * @return int
209
+     */
210
+    public function get_author( $context = 'view' ) {
211
+        return (int) $this->get_prop( 'author', $context );
212 212
     }
213 213
 
214 214
     /**
215
-	 * Get the elements that make up the form.
216
-	 *
217
-	 * @since 1.0.19
218
-	 * @param  string $context View or edit context.
219
-	 * @return array
220
-	 */
221
-	public function get_elements( $context = 'view' ) {
222
-		$elements = $this->get_prop( 'elements', $context );
215
+     * Get the elements that make up the form.
216
+     *
217
+     * @since 1.0.19
218
+     * @param  string $context View or edit context.
219
+     * @return array
220
+     */
221
+    public function get_elements( $context = 'view' ) {
222
+        $elements = $this->get_prop( 'elements', $context );
223 223
 
224
-		if ( empty( $elements ) || ! is_array( $elements ) ) {
224
+        if ( empty( $elements ) || ! is_array( $elements ) ) {
225 225
             return wpinv_get_data( 'sample-payment-form' );
226
-		}
226
+        }
227 227
 
228
-		// Ensure that all required elements exist.
229
-		$_elements = array();
230
-		foreach ( $elements as $element ) {
228
+        // Ensure that all required elements exist.
229
+        $_elements = array();
230
+        foreach ( $elements as $element ) {
231 231
 
232
-			if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) {
232
+            if ( $element['type'] == 'pay_button' && ! $this->has_element_type( 'gateway_select' ) ) {
233 233
 
234
-				$_elements[] = array(
235
-					'text'        => __( 'Select Payment Method', 'invoicing' ),
236
-					'id'          => 'gtscicd',
237
-					'name'        => 'gtscicd',
238
-					'type'        => 'gateway_select',
239
-					'premade'     => true
234
+                $_elements[] = array(
235
+                    'text'        => __( 'Select Payment Method', 'invoicing' ),
236
+                    'id'          => 'gtscicd',
237
+                    'name'        => 'gtscicd',
238
+                    'type'        => 'gateway_select',
239
+                    'premade'     => true
240 240
 			
241
-				);
241
+                );
242 242
 
243
-			}
243
+            }
244 244
 
245
-			$_elements[] = $element;
245
+            $_elements[] = $element;
246 246
 
247
-		}
247
+        }
248 248
 
249 249
         return $_elements;
250
-	}
251
-
252
-	/**
253
-	 * Get the items sold via the form.
254
-	 *
255
-	 * @since 1.0.19
256
-	 * @param  string $context View or edit context.
257
-	 * @param  string $return objects or arrays.
258
-	 * @return GetPaid_Form_Item[]
259
-	 */
260
-	public function get_items( $context = 'view', $return = 'objects' ) {
261
-		$items = $this->get_prop( 'items', $context );
262
-
263
-		if ( empty( $items ) || ! is_array( $items ) ) {
250
+    }
251
+
252
+    /**
253
+     * Get the items sold via the form.
254
+     *
255
+     * @since 1.0.19
256
+     * @param  string $context View or edit context.
257
+     * @param  string $return objects or arrays.
258
+     * @return GetPaid_Form_Item[]
259
+     */
260
+    public function get_items( $context = 'view', $return = 'objects' ) {
261
+        $items = $this->get_prop( 'items', $context );
262
+
263
+        if ( empty( $items ) || ! is_array( $items ) ) {
264 264
             $items = wpinv_get_data( 'sample-payment-form-items' );
265
-		}
265
+        }
266
+
267
+        // Convert the items.
268
+        $prepared = array();
266 269
 
267
-		// Convert the items.
268
-		$prepared = array();
270
+        foreach ( $items as $key => $value ) {
269 271
 
270
-		foreach ( $items as $key => $value ) {
272
+            //Form items.
273
+            if ( $value instanceof GetPaid_Form_Item ) {
271 274
 
272
-			//Form items.
273
-			if ( $value instanceof GetPaid_Form_Item ) {
275
+                if ( $value->can_purchase() ) {
276
+                    $prepared[] = $value;
277
+                }
274 278
 
275
-				if ( $value->can_purchase() ) {
276
-					$prepared[] = $value;
277
-				}
279
+                continue;
278 280
 
279
-				continue;
281
+            }
280 282
 
281
-			}
283
+            // $item_id => $quantity
284
+            if ( is_numeric( $key ) && is_numeric( $value ) ) {
285
+                $item = new GetPaid_Form_Item( $key );
282 286
 
283
-			// $item_id => $quantity
284
-			if ( is_numeric( $key ) && is_numeric( $value ) ) {
285
-				$item = new GetPaid_Form_Item( $key );
287
+                if ( $item->can_purchase() ) {
288
+                    $item->set_quantity( $value );
289
+                    $prepared[] = $item;
290
+                }
286 291
 
287
-				if ( $item->can_purchase() ) {
288
-					$item->set_quantity( $value );
289
-					$prepared[] = $item;
290
-				}
292
+                continue;
293
+            }
291 294
 
292
-				continue;
293
-			}
295
+            // $item_id => array( 'price' => 10 )
296
+            if ( is_numeric( $key ) && is_array( $value ) ) {
297
+                $item = new GetPaid_Form_Item( $key );
294 298
 
295
-			// $item_id => array( 'price' => 10 )
296
-			if ( is_numeric( $key ) && is_array( $value ) ) {
297
-				$item = new GetPaid_Form_Item( $key );
299
+                if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) {
300
+                    $item->set_price( $value['price'] );
301
+                }
298 302
 
299
-				if ( isset( $value['price'] ) && $item->user_can_set_their_price() ) {
300
-					$item->set_price( $value['price'] );
301
-				}
303
+                if ( $item->can_purchase() ) {
304
+                    $prepared[] = $item;
305
+                }
302 306
 
303
-				if ( $item->can_purchase() ) {
304
-					$prepared[] = $item;
305
-				}
307
+                continue;
308
+            }
306 309
 
307
-				continue;
308
-			}
310
+            if ( is_array( $value ) && isset( $value['id'] ) ) {
309 311
 
310
-			if ( is_array( $value ) && isset( $value['id'] ) ) {
312
+                $item = new GetPaid_Form_Item( $value['id'] );
311 313
 
312
-				$item = new GetPaid_Form_Item( $value['id'] );
314
+                if ( ! $item->can_purchase() ) {
315
+                    continue;
316
+                }
313 317
 
314
-				if ( ! $item->can_purchase() ) {
315
-					continue;
316
-				}
318
+                // Sub-total (Cart items).
319
+                if ( isset( $value['subtotal'] ) ) {
320
+                    $item->set_price( $value['subtotal'] );
321
+                }
317 322
 
318
-				// Sub-total (Cart items).
319
-				if ( isset( $value['subtotal'] ) ) {
320
-					$item->set_price( $value['subtotal'] );
321
-				}
323
+                if ( isset( $value['quantity'] ) ) {
324
+                    $item->set_quantity( $value['quantity'] );
325
+                }
326
+
327
+                if ( isset( $value['allow_quantities'] ) ) {
328
+                    $item->set_allow_quantities( $value['allow_quantities'] );
329
+                }
330
+
331
+                if ( isset( $value['required'] ) ) {
332
+                    $item->set_is_required( $value['required'] );
333
+                }
334
+
335
+                if ( isset( $value['description'] ) ) {
336
+                    $item->set_custom_description( $value['description'] );
337
+                }
338
+
339
+                $prepared[] = $item;
340
+                continue;
341
+
342
+            }
343
+        }
344
+
345
+        if ( 'objects' == $return && 'view' == $context ) {
346
+            return $prepared;
347
+        }
348
+
349
+        $items = array();
350
+        foreach ( $prepared as $item ) {
351
+            $items[] = $item->prepare_data_for_use();
352
+        }
353
+
354
+        return $items;
355
+    }
356
+
357
+    /**
358
+     * Get a single item belonging to the form.
359
+     *
360
+     * @since 1.0.19
361
+     * @param  int $item_id The item id to return.
362
+     * @return GetPaid_Form_Item|bool
363
+     */
364
+    public function get_item( $item_id ) {
365
+
366
+        if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
367
+            return false;
368
+        }
369
+
370
+        foreach( $this->get_items() as $item ) {
371
+            if ( $item->get_id() == (int) $item_id ) {
372
+                return $item;
373
+            }
374
+        }
375
+
376
+        return false;
377
+
378
+    }
379
+
380
+    /**
381
+     * Gets a single element.
382
+     *
383
+     * @since 1.0.19
384
+     * @param  string $element_type The element type to return.
385
+     * @return array|bool
386
+     */
387
+    public function get_element_type( $element_type ) {
388
+
389
+        if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
390
+            return false;
391
+        }
392
+
393
+        foreach ( $this->get_prop( 'elements' ) as $element ) {
394
+
395
+            if ( $element['type'] == $element_type ) {
396
+                return $element;
397
+            }
398
+
399
+        }
400
+
401
+        return false;
402
+
403
+    }
404
+
405
+    /**
406
+     * Get the total amount earned via this form.
407
+     *
408
+     * @since 1.0.19
409
+     * @param  string $context View or edit context.
410
+     * @return array
411
+     */
412
+    public function get_earned( $context = 'view' ) {
413
+        return $this->get_prop( 'earned', $context );
414
+    }
415
+
416
+    /**
417
+     * Get the total amount refunded via this form.
418
+     *
419
+     * @since 1.0.19
420
+     * @param  string $context View or edit context.
421
+     * @return array
422
+     */
423
+    public function get_refunded( $context = 'view' ) {
424
+        return $this->get_prop( 'refunded', $context );
425
+    }
322 426
 
323
-				if ( isset( $value['quantity'] ) ) {
324
-					$item->set_quantity( $value['quantity'] );
325
-				}
427
+    /**
428
+     * Get the total amount cancelled via this form.
429
+     *
430
+     * @since 1.0.19
431
+     * @param  string $context View or edit context.
432
+     * @return array
433
+     */
434
+    public function get_cancelled( $context = 'view' ) {
435
+        return $this->get_prop( 'cancelled', $context );
436
+    }
326 437
 
327
-				if ( isset( $value['allow_quantities'] ) ) {
328
-					$item->set_allow_quantities( $value['allow_quantities'] );
329
-				}
438
+    /**
439
+     * Get the total amount failed via this form.
440
+     *
441
+     * @since 1.0.19
442
+     * @param  string $context View or edit context.
443
+     * @return array
444
+     */
445
+    public function get_failed( $context = 'view' ) {
446
+        return $this->get_prop( 'failed', $context );
447
+    }
330 448
 
331
-				if ( isset( $value['required'] ) ) {
332
-					$item->set_is_required( $value['required'] );
333
-				}
334
-
335
-				if ( isset( $value['description'] ) ) {
336
-					$item->set_custom_description( $value['description'] );
337
-				}
338
-
339
-				$prepared[] = $item;
340
-				continue;
341
-
342
-			}
343
-		}
344
-
345
-		if ( 'objects' == $return && 'view' == $context ) {
346
-			return $prepared;
347
-		}
348
-
349
-		$items = array();
350
-		foreach ( $prepared as $item ) {
351
-			$items[] = $item->prepare_data_for_use();
352
-		}
353
-
354
-		return $items;
355
-	}
356
-
357
-	/**
358
-	 * Get a single item belonging to the form.
359
-	 *
360
-	 * @since 1.0.19
361
-	 * @param  int $item_id The item id to return.
362
-	 * @return GetPaid_Form_Item|bool
363
-	 */
364
-	public function get_item( $item_id ) {
365
-
366
-		if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
367
-			return false;
368
-		}
369
-
370
-		foreach( $this->get_items() as $item ) {
371
-			if ( $item->get_id() == (int) $item_id ) {
372
-				return $item;
373
-			}
374
-		}
375
-
376
-		return false;
377
-
378
-	}
379
-
380
-	/**
381
-	 * Gets a single element.
382
-	 *
383
-	 * @since 1.0.19
384
-	 * @param  string $element_type The element type to return.
385
-	 * @return array|bool
386
-	 */
387
-	public function get_element_type( $element_type ) {
388
-
389
-		if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
390
-			return false;
391
-		}
392
-
393
-		foreach ( $this->get_prop( 'elements' ) as $element ) {
394
-
395
-			if ( $element['type'] == $element_type ) {
396
-				return $element;
397
-			}
398
-
399
-		}
400
-
401
-		return false;
402
-
403
-	}
404
-
405
-	/**
406
-	 * Get the total amount earned via this form.
407
-	 *
408
-	 * @since 1.0.19
409
-	 * @param  string $context View or edit context.
410
-	 * @return array
411
-	 */
412
-	public function get_earned( $context = 'view' ) {
413
-		return $this->get_prop( 'earned', $context );
414
-	}
415
-
416
-	/**
417
-	 * Get the total amount refunded via this form.
418
-	 *
419
-	 * @since 1.0.19
420
-	 * @param  string $context View or edit context.
421
-	 * @return array
422
-	 */
423
-	public function get_refunded( $context = 'view' ) {
424
-		return $this->get_prop( 'refunded', $context );
425
-	}
426
-
427
-	/**
428
-	 * Get the total amount cancelled via this form.
429
-	 *
430
-	 * @since 1.0.19
431
-	 * @param  string $context View or edit context.
432
-	 * @return array
433
-	 */
434
-	public function get_cancelled( $context = 'view' ) {
435
-		return $this->get_prop( 'cancelled', $context );
436
-	}
437
-
438
-	/**
439
-	 * Get the total amount failed via this form.
440
-	 *
441
-	 * @since 1.0.19
442
-	 * @param  string $context View or edit context.
443
-	 * @return array
444
-	 */
445
-	public function get_failed( $context = 'view' ) {
446
-		return $this->get_prop( 'failed', $context );
447
-	}
448
-
449
-	/**
450
-	 * Get the currency.
451
-	 *
452
-	 * @since 1.0.19
453
-	 * @param  string $context View or edit context.
454
-	 * @return string
455
-	 */
456
-	public function get_currency() {
457
-		$currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
458
-		return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
459
-	}
449
+    /**
450
+     * Get the currency.
451
+     *
452
+     * @since 1.0.19
453
+     * @param  string $context View or edit context.
454
+     * @return string
455
+     */
456
+    public function get_currency() {
457
+        $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
458
+        return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
459
+    }
460 460
 
461 461
     /*
462 462
 	|--------------------------------------------------------------------------
@@ -469,22 +469,22 @@  discard block
 block discarded – undo
469 469
     */
470 470
 
471 471
     /**
472
-	 * Set plugin version when the item was created.
473
-	 *
474
-	 * @since 1.0.19
475
-	 */
476
-	public function set_version( $value ) {
477
-		$this->set_prop( 'version', $value );
472
+     * Set plugin version when the item was created.
473
+     *
474
+     * @since 1.0.19
475
+     */
476
+    public function set_version( $value ) {
477
+        $this->set_prop( 'version', $value );
478 478
     }
479 479
 
480 480
     /**
481
-	 * Set date when the item was created.
482
-	 *
483
-	 * @since 1.0.19
484
-	 * @param string $value Value to set.
481
+     * Set date when the item was created.
482
+     *
483
+     * @since 1.0.19
484
+     * @param string $value Value to set.
485 485
      * @return bool Whether or not the date was set.
486
-	 */
487
-	public function set_date_created( $value ) {
486
+     */
487
+    public function set_date_created( $value ) {
488 488
         $date = strtotime( $value );
489 489
 
490 490
         if ( $date ) {
@@ -497,13 +497,13 @@  discard block
 block discarded – undo
497 497
     }
498 498
 
499 499
     /**
500
-	 * Set date when the item was last modified.
501
-	 *
502
-	 * @since 1.0.19
503
-	 * @param string $value Value to set.
500
+     * Set date when the item was last modified.
501
+     *
502
+     * @since 1.0.19
503
+     * @param string $value Value to set.
504 504
      * @return bool Whether or not the date was set.
505
-	 */
506
-	public function set_date_modified( $value ) {
505
+     */
506
+    public function set_date_modified( $value ) {
507 507
         $date = strtotime( $value );
508 508
 
509 509
         if ( $date ) {
@@ -516,118 +516,118 @@  discard block
 block discarded – undo
516 516
     }
517 517
 
518 518
     /**
519
-	 * Set the item name.
520
-	 *
521
-	 * @since 1.0.19
522
-	 * @param  string $value New name.
523
-	 */
524
-	public function set_name( $value ) {
525
-		$this->set_prop( 'name', sanitize_text_field( $value ) );
526
-    }
527
-
528
-    /**
529
-	 * Alias of self::set_name().
530
-	 *
531
-	 * @since 1.0.19
532
-	 * @param  string $value New name.
533
-	 */
534
-	public function set_title( $value ) {
535
-		$this->set_name( $value );
536
-    }
537
-
538
-    /**
539
-	 * Set the owner of the item.
540
-	 *
541
-	 * @since 1.0.19
542
-	 * @param  int $value New author.
543
-	 */
544
-	public function set_author( $value ) {
545
-		$this->set_prop( 'author', (int) $value );
546
-	}
547
-
548
-	/**
549
-	 * Set the form elements.
550
-	 *
551
-	 * @since 1.0.19
552
-	 * @param  array $value Form elements.
553
-	 */
554
-	public function set_elements( $value ) {
555
-		if ( is_array( $value ) ) {
556
-			$this->set_prop( 'elements', $value );
557
-		}
558
-	}
559
-
560
-	/**
561
-	 * Set the form items.
562
-	 *
563
-	 * @since 1.0.19
564
-	 * @param  array $value Form elements.
565
-	 */
566
-	public function set_items( $value ) {
567
-		if ( is_array( $value ) ) {
568
-			$this->set_prop( 'items', $value );
569
-		}
570
-	}
571
-
572
-	/**
573
-	 * Set the total amount earned via this form.
574
-	 *
575
-	 * @since 1.0.19
576
-	 * @param  float $value Amount earned.
577
-	 * @return array
578
-	 */
579
-	public function set_earned( $value ) {
580
-		return $this->set_prop( 'earned', (float) $value );
581
-	}
582
-
583
-	/**
584
-	 * Set the total amount refunded via this form.
585
-	 *
586
-	 * @since 1.0.19
587
-	 * @param  float $value Amount refunded.
588
-	 * @return array
589
-	 */
590
-	public function set_refunded( $value ) {
591
-		return $this->set_prop( 'refunded', (float) $value );
592
-	}
593
-
594
-	/**
595
-	 * Set the total amount cancelled via this form.
596
-	 *
597
-	 * @since 1.0.19
598
-	 * @param  float $value Amount cancelled.
599
-	 * @return array
600
-	 */
601
-	public function set_cancelled( $value ) {
602
-		return $this->set_prop( 'cancelled', (float) $value );
603
-	}
604
-
605
-	/**
606
-	 * Set the total amount failed via this form.
607
-	 *
608
-	 * @since 1.0.19
609
-	 * @param  float $value Amount cancelled.
610
-	 * @return array
611
-	 */
612
-	public function set_failed( $value ) {
613
-		return $this->set_prop( 'failed', (float) $value );
614
-	}
519
+     * Set the item name.
520
+     *
521
+     * @since 1.0.19
522
+     * @param  string $value New name.
523
+     */
524
+    public function set_name( $value ) {
525
+        $this->set_prop( 'name', sanitize_text_field( $value ) );
526
+    }
527
+
528
+    /**
529
+     * Alias of self::set_name().
530
+     *
531
+     * @since 1.0.19
532
+     * @param  string $value New name.
533
+     */
534
+    public function set_title( $value ) {
535
+        $this->set_name( $value );
536
+    }
537
+
538
+    /**
539
+     * Set the owner of the item.
540
+     *
541
+     * @since 1.0.19
542
+     * @param  int $value New author.
543
+     */
544
+    public function set_author( $value ) {
545
+        $this->set_prop( 'author', (int) $value );
546
+    }
547
+
548
+    /**
549
+     * Set the form elements.
550
+     *
551
+     * @since 1.0.19
552
+     * @param  array $value Form elements.
553
+     */
554
+    public function set_elements( $value ) {
555
+        if ( is_array( $value ) ) {
556
+            $this->set_prop( 'elements', $value );
557
+        }
558
+    }
559
+
560
+    /**
561
+     * Set the form items.
562
+     *
563
+     * @since 1.0.19
564
+     * @param  array $value Form elements.
565
+     */
566
+    public function set_items( $value ) {
567
+        if ( is_array( $value ) ) {
568
+            $this->set_prop( 'items', $value );
569
+        }
570
+    }
571
+
572
+    /**
573
+     * Set the total amount earned via this form.
574
+     *
575
+     * @since 1.0.19
576
+     * @param  float $value Amount earned.
577
+     * @return array
578
+     */
579
+    public function set_earned( $value ) {
580
+        return $this->set_prop( 'earned', (float) $value );
581
+    }
582
+
583
+    /**
584
+     * Set the total amount refunded via this form.
585
+     *
586
+     * @since 1.0.19
587
+     * @param  float $value Amount refunded.
588
+     * @return array
589
+     */
590
+    public function set_refunded( $value ) {
591
+        return $this->set_prop( 'refunded', (float) $value );
592
+    }
593
+
594
+    /**
595
+     * Set the total amount cancelled via this form.
596
+     *
597
+     * @since 1.0.19
598
+     * @param  float $value Amount cancelled.
599
+     * @return array
600
+     */
601
+    public function set_cancelled( $value ) {
602
+        return $this->set_prop( 'cancelled', (float) $value );
603
+    }
604
+
605
+    /**
606
+     * Set the total amount failed via this form.
607
+     *
608
+     * @since 1.0.19
609
+     * @param  float $value Amount cancelled.
610
+     * @return array
611
+     */
612
+    public function set_failed( $value ) {
613
+        return $this->set_prop( 'failed', (float) $value );
614
+    }
615 615
 
616 616
     /**
617 617
      * Create an item. For backwards compatibilty.
618 618
      *
619 619
      * @deprecated
620
-	 * @return int item id
620
+     * @return int item id
621 621
      */
622 622
     public function create( $data = array() ) {
623 623
 
624
-		// Set the properties.
625
-		if ( is_array( $data ) ) {
626
-			$this->set_props( $data );
627
-		}
624
+        // Set the properties.
625
+        if ( is_array( $data ) ) {
626
+            $this->set_props( $data );
627
+        }
628 628
 
629
-		// Save the item.
630
-		return $this->save();
629
+        // Save the item.
630
+        return $this->save();
631 631
 
632 632
     }
633 633
 
@@ -635,7 +635,7 @@  discard block
 block discarded – undo
635 635
      * Updates an item. For backwards compatibilty.
636 636
      *
637 637
      * @deprecated
638
-	 * @return int item id
638
+     * @return int item id
639 639
      */
640 640
     public function update( $data = array() ) {
641 641
         return $this->create( $data );
@@ -651,22 +651,22 @@  discard block
 block discarded – undo
651 651
 	*/
652 652
 
653 653
     /**
654
-	 * Checks whether this is the default payment form.
655
-	 *
656
-	 * @since 1.0.19
657
-	 * @return bool
658
-	 */
654
+     * Checks whether this is the default payment form.
655
+     *
656
+     * @since 1.0.19
657
+     * @return bool
658
+     */
659 659
     public function is_default() {
660 660
         $is_default = $this->get_id() == wpinv_get_default_payment_form();
661 661
         return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this );
662
-	}
662
+    }
663 663
 
664 664
     /**
665
-	 * Checks whether the form is active.
666
-	 *
667
-	 * @since 1.0.19
668
-	 * @return bool
669
-	 */
665
+     * Checks whether the form is active.
666
+     *
667
+     * @since 1.0.19
668
+     * @return bool
669
+     */
670 670
     public function is_active() {
671 671
         $is_active = 0 !== (int) $this->get_id();
672 672
 
@@ -675,70 +675,70 @@  discard block
 block discarded – undo
675 675
         }
676 676
 
677 677
         return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this );
678
-	}
679
-
680
-	/**
681
-	 * Checks whether the form has a given item.
682
-	 *
683
-	 * @since 1.0.19
684
-	 * @return bool
685
-	 */
678
+    }
679
+
680
+    /**
681
+     * Checks whether the form has a given item.
682
+     *
683
+     * @since 1.0.19
684
+     * @return bool
685
+     */
686 686
     public function has_item( $item_id ) {
687 687
         return false !== $this->get_item( $item_id );
688
-	}
689
-
690
-	/**
691
-	 * Checks whether the form has a given element.
692
-	 *
693
-	 * @since 1.0.19
694
-	 * @return bool
695
-	 */
688
+    }
689
+
690
+    /**
691
+     * Checks whether the form has a given element.
692
+     *
693
+     * @since 1.0.19
694
+     * @return bool
695
+     */
696 696
     public function has_element_type( $element_type ) {
697 697
         return false !== $this->get_element_type( $element_type );
698
-	}
699
-
700
-	/**
701
-	 * Checks whether this form is recurring or not.
702
-	 *
703
-	 * @since 1.0.19
704
-	 * @return bool
705
-	 */
698
+    }
699
+
700
+    /**
701
+     * Checks whether this form is recurring or not.
702
+     *
703
+     * @since 1.0.19
704
+     * @return bool
705
+     */
706 706
     public function is_recurring() {
707 707
 
708
-		if ( ! empty( $this->invoice ) ) {
709
-			return $this->invoice->is_recurring();
710
-		}
708
+        if ( ! empty( $this->invoice ) ) {
709
+            return $this->invoice->is_recurring();
710
+        }
711 711
 
712
-		foreach ( $this->get_items() as $item ) {
712
+        foreach ( $this->get_items() as $item ) {
713 713
 
714
-			if ( $item->is_recurring() ) {
715
-				return true;
716
-			}
714
+            if ( $item->is_recurring() ) {
715
+                return true;
716
+            }
717 717
 
718
-		}
718
+        }
719 719
 
720 720
         return false;
721
-	}
721
+    }
722 722
 
723
-	/**
724
-	 * Retrieves the form's html.
725
-	 *
726
-	 * @since 1.0.19
727
-	 */
723
+    /**
724
+     * Retrieves the form's html.
725
+     *
726
+     * @since 1.0.19
727
+     */
728 728
     public function get_html() {
729 729
 
730
-		// Return the HTML.
731
-		return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) );
730
+        // Return the HTML.
731
+        return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) );
732 732
 
733
-	}
733
+    }
734 734
 
735
-	/**
736
-	 * Displays the payment form.
737
-	 *
738
-	 * @since 1.0.19
739
-	 */
735
+    /**
736
+     * Displays the payment form.
737
+     *
738
+     * @since 1.0.19
739
+     */
740 740
     public function display() {
741
-		echo $this->get_html();
741
+        echo $this->get_html();
742 742
     }
743 743
 
744 744
 }
Please login to merge, or discard this patch.
includes/class-wpinv-ajax.php 1 patch
Indentation   +58 added lines, -58 removed lines patch added patch discarded remove patch
@@ -14,70 +14,70 @@  discard block
 block discarded – undo
14 14
 class WPInv_Ajax {
15 15
 
16 16
     /**
17
-	 * Hook in ajax handlers.
18
-	 */
19
-	public static function init() {
20
-		add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
-		add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
22
-		self::add_ajax_events();
17
+     * Hook in ajax handlers.
18
+     */
19
+    public static function init() {
20
+        add_action( 'init', array( __CLASS__, 'define_ajax' ), 0 );
21
+        add_action( 'template_redirect', array( __CLASS__, 'do_wpinv_ajax' ), 0 );
22
+        self::add_ajax_events();
23 23
     }
24 24
 
25 25
     /**
26
-	 * Set GetPaid AJAX constant and headers.
27
-	 */
28
-	public static function define_ajax() {
29
-
30
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
-			getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
-			getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
-			if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
-				/** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
35
-			}
36
-			$GLOBALS['wpdb']->hide_errors();
37
-		}
26
+     * Set GetPaid AJAX constant and headers.
27
+     */
28
+    public static function define_ajax() {
29
+
30
+        if ( ! empty( $_GET['wpinv-ajax'] ) ) {
31
+            getpaid_maybe_define_constant( 'DOING_AJAX', true );
32
+            getpaid_maybe_define_constant( 'WPInv_DOING_AJAX', true );
33
+            if ( ! WP_DEBUG || ( WP_DEBUG && ! WP_DEBUG_DISPLAY ) ) {
34
+                /** @scrutinizer ignore-unhandled */ @ini_set( 'display_errors', 0 );
35
+            }
36
+            $GLOBALS['wpdb']->hide_errors();
37
+        }
38 38
 
39 39
     }
40 40
     
41 41
     /**
42
-	 * Send headers for GetPaid Ajax Requests.
43
-	 *
44
-	 * @since 1.0.18
45
-	 */
46
-	private static function wpinv_ajax_headers() {
47
-		if ( ! headers_sent() ) {
48
-			send_origin_headers();
49
-			send_nosniff_header();
50
-			nocache_headers();
51
-			header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
-			header( 'X-Robots-Tag: noindex' );
53
-			status_header( 200 );
54
-		}
42
+     * Send headers for GetPaid Ajax Requests.
43
+     *
44
+     * @since 1.0.18
45
+     */
46
+    private static function wpinv_ajax_headers() {
47
+        if ( ! headers_sent() ) {
48
+            send_origin_headers();
49
+            send_nosniff_header();
50
+            nocache_headers();
51
+            header( 'Content-Type: text/html; charset=' . get_option( 'blog_charset' ) );
52
+            header( 'X-Robots-Tag: noindex' );
53
+            status_header( 200 );
54
+        }
55 55
     }
56 56
     
57 57
     /**
58
-	 * Check for GetPaid Ajax request and fire action.
59
-	 */
60
-	public static function do_wpinv_ajax() {
61
-		global $wp_query;
58
+     * Check for GetPaid Ajax request and fire action.
59
+     */
60
+    public static function do_wpinv_ajax() {
61
+        global $wp_query;
62 62
 
63
-		if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
-			$wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
65
-		}
63
+        if ( ! empty( $_GET['wpinv-ajax'] ) ) {
64
+            $wp_query->set( 'wpinv-ajax', sanitize_text_field( wp_unslash( $_GET['wpinv-ajax'] ) ) );
65
+        }
66 66
 
67
-		$action = $wp_query->get( 'wpinv-ajax' );
67
+        $action = $wp_query->get( 'wpinv-ajax' );
68 68
 
69
-		if ( $action ) {
70
-			self::wpinv_ajax_headers();
71
-			$action = sanitize_text_field( $action );
72
-			do_action( 'wpinv_ajax_' . $action );
73
-			wp_die();
74
-		}
69
+        if ( $action ) {
70
+            self::wpinv_ajax_headers();
71
+            $action = sanitize_text_field( $action );
72
+            do_action( 'wpinv_ajax_' . $action );
73
+            wp_die();
74
+        }
75 75
 
76 76
     }
77 77
 
78 78
     /**
79
-	 * Hook in ajax methods.
80
-	 */
79
+     * Hook in ajax methods.
80
+     */
81 81
     public static function add_ajax_events() {
82 82
 
83 83
         // array( 'event' => is_frontend )
@@ -260,24 +260,24 @@  discard block
 block discarded – undo
260 260
         }
261 261
 
262 262
         // Is the request set up correctly?
263
-		if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
264
-			echo aui()->alert(
265
-				array(
266
-					'type'    => 'warning',
267
-					'content' => __( 'No payment form or item provided', 'invoicing' ),
268
-				)
263
+        if ( empty( $_GET['form'] ) && empty( $_GET['item'] ) ) {
264
+            echo aui()->alert(
265
+                array(
266
+                    'type'    => 'warning',
267
+                    'content' => __( 'No payment form or item provided', 'invoicing' ),
268
+                )
269 269
             );
270 270
             exit;
271 271
         }
272 272
 
273 273
         // Payment form or button?
274
-		if ( ! empty( $_GET['form'] ) ) {
274
+        if ( ! empty( $_GET['form'] ) ) {
275 275
             getpaid_display_payment_form( $_GET['form'] );
276
-		} else if( ! empty( $_GET['invoice'] ) ) {
277
-		    echo getpaid_display_invoice_payment_form( $_GET['invoice'] );
276
+        } else if( ! empty( $_GET['invoice'] ) ) {
277
+            echo getpaid_display_invoice_payment_form( $_GET['invoice'] );
278 278
         } else {
279
-			$items = getpaid_convert_items_to_array( $_GET['item'] );
280
-		    getpaid_display_item_payment_form( $items );
279
+            $items = getpaid_convert_items_to_array( $_GET['item'] );
280
+            getpaid_display_item_payment_form( $items );
281 281
         }
282 282
 
283 283
         exit;
Please login to merge, or discard this patch.
includes/class-getpaid-invoice-notification-emails.php 1 patch
Indentation   +269 added lines, -269 removed lines patch added patch discarded remove patch
@@ -15,321 +15,321 @@
 block discarded – undo
15 15
 class GetPaid_Invoice_Notification_Emails {
16 16
 
17 17
     /**
18
-	 * The array of invoice email actions.
19
-	 *
20
-	 * @param array
21
-	 */
22
-	public $invoice_actions;
18
+     * The array of invoice email actions.
19
+     *
20
+     * @param array
21
+     */
22
+    public $invoice_actions;
23 23
 
24 24
     /**
25
-	 * Class constructor
25
+     * Class constructor
26 26
      *
27
-	 */
28
-	public function __construct() {
29
-
30
-		$this->invoice_actions = apply_filters(
31
-			'getpaid_notification_email_invoice_triggers',
32
-			array(
33
-				'getpaid_new_invoice'                   => 'new_invoice',
34
-				'getpaid_invoice_status_wpi-cancelled'  => 'cancelled_invoice',
35
-				'getpaid_invoice_status_wpi-failed'     => 'failed_invoice',
36
-				'getpaid_invoice_status_wpi-onhold'     => 'onhold_invoice',
37
-				'getpaid_invoice_status_wpi-processing' => 'processing_invoice',
38
-				'getpaid_invoice_status_publish'        => 'completed_invoice',
39
-				'getpaid_invoice_status_wpi-renewal'    => 'completed_invoice',
40
-				'getpaid_invoice_status_wpi-refunded'   => 'refunded_invoice',
41
-				'getpaid_new_invoice'                   => 'user_invoice',
42
-				'getpaid_new_customer_note'             => 'user_note',
43
-				'getpaid_subscriptions_daily_cron'      => 'overdue',
44
-
45
-			)
46
-		);
27
+     */
28
+    public function __construct() {
29
+
30
+        $this->invoice_actions = apply_filters(
31
+            'getpaid_notification_email_invoice_triggers',
32
+            array(
33
+                'getpaid_new_invoice'                   => 'new_invoice',
34
+                'getpaid_invoice_status_wpi-cancelled'  => 'cancelled_invoice',
35
+                'getpaid_invoice_status_wpi-failed'     => 'failed_invoice',
36
+                'getpaid_invoice_status_wpi-onhold'     => 'onhold_invoice',
37
+                'getpaid_invoice_status_wpi-processing' => 'processing_invoice',
38
+                'getpaid_invoice_status_publish'        => 'completed_invoice',
39
+                'getpaid_invoice_status_wpi-renewal'    => 'completed_invoice',
40
+                'getpaid_invoice_status_wpi-refunded'   => 'refunded_invoice',
41
+                'getpaid_new_invoice'                   => 'user_invoice',
42
+                'getpaid_new_customer_note'             => 'user_note',
43
+                'getpaid_subscriptions_daily_cron'      => 'overdue',
44
+
45
+            )
46
+        );
47 47
 
48 48
     }
49 49
 
50 50
     /**
51
-	 * Registers email hooks.
52
-	 */
53
-	public function init_hooks() {
54
-
55
-		add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 3 );
56
-		add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 );
57
-		foreach ( $this->invoice_actions as $hook => $email_type ) {
58
-
59
-			$email = new GetPaid_Notification_Email( $email_type );
60
-
61
-			if ( $email->is_active() && method_exists( $this, $email_type ) ) {
62
-				add_action( $hook, array( $this, $email_type ), 100, 2 );
63
-			} else {
64
-				do_action( 'getpaid_hook_invoice_notification_email_invoice_trigger', $email );
65
-			}
66
-
67
-		}
68
-
69
-	}
70
-
71
-	/**
72
-	 * Filters invoice merge tags.
73
-	 *
74
-	 * @param array $merge_tags
75
-	 * @param string $email_type
76
-	 * @param mixed|WPInv_Invoice|WPInv_Subscription $object
77
-	 */
78
-	public function invoice_merge_tags( $merge_tags, $email_type, $object ) {
79
-
80
-		if ( is_a( $object, 'WPInv_Invoice' ) ) {
81
-			$merge_tags = array_merge(
82
-				$merge_tags,
83
-				$this->get_invoice_merge_tags( $object )
84
-			);
85
-		}
86
-
87
-		if ( is_a( $object, 'WPInv_Subscription' ) ) {
88
-			$merge_tags = array_merge(
89
-				$merge_tags,
90
-				$this->get_invoice_merge_tags( $object->get_parent_payment() )
91
-			);
92
-		}
93
-
94
-		return apply_filters( 'getpaid_invoice_notification_merge_tags', $merge_tags, $object, $email_type, $this );
95
-
96
-	}
97
-
98
-	/**
99
-	 * Generates invoice merge tags.
100
-	 *
101
-	 * @param WPInv_Invoice $invoice
102
-	 * @return array
103
-	 */
104
-	public function get_invoice_merge_tags( $invoice ) {
105
-
106
-		// Abort if it does not exist.
107
-		if ( ! $invoice->get_id() ) {
108
-			return array();
109
-		}
110
-
111
-		return array(
112
-			'{name}'                => sanitize_text_field( $invoice->get_user_full_name() ),
113
-			'{full_name}'           => sanitize_text_field( $invoice->get_user_full_name() ),
114
-			'{first_name}'          => sanitize_text_field( $invoice->get_first_name() ),
115
-			'{last_name}'           => sanitize_text_field( $invoice->get_last_name() ),
116
-			'{email}'               => sanitize_email( $invoice->get_email() ),
117
-			'{invoice_number}'      => sanitize_text_field( $invoice->get_number() ),
118
-			'{invoice_total}'       => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ),
119
-			'{invoice_link}'        => esc_url( $invoice->get_view_url() ),
120
-			'{invoice_pay_link}'    => esc_url( $invoice->get_checkout_payment_url() ),
121
-			'{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ),
122
-			'{invoice_date}'        => date( get_option( 'date_format' ), strtotime( $invoice->get_date_created(), current_time( 'timestamp' ) ) ),
123
-			'{invoice_due_date}'    => date( get_option( 'date_format' ), strtotime( $invoice->get_due_date(), current_time( 'timestamp' ) ) ),
124
-			'{invoice_quote}'       => sanitize_text_field( $invoice->get_type() ),
125
-			'{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_type() ) ),
126
-			'{invoice_description}' => wp_kses_post( $invoice->get_description() ),
127
-			'{subscription_name}'   => wp_kses_post( $invoice->get_subscription_name() ),
128
-			'{is_was}'              => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
129
-		);
130
-
131
-	}
132
-
133
-	/**
134
-	 * Helper function to send an email.
135
-	 *
136
-	 * @param WPInv_Invoice $invoice
137
-	 * @param GetPaid_Notification_Email $email
138
-	 * @param string $type
139
-	 * @param string|array $recipients
140
-	 * @param array $extra_args Extra template args.
141
-	 */
142
-	public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
143
-
144
-		do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
145
-
146
-		$mailer     = new GetPaid_Notification_Email_Sender();
147
-		$merge_tags = $email->get_merge_tags();
148
-
149
-		$result = $mailer->send(
150
-			apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
151
-			$email->add_merge_tags( $email->get_subject(), $merge_tags ),
152
-			$email->get_content( $merge_tags, $extra_args ),
153
-			$email->get_attachments()
154
-		);
155
-
156
-		// Maybe send a copy to the admin.
157
-		if ( $email->include_admin_bcc() ) {
158
-			$mailer->send(
159
-				wpinv_get_admin_email(),
160
-				$email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
161
-				$email->get_content( $merge_tags ),
162
-				$email->get_attachments()
163
-			);
164
-		}
165
-
166
-		if ( ! $result ) {
167
-			$invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
168
-		}
169
-
170
-		do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
171
-
172
-	}
173
-
174
-	/**
175
-	 * Also send emails to any cc users.
176
-	 *
177
-	 * @param array $recipients
178
-	 * @param GetPaid_Notification_Email $email
179
-	 */
180
-	public function filter_email_recipients( $recipients, $email ) {
181
-
182
-		if ( ! $email->is_admin_email() ) {
183
-			$cc = $email->object->get_email_cc();
184
-
185
-			if ( ! empty( $cc ) ) {
186
-				$cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
187
-				$recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
188
-			}
189
-
190
-		}
191
-
192
-		return $recipients;
193
-
194
-	}
51
+     * Registers email hooks.
52
+     */
53
+    public function init_hooks() {
54
+
55
+        add_filter( 'getpaid_get_email_merge_tags', array( $this, 'invoice_merge_tags' ), 10, 3 );
56
+        add_filter( 'getpaid_invoice_email_recipients', array( $this, 'filter_email_recipients' ), 10, 2 );
57
+        foreach ( $this->invoice_actions as $hook => $email_type ) {
58
+
59
+            $email = new GetPaid_Notification_Email( $email_type );
60
+
61
+            if ( $email->is_active() && method_exists( $this, $email_type ) ) {
62
+                add_action( $hook, array( $this, $email_type ), 100, 2 );
63
+            } else {
64
+                do_action( 'getpaid_hook_invoice_notification_email_invoice_trigger', $email );
65
+            }
66
+
67
+        }
68
+
69
+    }
195 70
 
196 71
     /**
197
-	 * Sends a new invoice notification.
198
-	 *
199
-	 * @param WPInv_Invoice $invoice
200
-	 */
201
-	public function new_invoice( $invoice ) {
72
+     * Filters invoice merge tags.
73
+     *
74
+     * @param array $merge_tags
75
+     * @param string $email_type
76
+     * @param mixed|WPInv_Invoice|WPInv_Subscription $object
77
+     */
78
+    public function invoice_merge_tags( $merge_tags, $email_type, $object ) {
79
+
80
+        if ( is_a( $object, 'WPInv_Invoice' ) ) {
81
+            $merge_tags = array_merge(
82
+                $merge_tags,
83
+                $this->get_invoice_merge_tags( $object )
84
+            );
85
+        }
86
+
87
+        if ( is_a( $object, 'WPInv_Subscription' ) ) {
88
+            $merge_tags = array_merge(
89
+                $merge_tags,
90
+                $this->get_invoice_merge_tags( $object->get_parent_payment() )
91
+            );
92
+        }
93
+
94
+        return apply_filters( 'getpaid_invoice_notification_merge_tags', $merge_tags, $object, $email_type, $this );
202 95
 
203
-		$email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
204
-		$recipient = wpinv_get_admin_email();
96
+    }
205 97
 
206
-		$this->send_email( $invoice, $email, __METHOD__, $recipient );
98
+    /**
99
+     * Generates invoice merge tags.
100
+     *
101
+     * @param WPInv_Invoice $invoice
102
+     * @return array
103
+     */
104
+    public function get_invoice_merge_tags( $invoice ) {
105
+
106
+        // Abort if it does not exist.
107
+        if ( ! $invoice->get_id() ) {
108
+            return array();
109
+        }
110
+
111
+        return array(
112
+            '{name}'                => sanitize_text_field( $invoice->get_user_full_name() ),
113
+            '{full_name}'           => sanitize_text_field( $invoice->get_user_full_name() ),
114
+            '{first_name}'          => sanitize_text_field( $invoice->get_first_name() ),
115
+            '{last_name}'           => sanitize_text_field( $invoice->get_last_name() ),
116
+            '{email}'               => sanitize_email( $invoice->get_email() ),
117
+            '{invoice_number}'      => sanitize_text_field( $invoice->get_number() ),
118
+            '{invoice_total}'       => wpinv_price( wpinv_format_amount( $invoice->get_total() ) ),
119
+            '{invoice_link}'        => esc_url( $invoice->get_view_url() ),
120
+            '{invoice_pay_link}'    => esc_url( $invoice->get_checkout_payment_url() ),
121
+            '{invoice_receipt_link}'=> esc_url( $invoice->get_receipt_url() ),
122
+            '{invoice_date}'        => date( get_option( 'date_format' ), strtotime( $invoice->get_date_created(), current_time( 'timestamp' ) ) ),
123
+            '{invoice_due_date}'    => date( get_option( 'date_format' ), strtotime( $invoice->get_due_date(), current_time( 'timestamp' ) ) ),
124
+            '{invoice_quote}'       => sanitize_text_field( $invoice->get_type() ),
125
+            '{invoice_label}'       => sanitize_text_field( ucfirst( $invoice->get_type() ) ),
126
+            '{invoice_description}' => wp_kses_post( $invoice->get_description() ),
127
+            '{subscription_name}'   => wp_kses_post( $invoice->get_subscription_name() ),
128
+            '{is_was}'              => strtotime( $invoice->get_due_date() ) < current_time( 'timestamp' ) ? __( 'was', 'invoicing' ) : __( 'is', 'invoicing' ),
129
+        );
207 130
 
208
-	}
131
+    }
209 132
 
210
-	/**
211
-	 * Sends a cancelled invoice notification.
212
-	 *
213
-	 * @param WPInv_Invoice $invoice
214
-	 */
215
-	public function cancelled_invoice( $invoice ) {
133
+    /**
134
+     * Helper function to send an email.
135
+     *
136
+     * @param WPInv_Invoice $invoice
137
+     * @param GetPaid_Notification_Email $email
138
+     * @param string $type
139
+     * @param string|array $recipients
140
+     * @param array $extra_args Extra template args.
141
+     */
142
+    public function send_email( $invoice, $email, $type, $recipients, $extra_args = array() ) {
143
+
144
+        do_action( 'getpaid_before_send_invoice_notification', $type, $invoice, $email );
145
+
146
+        $mailer     = new GetPaid_Notification_Email_Sender();
147
+        $merge_tags = $email->get_merge_tags();
148
+
149
+        $result = $mailer->send(
150
+            apply_filters( 'getpaid_invoice_email_recipients', wpinv_parse_list( $recipients ), $email ),
151
+            $email->add_merge_tags( $email->get_subject(), $merge_tags ),
152
+            $email->get_content( $merge_tags, $extra_args ),
153
+            $email->get_attachments()
154
+        );
155
+
156
+        // Maybe send a copy to the admin.
157
+        if ( $email->include_admin_bcc() ) {
158
+            $mailer->send(
159
+                wpinv_get_admin_email(),
160
+                $email->add_merge_tags( $email->get_subject() . __( ' - ADMIN BCC COPY', 'invoicing' ), $merge_tags ),
161
+                $email->get_content( $merge_tags ),
162
+                $email->get_attachments()
163
+            );
164
+        }
165
+
166
+        if ( ! $result ) {
167
+            $invoice->add_note( sprintf( __( 'Failed sending %s notification email.', 'invoicing' ), sanitize_key( $type ) ), false, false, true );
168
+        }
169
+
170
+        do_action( 'getpaid_after_send_invoice_notification', $type, $invoice, $email );
216 171
 
217
-		$email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
218
-		$recipient = wpinv_get_admin_email();
172
+    }
219 173
 
220
-		$this->send_email( $invoice, $email, __METHOD__, $recipient );
174
+    /**
175
+     * Also send emails to any cc users.
176
+     *
177
+     * @param array $recipients
178
+     * @param GetPaid_Notification_Email $email
179
+     */
180
+    public function filter_email_recipients( $recipients, $email ) {
221 181
 
222
-	}
182
+        if ( ! $email->is_admin_email() ) {
183
+            $cc = $email->object->get_email_cc();
223 184
 
224
-	/**
225
-	 * Sends a failed invoice notification.
226
-	 *
227
-	 * @param WPInv_Invoice $invoice
228
-	 */
229
-	public function failed_invoice( $invoice ) {
185
+            if ( ! empty( $cc ) ) {
186
+                $cc = array_map( 'sanitize_email', wpinv_parse_list( $cc ) );
187
+                $recipients = array_filter( array_unique( array_merge( $recipients, $cc ) ) );
188
+            }
230 189
 
231
-		$email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
232
-		$recipient = wpinv_get_admin_email();
190
+        }
233 191
 
234
-		$this->send_email( $invoice, $email, __METHOD__, $recipient );
192
+        return $recipients;
235 193
 
236
-	}
194
+    }
237 195
 
238
-	/**
239
-	 * Sends a notification whenever an invoice is put on hold.
240
-	 *
241
-	 * @param WPInv_Invoice $invoice
242
-	 */
243
-	public function onhold_invoice( $invoice ) {
196
+    /**
197
+     * Sends a new invoice notification.
198
+     *
199
+     * @param WPInv_Invoice $invoice
200
+     */
201
+    public function new_invoice( $invoice ) {
244 202
 
245
-		$email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
246
-		$recipient = $invoice->get_email();
203
+        $email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
204
+        $recipient = wpinv_get_admin_email();
247 205
 
248
-		$this->send_email( $invoice, $email, __METHOD__, $recipient );
206
+        $this->send_email( $invoice, $email, __METHOD__, $recipient );
249 207
 
250
-	}
208
+    }
251 209
 
252
-	/**
253
-	 * Sends a notification whenever an invoice is marked as processing payment.
254
-	 *
255
-	 * @param WPInv_Invoice $invoice
256
-	 */
257
-	public function processing_invoice( $invoice ) {
210
+    /**
211
+     * Sends a cancelled invoice notification.
212
+     *
213
+     * @param WPInv_Invoice $invoice
214
+     */
215
+    public function cancelled_invoice( $invoice ) {
258 216
 
259
-		$email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
260
-		$recipient = $invoice->get_email();
217
+        $email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
218
+        $recipient = wpinv_get_admin_email();
261 219
 
262
-		$this->send_email( $invoice, $email, __METHOD__, $recipient );
220
+        $this->send_email( $invoice, $email, __METHOD__, $recipient );
263 221
 
264
-	}
222
+    }
265 223
 
266
-	/**
267
-	 * Sends a notification whenever an invoice is paid.
268
-	 *
269
-	 * @param WPInv_Invoice $invoice
270
-	 */
271
-	public function completed_invoice( $invoice ) {
224
+    /**
225
+     * Sends a failed invoice notification.
226
+     *
227
+     * @param WPInv_Invoice $invoice
228
+     */
229
+    public function failed_invoice( $invoice ) {
272 230
 
273
-		// (Maybe) abort if it is a renewal invoice.
274
-		if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
275
-			return;
276
-		}
231
+        $email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
232
+        $recipient = wpinv_get_admin_email();
277 233
 
278
-		$email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
279
-		$recipient = $invoice->get_email();
234
+        $this->send_email( $invoice, $email, __METHOD__, $recipient );
280 235
 
281
-		$this->send_email( $invoice, $email, __METHOD__, $recipient );
236
+    }
282 237
 
283
-	}
238
+    /**
239
+     * Sends a notification whenever an invoice is put on hold.
240
+     *
241
+     * @param WPInv_Invoice $invoice
242
+     */
243
+    public function onhold_invoice( $invoice ) {
284 244
 
285
-	/**
286
-	 * Sends a notification whenever an invoice is refunded.
287
-	 *
288
-	 * @param WPInv_Invoice $invoice
289
-	 */
290
-	public function refunded_invoice( $invoice ) {
245
+        $email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
246
+        $recipient = $invoice->get_email();
291 247
 
292
-		$email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
293
-		$recipient = $invoice->get_email();
248
+        $this->send_email( $invoice, $email, __METHOD__, $recipient );
294 249
 
295
-		$this->send_email( $invoice, $email, __METHOD__, $recipient );
250
+    }
251
+
252
+    /**
253
+     * Sends a notification whenever an invoice is marked as processing payment.
254
+     *
255
+     * @param WPInv_Invoice $invoice
256
+     */
257
+    public function processing_invoice( $invoice ) {
258
+
259
+        $email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
260
+        $recipient = $invoice->get_email();
261
+
262
+        $this->send_email( $invoice, $email, __METHOD__, $recipient );
263
+
264
+    }
265
+
266
+    /**
267
+     * Sends a notification whenever an invoice is paid.
268
+     *
269
+     * @param WPInv_Invoice $invoice
270
+     */
271
+    public function completed_invoice( $invoice ) {
272
+
273
+        // (Maybe) abort if it is a renewal invoice.
274
+        if ( $invoice->is_renewal() && ! wpinv_get_option( 'email_completed_invoice_renewal_active', false ) ) {
275
+            return;
276
+        }
277
+
278
+        $email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
279
+        $recipient = $invoice->get_email();
280
+
281
+        $this->send_email( $invoice, $email, __METHOD__, $recipient );
296 282
 
297
-	}
283
+    }
284
+
285
+    /**
286
+     * Sends a notification whenever an invoice is refunded.
287
+     *
288
+     * @param WPInv_Invoice $invoice
289
+     */
290
+    public function refunded_invoice( $invoice ) {
291
+
292
+        $email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
293
+        $recipient = $invoice->get_email();
294
+
295
+        $this->send_email( $invoice, $email, __METHOD__, $recipient );
296
+
297
+    }
298 298
 
299
-	/**
300
-	 * Notifies a user about new invoices
301
-	 *
302
-	 * @param WPInv_Invoice $invoice
303
-	 */
304
-	public function user_invoice( $invoice ) {
299
+    /**
300
+     * Notifies a user about new invoices
301
+     *
302
+     * @param WPInv_Invoice $invoice
303
+     */
304
+    public function user_invoice( $invoice ) {
305 305
 
306
-		// Only send this email for invoices created via the admin page.
307
-		$payment_form = $invoice->get_payment_form();
306
+        // Only send this email for invoices created via the admin page.
307
+        $payment_form = $invoice->get_payment_form();
308 308
 
309
-		if ( 1 != $payment_form && wpinv_get_default_payment_form() != $payment_form ) {
310
-			return;
311
-		}
309
+        if ( 1 != $payment_form && wpinv_get_default_payment_form() != $payment_form ) {
310
+            return;
311
+        }
312 312
 
313
-		$email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
314
-		$recipient = $invoice->get_email();
313
+        $email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
314
+        $recipient = $invoice->get_email();
315 315
 
316
-		$this->send_email( $invoice, $email, __METHOD__, $recipient );
316
+        $this->send_email( $invoice, $email, __METHOD__, $recipient );
317 317
 
318
-	}
318
+    }
319 319
 
320
-	/**
321
-	 * Notifies admin about new invoice notes
322
-	 *
323
-	 * @param WPInv_Invoice $invoice
324
-	 * @param string $note
325
-	 */
326
-	public function user_note( $invoice, $note ) {
320
+    /**
321
+     * Notifies admin about new invoice notes
322
+     *
323
+     * @param WPInv_Invoice $invoice
324
+     * @param string $note
325
+     */
326
+    public function user_note( $invoice, $note ) {
327 327
 
328
-		$email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
329
-		$recipient = $invoice->get_email();
328
+        $email     = new GetPaid_Notification_Email( __METHOD__, $invoice );
329
+        $recipient = $invoice->get_email();
330 330
 
331
-		$this->send_email( $invoice, $email, __METHOD__, $recipient, array( 'customer_note' => $note ) );
331
+        $this->send_email( $invoice, $email, __METHOD__, $recipient, array( 'customer_note' => $note ) );
332 332
 
333
-	}
333
+    }
334 334
 
335 335
 }
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-invoice-data-store.php 1 patch
Indentation   +447 added lines, -447 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 if ( ! defined( 'ABSPATH' ) ) {
8
-	exit;
8
+    exit;
9 9
 }
10 10
 
11 11
 /**
@@ -15,517 +15,517 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class GetPaid_Invoice_Data_Store extends GetPaid_Data_Store_WP {
17 17
 
18
-	/**
19
-	 * Data stored in meta keys, but not considered "meta" for a discount.
20
-	 *
21
-	 * @since 1.0.19
22
-	 * @var array
23
-	 */
24
-	protected $internal_meta_keys = array(
25
-		'_wpinv_subscr_profile_id',
26
-		'_wpinv_subscription_id',
27
-		'_wpinv_taxes',
28
-		'_wpinv_fees',
29
-		'_wpinv_discounts',
30
-		'_wpinv_submission_id',
31
-		'_wpinv_payment_form',
32
-		'_wpinv_is_viewed',
33
-		'wpinv_email_cc',
34
-		'wpinv_template'
35
-	);
36
-
37
-	/**
38
-	 * A map of meta keys to data props.
39
-	 *
40
-	 * @since 1.0.19
41
-	 *
42
-	 * @var array
43
-	 */
44
-	protected $meta_key_to_props = array(
45
-		'_wpinv_subscr_profile_id' => 'remote_subscription_id',
46
-		'_wpinv_subscription_id'   => 'subscription_id',
47
-		'_wpinv_taxes'             => 'taxes',
48
-		'_wpinv_fees'              => 'fees',
49
-		'_wpinv_discounts'         => 'discounts',
50
-		'_wpinv_submission_id'     => 'submission_id',
51
-		'_wpinv_payment_form'      => 'payment_form',
52
-		'_wpinv_is_viewed'         => 'is_viewed',
53
-		'wpinv_email_cc'           => 'email_cc',
54
-		'wpinv_template'           => 'template',
55
-	);
56
-
57
-	/**
58
-	 * A map of database fields to data props.
59
-	 *
60
-	 * @since 1.0.19
61
-	 *
62
-	 * @var array
63
-	 */
64
-	protected $database_fields_to_props = array(
65
-		'post_id'            => 'id',
66
-		'number'             => 'number',
67
-		'currency'           => 'currency',
68
-		'key'                => 'key',
69
-		'type'               => 'type',
70
-		'mode'               => 'mode',
71
-		'user_ip'            => 'user_ip',
72
-		'first_name'         => 'first_name',
73
-		'last_name'          => 'last_name',
74
-		'address'            => 'address',
75
-		'city'               => 'city',
76
-		'state'              => 'state',
77
-		'country'            => 'country',
78
-		'zip'                => 'zip',
79
-		'zip'                => 'zip',
80
-		'adddress_confirmed' => 'address_confirmed',
81
-		'gateway'            => 'gateway',
82
-		'transaction_id'     => 'transaction_id',
83
-		'currency'           => 'currency',
84
-		'subtotal'           => 'subtotal',
85
-		'tax'                => 'total_tax',
86
-		'fees_total'         => 'total_fees',
87
-		'discount'           => 'total_discount',
88
-		'total'              => 'total',
89
-		'discount_code'      => 'discount_code',
90
-		'disable_taxes'      => 'disable_taxes',
91
-		'due_date'           => 'due_date',
92
-		'completed_date'     => 'completed_date',
93
-		'company'            => 'company',
94
-		'vat_number'         => 'vat_number',
95
-		'vat_rate'           => 'vat_rate',
96
-	);
97
-
98
-	/*
18
+    /**
19
+     * Data stored in meta keys, but not considered "meta" for a discount.
20
+     *
21
+     * @since 1.0.19
22
+     * @var array
23
+     */
24
+    protected $internal_meta_keys = array(
25
+        '_wpinv_subscr_profile_id',
26
+        '_wpinv_subscription_id',
27
+        '_wpinv_taxes',
28
+        '_wpinv_fees',
29
+        '_wpinv_discounts',
30
+        '_wpinv_submission_id',
31
+        '_wpinv_payment_form',
32
+        '_wpinv_is_viewed',
33
+        'wpinv_email_cc',
34
+        'wpinv_template'
35
+    );
36
+
37
+    /**
38
+     * A map of meta keys to data props.
39
+     *
40
+     * @since 1.0.19
41
+     *
42
+     * @var array
43
+     */
44
+    protected $meta_key_to_props = array(
45
+        '_wpinv_subscr_profile_id' => 'remote_subscription_id',
46
+        '_wpinv_subscription_id'   => 'subscription_id',
47
+        '_wpinv_taxes'             => 'taxes',
48
+        '_wpinv_fees'              => 'fees',
49
+        '_wpinv_discounts'         => 'discounts',
50
+        '_wpinv_submission_id'     => 'submission_id',
51
+        '_wpinv_payment_form'      => 'payment_form',
52
+        '_wpinv_is_viewed'         => 'is_viewed',
53
+        'wpinv_email_cc'           => 'email_cc',
54
+        'wpinv_template'           => 'template',
55
+    );
56
+
57
+    /**
58
+     * A map of database fields to data props.
59
+     *
60
+     * @since 1.0.19
61
+     *
62
+     * @var array
63
+     */
64
+    protected $database_fields_to_props = array(
65
+        'post_id'            => 'id',
66
+        'number'             => 'number',
67
+        'currency'           => 'currency',
68
+        'key'                => 'key',
69
+        'type'               => 'type',
70
+        'mode'               => 'mode',
71
+        'user_ip'            => 'user_ip',
72
+        'first_name'         => 'first_name',
73
+        'last_name'          => 'last_name',
74
+        'address'            => 'address',
75
+        'city'               => 'city',
76
+        'state'              => 'state',
77
+        'country'            => 'country',
78
+        'zip'                => 'zip',
79
+        'zip'                => 'zip',
80
+        'adddress_confirmed' => 'address_confirmed',
81
+        'gateway'            => 'gateway',
82
+        'transaction_id'     => 'transaction_id',
83
+        'currency'           => 'currency',
84
+        'subtotal'           => 'subtotal',
85
+        'tax'                => 'total_tax',
86
+        'fees_total'         => 'total_fees',
87
+        'discount'           => 'total_discount',
88
+        'total'              => 'total',
89
+        'discount_code'      => 'discount_code',
90
+        'disable_taxes'      => 'disable_taxes',
91
+        'due_date'           => 'due_date',
92
+        'completed_date'     => 'completed_date',
93
+        'company'            => 'company',
94
+        'vat_number'         => 'vat_number',
95
+        'vat_rate'           => 'vat_rate',
96
+    );
97
+
98
+    /*
99 99
 	|--------------------------------------------------------------------------
100 100
 	| CRUD Methods
101 101
 	|--------------------------------------------------------------------------
102 102
 	*/
103 103
 
104
-	/**
105
-	 * Method to create a new invoice in the database.
106
-	 *
107
-	 * @param WPInv_Invoice $invoice Invoice object.
108
-	 */
109
-	public function create( &$invoice ) {
110
-		$invoice->set_version( WPINV_VERSION );
111
-		$invoice->set_date_created( current_time('mysql') );
112
-
113
-		// Create a new post.
114
-		$id = wp_insert_post(
115
-			apply_filters(
116
-				'getpaid_new_invoice_data',
117
-				array(
118
-					'post_date'     => $invoice->get_date_created( 'edit' ),
119
-					'post_type'     => $invoice->get_post_type( 'edit' ),
120
-					'post_status'   => $this->get_post_status( $invoice ),
121
-					'ping_status'   => 'closed',
122
-					'post_author'   => $invoice->get_user_id( 'edit' ),
123
-					'post_title'    => $invoice->get_title( 'edit' ),
124
-					'post_excerpt'  => $invoice->get_description( 'edit' ),
125
-					'post_parent'   => $invoice->get_parent_id( 'edit' ),
126
-				)
127
-			),
128
-			true
129
-		);
130
-
131
-		if ( $id && ! is_wp_error( $id ) ) {
132
-
133
-			// Update the new id and regenerate a title.
134
-			$invoice->set_id( $id );
135
-
136
-			$invoice->maybe_set_number();
137
-
138
-			wp_update_post(
139
-				array(
140
-					'ID'         => $invoice->get_id(),
141
-					'post_title' => $invoice->get_number( 'edit' ),
142
-					'post_name'  => $invoice->get_path( 'edit' )
143
-				)
144
-			);
145
-
146
-			// Save special fields and items.
147
-			$this->save_special_fields( $invoice );
148
-			$this->save_items( $invoice );
149
-
150
-			// Update meta data.
151
-			$this->update_post_meta( $invoice );
152
-			$invoice->save_meta_data();
153
-
154
-			// Apply changes.
155
-			$invoice->apply_changes();
156
-			$this->clear_caches( $invoice );
157
-
158
-			// Fires after a new invoice is created.
159
-			do_action( 'getpaid_new_' . $invoice->get_type(), $invoice );
160
-			return true;
161
-		}
162
-
163
-		if ( is_wp_error( $id ) ) {
164
-			$invoice->last_error = $id->get_error_message();
165
-		}
166
-
167
-		return false;
168
-	}
169
-
170
-	/**
171
-	 * Method to read an invoice from the database.
172
-	 *
173
-	 * @param WPInv_Invoice $invoice Invoice object.
174
-	 *
175
-	 */
176
-	public function read( &$invoice ) {
177
-
178
-		$invoice->set_defaults();
179
-		$invoice_object = get_post( $invoice->get_id() );
180
-
181
-		if ( ! $invoice->get_id() || ! $invoice_object || ! getpaid_is_invoice_post_type( $invoice_object->post_type ) ) {
182
-			$invoice->last_error = __( 'Invalid invoice.', 'invoicing' );
183
-			$invoice->set_id( 0 );
184
-			return false;
185
-		}
186
-
187
-		$invoice->set_props(
188
-			array(
189
-				'date_created'  => 0 < $invoice_object->post_date ? $invoice_object->post_date : null,
190
-				'date_modified' => 0 < $invoice_object->post_modified ? $invoice_object->post_modified : null,
191
-				'status'        => $invoice_object->post_status,
192
-				'author'        => $invoice_object->post_author,
193
-				'description'   => $invoice_object->post_excerpt,
194
-				'parent_id'     => $invoice_object->post_parent,
195
-				'name'          => $invoice_object->post_title,
196
-				'path'          => $invoice_object->post_name,
197
-				'post_type'     => $invoice_object->post_type,
198
-			)
199
-		);
200
-
201
-		$invoice->set_type( $invoice_object->post_type );
202
-
203
-		$this->read_object_data( $invoice, $invoice_object );
204
-		$this->add_special_fields( $invoice );
205
-		$this->add_items( $invoice );
206
-		$invoice->read_meta_data();
207
-		$invoice->set_object_read( true );
208
-		do_action( 'getpaid_read_' . $invoice->get_type(), $invoice );
209
-
210
-	}
211
-
212
-	/**
213
-	 * Method to update an invoice in the database.
214
-	 *
215
-	 * @param WPInv_Invoice $invoice Invoice object.
216
-	 */
217
-	public function update( &$invoice ) {
218
-		$invoice->save_meta_data();
219
-		$invoice->set_version( WPINV_VERSION );
220
-
221
-		if ( null === $invoice->get_date_created( 'edit' ) ) {
222
-			$invoice->set_date_created(  current_time('mysql') );
223
-		}
224
-
225
-		// Ensure both the key and number are set.
226
-		$invoice->get_path();
227
-
228
-		// Grab the current status so we can compare.
229
-		$previous_status = get_post_status( $invoice->get_id() );
230
-
231
-		$changes = $invoice->get_changes();
232
-
233
-		// Only update the post when the post data changes.
234
-		if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'name', 'author', 'description', 'parent_id', 'post_excerpt', 'path' ), array_keys( $changes ) ) ) {
235
-			$post_data = array(
236
-				'post_date'         => $invoice->get_date_created( 'edit' ),
237
-				'post_date_gmt'     => $invoice->get_date_created_gmt( 'edit' ),
238
-				'post_status'       => $invoice->get_status( 'edit' ),
239
-				'post_title'        => $invoice->get_name( 'edit' ),
240
-				'post_author'       => $invoice->get_user_id( 'edit' ),
241
-				'post_modified'     => $invoice->get_date_modified( 'edit' ),
242
-				'post_excerpt'      => $invoice->get_description( 'edit' ),
243
-				'post_parent'       => $invoice->get_parent_id( 'edit' ),
244
-				'post_name'         => $invoice->get_path( 'edit' ),
245
-				'post_type'         => $invoice->get_post_type( 'edit' ),
246
-			);
247
-
248
-			/**
249
-			 * When updating this object, to prevent infinite loops, use $wpdb
250
-			 * to update data, since wp_update_post spawns more calls to the
251
-			 * save_post action.
252
-			 *
253
-			 * This ensures hooks are fired by either WP itself (admin screen save),
254
-			 * or an update purely from CRUD.
255
-			 */
256
-			if ( doing_action( 'save_post' ) ) {
257
-				$GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $invoice->get_id() ) );
258
-				clean_post_cache( $invoice->get_id() );
259
-			} else {
260
-				wp_update_post( array_merge( array( 'ID' => $invoice->get_id() ), $post_data ) );
261
-			}
262
-			$invoice->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
263
-		}
264
-
265
-		// Update meta data.
266
-		$this->update_post_meta( $invoice );
267
-
268
-		// Save special fields and items.
269
-		$this->save_special_fields( $invoice );
270
-		$this->save_items( $invoice );
271
-
272
-		// Apply the changes.
273
-		$invoice->apply_changes();
274
-
275
-		// Clear caches.
276
-		$this->clear_caches( $invoice );
277
-
278
-		// Fire a hook depending on the status - this should be considered a creation if it was previously draft status.
279
-		$new_status = $invoice->get_status( 'edit' );
280
-
281
-		if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) {
282
-			do_action( 'getpaid_new_' . $invoice->get_type(), $invoice );
283
-		} else {
284
-			do_action( 'getpaid_update_' . $invoice->get_type(), $invoice );
285
-		}
286
-
287
-	}
288
-
289
-	/*
104
+    /**
105
+     * Method to create a new invoice in the database.
106
+     *
107
+     * @param WPInv_Invoice $invoice Invoice object.
108
+     */
109
+    public function create( &$invoice ) {
110
+        $invoice->set_version( WPINV_VERSION );
111
+        $invoice->set_date_created( current_time('mysql') );
112
+
113
+        // Create a new post.
114
+        $id = wp_insert_post(
115
+            apply_filters(
116
+                'getpaid_new_invoice_data',
117
+                array(
118
+                    'post_date'     => $invoice->get_date_created( 'edit' ),
119
+                    'post_type'     => $invoice->get_post_type( 'edit' ),
120
+                    'post_status'   => $this->get_post_status( $invoice ),
121
+                    'ping_status'   => 'closed',
122
+                    'post_author'   => $invoice->get_user_id( 'edit' ),
123
+                    'post_title'    => $invoice->get_title( 'edit' ),
124
+                    'post_excerpt'  => $invoice->get_description( 'edit' ),
125
+                    'post_parent'   => $invoice->get_parent_id( 'edit' ),
126
+                )
127
+            ),
128
+            true
129
+        );
130
+
131
+        if ( $id && ! is_wp_error( $id ) ) {
132
+
133
+            // Update the new id and regenerate a title.
134
+            $invoice->set_id( $id );
135
+
136
+            $invoice->maybe_set_number();
137
+
138
+            wp_update_post(
139
+                array(
140
+                    'ID'         => $invoice->get_id(),
141
+                    'post_title' => $invoice->get_number( 'edit' ),
142
+                    'post_name'  => $invoice->get_path( 'edit' )
143
+                )
144
+            );
145
+
146
+            // Save special fields and items.
147
+            $this->save_special_fields( $invoice );
148
+            $this->save_items( $invoice );
149
+
150
+            // Update meta data.
151
+            $this->update_post_meta( $invoice );
152
+            $invoice->save_meta_data();
153
+
154
+            // Apply changes.
155
+            $invoice->apply_changes();
156
+            $this->clear_caches( $invoice );
157
+
158
+            // Fires after a new invoice is created.
159
+            do_action( 'getpaid_new_' . $invoice->get_type(), $invoice );
160
+            return true;
161
+        }
162
+
163
+        if ( is_wp_error( $id ) ) {
164
+            $invoice->last_error = $id->get_error_message();
165
+        }
166
+
167
+        return false;
168
+    }
169
+
170
+    /**
171
+     * Method to read an invoice from the database.
172
+     *
173
+     * @param WPInv_Invoice $invoice Invoice object.
174
+     *
175
+     */
176
+    public function read( &$invoice ) {
177
+
178
+        $invoice->set_defaults();
179
+        $invoice_object = get_post( $invoice->get_id() );
180
+
181
+        if ( ! $invoice->get_id() || ! $invoice_object || ! getpaid_is_invoice_post_type( $invoice_object->post_type ) ) {
182
+            $invoice->last_error = __( 'Invalid invoice.', 'invoicing' );
183
+            $invoice->set_id( 0 );
184
+            return false;
185
+        }
186
+
187
+        $invoice->set_props(
188
+            array(
189
+                'date_created'  => 0 < $invoice_object->post_date ? $invoice_object->post_date : null,
190
+                'date_modified' => 0 < $invoice_object->post_modified ? $invoice_object->post_modified : null,
191
+                'status'        => $invoice_object->post_status,
192
+                'author'        => $invoice_object->post_author,
193
+                'description'   => $invoice_object->post_excerpt,
194
+                'parent_id'     => $invoice_object->post_parent,
195
+                'name'          => $invoice_object->post_title,
196
+                'path'          => $invoice_object->post_name,
197
+                'post_type'     => $invoice_object->post_type,
198
+            )
199
+        );
200
+
201
+        $invoice->set_type( $invoice_object->post_type );
202
+
203
+        $this->read_object_data( $invoice, $invoice_object );
204
+        $this->add_special_fields( $invoice );
205
+        $this->add_items( $invoice );
206
+        $invoice->read_meta_data();
207
+        $invoice->set_object_read( true );
208
+        do_action( 'getpaid_read_' . $invoice->get_type(), $invoice );
209
+
210
+    }
211
+
212
+    /**
213
+     * Method to update an invoice in the database.
214
+     *
215
+     * @param WPInv_Invoice $invoice Invoice object.
216
+     */
217
+    public function update( &$invoice ) {
218
+        $invoice->save_meta_data();
219
+        $invoice->set_version( WPINV_VERSION );
220
+
221
+        if ( null === $invoice->get_date_created( 'edit' ) ) {
222
+            $invoice->set_date_created(  current_time('mysql') );
223
+        }
224
+
225
+        // Ensure both the key and number are set.
226
+        $invoice->get_path();
227
+
228
+        // Grab the current status so we can compare.
229
+        $previous_status = get_post_status( $invoice->get_id() );
230
+
231
+        $changes = $invoice->get_changes();
232
+
233
+        // Only update the post when the post data changes.
234
+        if ( array_intersect( array( 'date_created', 'date_modified', 'status', 'name', 'author', 'description', 'parent_id', 'post_excerpt', 'path' ), array_keys( $changes ) ) ) {
235
+            $post_data = array(
236
+                'post_date'         => $invoice->get_date_created( 'edit' ),
237
+                'post_date_gmt'     => $invoice->get_date_created_gmt( 'edit' ),
238
+                'post_status'       => $invoice->get_status( 'edit' ),
239
+                'post_title'        => $invoice->get_name( 'edit' ),
240
+                'post_author'       => $invoice->get_user_id( 'edit' ),
241
+                'post_modified'     => $invoice->get_date_modified( 'edit' ),
242
+                'post_excerpt'      => $invoice->get_description( 'edit' ),
243
+                'post_parent'       => $invoice->get_parent_id( 'edit' ),
244
+                'post_name'         => $invoice->get_path( 'edit' ),
245
+                'post_type'         => $invoice->get_post_type( 'edit' ),
246
+            );
247
+
248
+            /**
249
+             * When updating this object, to prevent infinite loops, use $wpdb
250
+             * to update data, since wp_update_post spawns more calls to the
251
+             * save_post action.
252
+             *
253
+             * This ensures hooks are fired by either WP itself (admin screen save),
254
+             * or an update purely from CRUD.
255
+             */
256
+            if ( doing_action( 'save_post' ) ) {
257
+                $GLOBALS['wpdb']->update( $GLOBALS['wpdb']->posts, $post_data, array( 'ID' => $invoice->get_id() ) );
258
+                clean_post_cache( $invoice->get_id() );
259
+            } else {
260
+                wp_update_post( array_merge( array( 'ID' => $invoice->get_id() ), $post_data ) );
261
+            }
262
+            $invoice->read_meta_data( true ); // Refresh internal meta data, in case things were hooked into `save_post` or another WP hook.
263
+        }
264
+
265
+        // Update meta data.
266
+        $this->update_post_meta( $invoice );
267
+
268
+        // Save special fields and items.
269
+        $this->save_special_fields( $invoice );
270
+        $this->save_items( $invoice );
271
+
272
+        // Apply the changes.
273
+        $invoice->apply_changes();
274
+
275
+        // Clear caches.
276
+        $this->clear_caches( $invoice );
277
+
278
+        // Fire a hook depending on the status - this should be considered a creation if it was previously draft status.
279
+        $new_status = $invoice->get_status( 'edit' );
280
+
281
+        if ( $new_status !== $previous_status && in_array( $previous_status, array( 'new', 'auto-draft', 'draft' ), true ) ) {
282
+            do_action( 'getpaid_new_' . $invoice->get_type(), $invoice );
283
+        } else {
284
+            do_action( 'getpaid_update_' . $invoice->get_type(), $invoice );
285
+        }
286
+
287
+    }
288
+
289
+    /*
290 290
 	|--------------------------------------------------------------------------
291 291
 	| Additional Methods
292 292
 	|--------------------------------------------------------------------------
293 293
 	*/
294 294
 
295
-	/**
295
+    /**
296 296
      * Retrieves special fields and adds to the invoice.
297
-	 *
298
-	 * @param WPInv_Invoice $invoice Invoice object.
297
+     *
298
+     * @param WPInv_Invoice $invoice Invoice object.
299 299
      */
300 300
     public function add_special_fields( &$invoice ) {
301
-		global $wpdb;
301
+        global $wpdb;
302 302
 
303
-		// Maybe retrieve from the cache.
304
-		$data   = wp_cache_get( $invoice->get_id(), 'getpaid_invoice_special_fields' );
303
+        // Maybe retrieve from the cache.
304
+        $data   = wp_cache_get( $invoice->get_id(), 'getpaid_invoice_special_fields' );
305 305
 
306
-		// If not found, retrieve from the db.
307
-		if ( false === $data ) {
308
-			$table =  $wpdb->prefix . 'getpaid_invoices';
306
+        // If not found, retrieve from the db.
307
+        if ( false === $data ) {
308
+            $table =  $wpdb->prefix . 'getpaid_invoices';
309 309
 
310
-			$data  = $wpdb->get_row(
311
-				$wpdb->prepare( "SELECT * FROM $table WHERE `post_id`=%d LIMIT 1", $invoice->get_id() ),
312
-				ARRAY_A
313
-			);
310
+            $data  = $wpdb->get_row(
311
+                $wpdb->prepare( "SELECT * FROM $table WHERE `post_id`=%d LIMIT 1", $invoice->get_id() ),
312
+                ARRAY_A
313
+            );
314 314
 
315
-			// Update the cache with our data
316
-			wp_cache_set( $invoice->get_id(), $data, 'getpaid_invoice_special_fields' );
315
+            // Update the cache with our data
316
+            wp_cache_set( $invoice->get_id(), $data, 'getpaid_invoice_special_fields' );
317 317
 
318
-		}
318
+        }
319 319
 
320
-		// Abort if the data does not exist.
321
-		if ( empty( $data ) ) {
322
-			$invoice->set_object_read( true );
323
-			$invoice->set_props( wpinv_get_user_address( $invoice->get_user_id() ) );
324
-			return;
325
-		}
320
+        // Abort if the data does not exist.
321
+        if ( empty( $data ) ) {
322
+            $invoice->set_object_read( true );
323
+            $invoice->set_props( wpinv_get_user_address( $invoice->get_user_id() ) );
324
+            return;
325
+        }
326 326
 
327
-		$props = array();
327
+        $props = array();
328 328
 
329
-		foreach ( $this->database_fields_to_props as $db_field => $prop ) {
329
+        foreach ( $this->database_fields_to_props as $db_field => $prop ) {
330 330
 			
331
-			if ( $db_field == 'post_id' ) {
332
-				continue;
333
-			}
334
-
335
-			$props[ $prop ] = $data[ $db_field ];
336
-		}
337
-
338
-		$invoice->set_props( $props );
339
-
340
-	}
341
-
342
-	/**
343
-	 * Gets a list of special fields that need updated based on change state
344
-	 * or if they are present in the database or not.
345
-	 *
346
-	 * @param  WPInv_Invoice $invoice       The Invoice object.
347
-	 * @return array                        A mapping of field keys => prop names, filtered by ones that should be updated.
348
-	 */
349
-	protected function get_special_fields_to_update( $invoice ) {
350
-		$fields_to_update = array();
351
-		$changed_props   = $invoice->get_changes();
352
-
353
-		// Props should be updated if they are a part of the $changed array or don't exist yet.
354
-		foreach ( $this->database_fields_to_props as $database_field => $prop ) {
355
-			if ( array_key_exists( $prop, $changed_props ) ) {
356
-				$fields_to_update[ $database_field ] = $prop;
357
-			}
358
-		}
359
-
360
-		return $fields_to_update;
361
-	}
362
-
363
-	/**
364
-	 * Helper method that updates all the database fields for an invoice based on it's settings in the WPInv_Invoice class.
365
-	 *
366
-	 * @param WPInv_Invoice $invoice WPInv_Invoice object.
367
-	 * @since 1.0.19
368
-	 */
369
-	protected function update_special_fields( &$invoice ) {
370
-		global $wpdb;
371
-
372
-		$updated_props    = array();
373
-		$fields_to_update = $this->get_special_fields_to_update( $invoice );
374
-
375
-		foreach ( $fields_to_update as $database_field => $prop ) {
376
-			$value = $invoice->{"get_$prop"}( 'edit' );
377
-			$value = is_string( $value ) ? wp_slash( $value ) : $value;
378
-			$value = is_bool( $value ) ? ( int ) $value : $value;
379
-			$updated_props[ $database_field ] = maybe_serialize( $value );
380
-		}
381
-
382
-		if ( ! empty( $updated_props ) ) {
383
-
384
-			$table = $wpdb->prefix . 'getpaid_invoices';
385
-			$wpdb->update( $table, $updated_props, array( 'post_id' => $invoice->get_id() ) );
386
-			wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_special_fields' );
387
-			do_action( "getpaid_invoice_update_database_fields", $invoice, $updated_props );
388
-
389
-		}
390
-
391
-	}
392
-
393
-	/**
394
-	 * Helper method that inserts special fields to the database.
395
-	 *
396
-	 * @param WPInv_Invoice $invoice WPInv_Invoice object.
397
-	 * @since 1.0.19
398
-	 */
399
-	protected function insert_special_fields( &$invoice ) {
400
-		global $wpdb;
401
-
402
-		$updated_props   = array();
403
-
404
-		foreach ( $this->database_fields_to_props as $database_field => $prop ) {
405
-			$value = $invoice->{"get_$prop"}( 'edit' );
406
-			$value = is_string( $value ) ? wp_slash( $value ) : $value;
407
-			$value = is_bool( $value ) ? ( int ) $value : $value;
408
-			$updated_props[ $database_field ] = maybe_serialize( $value );
409
-		}
410
-
411
-		$table = $wpdb->prefix . 'getpaid_invoices';
412
-		$wpdb->insert( $table, $updated_props );
413
-		wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_special_fields' );
414
-		do_action( "getpaid_invoice_insert_database_fields", $invoice, $updated_props );
415
-
416
-	}
417
-
418
-	/**
331
+            if ( $db_field == 'post_id' ) {
332
+                continue;
333
+            }
334
+
335
+            $props[ $prop ] = $data[ $db_field ];
336
+        }
337
+
338
+        $invoice->set_props( $props );
339
+
340
+    }
341
+
342
+    /**
343
+     * Gets a list of special fields that need updated based on change state
344
+     * or if they are present in the database or not.
345
+     *
346
+     * @param  WPInv_Invoice $invoice       The Invoice object.
347
+     * @return array                        A mapping of field keys => prop names, filtered by ones that should be updated.
348
+     */
349
+    protected function get_special_fields_to_update( $invoice ) {
350
+        $fields_to_update = array();
351
+        $changed_props   = $invoice->get_changes();
352
+
353
+        // Props should be updated if they are a part of the $changed array or don't exist yet.
354
+        foreach ( $this->database_fields_to_props as $database_field => $prop ) {
355
+            if ( array_key_exists( $prop, $changed_props ) ) {
356
+                $fields_to_update[ $database_field ] = $prop;
357
+            }
358
+        }
359
+
360
+        return $fields_to_update;
361
+    }
362
+
363
+    /**
364
+     * Helper method that updates all the database fields for an invoice based on it's settings in the WPInv_Invoice class.
365
+     *
366
+     * @param WPInv_Invoice $invoice WPInv_Invoice object.
367
+     * @since 1.0.19
368
+     */
369
+    protected function update_special_fields( &$invoice ) {
370
+        global $wpdb;
371
+
372
+        $updated_props    = array();
373
+        $fields_to_update = $this->get_special_fields_to_update( $invoice );
374
+
375
+        foreach ( $fields_to_update as $database_field => $prop ) {
376
+            $value = $invoice->{"get_$prop"}( 'edit' );
377
+            $value = is_string( $value ) ? wp_slash( $value ) : $value;
378
+            $value = is_bool( $value ) ? ( int ) $value : $value;
379
+            $updated_props[ $database_field ] = maybe_serialize( $value );
380
+        }
381
+
382
+        if ( ! empty( $updated_props ) ) {
383
+
384
+            $table = $wpdb->prefix . 'getpaid_invoices';
385
+            $wpdb->update( $table, $updated_props, array( 'post_id' => $invoice->get_id() ) );
386
+            wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_special_fields' );
387
+            do_action( "getpaid_invoice_update_database_fields", $invoice, $updated_props );
388
+
389
+        }
390
+
391
+    }
392
+
393
+    /**
394
+     * Helper method that inserts special fields to the database.
395
+     *
396
+     * @param WPInv_Invoice $invoice WPInv_Invoice object.
397
+     * @since 1.0.19
398
+     */
399
+    protected function insert_special_fields( &$invoice ) {
400
+        global $wpdb;
401
+
402
+        $updated_props   = array();
403
+
404
+        foreach ( $this->database_fields_to_props as $database_field => $prop ) {
405
+            $value = $invoice->{"get_$prop"}( 'edit' );
406
+            $value = is_string( $value ) ? wp_slash( $value ) : $value;
407
+            $value = is_bool( $value ) ? ( int ) $value : $value;
408
+            $updated_props[ $database_field ] = maybe_serialize( $value );
409
+        }
410
+
411
+        $table = $wpdb->prefix . 'getpaid_invoices';
412
+        $wpdb->insert( $table, $updated_props );
413
+        wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_special_fields' );
414
+        do_action( "getpaid_invoice_insert_database_fields", $invoice, $updated_props );
415
+
416
+    }
417
+
418
+    /**
419 419
      * Saves all special fields.
420
-	 *
421
-	 * @param WPInv_Invoice $invoice Invoice object.
420
+     *
421
+     * @param WPInv_Invoice $invoice Invoice object.
422 422
      */
423 423
     public function save_special_fields( & $invoice ) {
424
-		global $wpdb;
424
+        global $wpdb;
425 425
 
426
-		// The invoices table.
427
-		$table = $wpdb->prefix . 'getpaid_invoices';
428
-		$id    = (int) $invoice->get_id();
429
-		$invoice->maybe_set_key();
426
+        // The invoices table.
427
+        $table = $wpdb->prefix . 'getpaid_invoices';
428
+        $id    = (int) $invoice->get_id();
429
+        $invoice->maybe_set_key();
430 430
 
431
-		if ( $wpdb->get_var( "SELECT `post_id` FROM $table WHERE `post_id`= $id" ) ) {
431
+        if ( $wpdb->get_var( "SELECT `post_id` FROM $table WHERE `post_id`= $id" ) ) {
432 432
 
433
-			$this->update_special_fields( $invoice );
433
+            $this->update_special_fields( $invoice );
434 434
 
435
-		} else {
435
+        } else {
436 436
 
437
-			$this->insert_special_fields( $invoice );
437
+            $this->insert_special_fields( $invoice );
438 438
 
439
-		}
439
+        }
440 440
 
441
-	}
441
+    }
442 442
 
443
-	/**
443
+    /**
444 444
      * Set's up cart details.
445
-	 *
446
-	 * @param WPInv_Invoice $invoice Invoice object.
445
+     *
446
+     * @param WPInv_Invoice $invoice Invoice object.
447 447
      */
448 448
     public function add_items( &$invoice ) {
449
-		global $wpdb;
449
+        global $wpdb;
450 450
 
451
-		// Maybe retrieve from the cache.
452
-		$items = wp_cache_get( $invoice->get_id(), 'getpaid_invoice_cart_details' );
451
+        // Maybe retrieve from the cache.
452
+        $items = wp_cache_get( $invoice->get_id(), 'getpaid_invoice_cart_details' );
453 453
 
454
-		// If not found, retrieve from the db.
455
-		if ( false === $items ) {
456
-			$table =  $wpdb->prefix . 'getpaid_invoice_items';
454
+        // If not found, retrieve from the db.
455
+        if ( false === $items ) {
456
+            $table =  $wpdb->prefix . 'getpaid_invoice_items';
457 457
 
458
-			$items = $wpdb->get_results(
459
-				$wpdb->prepare( "SELECT * FROM $table WHERE `post_id`=%d", $invoice->get_id() )
460
-			);
458
+            $items = $wpdb->get_results(
459
+                $wpdb->prepare( "SELECT * FROM $table WHERE `post_id`=%d", $invoice->get_id() )
460
+            );
461 461
 
462
-			// Update the cache with our data
463
-			wp_cache_set( $invoice->get_id(), $items, 'getpaid_invoice_cart_details' );
462
+            // Update the cache with our data
463
+            wp_cache_set( $invoice->get_id(), $items, 'getpaid_invoice_cart_details' );
464 464
 
465
-		}
465
+        }
466 466
 
467
-		// Abort if no items found.
467
+        // Abort if no items found.
468 468
         if ( empty( $items ) ) {
469 469
             return;
470
-		}
470
+        }
471 471
 
472
-		foreach ( $items as $item_data ) {
473
-			$item = new GetPaid_Form_Item( $item_data->item_id );
472
+        foreach ( $items as $item_data ) {
473
+            $item = new GetPaid_Form_Item( $item_data->item_id );
474 474
 
475
-			// Set item data.
476
-			$item->item_tax      = wpinv_sanitize_amount( $item_data->tax );
477
-			$item->item_discount = wpinv_sanitize_amount( $item_data->discount );
478
-			$item->set_name( $item_data->item_name );
479
-			$item->set_description( $item_data->item_description );
480
-			$item->set_price( $item_data->item_price );
481
-			$item->set_quantity( $item_data->quantity );
482
-			$item->set_item_meta( $item_data->meta );
475
+            // Set item data.
476
+            $item->item_tax      = wpinv_sanitize_amount( $item_data->tax );
477
+            $item->item_discount = wpinv_sanitize_amount( $item_data->discount );
478
+            $item->set_name( $item_data->item_name );
479
+            $item->set_description( $item_data->item_description );
480
+            $item->set_price( $item_data->item_price );
481
+            $item->set_quantity( $item_data->quantity );
482
+            $item->set_item_meta( $item_data->meta );
483 483
 
484
-			$invoice->add_item( $item );
485
-		}
484
+            $invoice->add_item( $item );
485
+        }
486 486
 
487
-	}
487
+    }
488 488
 
489
-	/**
489
+    /**
490 490
      * Saves cart details.
491
-	 *
492
-	 * @param WPInv_Invoice $invoice Invoice object.
491
+     *
492
+     * @param WPInv_Invoice $invoice Invoice object.
493 493
      */
494 494
     public function save_items( $invoice ) {
495 495
 
496
-		// Delete previously existing items.
497
-		$this->delete_items( $invoice );
496
+        // Delete previously existing items.
497
+        $this->delete_items( $invoice );
498 498
 
499
-		$table   =  $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items';
499
+        $table   =  $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items';
500 500
 
501
-		foreach ( $invoice->get_cart_details() as $item_data ) {
502
-			$item_data = array_map( 'maybe_serialize', $item_data );
503
-			$GLOBALS['wpdb']->insert( $table, $item_data );
504
-		}
501
+        foreach ( $invoice->get_cart_details() as $item_data ) {
502
+            $item_data = array_map( 'maybe_serialize', $item_data );
503
+            $GLOBALS['wpdb']->insert( $table, $item_data );
504
+        }
505 505
 
506
-		wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_cart_details' );
507
-		do_action( "getpaid_invoice_save_items", $invoice );
506
+        wp_cache_delete( $invoice->get_id(), 'getpaid_invoice_cart_details' );
507
+        do_action( "getpaid_invoice_save_items", $invoice );
508 508
 
509
-	}
509
+    }
510 510
 
511
-	/**
511
+    /**
512 512
      * Deletes an invoice's cart details from the database.
513
-	 *
514
-	 * @param WPInv_Invoice $invoice Invoice object.
513
+     *
514
+     * @param WPInv_Invoice $invoice Invoice object.
515 515
      */
516 516
     public function delete_items( $invoice ) {
517
-		$table =  $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items';
518
-		return $GLOBALS['wpdb']->delete( $table, array( 'post_id' => $invoice->get_id() ) );
519
-	}
517
+        $table =  $GLOBALS['wpdb']->prefix . 'getpaid_invoice_items';
518
+        return $GLOBALS['wpdb']->delete( $table, array( 'post_id' => $invoice->get_id() ) );
519
+    }
520 520
 
521
-	/**
521
+    /**
522 522
      * Deletes an invoice's special fields from the database.
523
-	 *
524
-	 * @param WPInv_Invoice $invoice Invoice object.
523
+     *
524
+     * @param WPInv_Invoice $invoice Invoice object.
525 525
      */
526 526
     public function delete_special_fields( $invoice ) {
527
-		$table =  $GLOBALS['wpdb']->prefix . 'getpaid_invoices';
528
-		return $GLOBALS['wpdb']->delete( $table, array( 'post_id' => $invoice->get_id() ) );
527
+        $table =  $GLOBALS['wpdb']->prefix . 'getpaid_invoices';
528
+        return $GLOBALS['wpdb']->delete( $table, array( 'post_id' => $invoice->get_id() ) );
529 529
     }
530 530
 
531 531
 }
Please login to merge, or discard this patch.
templates/invoice-history.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -40,86 +40,86 @@  discard block
 block discarded – undo
40 40
 				<tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
41 41
 					<?php
42 42
 
43
-						foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) :
43
+                        foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) :
44 44
 
45
-							$column_id = sanitize_html_class( $column_id );
46
-							$class     = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] );
45
+                            $column_id = sanitize_html_class( $column_id );
46
+                            $class     = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] );
47 47
 
48
-							echo "<td class='$column_id $class'>";
49
-							switch ( $column_id ) {
48
+                            echo "<td class='$column_id $class'>";
49
+                            switch ( $column_id ) {
50 50
 
51
-								case 'invoice-number':
52
-									echo wpinv_invoice_link( $invoice );
53
-									break;
51
+                                case 'invoice-number':
52
+                                    echo wpinv_invoice_link( $invoice );
53
+                                    break;
54 54
 
55
-								case 'created-date':
56
-									echo date_i18n( get_option( 'date_format' ), strtotime( $invoice->get_date_created() ) );
57
-									break;
55
+                                case 'created-date':
56
+                                    echo date_i18n( get_option( 'date_format' ), strtotime( $invoice->get_date_created() ) );
57
+                                    break;
58 58
 
59
-								case 'payment-date':
59
+                                case 'payment-date':
60 60
 
61
-									if ( $invoice->needs_payment() ) {
62
-										echo "&mdash;";
63
-									} else {
64
-										echo date_i18n( get_option( 'date_format' ), strtotime( $invoice->get_date_completed() ) );
65
-									}
61
+                                    if ( $invoice->needs_payment() ) {
62
+                                        echo "&mdash;";
63
+                                    } else {
64
+                                        echo date_i18n( get_option( 'date_format' ), strtotime( $invoice->get_date_completed() ) );
65
+                                    }
66 66
 									
67
-									break;
67
+                                    break;
68 68
 
69
-								case 'invoice-status':
70
-									echo $invoice->get_status_label_html();
69
+                                case 'invoice-status':
70
+                                    echo $invoice->get_status_label_html();
71 71
 									
72
-									break;
72
+                                    break;
73 73
 
74
-								case 'invoice-total':
75
-									echo wpinv_price( wpinv_format_amount( $invoice->get_total() ) );
74
+                                case 'invoice-total':
75
+                                    echo wpinv_price( wpinv_format_amount( $invoice->get_total() ) );
76 76
 									
77
-									break;
77
+                                    break;
78 78
 
79
-								case 'invoice-actions':
79
+                                case 'invoice-actions':
80 80
 
81
-									$actions = array(
81
+                                    $actions = array(
82 82
 
83
-										'pay'       => array(
84
-											'url'   => $invoice->get_checkout_payment_url(),
85
-											'name'  => __( 'Pay Now', 'invoicing' ),
83
+                                        'pay'       => array(
84
+                                            'url'   => $invoice->get_checkout_payment_url(),
85
+                                            'name'  => __( 'Pay Now', 'invoicing' ),
86 86
                                             'class' => 'btn-success'
87
-										),
87
+                                        ),
88 88
 
89 89
                                         'print'     => array(
90
-											'url'   => $invoice->get_view_url(),
91
-											'name'  => __( 'View Invoice', 'invoicing' ),
90
+                                            'url'   => $invoice->get_view_url(),
91
+                                            'name'  => __( 'View Invoice', 'invoicing' ),
92 92
                                             'class' => 'btn-secondary',
93 93
                                             'attrs' => 'target="_blank"'
94
-										)
95
-									);
94
+                                        )
95
+                                    );
96 96
 
97
-									if ( ! $invoice->needs_payment() ) {
98
-										unset( $actions['pay'] );
99
-									}
97
+                                    if ( ! $invoice->needs_payment() ) {
98
+                                        unset( $actions['pay'] );
99
+                                    }
100 100
 
101
-									$actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice );
101
+                                    $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice );
102 102
 
103
-									foreach ( $actions as $key => $action ) {
104
-										$class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
105
-										echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
106
-									}
103
+                                    foreach ( $actions as $key => $action ) {
104
+                                        $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
105
+                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
106
+                                    }
107 107
 									
108
-									break;
108
+                                    break;
109 109
 
110
-								default:
111
-									do_action( "wpinv_user_invoices_column_$column_id", $invoice );
112
-									break;
110
+                                default:
111
+                                    do_action( "wpinv_user_invoices_column_$column_id", $invoice );
112
+                                    break;
113 113
 
114 114
 								
115
-							}
115
+                            }
116 116
 
117
-							do_action( "wpinv_user_invoices_column_after_$column_id", $invoice );
117
+                            do_action( "wpinv_user_invoices_column_after_$column_id", $invoice );
118 118
 						
119
-							echo '</td>';
119
+                            echo '</td>';
120 120
 
121
-						endforeach;
122
-					?>
121
+                        endforeach;
122
+                    ?>
123 123
 				</tr>
124 124
 
125 125
 			<?php endforeach; ?>
@@ -132,14 +132,14 @@  discard block
 block discarded – undo
132 132
 	<?php if ( 1 < $invoices->max_num_pages ) : ?>
133 133
 		<div class="invoicing-Pagination">
134 134
 			<?php
135
-			$big = 999999;
136
-
137
-			echo paginate_links( array(
138
-				'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
139
-				'format'  => '?paged=%#%',
140
-				'total'   => $invoices->max_num_pages,
141
-			) );
142
-			?>
135
+            $big = 999999;
136
+
137
+            echo paginate_links( array(
138
+                'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
139
+                'format'  => '?paged=%#%',
140
+                'total'   => $invoices->max_num_pages,
141
+            ) );
142
+            ?>
143 143
 		</div>
144 144
 	<?php endif; ?>
145 145
 
Please login to merge, or discard this patch.