Passed
Pull Request — master (#387)
by Brian
08:47
created
includes/class-getpaid-payment-form-submission.php 1 patch
Indentation   +813 added lines, -813 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,891 +10,891 @@  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
-	 * The total fees amount for the submission.
92
-	 *
93
-	 * @var float
94
-	 */
95
-	protected $total_fees_amount = 0;
96
-
97
-	/**
98
-	 * An array of fees for the submission.
99
-	 *
100
-	 * @var array
101
-	 */
102
-	protected $fees = array();
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;
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
+     * The total fees amount for the submission.
92
+     *
93
+     * @var float
94
+     */
95
+    protected $total_fees_amount = 0;
96
+
97
+    /**
98
+     * An array of fees for the submission.
99
+     *
100
+     * @var array
101
+     */
102
+    protected $fees = array();
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 138
 	
139
-	/**
140
-	 * Checks if we have a digital vat rule.
141
-	 *
142
-	 * @var bool
143
-	 */
144
-	public $has_digital = false;
139
+    /**
140
+     * Checks if we have a digital vat rule.
141
+     *
142
+     * @var bool
143
+     */
144
+    public $has_digital = false;
145 145
 	
146
-	/**
147
-	 * Checks if we require vat.
148
-	 *
149
-	 * @var bool
150
-	 */
146
+    /**
147
+     * Checks if we require vat.
148
+     *
149
+     * @var bool
150
+     */
151 151
     public $requires_vat = false;
152 152
 
153 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
-	}
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['form_items'] ) ) {
225
-			$this->payment_form->set_items( $data['form_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
-	}
225
+            $this->payment_form->set_items( $data['form_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 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 ) {
451
-		$amount = (float) wpinv_sanitize_amount( $amount );
452
-
453
-		$this->total_tax_amount += $amount;
454
-
455
-		if ( isset( $this->taxes[ $name ] ) ) {
456
-			$this->taxes[ $name ] += $amount;
457
-		} else {
458
-			$this->taxes[ $name ] = $amount;
459
-		}
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 ] : 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 ) {
541
-		$amount = wpinv_sanitize_amount( $amount );
542
-
543
-		$this->total_discount_amount += $amount;
544
-
545
-		if ( isset( $this->discounts[ $name ] ) ) {
546
-			$this->discounts[ $name ] += $amount;
547
-		} else {
548
-			$this->discounts[ $name ] = $amount;
549
-		}
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 ];
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
-		}
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 ) {
451
+        $amount = (float) wpinv_sanitize_amount( $amount );
452
+
453
+        $this->total_tax_amount += $amount;
454
+
455
+        if ( isset( $this->taxes[ $name ] ) ) {
456
+            $this->taxes[ $name ] += $amount;
457
+        } else {
458
+            $this->taxes[ $name ] = $amount;
459
+        }
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() {
608 469
 
609
-		// For single use discounts...
610
-		if ( $discount->is_single_use ) {
470
+        $use_taxes = wpinv_use_taxes();
611 471
 
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
-			}
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 ] : 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 ) {
541
+        $amount = wpinv_sanitize_amount( $amount );
542
+
543
+        $this->total_discount_amount += $amount;
544
+
545
+        if ( isset( $this->discounts[ $name ] ) ) {
546
+            $this->discounts[ $name ] += $amount;
547
+        } else {
548
+            $this->discounts[ $name ] = $amount;
549
+        }
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 ];
562
+            unset( $this->discounts[ $name ] );
563
+        }
564
+
565
+    }
617 566
 
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
-			}
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
+    }
623 576
 
624
-		}
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
+    }
625 586
 
626
-		// Set the discount.
627
-		$this->discount = $discount;
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
+        }
628 598
 
629
-	}
599
+        // Fetch the discount.
600
+        $discount = wpinv_get_discount_obj( $this->data['discount'] );
630 601
 
631
-	/**
632
-	 * Removes an invalid discount code.
633
-	 *
634
-	 * @since 1.0.19
635
-	 */
636
-	public function maybe_remove_discount() {
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
+        }
637 608
 
638
-		// Do we have a discount?
639
-		if ( empty( $this->has_discount_code() ) ) {
640
-			return;
641
-		}
609
+        // For single use discounts...
610
+        if ( $discount->is_single_use ) {
642 611
 
643
-		// Fetch the discount amount.
644
-		$amount = $this->get_discount( 'Discount' );
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
+            }
645 617
 
646
-		// Abort early if this is a "zero" discount.
647
-		if ( empty( $amount ) ) {
648
-			return;
649
-		}
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
+            }
650 623
 
651
-		$total = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax();
624
+        }
652 625
 
653
-		if ( ! $this->discount->is_minimum_amount_met( $total ) ) {
654
-			$this->is_discount_valid = false;
626
+        // Set the discount.
627
+        $this->discount = $discount;
628
+
629
+    }
630
+
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 );
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 ] : 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 ) {
732
-		$amount = wpinv_sanitize_amount( $amount );
733
-
734
-		$this->total_fees_amount += $amount;
735
-
736
-		if ( isset( $this->fees[ $name ] ) ) {
737
-			$this->fees[ $name ] += $amount;
738
-		} else {
739
-			$this->fees[ $name ] = $amount;
740
-		}
741
-
742
-	}
743
-
744
-	/**
745
-	 * Returns the total fees amount.
746
-	 *
747
-	 * @since 1.0.19
748
-	 */
749
-	public function get_total_fees() {
750
-		return $this->total_fees_amount;
751
-	}
752
-
753
-	/**
754
-	 * Retrieves a specific fee.
755
-	 *
756
-	 * @since 1.0.19
757
-	 */
758
-	public function get_fee( $name ) {
759
-		return isset( $this->fees[ $name ] ) ? $this->fees[ $name ] : 0;
760
-	}
761
-
762
-	/**
763
-	 * Returns all fees.
764
-	 *
765
-	 * @since 1.0.19
766
-	 */
767
-	public function get_fees() {
768
-		return $this->fees;
769
-	}
770
-
771
-	// MISC //
772
-
773
-	/**
774
-	 * Returns the total amount to collect for this submission.
775
-	 *
776
-	 * @since 1.0.19
777
-	 */
778
-	public function get_total() {
779
-		$total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
780
-		$total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this  );
781
-		return wpinv_sanitize_amount( $total );
782
-	}
783
-
784
-	/**
785
-	 * Whether payment details should be collected for this submission.
786
-	 *
787
-	 * @since 1.0.19
788
-	 */
789
-	public function get_payment_details() {
790
-		$collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
791
-
792
-		if ( $this->has_recurring ) {
793
-			$collect = true;
794
-		}
795
-
796
-		$collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this  );
797
-		return $collect;
798
-	}
799
-
800
-	/**
801
-	 * Returns the billing email of the user.
802
-	 *
803
-	 * @since 1.0.19
804
-	 */
805
-	public function get_billing_email() {
806
-		$billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email'];
807
-		return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this  );
808
-	}
809
-
810
-	/**
811
-	 * Checks if the submitter has a billing email.
812
-	 *
813
-	 * @since 1.0.19
814
-	 */
815
-	public function has_billing_email() {
816
-		$billing_email = $this->get_billing_email();
817
-		return ! empty( $billing_email );
818
-	}
819
-
820
-	/**
821
-	 * Validate VAT data.
822
-	 *
823
-	 * @since 1.0.19
824
-	 */
825
-	public function maybe_validate_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 );
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 ] : 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 ) {
732
+        $amount = wpinv_sanitize_amount( $amount );
733
+
734
+        $this->total_fees_amount += $amount;
735
+
736
+        if ( isset( $this->fees[ $name ] ) ) {
737
+            $this->fees[ $name ] += $amount;
738
+        } else {
739
+            $this->fees[ $name ] = $amount;
740
+        }
741
+
742
+    }
743
+
744
+    /**
745
+     * Returns the total fees amount.
746
+     *
747
+     * @since 1.0.19
748
+     */
749
+    public function get_total_fees() {
750
+        return $this->total_fees_amount;
751
+    }
752
+
753
+    /**
754
+     * Retrieves a specific fee.
755
+     *
756
+     * @since 1.0.19
757
+     */
758
+    public function get_fee( $name ) {
759
+        return isset( $this->fees[ $name ] ) ? $this->fees[ $name ] : 0;
760
+    }
761
+
762
+    /**
763
+     * Returns all fees.
764
+     *
765
+     * @since 1.0.19
766
+     */
767
+    public function get_fees() {
768
+        return $this->fees;
769
+    }
770
+
771
+    // MISC //
772
+
773
+    /**
774
+     * Returns the total amount to collect for this submission.
775
+     *
776
+     * @since 1.0.19
777
+     */
778
+    public function get_total() {
779
+        $total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
780
+        $total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this  );
781
+        return wpinv_sanitize_amount( $total );
782
+    }
783
+
784
+    /**
785
+     * Whether payment details should be collected for this submission.
786
+     *
787
+     * @since 1.0.19
788
+     */
789
+    public function get_payment_details() {
790
+        $collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
791
+
792
+        if ( $this->has_recurring ) {
793
+            $collect = true;
794
+        }
795
+
796
+        $collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this  );
797
+        return $collect;
798
+    }
799
+
800
+    /**
801
+     * Returns the billing email of the user.
802
+     *
803
+     * @since 1.0.19
804
+     */
805
+    public function get_billing_email() {
806
+        $billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email'];
807
+        return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this  );
808
+    }
809
+
810
+    /**
811
+     * Checks if the submitter has a billing email.
812
+     *
813
+     * @since 1.0.19
814
+     */
815
+    public function has_billing_email() {
816
+        $billing_email = $this->get_billing_email();
817
+        return ! empty( $billing_email );
818
+    }
819
+
820
+    /**
821
+     * Validate VAT data.
822
+     *
823
+     * @since 1.0.19
824
+     */
825
+    public function maybe_validate_vat() {
826 826
 		
827
-		// Make sure that taxes are enabled.
828
-		if ( ! wpinv_use_taxes() ) {
829
-			return;
830
-		}
827
+        // Make sure that taxes are enabled.
828
+        if ( ! wpinv_use_taxes() ) {
829
+            return;
830
+        }
831 831
 
832
-		// Check if we have a digital VAT rule.
833
-		$has_digital = false;
832
+        // Check if we have a digital VAT rule.
833
+        $has_digital = false;
834 834
 
835
-		foreach ( $this->get_items() as $item ) {
835
+        foreach ( $this->get_items() as $item ) {
836 836
 
837
-			if ( 'digital' == $item->get_vat_rule() ) {
838
-				$has_digital = true;
839
-				break;
840
-			}
837
+            if ( 'digital' == $item->get_vat_rule() ) {
838
+                $has_digital = true;
839
+                break;
840
+            }
841 841
 
842
-		}
842
+        }
843 843
 
844
-		$this->has_digital = $has_digital;
844
+        $this->has_digital = $has_digital;
845 845
 
846
-		// Check if we require vat.
847
-		$requires_vat = (
848
-			( getpaid_is_eu_state( $this->country ) && ( getpaid_is_eu_state( wpinv_get_default_country() ) || $has_digital ) )
849
-			|| ( getpaid_is_gst_country( $this->country ) && getpaid_is_gst_country( wpinv_get_default_country() ) )
850
-		);
846
+        // Check if we require vat.
847
+        $requires_vat = (
848
+            ( getpaid_is_eu_state( $this->country ) && ( getpaid_is_eu_state( wpinv_get_default_country() ) || $has_digital ) )
849
+            || ( getpaid_is_gst_country( $this->country ) && getpaid_is_gst_country( wpinv_get_default_country() ) )
850
+        );
851 851
 
852
-		$this->requires_vat = $requires_vat;
852
+        $this->requires_vat = $requires_vat;
853 853
 
854
-		// Abort if we are not calculating the taxes.
855
-		if ( ! $has_digital && ! $requires_vat ) {
854
+        // Abort if we are not calculating the taxes.
855
+        if ( ! $has_digital && ! $requires_vat ) {
856 856
             return;
857
-		}
857
+        }
858 858
 
859
-		// Prepare variables.
860
-		$vat_number = $this->get_vat_number();
861
-		$company    = $this->get_company();
862
-		$ip_country = WPInv_EUVat::get_country_by_ip();
859
+        // Prepare variables.
860
+        $vat_number = $this->get_vat_number();
861
+        $company    = $this->get_company();
862
+        $ip_country = WPInv_EUVat::get_country_by_ip();
863 863
         $is_eu      = getpaid_is_eu_state( $this->country );
864 864
         $is_ip_eu   = getpaid_is_eu_state( $ip_country );
865
-		$is_non_eu  = ! $is_eu && ! $is_ip_eu;
866
-		$prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
865
+        $is_non_eu  = ! $is_eu && ! $is_ip_eu;
866
+        $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
867 867
 
868
-		// If we're preventing business to consumer purchases...
869
-		if ( ! empty( $prevent_b2c ) && ! $is_non_eu && ( empty( $vat_number ) || ! $requires_vat ) ) {
868
+        // If we're preventing business to consumer purchases...
869
+        if ( ! empty( $prevent_b2c ) && ! $is_non_eu && ( empty( $vat_number ) || ! $requires_vat ) ) {
870 870
 
871 871
             if ( $is_eu ) {
872
-				$this->last_error = wp_sprintf(
873
-					__( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
874
-					getpaid_vat_name()
875
-				);
872
+                $this->last_error = wp_sprintf(
873
+                    __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
874
+                    getpaid_vat_name()
875
+                );
876 876
             } else if ( $has_digital && $is_ip_eu ) {
877 877
 
878
-				$this->last_error = wp_sprintf(
879
-					__( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ),
880
-					getpaid_vat_name()
881
-				);
878
+                $this->last_error = wp_sprintf(
879
+                    __( 'Sales to non-EU countries cannot be completed because %s must be applied.', 'invoicing' ),
880
+                    getpaid_vat_name()
881
+                );
882 882
 
883
-			}
883
+            }
884 884
 
885
-		}
885
+        }
886 886
 		
887
-		// Abort if we are not validating vat.
888
-		if ( ! $is_eu || ! $requires_vat || empty( $vat_number ) ) {
887
+        // Abort if we are not validating vat.
888
+        if ( ! $is_eu || ! $requires_vat || empty( $vat_number ) ) {
889 889
             return;
890
-		}
890
+        }
891 891
 
892
-		$is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $this->country );
892
+        $is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $this->country );
893 893
 
894
-		if ( is_string( $is_valid ) ) {
895
-			$this->last_error = $is_valid;
896
-		}
894
+        if ( is_string( $is_valid ) ) {
895
+            $this->last_error = $is_valid;
896
+        }
897 897
 
898
-	}
898
+    }
899 899
 
900 900
 }
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-payment-gateway.php 1 patch
Indentation   +505 added lines, -505 removed lines patch added patch discarded remove patch
@@ -13,539 +13,539 @@
 block discarded – undo
13 13
  */
14 14
 abstract class GetPaid_Payment_Gateway {
15 15
 
16
-	/**
17
-	 * Set if the place checkout button should be renamed on selection.
18
-	 *
19
-	 * @var string
20
-	 */
21
-	public $checkout_button_text;
22
-
23
-	/**
24
-	 * Boolean whether the method is enabled.
25
-	 *
26
-	 * @var bool
27
-	 */
28
-	public $enabled = true;
29
-
30
-	/**
31
-	 * Payment method id.
32
-	 *
33
-	 * @var string
34
-	 */
35
-	public $id;
36
-
37
-	/**
38
-	 * Payment method order.
39
-	 *
40
-	 * @var int
41
-	 */
42
-	public $order = 10;
43
-
44
-	/**
45
-	 * Payment method title for the frontend.
46
-	 *
47
-	 * @var string
48
-	 */
49
-	public $title;
50
-
51
-	/**
52
-	 * Payment method description for the frontend.
53
-	 *
54
-	 * @var string
55
-	 */
56
-	public $description;
57
-
58
-	/**
59
-	 * Gateway title.
60
-	 *
61
-	 * @var string
62
-	 */
63
-	public $method_title = '';
64
-
65
-	/**
66
-	 * Gateway description.
67
-	 *
68
-	 * @var string
69
-	 */
70
-	public $method_description = '';
71
-
72
-	/**
73
-	 * Countries this gateway is allowed for.
74
-	 *
75
-	 * @var array
76
-	 */
77
-	public $countries;
78
-
79
-	/**
80
-	 * Currencies this gateway is allowed for.
81
-	 *
82
-	 * @var array
83
-	 */
84
-	public $currencies;
85
-
86
-	/**
87
-	 * Currencies this gateway is not allowed for.
88
-	 *
89
-	 * @var array
90
-	 */
91
-	public $exclude_currencies;
92
-
93
-	/**
94
-	 * Maximum transaction amount, zero does not define a maximum.
95
-	 *
96
-	 * @var int
97
-	 */
98
-	public $max_amount = 0;
99
-
100
-	/**
101
-	 * Optional URL to view a transaction.
102
-	 *
103
-	 * @var string
104
-	 */
105
-	public $view_transaction_url = '';
106
-
107
-	/**
108
-	 * Optional URL to view a subscription.
109
-	 *
110
-	 * @var string
111
-	 */
112
-	public $view_subscription_url = '';
113
-
114
-	/**
115
-	 * Optional label to show for "new payment method" in the payment
116
-	 * method/token selection radio selection.
117
-	 *
118
-	 * @var string
119
-	 */
120
-	public $new_method_label = '';
121
-
122
-	/**
123
-	 * Contains a users saved tokens for this gateway.
124
-	 *
125
-	 * @var array
126
-	 */
127
-	protected $tokens = array();
128
-
129
-	/**
130
-	 * An array of features that this gateway supports.
131
-	 *
132
-	 * @var array
133
-	 */
134
-	protected $supports = array();
135
-
136
-	/**
137
-	 * Class constructor.
138
-	 */
139
-	public function __construct() {
140
-		$this->enabled = wpinv_is_gateway_active( $this->id );
141
-
142
-		// Register gateway.
143
-		add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) );
144
-
145
-		// Enable Subscriptions.
146
-		if ( $this->supports( 'subscription' ) ) {
147
-			add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' );
148
-		}
149
-
150
-		// Gateway settings.
151
-		add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 );
152
-
153
-		// Process payment.
154
-		add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 );
155
-
156
-		// Change the checkout button text.
157
-		if ( ! empty( $this->checkout_button_text ) ) {
158
-			add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) );
159
-		}
160
-
161
-		// Check if a gateway is valid for a given currency.
162
-		add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 );
163
-
164
-		// Generate the transaction url.
165
-		add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 );
166
-
167
-		// Generate the subscription url.
168
-		add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 );
169
-
170
-		// Confirm payments.
171
-		add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 );
172
-
173
-		// Verify IPNs.
174
-		add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) );
175
-
176
-	}
177
-
178
-	/**
179
-	 * Checks if this gateway is a given gateway.
180
-	 *
181
-	 * @since 1.0.19
182
-	 * @return bool
183
-	 */
184
-	public function is( $gateway ) {
185
-		return $gateway == $this->id;
186
-	}
187
-
188
-	/**
189
-	 * Returns a users saved tokens for this gateway.
190
-	 *
191
-	 * @since 1.0.19
192
-	 * @return array
193
-	 */
194
-	public function get_tokens() {
195
-
196
-		if ( count( $this->tokens ) > 0 ) {
197
-			return $this->tokens;
198
-		}
199
-
200
-		if ( is_user_logged_in() && $this->supports( 'tokens' ) ) {
201
-			$tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true );
202
-
203
-			if ( is_array( $tokens ) ) {
204
-				$this->tokens = $tokens;
205
-			}
206
-
207
-		}
208
-
209
-		return $this->tokens;
210
-	}
211
-
212
-	/**
213
-	 * Return the title for admin screens.
214
-	 *
215
-	 * @return string
216
-	 */
217
-	public function get_method_title() {
218
-		return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this );
219
-	}
220
-
221
-	/**
222
-	 * Return the description for admin screens.
223
-	 *
224
-	 * @return string
225
-	 */
226
-	public function get_method_description() {
227
-		return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this );
228
-	}
229
-
230
-	/**
231
-	 * Get the success url.
232
-	 *
233
-	 * @param WPInv_Invoice $invoice Invoice object.
234
-	 * @return string
235
-	 */
236
-	public function get_return_url( $invoice ) {
237
-
238
-		// Payment success url
239
-		$return_url = add_query_arg(
240
-			array(
241
-				'payment-confirm' => $this->id,
242
-				'invoice_key'     => $invoice->get_key(),
243
-				'utm_nooverride'  => 1
244
-			),
245
-			wpinv_get_success_page_uri()
246
-		);
247
-
248
-		return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this );
249
-	}
250
-
251
-	/**
252
-	 * Confirms payments when rendering the success page.
253
-	 *
254
-	 * @param string $content Success page content.
255
-	 * @return string
256
-	 */
257
-	public function get_confirm_payment( $content ) {
16
+    /**
17
+     * Set if the place checkout button should be renamed on selection.
18
+     *
19
+     * @var string
20
+     */
21
+    public $checkout_button_text;
22
+
23
+    /**
24
+     * Boolean whether the method is enabled.
25
+     *
26
+     * @var bool
27
+     */
28
+    public $enabled = true;
29
+
30
+    /**
31
+     * Payment method id.
32
+     *
33
+     * @var string
34
+     */
35
+    public $id;
36
+
37
+    /**
38
+     * Payment method order.
39
+     *
40
+     * @var int
41
+     */
42
+    public $order = 10;
43
+
44
+    /**
45
+     * Payment method title for the frontend.
46
+     *
47
+     * @var string
48
+     */
49
+    public $title;
50
+
51
+    /**
52
+     * Payment method description for the frontend.
53
+     *
54
+     * @var string
55
+     */
56
+    public $description;
57
+
58
+    /**
59
+     * Gateway title.
60
+     *
61
+     * @var string
62
+     */
63
+    public $method_title = '';
64
+
65
+    /**
66
+     * Gateway description.
67
+     *
68
+     * @var string
69
+     */
70
+    public $method_description = '';
71
+
72
+    /**
73
+     * Countries this gateway is allowed for.
74
+     *
75
+     * @var array
76
+     */
77
+    public $countries;
78
+
79
+    /**
80
+     * Currencies this gateway is allowed for.
81
+     *
82
+     * @var array
83
+     */
84
+    public $currencies;
85
+
86
+    /**
87
+     * Currencies this gateway is not allowed for.
88
+     *
89
+     * @var array
90
+     */
91
+    public $exclude_currencies;
92
+
93
+    /**
94
+     * Maximum transaction amount, zero does not define a maximum.
95
+     *
96
+     * @var int
97
+     */
98
+    public $max_amount = 0;
99
+
100
+    /**
101
+     * Optional URL to view a transaction.
102
+     *
103
+     * @var string
104
+     */
105
+    public $view_transaction_url = '';
106
+
107
+    /**
108
+     * Optional URL to view a subscription.
109
+     *
110
+     * @var string
111
+     */
112
+    public $view_subscription_url = '';
113
+
114
+    /**
115
+     * Optional label to show for "new payment method" in the payment
116
+     * method/token selection radio selection.
117
+     *
118
+     * @var string
119
+     */
120
+    public $new_method_label = '';
121
+
122
+    /**
123
+     * Contains a users saved tokens for this gateway.
124
+     *
125
+     * @var array
126
+     */
127
+    protected $tokens = array();
128
+
129
+    /**
130
+     * An array of features that this gateway supports.
131
+     *
132
+     * @var array
133
+     */
134
+    protected $supports = array();
135
+
136
+    /**
137
+     * Class constructor.
138
+     */
139
+    public function __construct() {
140
+        $this->enabled = wpinv_is_gateway_active( $this->id );
141
+
142
+        // Register gateway.
143
+        add_filter( 'wpinv_payment_gateways', array( $this, 'register_gateway' ) );
144
+
145
+        // Enable Subscriptions.
146
+        if ( $this->supports( 'subscription' ) ) {
147
+            add_filter( "wpinv_{$this->id}_support_subscription", '__return_true' );
148
+        }
149
+
150
+        // Gateway settings.
151
+        add_action( "wpinv_{$this->id}_cc_form", array( $this, 'payment_fields' ), 10, 2 );
152
+
153
+        // Process payment.
154
+        add_action( "getpaid_gateway_{$this->id}", array( $this, 'process_payment' ), 10, 3 );
155
+
156
+        // Change the checkout button text.
157
+        if ( ! empty( $this->checkout_button_text ) ) {
158
+            add_filter( "getpaid_gateway_{$this->id}_checkout_button_label", array( $this, 'rename_checkout_button' ) );
159
+        }
160
+
161
+        // Check if a gateway is valid for a given currency.
162
+        add_filter( "getpaid_gateway_{$this->id}_is_valid_for_currency", array( $this, 'validate_currency' ), 10, 2 );
163
+
164
+        // Generate the transaction url.
165
+        add_filter( "getpaid_gateway_{$this->id}_transaction_url", array( $this, 'filter_transaction_url' ), 10, 2 );
166
+
167
+        // Generate the subscription url.
168
+        add_filter( "getpaid_gateway_{$this->id}_subscription_url", array( $this, 'filter_subscription_url' ), 10, 2 );
169
+
170
+        // Confirm payments.
171
+        add_filter( "wpinv_payment_confirm_{$this->id}", array( $this, 'confirm_payment' ), 10, 2 );
172
+
173
+        // Verify IPNs.
174
+        add_action( "wpinv_verify_{$this->id}_ipn", array( $this, 'verify_ipn' ) );
175
+
176
+    }
177
+
178
+    /**
179
+     * Checks if this gateway is a given gateway.
180
+     *
181
+     * @since 1.0.19
182
+     * @return bool
183
+     */
184
+    public function is( $gateway ) {
185
+        return $gateway == $this->id;
186
+    }
187
+
188
+    /**
189
+     * Returns a users saved tokens for this gateway.
190
+     *
191
+     * @since 1.0.19
192
+     * @return array
193
+     */
194
+    public function get_tokens() {
195
+
196
+        if ( count( $this->tokens ) > 0 ) {
197
+            return $this->tokens;
198
+        }
199
+
200
+        if ( is_user_logged_in() && $this->supports( 'tokens' ) ) {
201
+            $tokens = get_user_meta( get_current_user_id(), "getpaid_{$this->id}_tokens", true );
202
+
203
+            if ( is_array( $tokens ) ) {
204
+                $this->tokens = $tokens;
205
+            }
206
+
207
+        }
208
+
209
+        return $this->tokens;
210
+    }
211
+
212
+    /**
213
+     * Return the title for admin screens.
214
+     *
215
+     * @return string
216
+     */
217
+    public function get_method_title() {
218
+        return apply_filters( 'getpaid_gateway_method_title', $this->method_title, $this );
219
+    }
220
+
221
+    /**
222
+     * Return the description for admin screens.
223
+     *
224
+     * @return string
225
+     */
226
+    public function get_method_description() {
227
+        return apply_filters( 'getpaid_gateway_method_description', $this->method_description, $this );
228
+    }
229
+
230
+    /**
231
+     * Get the success url.
232
+     *
233
+     * @param WPInv_Invoice $invoice Invoice object.
234
+     * @return string
235
+     */
236
+    public function get_return_url( $invoice ) {
237
+
238
+        // Payment success url
239
+        $return_url = add_query_arg(
240
+            array(
241
+                'payment-confirm' => $this->id,
242
+                'invoice_key'     => $invoice->get_key(),
243
+                'utm_nooverride'  => 1
244
+            ),
245
+            wpinv_get_success_page_uri()
246
+        );
247
+
248
+        return apply_filters( 'getpaid_gateway_success_url', $return_url, $invoice, $this );
249
+    }
250
+
251
+    /**
252
+     * Confirms payments when rendering the success page.
253
+     *
254
+     * @param string $content Success page content.
255
+     * @return string
256
+     */
257
+    public function get_confirm_payment( $content ) {
258 258
 		
259
-		// Retrieve the invoice.
260
-		$invoice_id = getpaid_get_current_invoice_id();
261
-		$invoice    = wpinv_get_invoice( $invoice_id );
259
+        // Retrieve the invoice.
260
+        $invoice_id = getpaid_get_current_invoice_id();
261
+        $invoice    = wpinv_get_invoice( $invoice_id );
262 262
 	
263
-		// Ensure that it exists and that it is pending payment.
264
-		if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) {
265
-			return $content;
266
-		}
263
+        // Ensure that it exists and that it is pending payment.
264
+        if ( empty( $invoice_id ) || ! $invoice->needs_payment() ) {
265
+            return $content;
266
+        }
267 267
 	
268
-		// Can the user view this invoice??
269
-		if ( ! wpinv_user_can_view_invoice( $invoice ) ) {
270
-			return $content;
271
-		}
268
+        // Can the user view this invoice??
269
+        if ( ! wpinv_user_can_view_invoice( $invoice ) ) {
270
+            return $content;
271
+        }
272 272
 	
273
-		// Show payment processing indicator.
274
-		return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) );
275
-	}
276
-
277
-	/**
278
-	 * Processes ipns and marks payments as complete.
279
-	 *
280
-	 * @return void
281
-	 */
282
-	public function verify_ipn() {}
283
-
284
-	/**
285
-	 * Get a link to the transaction on the 3rd party gateway site (if applicable).
286
-	 *
287
-	 * @param string $transaction_url transaction url.
288
-	 * @param WPInv_Invoice $invoice Invoice object.
289
-	 * @return string transaction URL, or empty string.
290
-	 */
291
-	public function filter_transaction_url( $transaction_url, $invoice ) {
292
-
293
-		$transaction_id  = $invoice->get_transaction_id();
294
-
295
-		if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
296
-			$transaction_url = sprintf( $this->view_transaction_url, $transaction_id );
297
-			$replace         = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
298
-			$transaction_url = str_replace( '{sandbox}', $replace, $transaction_url );
299
-		}
300
-
301
-		return $transaction_url;
302
-	}
303
-
304
-	/**
305
-	 * Get a link to the subscription on the 3rd party gateway site (if applicable).
306
-	 *
307
-	 * @param string $subscription_url transaction url.
308
-	 * @param WPInv_Invoice $invoice Invoice object.
309
-	 * @return string subscription URL, or empty string.
310
-	 */
311
-	public function filter_subscription_url( $subscription_url, $invoice ) {
312
-
313
-		$profile_id      = $invoice->get_subscription_id();
314
-
315
-		if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) {
316
-
317
-			$subscription_url = sprintf( $this->view_subscription_url, $profile_id );
318
-			$replace          = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
319
-			$subscription_url = str_replace( '{sandbox}', $replace, $subscription_url );
320
-
321
-		}
322
-
323
-		return $subscription_url;
324
-	}
325
-
326
-	/**
327
-	 * Check if the gateway is available for use.
328
-	 *
329
-	 * @return bool
330
-	 */
331
-	public function is_available() {
332
-		return ! empty( $this->enabled );
333
-	}
334
-
335
-	/**
336
-	 * Return the gateway's title.
337
-	 *
338
-	 * @return string
339
-	 */
340
-	public function get_title() {
341
-		return apply_filters( 'getpaid_gateway_title', $this->title, $this );
342
-	}
343
-
344
-	/**
345
-	 * Return the gateway's description.
346
-	 *
347
-	 * @return string
348
-	 */
349
-	public function get_description() {
350
-		return apply_filters( 'getpaid_gateway_description', $this->description, $this );
351
-	}
352
-
353
-	/**
354
-	 * Process Payment.
355
-	 *
356
-	 *
357
-	 * @param WPInv_Invoice $invoice Invoice.
358
-	 * @param array $submission_data Posted checkout fields.
359
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
360
-	 * @return void
361
-	 */
362
-	public function process_payment( $invoice, $submission_data, $submission ) {
363
-		// Process the payment then either redirect to the success page or the gateway.
364
-	}
365
-
366
-	/**
367
-	 * Process refund.
368
-	 *
369
-	 * If the gateway declares 'refunds' support, this will allow it to refund.
370
-	 * a passed in amount.
371
-	 *
372
-	 * @param WPInv_Invoice $invoice Invoice.
373
-	 * @param  float  $amount Refund amount.
374
-	 * @param  string $reason Refund reason.
375
-	 * @return WP_Error|bool True or false based on success, or a WP_Error object.
376
-	 */
377
-	public function process_refund( $invoice, $amount = null, $reason = '' ) {
378
-		return false;
379
-	}
380
-
381
-	/**
382
-	 * Displays the payment fields, credit cards etc.
383
-	 * 
384
-	 * @param int $invoice_id 0 or invoice id.
385
-	 * @param GetPaid_Payment_Form $form Current payment form.
386
-	 */
387
-	public function payment_fields( $invoice_id, $form ) {}
388
-
389
-	/**
390
-	 * Check if a gateway supports a given feature.
391
-	 *
392
-	 * Gateways should override this to declare support (or lack of support) for a feature.
393
-	 * For backward compatibility, gateways support 'products' by default, but nothing else.
394
-	 *
395
-	 * @param string $feature string The name of a feature to test support for.
396
-	 * @return bool True if the gateway supports the feature, false otherwise.
397
-	 * @since 1.0.19
398
-	 */
399
-	public function supports( $feature ) {
400
-		return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this );
401
-	}
402
-
403
-	/**
404
-	 * Grab and display our saved payment methods.
405
-	 *
406
-	 * @since 1.0.19
407
-	 */
408
-	public function saved_payment_methods() {
409
-		$html = '<ul class="getpaid-saved-payment-methods" data-count="' . esc_attr( count( $this->get_tokens() ) ) . '">';
410
-
411
-		foreach ( $this->get_tokens() as $token ) {
412
-			$html .= $this->get_saved_payment_method_option_html( $token );
413
-		}
414
-
415
-		$html .= $this->get_new_payment_method_option_html();
416
-		$html .= '</ul>';
417
-
418
-		echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this );
419
-	}
420
-
421
-	/**
422
-	 * Gets saved payment method HTML from a token.
423
-	 *
424
-	 * @since 1.0.19
425
-	 * @param  array $token Payment Token.
426
-	 * @return string Generated payment method HTML
427
-	 */
428
-	public function get_saved_payment_method_option_html( $token ) {
429
-
430
-		return sprintf(
431
-			'<li class="getpaid-payment-method form-group">
273
+        // Show payment processing indicator.
274
+        return wpinv_get_template_html( 'wpinv-payment-processing.php', compact( 'invoice' ) );
275
+    }
276
+
277
+    /**
278
+     * Processes ipns and marks payments as complete.
279
+     *
280
+     * @return void
281
+     */
282
+    public function verify_ipn() {}
283
+
284
+    /**
285
+     * Get a link to the transaction on the 3rd party gateway site (if applicable).
286
+     *
287
+     * @param string $transaction_url transaction url.
288
+     * @param WPInv_Invoice $invoice Invoice object.
289
+     * @return string transaction URL, or empty string.
290
+     */
291
+    public function filter_transaction_url( $transaction_url, $invoice ) {
292
+
293
+        $transaction_id  = $invoice->get_transaction_id();
294
+
295
+        if ( ! empty( $this->view_transaction_url ) && ! empty( $transaction_id ) ) {
296
+            $transaction_url = sprintf( $this->view_transaction_url, $transaction_id );
297
+            $replace         = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
298
+            $transaction_url = str_replace( '{sandbox}', $replace, $transaction_url );
299
+        }
300
+
301
+        return $transaction_url;
302
+    }
303
+
304
+    /**
305
+     * Get a link to the subscription on the 3rd party gateway site (if applicable).
306
+     *
307
+     * @param string $subscription_url transaction url.
308
+     * @param WPInv_Invoice $invoice Invoice object.
309
+     * @return string subscription URL, or empty string.
310
+     */
311
+    public function filter_subscription_url( $subscription_url, $invoice ) {
312
+
313
+        $profile_id      = $invoice->get_subscription_id();
314
+
315
+        if ( ! empty( $this->view_subscription_url ) && ! empty( $profile_id ) ) {
316
+
317
+            $subscription_url = sprintf( $this->view_subscription_url, $profile_id );
318
+            $replace          = $this->is_sandbox( $invoice ) ? 'sandbox' : '';
319
+            $subscription_url = str_replace( '{sandbox}', $replace, $subscription_url );
320
+
321
+        }
322
+
323
+        return $subscription_url;
324
+    }
325
+
326
+    /**
327
+     * Check if the gateway is available for use.
328
+     *
329
+     * @return bool
330
+     */
331
+    public function is_available() {
332
+        return ! empty( $this->enabled );
333
+    }
334
+
335
+    /**
336
+     * Return the gateway's title.
337
+     *
338
+     * @return string
339
+     */
340
+    public function get_title() {
341
+        return apply_filters( 'getpaid_gateway_title', $this->title, $this );
342
+    }
343
+
344
+    /**
345
+     * Return the gateway's description.
346
+     *
347
+     * @return string
348
+     */
349
+    public function get_description() {
350
+        return apply_filters( 'getpaid_gateway_description', $this->description, $this );
351
+    }
352
+
353
+    /**
354
+     * Process Payment.
355
+     *
356
+     *
357
+     * @param WPInv_Invoice $invoice Invoice.
358
+     * @param array $submission_data Posted checkout fields.
359
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
360
+     * @return void
361
+     */
362
+    public function process_payment( $invoice, $submission_data, $submission ) {
363
+        // Process the payment then either redirect to the success page or the gateway.
364
+    }
365
+
366
+    /**
367
+     * Process refund.
368
+     *
369
+     * If the gateway declares 'refunds' support, this will allow it to refund.
370
+     * a passed in amount.
371
+     *
372
+     * @param WPInv_Invoice $invoice Invoice.
373
+     * @param  float  $amount Refund amount.
374
+     * @param  string $reason Refund reason.
375
+     * @return WP_Error|bool True or false based on success, or a WP_Error object.
376
+     */
377
+    public function process_refund( $invoice, $amount = null, $reason = '' ) {
378
+        return false;
379
+    }
380
+
381
+    /**
382
+     * Displays the payment fields, credit cards etc.
383
+     * 
384
+     * @param int $invoice_id 0 or invoice id.
385
+     * @param GetPaid_Payment_Form $form Current payment form.
386
+     */
387
+    public function payment_fields( $invoice_id, $form ) {}
388
+
389
+    /**
390
+     * Check if a gateway supports a given feature.
391
+     *
392
+     * Gateways should override this to declare support (or lack of support) for a feature.
393
+     * For backward compatibility, gateways support 'products' by default, but nothing else.
394
+     *
395
+     * @param string $feature string The name of a feature to test support for.
396
+     * @return bool True if the gateway supports the feature, false otherwise.
397
+     * @since 1.0.19
398
+     */
399
+    public function supports( $feature ) {
400
+        return apply_filters( 'getpaid_payment_gateway_supports', in_array( $feature, $this->supports ), $feature, $this );
401
+    }
402
+
403
+    /**
404
+     * Grab and display our saved payment methods.
405
+     *
406
+     * @since 1.0.19
407
+     */
408
+    public function saved_payment_methods() {
409
+        $html = '<ul class="getpaid-saved-payment-methods" data-count="' . esc_attr( count( $this->get_tokens() ) ) . '">';
410
+
411
+        foreach ( $this->get_tokens() as $token ) {
412
+            $html .= $this->get_saved_payment_method_option_html( $token );
413
+        }
414
+
415
+        $html .= $this->get_new_payment_method_option_html();
416
+        $html .= '</ul>';
417
+
418
+        echo apply_filters( 'getpaid_payment_gateway_form_saved_payment_methods_html', $html, $this );
419
+    }
420
+
421
+    /**
422
+     * Gets saved payment method HTML from a token.
423
+     *
424
+     * @since 1.0.19
425
+     * @param  array $token Payment Token.
426
+     * @return string Generated payment method HTML
427
+     */
428
+    public function get_saved_payment_method_option_html( $token ) {
429
+
430
+        return sprintf(
431
+            '<li class="getpaid-payment-method form-group">
432 432
 				<label>
433 433
 					<input name="getpaid-%1$s-payment-method" type="radio" value="%2$s" style="width:auto;" class="getpaid-saved-payment-method-token-input" %4$s />
434 434
 					<span>%3$s</span>
435 435
 				</label>
436 436
 			</li>',
437
-			esc_attr( $this->id ),
438
-			esc_attr( $token['id'] ),
439
-			esc_html( $token['name'] ),
440
-			checked( empty( $token['default'] ), false, false )
441
-		);
437
+            esc_attr( $this->id ),
438
+            esc_attr( $token['id'] ),
439
+            esc_html( $token['name'] ),
440
+            checked( empty( $token['default'] ), false, false )
441
+        );
442 442
 
443
-	}
443
+    }
444 444
 
445
-	/**
446
-	 * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method.
447
-	 *
448
-	 * @since 1.0.19
449
-	 */
450
-	public function get_new_payment_method_option_html() {
445
+    /**
446
+     * Displays a radio button for entering a new payment method (new CC details) instead of using a saved method.
447
+     *
448
+     * @since 1.0.19
449
+     */
450
+    public function get_new_payment_method_option_html() {
451 451
 
452
-		$label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this );
452
+        $label = apply_filters( 'getpaid_new_payment_method_label', $this->new_method_label ? $this->new_method_label : __( 'Use a new payment method', 'invoicing' ), $this );
453 453
 
454
-		return sprintf(
455
-			'<li class="getpaid-new-payment-method">
454
+        return sprintf(
455
+            '<li class="getpaid-new-payment-method">
456 456
 				<label>
457 457
 					<input name="getpaid-%1$s-payment-method" type="radio" value="new" style="width:auto;" />
458 458
 					<span>%2$s</span>
459 459
 				</label>
460 460
 			</li>',
461
-			esc_attr( $this->id ),
462
-			esc_html( $label )
463
-		);
464
-
465
-	}
466
-
467
-	/**
468
-	 * Outputs a checkbox for saving a new payment method to the database.
469
-	 *
470
-	 * @since 1.0.19
471
-	 */
472
-	public function save_payment_method_checkbox() {
461
+            esc_attr( $this->id ),
462
+            esc_html( $label )
463
+        );
464
+
465
+    }
466
+
467
+    /**
468
+     * Outputs a checkbox for saving a new payment method to the database.
469
+     *
470
+     * @since 1.0.19
471
+     */
472
+    public function save_payment_method_checkbox() {
473 473
 	
474
-		return sprintf(
475
-			'<p class="form-group getpaid-save-payment-method">
474
+        return sprintf(
475
+            '<p class="form-group getpaid-save-payment-method">
476 476
 				<label>
477 477
 					<input name="getpaid-%1$s-new-payment-method" type="checkbox" value="true" style="width:auto;" />
478 478
 					<span>%2$s</span>
479 479
 				</label>
480 480
 			</p>',
481
-			esc_attr( $this->id ),
482
-			esc_html__( 'Save payment method', 'invoicing' )
483
-		);
481
+            esc_attr( $this->id ),
482
+            esc_html__( 'Save payment method', 'invoicing' )
483
+        );
484 484
 
485
-	}
485
+    }
486 486
 
487
-	/**
488
-	 * Registers the gateway.
489
-	 *
490
-	 * @return array
491
-	 */
492
-	public function register_gateway( $gateways ) {
487
+    /**
488
+     * Registers the gateway.
489
+     *
490
+     * @return array
491
+     */
492
+    public function register_gateway( $gateways ) {
493 493
 
494
-		$gateways[ $this->id ] = array(
494
+        $gateways[ $this->id ] = array(
495 495
 
496
-			'admin_label'    => $this->method_title,
496
+            'admin_label'    => $this->method_title,
497 497
             'checkout_label' => $this->title,
498
-			'ordering'       => $this->order,
499
-
500
-		);
501
-
502
-		return $gateways;
503
-
504
-	}
505
-
506
-	/**
507
-	 * Checks whether or not this is a sandbox request.
508
-	 *
509
-	 * @param  WPInv_Invoice|null $invoice Invoice object or null.
510
-	 * @return bool
511
-	 */
512
-	public function is_sandbox( $invoice = null ) {
513
-
514
-		if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) {
515
-			return $invoice->get_mode() == 'test';
516
-		}
517
-
518
-		return wpinv_is_test_mode( $this->id );
519
-
520
-	}
521
-
522
-	/**
523
-	 * Renames the checkout button
524
-	 *
525
-	 * @return string
526
-	 */
527
-	public function rename_checkout_button() {
528
-		return $this->checkout_button_text;
529
-	}
530
-
531
-	/**
532
-	 * Validate gateway currency
533
-	 *
534
-	 * @return bool
535
-	 */
536
-	public function validate_currency( $validation, $currency ) {
537
-
538
-		// Required currencies.
539
-		if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) {
540
-			return false;
541
-		}
542
-
543
-		// Excluded currencies.
544
-		if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) {
545
-			return false;
546
-		}
547
-
548
-		return $validation;
549
-	}
498
+            'ordering'       => $this->order,
499
+
500
+        );
501
+
502
+        return $gateways;
503
+
504
+    }
505
+
506
+    /**
507
+     * Checks whether or not this is a sandbox request.
508
+     *
509
+     * @param  WPInv_Invoice|null $invoice Invoice object or null.
510
+     * @return bool
511
+     */
512
+    public function is_sandbox( $invoice = null ) {
513
+
514
+        if ( ! empty( $invoice ) && ! $invoice->needs_payment() ) {
515
+            return $invoice->get_mode() == 'test';
516
+        }
517
+
518
+        return wpinv_is_test_mode( $this->id );
519
+
520
+    }
521
+
522
+    /**
523
+     * Renames the checkout button
524
+     *
525
+     * @return string
526
+     */
527
+    public function rename_checkout_button() {
528
+        return $this->checkout_button_text;
529
+    }
530
+
531
+    /**
532
+     * Validate gateway currency
533
+     *
534
+     * @return bool
535
+     */
536
+    public function validate_currency( $validation, $currency ) {
537
+
538
+        // Required currencies.
539
+        if ( ! empty( $this->currencies ) && ! in_array( $currency, $this->currencies ) ) {
540
+            return false;
541
+        }
542
+
543
+        // Excluded currencies.
544
+        if ( ! empty( $this->exclude_currencies ) && in_array( $currency, $this->exclude_currencies ) ) {
545
+            return false;
546
+        }
547
+
548
+        return $validation;
549
+    }
550 550
 
551 551
 }
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-manual-gateway.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -13,30 +13,30 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Manual_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'manual';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array( 'subscription' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
34
-	public $order = 11;
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34
+    public $order = 11;
35 35
     
36 36
     /**
37
-	 * Class constructor.
38
-	 */
39
-	public function __construct() {
37
+     * Class constructor.
38
+     */
39
+    public function __construct() {
40 40
         parent::__construct();
41 41
 
42 42
         $this->title        = __( 'Manual Payment', 'invoicing' );
@@ -46,15 +46,15 @@  discard block
 block discarded – undo
46 46
     }
47 47
 
48 48
     /**
49
-	 * Process Payment.
50
-	 *
51
-	 *
52
-	 * @param WPInv_Invoice $invoice Invoice.
53
-	 * @param array $submission_data Posted checkout fields.
54
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
55
-	 * @return array
56
-	 */
57
-	public function process_payment( $invoice, $submission_data, $submission ) {
49
+     * Process Payment.
50
+     *
51
+     *
52
+     * @param WPInv_Invoice $invoice Invoice.
53
+     * @param array $submission_data Posted checkout fields.
54
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
55
+     * @return array
56
+     */
57
+    public function process_payment( $invoice, $submission_data, $submission ) {
58 58
 
59 59
         // Mark it as paid.
60 60
         $invoice->mark_paid();
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
     }
69 69
     
70 70
     /**
71
-	 * Starts a manual subscription profile.
72
-	 *
73
-	 *
74
-	 * @param WPInv_Invoice $invoice Invoice.
75
-	 */
76
-	public function start_manual_subscription_profile( $invoice ) {
71
+     * Starts a manual subscription profile.
72
+     *
73
+     *
74
+     * @param WPInv_Invoice $invoice Invoice.
75
+     */
76
+    public function start_manual_subscription_profile( $invoice ) {
77 77
 
78 78
         // Retrieve the subscription.
79 79
         $subscription = wpinv_get_subscription( $invoice );
@@ -100,12 +100,12 @@  discard block
 block discarded – undo
100 100
     }
101 101
 
102 102
     /**
103
-	 * Renews a manual subscription profile.
104
-	 *
105
-	 *
106
-	 * @param int $invoice_id Invoice.
107
-	 */
108
-	public function renew_manual_subscription_profile( $invoice_id ) {
103
+     * Renews a manual subscription profile.
104
+     *
105
+     *
106
+     * @param int $invoice_id Invoice.
107
+     */
108
+    public function renew_manual_subscription_profile( $invoice_id ) {
109 109
 
110 110
         // Retrieve the subscription.
111 111
         $subscription = wpinv_get_subscription( $invoice_id );
Please login to merge, or discard this patch.
includes/gateways/class-getpaid-paypal-gateway.php 1 patch
Indentation   +331 added lines, -331 removed lines patch added patch discarded remove patch
@@ -13,72 +13,72 @@  discard block
 block discarded – undo
13 13
 class GetPaid_Paypal_Gateway extends GetPaid_Payment_Gateway {
14 14
 
15 15
     /**
16
-	 * Payment method id.
17
-	 *
18
-	 * @var string
19
-	 */
16
+     * Payment method id.
17
+     *
18
+     * @var string
19
+     */
20 20
     public $id = 'paypal';
21 21
 
22 22
     /**
23
-	 * An array of features that this gateway supports.
24
-	 *
25
-	 * @var array
26
-	 */
23
+     * An array of features that this gateway supports.
24
+     *
25
+     * @var array
26
+     */
27 27
     protected $supports = array( 'subscription' );
28 28
 
29 29
     /**
30
-	 * Payment method order.
31
-	 *
32
-	 * @var int
33
-	 */
30
+     * Payment method order.
31
+     *
32
+     * @var int
33
+     */
34 34
     public $order = 1;
35 35
 
36 36
     /**
37
-	 * Stores line items to send to PayPal.
38
-	 *
39
-	 * @var array
40
-	 */
37
+     * Stores line items to send to PayPal.
38
+     *
39
+     * @var array
40
+     */
41 41
     protected $line_items = array();
42 42
 
43 43
     /**
44
-	 * Endpoint for requests from PayPal.
45
-	 *
46
-	 * @var string
47
-	 */
48
-	protected $notify_url;
44
+     * Endpoint for requests from PayPal.
45
+     *
46
+     * @var string
47
+     */
48
+    protected $notify_url;
49 49
 
50
-	/**
51
-	 * Endpoint for requests to PayPal.
52
-	 *
53
-	 * @var string
54
-	 */
50
+    /**
51
+     * Endpoint for requests to PayPal.
52
+     *
53
+     * @var string
54
+     */
55 55
     protected $endpoint;
56 56
     
57 57
     /**
58
-	 * Currencies this gateway is allowed for.
59
-	 *
60
-	 * @var array
61
-	 */
62
-	public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
58
+     * Currencies this gateway is allowed for.
59
+     *
60
+     * @var array
61
+     */
62
+    public $currencies = array( 'AUD', 'BRL', 'CAD', 'MXN', 'NZD', 'HKD', 'SGD', 'USD', 'EUR', 'JPY', 'TRY', 'NOK', 'CZK', 'DKK', 'HUF', 'ILS', 'MYR', 'PHP', 'PLN', 'SEK', 'CHF', 'TWD', 'THB', 'GBP', 'RMB', 'RUB', 'INR' );
63 63
 
64 64
     /**
65
-	 * URL to view a transaction.
66
-	 *
67
-	 * @var string
68
-	 */
65
+     * URL to view a transaction.
66
+     *
67
+     * @var string
68
+     */
69 69
     public $view_transaction_url = 'https://www.{sandbox}paypal.com/activity/payment/%s';
70 70
 
71 71
     /**
72
-	 * URL to view a subscription.
73
-	 *
74
-	 * @var string
75
-	 */
76
-	public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
72
+     * URL to view a subscription.
73
+     *
74
+     * @var string
75
+     */
76
+    public $view_subscription_url = 'https://www.{sandbox}paypal.com/cgi-bin/webscr?cmd=_profile-recurring-payments&encrypted_profile_id=%s';
77 77
 
78 78
     /**
79
-	 * Class constructor.
80
-	 */
81
-	public function __construct() {
79
+     * Class constructor.
80
+     */
81
+    public function __construct() {
82 82
 
83 83
         $this->title             = __( 'PayPal Standard', 'invoicing' );
84 84
         $this->method_title      = __( 'PayPal Standard', 'invoicing' );
@@ -92,15 +92,15 @@  discard block
 block discarded – undo
92 92
     }
93 93
 
94 94
     /**
95
-	 * Process Payment.
96
-	 *
97
-	 *
98
-	 * @param WPInv_Invoice $invoice Invoice.
99
-	 * @param array $submission_data Posted checkout fields.
100
-	 * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
101
-	 * @return array
102
-	 */
103
-	public function process_payment( $invoice, $submission_data, $submission ) {
95
+     * Process Payment.
96
+     *
97
+     *
98
+     * @param WPInv_Invoice $invoice Invoice.
99
+     * @param array $submission_data Posted checkout fields.
100
+     * @param GetPaid_Payment_Form_Submission $submission Checkout submission.
101
+     * @return array
102
+     */
103
+    public function process_payment( $invoice, $submission_data, $submission ) {
104 104
 
105 105
         // Get redirect url.
106 106
         $paypal_redirect = $this->get_request_url( $invoice );
@@ -123,15 +123,15 @@  discard block
 block discarded – undo
123 123
     }
124 124
 
125 125
     /**
126
-	 * Get the PayPal request URL for an invoice.
127
-	 *
128
-	 * @param  WPInv_Invoice $invoice Invoice object.
129
-	 * @return string
130
-	 */
131
-	public function get_request_url( $invoice ) {
126
+     * Get the PayPal request URL for an invoice.
127
+     *
128
+     * @param  WPInv_Invoice $invoice Invoice object.
129
+     * @return string
130
+     */
131
+    public function get_request_url( $invoice ) {
132 132
 
133 133
         // Endpoint for this request
134
-		$this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
134
+        $this->endpoint    = $this->is_sandbox( $invoice ) ? 'https://www.sandbox.paypal.com/cgi-bin/webscr?test_ipn=1&' : 'https://www.paypal.com/cgi-bin/webscr?';
135 135
 
136 136
         // Retrieve paypal args.
137 137
         $paypal_args       = map_deep( $this->get_paypal_args( $invoice ), 'urlencode' );
@@ -144,44 +144,44 @@  discard block
 block discarded – undo
144 144
 
145 145
         return add_query_arg( $paypal_args, $this->endpoint );
146 146
 
147
-	}
147
+    }
148 148
 
149 149
     /**
150
-	 * Get PayPal Args for passing to PP.
151
-	 *
152
-	 * @param  WPInv_Invoice $invoice Invoice object.
153
-	 * @return array
154
-	 */
155
-	protected function get_paypal_args( $invoice ) {
150
+     * Get PayPal Args for passing to PP.
151
+     *
152
+     * @param  WPInv_Invoice $invoice Invoice object.
153
+     * @return array
154
+     */
155
+    protected function get_paypal_args( $invoice ) {
156 156
 
157 157
         // Whether or not to send the line items as one item.
158
-		$force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice );
159
-
160
-		if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
161
-			$force_one_line_item = true;
162
-		}
163
-
164
-		$paypal_args = apply_filters(
165
-			'getpaid_paypal_args',
166
-			array_merge(
167
-				$this->get_transaction_args( $invoice ),
168
-				$this->get_line_item_args( $invoice, $force_one_line_item )
169
-			),
170
-			$invoice
171
-		);
172
-
173
-		return $this->fix_request_length( $invoice, $paypal_args );
158
+        $force_one_line_item = apply_filters( 'getpaid_paypal_force_one_line_item', false, $invoice );
159
+
160
+        if ( $invoice->is_recurring() || ( wpinv_use_taxes() && wpinv_prices_include_tax() ) ) {
161
+            $force_one_line_item = true;
162
+        }
163
+
164
+        $paypal_args = apply_filters(
165
+            'getpaid_paypal_args',
166
+            array_merge(
167
+                $this->get_transaction_args( $invoice ),
168
+                $this->get_line_item_args( $invoice, $force_one_line_item )
169
+            ),
170
+            $invoice
171
+        );
172
+
173
+        return $this->fix_request_length( $invoice, $paypal_args );
174 174
     }
175 175
 
176 176
     /**
177
-	 * Get transaction args for paypal request.
178
-	 *
179
-	 * @param WPInv_Invoice $invoice Invoice object.
180
-	 * @return array
181
-	 */
182
-	protected function get_transaction_args( $invoice ) {
177
+     * Get transaction args for paypal request.
178
+     *
179
+     * @param WPInv_Invoice $invoice Invoice object.
180
+     * @return array
181
+     */
182
+    protected function get_transaction_args( $invoice ) {
183 183
 
184
-		return array(
184
+        return array(
185 185
             'cmd'           => '_cart',
186 186
             'business'      => wpinv_get_option( 'paypal_email', false ),
187 187
             'no_shipping'   => '1',
@@ -206,16 +206,16 @@  discard block
 block discarded – undo
206 206
     }
207 207
 
208 208
     /**
209
-	 * Get line item args for paypal request.
210
-	 *
211
-	 * @param  WPInv_Invoice $invoice Invoice object.
212
-	 * @param  bool     $force_one_line_item Create only one item for this invoice.
213
-	 * @return array
214
-	 */
215
-	protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
209
+     * Get line item args for paypal request.
210
+     *
211
+     * @param  WPInv_Invoice $invoice Invoice object.
212
+     * @param  bool     $force_one_line_item Create only one item for this invoice.
213
+     * @return array
214
+     */
215
+    protected function get_line_item_args( $invoice, $force_one_line_item = false ) {
216 216
 
217 217
         // Maybe send invoice as a single item.
218
-		if ( $force_one_line_item ) {
218
+        if ( $force_one_line_item ) {
219 219
             return $this->get_line_item_args_single_item( $invoice );
220 220
         }
221 221
 
@@ -235,129 +235,129 @@  discard block
 block discarded – undo
235 235
             $line_item_args['discount_amount_cart'] = wpinv_sanitize_amount( (float) $invoice->get_total_discount(), 2 );
236 236
         }
237 237
 
238
-		return array_merge( $line_item_args, $this->get_line_items() );
238
+        return array_merge( $line_item_args, $this->get_line_items() );
239 239
 
240 240
     }
241 241
 
242 242
     /**
243
-	 * Get line item args for paypal request as a single line item.
244
-	 *
245
-	 * @param  WPInv_Invoice $invoice Invoice object.
246
-	 * @return array
247
-	 */
248
-	protected function get_line_item_args_single_item( $invoice ) {
249
-		$this->delete_line_items();
243
+     * Get line item args for paypal request as a single line item.
244
+     *
245
+     * @param  WPInv_Invoice $invoice Invoice object.
246
+     * @return array
247
+     */
248
+    protected function get_line_item_args_single_item( $invoice ) {
249
+        $this->delete_line_items();
250 250
 
251 251
         $item_name = sprintf( __( 'Invoice #%s', 'invoicing' ), $invoice->get_number() );
252
-		$this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() );
252
+        $this->add_line_item( $item_name, 1, wpinv_sanitize_amount( (float) $invoice->get_total(), 2 ), $invoice->get_id() );
253 253
 
254
-		return $this->get_line_items();
254
+        return $this->get_line_items();
255 255
     }
256 256
 
257 257
     /**
258
-	 * Return all line items.
259
-	 */
260
-	protected function get_line_items() {
261
-		return $this->line_items;
262
-	}
258
+     * Return all line items.
259
+     */
260
+    protected function get_line_items() {
261
+        return $this->line_items;
262
+    }
263 263
 
264 264
     /**
265
-	 * Remove all line items.
266
-	 */
267
-	protected function delete_line_items() {
268
-		$this->line_items = array();
265
+     * Remove all line items.
266
+     */
267
+    protected function delete_line_items() {
268
+        $this->line_items = array();
269 269
     }
270 270
 
271 271
     /**
272
-	 * Prepare line items to send to paypal.
273
-	 *
274
-	 * @param  WPInv_Invoice $invoice Invoice object.
275
-	 */
276
-	protected function prepare_line_items( $invoice ) {
277
-		$this->delete_line_items();
278
-
279
-		// Items.
280
-		foreach ( $invoice->get_items() as $item ) {
281
-			$amount   = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total();
282
-			$quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
283
-			$this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
272
+     * Prepare line items to send to paypal.
273
+     *
274
+     * @param  WPInv_Invoice $invoice Invoice object.
275
+     */
276
+    protected function prepare_line_items( $invoice ) {
277
+        $this->delete_line_items();
278
+
279
+        // Items.
280
+        foreach ( $invoice->get_items() as $item ) {
281
+            $amount   = $invoice->get_template() == 'amount' ? $item->get_price() : $item->get_sub_total();
282
+            $quantity = $invoice->get_template() == 'amount' ? 1 : $item->get_quantity();
283
+            $this->add_line_item( $item->get_raw_name(), $quantity, $amount, $item->get_id() );
284 284
         }
285 285
 
286 286
         // Fees.
287
-		foreach ( $invoice->get_fees() as $fee => $data ) {
287
+        foreach ( $invoice->get_fees() as $fee => $data ) {
288 288
             $this->add_line_item( $fee, 1, $data['amount'] );
289 289
         }
290 290
 
291 291
     }
292 292
 
293 293
     /**
294
-	 * Add PayPal Line Item.
295
-	 *
296
-	 * @param  string $item_name Item name.
297
-	 * @param  int    $quantity Item quantity.
298
-	 * @param  float  $amount Amount.
299
-	 * @param  string $item_number Item number.
300
-	 */
301
-	protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
302
-		$index = ( count( $this->line_items ) / 4 ) + 1;
303
-
304
-		$item = apply_filters(
305
-			'getpaid_paypal_line_item',
306
-			array(
307
-				'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
308
-				'quantity'    => (int) $quantity,
309
-				'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
310
-				'item_number' => $item_number,
311
-			),
312
-			$item_name,
313
-			$quantity,
314
-			$amount,
315
-			$item_number
316
-		);
317
-
318
-		$this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
294
+     * Add PayPal Line Item.
295
+     *
296
+     * @param  string $item_name Item name.
297
+     * @param  int    $quantity Item quantity.
298
+     * @param  float  $amount Amount.
299
+     * @param  string $item_number Item number.
300
+     */
301
+    protected function add_line_item( $item_name, $quantity = 1, $amount = 0.0, $item_number = '' ) {
302
+        $index = ( count( $this->line_items ) / 4 ) + 1;
303
+
304
+        $item = apply_filters(
305
+            'getpaid_paypal_line_item',
306
+            array(
307
+                'item_name'   => html_entity_decode( getpaid_limit_length( $item_name ? wp_strip_all_tags( $item_name ) : __( 'Item', 'invoicing' ), 127 ), ENT_NOQUOTES, 'UTF-8' ),
308
+                'quantity'    => (int) $quantity,
309
+                'amount'      => wpinv_sanitize_amount( (float) $amount, 2 ),
310
+                'item_number' => $item_number,
311
+            ),
312
+            $item_name,
313
+            $quantity,
314
+            $amount,
315
+            $item_number
316
+        );
317
+
318
+        $this->line_items[ 'item_name_' . $index ]   = getpaid_limit_length( $item['item_name'], 127 );
319 319
         $this->line_items[ 'quantity_' . $index ]    = $item['quantity'];
320 320
         
321 321
         // The price or amount of the product, service, or contribution, not including shipping, handling, or tax.
322
-		$this->line_items[ 'amount_' . $index ]      = $item['amount'];
323
-		$this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
322
+        $this->line_items[ 'amount_' . $index ]      = $item['amount'];
323
+        $this->line_items[ 'item_number_' . $index ] = getpaid_limit_length( $item['item_number'], 127 );
324 324
     }
325 325
 
326 326
     /**
327
-	 * If the default request with line items is too long, generate a new one with only one line item.
328
-	 *
329
-	 * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
330
-	 *
331
-	 * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
332
-	 * @param array    $paypal_args Arguments sent to Paypal in the request.
333
-	 * @return array
334
-	 */
335
-	protected function fix_request_length( $invoice, $paypal_args ) {
336
-		$max_paypal_length = 2083;
337
-		$query_candidate   = http_build_query( $paypal_args, '', '&' );
338
-
339
-		if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
340
-			return $paypal_args;
341
-		}
342
-
343
-		return apply_filters(
344
-			'getpaid_paypal_args',
345
-			array_merge(
346
-				$this->get_transaction_args( $invoice ),
347
-				$this->get_line_item_args( $invoice, true )
348
-			),
349
-			$invoice
350
-		);
327
+     * If the default request with line items is too long, generate a new one with only one line item.
328
+     *
329
+     * https://support.microsoft.com/en-us/help/208427/maximum-url-length-is-2-083-characters-in-internet-explorer.
330
+     *
331
+     * @param WPInv_Invoice $invoice Invoice to be sent to Paypal.
332
+     * @param array    $paypal_args Arguments sent to Paypal in the request.
333
+     * @return array
334
+     */
335
+    protected function fix_request_length( $invoice, $paypal_args ) {
336
+        $max_paypal_length = 2083;
337
+        $query_candidate   = http_build_query( $paypal_args, '', '&' );
338
+
339
+        if ( strlen( $this->endpoint . $query_candidate ) <= $max_paypal_length ) {
340
+            return $paypal_args;
341
+        }
342
+
343
+        return apply_filters(
344
+            'getpaid_paypal_args',
345
+            array_merge(
346
+                $this->get_transaction_args( $invoice ),
347
+                $this->get_line_item_args( $invoice, true )
348
+            ),
349
+            $invoice
350
+        );
351 351
 
352 352
     }
353 353
     
354 354
     /**
355
-	 * Processes recurring invoices.
356
-	 *
357
-	 * @param  array $paypal_args PayPal args.
358
-	 * @param  WPInv_Invoice    $invoice Invoice object.
359
-	 */
360
-	public function process_subscription( $paypal_args, $invoice ) {
355
+     * Processes recurring invoices.
356
+     *
357
+     * @param  array $paypal_args PayPal args.
358
+     * @param  WPInv_Invoice    $invoice Invoice object.
359
+     */
360
+    public function process_subscription( $paypal_args, $invoice ) {
361 361
 
362 362
         // Make sure this is a subscription.
363 363
         if ( ! $invoice->is_recurring() || ! $subscription = wpinv_get_subscription( $invoice ) ) {
@@ -382,11 +382,11 @@  discard block
 block discarded – undo
382 382
 
383 383
             $paypal_args['a1'] = 0 == $initial_amount ? 0 : $initial_amount;
384 384
 
385
-			// Trial period length.
386
-			$paypal_args['p1'] = $subscription_item->get_trial_interval();
385
+            // Trial period length.
386
+            $paypal_args['p1'] = $subscription_item->get_trial_interval();
387 387
 
388
-			// Trial period.
389
-			$paypal_args['t1'] = $subscription_item->get_trial_period();
388
+            // Trial period.
389
+            $paypal_args['t1'] = $subscription_item->get_trial_period();
390 390
 
391 391
         } else if ( $initial_amount != $recurring_amount ) {
392 392
 
@@ -409,40 +409,40 @@  discard block
 block discarded – undo
409 409
         }
410 410
 
411 411
         // We have a recurring payment
412
-		if ( ! isset( $param_number ) || 1 == $param_number ) {
412
+        if ( ! isset( $param_number ) || 1 == $param_number ) {
413 413
 
414
-			// Subscription price
415
-			$paypal_args['a3'] = $recurring_amount;
414
+            // Subscription price
415
+            $paypal_args['a3'] = $recurring_amount;
416 416
 
417
-			// Subscription duration
418
-			$paypal_args['p3'] = $interval;
417
+            // Subscription duration
418
+            $paypal_args['p3'] = $interval;
419 419
 
420
-			// Subscription period
421
-			$paypal_args['t3'] = $period;
420
+            // Subscription period
421
+            $paypal_args['t3'] = $period;
422 422
 
423 423
         }
424 424
         
425 425
         // Recurring payments
426
-		if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
426
+        if ( 1 == $bill_times || ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() && 2 == $bill_times ) ) {
427 427
 
428
-			// Non-recurring payments
429
-			$paypal_args['src'] = 0;
428
+            // Non-recurring payments
429
+            $paypal_args['src'] = 0;
430 430
 
431
-		} else {
431
+        } else {
432 432
 
433
-			$paypal_args['src'] = 1;
433
+            $paypal_args['src'] = 1;
434 434
 
435
-			if ( $bill_times > 0 ) {
435
+            if ( $bill_times > 0 ) {
436 436
 
437
-				// An initial period is being used to charge a sign-up fee
438
-				if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
439
-					$bill_times--;
440
-				}
437
+                // An initial period is being used to charge a sign-up fee
438
+                if ( $initial_amount != $recurring_amount && ! $subscription_item->has_free_trial() ) {
439
+                    $bill_times--;
440
+                }
441 441
 
442 442
                 // Make sure it's not over the max of 52
443 443
                 $paypal_args['srt'] = ( $bill_times <= 52 ? absint( $bill_times ) : 52 );
444 444
 
445
-			}
445
+            }
446 446
         }
447 447
         
448 448
         // Force return URL so that order description & instructions display
@@ -458,24 +458,24 @@  discard block
 block discarded – undo
458 458
         }
459 459
 
460 460
         return apply_filters(
461
-			'getpaid_paypal_subscription_args',
462
-			$paypal_args,
463
-			$invoice
461
+            'getpaid_paypal_subscription_args',
462
+            $paypal_args,
463
+            $invoice
464 464
         );
465 465
 
466 466
     }
467 467
 
468 468
     /**
469
-	 * Processes ipns and marks payments as complete.
470
-	 *
471
-	 * @return void
472
-	 */
473
-	public function verify_ipn() {
469
+     * Processes ipns and marks payments as complete.
470
+     *
471
+     * @return void
472
+     */
473
+    public function verify_ipn() {
474 474
 
475 475
         // Validate the IPN.
476 476
         if ( empty( $_POST ) || ! $this->validate_ipn() ) {
477
-		    wp_die( 'PayPal IPN Request Failure', 'PayPal IPN', array( 'response' => 500 ) );
478
-		}
477
+            wp_die( 'PayPal IPN Request Failure', 'PayPal IPN', array( 'response' => 500 ) );
478
+        }
479 479
 
480 480
         // Process the IPN.
481 481
         $posted  = wp_unslash( $_POST );
@@ -483,13 +483,13 @@  discard block
 block discarded – undo
483 483
 
484 484
         if ( $invoice && $this->id == $invoice->get_gateway() ) {
485 485
 
486
-			$posted['payment_status'] = strtolower( $posted['payment_status'] );
486
+            $posted['payment_status'] = strtolower( $posted['payment_status'] );
487 487
 
488 488
             wpinv_error_log( 'Found invoice #' . $invoice->get_number() );
489 489
             wpinv_error_log( 'Payment status:' . $posted['payment_status'] );
490 490
 
491
-			if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
492
-				call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
491
+            if ( method_exists( $this, 'ipn_txn_' . $posted['txn_type'] ) ) {
492
+                call_user_func( array( $this, 'ipn_txn_' . $posted['txn_type'] ), $invoice, $posted );
493 493
             } else {
494 494
                 wpinv_error_log( 'Aborting, Invalid type:' . $posted['txn_type'] );
495 495
             }
@@ -501,33 +501,33 @@  discard block
 block discarded – undo
501 501
     }
502 502
 
503 503
     /**
504
-	 * Check PayPal IPN validity.
505
-	 */
506
-	public function validate_ipn() {
507
-
508
-		wpinv_error_log( 'Validating PayPal IPN response' );
509
-
510
-		// Get received values from post data.
511
-		$validate_ipn        = wp_unslash( $_POST );
512
-		$validate_ipn['cmd'] = '_notify-validate';
513
-
514
-		// Send back post vars to paypal.
515
-		$params = array(
516
-			'body'        => $validate_ipn,
517
-			'timeout'     => 60,
518
-			'httpversion' => '1.1',
519
-			'compress'    => false,
520
-			'decompress'  => false,
521
-			'user-agent'  => 'GetPaid/' . WPINV_VERSION,
522
-		);
504
+     * Check PayPal IPN validity.
505
+     */
506
+    public function validate_ipn() {
507
+
508
+        wpinv_error_log( 'Validating PayPal IPN response' );
509
+
510
+        // Get received values from post data.
511
+        $validate_ipn        = wp_unslash( $_POST );
512
+        $validate_ipn['cmd'] = '_notify-validate';
513
+
514
+        // Send back post vars to paypal.
515
+        $params = array(
516
+            'body'        => $validate_ipn,
517
+            'timeout'     => 60,
518
+            'httpversion' => '1.1',
519
+            'compress'    => false,
520
+            'decompress'  => false,
521
+            'user-agent'  => 'GetPaid/' . WPINV_VERSION,
522
+        );
523 523
 
524
-		// Post back to get a response.
525
-		$response = wp_safe_remote_post( $this->is_sandbox() ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
524
+        // Post back to get a response.
525
+        $response = wp_safe_remote_post( $this->is_sandbox() ? 'https://www.sandbox.paypal.com/cgi-bin/webscr' : 'https://www.paypal.com/cgi-bin/webscr', $params );
526 526
 
527 527
         // Check to see if the request was valid.
528
-		if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
528
+        if ( ! is_wp_error( $response ) && $response['response']['code'] >= 200 && $response['response']['code'] < 300 && strstr( $response['body'], 'VERIFIED' ) ) {
529 529
             wpinv_error_log( $response['body'], 'Received valid response from PayPal IPN' );
530
-			return true;
530
+            return true;
531 531
         }
532 532
 
533 533
         if ( is_wp_error( $response ) ) {
@@ -541,63 +541,63 @@  discard block
 block discarded – undo
541 541
     }
542 542
 
543 543
     /**
544
-	 * Check currency from IPN matches the invoice.
545
-	 *
546
-	 * @param WPInv_Invoice $invoice          Invoice object.
547
-	 * @param string   $currency currency to validate.
548
-	 */
549
-	protected function validate_ipn_currency( $invoice, $currency ) {
550
-		if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
544
+     * Check currency from IPN matches the invoice.
545
+     *
546
+     * @param WPInv_Invoice $invoice          Invoice object.
547
+     * @param string   $currency currency to validate.
548
+     */
549
+    protected function validate_ipn_currency( $invoice, $currency ) {
550
+        if ( strtolower( $invoice->get_currency() ) !== strtolower( $currency ) ) {
551 551
             wpinv_record_gateway_error( 'IPN Error', "Currencies do not match: {$currency} instead of {$invoice->get_currency()}" );
552 552
 
553
-			/* translators: %s: currency code. */
554
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
555
-			exit;
556
-		}
557
-	}
558
-
559
-	/**
560
-	 * Check payment amount from IPN matches the invoice.
561
-	 *
562
-	 * @param WPInv_Invoice $invoice          Invoice object.
563
-	 * @param float   $amount amount to validate.
564
-	 */
565
-	protected function validate_ipn_amount( $invoice, $amount ) {
566
-		if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
553
+            /* translators: %s: currency code. */
554
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal currencies do not match (code %s).', 'invoicing' ), $currency ) );
555
+            exit;
556
+        }
557
+    }
558
+
559
+    /**
560
+     * Check payment amount from IPN matches the invoice.
561
+     *
562
+     * @param WPInv_Invoice $invoice          Invoice object.
563
+     * @param float   $amount amount to validate.
564
+     */
565
+    protected function validate_ipn_amount( $invoice, $amount ) {
566
+        if ( number_format( $invoice->get_total(), 2, '.', '' ) !== number_format( $amount, 2, '.', '' ) ) {
567 567
             wpinv_record_gateway_error( 'IPN Error', "Amounts do not match: {$amount} instead of {$invoice->get_total()}" );
568 568
 
569
-			/* translators: %s: Amount. */
570
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
571
-			exit;
572
-		}
573
-	}
574
-
575
-	/**
576
-	 * Verify receiver email from PayPal.
577
-	 *
578
-	 * @param WPInv_Invoice $invoice          Invoice object.
579
-	 * @param string   $receiver_email Email to validate.
580
-	 */
581
-	protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
569
+            /* translators: %s: Amount. */
570
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal amounts do not match (gross %s).', 'invoicing' ), $amount ) );
571
+            exit;
572
+        }
573
+    }
574
+
575
+    /**
576
+     * Verify receiver email from PayPal.
577
+     *
578
+     * @param WPInv_Invoice $invoice          Invoice object.
579
+     * @param string   $receiver_email Email to validate.
580
+     */
581
+    protected function validate_ipn_receiver_email( $invoice, $receiver_email ) {
582 582
         $paypal_email = wpinv_get_option( 'paypal_email' );
583 583
 
584
-		if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
584
+        if ( strcasecmp( trim( $receiver_email ), trim( $paypal_email ) ) !== 0 ) {
585 585
             wpinv_record_gateway_error( 'IPN Error', "IPN Response is for another account: {$receiver_email}. Your email is {$paypal_email}" );
586 586
 
587
-			/* translators: %s: email address . */
588
-			$invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
589
-			exit;
587
+            /* translators: %s: email address . */
588
+            $invoice->update_status( 'wpi-processing', sprintf( __( 'Validation error: PayPal IPN response from a different email address (%s).', 'invoicing' ), $receiver_email ) );
589
+            exit;
590 590
         }
591 591
 
592
-	}
592
+    }
593 593
 
594 594
     /**
595
-	 * Handles one time payments.
596
-	 *
597
-	 * @param WPInv_Invoice $invoice  Invoice object.
598
-	 * @param array    $posted Posted data.
599
-	 */
600
-	protected function ipn_txn_web_accept( $invoice, $posted ) {
595
+     * Handles one time payments.
596
+     *
597
+     * @param WPInv_Invoice $invoice  Invoice object.
598
+     * @param array    $posted Posted data.
599
+     */
600
+    protected function ipn_txn_web_accept( $invoice, $posted ) {
601 601
 
602 602
         // Collect payment details
603 603
         $payment_status = strtolower( $posted['payment_status'] );
@@ -658,27 +658,27 @@  discard block
 block discarded – undo
658 658
         // Process failures.
659 659
 
660 660
         /* translators: %s: payment status. */
661
-		$invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), wpinv_clean( $posted['payment_status'] ) ) );
662
-
663
-	}
664
-
665
-	/**
666
-	 * Handles one time payments.
667
-	 *
668
-	 * @param WPInv_Invoice $invoice  Invoice object.
669
-	 * @param array    $posted Posted data.
670
-	 */
671
-	protected function ipn_txn_cart( $invoice, $posted ) {
672
-		$this->ipn_txn_web_accept( $invoice, $posted );
661
+        $invoice->update_status( 'wpi-failed', sprintf( __( 'Payment %s via IPN.', 'invoicing' ), wpinv_clean( $posted['payment_status'] ) ) );
662
+
663
+    }
664
+
665
+    /**
666
+     * Handles one time payments.
667
+     *
668
+     * @param WPInv_Invoice $invoice  Invoice object.
669
+     * @param array    $posted Posted data.
670
+     */
671
+    protected function ipn_txn_cart( $invoice, $posted ) {
672
+        $this->ipn_txn_web_accept( $invoice, $posted );
673 673
     }
674 674
 
675 675
     /**
676
-	 * Handles subscription sign ups.
677
-	 *
678
-	 * @param WPInv_Invoice $invoice  Invoice object.
679
-	 * @param array    $posted Posted data.
680
-	 */
681
-	protected function ipn_txn_subscr_signup( $invoice, $posted ) {
676
+     * Handles subscription sign ups.
677
+     *
678
+     * @param WPInv_Invoice $invoice  Invoice object.
679
+     * @param array    $posted Posted data.
680
+     */
681
+    protected function ipn_txn_subscr_signup( $invoice, $posted ) {
682 682
 
683 683
         // Make sure the invoice has a subscription.
684 684
         $subscription = wpinv_get_subscription( $invoice );
@@ -717,12 +717,12 @@  discard block
 block discarded – undo
717 717
     }
718 718
 
719 719
     /**
720
-	 * Handles subscription renewals.
721
-	 *
722
-	 * @param WPInv_Invoice $invoice  Invoice object.
723
-	 * @param array    $posted Posted data.
724
-	 */
725
-	protected function ipn_txn_subscr_payment( $invoice, $posted ) {
720
+     * Handles subscription renewals.
721
+     *
722
+     * @param WPInv_Invoice $invoice  Invoice object.
723
+     * @param array    $posted Posted data.
724
+     */
725
+    protected function ipn_txn_subscr_payment( $invoice, $posted ) {
726 726
 
727 727
         // Make sure the invoice has a subscription.
728 728
         $subscription = wpinv_get_subscription( $invoice );
@@ -765,12 +765,12 @@  discard block
 block discarded – undo
765 765
     }
766 766
 
767 767
     /**
768
-	 * Handles subscription cancelations.
769
-	 *
770
-	 * @param WPInv_Invoice $invoice  Invoice object.
771
-	 * @param array    $posted Posted data.
772
-	 */
773
-	protected function ipn_txn_subscr_cancel( $invoice, $posted ) {
768
+     * Handles subscription cancelations.
769
+     *
770
+     * @param WPInv_Invoice $invoice  Invoice object.
771
+     * @param array    $posted Posted data.
772
+     */
773
+    protected function ipn_txn_subscr_cancel( $invoice, $posted ) {
774 774
 
775 775
         if ( $subscription = wpinv_get_subscription( $invoice ) ) {
776 776
             $subscription->cancel();
@@ -779,12 +779,12 @@  discard block
 block discarded – undo
779 779
     }
780 780
 
781 781
     /**
782
-	 * Handles subscription completions.
783
-	 *
784
-	 * @param WPInv_Invoice $invoice  Invoice object.
785
-	 * @param array    $posted Posted data.
786
-	 */
787
-	protected function ipn_txn_subscr_eot( $invoice, $posted ) {
782
+     * Handles subscription completions.
783
+     *
784
+     * @param WPInv_Invoice $invoice  Invoice object.
785
+     * @param array    $posted Posted data.
786
+     */
787
+    protected function ipn_txn_subscr_eot( $invoice, $posted ) {
788 788
 
789 789
         if ( $subscription = wpinv_get_subscription( $invoice ) ) {
790 790
             $subscription->complete();
@@ -793,12 +793,12 @@  discard block
 block discarded – undo
793 793
     }
794 794
 
795 795
     /**
796
-	 * Handles subscription fails.
797
-	 *
798
-	 * @param WPInv_Invoice $invoice  Invoice object.
799
-	 * @param array    $posted Posted data.
800
-	 */
801
-	protected function ipn_txn_subscr_failed( $invoice, $posted ) {
796
+     * Handles subscription fails.
797
+     *
798
+     * @param WPInv_Invoice $invoice  Invoice object.
799
+     * @param array    $posted Posted data.
800
+     */
801
+    protected function ipn_txn_subscr_failed( $invoice, $posted ) {
802 802
 
803 803
         if ( $subscription = wpinv_get_subscription( $invoice ) ) {
804 804
             $subscription->failing();
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 1 patch
Indentation   +2166 added lines, -2166 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,20 +79,20 @@  discard block
 block discarded – undo
79 79
         'transaction_id'       => '',
80 80
         'currency'             => '',
81 81
         'disable_taxes'        => false,
82
-		'subscription_id'      => null,
83
-		'is_viewed'            => false,
84
-		'email_cc'             => '',
85
-		'template'             => 'quantity', // hours, amount only
82
+        'subscription_id'      => null,
83
+        'is_viewed'            => false,
84
+        'email_cc'             => '',
85
+        'template'             => 'quantity', // hours, amount only
86 86
     );
87 87
 
88 88
     /**
89
-	 * Stores meta in cache for future reads.
90
-	 *
91
-	 * A group must be set to to enable caching.
92
-	 *
93
-	 * @var string
94
-	 */
95
-	protected $cache_group = 'getpaid_invoices';
89
+     * Stores meta in cache for future reads.
90
+     *
91
+     * A group must be set to to enable caching.
92
+     *
93
+     * @var string
94
+     */
95
+    protected $cache_group = 'getpaid_invoices';
96 96
 
97 97
     /**
98 98
      * Stores a reference to the original WP_Post object
@@ -106,104 +106,104 @@  discard block
 block discarded – undo
106 106
      *
107 107
      * @var int
108 108
      */
109
-	protected $recurring_item = null;
109
+    protected $recurring_item = null;
110 110
 
111
-	/**
111
+    /**
112 112
      * Stores an array of item totals.
113
-	 *
114
-	 * e.g $totals['discount'] = array(
115
-	 * 		'initial'   => 10,
116
-	 * 		'recurring' => 10,
117
-	 * )
113
+     *
114
+     * e.g $totals['discount'] = array(
115
+     * 		'initial'   => 10,
116
+     * 		'recurring' => 10,
117
+     * )
118 118
      *
119 119
      * @var array
120 120
      */
121
-	protected $totals = array();
121
+    protected $totals = array();
122 122
 
123
-	/**
124
-	 * Stores the status transition information.
125
-	 *
126
-	 * @since 1.0.19
127
-	 * @var bool
128
-	 */
129
-	protected $status_transition = false;
123
+    /**
124
+     * Stores the status transition information.
125
+     *
126
+     * @since 1.0.19
127
+     * @var bool
128
+     */
129
+    protected $status_transition = false;
130 130
 
131 131
     /**
132
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
133
-	 *
134
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
135
-	 */
132
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
133
+     *
134
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
135
+     */
136 136
     public function __construct( $invoice = false ) {
137 137
 
138 138
         parent::__construct( $invoice );
139 139
 
140
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
141
-			$this->set_id( $invoice );
142
-		} elseif ( $invoice instanceof self ) {
143
-			$this->set_id( $invoice->get_id() );
144
-		} elseif ( ! empty( $invoice->ID ) ) {
145
-			$this->set_id( $invoice->ID );
146
-		} elseif ( is_array( $invoice ) ) {
147
-			$this->set_props( $invoice );
148
-
149
-			if ( isset( $invoice['ID'] ) ) {
150
-				$this->set_id( $invoice['ID'] );
151
-			}
152
-
153
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
154
-			$this->set_id( $invoice_id );
155
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
156
-			$this->set_id( $invoice_id );
157
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
158
-			$this->set_id( $invoice_id );
159
-		}else {
160
-			$this->set_object_read( true );
161
-		}
140
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
141
+            $this->set_id( $invoice );
142
+        } elseif ( $invoice instanceof self ) {
143
+            $this->set_id( $invoice->get_id() );
144
+        } elseif ( ! empty( $invoice->ID ) ) {
145
+            $this->set_id( $invoice->ID );
146
+        } elseif ( is_array( $invoice ) ) {
147
+            $this->set_props( $invoice );
148
+
149
+            if ( isset( $invoice['ID'] ) ) {
150
+                $this->set_id( $invoice['ID'] );
151
+            }
152
+
153
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
154
+            $this->set_id( $invoice_id );
155
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
156
+            $this->set_id( $invoice_id );
157
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
158
+            $this->set_id( $invoice_id );
159
+        }else {
160
+            $this->set_object_read( true );
161
+        }
162 162
 
163 163
         // Load the datastore.
164
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
164
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
165 165
 
166
-		if ( $this->get_id() > 0 ) {
166
+        if ( $this->get_id() > 0 ) {
167 167
             $this->post = get_post( $this->get_id() );
168 168
             $this->ID   = $this->get_id();
169
-			$this->data_store->read( $this );
169
+            $this->data_store->read( $this );
170 170
         }
171 171
 
172 172
     }
173 173
 
174 174
     /**
175
-	 * Given an invoice key/number, it returns its id.
176
-	 *
177
-	 *
178
-	 * @static
179
-	 * @param string $value The invoice key or number
180
-	 * @param string $field Either key, transaction_id or number.
181
-	 * @since 1.0.15
182
-	 * @return int
183
-	 */
184
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
175
+     * Given an invoice key/number, it returns its id.
176
+     *
177
+     *
178
+     * @static
179
+     * @param string $value The invoice key or number
180
+     * @param string $field Either key, transaction_id or number.
181
+     * @since 1.0.15
182
+     * @return int
183
+     */
184
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
185 185
         global $wpdb;
186 186
 
187
-		// Trim the value.
188
-		$value = trim( $value );
187
+        // Trim the value.
188
+        $value = trim( $value );
189 189
 
190
-		if ( empty( $value ) ) {
191
-			return 0;
192
-		}
190
+        if ( empty( $value ) ) {
191
+            return 0;
192
+        }
193 193
 
194 194
         // Valid fields.
195 195
         $fields = array( 'key', 'number', 'transaction_id' );
196 196
 
197
-		// Ensure a field has been passed.
198
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
199
-			return 0;
200
-		}
197
+        // Ensure a field has been passed.
198
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
199
+            return 0;
200
+        }
201 201
 
202
-		// Maybe retrieve from the cache.
203
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
204
-		if ( ! empty( $invoice_id ) ) {
205
-			return $invoice_id;
206
-		}
202
+        // Maybe retrieve from the cache.
203
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
204
+        if ( ! empty( $invoice_id ) ) {
205
+            return $invoice_id;
206
+        }
207 207
 
208 208
         // Fetch from the db.
209 209
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
212 212
         );
213 213
 
214
-		if ( empty( $invoice_id ) ) {
215
-			return 0;
216
-		}
214
+        if ( empty( $invoice_id ) ) {
215
+            return 0;
216
+        }
217 217
 
218
-		// Update the cache with our data
219
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
218
+        // Update the cache with our data
219
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
220 220
 
221
-		return $invoice_id;
221
+        return $invoice_id;
222 222
     }
223 223
 
224 224
     /**
@@ -244,73 +244,73 @@  discard block
 block discarded – undo
244 244
     */
245 245
 
246 246
     /**
247
-	 * Get parent invoice ID.
248
-	 *
249
-	 * @since 1.0.19
250
-	 * @param  string $context View or edit context.
251
-	 * @return int
252
-	 */
253
-	public function get_parent_id( $context = 'view' ) {
254
-		return (int) $this->get_prop( 'parent_id', $context );
247
+     * Get parent invoice ID.
248
+     *
249
+     * @since 1.0.19
250
+     * @param  string $context View or edit context.
251
+     * @return int
252
+     */
253
+    public function get_parent_id( $context = 'view' ) {
254
+        return (int) $this->get_prop( 'parent_id', $context );
255 255
     }
256 256
 
257 257
     /**
258
-	 * Get parent invoice.
259
-	 *
260
-	 * @since 1.0.19
261
-	 * @return WPInv_Invoice
262
-	 */
258
+     * Get parent invoice.
259
+     *
260
+     * @since 1.0.19
261
+     * @return WPInv_Invoice
262
+     */
263 263
     public function get_parent_payment() {
264 264
         return new WPInv_Invoice( $this->get_parent_id() );
265 265
     }
266 266
 
267 267
     /**
268
-	 * Alias for self::get_parent_payment().
269
-	 *
270
-	 * @since 1.0.19
271
-	 * @return WPInv_Invoice
272
-	 */
268
+     * Alias for self::get_parent_payment().
269
+     *
270
+     * @since 1.0.19
271
+     * @return WPInv_Invoice
272
+     */
273 273
     public function get_parent() {
274 274
         return $this->get_parent_payment();
275 275
     }
276 276
 
277 277
     /**
278
-	 * Get invoice status.
279
-	 *
280
-	 * @since 1.0.19
281
-	 * @param  string $context View or edit context.
282
-	 * @return string
283
-	 */
284
-	public function get_status( $context = 'view' ) {
285
-		return $this->get_prop( 'status', $context );
286
-	}
278
+     * Get invoice status.
279
+     *
280
+     * @since 1.0.19
281
+     * @param  string $context View or edit context.
282
+     * @return string
283
+     */
284
+    public function get_status( $context = 'view' ) {
285
+        return $this->get_prop( 'status', $context );
286
+    }
287 287
 	
288
-	/**
289
-	 * Retrieves an array of possible invoice statuses.
290
-	 *
291
-	 * @since 1.0.19
292
-	 * @return array
293
-	 */
294
-	public function get_all_statuses() {
288
+    /**
289
+     * Retrieves an array of possible invoice statuses.
290
+     *
291
+     * @since 1.0.19
292
+     * @return array
293
+     */
294
+    public function get_all_statuses() {
295 295
 		
296
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
296
+        $statuses = wpinv_get_invoice_statuses( true, true, $this );
297 297
 
298
-		// For backwards compatibility.
299
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
298
+        // For backwards compatibility.
299
+        if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
300 300
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
301
-		}
301
+        }
302 302
 
303
-		return $statuses;
303
+        return $statuses;
304 304
     }
305 305
 
306 306
     /**
307
-	 * Get invoice status nice name.
308
-	 *
309
-	 * @since 1.0.19
310
-	 * @return string
311
-	 */
307
+     * Get invoice status nice name.
308
+     *
309
+     * @since 1.0.19
310
+     * @return string
311
+     */
312 312
     public function get_status_nicename() {
313
-		$statuses = $this->get_all_statuses();
313
+        $statuses = $this->get_all_statuses();
314 314
 
315 315
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
316 316
 
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
     }
319 319
 
320 320
     /**
321
-	 * Get plugin version when the invoice was created.
322
-	 *
323
-	 * @since 1.0.19
324
-	 * @param  string $context View or edit context.
325
-	 * @return string
326
-	 */
327
-	public function get_version( $context = 'view' ) {
328
-		return $this->get_prop( 'version', $context );
329
-	}
321
+     * Get plugin version when the invoice was created.
322
+     *
323
+     * @since 1.0.19
324
+     * @param  string $context View or edit context.
325
+     * @return string
326
+     */
327
+    public function get_version( $context = 'view' ) {
328
+        return $this->get_prop( 'version', $context );
329
+    }
330 330
 
331
-	/**
332
-	 * @deprecated
333
-	 */
334
-	public function get_invoice_date( $formatted = true ) {
331
+    /**
332
+     * @deprecated
333
+     */
334
+    public function get_invoice_date( $formatted = true ) {
335 335
         $date_completed = $this->get_date_completed();
336 336
         $invoice_date   = $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
337 337
 
@@ -348,187 +348,187 @@  discard block
 block discarded – undo
348 348
     }
349 349
 
350 350
     /**
351
-	 * Get date when the invoice was created.
352
-	 *
353
-	 * @since 1.0.19
354
-	 * @param  string $context View or edit context.
355
-	 * @return string
356
-	 */
357
-	public function get_date_created( $context = 'view' ) {
358
-		return $this->get_prop( 'date_created', $context );
359
-	}
351
+     * Get date when the invoice was created.
352
+     *
353
+     * @since 1.0.19
354
+     * @param  string $context View or edit context.
355
+     * @return string
356
+     */
357
+    public function get_date_created( $context = 'view' ) {
358
+        return $this->get_prop( 'date_created', $context );
359
+    }
360 360
 	
361
-	/**
362
-	 * Alias for self::get_date_created().
363
-	 *
364
-	 * @since 1.0.19
365
-	 * @param  string $context View or edit context.
366
-	 * @return string
367
-	 */
368
-	public function get_created_date( $context = 'view' ) {
369
-		return $this->get_date_created( $context );
370
-    }
371
-
372
-    /**
373
-	 * Get GMT date when the invoice was created.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_date_created_gmt( $context = 'view' ) {
361
+    /**
362
+     * Alias for self::get_date_created().
363
+     *
364
+     * @since 1.0.19
365
+     * @param  string $context View or edit context.
366
+     * @return string
367
+     */
368
+    public function get_created_date( $context = 'view' ) {
369
+        return $this->get_date_created( $context );
370
+    }
371
+
372
+    /**
373
+     * Get GMT date when the invoice was created.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_date_created_gmt( $context = 'view' ) {
380 380
         $date = $this->get_date_created( $context );
381 381
 
382 382
         if ( $date ) {
383 383
             $date = get_gmt_from_date( $date );
384 384
         }
385
-		return $date;
385
+        return $date;
386 386
     }
387 387
 
388 388
     /**
389
-	 * Get date when the invoice was last modified.
390
-	 *
391
-	 * @since 1.0.19
392
-	 * @param  string $context View or edit context.
393
-	 * @return string
394
-	 */
395
-	public function get_date_modified( $context = 'view' ) {
396
-		return $this->get_prop( 'date_modified', $context );
397
-	}
389
+     * Get date when the invoice was last modified.
390
+     *
391
+     * @since 1.0.19
392
+     * @param  string $context View or edit context.
393
+     * @return string
394
+     */
395
+    public function get_date_modified( $context = 'view' ) {
396
+        return $this->get_prop( 'date_modified', $context );
397
+    }
398 398
 
399
-	/**
400
-	 * Alias for self::get_date_modified().
401
-	 *
402
-	 * @since 1.0.19
403
-	 * @param  string $context View or edit context.
404
-	 * @return string
405
-	 */
406
-	public function get_modified_date( $context = 'view' ) {
407
-		return $this->get_date_modified( $context );
399
+    /**
400
+     * Alias for self::get_date_modified().
401
+     *
402
+     * @since 1.0.19
403
+     * @param  string $context View or edit context.
404
+     * @return string
405
+     */
406
+    public function get_modified_date( $context = 'view' ) {
407
+        return $this->get_date_modified( $context );
408 408
     }
409 409
 
410 410
     /**
411
-	 * Get GMT date when the invoice was last modified.
412
-	 *
413
-	 * @since 1.0.19
414
-	 * @param  string $context View or edit context.
415
-	 * @return string
416
-	 */
417
-	public function get_date_modified_gmt( $context = 'view' ) {
411
+     * Get GMT date when the invoice was last modified.
412
+     *
413
+     * @since 1.0.19
414
+     * @param  string $context View or edit context.
415
+     * @return string
416
+     */
417
+    public function get_date_modified_gmt( $context = 'view' ) {
418 418
         $date = $this->get_date_modified( $context );
419 419
 
420 420
         if ( $date ) {
421 421
             $date = get_gmt_from_date( $date );
422 422
         }
423
-		return $date;
423
+        return $date;
424 424
     }
425 425
 
426 426
     /**
427
-	 * Get the invoice due date.
428
-	 *
429
-	 * @since 1.0.19
430
-	 * @param  string $context View or edit context.
431
-	 * @return string
432
-	 */
433
-	public function get_due_date( $context = 'view' ) {
434
-		return $this->get_prop( 'due_date', $context );
427
+     * Get the invoice due date.
428
+     *
429
+     * @since 1.0.19
430
+     * @param  string $context View or edit context.
431
+     * @return string
432
+     */
433
+    public function get_due_date( $context = 'view' ) {
434
+        return $this->get_prop( 'due_date', $context );
435 435
     }
436 436
 
437 437
     /**
438
-	 * Alias for self::get_due_date().
439
-	 *
440
-	 * @since 1.0.19
441
-	 * @param  string $context View or edit context.
442
-	 * @return string
443
-	 */
444
-	public function get_date_due( $context = 'view' ) {
445
-		return $this->get_due_date( $context );
438
+     * Alias for self::get_due_date().
439
+     *
440
+     * @since 1.0.19
441
+     * @param  string $context View or edit context.
442
+     * @return string
443
+     */
444
+    public function get_date_due( $context = 'view' ) {
445
+        return $this->get_due_date( $context );
446 446
     }
447 447
 
448 448
     /**
449
-	 * Get the invoice GMT due date.
450
-	 *
451
-	 * @since 1.0.19
452
-	 * @param  string $context View or edit context.
453
-	 * @return string
454
-	 */
455
-	public function get_due_date_gmt( $context = 'view' ) {
449
+     * Get the invoice GMT due date.
450
+     *
451
+     * @since 1.0.19
452
+     * @param  string $context View or edit context.
453
+     * @return string
454
+     */
455
+    public function get_due_date_gmt( $context = 'view' ) {
456 456
         $date = $this->get_due_date( $context );
457 457
 
458 458
         if ( $date ) {
459 459
             $date = get_gmt_from_date( $date );
460 460
         }
461
-		return $date;
461
+        return $date;
462 462
     }
463 463
 
464 464
     /**
465
-	 * Alias for self::get_due_date_gmt().
466
-	 *
467
-	 * @since 1.0.19
468
-	 * @param  string $context View or edit context.
469
-	 * @return string
470
-	 */
471
-	public function get_gmt_date_due( $context = 'view' ) {
472
-		return $this->get_due_date_gmt( $context );
465
+     * Alias for self::get_due_date_gmt().
466
+     *
467
+     * @since 1.0.19
468
+     * @param  string $context View or edit context.
469
+     * @return string
470
+     */
471
+    public function get_gmt_date_due( $context = 'view' ) {
472
+        return $this->get_due_date_gmt( $context );
473 473
     }
474 474
 
475 475
     /**
476
-	 * Get date when the invoice was completed.
477
-	 *
478
-	 * @since 1.0.19
479
-	 * @param  string $context View or edit context.
480
-	 * @return string
481
-	 */
482
-	public function get_completed_date( $context = 'view' ) {
483
-		return $this->get_prop( 'completed_date', $context );
476
+     * Get date when the invoice was completed.
477
+     *
478
+     * @since 1.0.19
479
+     * @param  string $context View or edit context.
480
+     * @return string
481
+     */
482
+    public function get_completed_date( $context = 'view' ) {
483
+        return $this->get_prop( 'completed_date', $context );
484 484
     }
485 485
 
486 486
     /**
487
-	 * Alias for self::get_completed_date().
488
-	 *
489
-	 * @since 1.0.19
490
-	 * @param  string $context View or edit context.
491
-	 * @return string
492
-	 */
493
-	public function get_date_completed( $context = 'view' ) {
494
-		return $this->get_completed_date( $context );
487
+     * Alias for self::get_completed_date().
488
+     *
489
+     * @since 1.0.19
490
+     * @param  string $context View or edit context.
491
+     * @return string
492
+     */
493
+    public function get_date_completed( $context = 'view' ) {
494
+        return $this->get_completed_date( $context );
495 495
     }
496 496
 
497 497
     /**
498
-	 * Get GMT date when the invoice was was completed.
499
-	 *
500
-	 * @since 1.0.19
501
-	 * @param  string $context View or edit context.
502
-	 * @return string
503
-	 */
504
-	public function get_completed_date_gmt( $context = 'view' ) {
498
+     * Get GMT date when the invoice was was completed.
499
+     *
500
+     * @since 1.0.19
501
+     * @param  string $context View or edit context.
502
+     * @return string
503
+     */
504
+    public function get_completed_date_gmt( $context = 'view' ) {
505 505
         $date = $this->get_completed_date( $context );
506 506
 
507 507
         if ( $date ) {
508 508
             $date = get_gmt_from_date( $date );
509 509
         }
510
-		return $date;
510
+        return $date;
511 511
     }
512 512
 
513 513
     /**
514
-	 * Alias for self::get_completed_date_gmt().
515
-	 *
516
-	 * @since 1.0.19
517
-	 * @param  string $context View or edit context.
518
-	 * @return string
519
-	 */
520
-	public function get_gmt_completed_date( $context = 'view' ) {
521
-		return $this->get_completed_date_gmt( $context );
514
+     * Alias for self::get_completed_date_gmt().
515
+     *
516
+     * @since 1.0.19
517
+     * @param  string $context View or edit context.
518
+     * @return string
519
+     */
520
+    public function get_gmt_completed_date( $context = 'view' ) {
521
+        return $this->get_completed_date_gmt( $context );
522 522
     }
523 523
 
524 524
     /**
525
-	 * Get the invoice number.
526
-	 *
527
-	 * @since 1.0.19
528
-	 * @param  string $context View or edit context.
529
-	 * @return string
530
-	 */
531
-	public function get_number( $context = 'view' ) {
525
+     * Get the invoice number.
526
+     *
527
+     * @since 1.0.19
528
+     * @param  string $context View or edit context.
529
+     * @return string
530
+     */
531
+    public function get_number( $context = 'view' ) {
532 532
         $number = $this->get_prop( 'number', $context );
533 533
 
534 534
         if ( empty( $number ) ) {
@@ -536,17 +536,17 @@  discard block
 block discarded – undo
536 536
             $this->set_number( $number );
537 537
         }
538 538
 
539
-		return $number;
539
+        return $number;
540 540
     }
541 541
 
542 542
     /**
543
-	 * Get the invoice key.
544
-	 *
545
-	 * @since 1.0.19
546
-	 * @param  string $context View or edit context.
547
-	 * @return string
548
-	 */
549
-	public function get_key( $context = 'view' ) {
543
+     * Get the invoice key.
544
+     *
545
+     * @since 1.0.19
546
+     * @param  string $context View or edit context.
547
+     * @return string
548
+     */
549
+    public function get_key( $context = 'view' ) {
550 550
         $key = $this->get_prop( 'key', $context );
551 551
 
552 552
         if ( empty( $key ) ) {
@@ -554,24 +554,24 @@  discard block
 block discarded – undo
554 554
             $this->set_key( $key );
555 555
         }
556 556
 
557
-		return $key;
557
+        return $key;
558 558
     }
559 559
 
560 560
     /**
561
-	 * Get the invoice type.
562
-	 *
563
-	 * @since 1.0.19
564
-	 * @param  string $context View or edit context.
565
-	 * @return string
566
-	 */
567
-	public function get_type( $context = 'view' ) {
561
+     * Get the invoice type.
562
+     *
563
+     * @since 1.0.19
564
+     * @param  string $context View or edit context.
565
+     * @return string
566
+     */
567
+    public function get_type( $context = 'view' ) {
568 568
         return $this->get_prop( 'type', $context );
569
-	}
569
+    }
570 570
 
571
-	/**
572
-	 * @deprecated
573
-	 */
574
-	public function get_invoice_quote_type( $post_id ) {
571
+    /**
572
+     * @deprecated
573
+     */
574
+    public function get_invoice_quote_type( $post_id ) {
575 575
         if ( empty( $post_id ) ) {
576 576
             return '';
577 577
         }
@@ -588,35 +588,35 @@  discard block
 block discarded – undo
588 588
     }
589 589
 
590 590
     /**
591
-	 * Get the invoice post type.
592
-	 *
593
-	 * @since 1.0.19
594
-	 * @param  string $context View or edit context.
595
-	 * @return string
596
-	 */
597
-	public function get_post_type( $context = 'view' ) {
591
+     * Get the invoice post type.
592
+     *
593
+     * @since 1.0.19
594
+     * @param  string $context View or edit context.
595
+     * @return string
596
+     */
597
+    public function get_post_type( $context = 'view' ) {
598 598
         return $this->get_prop( 'post_type', $context );
599 599
     }
600 600
 
601 601
     /**
602
-	 * Get the invoice mode.
603
-	 *
604
-	 * @since 1.0.19
605
-	 * @param  string $context View or edit context.
606
-	 * @return string
607
-	 */
608
-	public function get_mode( $context = 'view' ) {
602
+     * Get the invoice mode.
603
+     *
604
+     * @since 1.0.19
605
+     * @param  string $context View or edit context.
606
+     * @return string
607
+     */
608
+    public function get_mode( $context = 'view' ) {
609 609
         return $this->get_prop( 'mode', $context );
610 610
     }
611 611
 
612 612
     /**
613
-	 * Get the invoice path.
614
-	 *
615
-	 * @since 1.0.19
616
-	 * @param  string $context View or edit context.
617
-	 * @return string
618
-	 */
619
-	public function get_path( $context = 'view' ) {
613
+     * Get the invoice path.
614
+     *
615
+     * @since 1.0.19
616
+     * @param  string $context View or edit context.
617
+     * @return string
618
+     */
619
+    public function get_path( $context = 'view' ) {
620 620
         $path = $this->get_prop( 'path', $context );
621 621
 
622 622
         if ( empty( $path ) ) {
@@ -624,73 +624,73 @@  discard block
 block discarded – undo
624 624
             $path   = sanitize_title( $prefix . $this->get_id() );
625 625
         }
626 626
 
627
-		return $path;
627
+        return $path;
628 628
     }
629 629
 
630 630
     /**
631
-	 * Get the invoice name/title.
632
-	 *
633
-	 * @since 1.0.19
634
-	 * @param  string $context View or edit context.
635
-	 * @return string
636
-	 */
637
-	public function get_name( $context = 'view' ) {
631
+     * Get the invoice name/title.
632
+     *
633
+     * @since 1.0.19
634
+     * @param  string $context View or edit context.
635
+     * @return string
636
+     */
637
+    public function get_name( $context = 'view' ) {
638 638
         $name = $this->get_prop( 'title', $context );
639 639
 
640
-		return empty( $name ) ? $this->get_number( $context ) : $name;
640
+        return empty( $name ) ? $this->get_number( $context ) : $name;
641 641
     }
642 642
 
643 643
     /**
644
-	 * Alias of self::get_name().
645
-	 *
646
-	 * @since 1.0.19
647
-	 * @param  string $context View or edit context.
648
-	 * @return string
649
-	 */
650
-	public function get_title( $context = 'view' ) {
651
-		return $this->get_name( $context );
644
+     * Alias of self::get_name().
645
+     *
646
+     * @since 1.0.19
647
+     * @param  string $context View or edit context.
648
+     * @return string
649
+     */
650
+    public function get_title( $context = 'view' ) {
651
+        return $this->get_name( $context );
652 652
     }
653 653
 
654 654
     /**
655
-	 * Get the invoice description.
656
-	 *
657
-	 * @since 1.0.19
658
-	 * @param  string $context View or edit context.
659
-	 * @return string
660
-	 */
661
-	public function get_description( $context = 'view' ) {
662
-		return $this->get_prop( 'description', $context );
655
+     * Get the invoice description.
656
+     *
657
+     * @since 1.0.19
658
+     * @param  string $context View or edit context.
659
+     * @return string
660
+     */
661
+    public function get_description( $context = 'view' ) {
662
+        return $this->get_prop( 'description', $context );
663 663
     }
664 664
 
665 665
     /**
666
-	 * Alias of self::get_description().
667
-	 *
668
-	 * @since 1.0.19
669
-	 * @param  string $context View or edit context.
670
-	 * @return string
671
-	 */
672
-	public function get_excerpt( $context = 'view' ) {
673
-		return $this->get_description( $context );
666
+     * Alias of self::get_description().
667
+     *
668
+     * @since 1.0.19
669
+     * @param  string $context View or edit context.
670
+     * @return string
671
+     */
672
+    public function get_excerpt( $context = 'view' ) {
673
+        return $this->get_description( $context );
674 674
     }
675 675
 
676 676
     /**
677
-	 * Alias of self::get_description().
678
-	 *
679
-	 * @since 1.0.19
680
-	 * @param  string $context View or edit context.
681
-	 * @return string
682
-	 */
683
-	public function get_summary( $context = 'view' ) {
684
-		return $this->get_description( $context );
677
+     * Alias of self::get_description().
678
+     *
679
+     * @since 1.0.19
680
+     * @param  string $context View or edit context.
681
+     * @return string
682
+     */
683
+    public function get_summary( $context = 'view' ) {
684
+        return $this->get_description( $context );
685 685
     }
686 686
 
687 687
     /**
688
-	 * Returns the user info.
689
-	 *
690
-	 * @since 1.0.19
688
+     * Returns the user info.
689
+     *
690
+     * @since 1.0.19
691 691
      * @param  string $context View or edit context.
692
-	 * @return array
693
-	 */
692
+     * @return array
693
+     */
694 694
     public function get_user_info( $context = 'view' ) {
695 695
 
696 696
         $user_info = array(
@@ -707,605 +707,605 @@  discard block
 block discarded – undo
707 707
             'company'    => $this->get_company( $context ),
708 708
             'vat_number' => $this->get_vat_number( $context ),
709 709
             'discount'   => $this->get_discount_code( $context ),
710
-		);
710
+        );
711 711
 
712
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
712
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
713 713
 
714 714
     }
715 715
 
716 716
     /**
717
-	 * Get the customer id.
718
-	 *
719
-	 * @since 1.0.19
720
-	 * @param  string $context View or edit context.
721
-	 * @return int
722
-	 */
723
-	public function get_author( $context = 'view' ) {
724
-		return (int) $this->get_prop( 'author', $context );
717
+     * Get the customer id.
718
+     *
719
+     * @since 1.0.19
720
+     * @param  string $context View or edit context.
721
+     * @return int
722
+     */
723
+    public function get_author( $context = 'view' ) {
724
+        return (int) $this->get_prop( 'author', $context );
725 725
     }
726 726
 
727 727
     /**
728
-	 * Alias of self::get_author().
729
-	 *
730
-	 * @since 1.0.19
731
-	 * @param  string $context View or edit context.
732
-	 * @return int
733
-	 */
734
-	public function get_user_id( $context = 'view' ) {
735
-		return $this->get_author( $context );
728
+     * Alias of self::get_author().
729
+     *
730
+     * @since 1.0.19
731
+     * @param  string $context View or edit context.
732
+     * @return int
733
+     */
734
+    public function get_user_id( $context = 'view' ) {
735
+        return $this->get_author( $context );
736 736
     }
737 737
 
738
-     /**
739
-	 * Alias of self::get_author().
740
-	 *
741
-	 * @since 1.0.19
742
-	 * @param  string $context View or edit context.
743
-	 * @return int
744
-	 */
745
-	public function get_customer_id( $context = 'view' ) {
746
-		return $this->get_author( $context );
738
+        /**
739
+         * Alias of self::get_author().
740
+         *
741
+         * @since 1.0.19
742
+         * @param  string $context View or edit context.
743
+         * @return int
744
+         */
745
+    public function get_customer_id( $context = 'view' ) {
746
+        return $this->get_author( $context );
747 747
     }
748 748
 
749 749
     /**
750
-	 * Get the customer's ip.
751
-	 *
752
-	 * @since 1.0.19
753
-	 * @param  string $context View or edit context.
754
-	 * @return string
755
-	 */
756
-	public function get_ip( $context = 'view' ) {
757
-		return $this->get_prop( 'user_ip', $context );
750
+     * Get the customer's ip.
751
+     *
752
+     * @since 1.0.19
753
+     * @param  string $context View or edit context.
754
+     * @return string
755
+     */
756
+    public function get_ip( $context = 'view' ) {
757
+        return $this->get_prop( 'user_ip', $context );
758 758
     }
759 759
 
760 760
     /**
761
-	 * Alias of self::get_ip().
762
-	 *
763
-	 * @since 1.0.19
764
-	 * @param  string $context View or edit context.
765
-	 * @return string
766
-	 */
767
-	public function get_user_ip( $context = 'view' ) {
768
-		return $this->get_ip( $context );
761
+     * Alias of self::get_ip().
762
+     *
763
+     * @since 1.0.19
764
+     * @param  string $context View or edit context.
765
+     * @return string
766
+     */
767
+    public function get_user_ip( $context = 'view' ) {
768
+        return $this->get_ip( $context );
769 769
     }
770 770
 
771
-     /**
772
-	 * Alias of self::get_ip().
773
-	 *
774
-	 * @since 1.0.19
775
-	 * @param  string $context View or edit context.
776
-	 * @return string
777
-	 */
778
-	public function get_customer_ip( $context = 'view' ) {
779
-		return $this->get_ip( $context );
771
+        /**
772
+         * Alias of self::get_ip().
773
+         *
774
+         * @since 1.0.19
775
+         * @param  string $context View or edit context.
776
+         * @return string
777
+         */
778
+    public function get_customer_ip( $context = 'view' ) {
779
+        return $this->get_ip( $context );
780 780
     }
781 781
 
782 782
     /**
783
-	 * Get the customer's first name.
784
-	 *
785
-	 * @since 1.0.19
786
-	 * @param  string $context View or edit context.
787
-	 * @return string
788
-	 */
789
-	public function get_first_name( $context = 'view' ) {
790
-		return $this->get_prop( 'first_name', $context );
783
+     * Get the customer's first name.
784
+     *
785
+     * @since 1.0.19
786
+     * @param  string $context View or edit context.
787
+     * @return string
788
+     */
789
+    public function get_first_name( $context = 'view' ) {
790
+        return $this->get_prop( 'first_name', $context );
791 791
     }
792 792
 
793 793
     /**
794
-	 * Alias of self::get_first_name().
795
-	 *
796
-	 * @since 1.0.19
797
-	 * @param  string $context View or edit context.
798
-	 * @return int
799
-	 */
800
-	public function get_user_first_name( $context = 'view' ) {
801
-		return $this->get_first_name( $context );
794
+     * Alias of self::get_first_name().
795
+     *
796
+     * @since 1.0.19
797
+     * @param  string $context View or edit context.
798
+     * @return int
799
+     */
800
+    public function get_user_first_name( $context = 'view' ) {
801
+        return $this->get_first_name( $context );
802 802
     }
803 803
 
804
-     /**
805
-	 * Alias of self::get_first_name().
806
-	 *
807
-	 * @since 1.0.19
808
-	 * @param  string $context View or edit context.
809
-	 * @return int
810
-	 */
811
-	public function get_customer_first_name( $context = 'view' ) {
812
-		return $this->get_first_name( $context );
804
+        /**
805
+         * Alias of self::get_first_name().
806
+         *
807
+         * @since 1.0.19
808
+         * @param  string $context View or edit context.
809
+         * @return int
810
+         */
811
+    public function get_customer_first_name( $context = 'view' ) {
812
+        return $this->get_first_name( $context );
813 813
     }
814 814
 
815 815
     /**
816
-	 * Get the customer's last name.
817
-	 *
818
-	 * @since 1.0.19
819
-	 * @param  string $context View or edit context.
820
-	 * @return string
821
-	 */
822
-	public function get_last_name( $context = 'view' ) {
823
-		return $this->get_prop( 'last_name', $context );
816
+     * Get the customer's last name.
817
+     *
818
+     * @since 1.0.19
819
+     * @param  string $context View or edit context.
820
+     * @return string
821
+     */
822
+    public function get_last_name( $context = 'view' ) {
823
+        return $this->get_prop( 'last_name', $context );
824 824
     }
825 825
 
826 826
     /**
827
-	 * Alias of self::get_last_name().
828
-	 *
829
-	 * @since 1.0.19
830
-	 * @param  string $context View or edit context.
831
-	 * @return int
832
-	 */
833
-	public function get_user_last_name( $context = 'view' ) {
834
-		return $this->get_last_name( $context );
827
+     * Alias of self::get_last_name().
828
+     *
829
+     * @since 1.0.19
830
+     * @param  string $context View or edit context.
831
+     * @return int
832
+     */
833
+    public function get_user_last_name( $context = 'view' ) {
834
+        return $this->get_last_name( $context );
835 835
     }
836 836
 
837 837
     /**
838
-	 * Alias of self::get_last_name().
839
-	 *
840
-	 * @since 1.0.19
841
-	 * @param  string $context View or edit context.
842
-	 * @return int
843
-	 */
844
-	public function get_customer_last_name( $context = 'view' ) {
845
-		return $this->get_last_name( $context );
838
+     * Alias of self::get_last_name().
839
+     *
840
+     * @since 1.0.19
841
+     * @param  string $context View or edit context.
842
+     * @return int
843
+     */
844
+    public function get_customer_last_name( $context = 'view' ) {
845
+        return $this->get_last_name( $context );
846 846
     }
847 847
 
848 848
     /**
849
-	 * Get the customer's full name.
850
-	 *
851
-	 * @since 1.0.19
852
-	 * @param  string $context View or edit context.
853
-	 * @return string
854
-	 */
855
-	public function get_full_name( $context = 'view' ) {
856
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
849
+     * Get the customer's full name.
850
+     *
851
+     * @since 1.0.19
852
+     * @param  string $context View or edit context.
853
+     * @return string
854
+     */
855
+    public function get_full_name( $context = 'view' ) {
856
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
857 857
     }
858 858
 
859 859
     /**
860
-	 * Alias of self::get_full_name().
861
-	 *
862
-	 * @since 1.0.19
863
-	 * @param  string $context View or edit context.
864
-	 * @return int
865
-	 */
866
-	public function get_user_full_name( $context = 'view' ) {
867
-		return $this->get_full_name( $context );
860
+     * Alias of self::get_full_name().
861
+     *
862
+     * @since 1.0.19
863
+     * @param  string $context View or edit context.
864
+     * @return int
865
+     */
866
+    public function get_user_full_name( $context = 'view' ) {
867
+        return $this->get_full_name( $context );
868 868
     }
869 869
 
870 870
     /**
871
-	 * Alias of self::get_full_name().
872
-	 *
873
-	 * @since 1.0.19
874
-	 * @param  string $context View or edit context.
875
-	 * @return int
876
-	 */
877
-	public function get_customer_full_name( $context = 'view' ) {
878
-		return $this->get_full_name( $context );
871
+     * Alias of self::get_full_name().
872
+     *
873
+     * @since 1.0.19
874
+     * @param  string $context View or edit context.
875
+     * @return int
876
+     */
877
+    public function get_customer_full_name( $context = 'view' ) {
878
+        return $this->get_full_name( $context );
879 879
     }
880 880
 
881 881
     /**
882
-	 * Get the customer's phone number.
883
-	 *
884
-	 * @since 1.0.19
885
-	 * @param  string $context View or edit context.
886
-	 * @return string
887
-	 */
888
-	public function get_phone( $context = 'view' ) {
889
-		return $this->get_prop( 'phone', $context );
882
+     * Get the customer's phone number.
883
+     *
884
+     * @since 1.0.19
885
+     * @param  string $context View or edit context.
886
+     * @return string
887
+     */
888
+    public function get_phone( $context = 'view' ) {
889
+        return $this->get_prop( 'phone', $context );
890 890
     }
891 891
 
892 892
     /**
893
-	 * Alias of self::get_phone().
894
-	 *
895
-	 * @since 1.0.19
896
-	 * @param  string $context View or edit context.
897
-	 * @return int
898
-	 */
899
-	public function get_phone_number( $context = 'view' ) {
900
-		return $this->get_phone( $context );
893
+     * Alias of self::get_phone().
894
+     *
895
+     * @since 1.0.19
896
+     * @param  string $context View or edit context.
897
+     * @return int
898
+     */
899
+    public function get_phone_number( $context = 'view' ) {
900
+        return $this->get_phone( $context );
901 901
     }
902 902
 
903 903
     /**
904
-	 * Alias of self::get_phone().
905
-	 *
906
-	 * @since 1.0.19
907
-	 * @param  string $context View or edit context.
908
-	 * @return int
909
-	 */
910
-	public function get_user_phone( $context = 'view' ) {
911
-		return $this->get_phone( $context );
904
+     * Alias of self::get_phone().
905
+     *
906
+     * @since 1.0.19
907
+     * @param  string $context View or edit context.
908
+     * @return int
909
+     */
910
+    public function get_user_phone( $context = 'view' ) {
911
+        return $this->get_phone( $context );
912 912
     }
913 913
 
914 914
     /**
915
-	 * Alias of self::get_phone().
916
-	 *
917
-	 * @since 1.0.19
918
-	 * @param  string $context View or edit context.
919
-	 * @return int
920
-	 */
921
-	public function get_customer_phone( $context = 'view' ) {
922
-		return $this->get_phone( $context );
915
+     * Alias of self::get_phone().
916
+     *
917
+     * @since 1.0.19
918
+     * @param  string $context View or edit context.
919
+     * @return int
920
+     */
921
+    public function get_customer_phone( $context = 'view' ) {
922
+        return $this->get_phone( $context );
923 923
     }
924 924
 
925 925
     /**
926
-	 * Get the customer's email address.
927
-	 *
928
-	 * @since 1.0.19
929
-	 * @param  string $context View or edit context.
930
-	 * @return string
931
-	 */
932
-	public function get_email( $context = 'view' ) {
933
-		return $this->get_prop( 'email', $context );
926
+     * Get the customer's email address.
927
+     *
928
+     * @since 1.0.19
929
+     * @param  string $context View or edit context.
930
+     * @return string
931
+     */
932
+    public function get_email( $context = 'view' ) {
933
+        return $this->get_prop( 'email', $context );
934 934
     }
935 935
 
936 936
     /**
937
-	 * Alias of self::get_email().
938
-	 *
939
-	 * @since 1.0.19
940
-	 * @param  string $context View or edit context.
941
-	 * @return string
942
-	 */
943
-	public function get_email_address( $context = 'view' ) {
944
-		return $this->get_email( $context );
937
+     * Alias of self::get_email().
938
+     *
939
+     * @since 1.0.19
940
+     * @param  string $context View or edit context.
941
+     * @return string
942
+     */
943
+    public function get_email_address( $context = 'view' ) {
944
+        return $this->get_email( $context );
945 945
     }
946 946
 
947 947
     /**
948
-	 * Alias of self::get_email().
949
-	 *
950
-	 * @since 1.0.19
951
-	 * @param  string $context View or edit context.
952
-	 * @return int
953
-	 */
954
-	public function get_user_email( $context = 'view' ) {
955
-		return $this->get_email( $context );
948
+     * Alias of self::get_email().
949
+     *
950
+     * @since 1.0.19
951
+     * @param  string $context View or edit context.
952
+     * @return int
953
+     */
954
+    public function get_user_email( $context = 'view' ) {
955
+        return $this->get_email( $context );
956 956
     }
957 957
 
958 958
     /**
959
-	 * Alias of self::get_email().
960
-	 *
961
-	 * @since 1.0.19
962
-	 * @param  string $context View or edit context.
963
-	 * @return int
964
-	 */
965
-	public function get_customer_email( $context = 'view' ) {
966
-		return $this->get_email( $context );
959
+     * Alias of self::get_email().
960
+     *
961
+     * @since 1.0.19
962
+     * @param  string $context View or edit context.
963
+     * @return int
964
+     */
965
+    public function get_customer_email( $context = 'view' ) {
966
+        return $this->get_email( $context );
967 967
     }
968 968
 
969 969
     /**
970
-	 * Get the customer's country.
971
-	 *
972
-	 * @since 1.0.19
973
-	 * @param  string $context View or edit context.
974
-	 * @return string
975
-	 */
976
-	public function get_country( $context = 'view' ) {
977
-		$country = $this->get_prop( 'country', $context );
978
-		return empty( $country ) ? wpinv_get_default_country() : $country;
970
+     * Get the customer's country.
971
+     *
972
+     * @since 1.0.19
973
+     * @param  string $context View or edit context.
974
+     * @return string
975
+     */
976
+    public function get_country( $context = 'view' ) {
977
+        $country = $this->get_prop( 'country', $context );
978
+        return empty( $country ) ? wpinv_get_default_country() : $country;
979 979
     }
980 980
 
981 981
     /**
982
-	 * Alias of self::get_country().
983
-	 *
984
-	 * @since 1.0.19
985
-	 * @param  string $context View or edit context.
986
-	 * @return int
987
-	 */
988
-	public function get_user_country( $context = 'view' ) {
989
-		return $this->get_country( $context );
982
+     * Alias of self::get_country().
983
+     *
984
+     * @since 1.0.19
985
+     * @param  string $context View or edit context.
986
+     * @return int
987
+     */
988
+    public function get_user_country( $context = 'view' ) {
989
+        return $this->get_country( $context );
990 990
     }
991 991
 
992 992
     /**
993
-	 * Alias of self::get_country().
994
-	 *
995
-	 * @since 1.0.19
996
-	 * @param  string $context View or edit context.
997
-	 * @return int
998
-	 */
999
-	public function get_customer_country( $context = 'view' ) {
1000
-		return $this->get_country( $context );
993
+     * Alias of self::get_country().
994
+     *
995
+     * @since 1.0.19
996
+     * @param  string $context View or edit context.
997
+     * @return int
998
+     */
999
+    public function get_customer_country( $context = 'view' ) {
1000
+        return $this->get_country( $context );
1001 1001
     }
1002 1002
 
1003 1003
     /**
1004
-	 * Get the customer's state.
1005
-	 *
1006
-	 * @since 1.0.19
1007
-	 * @param  string $context View or edit context.
1008
-	 * @return string
1009
-	 */
1010
-	public function get_state( $context = 'view' ) {
1011
-		$state = $this->get_prop( 'state', $context );
1012
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1004
+     * Get the customer's state.
1005
+     *
1006
+     * @since 1.0.19
1007
+     * @param  string $context View or edit context.
1008
+     * @return string
1009
+     */
1010
+    public function get_state( $context = 'view' ) {
1011
+        $state = $this->get_prop( 'state', $context );
1012
+        return empty( $state ) ? wpinv_get_default_state() : $state;
1013 1013
     }
1014 1014
 
1015 1015
     /**
1016
-	 * Alias of self::get_state().
1017
-	 *
1018
-	 * @since 1.0.19
1019
-	 * @param  string $context View or edit context.
1020
-	 * @return int
1021
-	 */
1022
-	public function get_user_state( $context = 'view' ) {
1023
-		return $this->get_state( $context );
1016
+     * Alias of self::get_state().
1017
+     *
1018
+     * @since 1.0.19
1019
+     * @param  string $context View or edit context.
1020
+     * @return int
1021
+     */
1022
+    public function get_user_state( $context = 'view' ) {
1023
+        return $this->get_state( $context );
1024 1024
     }
1025 1025
 
1026 1026
     /**
1027
-	 * Alias of self::get_state().
1028
-	 *
1029
-	 * @since 1.0.19
1030
-	 * @param  string $context View or edit context.
1031
-	 * @return int
1032
-	 */
1033
-	public function get_customer_state( $context = 'view' ) {
1034
-		return $this->get_state( $context );
1027
+     * Alias of self::get_state().
1028
+     *
1029
+     * @since 1.0.19
1030
+     * @param  string $context View or edit context.
1031
+     * @return int
1032
+     */
1033
+    public function get_customer_state( $context = 'view' ) {
1034
+        return $this->get_state( $context );
1035 1035
     }
1036 1036
 
1037 1037
     /**
1038
-	 * Get the customer's city.
1039
-	 *
1040
-	 * @since 1.0.19
1041
-	 * @param  string $context View or edit context.
1042
-	 * @return string
1043
-	 */
1044
-	public function get_city( $context = 'view' ) {
1045
-		return $this->get_prop( 'city', $context );
1038
+     * Get the customer's city.
1039
+     *
1040
+     * @since 1.0.19
1041
+     * @param  string $context View or edit context.
1042
+     * @return string
1043
+     */
1044
+    public function get_city( $context = 'view' ) {
1045
+        return $this->get_prop( 'city', $context );
1046 1046
     }
1047 1047
 
1048 1048
     /**
1049
-	 * Alias of self::get_city().
1050
-	 *
1051
-	 * @since 1.0.19
1052
-	 * @param  string $context View or edit context.
1053
-	 * @return string
1054
-	 */
1055
-	public function get_user_city( $context = 'view' ) {
1056
-		return $this->get_city( $context );
1049
+     * Alias of self::get_city().
1050
+     *
1051
+     * @since 1.0.19
1052
+     * @param  string $context View or edit context.
1053
+     * @return string
1054
+     */
1055
+    public function get_user_city( $context = 'view' ) {
1056
+        return $this->get_city( $context );
1057 1057
     }
1058 1058
 
1059 1059
     /**
1060
-	 * Alias of self::get_city().
1061
-	 *
1062
-	 * @since 1.0.19
1063
-	 * @param  string $context View or edit context.
1064
-	 * @return string
1065
-	 */
1066
-	public function get_customer_city( $context = 'view' ) {
1067
-		return $this->get_city( $context );
1060
+     * Alias of self::get_city().
1061
+     *
1062
+     * @since 1.0.19
1063
+     * @param  string $context View or edit context.
1064
+     * @return string
1065
+     */
1066
+    public function get_customer_city( $context = 'view' ) {
1067
+        return $this->get_city( $context );
1068 1068
     }
1069 1069
 
1070 1070
     /**
1071
-	 * Get the customer's zip.
1072
-	 *
1073
-	 * @since 1.0.19
1074
-	 * @param  string $context View or edit context.
1075
-	 * @return string
1076
-	 */
1077
-	public function get_zip( $context = 'view' ) {
1078
-		return $this->get_prop( 'zip', $context );
1071
+     * Get the customer's zip.
1072
+     *
1073
+     * @since 1.0.19
1074
+     * @param  string $context View or edit context.
1075
+     * @return string
1076
+     */
1077
+    public function get_zip( $context = 'view' ) {
1078
+        return $this->get_prop( 'zip', $context );
1079 1079
     }
1080 1080
 
1081 1081
     /**
1082
-	 * Alias of self::get_zip().
1083
-	 *
1084
-	 * @since 1.0.19
1085
-	 * @param  string $context View or edit context.
1086
-	 * @return string
1087
-	 */
1088
-	public function get_user_zip( $context = 'view' ) {
1089
-		return $this->get_zip( $context );
1082
+     * Alias of self::get_zip().
1083
+     *
1084
+     * @since 1.0.19
1085
+     * @param  string $context View or edit context.
1086
+     * @return string
1087
+     */
1088
+    public function get_user_zip( $context = 'view' ) {
1089
+        return $this->get_zip( $context );
1090 1090
     }
1091 1091
 
1092 1092
     /**
1093
-	 * Alias of self::get_zip().
1094
-	 *
1095
-	 * @since 1.0.19
1096
-	 * @param  string $context View or edit context.
1097
-	 * @return string
1098
-	 */
1099
-	public function get_customer_zip( $context = 'view' ) {
1100
-		return $this->get_zip( $context );
1093
+     * Alias of self::get_zip().
1094
+     *
1095
+     * @since 1.0.19
1096
+     * @param  string $context View or edit context.
1097
+     * @return string
1098
+     */
1099
+    public function get_customer_zip( $context = 'view' ) {
1100
+        return $this->get_zip( $context );
1101 1101
     }
1102 1102
 
1103 1103
     /**
1104
-	 * Get the customer's company.
1105
-	 *
1106
-	 * @since 1.0.19
1107
-	 * @param  string $context View or edit context.
1108
-	 * @return string
1109
-	 */
1110
-	public function get_company( $context = 'view' ) {
1111
-		return $this->get_prop( 'company', $context );
1104
+     * Get the customer's company.
1105
+     *
1106
+     * @since 1.0.19
1107
+     * @param  string $context View or edit context.
1108
+     * @return string
1109
+     */
1110
+    public function get_company( $context = 'view' ) {
1111
+        return $this->get_prop( 'company', $context );
1112 1112
     }
1113 1113
 
1114 1114
     /**
1115
-	 * Alias of self::get_company().
1116
-	 *
1117
-	 * @since 1.0.19
1118
-	 * @param  string $context View or edit context.
1119
-	 * @return string
1120
-	 */
1121
-	public function get_user_company( $context = 'view' ) {
1122
-		return $this->get_company( $context );
1115
+     * Alias of self::get_company().
1116
+     *
1117
+     * @since 1.0.19
1118
+     * @param  string $context View or edit context.
1119
+     * @return string
1120
+     */
1121
+    public function get_user_company( $context = 'view' ) {
1122
+        return $this->get_company( $context );
1123 1123
     }
1124 1124
 
1125 1125
     /**
1126
-	 * Alias of self::get_company().
1127
-	 *
1128
-	 * @since 1.0.19
1129
-	 * @param  string $context View or edit context.
1130
-	 * @return string
1131
-	 */
1132
-	public function get_customer_company( $context = 'view' ) {
1133
-		return $this->get_company( $context );
1126
+     * Alias of self::get_company().
1127
+     *
1128
+     * @since 1.0.19
1129
+     * @param  string $context View or edit context.
1130
+     * @return string
1131
+     */
1132
+    public function get_customer_company( $context = 'view' ) {
1133
+        return $this->get_company( $context );
1134 1134
     }
1135 1135
 
1136 1136
     /**
1137
-	 * Get the customer's vat number.
1138
-	 *
1139
-	 * @since 1.0.19
1140
-	 * @param  string $context View or edit context.
1141
-	 * @return string
1142
-	 */
1143
-	public function get_vat_number( $context = 'view' ) {
1144
-		return $this->get_prop( 'vat_number', $context );
1137
+     * Get the customer's vat number.
1138
+     *
1139
+     * @since 1.0.19
1140
+     * @param  string $context View or edit context.
1141
+     * @return string
1142
+     */
1143
+    public function get_vat_number( $context = 'view' ) {
1144
+        return $this->get_prop( 'vat_number', $context );
1145 1145
     }
1146 1146
 
1147 1147
     /**
1148
-	 * Alias of self::get_vat_number().
1149
-	 *
1150
-	 * @since 1.0.19
1151
-	 * @param  string $context View or edit context.
1152
-	 * @return string
1153
-	 */
1154
-	public function get_user_vat_number( $context = 'view' ) {
1155
-		return $this->get_vat_number( $context );
1148
+     * Alias of self::get_vat_number().
1149
+     *
1150
+     * @since 1.0.19
1151
+     * @param  string $context View or edit context.
1152
+     * @return string
1153
+     */
1154
+    public function get_user_vat_number( $context = 'view' ) {
1155
+        return $this->get_vat_number( $context );
1156 1156
     }
1157 1157
 
1158 1158
     /**
1159
-	 * Alias of self::get_vat_number().
1160
-	 *
1161
-	 * @since 1.0.19
1162
-	 * @param  string $context View or edit context.
1163
-	 * @return string
1164
-	 */
1165
-	public function get_customer_vat_number( $context = 'view' ) {
1166
-		return $this->get_vat_number( $context );
1159
+     * Alias of self::get_vat_number().
1160
+     *
1161
+     * @since 1.0.19
1162
+     * @param  string $context View or edit context.
1163
+     * @return string
1164
+     */
1165
+    public function get_customer_vat_number( $context = 'view' ) {
1166
+        return $this->get_vat_number( $context );
1167 1167
     }
1168 1168
 
1169 1169
     /**
1170
-	 * Get the customer's vat rate.
1171
-	 *
1172
-	 * @since 1.0.19
1173
-	 * @param  string $context View or edit context.
1174
-	 * @return string
1175
-	 */
1176
-	public function get_vat_rate( $context = 'view' ) {
1177
-		return $this->get_prop( 'vat_rate', $context );
1178
-    }
1170
+     * Get the customer's vat rate.
1171
+     *
1172
+     * @since 1.0.19
1173
+     * @param  string $context View or edit context.
1174
+     * @return string
1175
+     */
1176
+    public function get_vat_rate( $context = 'view' ) {
1177
+        return $this->get_prop( 'vat_rate', $context );
1178
+    }
1179
+
1180
+    /**
1181
+     * Alias of self::get_vat_rate().
1182
+     *
1183
+     * @since 1.0.19
1184
+     * @param  string $context View or edit context.
1185
+     * @return string
1186
+     */
1187
+    public function get_user_vat_rate( $context = 'view' ) {
1188
+        return $this->get_vat_rate( $context );
1189
+    }
1190
+
1191
+    /**
1192
+     * Alias of self::get_vat_rate().
1193
+     *
1194
+     * @since 1.0.19
1195
+     * @param  string $context View or edit context.
1196
+     * @return string
1197
+     */
1198
+    public function get_customer_vat_rate( $context = 'view' ) {
1199
+        return $this->get_vat_rate( $context );
1200
+    }
1201
+
1202
+    /**
1203
+     * Get the customer's address.
1204
+     *
1205
+     * @since 1.0.19
1206
+     * @param  string $context View or edit context.
1207
+     * @return string
1208
+     */
1209
+    public function get_address( $context = 'view' ) {
1210
+        return $this->get_prop( 'address', $context );
1211
+    }
1212
+
1213
+    /**
1214
+     * Alias of self::get_address().
1215
+     *
1216
+     * @since 1.0.19
1217
+     * @param  string $context View or edit context.
1218
+     * @return string
1219
+     */
1220
+    public function get_user_address( $context = 'view' ) {
1221
+        return $this->get_address( $context );
1222
+    }
1223
+
1224
+    /**
1225
+     * Alias of self::get_address().
1226
+     *
1227
+     * @since 1.0.19
1228
+     * @param  string $context View or edit context.
1229
+     * @return string
1230
+     */
1231
+    public function get_customer_address( $context = 'view' ) {
1232
+        return $this->get_address( $context );
1233
+    }
1179 1234
 
1180 1235
     /**
1181
-	 * Alias of self::get_vat_rate().
1182
-	 *
1183
-	 * @since 1.0.19
1184
-	 * @param  string $context View or edit context.
1185
-	 * @return string
1186
-	 */
1187
-	public function get_user_vat_rate( $context = 'view' ) {
1188
-		return $this->get_vat_rate( $context );
1236
+     * Get whether the customer has viewed the invoice or not.
1237
+     *
1238
+     * @since 1.0.19
1239
+     * @param  string $context View or edit context.
1240
+     * @return bool
1241
+     */
1242
+    public function get_is_viewed( $context = 'view' ) {
1243
+        return (bool) $this->get_prop( 'is_viewed', $context );
1244
+    }
1245
+
1246
+    /**
1247
+     * Get other recipients for invoice communications.
1248
+     *
1249
+     * @since 1.0.19
1250
+     * @param  string $context View or edit context.
1251
+     * @return bool
1252
+     */
1253
+    public function get_email_cc( $context = 'view' ) {
1254
+        return $this->get_prop( 'email_cc', $context );
1255
+    }
1256
+
1257
+    /**
1258
+     * Get invoice template.
1259
+     *
1260
+     * @since 1.0.19
1261
+     * @param  string $context View or edit context.
1262
+     * @return bool
1263
+     */
1264
+    public function get_template( $context = 'view' ) {
1265
+        return $this->get_prop( 'template', $context );
1266
+    }
1267
+
1268
+    /**
1269
+     * Get whether the customer has confirmed their address.
1270
+     *
1271
+     * @since 1.0.19
1272
+     * @param  string $context View or edit context.
1273
+     * @return bool
1274
+     */
1275
+    public function get_address_confirmed( $context = 'view' ) {
1276
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1189 1277
     }
1190 1278
 
1191 1279
     /**
1192
-	 * Alias of self::get_vat_rate().
1193
-	 *
1194
-	 * @since 1.0.19
1195
-	 * @param  string $context View or edit context.
1196
-	 * @return string
1197
-	 */
1198
-	public function get_customer_vat_rate( $context = 'view' ) {
1199
-		return $this->get_vat_rate( $context );
1280
+     * Alias of self::get_address_confirmed().
1281
+     *
1282
+     * @since 1.0.19
1283
+     * @param  string $context View or edit context.
1284
+     * @return bool
1285
+     */
1286
+    public function get_user_address_confirmed( $context = 'view' ) {
1287
+        return $this->get_address_confirmed( $context );
1200 1288
     }
1201 1289
 
1202 1290
     /**
1203
-	 * Get the customer's address.
1204
-	 *
1205
-	 * @since 1.0.19
1206
-	 * @param  string $context View or edit context.
1207
-	 * @return string
1208
-	 */
1209
-	public function get_address( $context = 'view' ) {
1210
-		return $this->get_prop( 'address', $context );
1211
-    }
1212
-
1213
-    /**
1214
-	 * Alias of self::get_address().
1215
-	 *
1216
-	 * @since 1.0.19
1217
-	 * @param  string $context View or edit context.
1218
-	 * @return string
1219
-	 */
1220
-	public function get_user_address( $context = 'view' ) {
1221
-		return $this->get_address( $context );
1222
-    }
1223
-
1224
-    /**
1225
-	 * Alias of self::get_address().
1226
-	 *
1227
-	 * @since 1.0.19
1228
-	 * @param  string $context View or edit context.
1229
-	 * @return string
1230
-	 */
1231
-	public function get_customer_address( $context = 'view' ) {
1232
-		return $this->get_address( $context );
1233
-    }
1234
-
1235
-    /**
1236
-	 * Get whether the customer has viewed the invoice or not.
1237
-	 *
1238
-	 * @since 1.0.19
1239
-	 * @param  string $context View or edit context.
1240
-	 * @return bool
1241
-	 */
1242
-	public function get_is_viewed( $context = 'view' ) {
1243
-		return (bool) $this->get_prop( 'is_viewed', $context );
1244
-	}
1245
-
1246
-	/**
1247
-	 * Get other recipients for invoice communications.
1248
-	 *
1249
-	 * @since 1.0.19
1250
-	 * @param  string $context View or edit context.
1251
-	 * @return bool
1252
-	 */
1253
-	public function get_email_cc( $context = 'view' ) {
1254
-		return $this->get_prop( 'email_cc', $context );
1255
-	}
1256
-
1257
-	/**
1258
-	 * Get invoice template.
1259
-	 *
1260
-	 * @since 1.0.19
1261
-	 * @param  string $context View or edit context.
1262
-	 * @return bool
1263
-	 */
1264
-	public function get_template( $context = 'view' ) {
1265
-		return $this->get_prop( 'template', $context );
1266
-	}
1267
-
1268
-	/**
1269
-	 * Get whether the customer has confirmed their address.
1270
-	 *
1271
-	 * @since 1.0.19
1272
-	 * @param  string $context View or edit context.
1273
-	 * @return bool
1274
-	 */
1275
-	public function get_address_confirmed( $context = 'view' ) {
1276
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1277
-    }
1278
-
1279
-    /**
1280
-	 * Alias of self::get_address_confirmed().
1281
-	 *
1282
-	 * @since 1.0.19
1283
-	 * @param  string $context View or edit context.
1284
-	 * @return bool
1285
-	 */
1286
-	public function get_user_address_confirmed( $context = 'view' ) {
1287
-		return $this->get_address_confirmed( $context );
1288
-    }
1289
-
1290
-    /**
1291
-	 * Alias of self::get_address().
1292
-	 *
1293
-	 * @since 1.0.19
1294
-	 * @param  string $context View or edit context.
1295
-	 * @return bool
1296
-	 */
1297
-	public function get_customer_address_confirmed( $context = 'view' ) {
1298
-		return $this->get_address_confirmed( $context );
1299
-    }
1300
-
1301
-    /**
1302
-	 * Get the invoice subtotal.
1303
-	 *
1304
-	 * @since 1.0.19
1305
-	 * @param  string $context View or edit context.
1306
-	 * @return float
1307
-	 */
1308
-	public function get_subtotal( $context = 'view' ) {
1291
+     * Alias of self::get_address().
1292
+     *
1293
+     * @since 1.0.19
1294
+     * @param  string $context View or edit context.
1295
+     * @return bool
1296
+     */
1297
+    public function get_customer_address_confirmed( $context = 'view' ) {
1298
+        return $this->get_address_confirmed( $context );
1299
+    }
1300
+
1301
+    /**
1302
+     * Get the invoice subtotal.
1303
+     *
1304
+     * @since 1.0.19
1305
+     * @param  string $context View or edit context.
1306
+     * @return float
1307
+     */
1308
+    public function get_subtotal( $context = 'view' ) {
1309 1309
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1310 1310
 
1311 1311
         // Backwards compatibility.
@@ -1317,155 +1317,155 @@  discard block
 block discarded – undo
1317 1317
     }
1318 1318
 
1319 1319
     /**
1320
-	 * Get the invoice discount total.
1321
-	 *
1322
-	 * @since 1.0.19
1323
-	 * @param  string $context View or edit context.
1324
-	 * @return float
1325
-	 */
1326
-	public function get_total_discount( $context = 'view' ) {
1327
-		return (float) $this->get_prop( 'total_discount', $context );
1320
+     * Get the invoice discount total.
1321
+     *
1322
+     * @since 1.0.19
1323
+     * @param  string $context View or edit context.
1324
+     * @return float
1325
+     */
1326
+    public function get_total_discount( $context = 'view' ) {
1327
+        return (float) $this->get_prop( 'total_discount', $context );
1328 1328
     }
1329 1329
 
1330 1330
     /**
1331
-	 * Get the invoice tax total.
1332
-	 *
1333
-	 * @since 1.0.19
1334
-	 * @param  string $context View or edit context.
1335
-	 * @return float
1336
-	 */
1337
-	public function get_total_tax( $context = 'view' ) {
1338
-		return (float) $this->get_prop( 'total_tax', $context );
1339
-	}
1331
+     * Get the invoice tax total.
1332
+     *
1333
+     * @since 1.0.19
1334
+     * @param  string $context View or edit context.
1335
+     * @return float
1336
+     */
1337
+    public function get_total_tax( $context = 'view' ) {
1338
+        return (float) $this->get_prop( 'total_tax', $context );
1339
+    }
1340 1340
 
1341
-	/**
1342
-	 * @deprecated
1343
-	 */
1344
-	public function get_final_tax( $currency = false ) {
1345
-		$tax = $this->get_total_tax();
1341
+    /**
1342
+     * @deprecated
1343
+     */
1344
+    public function get_final_tax( $currency = false ) {
1345
+        $tax = $this->get_total_tax();
1346 1346
 
1347 1347
         if ( $currency ) {
1348
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1348
+            return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1349 1349
         }
1350 1350
 
1351 1351
         return $tax;
1352 1352
     }
1353 1353
 
1354 1354
     /**
1355
-	 * Get the invoice fees total.
1356
-	 *
1357
-	 * @since 1.0.19
1358
-	 * @param  string $context View or edit context.
1359
-	 * @return float
1360
-	 */
1361
-	public function get_total_fees( $context = 'view' ) {
1362
-		return (float) $this->get_prop( 'total_fees', $context );
1355
+     * Get the invoice fees total.
1356
+     *
1357
+     * @since 1.0.19
1358
+     * @param  string $context View or edit context.
1359
+     * @return float
1360
+     */
1361
+    public function get_total_fees( $context = 'view' ) {
1362
+        return (float) $this->get_prop( 'total_fees', $context );
1363 1363
     }
1364 1364
 
1365 1365
     /**
1366
-	 * Alias for self::get_total_fees().
1367
-	 *
1368
-	 * @since 1.0.19
1369
-	 * @param  string $context View or edit context.
1370
-	 * @return float
1371
-	 */
1372
-	public function get_fees_total( $context = 'view' ) {
1373
-		return $this->get_total_fees( $context );
1366
+     * Alias for self::get_total_fees().
1367
+     *
1368
+     * @since 1.0.19
1369
+     * @param  string $context View or edit context.
1370
+     * @return float
1371
+     */
1372
+    public function get_fees_total( $context = 'view' ) {
1373
+        return $this->get_total_fees( $context );
1374 1374
     }
1375 1375
 
1376 1376
     /**
1377
-	 * Get the invoice total.
1378
-	 *
1379
-	 * @since 1.0.19
1377
+     * Get the invoice total.
1378
+     *
1379
+     * @since 1.0.19
1380 1380
      * @return float
1381
-	 */
1382
-	public function get_total() {
1383
-		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1384
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1381
+     */
1382
+    public function get_total() {
1383
+        $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1384
+        return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1385 1385
     }
1386 1386
 
1387 1387
     /**
1388
-	 * Get the initial invoice total.
1389
-	 *
1390
-	 * @since 1.0.19
1388
+     * Get the initial invoice total.
1389
+     *
1390
+     * @since 1.0.19
1391 1391
      * @param  string $context View or edit context.
1392 1392
      * @return float
1393
-	 */
1393
+     */
1394 1394
     public function get_initial_total() {
1395 1395
 
1396
-		if ( empty( $this->totals ) ) {
1397
-			$this->recalculate_total();
1398
-		}
1396
+        if ( empty( $this->totals ) ) {
1397
+            $this->recalculate_total();
1398
+        }
1399 1399
 
1400
-		$tax      = $this->totals['tax']['initial'];
1401
-		$fee      = $this->totals['fee']['initial'];
1402
-		$discount = $this->totals['discount']['initial'];
1403
-		$subtotal = $this->totals['subtotal']['initial'];
1404
-		$total    = $tax + $fee - $discount + $subtotal;
1400
+        $tax      = $this->totals['tax']['initial'];
1401
+        $fee      = $this->totals['fee']['initial'];
1402
+        $discount = $this->totals['discount']['initial'];
1403
+        $subtotal = $this->totals['subtotal']['initial'];
1404
+        $total    = $tax + $fee - $discount + $subtotal;
1405 1405
 
1406
-		if ( 0 > $total ) {
1407
-			$total = 0;
1408
-		}
1406
+        if ( 0 > $total ) {
1407
+            $total = 0;
1408
+        }
1409 1409
 
1410 1410
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1411
-	}
1411
+    }
1412 1412
 
1413
-	/**
1414
-	 * Get the recurring invoice total.
1415
-	 *
1416
-	 * @since 1.0.19
1413
+    /**
1414
+     * Get the recurring invoice total.
1415
+     *
1416
+     * @since 1.0.19
1417 1417
      * @param  string $context View or edit context.
1418 1418
      * @return float
1419
-	 */
1419
+     */
1420 1420
     public function get_recurring_total() {
1421 1421
 
1422
-		if ( empty( $this->totals ) ) {
1423
-			$this->recalculate_total();
1424
-		}
1422
+        if ( empty( $this->totals ) ) {
1423
+            $this->recalculate_total();
1424
+        }
1425 1425
 
1426
-		$tax      = $this->totals['tax']['recurring'];
1427
-		$fee      = $this->totals['fee']['recurring'];
1428
-		$discount = $this->totals['discount']['recurring'];
1429
-		$subtotal = $this->totals['subtotal']['recurring'];
1430
-		$total    = $tax + $fee - $discount + $subtotal;
1426
+        $tax      = $this->totals['tax']['recurring'];
1427
+        $fee      = $this->totals['fee']['recurring'];
1428
+        $discount = $this->totals['discount']['recurring'];
1429
+        $subtotal = $this->totals['subtotal']['recurring'];
1430
+        $total    = $tax + $fee - $discount + $subtotal;
1431 1431
 
1432
-		if ( 0 > $total ) {
1433
-			$total = 0;
1434
-		}
1432
+        if ( 0 > $total ) {
1433
+            $total = 0;
1434
+        }
1435 1435
 
1436 1436
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1437
-	}
1437
+    }
1438 1438
 
1439
-	/**
1440
-	 * Returns recurring payment details.
1441
-	 *
1442
-	 * @since 1.0.19
1439
+    /**
1440
+     * Returns recurring payment details.
1441
+     *
1442
+     * @since 1.0.19
1443 1443
      * @param  string $field Optionally provide a field to return.
1444
-	 * @param string $currency Whether to include the currency.
1444
+     * @param string $currency Whether to include the currency.
1445 1445
      * @return float
1446
-	 */
1446
+     */
1447 1447
     public function get_recurring_details( $field = '', $currency = false ) {
1448 1448
 
1449
-		// Maybe recalculate totals.
1450
-		if ( empty( $this->totals ) ) {
1451
-			$this->recalculate_total();
1452
-		}
1449
+        // Maybe recalculate totals.
1450
+        if ( empty( $this->totals ) ) {
1451
+            $this->recalculate_total();
1452
+        }
1453 1453
 
1454
-		// Prepare recurring totals.
1454
+        // Prepare recurring totals.
1455 1455
         $data = apply_filters(
1456
-			'wpinv_get_invoice_recurring_details',
1457
-			array(
1458
-				'cart_details' => $this->get_cart_details(),
1459
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1460
-				'discount'     => $this->totals['discount']['recurring'],
1461
-				'tax'          => $this->totals['tax']['recurring'],
1462
-				'fee'          => $this->totals['fee']['recurring'],
1463
-				'total'        => $this->get_recurring_total(),
1464
-			),
1465
-			$this,
1466
-			$field,
1467
-			$currency
1468
-		);
1456
+            'wpinv_get_invoice_recurring_details',
1457
+            array(
1458
+                'cart_details' => $this->get_cart_details(),
1459
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1460
+                'discount'     => $this->totals['discount']['recurring'],
1461
+                'tax'          => $this->totals['tax']['recurring'],
1462
+                'fee'          => $this->totals['fee']['recurring'],
1463
+                'total'        => $this->get_recurring_total(),
1464
+            ),
1465
+            $this,
1466
+            $field,
1467
+            $currency
1468
+        );
1469 1469
 
1470 1470
         if ( isset( $data[$field] ) ) {
1471 1471
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1475,145 +1475,145 @@  discard block
 block discarded – undo
1475 1475
     }
1476 1476
 
1477 1477
     /**
1478
-	 * Get the invoice fees.
1479
-	 *
1480
-	 * @since 1.0.19
1481
-	 * @param  string $context View or edit context.
1482
-	 * @return array
1483
-	 */
1484
-	public function get_fees( $context = 'view' ) {
1485
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1478
+     * Get the invoice fees.
1479
+     *
1480
+     * @since 1.0.19
1481
+     * @param  string $context View or edit context.
1482
+     * @return array
1483
+     */
1484
+    public function get_fees( $context = 'view' ) {
1485
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1486 1486
     }
1487 1487
 
1488 1488
     /**
1489
-	 * Get the invoice discounts.
1490
-	 *
1491
-	 * @since 1.0.19
1492
-	 * @param  string $context View or edit context.
1493
-	 * @return array
1494
-	 */
1495
-	public function get_discounts( $context = 'view' ) {
1496
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1489
+     * Get the invoice discounts.
1490
+     *
1491
+     * @since 1.0.19
1492
+     * @param  string $context View or edit context.
1493
+     * @return array
1494
+     */
1495
+    public function get_discounts( $context = 'view' ) {
1496
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1497 1497
     }
1498 1498
 
1499 1499
     /**
1500
-	 * Get the invoice taxes.
1501
-	 *
1502
-	 * @since 1.0.19
1503
-	 * @param  string $context View or edit context.
1504
-	 * @return array
1505
-	 */
1506
-	public function get_taxes( $context = 'view' ) {
1507
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1500
+     * Get the invoice taxes.
1501
+     *
1502
+     * @since 1.0.19
1503
+     * @param  string $context View or edit context.
1504
+     * @return array
1505
+     */
1506
+    public function get_taxes( $context = 'view' ) {
1507
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1508 1508
     }
1509 1509
 
1510 1510
     /**
1511
-	 * Get the invoice items.
1512
-	 *
1513
-	 * @since 1.0.19
1514
-	 * @param  string $context View or edit context.
1515
-	 * @return GetPaid_Form_Item[]
1516
-	 */
1517
-	public function get_items( $context = 'view' ) {
1511
+     * Get the invoice items.
1512
+     *
1513
+     * @since 1.0.19
1514
+     * @param  string $context View or edit context.
1515
+     * @return GetPaid_Form_Item[]
1516
+     */
1517
+    public function get_items( $context = 'view' ) {
1518 1518
         return $this->get_prop( 'items', $context );
1519 1519
     }
1520 1520
 
1521 1521
     /**
1522
-	 * Get the invoice's payment form.
1523
-	 *
1524
-	 * @since 1.0.19
1525
-	 * @param  string $context View or edit context.
1526
-	 * @return int
1527
-	 */
1528
-	public function get_payment_form( $context = 'view' ) {
1529
-		return intval( $this->get_prop( 'payment_form', $context ) );
1522
+     * Get the invoice's payment form.
1523
+     *
1524
+     * @since 1.0.19
1525
+     * @param  string $context View or edit context.
1526
+     * @return int
1527
+     */
1528
+    public function get_payment_form( $context = 'view' ) {
1529
+        return intval( $this->get_prop( 'payment_form', $context ) );
1530 1530
     }
1531 1531
 
1532 1532
     /**
1533
-	 * Get the invoice's submission id.
1534
-	 *
1535
-	 * @since 1.0.19
1536
-	 * @param  string $context View or edit context.
1537
-	 * @return string
1538
-	 */
1539
-	public function get_submission_id( $context = 'view' ) {
1540
-		return $this->get_prop( 'submission_id', $context );
1533
+     * Get the invoice's submission id.
1534
+     *
1535
+     * @since 1.0.19
1536
+     * @param  string $context View or edit context.
1537
+     * @return string
1538
+     */
1539
+    public function get_submission_id( $context = 'view' ) {
1540
+        return $this->get_prop( 'submission_id', $context );
1541 1541
     }
1542 1542
 
1543 1543
     /**
1544
-	 * Get the invoice's discount code.
1545
-	 *
1546
-	 * @since 1.0.19
1547
-	 * @param  string $context View or edit context.
1548
-	 * @return string
1549
-	 */
1550
-	public function get_discount_code( $context = 'view' ) {
1551
-		return $this->get_prop( 'discount_code', $context );
1544
+     * Get the invoice's discount code.
1545
+     *
1546
+     * @since 1.0.19
1547
+     * @param  string $context View or edit context.
1548
+     * @return string
1549
+     */
1550
+    public function get_discount_code( $context = 'view' ) {
1551
+        return $this->get_prop( 'discount_code', $context );
1552 1552
     }
1553 1553
 
1554 1554
     /**
1555
-	 * Get the invoice's gateway.
1556
-	 *
1557
-	 * @since 1.0.19
1558
-	 * @param  string $context View or edit context.
1559
-	 * @return string
1560
-	 */
1561
-	public function get_gateway( $context = 'view' ) {
1562
-		return $this->get_prop( 'gateway', $context );
1555
+     * Get the invoice's gateway.
1556
+     *
1557
+     * @since 1.0.19
1558
+     * @param  string $context View or edit context.
1559
+     * @return string
1560
+     */
1561
+    public function get_gateway( $context = 'view' ) {
1562
+        return $this->get_prop( 'gateway', $context );
1563 1563
     }
1564 1564
 
1565 1565
     /**
1566
-	 * Get the invoice's gateway display title.
1567
-	 *
1568
-	 * @since 1.0.19
1569
-	 * @return string
1570
-	 */
1566
+     * Get the invoice's gateway display title.
1567
+     *
1568
+     * @since 1.0.19
1569
+     * @return string
1570
+     */
1571 1571
     public function get_gateway_title() {
1572 1572
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1573 1573
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1574 1574
     }
1575 1575
 
1576 1576
     /**
1577
-	 * Get the invoice's transaction id.
1578
-	 *
1579
-	 * @since 1.0.19
1580
-	 * @param  string $context View or edit context.
1581
-	 * @return string
1582
-	 */
1583
-	public function get_transaction_id( $context = 'view' ) {
1584
-		return $this->get_prop( 'transaction_id', $context );
1577
+     * Get the invoice's transaction id.
1578
+     *
1579
+     * @since 1.0.19
1580
+     * @param  string $context View or edit context.
1581
+     * @return string
1582
+     */
1583
+    public function get_transaction_id( $context = 'view' ) {
1584
+        return $this->get_prop( 'transaction_id', $context );
1585 1585
     }
1586 1586
 
1587 1587
     /**
1588
-	 * Get the invoice's currency.
1589
-	 *
1590
-	 * @since 1.0.19
1591
-	 * @param  string $context View or edit context.
1592
-	 * @return string
1593
-	 */
1594
-	public function get_currency( $context = 'view' ) {
1588
+     * Get the invoice's currency.
1589
+     *
1590
+     * @since 1.0.19
1591
+     * @param  string $context View or edit context.
1592
+     * @return string
1593
+     */
1594
+    public function get_currency( $context = 'view' ) {
1595 1595
         $currency = $this->get_prop( 'currency', $context );
1596 1596
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1597 1597
     }
1598 1598
 
1599 1599
     /**
1600
-	 * Checks if we are charging taxes for this invoice.
1601
-	 *
1602
-	 * @since 1.0.19
1603
-	 * @param  string $context View or edit context.
1604
-	 * @return bool
1605
-	 */
1606
-	public function get_disable_taxes( $context = 'view' ) {
1600
+     * Checks if we are charging taxes for this invoice.
1601
+     *
1602
+     * @since 1.0.19
1603
+     * @param  string $context View or edit context.
1604
+     * @return bool
1605
+     */
1606
+    public function get_disable_taxes( $context = 'view' ) {
1607 1607
         return (bool) $this->get_prop( 'disable_taxes', $context );
1608 1608
     }
1609 1609
 
1610 1610
     /**
1611
-	 * Retrieves the remote subscription id for an invoice.
1612
-	 *
1613
-	 * @since 1.0.19
1614
-	 * @param  string $context View or edit context.
1615
-	 * @return int
1616
-	 */
1611
+     * Retrieves the remote subscription id for an invoice.
1612
+     *
1613
+     * @since 1.0.19
1614
+     * @param  string $context View or edit context.
1615
+     * @return int
1616
+     */
1617 1617
     public function get_subscription_id( $context = 'view' ) {
1618 1618
         $subscription_id = $this->get_prop( 'subscription_id', $context );
1619 1619
 
@@ -1626,12 +1626,12 @@  discard block
 block discarded – undo
1626 1626
     }
1627 1627
 
1628 1628
     /**
1629
-	 * Retrieves the payment meta for an invoice.
1630
-	 *
1631
-	 * @since 1.0.19
1632
-	 * @param  string $context View or edit context.
1633
-	 * @return array
1634
-	 */
1629
+     * Retrieves the payment meta for an invoice.
1630
+     *
1631
+     * @since 1.0.19
1632
+     * @param  string $context View or edit context.
1633
+     * @return array
1634
+     */
1635 1635
     public function get_payment_meta( $context = 'view' ) {
1636 1636
 
1637 1637
         return array(
@@ -1651,11 +1651,11 @@  discard block
 block discarded – undo
1651 1651
     }
1652 1652
 
1653 1653
     /**
1654
-	 * Retrieves the cart details for an invoice.
1655
-	 *
1656
-	 * @since 1.0.19
1657
-	 * @return array
1658
-	 */
1654
+     * Retrieves the cart details for an invoice.
1655
+     *
1656
+     * @since 1.0.19
1657
+     * @return array
1658
+     */
1659 1659
     public function get_cart_details() {
1660 1660
         $items        = $this->get_items();
1661 1661
         $cart_details = array();
@@ -1665,16 +1665,16 @@  discard block
 block discarded – undo
1665 1665
         }
1666 1666
 
1667 1667
         return $cart_details;
1668
-	}
1668
+    }
1669 1669
 
1670
-	/**
1671
-	 * Retrieves the recurring item.
1672
-	 *
1673
-	 * @return null|GetPaid_Form_Item|int
1674
-	 */
1675
-	public function get_recurring( $object = false ) {
1670
+    /**
1671
+     * Retrieves the recurring item.
1672
+     *
1673
+     * @return null|GetPaid_Form_Item|int
1674
+     */
1675
+    public function get_recurring( $object = false ) {
1676 1676
 
1677
-		// Are we returning an object?
1677
+        // Are we returning an object?
1678 1678
         if ( $object ) {
1679 1679
             return $this->get_item( $this->recurring_item );
1680 1680
         }
@@ -1682,100 +1682,100 @@  discard block
 block discarded – undo
1682 1682
         return $this->recurring_item;
1683 1683
     }
1684 1684
 
1685
-	/**
1686
-	 * Retrieves the subscription name.
1687
-	 *
1688
-	 * @since 1.0.19
1689
-	 * @return string
1690
-	 */
1691
-	public function get_subscription_name() {
1685
+    /**
1686
+     * Retrieves the subscription name.
1687
+     *
1688
+     * @since 1.0.19
1689
+     * @return string
1690
+     */
1691
+    public function get_subscription_name() {
1692 1692
 
1693
-		// Retrieve the recurring name
1693
+        // Retrieve the recurring name
1694 1694
         $item = $this->get_recurring( true );
1695 1695
 
1696
-		// Abort if it does not exist.
1696
+        // Abort if it does not exist.
1697 1697
         if ( empty( $item ) ) {
1698 1698
             return '';
1699 1699
         }
1700 1700
 
1701
-		// Return the item name.
1701
+        // Return the item name.
1702 1702
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1703
-	}
1704
-
1705
-	/**
1706
-	 * Retrieves the view url.
1707
-	 *
1708
-	 * @since 1.0.19
1709
-	 * @return string
1710
-	 */
1711
-	public function get_view_url() {
1703
+    }
1704
+
1705
+    /**
1706
+     * Retrieves the view url.
1707
+     *
1708
+     * @since 1.0.19
1709
+     * @return string
1710
+     */
1711
+    public function get_view_url() {
1712 1712
         $invoice_url = get_permalink( $this->get_id() );
1713
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1713
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1714 1714
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1715
-	}
1715
+    }
1716 1716
 
1717
-	/**
1718
-	 * Retrieves the payment url.
1719
-	 *
1720
-	 * @since 1.0.19
1721
-	 * @return string
1722
-	 */
1723
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1717
+    /**
1718
+     * Retrieves the payment url.
1719
+     *
1720
+     * @since 1.0.19
1721
+     * @return string
1722
+     */
1723
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1724 1724
 
1725
-		// Retrieve the checkout url.
1725
+        // Retrieve the checkout url.
1726 1726
         $pay_url = wpinv_get_checkout_uri();
1727 1727
 
1728
-		// Maybe force ssl.
1728
+        // Maybe force ssl.
1729 1729
         if ( is_ssl() ) {
1730 1730
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1731 1731
         }
1732 1732
 
1733
-		// Add the invoice key.
1734
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1733
+        // Add the invoice key.
1734
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1735 1735
 
1736
-		// (Maybe?) add a secret
1736
+        // (Maybe?) add a secret
1737 1737
         if ( $secret ) {
1738 1738
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1739 1739
         }
1740 1740
 
1741 1741
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1742
-	}
1742
+    }
1743 1743
 	
1744
-	/**
1745
-	 * Retrieves the receipt url.
1746
-	 *
1747
-	 * @since 1.0.19
1748
-	 * @return string
1749
-	 */
1750
-	public function get_receipt_url() {
1751
-
1752
-		// Retrieve the checkout url.
1744
+    /**
1745
+     * Retrieves the receipt url.
1746
+     *
1747
+     * @since 1.0.19
1748
+     * @return string
1749
+     */
1750
+    public function get_receipt_url() {
1751
+
1752
+        // Retrieve the checkout url.
1753 1753
         $receipt_url = wpinv_get_success_page_uri();
1754 1754
 
1755
-		// Maybe force ssl.
1755
+        // Maybe force ssl.
1756 1756
         if ( is_ssl() ) {
1757 1757
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1758 1758
         }
1759 1759
 
1760
-		// Add the invoice key.
1761
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1760
+        // Add the invoice key.
1761
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1762 1762
 
1763 1763
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1764 1764
     }
1765 1765
 
1766 1766
     /**
1767
-	 * Magic method for accessing invoice properties.
1768
-	 *
1769
-	 * @since 1.0.15
1770
-	 * @access public
1771
-	 *
1772
-	 * @param string $key Discount data to retrieve
1773
-	 * @param  string $context View or edit context.
1774
-	 * @return mixed Value of the given invoice property (if set).
1775
-	 */
1776
-	public function get( $key, $context = 'view' ) {
1767
+     * Magic method for accessing invoice properties.
1768
+     *
1769
+     * @since 1.0.15
1770
+     * @access public
1771
+     *
1772
+     * @param string $key Discount data to retrieve
1773
+     * @param  string $context View or edit context.
1774
+     * @return mixed Value of the given invoice property (if set).
1775
+     */
1776
+    public function get( $key, $context = 'view' ) {
1777 1777
         return $this->get_prop( $key, $context );
1778
-	}
1778
+    }
1779 1779
 
1780 1780
     /*
1781 1781
 	|--------------------------------------------------------------------------
@@ -1788,131 +1788,131 @@  discard block
 block discarded – undo
1788 1788
     */
1789 1789
 
1790 1790
     /**
1791
-	 * Magic method for setting invoice properties.
1792
-	 *
1793
-	 * @since 1.0.19
1794
-	 * @access public
1795
-	 *
1796
-	 * @param string $key Discount data to retrieve
1797
-	 * @param  mixed $value new value.
1798
-	 * @return mixed Value of the given invoice property (if set).
1799
-	 */
1800
-	public function set( $key, $value ) {
1791
+     * Magic method for setting invoice properties.
1792
+     *
1793
+     * @since 1.0.19
1794
+     * @access public
1795
+     *
1796
+     * @param string $key Discount data to retrieve
1797
+     * @param  mixed $value new value.
1798
+     * @return mixed Value of the given invoice property (if set).
1799
+     */
1800
+    public function set( $key, $value ) {
1801 1801
 
1802 1802
         $setter = "set_$key";
1803 1803
         if ( is_callable( array( $this, $setter ) ) ) {
1804 1804
             $this->{$setter}( $value );
1805 1805
         }
1806 1806
 
1807
-	}
1807
+    }
1808 1808
 
1809
-	/**
1810
-	 * Sets item status.
1811
-	 *
1812
-	 * @since 1.0.19
1813
-	 * @param string $new_status    New status.
1814
-	 * @param string $note          Optional note to add.
1815
-	 * @param bool   $manual_update Is this a manual status change?.
1816
-	 * @return array details of change.
1817
-	 */
1818
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1819
-		$old_status = $this->get_status();
1809
+    /**
1810
+     * Sets item status.
1811
+     *
1812
+     * @since 1.0.19
1813
+     * @param string $new_status    New status.
1814
+     * @param string $note          Optional note to add.
1815
+     * @param bool   $manual_update Is this a manual status change?.
1816
+     * @return array details of change.
1817
+     */
1818
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1819
+        $old_status = $this->get_status();
1820 1820
 
1821
-		$statuses = $this->get_all_statuses();
1821
+        $statuses = $this->get_all_statuses();
1822 1822
 
1823
-		if ( isset( $statuses[ 'draft' ] ) ) {
1824
-			unset( $statuses[ 'draft' ] );
1825
-		}
1823
+        if ( isset( $statuses[ 'draft' ] ) ) {
1824
+            unset( $statuses[ 'draft' ] );
1825
+        }
1826 1826
 
1827 1827
 
1828
-		$this->set_prop( 'status', $new_status );
1828
+        $this->set_prop( 'status', $new_status );
1829 1829
 
1830
-		// If setting the status, ensure it's set to a valid status.
1831
-		if ( true === $this->object_read ) {
1830
+        // If setting the status, ensure it's set to a valid status.
1831
+        if ( true === $this->object_read ) {
1832 1832
 
1833
-			// Only allow valid new status.
1834
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1835
-				$new_status = 'wpi-pending';
1836
-			}
1833
+            // Only allow valid new status.
1834
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1835
+                $new_status = 'wpi-pending';
1836
+            }
1837 1837
 
1838
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1839
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1840
-				$old_status = 'wpi-pending';
1841
-			}
1838
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1839
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1840
+                $old_status = 'wpi-pending';
1841
+            }
1842 1842
 
1843
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1844
-			if ( $new_status == 'wpi-renewal' && $old_status == 'publish' ) {
1845
-				$old_status = 'wpi-pending';
1846
-			}
1843
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1844
+            if ( $new_status == 'wpi-renewal' && $old_status == 'publish' ) {
1845
+                $old_status = 'wpi-pending';
1846
+            }
1847 1847
 
1848
-		}
1848
+        }
1849 1849
 
1850
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1851
-			$this->status_transition = array(
1852
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1853
-				'to'     => $new_status,
1854
-				'note'   => $note,
1855
-				'manual' => (bool) $manual_update,
1856
-			);
1850
+        if ( true === $this->object_read && $old_status !== $new_status ) {
1851
+            $this->status_transition = array(
1852
+                'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1853
+                'to'     => $new_status,
1854
+                'note'   => $note,
1855
+                'manual' => (bool) $manual_update,
1856
+            );
1857 1857
 
1858
-			if ( $manual_update ) {
1859
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1860
-			}
1858
+            if ( $manual_update ) {
1859
+                do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1860
+            }
1861 1861
 
1862
-			$this->maybe_set_date_paid();
1862
+            $this->maybe_set_date_paid();
1863 1863
 
1864
-		}
1864
+        }
1865 1865
 
1866
-		return array(
1867
-			'from' => $old_status,
1868
-			'to'   => $new_status,
1869
-		);
1870
-	}
1866
+        return array(
1867
+            'from' => $old_status,
1868
+            'to'   => $new_status,
1869
+        );
1870
+    }
1871 1871
 
1872
-	/**
1873
-	 * Maybe set date paid.
1874
-	 *
1875
-	 * Sets the date paid variable when transitioning to the payment complete
1876
-	 * order status.
1877
-	 *
1878
-	 * @since 1.0.19
1879
-	 */
1880
-	public function maybe_set_date_paid() {
1872
+    /**
1873
+     * Maybe set date paid.
1874
+     *
1875
+     * Sets the date paid variable when transitioning to the payment complete
1876
+     * order status.
1877
+     *
1878
+     * @since 1.0.19
1879
+     */
1880
+    public function maybe_set_date_paid() {
1881 1881
 
1882
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1883
-			$this->set_date_completed( current_time( 'mysql' ) );
1884
-		}
1885
-	}
1882
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1883
+            $this->set_date_completed( current_time( 'mysql' ) );
1884
+        }
1885
+    }
1886 1886
 
1887 1887
     /**
1888
-	 * Set parent invoice ID.
1889
-	 *
1890
-	 * @since 1.0.19
1891
-	 */
1892
-	public function set_parent_id( $value ) {
1893
-		if ( $value && ( $value === $this->get_id() ) ) {
1894
-			return;
1895
-		}
1896
-		$this->set_prop( 'parent_id', absint( $value ) );
1888
+     * Set parent invoice ID.
1889
+     *
1890
+     * @since 1.0.19
1891
+     */
1892
+    public function set_parent_id( $value ) {
1893
+        if ( $value && ( $value === $this->get_id() ) ) {
1894
+            return;
1895
+        }
1896
+        $this->set_prop( 'parent_id', absint( $value ) );
1897 1897
     }
1898 1898
 
1899 1899
     /**
1900
-	 * Set plugin version when the invoice was created.
1901
-	 *
1902
-	 * @since 1.0.19
1903
-	 */
1904
-	public function set_version( $value ) {
1905
-		$this->set_prop( 'version', $value );
1900
+     * Set plugin version when the invoice was created.
1901
+     *
1902
+     * @since 1.0.19
1903
+     */
1904
+    public function set_version( $value ) {
1905
+        $this->set_prop( 'version', $value );
1906 1906
     }
1907
-
1908
-    /**
1909
-	 * Set date when the invoice was created.
1910
-	 *
1911
-	 * @since 1.0.19
1912
-	 * @param string $value Value to set.
1907
+
1908
+    /**
1909
+     * Set date when the invoice was created.
1910
+     *
1911
+     * @since 1.0.19
1912
+     * @param string $value Value to set.
1913 1913
      * @return bool Whether or not the date was set.
1914
-	 */
1915
-	public function set_date_created( $value ) {
1914
+     */
1915
+    public function set_date_created( $value ) {
1916 1916
         $date = strtotime( $value );
1917 1917
 
1918 1918
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1925,13 +1925,13 @@  discard block
 block discarded – undo
1925 1925
     }
1926 1926
 
1927 1927
     /**
1928
-	 * Set date invoice due date.
1929
-	 *
1930
-	 * @since 1.0.19
1931
-	 * @param string $value Value to set.
1928
+     * Set date invoice due date.
1929
+     *
1930
+     * @since 1.0.19
1931
+     * @param string $value Value to set.
1932 1932
      * @return bool Whether or not the date was set.
1933
-	 */
1934
-	public function set_due_date( $value ) {
1933
+     */
1934
+    public function set_due_date( $value ) {
1935 1935
         $date = strtotime( $value );
1936 1936
 
1937 1937
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1939,29 +1939,29 @@  discard block
 block discarded – undo
1939 1939
             return true;
1940 1940
         }
1941 1941
 
1942
-		$this->set_prop( 'due_date', '' );
1942
+        $this->set_prop( 'due_date', '' );
1943 1943
         return false;
1944 1944
 
1945 1945
     }
1946 1946
 
1947 1947
     /**
1948
-	 * Alias of self::set_due_date().
1949
-	 *
1950
-	 * @since 1.0.19
1951
-	 * @param  string $value New name.
1952
-	 */
1953
-	public function set_date_due( $value ) {
1954
-		$this->set_due_date( $value );
1948
+     * Alias of self::set_due_date().
1949
+     *
1950
+     * @since 1.0.19
1951
+     * @param  string $value New name.
1952
+     */
1953
+    public function set_date_due( $value ) {
1954
+        $this->set_due_date( $value );
1955 1955
     }
1956 1956
 
1957 1957
     /**
1958
-	 * Set date invoice was completed.
1959
-	 *
1960
-	 * @since 1.0.19
1961
-	 * @param string $value Value to set.
1958
+     * Set date invoice was completed.
1959
+     *
1960
+     * @since 1.0.19
1961
+     * @param string $value Value to set.
1962 1962
      * @return bool Whether or not the date was set.
1963
-	 */
1964
-	public function set_completed_date( $value ) {
1963
+     */
1964
+    public function set_completed_date( $value ) {
1965 1965
         $date = strtotime( $value );
1966 1966
 
1967 1967
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -1969,29 +1969,29 @@  discard block
 block discarded – undo
1969 1969
             return true;
1970 1970
         }
1971 1971
 
1972
-		$this->set_prop( 'completed_date', '' );
1972
+        $this->set_prop( 'completed_date', '' );
1973 1973
         return false;
1974 1974
 
1975 1975
     }
1976 1976
 
1977 1977
     /**
1978
-	 * Alias of self::set_completed_date().
1979
-	 *
1980
-	 * @since 1.0.19
1981
-	 * @param  string $value New name.
1982
-	 */
1983
-	public function set_date_completed( $value ) {
1984
-		$this->set_completed_date( $value );
1978
+     * Alias of self::set_completed_date().
1979
+     *
1980
+     * @since 1.0.19
1981
+     * @param  string $value New name.
1982
+     */
1983
+    public function set_date_completed( $value ) {
1984
+        $this->set_completed_date( $value );
1985 1985
     }
1986 1986
 
1987 1987
     /**
1988
-	 * Set date when the invoice was last modified.
1989
-	 *
1990
-	 * @since 1.0.19
1991
-	 * @param string $value Value to set.
1988
+     * Set date when the invoice was last modified.
1989
+     *
1990
+     * @since 1.0.19
1991
+     * @param string $value Value to set.
1992 1992
      * @return bool Whether or not the date was set.
1993
-	 */
1994
-	public function set_date_modified( $value ) {
1993
+     */
1994
+    public function set_date_modified( $value ) {
1995 1995
         $date = strtotime( $value );
1996 1996
 
1997 1997
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1999,706 +1999,706 @@  discard block
 block discarded – undo
1999 1999
             return true;
2000 2000
         }
2001 2001
 
2002
-		$this->set_prop( 'date_modified', '' );
2002
+        $this->set_prop( 'date_modified', '' );
2003 2003
         return false;
2004 2004
 
2005 2005
     }
2006 2006
 
2007 2007
     /**
2008
-	 * Set the invoice number.
2009
-	 *
2010
-	 * @since 1.0.19
2011
-	 * @param  string $value New number.
2012
-	 */
2013
-	public function set_number( $value ) {
2008
+     * Set the invoice number.
2009
+     *
2010
+     * @since 1.0.19
2011
+     * @param  string $value New number.
2012
+     */
2013
+    public function set_number( $value ) {
2014 2014
         $number = sanitize_text_field( $value );
2015
-		$this->set_prop( 'number', $number );
2015
+        $this->set_prop( 'number', $number );
2016 2016
     }
2017 2017
 
2018 2018
     /**
2019
-	 * Set the invoice type.
2020
-	 *
2021
-	 * @since 1.0.19
2022
-	 * @param  string $value Type.
2023
-	 */
2024
-	public function set_type( $value ) {
2019
+     * Set the invoice type.
2020
+     *
2021
+     * @since 1.0.19
2022
+     * @param  string $value Type.
2023
+     */
2024
+    public function set_type( $value ) {
2025 2025
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2026
-		$this->set_prop( 'type', $type );
2027
-	}
2026
+        $this->set_prop( 'type', $type );
2027
+    }
2028 2028
 
2029 2029
     /**
2030
-	 * Set the invoice post type.
2031
-	 *
2032
-	 * @since 1.0.19
2033
-	 * @param  string $value Post type.
2034
-	 */
2035
-	public function set_post_type( $value ) {
2030
+     * Set the invoice post type.
2031
+     *
2032
+     * @since 1.0.19
2033
+     * @param  string $value Post type.
2034
+     */
2035
+    public function set_post_type( $value ) {
2036 2036
         if ( getpaid_is_invoice_post_type( $value ) ) {
2037
-			$this->set_type( $value );
2037
+            $this->set_type( $value );
2038 2038
             $this->set_prop( 'post_type', $value );
2039 2039
         }
2040 2040
     }
2041 2041
 
2042 2042
     /**
2043
-	 * Set the invoice key.
2044
-	 *
2045
-	 * @since 1.0.19
2046
-	 * @param  string $value New key.
2047
-	 */
2048
-	public function set_key( $value ) {
2043
+     * Set the invoice key.
2044
+     *
2045
+     * @since 1.0.19
2046
+     * @param  string $value New key.
2047
+     */
2048
+    public function set_key( $value ) {
2049 2049
         $key = sanitize_text_field( $value );
2050
-		$this->set_prop( 'key', $key );
2050
+        $this->set_prop( 'key', $key );
2051 2051
     }
2052 2052
 
2053 2053
     /**
2054
-	 * Set the invoice mode.
2055
-	 *
2056
-	 * @since 1.0.19
2057
-	 * @param  string $value mode.
2058
-	 */
2059
-	public function set_mode( $value ) {
2054
+     * Set the invoice mode.
2055
+     *
2056
+     * @since 1.0.19
2057
+     * @param  string $value mode.
2058
+     */
2059
+    public function set_mode( $value ) {
2060 2060
         if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2061 2061
             $this->set_prop( 'value', $value );
2062 2062
         }
2063 2063
     }
2064 2064
 
2065 2065
     /**
2066
-	 * Set the invoice path.
2067
-	 *
2068
-	 * @since 1.0.19
2069
-	 * @param  string $value path.
2070
-	 */
2071
-	public function set_path( $value ) {
2066
+     * Set the invoice path.
2067
+     *
2068
+     * @since 1.0.19
2069
+     * @param  string $value path.
2070
+     */
2071
+    public function set_path( $value ) {
2072 2072
         $this->set_prop( 'path', $value );
2073 2073
     }
2074 2074
 
2075 2075
     /**
2076
-	 * Set the invoice name.
2077
-	 *
2078
-	 * @since 1.0.19
2079
-	 * @param  string $value New name.
2080
-	 */
2081
-	public function set_name( $value ) {
2076
+     * Set the invoice name.
2077
+     *
2078
+     * @since 1.0.19
2079
+     * @param  string $value New name.
2080
+     */
2081
+    public function set_name( $value ) {
2082 2082
         $name = sanitize_text_field( $value );
2083
-		$this->set_prop( 'name', $name );
2083
+        $this->set_prop( 'name', $name );
2084 2084
     }
2085 2085
 
2086 2086
     /**
2087
-	 * Alias of self::set_name().
2088
-	 *
2089
-	 * @since 1.0.19
2090
-	 * @param  string $value New name.
2091
-	 */
2092
-	public function set_title( $value ) {
2093
-		$this->set_name( $value );
2087
+     * Alias of self::set_name().
2088
+     *
2089
+     * @since 1.0.19
2090
+     * @param  string $value New name.
2091
+     */
2092
+    public function set_title( $value ) {
2093
+        $this->set_name( $value );
2094 2094
     }
2095 2095
 
2096 2096
     /**
2097
-	 * Set the invoice description.
2098
-	 *
2099
-	 * @since 1.0.19
2100
-	 * @param  string $value New description.
2101
-	 */
2102
-	public function set_description( $value ) {
2097
+     * Set the invoice description.
2098
+     *
2099
+     * @since 1.0.19
2100
+     * @param  string $value New description.
2101
+     */
2102
+    public function set_description( $value ) {
2103 2103
         $description = wp_kses_post( $value );
2104
-		return $this->set_prop( 'description', $description );
2104
+        return $this->set_prop( 'description', $description );
2105 2105
     }
2106 2106
 
2107 2107
     /**
2108
-	 * Alias of self::set_description().
2109
-	 *
2110
-	 * @since 1.0.19
2111
-	 * @param  string $value New description.
2112
-	 */
2113
-	public function set_excerpt( $value ) {
2114
-		$this->set_description( $value );
2108
+     * Alias of self::set_description().
2109
+     *
2110
+     * @since 1.0.19
2111
+     * @param  string $value New description.
2112
+     */
2113
+    public function set_excerpt( $value ) {
2114
+        $this->set_description( $value );
2115 2115
     }
2116 2116
 
2117 2117
     /**
2118
-	 * Alias of self::set_description().
2119
-	 *
2120
-	 * @since 1.0.19
2121
-	 * @param  string $value New description.
2122
-	 */
2123
-	public function set_summary( $value ) {
2124
-		$this->set_description( $value );
2118
+     * Alias of self::set_description().
2119
+     *
2120
+     * @since 1.0.19
2121
+     * @param  string $value New description.
2122
+     */
2123
+    public function set_summary( $value ) {
2124
+        $this->set_description( $value );
2125 2125
     }
2126 2126
 
2127 2127
     /**
2128
-	 * Set the receiver of the invoice.
2129
-	 *
2130
-	 * @since 1.0.19
2131
-	 * @param  int $value New author.
2132
-	 */
2133
-	public function set_author( $value ) {
2134
-		$user = get_user_by( 'id', (int) $value );
2128
+     * Set the receiver of the invoice.
2129
+     *
2130
+     * @since 1.0.19
2131
+     * @param  int $value New author.
2132
+     */
2133
+    public function set_author( $value ) {
2134
+        $user = get_user_by( 'id', (int) $value );
2135 2135
 
2136
-		if ( $user && $user->ID ) {
2137
-			$this->set_prop( 'author', $user->ID );
2138
-			$this->set_prop( 'email', $user->user_email );
2139
-		}
2136
+        if ( $user && $user->ID ) {
2137
+            $this->set_prop( 'author', $user->ID );
2138
+            $this->set_prop( 'email', $user->user_email );
2139
+        }
2140 2140
 		
2141 2141
     }
2142 2142
 
2143 2143
     /**
2144
-	 * Alias of self::set_author().
2145
-	 *
2146
-	 * @since 1.0.19
2147
-	 * @param  int $value New user id.
2148
-	 */
2149
-	public function set_user_id( $value ) {
2150
-		$this->set_author( $value );
2144
+     * Alias of self::set_author().
2145
+     *
2146
+     * @since 1.0.19
2147
+     * @param  int $value New user id.
2148
+     */
2149
+    public function set_user_id( $value ) {
2150
+        $this->set_author( $value );
2151 2151
     }
2152 2152
 
2153 2153
     /**
2154
-	 * Alias of self::set_author().
2155
-	 *
2156
-	 * @since 1.0.19
2157
-	 * @param  int $value New user id.
2158
-	 */
2159
-	public function set_customer_id( $value ) {
2160
-		$this->set_author( $value );
2154
+     * Alias of self::set_author().
2155
+     *
2156
+     * @since 1.0.19
2157
+     * @param  int $value New user id.
2158
+     */
2159
+    public function set_customer_id( $value ) {
2160
+        $this->set_author( $value );
2161 2161
     }
2162 2162
 
2163 2163
     /**
2164
-	 * Set the customer's ip.
2165
-	 *
2166
-	 * @since 1.0.19
2167
-	 * @param  string $value ip address.
2168
-	 */
2169
-	public function set_ip( $value ) {
2170
-		$this->set_prop( 'ip', $value );
2164
+     * Set the customer's ip.
2165
+     *
2166
+     * @since 1.0.19
2167
+     * @param  string $value ip address.
2168
+     */
2169
+    public function set_ip( $value ) {
2170
+        $this->set_prop( 'ip', $value );
2171 2171
     }
2172 2172
 
2173 2173
     /**
2174
-	 * Alias of self::set_ip().
2175
-	 *
2176
-	 * @since 1.0.19
2177
-	 * @param  string $value ip address.
2178
-	 */
2179
-	public function set_user_ip( $value ) {
2180
-		$this->set_ip( $value );
2174
+     * Alias of self::set_ip().
2175
+     *
2176
+     * @since 1.0.19
2177
+     * @param  string $value ip address.
2178
+     */
2179
+    public function set_user_ip( $value ) {
2180
+        $this->set_ip( $value );
2181 2181
     }
2182 2182
 
2183 2183
     /**
2184
-	 * Set the customer's first name.
2185
-	 *
2186
-	 * @since 1.0.19
2187
-	 * @param  string $value first name.
2188
-	 */
2189
-	public function set_first_name( $value ) {
2190
-		$this->set_prop( 'first_name', $value );
2184
+     * Set the customer's first name.
2185
+     *
2186
+     * @since 1.0.19
2187
+     * @param  string $value first name.
2188
+     */
2189
+    public function set_first_name( $value ) {
2190
+        $this->set_prop( 'first_name', $value );
2191
+    }
2192
+
2193
+    /**
2194
+     * Alias of self::set_first_name().
2195
+     *
2196
+     * @since 1.0.19
2197
+     * @param  string $value first name.
2198
+     */
2199
+    public function set_user_first_name( $value ) {
2200
+        $this->set_first_name( $value );
2201
+    }
2202
+
2203
+    /**
2204
+     * Alias of self::set_first_name().
2205
+     *
2206
+     * @since 1.0.19
2207
+     * @param  string $value first name.
2208
+     */
2209
+    public function set_customer_first_name( $value ) {
2210
+        $this->set_first_name( $value );
2211
+    }
2212
+
2213
+    /**
2214
+     * Set the customer's last name.
2215
+     *
2216
+     * @since 1.0.19
2217
+     * @param  string $value last name.
2218
+     */
2219
+    public function set_last_name( $value ) {
2220
+        $this->set_prop( 'last_name', $value );
2191 2221
     }
2192 2222
 
2193 2223
     /**
2194
-	 * Alias of self::set_first_name().
2195
-	 *
2196
-	 * @since 1.0.19
2197
-	 * @param  string $value first name.
2198
-	 */
2199
-	public function set_user_first_name( $value ) {
2200
-		$this->set_first_name( $value );
2224
+     * Alias of self::set_last_name().
2225
+     *
2226
+     * @since 1.0.19
2227
+     * @param  string $value last name.
2228
+     */
2229
+    public function set_user_last_name( $value ) {
2230
+        $this->set_last_name( $value );
2201 2231
     }
2202 2232
 
2203 2233
     /**
2204
-	 * Alias of self::set_first_name().
2205
-	 *
2206
-	 * @since 1.0.19
2207
-	 * @param  string $value first name.
2208
-	 */
2209
-	public function set_customer_first_name( $value ) {
2210
-		$this->set_first_name( $value );
2234
+     * Alias of self::set_last_name().
2235
+     *
2236
+     * @since 1.0.19
2237
+     * @param  string $value last name.
2238
+     */
2239
+    public function set_customer_last_name( $value ) {
2240
+        $this->set_last_name( $value );
2211 2241
     }
2212 2242
 
2213 2243
     /**
2214
-	 * Set the customer's last name.
2215
-	 *
2216
-	 * @since 1.0.19
2217
-	 * @param  string $value last name.
2218
-	 */
2219
-	public function set_last_name( $value ) {
2220
-		$this->set_prop( 'last_name', $value );
2244
+     * Set the customer's phone number.
2245
+     *
2246
+     * @since 1.0.19
2247
+     * @param  string $value phone.
2248
+     */
2249
+    public function set_phone( $value ) {
2250
+        $this->set_prop( 'phone', $value );
2221 2251
     }
2222 2252
 
2223 2253
     /**
2224
-	 * Alias of self::set_last_name().
2225
-	 *
2226
-	 * @since 1.0.19
2227
-	 * @param  string $value last name.
2228
-	 */
2229
-	public function set_user_last_name( $value ) {
2230
-		$this->set_last_name( $value );
2254
+     * Alias of self::set_phone().
2255
+     *
2256
+     * @since 1.0.19
2257
+     * @param  string $value phone.
2258
+     */
2259
+    public function set_user_phone( $value ) {
2260
+        $this->set_phone( $value );
2231 2261
     }
2232 2262
 
2233 2263
     /**
2234
-	 * Alias of self::set_last_name().
2235
-	 *
2236
-	 * @since 1.0.19
2237
-	 * @param  string $value last name.
2238
-	 */
2239
-	public function set_customer_last_name( $value ) {
2240
-		$this->set_last_name( $value );
2264
+     * Alias of self::set_phone().
2265
+     *
2266
+     * @since 1.0.19
2267
+     * @param  string $value phone.
2268
+     */
2269
+    public function set_customer_phone( $value ) {
2270
+        $this->set_phone( $value );
2241 2271
     }
2242 2272
 
2243 2273
     /**
2244
-	 * Set the customer's phone number.
2245
-	 *
2246
-	 * @since 1.0.19
2247
-	 * @param  string $value phone.
2248
-	 */
2249
-	public function set_phone( $value ) {
2250
-		$this->set_prop( 'phone', $value );
2274
+     * Alias of self::set_phone().
2275
+     *
2276
+     * @since 1.0.19
2277
+     * @param  string $value phone.
2278
+     */
2279
+    public function set_phone_number( $value ) {
2280
+        $this->set_phone( $value );
2251 2281
     }
2252 2282
 
2253 2283
     /**
2254
-	 * Alias of self::set_phone().
2255
-	 *
2256
-	 * @since 1.0.19
2257
-	 * @param  string $value phone.
2258
-	 */
2259
-	public function set_user_phone( $value ) {
2260
-		$this->set_phone( $value );
2284
+     * Set the customer's email address.
2285
+     *
2286
+     * @since 1.0.19
2287
+     * @param  string $value email address.
2288
+     */
2289
+    public function set_email( $value ) {
2290
+        $this->set_prop( 'email', $value );
2261 2291
     }
2262 2292
 
2263 2293
     /**
2264
-	 * Alias of self::set_phone().
2265
-	 *
2266
-	 * @since 1.0.19
2267
-	 * @param  string $value phone.
2268
-	 */
2269
-	public function set_customer_phone( $value ) {
2270
-		$this->set_phone( $value );
2294
+     * Alias of self::set_email().
2295
+     *
2296
+     * @since 1.0.19
2297
+     * @param  string $value email address.
2298
+     */
2299
+    public function set_user_email( $value ) {
2300
+        $this->set_email( $value );
2271 2301
     }
2272 2302
 
2273 2303
     /**
2274
-	 * Alias of self::set_phone().
2275
-	 *
2276
-	 * @since 1.0.19
2277
-	 * @param  string $value phone.
2278
-	 */
2279
-	public function set_phone_number( $value ) {
2280
-		$this->set_phone( $value );
2304
+     * Alias of self::set_email().
2305
+     *
2306
+     * @since 1.0.19
2307
+     * @param  string $value email address.
2308
+     */
2309
+    public function set_email_address( $value ) {
2310
+        $this->set_email( $value );
2281 2311
     }
2282 2312
 
2283 2313
     /**
2284
-	 * Set the customer's email address.
2285
-	 *
2286
-	 * @since 1.0.19
2287
-	 * @param  string $value email address.
2288
-	 */
2289
-	public function set_email( $value ) {
2290
-		$this->set_prop( 'email', $value );
2314
+     * Alias of self::set_email().
2315
+     *
2316
+     * @since 1.0.19
2317
+     * @param  string $value email address.
2318
+     */
2319
+    public function set_customer_email( $value ) {
2320
+        $this->set_email( $value );
2291 2321
     }
2292 2322
 
2293 2323
     /**
2294
-	 * Alias of self::set_email().
2295
-	 *
2296
-	 * @since 1.0.19
2297
-	 * @param  string $value email address.
2298
-	 */
2299
-	public function set_user_email( $value ) {
2300
-		$this->set_email( $value );
2324
+     * Set the customer's country.
2325
+     *
2326
+     * @since 1.0.19
2327
+     * @param  string $value country.
2328
+     */
2329
+    public function set_country( $value ) {
2330
+        $this->set_prop( 'country', $value );
2301 2331
     }
2302 2332
 
2303 2333
     /**
2304
-	 * Alias of self::set_email().
2305
-	 *
2306
-	 * @since 1.0.19
2307
-	 * @param  string $value email address.
2308
-	 */
2309
-	public function set_email_address( $value ) {
2310
-		$this->set_email( $value );
2334
+     * Alias of self::set_country().
2335
+     *
2336
+     * @since 1.0.19
2337
+     * @param  string $value country.
2338
+     */
2339
+    public function set_user_country( $value ) {
2340
+        $this->set_country( $value );
2311 2341
     }
2312 2342
 
2313 2343
     /**
2314
-	 * Alias of self::set_email().
2315
-	 *
2316
-	 * @since 1.0.19
2317
-	 * @param  string $value email address.
2318
-	 */
2319
-	public function set_customer_email( $value ) {
2320
-		$this->set_email( $value );
2344
+     * Alias of self::set_country().
2345
+     *
2346
+     * @since 1.0.19
2347
+     * @param  string $value country.
2348
+     */
2349
+    public function set_customer_country( $value ) {
2350
+        $this->set_country( $value );
2321 2351
     }
2322 2352
 
2323 2353
     /**
2324
-	 * Set the customer's country.
2325
-	 *
2326
-	 * @since 1.0.19
2327
-	 * @param  string $value country.
2328
-	 */
2329
-	public function set_country( $value ) {
2330
-		$this->set_prop( 'country', $value );
2354
+     * Set the customer's state.
2355
+     *
2356
+     * @since 1.0.19
2357
+     * @param  string $value state.
2358
+     */
2359
+    public function set_state( $value ) {
2360
+        $this->set_prop( 'state', $value );
2331 2361
     }
2332 2362
 
2333 2363
     /**
2334
-	 * Alias of self::set_country().
2335
-	 *
2336
-	 * @since 1.0.19
2337
-	 * @param  string $value country.
2338
-	 */
2339
-	public function set_user_country( $value ) {
2340
-		$this->set_country( $value );
2364
+     * Alias of self::set_state().
2365
+     *
2366
+     * @since 1.0.19
2367
+     * @param  string $value state.
2368
+     */
2369
+    public function set_user_state( $value ) {
2370
+        $this->set_state( $value );
2341 2371
     }
2342 2372
 
2343 2373
     /**
2344
-	 * Alias of self::set_country().
2345
-	 *
2346
-	 * @since 1.0.19
2347
-	 * @param  string $value country.
2348
-	 */
2349
-	public function set_customer_country( $value ) {
2350
-		$this->set_country( $value );
2374
+     * Alias of self::set_state().
2375
+     *
2376
+     * @since 1.0.19
2377
+     * @param  string $value state.
2378
+     */
2379
+    public function set_customer_state( $value ) {
2380
+        $this->set_state( $value );
2351 2381
     }
2352 2382
 
2353 2383
     /**
2354
-	 * Set the customer's state.
2355
-	 *
2356
-	 * @since 1.0.19
2357
-	 * @param  string $value state.
2358
-	 */
2359
-	public function set_state( $value ) {
2360
-		$this->set_prop( 'state', $value );
2384
+     * Set the customer's city.
2385
+     *
2386
+     * @since 1.0.19
2387
+     * @param  string $value city.
2388
+     */
2389
+    public function set_city( $value ) {
2390
+        $this->set_prop( 'city', $value );
2361 2391
     }
2362 2392
 
2363 2393
     /**
2364
-	 * Alias of self::set_state().
2365
-	 *
2366
-	 * @since 1.0.19
2367
-	 * @param  string $value state.
2368
-	 */
2369
-	public function set_user_state( $value ) {
2370
-		$this->set_state( $value );
2394
+     * Alias of self::set_city().
2395
+     *
2396
+     * @since 1.0.19
2397
+     * @param  string $value city.
2398
+     */
2399
+    public function set_user_city( $value ) {
2400
+        $this->set_city( $value );
2371 2401
     }
2372 2402
 
2373 2403
     /**
2374
-	 * Alias of self::set_state().
2375
-	 *
2376
-	 * @since 1.0.19
2377
-	 * @param  string $value state.
2378
-	 */
2379
-	public function set_customer_state( $value ) {
2380
-		$this->set_state( $value );
2404
+     * Alias of self::set_city().
2405
+     *
2406
+     * @since 1.0.19
2407
+     * @param  string $value city.
2408
+     */
2409
+    public function set_customer_city( $value ) {
2410
+        $this->set_city( $value );
2381 2411
     }
2382 2412
 
2383 2413
     /**
2384
-	 * Set the customer's city.
2385
-	 *
2386
-	 * @since 1.0.19
2387
-	 * @param  string $value city.
2388
-	 */
2389
-	public function set_city( $value ) {
2390
-		$this->set_prop( 'city', $value );
2414
+     * Set the customer's zip code.
2415
+     *
2416
+     * @since 1.0.19
2417
+     * @param  string $value zip.
2418
+     */
2419
+    public function set_zip( $value ) {
2420
+        $this->set_prop( 'zip', $value );
2391 2421
     }
2392 2422
 
2393 2423
     /**
2394
-	 * Alias of self::set_city().
2395
-	 *
2396
-	 * @since 1.0.19
2397
-	 * @param  string $value city.
2398
-	 */
2399
-	public function set_user_city( $value ) {
2400
-		$this->set_city( $value );
2424
+     * Alias of self::set_zip().
2425
+     *
2426
+     * @since 1.0.19
2427
+     * @param  string $value zip.
2428
+     */
2429
+    public function set_user_zip( $value ) {
2430
+        $this->set_zip( $value );
2401 2431
     }
2402 2432
 
2403 2433
     /**
2404
-	 * Alias of self::set_city().
2405
-	 *
2406
-	 * @since 1.0.19
2407
-	 * @param  string $value city.
2408
-	 */
2409
-	public function set_customer_city( $value ) {
2410
-		$this->set_city( $value );
2434
+     * Alias of self::set_zip().
2435
+     *
2436
+     * @since 1.0.19
2437
+     * @param  string $value zip.
2438
+     */
2439
+    public function set_customer_zip( $value ) {
2440
+        $this->set_zip( $value );
2411 2441
     }
2412 2442
 
2413 2443
     /**
2414
-	 * Set the customer's zip code.
2415
-	 *
2416
-	 * @since 1.0.19
2417
-	 * @param  string $value zip.
2418
-	 */
2419
-	public function set_zip( $value ) {
2420
-		$this->set_prop( 'zip', $value );
2444
+     * Set the customer's company.
2445
+     *
2446
+     * @since 1.0.19
2447
+     * @param  string $value company.
2448
+     */
2449
+    public function set_company( $value ) {
2450
+        $this->set_prop( 'company', $value );
2421 2451
     }
2422 2452
 
2423 2453
     /**
2424
-	 * Alias of self::set_zip().
2425
-	 *
2426
-	 * @since 1.0.19
2427
-	 * @param  string $value zip.
2428
-	 */
2429
-	public function set_user_zip( $value ) {
2430
-		$this->set_zip( $value );
2454
+     * Alias of self::set_company().
2455
+     *
2456
+     * @since 1.0.19
2457
+     * @param  string $value company.
2458
+     */
2459
+    public function set_user_company( $value ) {
2460
+        $this->set_company( $value );
2431 2461
     }
2432 2462
 
2433 2463
     /**
2434
-	 * Alias of self::set_zip().
2435
-	 *
2436
-	 * @since 1.0.19
2437
-	 * @param  string $value zip.
2438
-	 */
2439
-	public function set_customer_zip( $value ) {
2440
-		$this->set_zip( $value );
2464
+     * Alias of self::set_company().
2465
+     *
2466
+     * @since 1.0.19
2467
+     * @param  string $value company.
2468
+     */
2469
+    public function set_customer_company( $value ) {
2470
+        $this->set_company( $value );
2441 2471
     }
2442 2472
 
2443 2473
     /**
2444
-	 * Set the customer's company.
2445
-	 *
2446
-	 * @since 1.0.19
2447
-	 * @param  string $value company.
2448
-	 */
2449
-	public function set_company( $value ) {
2450
-		$this->set_prop( 'company', $value );
2474
+     * Set the customer's var number.
2475
+     *
2476
+     * @since 1.0.19
2477
+     * @param  string $value var number.
2478
+     */
2479
+    public function set_vat_number( $value ) {
2480
+        $this->set_prop( 'vat_number', $value );
2451 2481
     }
2452 2482
 
2453 2483
     /**
2454
-	 * Alias of self::set_company().
2455
-	 *
2456
-	 * @since 1.0.19
2457
-	 * @param  string $value company.
2458
-	 */
2459
-	public function set_user_company( $value ) {
2460
-		$this->set_company( $value );
2484
+     * Alias of self::set_vat_number().
2485
+     *
2486
+     * @since 1.0.19
2487
+     * @param  string $value var number.
2488
+     */
2489
+    public function set_user_vat_number( $value ) {
2490
+        $this->set_vat_number( $value );
2461 2491
     }
2462 2492
 
2463 2493
     /**
2464
-	 * Alias of self::set_company().
2465
-	 *
2466
-	 * @since 1.0.19
2467
-	 * @param  string $value company.
2468
-	 */
2469
-	public function set_customer_company( $value ) {
2470
-		$this->set_company( $value );
2494
+     * Alias of self::set_vat_number().
2495
+     *
2496
+     * @since 1.0.19
2497
+     * @param  string $value var number.
2498
+     */
2499
+    public function set_customer_vat_number( $value ) {
2500
+        $this->set_vat_number( $value );
2471 2501
     }
2472 2502
 
2473 2503
     /**
2474
-	 * Set the customer's var number.
2475
-	 *
2476
-	 * @since 1.0.19
2477
-	 * @param  string $value var number.
2478
-	 */
2479
-	public function set_vat_number( $value ) {
2480
-		$this->set_prop( 'vat_number', $value );
2504
+     * Set the customer's vat rate.
2505
+     *
2506
+     * @since 1.0.19
2507
+     * @param  string $value var rate.
2508
+     */
2509
+    public function set_vat_rate( $value ) {
2510
+        $this->set_prop( 'vat_rate', $value );
2481 2511
     }
2482 2512
 
2483 2513
     /**
2484
-	 * Alias of self::set_vat_number().
2485
-	 *
2486
-	 * @since 1.0.19
2487
-	 * @param  string $value var number.
2488
-	 */
2489
-	public function set_user_vat_number( $value ) {
2490
-		$this->set_vat_number( $value );
2514
+     * Alias of self::set_vat_rate().
2515
+     *
2516
+     * @since 1.0.19
2517
+     * @param  string $value var number.
2518
+     */
2519
+    public function set_user_vat_rate( $value ) {
2520
+        $this->set_vat_rate( $value );
2491 2521
     }
2492 2522
 
2493 2523
     /**
2494
-	 * Alias of self::set_vat_number().
2495
-	 *
2496
-	 * @since 1.0.19
2497
-	 * @param  string $value var number.
2498
-	 */
2499
-	public function set_customer_vat_number( $value ) {
2500
-		$this->set_vat_number( $value );
2524
+     * Alias of self::set_vat_rate().
2525
+     *
2526
+     * @since 1.0.19
2527
+     * @param  string $value var number.
2528
+     */
2529
+    public function set_customer_vat_rate( $value ) {
2530
+        $this->set_vat_rate( $value );
2501 2531
     }
2502 2532
 
2503 2533
     /**
2504
-	 * Set the customer's vat rate.
2505
-	 *
2506
-	 * @since 1.0.19
2507
-	 * @param  string $value var rate.
2508
-	 */
2509
-	public function set_vat_rate( $value ) {
2510
-		$this->set_prop( 'vat_rate', $value );
2534
+     * Set the customer's address.
2535
+     *
2536
+     * @since 1.0.19
2537
+     * @param  string $value address.
2538
+     */
2539
+    public function set_address( $value ) {
2540
+        $this->set_prop( 'address', $value );
2511 2541
     }
2512 2542
 
2513 2543
     /**
2514
-	 * Alias of self::set_vat_rate().
2515
-	 *
2516
-	 * @since 1.0.19
2517
-	 * @param  string $value var number.
2518
-	 */
2519
-	public function set_user_vat_rate( $value ) {
2520
-		$this->set_vat_rate( $value );
2544
+     * Alias of self::set_address().
2545
+     *
2546
+     * @since 1.0.19
2547
+     * @param  string $value address.
2548
+     */
2549
+    public function set_user_address( $value ) {
2550
+        $this->set_address( $value );
2521 2551
     }
2522 2552
 
2523 2553
     /**
2524
-	 * Alias of self::set_vat_rate().
2525
-	 *
2526
-	 * @since 1.0.19
2527
-	 * @param  string $value var number.
2528
-	 */
2529
-	public function set_customer_vat_rate( $value ) {
2530
-		$this->set_vat_rate( $value );
2554
+     * Alias of self::set_address().
2555
+     *
2556
+     * @since 1.0.19
2557
+     * @param  string $value address.
2558
+     */
2559
+    public function set_customer_address( $value ) {
2560
+        $this->set_address( $value );
2531 2561
     }
2532 2562
 
2533 2563
     /**
2534
-	 * Set the customer's address.
2535
-	 *
2536
-	 * @since 1.0.19
2537
-	 * @param  string $value address.
2538
-	 */
2539
-	public function set_address( $value ) {
2540
-		$this->set_prop( 'address', $value );
2564
+     * Set whether the customer has viewed the invoice or not.
2565
+     *
2566
+     * @since 1.0.19
2567
+     * @param  int|bool $value confirmed.
2568
+     */
2569
+    public function set_is_viewed( $value ) {
2570
+        $this->set_prop( 'is_viewed', $value );
2541 2571
     }
2542 2572
 
2543 2573
     /**
2544
-	 * Alias of self::set_address().
2545
-	 *
2546
-	 * @since 1.0.19
2547
-	 * @param  string $value address.
2548
-	 */
2549
-	public function set_user_address( $value ) {
2550
-		$this->set_address( $value );
2574
+     * Set extra email recipients.
2575
+     *
2576
+     * @since 1.0.19
2577
+     * @param  string $value email recipients.
2578
+     */
2579
+    public function set_email_cc( $value ) {
2580
+        $this->set_prop( 'email_cc', $value );
2551 2581
     }
2552 2582
 
2553 2583
     /**
2554
-	 * Alias of self::set_address().
2555
-	 *
2556
-	 * @since 1.0.19
2557
-	 * @param  string $value address.
2558
-	 */
2559
-	public function set_customer_address( $value ) {
2560
-		$this->set_address( $value );
2584
+     * Set the invoice template.
2585
+     *
2586
+     * @since 1.0.19
2587
+     * @param  string $value email recipients.
2588
+     */
2589
+    public function set_template( $value ) {
2590
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2591
+            $this->set_prop( 'template', $value );
2592
+        }
2561 2593
     }
2562 2594
 
2563 2595
     /**
2564
-	 * Set whether the customer has viewed the invoice or not.
2565
-	 *
2566
-	 * @since 1.0.19
2567
-	 * @param  int|bool $value confirmed.
2568
-	 */
2569
-	public function set_is_viewed( $value ) {
2570
-		$this->set_prop( 'is_viewed', $value );
2571
-	}
2572
-
2573
-	/**
2574
-	 * Set extra email recipients.
2575
-	 *
2576
-	 * @since 1.0.19
2577
-	 * @param  string $value email recipients.
2578
-	 */
2579
-	public function set_email_cc( $value ) {
2580
-		$this->set_prop( 'email_cc', $value );
2581
-	}
2582
-
2583
-	/**
2584
-	 * Set the invoice template.
2585
-	 *
2586
-	 * @since 1.0.19
2587
-	 * @param  string $value email recipients.
2588
-	 */
2589
-	public function set_template( $value ) {
2590
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2591
-			$this->set_prop( 'template', $value );
2592
-		}
2593
-	}
2594
-
2595
-	/**
2596
-	 * Set the customer's address confirmed status.
2597
-	 *
2598
-	 * @since 1.0.19
2599
-	 * @param  int|bool $value confirmed.
2600
-	 */
2601
-	public function set_address_confirmed( $value ) {
2602
-		$this->set_prop( 'address_confirmed', $value );
2596
+     * Set the customer's address confirmed status.
2597
+     *
2598
+     * @since 1.0.19
2599
+     * @param  int|bool $value confirmed.
2600
+     */
2601
+    public function set_address_confirmed( $value ) {
2602
+        $this->set_prop( 'address_confirmed', $value );
2603 2603
     }
2604 2604
 
2605 2605
     /**
2606
-	 * Alias of self::set_address_confirmed().
2607
-	 *
2608
-	 * @since 1.0.19
2609
-	 * @param  int|bool $value confirmed.
2610
-	 */
2611
-	public function set_user_address_confirmed( $value ) {
2612
-		$this->set_address_confirmed( $value );
2606
+     * Alias of self::set_address_confirmed().
2607
+     *
2608
+     * @since 1.0.19
2609
+     * @param  int|bool $value confirmed.
2610
+     */
2611
+    public function set_user_address_confirmed( $value ) {
2612
+        $this->set_address_confirmed( $value );
2613 2613
     }
2614 2614
 
2615 2615
     /**
2616
-	 * Alias of self::set_address_confirmed().
2617
-	 *
2618
-	 * @since 1.0.19
2619
-	 * @param  int|bool $value confirmed.
2620
-	 */
2621
-	public function set_customer_address_confirmed( $value ) {
2622
-		$this->set_address_confirmed( $value );
2616
+     * Alias of self::set_address_confirmed().
2617
+     *
2618
+     * @since 1.0.19
2619
+     * @param  int|bool $value confirmed.
2620
+     */
2621
+    public function set_customer_address_confirmed( $value ) {
2622
+        $this->set_address_confirmed( $value );
2623 2623
     }
2624 2624
 
2625 2625
     /**
2626
-	 * Set the invoice sub total.
2627
-	 *
2628
-	 * @since 1.0.19
2629
-	 * @param  float $value sub total.
2630
-	 */
2631
-	public function set_subtotal( $value ) {
2632
-		$this->set_prop( 'subtotal', $value );
2626
+     * Set the invoice sub total.
2627
+     *
2628
+     * @since 1.0.19
2629
+     * @param  float $value sub total.
2630
+     */
2631
+    public function set_subtotal( $value ) {
2632
+        $this->set_prop( 'subtotal', $value );
2633 2633
     }
2634 2634
 
2635 2635
     /**
2636
-	 * Set the invoice discount amount.
2637
-	 *
2638
-	 * @since 1.0.19
2639
-	 * @param  float $value discount total.
2640
-	 */
2641
-	public function set_total_discount( $value ) {
2642
-		$this->set_prop( 'total_discount', $value );
2636
+     * Set the invoice discount amount.
2637
+     *
2638
+     * @since 1.0.19
2639
+     * @param  float $value discount total.
2640
+     */
2641
+    public function set_total_discount( $value ) {
2642
+        $this->set_prop( 'total_discount', $value );
2643 2643
     }
2644 2644
 
2645 2645
     /**
2646
-	 * Alias of self::set_total_discount().
2647
-	 *
2648
-	 * @since 1.0.19
2649
-	 * @param  float $value discount total.
2650
-	 */
2651
-	public function set_discount( $value ) {
2652
-		$this->set_total_discount( $value );
2646
+     * Alias of self::set_total_discount().
2647
+     *
2648
+     * @since 1.0.19
2649
+     * @param  float $value discount total.
2650
+     */
2651
+    public function set_discount( $value ) {
2652
+        $this->set_total_discount( $value );
2653 2653
     }
2654 2654
 
2655 2655
     /**
2656
-	 * Set the invoice tax amount.
2657
-	 *
2658
-	 * @since 1.0.19
2659
-	 * @param  float $value tax total.
2660
-	 */
2661
-	public function set_total_tax( $value ) {
2662
-		$this->set_prop( 'total_tax', $value );
2656
+     * Set the invoice tax amount.
2657
+     *
2658
+     * @since 1.0.19
2659
+     * @param  float $value tax total.
2660
+     */
2661
+    public function set_total_tax( $value ) {
2662
+        $this->set_prop( 'total_tax', $value );
2663 2663
     }
2664 2664
 
2665 2665
     /**
2666
-	 * Alias of self::set_total_tax().
2667
-	 *
2668
-	 * @since 1.0.19
2669
-	 * @param  float $value tax total.
2670
-	 */
2671
-	public function set_tax_total( $value ) {
2672
-		$this->set_total_tax( $value );
2666
+     * Alias of self::set_total_tax().
2667
+     *
2668
+     * @since 1.0.19
2669
+     * @param  float $value tax total.
2670
+     */
2671
+    public function set_tax_total( $value ) {
2672
+        $this->set_total_tax( $value );
2673 2673
     }
2674 2674
 
2675 2675
     /**
2676
-	 * Set the invoice fees amount.
2677
-	 *
2678
-	 * @since 1.0.19
2679
-	 * @param  float $value fees total.
2680
-	 */
2681
-	public function set_total_fees( $value ) {
2682
-		$this->set_prop( 'total_fees', $value );
2676
+     * Set the invoice fees amount.
2677
+     *
2678
+     * @since 1.0.19
2679
+     * @param  float $value fees total.
2680
+     */
2681
+    public function set_total_fees( $value ) {
2682
+        $this->set_prop( 'total_fees', $value );
2683 2683
     }
2684 2684
 
2685 2685
     /**
2686
-	 * Alias of self::set_total_fees().
2687
-	 *
2688
-	 * @since 1.0.19
2689
-	 * @param  float $value fees total.
2690
-	 */
2691
-	public function set_fees_total( $value ) {
2692
-		$this->set_total_fees( $value );
2686
+     * Alias of self::set_total_fees().
2687
+     *
2688
+     * @since 1.0.19
2689
+     * @param  float $value fees total.
2690
+     */
2691
+    public function set_fees_total( $value ) {
2692
+        $this->set_total_fees( $value );
2693 2693
     }
2694 2694
 
2695 2695
     /**
2696
-	 * Set the invoice fees.
2697
-	 *
2698
-	 * @since 1.0.19
2699
-	 * @param  array $value fees.
2700
-	 */
2701
-	public function set_fees( $value ) {
2696
+     * Set the invoice fees.
2697
+     *
2698
+     * @since 1.0.19
2699
+     * @param  array $value fees.
2700
+     */
2701
+    public function set_fees( $value ) {
2702 2702
 
2703 2703
         $this->set_prop( 'fees', array() );
2704 2704
 
@@ -2716,23 +2716,23 @@  discard block
 block discarded – undo
2716 2716
     }
2717 2717
 
2718 2718
     /**
2719
-	 * Set the invoice taxes.
2720
-	 *
2721
-	 * @since 1.0.19
2722
-	 * @param  array $value taxes.
2723
-	 */
2724
-	public function set_taxes( $value ) {
2725
-		$this->set_prop( 'taxes', $value );
2719
+     * Set the invoice taxes.
2720
+     *
2721
+     * @since 1.0.19
2722
+     * @param  array $value taxes.
2723
+     */
2724
+    public function set_taxes( $value ) {
2725
+        $this->set_prop( 'taxes', $value );
2726 2726
     }
2727 2727
 
2728 2728
     /**
2729
-	 * Set the invoice discounts.
2730
-	 *
2731
-	 * @since 1.0.19
2732
-	 * @param  array $value discounts.
2733
-	 */
2734
-	public function set_discounts( $value ) {
2735
-		$this->set_prop( 'discounts', array() );
2729
+     * Set the invoice discounts.
2730
+     *
2731
+     * @since 1.0.19
2732
+     * @param  array $value discounts.
2733
+     */
2734
+    public function set_discounts( $value ) {
2735
+        $this->set_prop( 'discounts', array() );
2736 2736
 
2737 2737
         // Ensure that we have an array.
2738 2738
         if ( ! is_array( $value ) ) {
@@ -2747,12 +2747,12 @@  discard block
 block discarded – undo
2747 2747
     }
2748 2748
 
2749 2749
     /**
2750
-	 * Set the invoice items.
2751
-	 *
2752
-	 * @since 1.0.19
2753
-	 * @param  GetPaid_Form_Item[] $value items.
2754
-	 */
2755
-	public function set_items( $value ) {
2750
+     * Set the invoice items.
2751
+     *
2752
+     * @since 1.0.19
2753
+     * @param  GetPaid_Form_Item[] $value items.
2754
+     */
2755
+    public function set_items( $value ) {
2756 2756
 
2757 2757
         // Remove existing items.
2758 2758
         $this->set_prop( 'items', array() );
@@ -2769,83 +2769,83 @@  discard block
 block discarded – undo
2769 2769
     }
2770 2770
 
2771 2771
     /**
2772
-	 * Set the payment form.
2773
-	 *
2774
-	 * @since 1.0.19
2775
-	 * @param  int $value payment form.
2776
-	 */
2777
-	public function set_payment_form( $value ) {
2778
-		$this->set_prop( 'payment_form', $value );
2772
+     * Set the payment form.
2773
+     *
2774
+     * @since 1.0.19
2775
+     * @param  int $value payment form.
2776
+     */
2777
+    public function set_payment_form( $value ) {
2778
+        $this->set_prop( 'payment_form', $value );
2779 2779
     }
2780 2780
 
2781 2781
     /**
2782
-	 * Set the submission id.
2783
-	 *
2784
-	 * @since 1.0.19
2785
-	 * @param  string $value submission id.
2786
-	 */
2787
-	public function set_submission_id( $value ) {
2788
-		$this->set_prop( 'submission_id', $value );
2782
+     * Set the submission id.
2783
+     *
2784
+     * @since 1.0.19
2785
+     * @param  string $value submission id.
2786
+     */
2787
+    public function set_submission_id( $value ) {
2788
+        $this->set_prop( 'submission_id', $value );
2789 2789
     }
2790 2790
 
2791 2791
     /**
2792
-	 * Set the discount code.
2793
-	 *
2794
-	 * @since 1.0.19
2795
-	 * @param  string $value discount code.
2796
-	 */
2797
-	public function set_discount_code( $value ) {
2798
-		$this->set_prop( 'discount_code', $value );
2792
+     * Set the discount code.
2793
+     *
2794
+     * @since 1.0.19
2795
+     * @param  string $value discount code.
2796
+     */
2797
+    public function set_discount_code( $value ) {
2798
+        $this->set_prop( 'discount_code', $value );
2799 2799
     }
2800 2800
 
2801 2801
     /**
2802
-	 * Set the gateway.
2803
-	 *
2804
-	 * @since 1.0.19
2805
-	 * @param  string $value gateway.
2806
-	 */
2807
-	public function set_gateway( $value ) {
2808
-		$this->set_prop( 'gateway', $value );
2802
+     * Set the gateway.
2803
+     *
2804
+     * @since 1.0.19
2805
+     * @param  string $value gateway.
2806
+     */
2807
+    public function set_gateway( $value ) {
2808
+        $this->set_prop( 'gateway', $value );
2809 2809
     }
2810 2810
 
2811 2811
     /**
2812
-	 * Set the transaction id.
2813
-	 *
2814
-	 * @since 1.0.19
2815
-	 * @param  string $value transaction id.
2816
-	 */
2817
-	public function set_transaction_id( $value ) {
2818
-		$this->set_prop( 'transaction_id', $value );
2812
+     * Set the transaction id.
2813
+     *
2814
+     * @since 1.0.19
2815
+     * @param  string $value transaction id.
2816
+     */
2817
+    public function set_transaction_id( $value ) {
2818
+        $this->set_prop( 'transaction_id', $value );
2819 2819
     }
2820 2820
 
2821 2821
     /**
2822
-	 * Set the currency id.
2823
-	 *
2824
-	 * @since 1.0.19
2825
-	 * @param  string $value currency id.
2826
-	 */
2827
-	public function set_currency( $value ) {
2828
-		$this->set_prop( 'currency', $value );
2822
+     * Set the currency id.
2823
+     *
2824
+     * @since 1.0.19
2825
+     * @param  string $value currency id.
2826
+     */
2827
+    public function set_currency( $value ) {
2828
+        $this->set_prop( 'currency', $value );
2829 2829
     }
2830 2830
 
2831
-	/**
2832
-	 * Set whether to disable taxes.
2833
-	 *
2834
-	 * @since 1.0.19
2835
-	 * @param  bool $value value.
2836
-	 */
2837
-	public function set_disable_taxes( $value ) {
2838
-		$this->set_prop( 'disable_taxes', (bool) $value );
2839
-	}
2831
+    /**
2832
+     * Set whether to disable taxes.
2833
+     *
2834
+     * @since 1.0.19
2835
+     * @param  bool $value value.
2836
+     */
2837
+    public function set_disable_taxes( $value ) {
2838
+        $this->set_prop( 'disable_taxes', (bool) $value );
2839
+    }
2840 2840
 
2841 2841
     /**
2842
-	 * Set the subscription id.
2843
-	 *
2844
-	 * @since 1.0.19
2845
-	 * @param  string $value subscription id.
2846
-	 */
2847
-	public function set_subscription_id( $value ) {
2848
-		$this->set_prop( 'subscription_id', $value );
2842
+     * Set the subscription id.
2843
+     *
2844
+     * @since 1.0.19
2845
+     * @param  string $value subscription id.
2846
+     */
2847
+    public function set_subscription_id( $value ) {
2848
+        $this->set_prop( 'subscription_id', $value );
2849 2849
     }
2850 2850
 
2851 2851
     /*
@@ -2884,12 +2884,12 @@  discard block
 block discarded – undo
2884 2884
      */
2885 2885
     public function is_taxable() {
2886 2886
         return ! $this->get_disable_taxes();
2887
-	}
2887
+    }
2888 2888
 
2889
-	/**
2890
-	 * @deprecated
2891
-	 */
2892
-	public function has_vat() {
2889
+    /**
2890
+     * @deprecated
2891
+     */
2892
+    public function has_vat() {
2893 2893
         global $wpinv_euvat, $wpi_country;
2894 2894
 
2895 2895
         $requires_vat = false;
@@ -2900,17 +2900,17 @@  discard block
 block discarded – undo
2900 2900
         }
2901 2901
 
2902 2902
         return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2903
-	}
2903
+    }
2904 2904
 
2905
-	/**
2906
-	 * Checks to see if the invoice requires payment.
2907
-	 */
2908
-	public function is_free() {
2905
+    /**
2906
+     * Checks to see if the invoice requires payment.
2907
+     */
2908
+    public function is_free() {
2909 2909
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2910 2910
 
2911
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2912
-			$is_free = false;
2913
-		}
2911
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2912
+            $is_free = false;
2913
+        }
2914 2914
 
2915 2915
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2916 2916
     }
@@ -2921,38 +2921,38 @@  discard block
 block discarded – undo
2921 2921
     public function is_paid() {
2922 2922
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2923 2923
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2924
-	}
2924
+    }
2925 2925
 
2926
-	/**
2926
+    /**
2927 2927
      * Checks if the invoice needs payment.
2928 2928
      */
2929
-	public function needs_payment() {
2930
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2929
+    public function needs_payment() {
2930
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2931 2931
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2932 2932
     }
2933 2933
 
2934
-	/**
2934
+    /**
2935 2935
      * Checks if the invoice is refunded.
2936 2936
      */
2937
-	public function is_refunded() {
2937
+    public function is_refunded() {
2938 2938
         $is_refunded = $this->has_status( 'wpi-refunded' );
2939 2939
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2940
-	}
2940
+    }
2941 2941
 
2942
-	/**
2942
+    /**
2943 2943
      * Checks if the invoice is due.
2944 2944
      */
2945
-	public function is_due() {
2946
-		$due_date = $this->get_due_date();
2947
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2948
-	}
2945
+    public function is_due() {
2946
+        $due_date = $this->get_due_date();
2947
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2948
+    }
2949 2949
 
2950
-	/**
2950
+    /**
2951 2951
      * Checks if the invoice is draft.
2952 2952
      */
2953
-	public function is_draft() {
2953
+    public function is_draft() {
2954 2954
         return $this->has_status( 'draft, auto-draft' );
2955
-	}
2955
+    }
2956 2956
 
2957 2957
     /**
2958 2958
      * Checks if the invoice has a given status.
@@ -2960,9 +2960,9 @@  discard block
 block discarded – undo
2960 2960
     public function has_status( $status ) {
2961 2961
         $status = wpinv_parse_list( $status );
2962 2962
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
2963
-	}
2963
+    }
2964 2964
 
2965
-	/**
2965
+    /**
2966 2966
      * Checks if the invoice is of a given type.
2967 2967
      */
2968 2968
     public function is_type( $type ) {
@@ -2985,25 +2985,25 @@  discard block
 block discarded – undo
2985 2985
      */
2986 2986
     public function has_free_trial() {
2987 2987
         return $this->is_recurring() && 0 == $this->get_initial_total();
2988
-	}
2988
+    }
2989 2989
 
2990
-	/**
2990
+    /**
2991 2991
      * @deprecated
2992 2992
      */
2993 2993
     public function is_free_trial() {
2994 2994
         $this->has_free_trial();
2995 2995
     }
2996 2996
 
2997
-	/**
2997
+    /**
2998 2998
      * Check if the initial payment if 0.
2999 2999
      *
3000 3000
      */
3001
-	public function is_initial_free() {
3001
+    public function is_initial_free() {
3002 3002
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3003 3003
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3004 3004
     }
3005 3005
 	
3006
-	/**
3006
+    /**
3007 3007
      * Check if the recurring item has a free trial.
3008 3008
      *
3009 3009
      */
@@ -3016,21 +3016,21 @@  discard block
 block discarded – undo
3016 3016
 
3017 3017
         $item = $this->get_recurring( true );
3018 3018
         return $item->has_free_trial();
3019
-	}
3019
+    }
3020 3020
 
3021
-	/**
3021
+    /**
3022 3022
      * Check if the free trial is a result of a discount.
3023 3023
      */
3024 3024
     public function is_free_trial_from_discount() {
3025
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3026
-	}
3025
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3026
+    }
3027 3027
 	
3028
-	/**
3028
+    /**
3029 3029
      * @deprecated
3030 3030
      */
3031 3031
     public function discount_first_payment_only() {
3032 3032
 
3033
-		$discount_code = $this->get_discount_code();
3033
+        $discount_code = $this->get_discount_code();
3034 3034
         if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3035 3035
             return true;
3036 3036
         }
@@ -3062,19 +3062,19 @@  discard block
 block discarded – undo
3062 3062
     public function add_item( $item ) {
3063 3063
 
3064 3064
         // Make sure that it is available for purchase.
3065
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3066
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3065
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3066
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3067 3067
         }
3068 3068
 
3069 3069
         // Do we have a recurring item?
3070
-		if ( $item->is_recurring() ) {
3070
+        if ( $item->is_recurring() ) {
3071 3071
 
3072
-			// An invoice can only contain one recurring item.
3073
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3074
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3075
-			}
3072
+            // An invoice can only contain one recurring item.
3073
+            if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3074
+                return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3075
+            }
3076 3076
 
3077
-			$this->recurring_item = $item->get_id();
3077
+            $this->recurring_item = $item->get_id();
3078 3078
         }
3079 3079
 
3080 3080
         // Invoice id.
@@ -3085,28 +3085,28 @@  discard block
 block discarded – undo
3085 3085
         $items[ (int) $item->get_id() ] = $item;
3086 3086
 
3087 3087
         $this->set_prop( 'items', $items );
3088
-		return true;
3088
+        return true;
3089 3089
     }
3090 3090
 
3091 3091
     /**
3092
-	 * Retrieves a specific item.
3093
-	 *
3094
-	 * @since 1.0.19
3095
-	 */
3096
-	public function get_item( $item_id ) {
3097
-		$items   = $this->get_items();
3098
-		$item_id = (int) $item_id;
3099
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3092
+     * Retrieves a specific item.
3093
+     *
3094
+     * @since 1.0.19
3095
+     */
3096
+    public function get_item( $item_id ) {
3097
+        $items   = $this->get_items();
3098
+        $item_id = (int) $item_id;
3099
+        return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3100 3100
     }
3101 3101
 
3102 3102
     /**
3103
-	 * Removes a specific item.
3104
-	 *
3105
-	 * @since 1.0.19
3106
-	 */
3107
-	public function remove_item( $item_id ) {
3108
-		$items   = $this->get_items();
3109
-		$item_id = (int) $item_id;
3103
+     * Removes a specific item.
3104
+     *
3105
+     * @since 1.0.19
3106
+     */
3107
+    public function remove_item( $item_id ) {
3108
+        $items   = $this->get_items();
3109
+        $item_id = (int) $item_id;
3110 3110
 
3111 3111
         if ( $item_id == $this->recurring_item ) {
3112 3112
             $this->recurring_item = null;
@@ -3133,38 +3133,38 @@  discard block
 block discarded – undo
3133 3133
         if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3134 3134
 
3135 3135
             $amount = $fees[ $fee ]['amount'] += $amount;
3136
-			$fees[ $fee ] = array(
3136
+            $fees[ $fee ] = array(
3137 3137
                 'amount'    => $amount,
3138 3138
                 'recurring' => (bool) $recurring,
3139 3139
             );
3140 3140
 
3141
-		} else {
3142
-			$fees[ $fee ] = array(
3141
+        } else {
3142
+            $fees[ $fee ] = array(
3143 3143
                 'amount'    => $amount,
3144 3144
                 'recurring' => (bool) $recurring,
3145 3145
             );
3146
-		}
3146
+        }
3147 3147
 
3148 3148
         $this->set_prop( 'fees', $fee );
3149 3149
 
3150 3150
     }
3151 3151
 
3152 3152
     /**
3153
-	 * Retrieves a specific fee.
3154
-	 *
3155
-	 * @since 1.0.19
3156
-	 */
3157
-	public function get_fee( $fee ) {
3153
+     * Retrieves a specific fee.
3154
+     *
3155
+     * @since 1.0.19
3156
+     */
3157
+    public function get_fee( $fee ) {
3158 3158
         $fees = $this->get_fees();
3159
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3159
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3160 3160
     }
3161 3161
 
3162 3162
     /**
3163
-	 * Removes a specific fee.
3164
-	 *
3165
-	 * @since 1.0.19
3166
-	 */
3167
-	public function remove_fee( $fee ) {
3163
+     * Removes a specific fee.
3164
+     *
3165
+     * @since 1.0.19
3166
+     */
3167
+    public function remove_fee( $fee ) {
3168 3168
         $fees = $this->get_fees();
3169 3169
         if ( isset( $fees[ $fee ] ) ) {
3170 3170
             unset( $fees[ $fee ] );
@@ -3187,44 +3187,44 @@  discard block
 block discarded – undo
3187 3187
         if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3188 3188
 
3189 3189
             $amount = $discounts[ $discount ]['amount'] += $amount;
3190
-			$discounts[ $discount ] = array(
3190
+            $discounts[ $discount ] = array(
3191 3191
                 'amount'    => $amount,
3192 3192
                 'recurring' => (bool) $recurring,
3193 3193
             );
3194 3194
 
3195
-		} else {
3196
-			$discounts[ $discount ] = array(
3195
+        } else {
3196
+            $discounts[ $discount ] = array(
3197 3197
                 'amount'    => $amount,
3198 3198
                 'recurring' => (bool) $recurring,
3199 3199
             );
3200
-		}
3200
+        }
3201 3201
 
3202 3202
         $this->set_prop( 'discounts', $discount );
3203 3203
 
3204 3204
     }
3205 3205
 
3206 3206
     /**
3207
-	 * Retrieves a specific discount.
3208
-	 *
3209
-	 * @since 1.0.19
3210
-	 */
3211
-	public function get_discount( $discount = false ) {
3207
+     * Retrieves a specific discount.
3208
+     *
3209
+     * @since 1.0.19
3210
+     */
3211
+    public function get_discount( $discount = false ) {
3212 3212
 
3213
-		// Backwards compatibilty.
3214
-		if ( empty( $discount ) ) {
3215
-			return $this->get_total_discount();
3216
-		}
3213
+        // Backwards compatibilty.
3214
+        if ( empty( $discount ) ) {
3215
+            return $this->get_total_discount();
3216
+        }
3217 3217
 
3218 3218
         $discounts = $this->get_discounts();
3219
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3219
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3220 3220
     }
3221 3221
 
3222 3222
     /**
3223
-	 * Removes a specific discount.
3224
-	 *
3225
-	 * @since 1.0.19
3226
-	 */
3227
-	public function remove_discount( $discount ) {
3223
+     * Removes a specific discount.
3224
+     *
3225
+     * @since 1.0.19
3226
+     */
3227
+    public function remove_discount( $discount ) {
3228 3228
         $discounts = $this->get_discounts();
3229 3229
         if ( isset( $discounts[ $discount ] ) ) {
3230 3230
             unset( $discounts[ $discount ] );
@@ -3250,44 +3250,44 @@  discard block
 block discarded – undo
3250 3250
         if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3251 3251
 
3252 3252
             $amount = $taxes[ $tax ]['amount'] += $amount;
3253
-			$taxes[ $tax ] = array(
3253
+            $taxes[ $tax ] = array(
3254 3254
                 'amount'    => $amount,
3255 3255
                 'recurring' => (bool) $recurring,
3256 3256
             );
3257 3257
 
3258
-		} else {
3259
-			$taxes[ $tax ] = array(
3258
+        } else {
3259
+            $taxes[ $tax ] = array(
3260 3260
                 'amount'    => $amount,
3261 3261
                 'recurring' => (bool) $recurring,
3262 3262
             );
3263
-		}
3263
+        }
3264 3264
 
3265 3265
         $this->set_prop( 'taxes', $tax );
3266 3266
 
3267 3267
     }
3268 3268
 
3269 3269
     /**
3270
-	 * Retrieves a specific tax.
3271
-	 *
3272
-	 * @since 1.0.19
3273
-	 */
3274
-	public function get_tax( $tax = null ) {
3270
+     * Retrieves a specific tax.
3271
+     *
3272
+     * @since 1.0.19
3273
+     */
3274
+    public function get_tax( $tax = null ) {
3275 3275
 
3276
-		// Backwards compatility.
3277
-		if ( empty( $tax ) ) {
3278
-			return $this->get_total_tax();
3279
-		}
3276
+        // Backwards compatility.
3277
+        if ( empty( $tax ) ) {
3278
+            return $this->get_total_tax();
3279
+        }
3280 3280
 
3281 3281
         $taxes = $this->get_taxes();
3282
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3282
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3283 3283
     }
3284 3284
 
3285 3285
     /**
3286
-	 * Removes a specific tax.
3287
-	 *
3288
-	 * @since 1.0.19
3289
-	 */
3290
-	public function remove_tax( $tax ) {
3286
+     * Removes a specific tax.
3287
+     *
3288
+     * @since 1.0.19
3289
+     */
3290
+    public function remove_tax( $tax ) {
3291 3291
         $taxes = $this->get_discounts();
3292 3292
         if ( isset( $taxes[ $tax ] ) ) {
3293 3293
             unset( $taxes[ $tax ] );
@@ -3296,160 +3296,160 @@  discard block
 block discarded – undo
3296 3296
     }
3297 3297
 
3298 3298
     /**
3299
-	 * Recalculates the invoice subtotal.
3300
-	 *
3301
-	 * @since 1.0.19
3302
-	 * @return float The recalculated subtotal
3303
-	 */
3304
-	public function recalculate_subtotal() {
3299
+     * Recalculates the invoice subtotal.
3300
+     *
3301
+     * @since 1.0.19
3302
+     * @return float The recalculated subtotal
3303
+     */
3304
+    public function recalculate_subtotal() {
3305 3305
         $items     = $this->get_items();
3306
-		$subtotal  = 0;
3307
-		$recurring = 0;
3306
+        $subtotal  = 0;
3307
+        $recurring = 0;
3308 3308
 
3309 3309
         foreach ( $items as $item ) {
3310
-			$subtotal  += $item->get_sub_total();
3311
-			$recurring += $item->get_recurring_sub_total();
3310
+            $subtotal  += $item->get_sub_total();
3311
+            $recurring += $item->get_recurring_sub_total();
3312 3312
         }
3313 3313
 
3314
-		if ( $this->is_renewal() ) {
3315
-			$this->set_subtotal( $recurring );
3316
-		} else {
3317
-			$this->set_subtotal( $subtotal );
3318
-		}
3314
+        if ( $this->is_renewal() ) {
3315
+            $this->set_subtotal( $recurring );
3316
+        } else {
3317
+            $this->set_subtotal( $subtotal );
3318
+        }
3319 3319
 
3320
-		$this->totals['subtotal'] = array(
3321
-			'initial'   => $subtotal,
3322
-			'recurring' => $recurring,
3323
-		);
3320
+        $this->totals['subtotal'] = array(
3321
+            'initial'   => $subtotal,
3322
+            'recurring' => $recurring,
3323
+        );
3324 3324
 
3325 3325
         return $this->is_renewal() ? $recurring : $subtotal;
3326 3326
     }
3327 3327
 
3328 3328
     /**
3329
-	 * Recalculates the invoice discount total.
3330
-	 *
3331
-	 * @since 1.0.19
3332
-	 * @return float The recalculated discount
3333
-	 */
3334
-	public function recalculate_total_discount() {
3329
+     * Recalculates the invoice discount total.
3330
+     *
3331
+     * @since 1.0.19
3332
+     * @return float The recalculated discount
3333
+     */
3334
+    public function recalculate_total_discount() {
3335 3335
         $discounts = $this->get_discounts();
3336
-		$discount  = 0;
3337
-		$recurring = 0;
3336
+        $discount  = 0;
3337
+        $recurring = 0;
3338 3338
 
3339 3339
         foreach ( $discounts as $data ) {
3340 3340
 
3341
-			if ( $data['recurring'] ) {
3342
-				$recurring += $data['amount'];
3343
-			} else {
3344
-				$discount += $data['amount'];
3345
-			}
3341
+            if ( $data['recurring'] ) {
3342
+                $recurring += $data['amount'];
3343
+            } else {
3344
+                $discount += $data['amount'];
3345
+            }
3346 3346
 
3347
-		}
3347
+        }
3348 3348
 
3349
-		if ( $this->is_renewal() ) {
3350
-			$this->set_total_discount( $recurring );
3351
-		} else {
3352
-			$this->set_total_discount( $discount );
3353
-		}
3349
+        if ( $this->is_renewal() ) {
3350
+            $this->set_total_discount( $recurring );
3351
+        } else {
3352
+            $this->set_total_discount( $discount );
3353
+        }
3354 3354
 
3355
-		$this->totals['discount'] = array(
3356
-			'initial'   => $discount,
3357
-			'recurring' => $recurring,
3358
-		);
3355
+        $this->totals['discount'] = array(
3356
+            'initial'   => $discount,
3357
+            'recurring' => $recurring,
3358
+        );
3359 3359
 
3360
-		return $this->is_renewal() ? $recurring : $discount;
3360
+        return $this->is_renewal() ? $recurring : $discount;
3361 3361
 
3362 3362
     }
3363 3363
 
3364 3364
     /**
3365
-	 * Recalculates the invoice tax total.
3366
-	 *
3367
-	 * @since 1.0.19
3368
-	 * @return float The recalculated tax
3369
-	 */
3370
-	public function recalculate_total_tax() {
3365
+     * Recalculates the invoice tax total.
3366
+     *
3367
+     * @since 1.0.19
3368
+     * @return float The recalculated tax
3369
+     */
3370
+    public function recalculate_total_tax() {
3371 3371
         $taxes     = $this->get_taxes();
3372
-		$tax       = 0;
3373
-		$recurring = 0;
3372
+        $tax       = 0;
3373
+        $recurring = 0;
3374 3374
 
3375 3375
         foreach ( $taxes as $data ) {
3376 3376
 
3377
-			if ( $data['recurring'] ) {
3378
-				$recurring += $data['amount'];
3379
-			} else {
3380
-				$tax += $data['amount'];
3381
-			}
3377
+            if ( $data['recurring'] ) {
3378
+                $recurring += $data['amount'];
3379
+            } else {
3380
+                $tax += $data['amount'];
3381
+            }
3382 3382
 
3383
-		}
3383
+        }
3384 3384
 
3385
-		if ( $this->is_renewal() ) {
3386
-			$this->set_total_tax( $recurring );
3387
-		} else {
3388
-			$this->set_total_tax( $tax );
3389
-		}
3385
+        if ( $this->is_renewal() ) {
3386
+            $this->set_total_tax( $recurring );
3387
+        } else {
3388
+            $this->set_total_tax( $tax );
3389
+        }
3390 3390
 
3391
-		$this->totals['tax'] = array(
3392
-			'initial'   => $tax,
3393
-			'recurring' => $recurring,
3394
-		);
3391
+        $this->totals['tax'] = array(
3392
+            'initial'   => $tax,
3393
+            'recurring' => $recurring,
3394
+        );
3395 3395
 
3396
-		return $this->is_renewal() ? $recurring : $tax;
3396
+        return $this->is_renewal() ? $recurring : $tax;
3397 3397
 
3398 3398
     }
3399 3399
 
3400 3400
     /**
3401
-	 * Recalculates the invoice fees total.
3402
-	 *
3403
-	 * @since 1.0.19
3404
-	 * @return float The recalculated fee
3405
-	 */
3406
-	public function recalculate_total_fees() {
3407
-		$fees      = $this->get_fees();
3408
-		$fee       = 0;
3409
-		$recurring = 0;
3401
+     * Recalculates the invoice fees total.
3402
+     *
3403
+     * @since 1.0.19
3404
+     * @return float The recalculated fee
3405
+     */
3406
+    public function recalculate_total_fees() {
3407
+        $fees      = $this->get_fees();
3408
+        $fee       = 0;
3409
+        $recurring = 0;
3410 3410
 
3411 3411
         foreach ( $fees as $data ) {
3412 3412
 
3413
-			if ( $data['recurring'] ) {
3414
-				$recurring += $data['amount'];
3415
-			} else {
3416
-				$fee += $data['amount'];
3417
-			}
3413
+            if ( $data['recurring'] ) {
3414
+                $recurring += $data['amount'];
3415
+            } else {
3416
+                $fee += $data['amount'];
3417
+            }
3418 3418
 
3419
-		}
3419
+        }
3420 3420
 
3421 3421
         if ( $this->is_renewal() ) {
3422
-			$this->set_total_fees( $recurring );
3423
-		} else {
3424
-			$this->set_total_fees( $fee );
3425
-		}
3422
+            $this->set_total_fees( $recurring );
3423
+        } else {
3424
+            $this->set_total_fees( $fee );
3425
+        }
3426 3426
 
3427
-		$this->totals['fee'] = array(
3428
-			'initial'   => $fee,
3429
-			'recurring' => $recurring,
3430
-		);
3427
+        $this->totals['fee'] = array(
3428
+            'initial'   => $fee,
3429
+            'recurring' => $recurring,
3430
+        );
3431 3431
 
3432 3432
         $this->set_total_fees( $fee );
3433 3433
         return $this->is_renewal() ? $recurring : $fee;
3434 3434
     }
3435 3435
 
3436 3436
     /**
3437
-	 * Recalculates the invoice total.
3438
-	 *
3439
-	 * @since 1.0.19
3437
+     * Recalculates the invoice total.
3438
+     *
3439
+     * @since 1.0.19
3440 3440
      * @return float The invoice total
3441
-	 */
3442
-	public function recalculate_total() {
3441
+     */
3442
+    public function recalculate_total() {
3443 3443
         $this->recalculate_subtotal();
3444 3444
         $this->recalculate_total_fees();
3445 3445
         $this->recalculate_total_discount();
3446 3446
         $this->recalculate_total_tax();
3447
-		return $this->get_total();
3448
-	}
3447
+        return $this->get_total();
3448
+    }
3449 3449
 
3450
-	/**
3451
-	 * @deprecated
3452
-	 */
3450
+    /**
3451
+     * @deprecated
3452
+     */
3453 3453
     public function recalculate_totals( $temp = false ) {
3454 3454
         $this->update_items( $temp );
3455 3455
         $this->save( true );
@@ -3513,9 +3513,9 @@  discard block
 block discarded – undo
3513 3513
         }
3514 3514
 
3515 3515
         return $note_id;
3516
-	}
3516
+    }
3517 3517
 
3518
-	/**
3518
+    /**
3519 3519
      * Generates a unique key for the invoice.
3520 3520
      */
3521 3521
     public function generate_key( $string = '' ) {
@@ -3535,106 +3535,106 @@  discard block
 block discarded – undo
3535 3535
             $number = wpinv_get_next_invoice_number( $this->post_type );
3536 3536
         }
3537 3537
 
3538
-		$number = wpinv_format_invoice_number( $number, $this->post_type );
3538
+        $number = wpinv_format_invoice_number( $number, $this->post_type );
3539 3539
 
3540
-		return $number;
3541
-	}
3540
+        return $number;
3541
+    }
3542 3542
 
3543
-	/**
3544
-	 * Handle the status transition.
3545
-	 */
3546
-	protected function status_transition() {
3547
-		$status_transition = $this->status_transition;
3543
+    /**
3544
+     * Handle the status transition.
3545
+     */
3546
+    protected function status_transition() {
3547
+        $status_transition = $this->status_transition;
3548 3548
 
3549
-		// Reset status transition variable.
3550
-		$this->status_transition = false;
3549
+        // Reset status transition variable.
3550
+        $this->status_transition = false;
3551 3551
 
3552
-		if ( $status_transition ) {
3553
-			try {
3552
+        if ( $status_transition ) {
3553
+            try {
3554 3554
 
3555
-				// Fire a hook for the status change.
3556
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
3555
+                // Fire a hook for the status change.
3556
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
3557 3557
 
3558
-				// @deprecated this is deprecated and will be removed in the future.
3559
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3558
+                // @deprecated this is deprecated and will be removed in the future.
3559
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3560 3560
 
3561
-				if ( ! empty( $status_transition['from'] ) ) {
3561
+                if ( ! empty( $status_transition['from'] ) ) {
3562 3562
 
3563
-					/* translators: 1: old invoice status 2: new invoice status */
3564
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3563
+                    /* translators: 1: old invoice status 2: new invoice status */
3564
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3565 3565
 
3566
-					// Fire another hook.
3567
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
3568
-					do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
3566
+                    // Fire another hook.
3567
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
3568
+                    do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
3569 3569
 
3570
-					// @deprecated this is deprecated and will be removed in the future.
3571
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3570
+                    // @deprecated this is deprecated and will be removed in the future.
3571
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3572 3572
 
3573
-					// Note the transition occurred.
3574
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3573
+                    // Note the transition occurred.
3574
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3575 3575
 
3576
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3577
-					if (
3578
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3579
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3580
-					) {
3581
-						do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition );
3582
-					}
3583
-				} else {
3584
-					/* translators: %s: new invoice status */
3585
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3576
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3577
+                    if (
3578
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3579
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3580
+                    ) {
3581
+                        do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition );
3582
+                    }
3583
+                } else {
3584
+                    /* translators: %s: new invoice status */
3585
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3586 3586
 
3587
-					// Note the transition occurred.
3588
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3587
+                    // Note the transition occurred.
3588
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3589 3589
 
3590
-				}
3591
-			} catch ( Exception $e ) {
3592
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3593
-			}
3594
-		}
3595
-	}
3590
+                }
3591
+            } catch ( Exception $e ) {
3592
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3593
+            }
3594
+        }
3595
+    }
3596 3596
 
3597
-	/**
3598
-	 * Updates an invoice status.
3599
-	 */
3600
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3597
+    /**
3598
+     * Updates an invoice status.
3599
+     */
3600
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3601 3601
 
3602
-		// Fires before updating a status.
3603
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3602
+        // Fires before updating a status.
3603
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3604 3604
 
3605
-		// Update the status.
3606
-		$this->set_status( $new_status, $note, $manual );
3605
+        // Update the status.
3606
+        $this->set_status( $new_status, $note, $manual );
3607 3607
 
3608
-		// Save the order.
3609
-		return $this->save();
3608
+        // Save the order.
3609
+        return $this->save();
3610 3610
 
3611
-	}
3611
+    }
3612 3612
 
3613
-	/**
3614
-	 * @deprecated
3615
-	 */
3616
-	public function refresh_item_ids() {
3613
+    /**
3614
+     * @deprecated
3615
+     */
3616
+    public function refresh_item_ids() {
3617 3617
         $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3618 3618
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3619
-	}
3619
+    }
3620 3620
 
3621
-	/**
3622
-	 * @deprecated
3623
-	 */
3624
-	public function update_items( $temp = false ) {
3621
+    /**
3622
+     * @deprecated
3623
+     */
3624
+    public function update_items( $temp = false ) {
3625 3625
 
3626
-		$this->set_items( $this->get_items() );
3626
+        $this->set_items( $this->get_items() );
3627 3627
 
3628
-		if ( ! $temp ) {
3629
-			$this->save();
3630
-		}
3628
+        if ( ! $temp ) {
3629
+            $this->save();
3630
+        }
3631 3631
 
3632 3632
         return $this;
3633
-	}
3633
+    }
3634 3634
 
3635
-	/**
3636
-	 * @deprecated
3637
-	 */
3635
+    /**
3636
+     * @deprecated
3637
+     */
3638 3638
     public function validate_discount() {
3639 3639
 
3640 3640
         $discount_code = $this->get_discount_code();
@@ -3650,86 +3650,86 @@  discard block
 block discarded – undo
3650 3650
 
3651 3651
     }
3652 3652
 
3653
-	/**
3654
-	 * Refunds an invoice.
3655
-	 */
3653
+    /**
3654
+     * Refunds an invoice.
3655
+     */
3656 3656
     public function refund() {
3657
-		$this->set_status( 'wpi-refunded' );
3657
+        $this->set_status( 'wpi-refunded' );
3658 3658
         $this->save();
3659
-	}
3659
+    }
3660 3660
 
3661
-	/**
3662
-	 * Marks an invoice as paid.
3663
-	 * 
3664
-	 * @param string $transaction_id
3665
-	 */
3661
+    /**
3662
+     * Marks an invoice as paid.
3663
+     * 
3664
+     * @param string $transaction_id
3665
+     */
3666 3666
     public function mark_paid( $transaction_id = null, $note = '' ) {
3667 3667
 
3668
-		// Set the transaction id.
3669
-		if ( empty( $transaction_id ) ) {
3670
-			$transaction_id = $this->generate_key('trans_');
3671
-		}
3668
+        // Set the transaction id.
3669
+        if ( empty( $transaction_id ) ) {
3670
+            $transaction_id = $this->generate_key('trans_');
3671
+        }
3672 3672
 
3673
-		if ( ! $this->get_transaction_id() ) {
3674
-			$this->set_transaction_id( $transaction_id );
3675
-		}
3673
+        if ( ! $this->get_transaction_id() ) {
3674
+            $this->set_transaction_id( $transaction_id );
3675
+        }
3676 3676
 
3677
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3678
-			return $this->save();
3679
-		}
3677
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3678
+            return $this->save();
3679
+        }
3680 3680
 
3681
-		// Set the completed date.
3682
-		$this->set_date_completed( current_time( 'mysql' ) );
3681
+        // Set the completed date.
3682
+        $this->set_date_completed( current_time( 'mysql' ) );
3683 3683
 
3684
-		// Set the new status.
3685
-		if ( $this->is_renewal() ) {
3684
+        // Set the new status.
3685
+        if ( $this->is_renewal() ) {
3686 3686
 
3687
-			$_note = sprintf(
3688
-				__( 'Renewed via %s', 'invoicing' ),
3689
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3690
-			);
3687
+            $_note = sprintf(
3688
+                __( 'Renewed via %s', 'invoicing' ),
3689
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3690
+            );
3691 3691
 
3692
-			if ( 'none' == $this->get_gateway() ) {
3693
-				$_note = $note;
3694
-			}
3692
+            if ( 'none' == $this->get_gateway() ) {
3693
+                $_note = $note;
3694
+            }
3695 3695
 
3696
-			$this->set_status( 'wpi-renewal', $_note );
3696
+            $this->set_status( 'wpi-renewal', $_note );
3697 3697
 
3698
-		} else {
3698
+        } else {
3699 3699
 
3700
-			$_note = sprintf(
3701
-				__( 'Paid via %s', 'invoicing' ),
3702
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3703
-			);
3700
+            $_note = sprintf(
3701
+                __( 'Paid via %s', 'invoicing' ),
3702
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3703
+            );
3704 3704
 
3705
-			if ( 'none' == $this->get_gateway() ) {
3706
-				$_note = $note;
3707
-			}
3705
+            if ( 'none' == $this->get_gateway() ) {
3706
+                $_note = $note;
3707
+            }
3708 3708
 
3709
-			$this->set_status( 'publish',$_note );
3709
+            $this->set_status( 'publish',$_note );
3710 3710
 
3711
-		}
3711
+        }
3712 3712
 
3713
-		// Set checkout mode.
3714
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3715
-		$this->set_mode( $mode );
3713
+        // Set checkout mode.
3714
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3715
+        $this->set_mode( $mode );
3716 3716
 
3717
-		// Save the invoice.
3717
+        // Save the invoice.
3718 3718
         $this->save();
3719
-	}
3720
-
3721
-
3722
-	/**
3723
-	 * Save data to the database.
3724
-	 *
3725
-	 * @since 1.0.19
3726
-	 * @return int invoice ID
3727
-	 */
3728
-	public function save() {
3729
-		$this->maybe_set_date_paid();
3730
-		parent::save();
3731
-		$this->status_transition();
3732
-		return $this->get_id();
3733
-	}
3719
+    }
3720
+
3721
+
3722
+    /**
3723
+     * Save data to the database.
3724
+     *
3725
+     * @since 1.0.19
3726
+     * @return int invoice ID
3727
+     */
3728
+    public function save() {
3729
+        $this->maybe_set_date_paid();
3730
+        parent::save();
3731
+        $this->status_transition();
3732
+        return $this->get_id();
3733
+    }
3734 3734
 
3735 3735
 }
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 1 patch
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
  * @return array
97 97
  */
98 98
 function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
99
-	$invoice_statuses = array(
100
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
99
+    $invoice_statuses = array(
100
+        'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
101 101
         'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
102 102
         'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
103
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
104
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
105
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
103
+        'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
104
+        'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
105
+        'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
106 106
         'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
107 107
         'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
108 108
     );
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
116 116
     }
117 117
 
118
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
118
+    return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
119 119
 }
120 120
 
121 121
 function wpinv_status_nicename( $status ) {
@@ -712,13 +712,13 @@  discard block
 block discarded – undo
712 712
  * @param mixed  $value Value.
713 713
  */
714 714
 function getpaid_maybe_define_constant( $name, $value ) {
715
-	if ( ! defined( $name ) ) {
716
-		define( $name, $value );
717
-	}
715
+    if ( ! defined( $name ) ) {
716
+        define( $name, $value );
717
+    }
718 718
 }
719 719
 
720 720
 function wpinv_get_php_arg_separator_output() {
721
-	return ini_get( 'arg_separator.output' );
721
+    return ini_get( 'arg_separator.output' );
722 722
 }
723 723
 
724 724
 function wpinv_rgb_from_hex( $color ) {
@@ -1067,11 +1067,11 @@  discard block
 block discarded – undo
1067 1067
         $list = array();
1068 1068
     }
1069 1069
 
1070
-	if ( ! is_array( $list ) ) {
1071
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
1072
-	}
1070
+    if ( ! is_array( $list ) ) {
1071
+        return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
1072
+    }
1073 1073
 
1074
-	return $list;
1074
+    return $list;
1075 1075
 }
1076 1076
 
1077 1077
 /**
@@ -1091,9 +1091,9 @@  discard block
 block discarded – undo
1091 1091
     }
1092 1092
 
1093 1093
     $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
1094
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
1094
+    wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
1095 1095
 
1096
-	return $data;
1096
+    return $data;
1097 1097
 }
1098 1098
 
1099 1099
 /**
@@ -1122,17 +1122,17 @@  discard block
 block discarded – undo
1122 1122
  */
1123 1123
 function wpinv_clean( $var ) {
1124 1124
 
1125
-	if ( is_array( $var ) ) {
1126
-		return array_map( 'wpinv_clean', $var );
1125
+    if ( is_array( $var ) ) {
1126
+        return array_map( 'wpinv_clean', $var );
1127 1127
     }
1128 1128
 
1129 1129
     if ( is_object( $var ) ) {
1130
-		$object_vars = get_object_vars( $var );
1131
-		foreach ( $object_vars as $property_name => $property_value ) {
1132
-			$var->$property_name = wpinv_clean( $property_value );
1130
+        $object_vars = get_object_vars( $var );
1131
+        foreach ( $object_vars as $property_name => $property_value ) {
1132
+            $var->$property_name = wpinv_clean( $property_value );
1133 1133
         }
1134 1134
         return $var;
1135
-	}
1135
+    }
1136 1136
     
1137 1137
     return is_string( $var ) ? sanitize_text_field( $var ) : $var;
1138 1138
 }
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
  */
1146 1146
 function getpaid_convert_price_string_to_options( $str ) {
1147 1147
 
1148
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
1148
+    $raw_options = array_map( 'trim', explode( ',', $str ) );
1149 1149
     $options     = array();
1150 1150
 
1151 1151
     foreach ( $raw_options as $option ) {
@@ -1218,15 +1218,15 @@  discard block
 block discarded – undo
1218 1218
 function getpaid_limit_length( $string, $limit ) {
1219 1219
     $str_limit = $limit - 3;
1220 1220
 
1221
-	if ( function_exists( 'mb_strimwidth' ) ) {
1222
-		if ( mb_strlen( $string ) > $limit ) {
1223
-			$string = mb_strimwidth( $string, 0, $str_limit ) . '...';
1224
-		}
1225
-	} else {
1226
-		if ( strlen( $string ) > $limit ) {
1227
-			$string = substr( $string, 0, $str_limit ) . '...';
1228
-		}
1229
-	}
1221
+    if ( function_exists( 'mb_strimwidth' ) ) {
1222
+        if ( mb_strlen( $string ) > $limit ) {
1223
+            $string = mb_strimwidth( $string, 0, $str_limit ) . '...';
1224
+        }
1225
+    } else {
1226
+        if ( strlen( $string ) > $limit ) {
1227
+            $string = substr( $string, 0, $str_limit ) . '...';
1228
+        }
1229
+    }
1230 1230
     return $string;
1231 1231
 
1232 1232
 }
Please login to merge, or discard this patch.
includes/class-getpaid-payment-form.php 1 patch
Indentation   +507 added lines, -507 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,333 +114,333 @@  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
+            if ( $value instanceof GetPaid_Form_Item ) {
271 273
 
272
-			if ( $value instanceof GetPaid_Form_Item ) {
274
+                if ( $value->can_purchase() ) {
275
+                    $prepared[] = $value;
276
+                }
273 277
 
274
-				if ( $value->can_purchase() ) {
275
-					$prepared[] = $value;
276
-				}
278
+                continue;
277 279
 
278
-				continue;
280
+            }
279 281
 
280
-			}
282
+            // $item_id => $quantity
283
+            if ( is_numeric( $key ) && is_numeric( $value ) ) {
284
+                $item   = new GetPaid_Form_Item( $key );
281 285
 
282
-			// $item_id => $quantity
283
-			if ( is_numeric( $key ) && is_numeric( $value ) ) {
284
-				$item   = new GetPaid_Form_Item( $key );
286
+                if ( $item->can_purchase() ) {
287
+                    $item->set_quantity( $value );
288
+                    $prepared[] = $item;
289
+                }
285 290
 
286
-				if ( $item->can_purchase() ) {
287
-					$item->set_quantity( $value );
288
-					$prepared[] = $item;
289
-				}
291
+                continue;
292
+            }
290 293
 
291
-				continue;
292
-			}
294
+            if ( is_array( $value ) && isset( $value['id'] ) ) {
293 295
 
294
-			if ( is_array( $value ) && isset( $value['id'] ) ) {
296
+                $item = new GetPaid_Form_Item( $value['id'] );
295 297
 
296
-				$item = new GetPaid_Form_Item( $value['id'] );
298
+                if ( ! $item->can_purchase() ) {
299
+                    continue;
300
+                }
297 301
 
298
-				if ( ! $item->can_purchase() ) {
299
-					continue;
300
-				}
302
+                // Sub-total (Cart items).
303
+                if ( isset( $value['subtotal'] ) ) {
304
+                    $item->set_price( $value['subtotal'] );
305
+                }
301 306
 
302
-				// Sub-total (Cart items).
303
-				if ( isset( $value['subtotal'] ) ) {
304
-					$item->set_price( $value['subtotal'] );
305
-				}
307
+                if ( isset( $value['quantity'] ) ) {
308
+                    $item->set_quantity( $value['quantity'] );
309
+                }
310
+
311
+                if ( isset( $value['allow_quantities'] ) ) {
312
+                    $item->set_allow_quantities( $value['allow_quantities'] );
313
+                }
314
+
315
+                if ( isset( $value['required'] ) ) {
316
+                    $item->set_is_required( $value['required'] );
317
+                }
318
+
319
+                if ( isset( $value['description'] ) ) {
320
+                    $item->set_custom_description( $value['description'] );
321
+                }
322
+
323
+                $prepared[] = $item;
324
+                continue;
325
+
326
+            }
327
+        }
328
+
329
+        if ( 'objects' == $return && 'view' == $context ) {
330
+            return $prepared;
331
+        }
332
+
333
+        $items = array();
334
+        foreach ( $prepared as $item ) {
335
+            $items[] = $item->prepare_data_for_use();
336
+        }
337
+
338
+        return $items;
339
+    }
340
+
341
+    /**
342
+     * Get a single item belonging to the form.
343
+     *
344
+     * @since 1.0.19
345
+     * @param  int $item_id The item id to return.
346
+     * @return GetPaid_Form_Item|bool
347
+     */
348
+    public function get_item( $item_id ) {
349
+
350
+        if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
351
+            return false;
352
+        }
353
+
354
+        foreach( $this->get_items() as $item ) {
355
+            if ( $item->get_id() == (int) $item_id ) {
356
+                return $item;
357
+            }
358
+        }
359
+
360
+        return false;
361
+
362
+    }
363
+
364
+    /**
365
+     * Gets a single element.
366
+     *
367
+     * @since 1.0.19
368
+     * @param  string $element_type The element type to return.
369
+     * @return array|bool
370
+     */
371
+    public function get_element_type( $element_type ) {
372
+
373
+        if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
374
+            return false;
375
+        }
376
+
377
+        foreach ( $this->get_prop( 'elements' ) as $element ) {
378
+
379
+            if ( $element['type'] == $element_type ) {
380
+                return $element;
381
+            }
382
+
383
+        }
384
+
385
+        return false;
386
+
387
+    }
388
+
389
+    /**
390
+     * Get the total amount earned via this form.
391
+     *
392
+     * @since 1.0.19
393
+     * @param  string $context View or edit context.
394
+     * @return array
395
+     */
396
+    public function get_earned( $context = 'view' ) {
397
+        return $this->get_prop( 'earned', $context );
398
+    }
399
+
400
+    /**
401
+     * Get the total amount refunded via this form.
402
+     *
403
+     * @since 1.0.19
404
+     * @param  string $context View or edit context.
405
+     * @return array
406
+     */
407
+    public function get_refunded( $context = 'view' ) {
408
+        return $this->get_prop( 'refunded', $context );
409
+    }
306 410
 
307
-				if ( isset( $value['quantity'] ) ) {
308
-					$item->set_quantity( $value['quantity'] );
309
-				}
411
+    /**
412
+     * Get the total amount cancelled via this form.
413
+     *
414
+     * @since 1.0.19
415
+     * @param  string $context View or edit context.
416
+     * @return array
417
+     */
418
+    public function get_cancelled( $context = 'view' ) {
419
+        return $this->get_prop( 'cancelled', $context );
420
+    }
310 421
 
311
-				if ( isset( $value['allow_quantities'] ) ) {
312
-					$item->set_allow_quantities( $value['allow_quantities'] );
313
-				}
422
+    /**
423
+     * Get the total amount failed via this form.
424
+     *
425
+     * @since 1.0.19
426
+     * @param  string $context View or edit context.
427
+     * @return array
428
+     */
429
+    public function get_failed( $context = 'view' ) {
430
+        return $this->get_prop( 'failed', $context );
431
+    }
314 432
 
315
-				if ( isset( $value['required'] ) ) {
316
-					$item->set_is_required( $value['required'] );
317
-				}
318
-
319
-				if ( isset( $value['description'] ) ) {
320
-					$item->set_custom_description( $value['description'] );
321
-				}
322
-
323
-				$prepared[] = $item;
324
-				continue;
325
-
326
-			}
327
-		}
328
-
329
-		if ( 'objects' == $return && 'view' == $context ) {
330
-			return $prepared;
331
-		}
332
-
333
-		$items = array();
334
-		foreach ( $prepared as $item ) {
335
-			$items[] = $item->prepare_data_for_use();
336
-		}
337
-
338
-		return $items;
339
-	}
340
-
341
-	/**
342
-	 * Get a single item belonging to the form.
343
-	 *
344
-	 * @since 1.0.19
345
-	 * @param  int $item_id The item id to return.
346
-	 * @return GetPaid_Form_Item|bool
347
-	 */
348
-	public function get_item( $item_id ) {
349
-
350
-		if ( empty( $item_id ) || ! is_numeric( $item_id ) ) {
351
-			return false;
352
-		}
353
-
354
-		foreach( $this->get_items() as $item ) {
355
-			if ( $item->get_id() == (int) $item_id ) {
356
-				return $item;
357
-			}
358
-		}
359
-
360
-		return false;
361
-
362
-	}
363
-
364
-	/**
365
-	 * Gets a single element.
366
-	 *
367
-	 * @since 1.0.19
368
-	 * @param  string $element_type The element type to return.
369
-	 * @return array|bool
370
-	 */
371
-	public function get_element_type( $element_type ) {
372
-
373
-		if ( empty( $element_type ) || ! is_scalar( $element_type ) ) {
374
-			return false;
375
-		}
376
-
377
-		foreach ( $this->get_prop( 'elements' ) as $element ) {
378
-
379
-			if ( $element['type'] == $element_type ) {
380
-				return $element;
381
-			}
382
-
383
-		}
384
-
385
-		return false;
386
-
387
-	}
388
-
389
-	/**
390
-	 * Get the total amount earned via this form.
391
-	 *
392
-	 * @since 1.0.19
393
-	 * @param  string $context View or edit context.
394
-	 * @return array
395
-	 */
396
-	public function get_earned( $context = 'view' ) {
397
-		return $this->get_prop( 'earned', $context );
398
-	}
399
-
400
-	/**
401
-	 * Get the total amount refunded via this form.
402
-	 *
403
-	 * @since 1.0.19
404
-	 * @param  string $context View or edit context.
405
-	 * @return array
406
-	 */
407
-	public function get_refunded( $context = 'view' ) {
408
-		return $this->get_prop( 'refunded', $context );
409
-	}
410
-
411
-	/**
412
-	 * Get the total amount cancelled via this form.
413
-	 *
414
-	 * @since 1.0.19
415
-	 * @param  string $context View or edit context.
416
-	 * @return array
417
-	 */
418
-	public function get_cancelled( $context = 'view' ) {
419
-		return $this->get_prop( 'cancelled', $context );
420
-	}
421
-
422
-	/**
423
-	 * Get the total amount failed via this form.
424
-	 *
425
-	 * @since 1.0.19
426
-	 * @param  string $context View or edit context.
427
-	 * @return array
428
-	 */
429
-	public function get_failed( $context = 'view' ) {
430
-		return $this->get_prop( 'failed', $context );
431
-	}
432
-
433
-	/**
434
-	 * Get the currency.
435
-	 *
436
-	 * @since 1.0.19
437
-	 * @param  string $context View or edit context.
438
-	 * @return string
439
-	 */
440
-	public function get_currency() {
441
-		$currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
442
-		return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
443
-	}
433
+    /**
434
+     * Get the currency.
435
+     *
436
+     * @since 1.0.19
437
+     * @param  string $context View or edit context.
438
+     * @return string
439
+     */
440
+    public function get_currency() {
441
+        $currency = empty( $this->invoice ) ? wpinv_get_currency() : $this->invoice->get_currency();
442
+        return apply_filters( 'getpaid-payment-form-currency', $currency, $this );
443
+    }
444 444
 
445 445
     /*
446 446
 	|--------------------------------------------------------------------------
@@ -453,22 +453,22 @@  discard block
 block discarded – undo
453 453
     */
454 454
 
455 455
     /**
456
-	 * Set plugin version when the item was created.
457
-	 *
458
-	 * @since 1.0.19
459
-	 */
460
-	public function set_version( $value ) {
461
-		$this->set_prop( 'version', $value );
456
+     * Set plugin version when the item was created.
457
+     *
458
+     * @since 1.0.19
459
+     */
460
+    public function set_version( $value ) {
461
+        $this->set_prop( 'version', $value );
462 462
     }
463 463
 
464 464
     /**
465
-	 * Set date when the item was created.
466
-	 *
467
-	 * @since 1.0.19
468
-	 * @param string $value Value to set.
465
+     * Set date when the item was created.
466
+     *
467
+     * @since 1.0.19
468
+     * @param string $value Value to set.
469 469
      * @return bool Whether or not the date was set.
470
-	 */
471
-	public function set_date_created( $value ) {
470
+     */
471
+    public function set_date_created( $value ) {
472 472
         $date = strtotime( $value );
473 473
 
474 474
         if ( $date ) {
@@ -481,13 +481,13 @@  discard block
 block discarded – undo
481 481
     }
482 482
 
483 483
     /**
484
-	 * Set date when the item was last modified.
485
-	 *
486
-	 * @since 1.0.19
487
-	 * @param string $value Value to set.
484
+     * Set date when the item was last modified.
485
+     *
486
+     * @since 1.0.19
487
+     * @param string $value Value to set.
488 488
      * @return bool Whether or not the date was set.
489
-	 */
490
-	public function set_date_modified( $value ) {
489
+     */
490
+    public function set_date_modified( $value ) {
491 491
         $date = strtotime( $value );
492 492
 
493 493
         if ( $date ) {
@@ -500,118 +500,118 @@  discard block
 block discarded – undo
500 500
     }
501 501
 
502 502
     /**
503
-	 * Set the item name.
504
-	 *
505
-	 * @since 1.0.19
506
-	 * @param  string $value New name.
507
-	 */
508
-	public function set_name( $value ) {
509
-		$this->set_prop( 'name', sanitize_text_field( $value ) );
510
-    }
511
-
512
-    /**
513
-	 * Alias of self::set_name().
514
-	 *
515
-	 * @since 1.0.19
516
-	 * @param  string $value New name.
517
-	 */
518
-	public function set_title( $value ) {
519
-		$this->set_name( $value );
520
-    }
521
-
522
-    /**
523
-	 * Set the owner of the item.
524
-	 *
525
-	 * @since 1.0.19
526
-	 * @param  int $value New author.
527
-	 */
528
-	public function set_author( $value ) {
529
-		$this->set_prop( 'author', (int) $value );
530
-	}
531
-
532
-	/**
533
-	 * Set the form elements.
534
-	 *
535
-	 * @since 1.0.19
536
-	 * @param  array $value Form elements.
537
-	 */
538
-	public function set_elements( $value ) {
539
-		if ( is_array( $value ) ) {
540
-			$this->set_prop( 'elements', $value );
541
-		}
542
-	}
543
-
544
-	/**
545
-	 * Set the form items.
546
-	 *
547
-	 * @since 1.0.19
548
-	 * @param  array $value Form elements.
549
-	 */
550
-	public function set_items( $value ) {
551
-		if ( is_array( $value ) ) {
552
-			$this->set_prop( 'items', $value );
553
-		}
554
-	}
555
-
556
-	/**
557
-	 * Set the total amount earned via this form.
558
-	 *
559
-	 * @since 1.0.19
560
-	 * @param  float $value Amount earned.
561
-	 * @return array
562
-	 */
563
-	public function set_earned( $value ) {
564
-		return $this->set_prop( 'earned', (float) $value );
565
-	}
566
-
567
-	/**
568
-	 * Set the total amount refunded via this form.
569
-	 *
570
-	 * @since 1.0.19
571
-	 * @param  float $value Amount refunded.
572
-	 * @return array
573
-	 */
574
-	public function set_refunded( $value ) {
575
-		return $this->set_prop( 'refunded', (float) $value );
576
-	}
577
-
578
-	/**
579
-	 * Set the total amount cancelled via this form.
580
-	 *
581
-	 * @since 1.0.19
582
-	 * @param  float $value Amount cancelled.
583
-	 * @return array
584
-	 */
585
-	public function set_cancelled( $value ) {
586
-		return $this->set_prop( 'cancelled', (float) $value );
587
-	}
588
-
589
-	/**
590
-	 * Set the total amount failed via this form.
591
-	 *
592
-	 * @since 1.0.19
593
-	 * @param  float $value Amount cancelled.
594
-	 * @return array
595
-	 */
596
-	public function set_failed( $value ) {
597
-		return $this->set_prop( 'failed', (float) $value );
598
-	}
503
+     * Set the item name.
504
+     *
505
+     * @since 1.0.19
506
+     * @param  string $value New name.
507
+     */
508
+    public function set_name( $value ) {
509
+        $this->set_prop( 'name', sanitize_text_field( $value ) );
510
+    }
511
+
512
+    /**
513
+     * Alias of self::set_name().
514
+     *
515
+     * @since 1.0.19
516
+     * @param  string $value New name.
517
+     */
518
+    public function set_title( $value ) {
519
+        $this->set_name( $value );
520
+    }
521
+
522
+    /**
523
+     * Set the owner of the item.
524
+     *
525
+     * @since 1.0.19
526
+     * @param  int $value New author.
527
+     */
528
+    public function set_author( $value ) {
529
+        $this->set_prop( 'author', (int) $value );
530
+    }
531
+
532
+    /**
533
+     * Set the form elements.
534
+     *
535
+     * @since 1.0.19
536
+     * @param  array $value Form elements.
537
+     */
538
+    public function set_elements( $value ) {
539
+        if ( is_array( $value ) ) {
540
+            $this->set_prop( 'elements', $value );
541
+        }
542
+    }
543
+
544
+    /**
545
+     * Set the form items.
546
+     *
547
+     * @since 1.0.19
548
+     * @param  array $value Form elements.
549
+     */
550
+    public function set_items( $value ) {
551
+        if ( is_array( $value ) ) {
552
+            $this->set_prop( 'items', $value );
553
+        }
554
+    }
555
+
556
+    /**
557
+     * Set the total amount earned via this form.
558
+     *
559
+     * @since 1.0.19
560
+     * @param  float $value Amount earned.
561
+     * @return array
562
+     */
563
+    public function set_earned( $value ) {
564
+        return $this->set_prop( 'earned', (float) $value );
565
+    }
566
+
567
+    /**
568
+     * Set the total amount refunded via this form.
569
+     *
570
+     * @since 1.0.19
571
+     * @param  float $value Amount refunded.
572
+     * @return array
573
+     */
574
+    public function set_refunded( $value ) {
575
+        return $this->set_prop( 'refunded', (float) $value );
576
+    }
577
+
578
+    /**
579
+     * Set the total amount cancelled via this form.
580
+     *
581
+     * @since 1.0.19
582
+     * @param  float $value Amount cancelled.
583
+     * @return array
584
+     */
585
+    public function set_cancelled( $value ) {
586
+        return $this->set_prop( 'cancelled', (float) $value );
587
+    }
588
+
589
+    /**
590
+     * Set the total amount failed via this form.
591
+     *
592
+     * @since 1.0.19
593
+     * @param  float $value Amount cancelled.
594
+     * @return array
595
+     */
596
+    public function set_failed( $value ) {
597
+        return $this->set_prop( 'failed', (float) $value );
598
+    }
599 599
 
600 600
     /**
601 601
      * Create an item. For backwards compatibilty.
602 602
      *
603 603
      * @deprecated
604
-	 * @return int item id
604
+     * @return int item id
605 605
      */
606 606
     public function create( $data = array() ) {
607 607
 
608
-		// Set the properties.
609
-		if ( is_array( $data ) ) {
610
-			$this->set_props( $data );
611
-		}
608
+        // Set the properties.
609
+        if ( is_array( $data ) ) {
610
+            $this->set_props( $data );
611
+        }
612 612
 
613
-		// Save the item.
614
-		return $this->save();
613
+        // Save the item.
614
+        return $this->save();
615 615
 
616 616
     }
617 617
 
@@ -619,7 +619,7 @@  discard block
 block discarded – undo
619 619
      * Updates an item. For backwards compatibilty.
620 620
      *
621 621
      * @deprecated
622
-	 * @return int item id
622
+     * @return int item id
623 623
      */
624 624
     public function update( $data = array() ) {
625 625
         return $this->create( $data );
@@ -635,22 +635,22 @@  discard block
 block discarded – undo
635 635
 	*/
636 636
 
637 637
     /**
638
-	 * Checks whether this is the default payment form.
639
-	 *
640
-	 * @since 1.0.19
641
-	 * @return bool
642
-	 */
638
+     * Checks whether this is the default payment form.
639
+     *
640
+     * @since 1.0.19
641
+     * @return bool
642
+     */
643 643
     public function is_default() {
644 644
         $is_default = $this->get_id() == wpinv_get_default_payment_form();
645 645
         return (bool) apply_filters( 'wpinv_is_default_payment_form', $is_default, $this->get_id(), $this );
646
-	}
646
+    }
647 647
 
648 648
     /**
649
-	 * Checks whether the form is active.
650
-	 *
651
-	 * @since 1.0.19
652
-	 * @return bool
653
-	 */
649
+     * Checks whether the form is active.
650
+     *
651
+     * @since 1.0.19
652
+     * @return bool
653
+     */
654 654
     public function is_active() {
655 655
         $is_active = 0 !== (int) $this->get_id();
656 656
 
@@ -659,70 +659,70 @@  discard block
 block discarded – undo
659 659
         }
660 660
 
661 661
         return (bool) apply_filters( 'wpinv_is_payment_form_active', $is_active, $this );
662
-	}
663
-
664
-	/**
665
-	 * Checks whether the form has a given item.
666
-	 *
667
-	 * @since 1.0.19
668
-	 * @return bool
669
-	 */
662
+    }
663
+
664
+    /**
665
+     * Checks whether the form has a given item.
666
+     *
667
+     * @since 1.0.19
668
+     * @return bool
669
+     */
670 670
     public function has_item( $item_id ) {
671 671
         return false !== $this->get_item( $item_id );
672
-	}
673
-
674
-	/**
675
-	 * Checks whether the form has a given element.
676
-	 *
677
-	 * @since 1.0.19
678
-	 * @return bool
679
-	 */
672
+    }
673
+
674
+    /**
675
+     * Checks whether the form has a given element.
676
+     *
677
+     * @since 1.0.19
678
+     * @return bool
679
+     */
680 680
     public function has_element_type( $element_type ) {
681 681
         return false !== $this->get_element_type( $element_type );
682
-	}
683
-
684
-	/**
685
-	 * Checks whether this form is recurring or not.
686
-	 *
687
-	 * @since 1.0.19
688
-	 * @return bool
689
-	 */
682
+    }
683
+
684
+    /**
685
+     * Checks whether this form is recurring or not.
686
+     *
687
+     * @since 1.0.19
688
+     * @return bool
689
+     */
690 690
     public function is_recurring() {
691 691
 
692
-		if ( ! empty( $this->invoice ) ) {
693
-			return $this->invoice->is_recurring();
694
-		}
692
+        if ( ! empty( $this->invoice ) ) {
693
+            return $this->invoice->is_recurring();
694
+        }
695 695
 
696
-		foreach ( $this->get_items() as $item ) {
696
+        foreach ( $this->get_items() as $item ) {
697 697
 
698
-			if ( $item->is_recurring() ) {
699
-				return true;
700
-			}
698
+            if ( $item->is_recurring() ) {
699
+                return true;
700
+            }
701 701
 
702
-		}
702
+        }
703 703
 
704 704
         return false;
705
-	}
705
+    }
706 706
 
707
-	/**
708
-	 * Retrieves the form's html.
709
-	 *
710
-	 * @since 1.0.19
711
-	 */
707
+    /**
708
+     * Retrieves the form's html.
709
+     *
710
+     * @since 1.0.19
711
+     */
712 712
     public function get_html() {
713 713
 
714
-		// Return the HTML.
715
-		return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) );
714
+        // Return the HTML.
715
+        return wpinv_get_template_html( 'payment-forms/form.php', array( 'form' => $this ) );
716 716
 
717
-	}
717
+    }
718 718
 
719
-	/**
720
-	 * Displays the payment form.
721
-	 *
722
-	 * @since 1.0.19
723
-	 */
719
+    /**
720
+     * Displays the payment form.
721
+     *
722
+     * @since 1.0.19
723
+     */
724 724
     public function display() {
725
-		echo $this->get_html();
725
+        echo $this->get_html();
726 726
     }
727 727
 
728 728
 }
Please login to merge, or discard this patch.
includes/wpinv-subscription.php 1 patch
Indentation   +474 added lines, -474 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 
3 3
 // Exit if accessed directly
4 4
 if ( ! defined( 'ABSPATH' ) ) {
5
-	exit;
5
+    exit;
6 6
 }
7 7
 
8 8
 
@@ -13,187 +13,187 @@  discard block
 block discarded – undo
13 13
  */
14 14
 class WPInv_Subscription {
15 15
 
16
-	private $subs_db;
16
+    private $subs_db;
17
+
18
+    public $id                = 0;
19
+    public $customer_id       = 0;
20
+    public $period            = '';
21
+    public $initial_amount    = '';
22
+    public $recurring_amount  = '';
23
+    public $bill_times        = 0;
24
+    public $transaction_id    = '';
25
+    public $parent_payment_id = 0;
26
+    public $product_id        = 0;
27
+    public $created           = '0000-00-00 00:00:00';
28
+    public $expiration        = '0000-00-00 00:00:00';
29
+    public $trial_period      = '';
30
+    public $status            = 'pending';
31
+    public $profile_id        = '';
32
+    public $gateway           = '';
33
+    public $customer;
17 34
 
18
-	public $id                = 0;
19
-	public $customer_id       = 0;
20
-	public $period            = '';
21
-	public $initial_amount    = '';
22
-	public $recurring_amount  = '';
23
-	public $bill_times        = 0;
24
-	public $transaction_id    = '';
25
-	public $parent_payment_id = 0;
26
-	public $product_id        = 0;
27
-	public $created           = '0000-00-00 00:00:00';
28
-	public $expiration        = '0000-00-00 00:00:00';
29
-	public $trial_period      = '';
30
-	public $status            = 'pending';
31
-	public $profile_id        = '';
32
-	public $gateway           = '';
33
-	public $customer;
34
-
35
-	/**
36
-	 * Get us started
37
-	 *
38
-	 * @since  1.0.0
39
-	 * @return void
40
-	 */
41
-	function __construct( $_id_or_object = 0, $_by_profile_id = false ) {
35
+    /**
36
+     * Get us started
37
+     *
38
+     * @since  1.0.0
39
+     * @return void
40
+     */
41
+    function __construct( $_id_or_object = 0, $_by_profile_id = false ) {
42 42
 
43
-		$this->subs_db = new WPInv_Subscriptions_DB;
43
+        $this->subs_db = new WPInv_Subscriptions_DB;
44 44
 
45
-		if( $_by_profile_id ) {
45
+        if( $_by_profile_id ) {
46 46
 
47
-			$_sub = $this->subs_db->get_by( 'profile_id', $_id_or_object );
47
+            $_sub = $this->subs_db->get_by( 'profile_id', $_id_or_object );
48 48
 
49
-			if( empty( $_sub ) ) {
50
-				return false;
51
-			}
49
+            if( empty( $_sub ) ) {
50
+                return false;
51
+            }
52 52
 
53
-			$_id_or_object = $_sub;
53
+            $_id_or_object = $_sub;
54 54
 
55
-		}
55
+        }
56 56
 
57
-		return $this->setup_subscription( $_id_or_object );
58
-	}
57
+        return $this->setup_subscription( $_id_or_object );
58
+    }
59 59
 
60
-	/**
61
-	 * Setup the subscription object
62
-	 *
63
-	 * @since  1.0.0
64
-	 * @return void
65
-	 */
66
-	private function setup_subscription( $id_or_object = 0 ) {
60
+    /**
61
+     * Setup the subscription object
62
+     *
63
+     * @since  1.0.0
64
+     * @return void
65
+     */
66
+    private function setup_subscription( $id_or_object = 0 ) {
67 67
 
68
-		if( empty( $id_or_object ) ) {
69
-			return false;
70
-		}
68
+        if( empty( $id_or_object ) ) {
69
+            return false;
70
+        }
71 71
 
72
-		if( is_numeric( $id_or_object ) ) {
72
+        if( is_numeric( $id_or_object ) ) {
73 73
 
74
-			$sub = $this->subs_db->get( $id_or_object );
74
+            $sub = $this->subs_db->get( $id_or_object );
75 75
 
76
-		} elseif( is_object( $id_or_object ) ) {
76
+        } elseif( is_object( $id_or_object ) ) {
77 77
 
78
-			$sub = $id_or_object;
78
+            $sub = $id_or_object;
79 79
 
80
-		}
80
+        }
81 81
 
82
-		if( empty( $sub ) ) {
83
-			return false;
84
-		}
82
+        if( empty( $sub ) ) {
83
+            return false;
84
+        }
85 85
 
86
-		foreach( $sub as $key => $value ) {
87
-			$this->$key = $value;
88
-		}
86
+        foreach( $sub as $key => $value ) {
87
+            $this->$key = $value;
88
+        }
89 89
 
90
-		$this->customer = get_userdata( $this->customer_id );
91
-		$this->gateway  = wpinv_get_payment_gateway( $this->parent_payment_id );
90
+        $this->customer = get_userdata( $this->customer_id );
91
+        $this->gateway  = wpinv_get_payment_gateway( $this->parent_payment_id );
92 92
 
93
-		do_action( 'wpinv_recurring_setup_subscription', $this );
93
+        do_action( 'wpinv_recurring_setup_subscription', $this );
94 94
 
95
-		return $this;
96
-	}
95
+        return $this;
96
+    }
97 97
 
98
-	/**
99
-	 * Magic __get function to dispatch a call to retrieve a private property
100
-	 *
101
-	 * @since 1.0.0
102
-	 */
103
-	public function __get( $key ) {
98
+    /**
99
+     * Magic __get function to dispatch a call to retrieve a private property
100
+     *
101
+     * @since 1.0.0
102
+     */
103
+    public function __get( $key ) {
104 104
 
105
-		if( method_exists( $this, 'get_' . $key ) ) {
105
+        if( method_exists( $this, 'get_' . $key ) ) {
106 106
 
107
-			return call_user_func( array( $this, 'get_' . $key ) );
107
+            return call_user_func( array( $this, 'get_' . $key ) );
108 108
 
109
-		} else {
109
+        } else {
110 110
 
111
-			return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) );
111
+            return new WP_Error( 'wpinv-subscription-invalid-property', sprintf( __( 'Can\'t get property %s', 'invoicing' ), $key ) );
112 112
 
113
-		}
113
+        }
114 114
 
115
-	}
115
+    }
116 116
 
117
-	/**
118
-	 * Creates a subscription
119
-	 *
120
-	 * @since  1.0.0
121
-	 * @param  array  $data Array of attributes for a subscription
122
-	 * @return mixed  false if data isn't passed and class not instantiated for creation
123
-	 */
124
-	public function create( $data = array() ) {
117
+    /**
118
+     * Creates a subscription
119
+     *
120
+     * @since  1.0.0
121
+     * @param  array  $data Array of attributes for a subscription
122
+     * @return mixed  false if data isn't passed and class not instantiated for creation
123
+     */
124
+    public function create( $data = array() ) {
125 125
 
126
-		if ( $this->id != 0 ) {
127
-			return false;
128
-		}
126
+        if ( $this->id != 0 ) {
127
+            return false;
128
+        }
129 129
 
130
-		$defaults = array(
131
-			'customer_id'       => 0,
132
-			'frequency'         => '',
133
-			'period'            => '',
134
-			'initial_amount'    => '',
135
-			'recurring_amount'  => '',
136
-			'bill_times'        => 0,
137
-			'parent_payment_id' => 0,
138
-			'product_id'        => 0,
139
-			'created'           => '',
140
-			'expiration'        => '',
141
-			'status'            => '',
142
-			'profile_id'        => '',
143
-		);
130
+        $defaults = array(
131
+            'customer_id'       => 0,
132
+            'frequency'         => '',
133
+            'period'            => '',
134
+            'initial_amount'    => '',
135
+            'recurring_amount'  => '',
136
+            'bill_times'        => 0,
137
+            'parent_payment_id' => 0,
138
+            'product_id'        => 0,
139
+            'created'           => '',
140
+            'expiration'        => '',
141
+            'status'            => '',
142
+            'profile_id'        => '',
143
+        );
144 144
 
145
-		$args = wp_parse_args( $data, $defaults );
145
+        $args = wp_parse_args( $data, $defaults );
146 146
 
147
-		if( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) {
147
+        if( $args['expiration'] && strtotime( 'NOW', current_time( 'timestamp' ) ) > strtotime( $args['expiration'], current_time( 'timestamp' ) ) ) {
148 148
 
149
-			if( 'active' == $args['status'] || 'trialling' == $args['status'] ) {
149
+            if( 'active' == $args['status'] || 'trialling' == $args['status'] ) {
150 150
 
151
-				// Force an active subscription to expired if expiration date is in the past
152
-				$args['status'] = 'expired';
151
+                // Force an active subscription to expired if expiration date is in the past
152
+                $args['status'] = 'expired';
153 153
 
154
-			}
155
-		}
154
+            }
155
+        }
156 156
 
157
-		do_action( 'wpinv_subscription_pre_create', $args );
157
+        do_action( 'wpinv_subscription_pre_create', $args );
158 158
 
159
-		$id = $this->subs_db->insert( $args, 'subscription' );
159
+        $id = $this->subs_db->insert( $args, 'subscription' );
160 160
 
161
-		do_action( 'wpinv_subscription_post_create', $id, $args );
161
+        do_action( 'wpinv_subscription_post_create', $id, $args );
162 162
 
163
-		return $this->setup_subscription( $id );
163
+        return $this->setup_subscription( $id );
164 164
 
165
-	}
165
+    }
166 166
 
167
-	/**
168
-	 * Updates a subscription
169
-	 *
170
-	 * @since  1.0.0
171
-	 * @param  array $args Array of fields to update
172
-	 * @return bool
173
-	 */
174
-	public function update( $args = array() ) {
167
+    /**
168
+     * Updates a subscription
169
+     *
170
+     * @since  1.0.0
171
+     * @param  array $args Array of fields to update
172
+     * @return bool
173
+     */
174
+    public function update( $args = array() ) {
175 175
 
176
-		$ret = $this->subs_db->update( $this->id, $args );
176
+        $ret = $this->subs_db->update( $this->id, $args );
177 177
 
178
-		do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this );
178
+        do_action( 'wpinv_recurring_update_subscription', $this->id, $args, $this );
179 179
 
180
-		if ( $ret && isset( $args['profile_id'] ) ) {
181
-			update_post_meta( $this->parent_payment_id, 'subscription_id', $args['profile_id'] );
182
-		}
180
+        if ( $ret && isset( $args['profile_id'] ) ) {
181
+            update_post_meta( $this->parent_payment_id, 'subscription_id', $args['profile_id'] );
182
+        }
183 183
 
184
-		return $ret;
184
+        return $ret;
185 185
 
186
-	}
186
+    }
187 187
 
188
-	/**
189
-	 * Delete the subscription
190
-	 *
191
-	 * @since  1.0.0
192
-	 * @return bool
193
-	 */
194
-	public function delete() {
195
-		return $this->subs_db->delete( $this->id );
196
-	}
188
+    /**
189
+     * Delete the subscription
190
+     *
191
+     * @since  1.0.0
192
+     * @return bool
193
+     */
194
+    public function delete() {
195
+        return $this->subs_db->delete( $this->id );
196
+    }
197 197
 
198 198
     /**
199 199
      * Retrieves the parent payment ID
@@ -266,45 +266,45 @@  discard block
 block discarded – undo
266 266
      */
267 267
     public function add_payment( $args = array() ) {
268 268
 
269
-		// Do we have a parent invoice?
269
+        // Do we have a parent invoice?
270 270
         if ( ! $this->parent_payment_id || ! is_array( $args ) ) {
271 271
             return false;
272 272
         }
273 273
 
274
-		// Process each payment once.
274
+        // Process each payment once.
275 275
         if ( empty( $args['transaction_id'] ) || $this->payment_exists( $args['transaction_id'] ) ) {
276 276
             return false;
277 277
         }
278 278
 
279
-		// Ensure that the parent invoice is available.
279
+        // Ensure that the parent invoice is available.
280 280
         $parent_invoice = wpinv_get_invoice( $this->parent_payment_id );
281 281
         if ( ! $parent_invoice->get_id() ) {
282 282
             return false;
283 283
         }
284 284
 
285
-		// Duplicate the parent invoice.
286
-		$invoice = new WPInv_Invoice( $parent_invoice );
287
-		$invoice->set_id( 0 );
288
-		$invoice->set_parent_id( $parent_invoice->get_parent() );
289
-		$invoice->set_transaction_id( $args['transaction_id'] );
290
-		$invoice->set_key( $invoice->generate_key('renewal_') );
291
-		$invoice->set_number( '' );
292
-		$invoice->set_completed_date( current_time( 'mysql' ) );
293
-
294
-		if ( ! empty( $args['gateway'] ) ) {
295
-			$invoice->set_gateway( $args['gateway'] );
296
-		}
285
+        // Duplicate the parent invoice.
286
+        $invoice = new WPInv_Invoice( $parent_invoice );
287
+        $invoice->set_id( 0 );
288
+        $invoice->set_parent_id( $parent_invoice->get_parent() );
289
+        $invoice->set_transaction_id( $args['transaction_id'] );
290
+        $invoice->set_key( $invoice->generate_key('renewal_') );
291
+        $invoice->set_number( '' );
292
+        $invoice->set_completed_date( current_time( 'mysql' ) );
293
+
294
+        if ( ! empty( $args['gateway'] ) ) {
295
+            $invoice->set_gateway( $args['gateway'] );
296
+        }
297 297
 
298
-		$invoice->set_status( 'wpi-renewal' );
298
+        $invoice->set_status( 'wpi-renewal' );
299 299
 
300
-		$invoice->save();
300
+        $invoice->save();
301 301
 
302
-		if ( ! $invoice->get_id() ) {
303
-			return 0;
304
-		}
302
+        if ( ! $invoice->get_id() ) {
303
+            return 0;
304
+        }
305 305
 
306
-		do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
307
-		do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
306
+        do_action( 'getpaid_after_create_subscription_renewal_invoice', $invoice, $this );
307
+        do_action( 'wpinv_recurring_add_subscription_payment', $invoice, $this );
308 308
         do_action( 'wpinv_recurring_record_payment', $invoice->get_id(), $this->parent_payment_id, $invoice->get_recurring_total(), $invoice->get_transaction_id() );
309 309
 
310 310
         update_post_meta( $invoice->get_id(), '_wpinv_subscription_id', $this->id );
@@ -312,169 +312,169 @@  discard block
 block discarded – undo
312 312
         return $invoice->get_id();
313 313
     }
314 314
 
315
-	/**
316
-	 * Retrieves the transaction ID from the subscription
317
-	 *
318
-	 * @since  1.0.0
319
-	 * @return bool
320
-	 */
321
-	public function get_transaction_id() {
315
+    /**
316
+     * Retrieves the transaction ID from the subscription
317
+     *
318
+     * @since  1.0.0
319
+     * @return bool
320
+     */
321
+    public function get_transaction_id() {
322 322
 
323
-		if( empty( $this->transaction_id ) ) {
323
+        if( empty( $this->transaction_id ) ) {
324 324
 
325
-			$txn_id = wpinv_get_payment_transaction_id( $this->parent_payment_id );
325
+            $txn_id = wpinv_get_payment_transaction_id( $this->parent_payment_id );
326 326
 
327
-			if( ! empty( $txn_id ) && (int) $this->parent_payment_id !== (int) $txn_id ) {
328
-				$this->set_transaction_id( $txn_id );
329
-			}
327
+            if( ! empty( $txn_id ) && (int) $this->parent_payment_id !== (int) $txn_id ) {
328
+                $this->set_transaction_id( $txn_id );
329
+            }
330 330
 
331
-		}
331
+        }
332 332
 
333
-		return $this->transaction_id;
333
+        return $this->transaction_id;
334 334
 
335
-	}
335
+    }
336 336
 
337
-	/**
338
-	 * Stores the transaction ID for the subscription purchase
339
-	 *
340
-	 * @since  1.0.0.4
341
-	 * @return bool
342
-	 */
343
-	public function set_transaction_id( $txn_id = '' ) {
344
-		$this->update( array( 'transaction_id' => $txn_id ) );
345
-		$this->transaction_id = $txn_id;
346
-	}
337
+    /**
338
+     * Stores the transaction ID for the subscription purchase
339
+     *
340
+     * @since  1.0.0.4
341
+     * @return bool
342
+     */
343
+    public function set_transaction_id( $txn_id = '' ) {
344
+        $this->update( array( 'transaction_id' => $txn_id ) );
345
+        $this->transaction_id = $txn_id;
346
+    }
347 347
 
348
-	/**
349
-	 * Renews a subscription
350
-	 *
351
-	 * @since  1.0.0
352
-	 * @return bool
353
-	 */
354
-	public function renew() {
348
+    /**
349
+     * Renews a subscription
350
+     *
351
+     * @since  1.0.0
352
+     * @return bool
353
+     */
354
+    public function renew() {
355 355
 
356
-		// Calculate new expiration
357
-		$expires        = $this->get_expiration_time();
358
-		$base_date      = $expires > current_time( 'timestamp' ) ? $expires : current_time( 'timestamp' );
359
-		$frequency      = isset( $this->frequency ) ? $this->frequency : 1;
360
-		$new_expiration = strtotime( "+ {$frequency} {$this->period}", strtotime( $base_date ) );
361
-		$new_expiration = apply_filters( 'wpinv_subscription_renewal_expiration', date( 'Y-m-d H:i:s', $new_expiration ), $this->id, $this );
356
+        // Calculate new expiration
357
+        $expires        = $this->get_expiration_time();
358
+        $base_date      = $expires > current_time( 'timestamp' ) ? $expires : current_time( 'timestamp' );
359
+        $frequency      = isset( $this->frequency ) ? $this->frequency : 1;
360
+        $new_expiration = strtotime( "+ {$frequency} {$this->period}", strtotime( $base_date ) );
361
+        $new_expiration = apply_filters( 'wpinv_subscription_renewal_expiration', date( 'Y-m-d H:i:s', $new_expiration ), $this->id, $this );
362 362
 
363
-		do_action( 'wpinv_subscription_pre_renew', $this->id, $new_expiration, $this );
363
+        do_action( 'wpinv_subscription_pre_renew', $this->id, $new_expiration, $this );
364 364
 
365
-		$this->status = 'active';
366
-		$times_billed = $this->get_times_billed();
365
+        $this->status = 'active';
366
+        $times_billed = $this->get_times_billed();
367 367
 
368
-		// Complete subscription if applicable
369
-		if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) {
370
-			$this->complete();
371
-			$this->status = 'completed';
372
-			return;
373
-		}
368
+        // Complete subscription if applicable
369
+        if ( $this->bill_times > 0 && $times_billed >= $this->bill_times ) {
370
+            $this->complete();
371
+            $this->status = 'completed';
372
+            return;
373
+        }
374 374
 
375
-		$args = array(
376
-			'expiration' => $new_expiration,
377
-			'status'     => $this->status,
378
-		);
375
+        $args = array(
376
+            'expiration' => $new_expiration,
377
+            'status'     => $this->status,
378
+        );
379 379
 
380 380
         $this->subs_db->update( $this->id, $args );
381 381
 
382
-		$this->expiration = $new_expiration;
382
+        $this->expiration = $new_expiration;
383 383
 
384
-		do_action( 'wpinv_subscription_post_renew', $this->id, $new_expiration, $this );
385
-		do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this );
384
+        do_action( 'wpinv_subscription_post_renew', $this->id, $new_expiration, $this );
385
+        do_action( 'wpinv_recurring_set_subscription_status', $this->id, $this->status, $this );
386 386
 
387
-	}
387
+    }
388 388
 
389
-	/**
390
-	 * Marks a subscription as completed
391
-	 *
392
-	 * Subscription is completed when the number of payments matches the billing_times field
393
-	 *
394
-	 * @since  1.0.0
395
-	 * @return void
396
-	 */
397
-	public function complete() {
389
+    /**
390
+     * Marks a subscription as completed
391
+     *
392
+     * Subscription is completed when the number of payments matches the billing_times field
393
+     *
394
+     * @since  1.0.0
395
+     * @return void
396
+     */
397
+    public function complete() {
398 398
 
399
-		// Only mark a subscription as complete if it's not already cancelled.
400
-		if ( 'cancelled' === $this->status ) {
401
-			return;
402
-		}
399
+        // Only mark a subscription as complete if it's not already cancelled.
400
+        if ( 'cancelled' === $this->status ) {
401
+            return;
402
+        }
403 403
 
404
-		$args = array(
405
-			'status' => 'completed'
406
-		);
404
+        $args = array(
405
+            'status' => 'completed'
406
+        );
407 407
 
408
-		if( $this->subs_db->update( $this->id, $args ) ) {
408
+        if( $this->subs_db->update( $this->id, $args ) ) {
409 409
 
410
-			$this->status = 'completed';
410
+            $this->status = 'completed';
411 411
 
412
-			do_action( 'wpinv_subscription_completed', $this->id, $this );
412
+            do_action( 'wpinv_subscription_completed', $this->id, $this );
413 413
 
414
-		}
414
+        }
415 415
 
416
-	}
416
+    }
417 417
 
418
-	/**
419
-	 * Marks a subscription as expired
420
-	 *
421
-	 * Subscription is completed when the billing times is reached
422
-	 *
423
-	 * @since  1.0.0
424
-	 * @param  $check_expiration bool True if expiration date should be checked with merchant processor before expiring
425
-	 * @return void
426
-	 */
427
-	public function expire( $check_expiration = false ) {
418
+    /**
419
+     * Marks a subscription as expired
420
+     *
421
+     * Subscription is completed when the billing times is reached
422
+     *
423
+     * @since  1.0.0
424
+     * @param  $check_expiration bool True if expiration date should be checked with merchant processor before expiring
425
+     * @return void
426
+     */
427
+    public function expire( $check_expiration = false ) {
428 428
 
429
-		$expiration = $this->expiration;
429
+        $expiration = $this->expiration;
430 430
 
431
-		if( $check_expiration ) {
431
+        if( $check_expiration ) {
432 432
 
433
-			// check_expiration() updates $this->expiration so compare to $expiration above
433
+            // check_expiration() updates $this->expiration so compare to $expiration above
434 434
 
435
-			if( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) {
435
+            if( $expiration < $this->get_expiration() && current_time( 'timestamp' ) < $this->get_expiration_time() ) {
436 436
 
437
-				return false; // Do not mark as expired since real expiration date is in the future
438
-			}
437
+                return false; // Do not mark as expired since real expiration date is in the future
438
+            }
439 439
 
440
-		}
440
+        }
441 441
 
442
-		$args = array(
443
-			'status' => 'expired'
444
-		);
442
+        $args = array(
443
+            'status' => 'expired'
444
+        );
445 445
 
446
-		if( $this->subs_db->update( $this->id, $args ) ) {
446
+        if( $this->subs_db->update( $this->id, $args ) ) {
447 447
 
448
-			$this->status = 'expired';
448
+            $this->status = 'expired';
449 449
 
450
-			do_action( 'wpinv_subscription_expired', $this->id, $this );
450
+            do_action( 'wpinv_subscription_expired', $this->id, $this );
451 451
 
452
-		}
452
+        }
453 453
 
454
-	}
454
+    }
455 455
 
456
-	/**
457
-	 * Marks a subscription as failing
458
-	 *
459
-	 * @since  2.4.2
460
-	 * @return void
461
-	 */
462
-	public function failing() {
456
+    /**
457
+     * Marks a subscription as failing
458
+     *
459
+     * @since  2.4.2
460
+     * @return void
461
+     */
462
+    public function failing() {
463 463
 
464
-		$args = array(
465
-			'status' => 'failing'
466
-		);
464
+        $args = array(
465
+            'status' => 'failing'
466
+        );
467 467
 
468
-		if( $this->subs_db->update( $this->id, $args ) ) {
468
+        if( $this->subs_db->update( $this->id, $args ) ) {
469 469
 
470
-			$this->status = 'failing';
470
+            $this->status = 'failing';
471 471
 
472
-			do_action( 'wpinv_subscription_failing', $this->id, $this );
473
-			do_action( 'wpinv_recurring_payment_failed', $this );
472
+            do_action( 'wpinv_subscription_failing', $this->id, $this );
473
+            do_action( 'wpinv_recurring_payment_failed', $this );
474 474
 
475
-		}
475
+        }
476 476
 
477
-	}
477
+    }
478 478
 
479 479
     /**
480 480
      * Marks a subscription as cancelled
@@ -508,22 +508,22 @@  discard block
 block discarded – undo
508 508
         }
509 509
     }
510 510
 
511
-	/**
512
-	 * Determines if subscription can be cancelled
513
-	 *
514
-	 * This method is filtered by payment gateways in order to return true on subscriptions
515
-	 * that can be cancelled with a profile ID through the merchant processor
516
-	 *
517
-	 * @since  1.0.0
518
-	 * @return bool
519
-	 */
520
-	public function can_cancel() {
511
+    /**
512
+     * Determines if subscription can be cancelled
513
+     *
514
+     * This method is filtered by payment gateways in order to return true on subscriptions
515
+     * that can be cancelled with a profile ID through the merchant processor
516
+     *
517
+     * @since  1.0.0
518
+     * @return bool
519
+     */
520
+    public function can_cancel() {
521 521
         $ret = false;
522
-	    if( $this->gateway === 'manual' || in_array( $this->status, $this->get_cancellable_statuses() ) ) {
522
+        if( $this->gateway === 'manual' || in_array( $this->status, $this->get_cancellable_statuses() ) ) {
523 523
             $ret = true;
524 524
         }
525
-		return apply_filters( 'wpinv_subscription_can_cancel', $ret, $this );
526
-	}
525
+        return apply_filters( 'wpinv_subscription_can_cancel', $ret, $this );
526
+    }
527 527
 
528 528
     /**
529 529
      * Returns an array of subscription statuses that can be cancelled
@@ -536,197 +536,197 @@  discard block
 block discarded – undo
536 536
         return apply_filters( 'wpinv_recurring_cancellable_statuses', array( 'active', 'trialling', 'failing' ) );
537 537
     }
538 538
 
539
-	/**
540
-	 * Retrieves the URL to cancel subscription
541
-	 *
542
-	 * @since  1.0.0
543
-	 * @return string
544
-	 */
545
-	public function get_cancel_url() {
539
+    /**
540
+     * Retrieves the URL to cancel subscription
541
+     *
542
+     * @since  1.0.0
543
+     * @return string
544
+     */
545
+    public function get_cancel_url() {
546 546
 
547
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' );
547
+        $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'cancel_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-cancel' );
548 548
 
549
-		return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
550
-	}
549
+        return apply_filters( 'wpinv_subscription_cancel_url', $url, $this );
550
+    }
551 551
 
552
-	/**
553
-	 * Determines if subscription can be manually renewed
554
-	 *
555
-	 * This method is filtered by payment gateways in order to return true on subscriptions
556
-	 * that can be renewed manually
557
-	 *
558
-	 * @since  2.5
559
-	 * @return bool
560
-	 */
561
-	public function can_renew() {
552
+    /**
553
+     * Determines if subscription can be manually renewed
554
+     *
555
+     * This method is filtered by payment gateways in order to return true on subscriptions
556
+     * that can be renewed manually
557
+     *
558
+     * @since  2.5
559
+     * @return bool
560
+     */
561
+    public function can_renew() {
562 562
 
563
-		return apply_filters( 'wpinv_subscription_can_renew', true, $this );
564
-	}
565
-
566
-	/**
567
-	 * Retrieves the URL to renew a subscription
568
-	 *
569
-	 * @since  2.5
570
-	 * @return string
571
-	 */
572
-	public function get_renew_url() {
573
-
574
-		$url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' );
575
-
576
-		return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
577
-	}
578
-
579
-	/**
580
-	 * Determines if subscription can have their payment method updated
581
-	 *
582
-	 * @since  1.0.0
583
-	 * @return bool
584
-	 */
585
-	public function can_update() {
586
-		return apply_filters( 'wpinv_subscription_can_update', false, $this );
587
-	}
588
-
589
-	/**
590
-	 * Retrieves the URL to update subscription
591
-	 *
592
-	 * @since  1.0.0
593
-	 * @return void
594
-	 */
595
-	public function get_update_url() {
596
-
597
-		$url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) );
598
-
599
-		return apply_filters( 'wpinv_subscription_update_url', $url, $this );
600
-	}
601
-
602
-	/**
603
-	 * Determines if subscription is active
604
-	 *
605
-	 * @since  1.0.0
606
-	 * @return void
607
-	 */
608
-	public function is_active() {
609
-
610
-		$ret = false;
611
-
612
-		if( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) {
613
-			$ret = true;
614
-		}
615
-
616
-		return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this );
617
-
618
-	}
619
-
620
-	/**
621
-	 * Determines if subscription is expired
622
-	 *
623
-	 * @since  1.0.0
624
-	 * @return void
625
-	 */
626
-	public function is_expired() {
627
-
628
-		$ret = false;
629
-
630
-		if ( $this->status == 'expired' ) {
631
-
632
-			$ret = true;
633
-
634
-		} elseif( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling'  ) {
635
-
636
-			$ret        = false;
637
-			$expiration = $this->get_expiration_time();
638
-
639
-			if( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) {
640
-				$ret = true;
641
-
642
-				if ( 'active' === $this->status || $this->status == 'trialling'  ) {
643
-					$this->expire();
644
-				}
645
-			}
646
-
647
-		}
648
-
649
-		return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this );
650
-
651
-	}
652
-
653
-	/**
654
-	 * Retrieves the expiration date
655
-	 *
656
-	 * @since  1.0.0
657
-	 * @return string
658
-	 */
659
-	public function get_expiration() {
660
-		return $this->expiration;
661
-	}
662
-
663
-	/**
664
-	 * Retrieves the expiration date in a timestamp
665
-	 *
666
-	 * @since  1.0.0
667
-	 * @return int
668
-	 */
669
-	public function get_expiration_time() {
670
-		return strtotime( $this->expiration, current_time( 'timestamp' ) );
671
-	}
672
-
673
-	/**
674
-	 * Retrieves the subscription status
675
-	 *
676
-	 * @since  1.0.0
677
-	 * @return int
678
-	 */
679
-	public function get_status() {
680
-
681
-		// Monitor for page load delays on pages with large subscription lists (IE: Subscriptions table in admin)
682
-		$this->is_expired();
683
-		return $this->status;
684
-	}
685
-
686
-	/**
687
-	 * Retrieves the subscription status label
688
-	 *
689
-	 * @since  1.0.0
690
-	 * @return int
691
-	 */
692
-	public function get_status_label() {
693
-
694
-		switch( $this->get_status() ) {
695
-			case 'active' :
696
-				$status = __( 'Active', 'invoicing' );
697
-				break;
698
-
699
-			case 'cancelled' :
700
-				$status = __( 'Cancelled', 'invoicing' );
701
-				break;
702
-
703
-			case 'expired' :
704
-				$status = __( 'Expired', 'invoicing' );
705
-				break;
706
-
707
-			case 'pending' :
708
-				$status = __( 'Pending', 'invoicing' );
709
-				break;
710
-
711
-			case 'failing' :
712
-				$status = __( 'Failing', 'invoicing' );
713
-				break;
714
-
715
-			case 'trialling' :
716
-				$status = __( 'Trialling', 'invoicing' );
717
-				break;
718
-
719
-			case 'completed' :
720
-				$status = __( 'Completed', 'invoicing' );
721
-				break;
722
-
723
-			default:
724
-				$status = ucfirst( $this->get_status() );
725
-				break;
726
-		}
727
-
728
-		return $status;
729
-	}
563
+        return apply_filters( 'wpinv_subscription_can_renew', true, $this );
564
+    }
565
+
566
+    /**
567
+     * Retrieves the URL to renew a subscription
568
+     *
569
+     * @since  2.5
570
+     * @return string
571
+     */
572
+    public function get_renew_url() {
573
+
574
+        $url = wp_nonce_url( add_query_arg( array( 'wpinv_action' => 'renew_subscription', 'sub_id' => $this->id ) ), 'wpinv-recurring-renew' );
575
+
576
+        return apply_filters( 'wpinv_subscription_renew_url', $url, $this );
577
+    }
578
+
579
+    /**
580
+     * Determines if subscription can have their payment method updated
581
+     *
582
+     * @since  1.0.0
583
+     * @return bool
584
+     */
585
+    public function can_update() {
586
+        return apply_filters( 'wpinv_subscription_can_update', false, $this );
587
+    }
588
+
589
+    /**
590
+     * Retrieves the URL to update subscription
591
+     *
592
+     * @since  1.0.0
593
+     * @return void
594
+     */
595
+    public function get_update_url() {
596
+
597
+        $url = add_query_arg( array( 'action' => 'update', 'subscription_id' => $this->id ) );
598
+
599
+        return apply_filters( 'wpinv_subscription_update_url', $url, $this );
600
+    }
601
+
602
+    /**
603
+     * Determines if subscription is active
604
+     *
605
+     * @since  1.0.0
606
+     * @return void
607
+     */
608
+    public function is_active() {
609
+
610
+        $ret = false;
611
+
612
+        if( ! $this->is_expired() && ( $this->status == 'active' || $this->status == 'cancelled' || $this->status == 'trialling' ) ) {
613
+            $ret = true;
614
+        }
615
+
616
+        return apply_filters( 'wpinv_subscription_is_active', $ret, $this->id, $this );
617
+
618
+    }
619
+
620
+    /**
621
+     * Determines if subscription is expired
622
+     *
623
+     * @since  1.0.0
624
+     * @return void
625
+     */
626
+    public function is_expired() {
627
+
628
+        $ret = false;
629
+
630
+        if ( $this->status == 'expired' ) {
631
+
632
+            $ret = true;
633
+
634
+        } elseif( 'active' === $this->status || 'cancelled' === $this->status || $this->status == 'trialling'  ) {
635
+
636
+            $ret        = false;
637
+            $expiration = $this->get_expiration_time();
638
+
639
+            if( $expiration && strtotime( 'NOW', current_time( 'timestamp' ) ) > $expiration ) {
640
+                $ret = true;
641
+
642
+                if ( 'active' === $this->status || $this->status == 'trialling'  ) {
643
+                    $this->expire();
644
+                }
645
+            }
646
+
647
+        }
648
+
649
+        return apply_filters( 'wpinv_subscription_is_expired', $ret, $this->id, $this );
650
+
651
+    }
652
+
653
+    /**
654
+     * Retrieves the expiration date
655
+     *
656
+     * @since  1.0.0
657
+     * @return string
658
+     */
659
+    public function get_expiration() {
660
+        return $this->expiration;
661
+    }
662
+
663
+    /**
664
+     * Retrieves the expiration date in a timestamp
665
+     *
666
+     * @since  1.0.0
667
+     * @return int
668
+     */
669
+    public function get_expiration_time() {
670
+        return strtotime( $this->expiration, current_time( 'timestamp' ) );
671
+    }
672
+
673
+    /**
674
+     * Retrieves the subscription status
675
+     *
676
+     * @since  1.0.0
677
+     * @return int
678
+     */
679
+    public function get_status() {
680
+
681
+        // Monitor for page load delays on pages with large subscription lists (IE: Subscriptions table in admin)
682
+        $this->is_expired();
683
+        return $this->status;
684
+    }
685
+
686
+    /**
687
+     * Retrieves the subscription status label
688
+     *
689
+     * @since  1.0.0
690
+     * @return int
691
+     */
692
+    public function get_status_label() {
693
+
694
+        switch( $this->get_status() ) {
695
+            case 'active' :
696
+                $status = __( 'Active', 'invoicing' );
697
+                break;
698
+
699
+            case 'cancelled' :
700
+                $status = __( 'Cancelled', 'invoicing' );
701
+                break;
702
+
703
+            case 'expired' :
704
+                $status = __( 'Expired', 'invoicing' );
705
+                break;
706
+
707
+            case 'pending' :
708
+                $status = __( 'Pending', 'invoicing' );
709
+                break;
710
+
711
+            case 'failing' :
712
+                $status = __( 'Failing', 'invoicing' );
713
+                break;
714
+
715
+            case 'trialling' :
716
+                $status = __( 'Trialling', 'invoicing' );
717
+                break;
718
+
719
+            case 'completed' :
720
+                $status = __( 'Completed', 'invoicing' );
721
+                break;
722
+
723
+            default:
724
+                $status = ucfirst( $this->get_status() );
725
+                break;
726
+        }
727
+
728
+        return $status;
729
+    }
730 730
 
731 731
     /**
732 732
      * Retrieves the subscription status label
Please login to merge, or discard this patch.
includes/class-getpaid-form-item.php 1 patch
Indentation   +348 added lines, -348 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,60 +10,60 @@  discard block
 block discarded – undo
10 10
 class GetPaid_Form_Item  extends WPInv_Item {
11 11
 
12 12
     /**
13
-	 * Stores a custom description for the item.
14
-	 *
15
-	 * @var string
16
-	 */
17
-	protected $custom_description = null;
18
-
19
-	/**
20
-	 * Stores the item quantity.
21
-	 *
22
-	 * @var int
23
-	 */
24
-	protected $quantity = 1;
25
-
26
-	/**
27
-	 * Stores the item meta.
28
-	 *
29
-	 * @var array
30
-	 */
31
-	protected $meta = array();
32
-
33
-	/**
34
-	 * Is this item required?
35
-	 *
36
-	 * @var int
37
-	 */
38
-	protected $is_required = true;
39
-
40
-	/**
41
-	 * Are quantities allowed?
42
-	 *
43
-	 * @var int
44
-	 */
45
-	protected $allow_quantities = false;
46
-
47
-	/**
48
-	 * Associated invoice.
49
-	 *
50
-	 * @var int
51
-	 */
52
-	public $invoice_id = 0;
53
-
54
-	/**
55
-	 * Item discount.
56
-	 *
57
-	 * @var float
58
-	 */
59
-	public $item_discount = 0;
60
-
61
-	/**
62
-	 * Item tax.
63
-	 *
64
-	 * @var float
65
-	 */
66
-	public $item_tax = 0;
13
+     * Stores a custom description for the item.
14
+     *
15
+     * @var string
16
+     */
17
+    protected $custom_description = null;
18
+
19
+    /**
20
+     * Stores the item quantity.
21
+     *
22
+     * @var int
23
+     */
24
+    protected $quantity = 1;
25
+
26
+    /**
27
+     * Stores the item meta.
28
+     *
29
+     * @var array
30
+     */
31
+    protected $meta = array();
32
+
33
+    /**
34
+     * Is this item required?
35
+     *
36
+     * @var int
37
+     */
38
+    protected $is_required = true;
39
+
40
+    /**
41
+     * Are quantities allowed?
42
+     *
43
+     * @var int
44
+     */
45
+    protected $allow_quantities = false;
46
+
47
+    /**
48
+     * Associated invoice.
49
+     *
50
+     * @var int
51
+     */
52
+    public $invoice_id = 0;
53
+
54
+    /**
55
+     * Item discount.
56
+     *
57
+     * @var float
58
+     */
59
+    public $item_discount = 0;
60
+
61
+    /**
62
+     * Item tax.
63
+     *
64
+     * @var float
65
+     */
66
+    public $item_tax = 0;
67 67
 
68 68
     /*
69 69
 	|--------------------------------------------------------------------------
@@ -81,226 +81,226 @@  discard block
 block discarded – undo
81 81
     */
82 82
 
83 83
     /**
84
-	 * Get the item name.
85
-	 *
86
-	 * @since 1.0.19
87
-	 * @param  string $context View or edit context.
88
-	 * @return string
89
-	 */
90
-	public function get_name( $context = 'view' ) {
91
-		$name = parent::get_name( $context );
92
-		return $name . wpinv_get_item_suffix( $this );
93
-	}
94
-
95
-	/**
96
-	 * Get the item name without a suffix.
97
-	 *
98
-	 * @since 1.0.19
99
-	 * @param  string $context View or edit context.
100
-	 * @return string
101
-	 */
102
-	public function get_raw_name( $context = 'view' ) {
103
-		return parent::get_name( $context );
104
-	}
105
-
106
-	/**
107
-	 * Get the item description.
108
-	 *
109
-	 * @since 1.0.19
110
-	 * @param  string $context View or edit context.
111
-	 * @return string
112
-	 */
113
-	public function get_description( $context = 'view' ) {
114
-
115
-		if ( isset( $this->custom_description ) ) {
116
-			return $this->custom_description;
117
-		}
118
-
119
-		return parent::get_description( $context );
120
-	}
121
-
122
-	/**
123
-	 * Returns the sub total.
124
-	 *
125
-	 * @since 1.0.19
126
-	 * @param  string $context View or edit context.
127
-	 * @return int
128
-	 */
129
-	public function get_sub_total( $context = 'view' ) {
130
-		return $this->get_quantity( $context ) * $this->get_initial_price( $context );
131
-	}
132
-
133
-	/**
134
-	 * Returns the recurring sub total.
135
-	 *
136
-	 * @since 1.0.19
137
-	 * @param  string $context View or edit context.
138
-	 * @return int
139
-	 */
140
-	public function get_recurring_sub_total( $context = 'view' ) {
141
-		return $this->get_quantity( $context ) * $this->get_price( $context );
142
-	}
143
-
144
-	/**
145
-	 * @deprecated
146
-	 */
147
-	public function get_qantity( $context = 'view' ) {
148
-		return $this->get_quantity( $context );
149
-	}
150
-
151
-	/**
152
-	 * Get the item quantity.
153
-	 *
154
-	 * @since 1.0.19
155
-	 * @param  string $context View or edit context.
156
-	 * @return int
157
-	 */
158
-	public function get_quantity( $context = 'view' ) {
159
-		$quantity = (int) $this->quantity;
160
-
161
-		if ( empty( $quantity ) || 1 > $quantity ) {
162
-			$quantity = 1;
163
-		}
164
-
165
-		if ( 'view' == $context ) {
166
-			return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this );
167
-		}
168
-
169
-		return $quantity;
170
-
171
-	}
172
-
173
-	/**
174
-	 * Get the item meta data.
175
-	 *
176
-	 * @since 1.0.19
177
-	 * @param  string $context View or edit context.
178
-	 * @return meta
179
-	 */
180
-	public function get_item_meta( $context = 'view' ) {
181
-		$meta = $this->meta;
182
-
183
-		if ( 'view' == $context ) {
184
-			return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this );
185
-		}
186
-
187
-		return $meta;
188
-
189
-	}
190
-
191
-	/**
192
-	 * Returns whether or not customers can update the item quantity.
193
-	 *
194
-	 * @since 1.0.19
195
-	 * @param  string $context View or edit context.
196
-	 * @return bool
197
-	 */
198
-	public function get_allow_quantities( $context = 'view' ) {
199
-		$allow_quantities = (bool) $this->allow_quantities;
200
-
201
-		if ( 'view' == $context ) {
202
-			return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this );
203
-		}
204
-
205
-		return $allow_quantities;
206
-
207
-	}
208
-
209
-	/**
210
-	 * Returns whether or not the item is required.
211
-	 *
212
-	 * @since 1.0.19
213
-	 * @param  string $context View or edit context.
214
-	 * @return bool
215
-	 */
216
-	public function get_is_required( $context = 'view' ) {
217
-		$is_required = (bool) $this->is_required;
218
-
219
-		if ( 'view' == $context ) {
220
-			return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this );
221
-		}
222
-
223
-		return $is_required;
224
-
225
-	}
226
-
227
-	/**
228
-	 * Prepares form data for use.
229
-	 *
230
-	 * @since 1.0.19
231
-	 * @return array
232
-	 */
233
-	public function prepare_data_for_use() {
234
-
235
-		return array(
236
-			'title'            => sanitize_text_field( $this->get_name() ),
237
-			'id'               => $this->get_id(),
238
-			'price'            => $this->get_price(),
239
-			'recurring'        => $this->is_recurring(),
240
-			'description'      => $this->get_description(),
241
-			'allow_quantities' => $this->allows_quantities(),
242
-			'required'         => $this->is_required(),
243
-		);
244
-
245
-	}
246
-
247
-	/**
248
-	 * Prepares form data for ajax use.
249
-	 *
250
-	 * @since 1.0.19
251
-	 * @return array
252
-	 */
253
-	public function prepare_data_for_invoice_edit_ajax( $currency = '' ) {
254
-
255
-		$description = getpaid_item_recurring_price_help_text( $this, $currency );
256
-
257
-		if ( $description ) {
258
-			$description = "<div class='getpaid-subscription-help-text'>$description</div>";
259
-		}
260
-
261
-		return array(
262
-			'id'     => $this->get_id(),
263
-			'texts'  => array(
264
-				'item-name'        => sanitize_text_field( $this->get_name() ),
265
-				'item-description' => wp_kses_post( $this->get_description() ) . $description,
266
-				'item-quantity'    => absint( $this->get_quantity() ),
267
-				'item-price'       => wpinv_price( wpinv_format_amount ( $this->get_price() ), $currency ),
268
-				'item-total'       => wpinv_price( wpinv_format_amount( $this->get_sub_total() ), $currency ),
269
-			),
270
-			'inputs' => array(
271
-				'item-id'          => $this->get_id(),
272
-				'item-name'        => sanitize_text_field( $this->get_name() ),
273
-				'item-description' => wp_kses_post( $this->get_description() ),
274
-				'item-quantity'    => absint( $this->get_quantity() ),
275
-				'item-price'       => $this->get_price(),
276
-			)
277
-		);
278
-
279
-	}
280
-
281
-	/**
282
-	 * Prepares form data for saving (cart_details).
283
-	 *
284
-	 * @since 1.0.19
285
-	 * @return array
286
-	 */
287
-	public function prepare_data_for_saving() {
288
-
289
-		return array(
290
-			'post_id'           => $this->invoice_id,
291
-			'item_id'           => $this->get_id(),
292
-			'item_name'         => sanitize_text_field( $this->get_raw_name() ),
293
-			'item_description'  => $this->get_description(),
294
-			'tax'               => $this->item_tax,
295
-			'item_price'        => $this->get_price(),
296
-			'quantity'          => (int) $this->get_quantity(),
297
-			'discount'          => $this->item_discount,
298
-			'subtotal'          => $this->get_sub_total(),
299
-			'price'             => $this->get_sub_total() + $this->item_tax + $this->item_discount,
300
-			'meta'              => $this->get_item_meta(),
301
-		);
302
-
303
-	}
84
+     * Get the item name.
85
+     *
86
+     * @since 1.0.19
87
+     * @param  string $context View or edit context.
88
+     * @return string
89
+     */
90
+    public function get_name( $context = 'view' ) {
91
+        $name = parent::get_name( $context );
92
+        return $name . wpinv_get_item_suffix( $this );
93
+    }
94
+
95
+    /**
96
+     * Get the item name without a suffix.
97
+     *
98
+     * @since 1.0.19
99
+     * @param  string $context View or edit context.
100
+     * @return string
101
+     */
102
+    public function get_raw_name( $context = 'view' ) {
103
+        return parent::get_name( $context );
104
+    }
105
+
106
+    /**
107
+     * Get the item description.
108
+     *
109
+     * @since 1.0.19
110
+     * @param  string $context View or edit context.
111
+     * @return string
112
+     */
113
+    public function get_description( $context = 'view' ) {
114
+
115
+        if ( isset( $this->custom_description ) ) {
116
+            return $this->custom_description;
117
+        }
118
+
119
+        return parent::get_description( $context );
120
+    }
121
+
122
+    /**
123
+     * Returns the sub total.
124
+     *
125
+     * @since 1.0.19
126
+     * @param  string $context View or edit context.
127
+     * @return int
128
+     */
129
+    public function get_sub_total( $context = 'view' ) {
130
+        return $this->get_quantity( $context ) * $this->get_initial_price( $context );
131
+    }
132
+
133
+    /**
134
+     * Returns the recurring sub total.
135
+     *
136
+     * @since 1.0.19
137
+     * @param  string $context View or edit context.
138
+     * @return int
139
+     */
140
+    public function get_recurring_sub_total( $context = 'view' ) {
141
+        return $this->get_quantity( $context ) * $this->get_price( $context );
142
+    }
143
+
144
+    /**
145
+     * @deprecated
146
+     */
147
+    public function get_qantity( $context = 'view' ) {
148
+        return $this->get_quantity( $context );
149
+    }
150
+
151
+    /**
152
+     * Get the item quantity.
153
+     *
154
+     * @since 1.0.19
155
+     * @param  string $context View or edit context.
156
+     * @return int
157
+     */
158
+    public function get_quantity( $context = 'view' ) {
159
+        $quantity = (int) $this->quantity;
160
+
161
+        if ( empty( $quantity ) || 1 > $quantity ) {
162
+            $quantity = 1;
163
+        }
164
+
165
+        if ( 'view' == $context ) {
166
+            return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this );
167
+        }
168
+
169
+        return $quantity;
170
+
171
+    }
172
+
173
+    /**
174
+     * Get the item meta data.
175
+     *
176
+     * @since 1.0.19
177
+     * @param  string $context View or edit context.
178
+     * @return meta
179
+     */
180
+    public function get_item_meta( $context = 'view' ) {
181
+        $meta = $this->meta;
182
+
183
+        if ( 'view' == $context ) {
184
+            return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this );
185
+        }
186
+
187
+        return $meta;
188
+
189
+    }
190
+
191
+    /**
192
+     * Returns whether or not customers can update the item quantity.
193
+     *
194
+     * @since 1.0.19
195
+     * @param  string $context View or edit context.
196
+     * @return bool
197
+     */
198
+    public function get_allow_quantities( $context = 'view' ) {
199
+        $allow_quantities = (bool) $this->allow_quantities;
200
+
201
+        if ( 'view' == $context ) {
202
+            return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this );
203
+        }
204
+
205
+        return $allow_quantities;
206
+
207
+    }
208
+
209
+    /**
210
+     * Returns whether or not the item is required.
211
+     *
212
+     * @since 1.0.19
213
+     * @param  string $context View or edit context.
214
+     * @return bool
215
+     */
216
+    public function get_is_required( $context = 'view' ) {
217
+        $is_required = (bool) $this->is_required;
218
+
219
+        if ( 'view' == $context ) {
220
+            return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this );
221
+        }
222
+
223
+        return $is_required;
224
+
225
+    }
226
+
227
+    /**
228
+     * Prepares form data for use.
229
+     *
230
+     * @since 1.0.19
231
+     * @return array
232
+     */
233
+    public function prepare_data_for_use() {
234
+
235
+        return array(
236
+            'title'            => sanitize_text_field( $this->get_name() ),
237
+            'id'               => $this->get_id(),
238
+            'price'            => $this->get_price(),
239
+            'recurring'        => $this->is_recurring(),
240
+            'description'      => $this->get_description(),
241
+            'allow_quantities' => $this->allows_quantities(),
242
+            'required'         => $this->is_required(),
243
+        );
244
+
245
+    }
246
+
247
+    /**
248
+     * Prepares form data for ajax use.
249
+     *
250
+     * @since 1.0.19
251
+     * @return array
252
+     */
253
+    public function prepare_data_for_invoice_edit_ajax( $currency = '' ) {
254
+
255
+        $description = getpaid_item_recurring_price_help_text( $this, $currency );
256
+
257
+        if ( $description ) {
258
+            $description = "<div class='getpaid-subscription-help-text'>$description</div>";
259
+        }
260
+
261
+        return array(
262
+            'id'     => $this->get_id(),
263
+            'texts'  => array(
264
+                'item-name'        => sanitize_text_field( $this->get_name() ),
265
+                'item-description' => wp_kses_post( $this->get_description() ) . $description,
266
+                'item-quantity'    => absint( $this->get_quantity() ),
267
+                'item-price'       => wpinv_price( wpinv_format_amount ( $this->get_price() ), $currency ),
268
+                'item-total'       => wpinv_price( wpinv_format_amount( $this->get_sub_total() ), $currency ),
269
+            ),
270
+            'inputs' => array(
271
+                'item-id'          => $this->get_id(),
272
+                'item-name'        => sanitize_text_field( $this->get_name() ),
273
+                'item-description' => wp_kses_post( $this->get_description() ),
274
+                'item-quantity'    => absint( $this->get_quantity() ),
275
+                'item-price'       => $this->get_price(),
276
+            )
277
+        );
278
+
279
+    }
280
+
281
+    /**
282
+     * Prepares form data for saving (cart_details).
283
+     *
284
+     * @since 1.0.19
285
+     * @return array
286
+     */
287
+    public function prepare_data_for_saving() {
288
+
289
+        return array(
290
+            'post_id'           => $this->invoice_id,
291
+            'item_id'           => $this->get_id(),
292
+            'item_name'         => sanitize_text_field( $this->get_raw_name() ),
293
+            'item_description'  => $this->get_description(),
294
+            'tax'               => $this->item_tax,
295
+            'item_price'        => $this->get_price(),
296
+            'quantity'          => (int) $this->get_quantity(),
297
+            'discount'          => $this->item_discount,
298
+            'subtotal'          => $this->get_sub_total(),
299
+            'price'             => $this->get_sub_total() + $this->item_tax + $this->item_discount,
300
+            'meta'              => $this->get_item_meta(),
301
+        );
302
+
303
+    }
304 304
 
305 305
     /*
306 306
 	|--------------------------------------------------------------------------
@@ -312,70 +312,70 @@  discard block
 block discarded – undo
312 312
 	| object.
313 313
     */
314 314
 
315
-	/**
316
-	 * Set the item qantity.
317
-	 *
318
-	 * @since 1.0.19
319
-	 * @param  int $quantity The item quantity.
320
-	 */
321
-	public function set_quantity( $quantity ) {
322
-
323
-		if ( empty( $quantity ) || ! is_numeric( $quantity ) ) {
324
-			$quantity = 1;
325
-		}
326
-
327
-		$this->quantity = (int) $quantity;
328
-
329
-	}
330
-
331
-	/**
332
-	 * Set the item meta data.
333
-	 *
334
-	 * @since 1.0.19
335
-	 * @param  array $meta The item meta data.
336
-	 */
337
-	public function set_item_meta( $meta ) {
338
-		$this->meta = maybe_unserialize( $meta );
339
-	}
340
-
341
-	/**
342
-	 * Set whether or not the quantities are allowed.
343
-	 *
344
-	 * @since 1.0.19
345
-	 * @param  bool $allow_quantities
346
-	 */
347
-	public function set_allow_quantities( $allow_quantities ) {
348
-		$this->allow_quantities = (bool) $allow_quantities;
349
-	}
350
-
351
-	/**
352
-	 * Set whether or not the item is required.
353
-	 *
354
-	 * @since 1.0.19
355
-	 * @param  bool $is_required
356
-	 */
357
-	public function set_is_required( $is_required ) {
358
-		$this->is_required = (bool) $is_required;
359
-	}
360
-
361
-	/**
362
-	 * Sets the custom item description.
363
-	 *
364
-	 * @since 1.0.19
365
-	 * @param  string $description
366
-	 */
367
-	public function set_custom_description( $description ) {
368
-		$this->custom_description = $description;
369
-	}
315
+    /**
316
+     * Set the item qantity.
317
+     *
318
+     * @since 1.0.19
319
+     * @param  int $quantity The item quantity.
320
+     */
321
+    public function set_quantity( $quantity ) {
322
+
323
+        if ( empty( $quantity ) || ! is_numeric( $quantity ) ) {
324
+            $quantity = 1;
325
+        }
326
+
327
+        $this->quantity = (int) $quantity;
328
+
329
+    }
330
+
331
+    /**
332
+     * Set the item meta data.
333
+     *
334
+     * @since 1.0.19
335
+     * @param  array $meta The item meta data.
336
+     */
337
+    public function set_item_meta( $meta ) {
338
+        $this->meta = maybe_unserialize( $meta );
339
+    }
340
+
341
+    /**
342
+     * Set whether or not the quantities are allowed.
343
+     *
344
+     * @since 1.0.19
345
+     * @param  bool $allow_quantities
346
+     */
347
+    public function set_allow_quantities( $allow_quantities ) {
348
+        $this->allow_quantities = (bool) $allow_quantities;
349
+    }
350
+
351
+    /**
352
+     * Set whether or not the item is required.
353
+     *
354
+     * @since 1.0.19
355
+     * @param  bool $is_required
356
+     */
357
+    public function set_is_required( $is_required ) {
358
+        $this->is_required = (bool) $is_required;
359
+    }
360
+
361
+    /**
362
+     * Sets the custom item description.
363
+     *
364
+     * @since 1.0.19
365
+     * @param  string $description
366
+     */
367
+    public function set_custom_description( $description ) {
368
+        $this->custom_description = $description;
369
+    }
370 370
 
371 371
     /**
372 372
      * We do not want to save items to the database.
373 373
      * 
374
-	 * @return int item id
374
+     * @return int item id
375 375
      */
376 376
     public function save( $data = array() ) {
377 377
         return $this->get_id();
378
-	}
378
+    }
379 379
 
380 380
     /*
381 381
 	|--------------------------------------------------------------------------
@@ -387,23 +387,23 @@  discard block
 block discarded – undo
387 387
 	*/
388 388
 
389 389
     /**
390
-	 * Checks whether the item has enabled dynamic pricing.
391
-	 *
392
-	 * @since 1.0.19
393
-	 * @return bool
394
-	 */
395
-	public function is_required() {
390
+     * Checks whether the item has enabled dynamic pricing.
391
+     *
392
+     * @since 1.0.19
393
+     * @return bool
394
+     */
395
+    public function is_required() {
396 396
         return (bool) $this->get_is_required();
397
-	}
398
-
399
-	/**
400
-	 * Checks whether users can edit the quantities.
401
-	 *
402
-	 * @since 1.0.19
403
-	 * @return bool
404
-	 */
405
-	public function allows_quantities() {
397
+    }
398
+
399
+    /**
400
+     * Checks whether users can edit the quantities.
401
+     *
402
+     * @since 1.0.19
403
+     * @return bool
404
+     */
405
+    public function allows_quantities() {
406 406
         return (bool) $this->get_allow_quantities();
407
-	}
407
+    }
408 408
 
409 409
 }
Please login to merge, or discard this patch.