Passed
Push — master ( b3b246...bcec86 )
by Brian
05:30
created
includes/class-wpinv-invoice.php 2 patches
Indentation   +2333 added lines, -2333 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'            => 0,
38
-		'status'               => 'wpi-pending',
39
-		'version'              => '',
40
-		'date_created'         => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'            => 0,
38
+        'status'               => 'wpi-pending',
39
+        'version'              => '',
40
+        'date_created'         => null,
41 41
         'date_modified'        => null,
42 42
         'due_date'             => null,
43 43
         'completed_date'       => null,
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
         'transaction_id'       => '',
80 80
         'currency'             => '',
81 81
         'disable_taxes'        => false,
82
-		'subscription_id'      => null,
83
-		'remote_subscription_id' => null,
84
-		'is_viewed'            => false,
85
-		'email_cc'             => '',
86
-		'template'             => 'quantity', // hours, amount only
82
+        'subscription_id'      => null,
83
+        'remote_subscription_id' => null,
84
+        'is_viewed'            => false,
85
+        'email_cc'             => '',
86
+        'template'             => 'quantity', // hours, amount only
87 87
     );
88 88
 
89 89
     /**
90
-	 * Stores meta in cache for future reads.
91
-	 *
92
-	 * A group must be set to to enable caching.
93
-	 *
94
-	 * @var string
95
-	 */
96
-	protected $cache_group = 'getpaid_invoices';
90
+     * Stores meta in cache for future reads.
91
+     *
92
+     * A group must be set to to enable caching.
93
+     *
94
+     * @var string
95
+     */
96
+    protected $cache_group = 'getpaid_invoices';
97 97
 
98 98
     /**
99 99
      * Stores a reference to the original WP_Post object
@@ -107,104 +107,104 @@  discard block
 block discarded – undo
107 107
      *
108 108
      * @var int
109 109
      */
110
-	protected $recurring_item = null;
110
+    protected $recurring_item = null;
111 111
 
112
-	/**
112
+    /**
113 113
      * Stores an array of item totals.
114
-	 *
115
-	 * e.g $totals['discount'] = array(
116
-	 * 		'initial'   => 10,
117
-	 * 		'recurring' => 10,
118
-	 * )
114
+     *
115
+     * e.g $totals['discount'] = array(
116
+     * 		'initial'   => 10,
117
+     * 		'recurring' => 10,
118
+     * )
119 119
      *
120 120
      * @var array
121 121
      */
122
-	protected $totals = array();
122
+    protected $totals = array();
123 123
 
124
-	/**
125
-	 * Stores the status transition information.
126
-	 *
127
-	 * @since 1.0.19
128
-	 * @var bool
129
-	 */
130
-	protected $status_transition = false;
124
+    /**
125
+     * Stores the status transition information.
126
+     *
127
+     * @since 1.0.19
128
+     * @var bool
129
+     */
130
+    protected $status_transition = false;
131 131
 
132 132
     /**
133
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
134
-	 *
135
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
136
-	 */
133
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
134
+     *
135
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
136
+     */
137 137
     public function __construct( $invoice = false ) {
138 138
 
139 139
         parent::__construct( $invoice );
140 140
 
141
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
142
-			$this->set_id( $invoice );
143
-		} elseif ( $invoice instanceof self ) {
144
-			$this->set_id( $invoice->get_id() );
145
-		} elseif ( ! empty( $invoice->ID ) ) {
146
-			$this->set_id( $invoice->ID );
147
-		} elseif ( is_array( $invoice ) ) {
148
-			$this->set_props( $invoice );
149
-
150
-			if ( isset( $invoice['ID'] ) ) {
151
-				$this->set_id( $invoice['ID'] );
152
-			}
153
-
154
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
155
-			$this->set_id( $invoice_id );
156
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
157
-			$this->set_id( $invoice_id );
158
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
159
-			$this->set_id( $invoice_id );
160
-		}else {
161
-			$this->set_object_read( true );
162
-		}
141
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
142
+            $this->set_id( $invoice );
143
+        } elseif ( $invoice instanceof self ) {
144
+            $this->set_id( $invoice->get_id() );
145
+        } elseif ( ! empty( $invoice->ID ) ) {
146
+            $this->set_id( $invoice->ID );
147
+        } elseif ( is_array( $invoice ) ) {
148
+            $this->set_props( $invoice );
149
+
150
+            if ( isset( $invoice['ID'] ) ) {
151
+                $this->set_id( $invoice['ID'] );
152
+            }
153
+
154
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
155
+            $this->set_id( $invoice_id );
156
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
157
+            $this->set_id( $invoice_id );
158
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
159
+            $this->set_id( $invoice_id );
160
+        }else {
161
+            $this->set_object_read( true );
162
+        }
163 163
 
164 164
         // Load the datastore.
165
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
165
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
166 166
 
167
-		if ( $this->get_id() > 0 ) {
167
+        if ( $this->get_id() > 0 ) {
168 168
             $this->post = get_post( $this->get_id() );
169 169
             $this->ID   = $this->get_id();
170
-			$this->data_store->read( $this );
170
+            $this->data_store->read( $this );
171 171
         }
172 172
 
173 173
     }
174 174
 
175 175
     /**
176
-	 * Given an invoice key/number, it returns its id.
177
-	 *
178
-	 *
179
-	 * @static
180
-	 * @param string $value The invoice key or number
181
-	 * @param string $field Either key, transaction_id or number.
182
-	 * @since 1.0.15
183
-	 * @return int
184
-	 */
185
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
176
+     * Given an invoice key/number, it returns its id.
177
+     *
178
+     *
179
+     * @static
180
+     * @param string $value The invoice key or number
181
+     * @param string $field Either key, transaction_id or number.
182
+     * @since 1.0.15
183
+     * @return int
184
+     */
185
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
186 186
         global $wpdb;
187 187
 
188
-		// Trim the value.
189
-		$value = trim( $value );
188
+        // Trim the value.
189
+        $value = trim( $value );
190 190
 
191
-		if ( empty( $value ) ) {
192
-			return 0;
193
-		}
191
+        if ( empty( $value ) ) {
192
+            return 0;
193
+        }
194 194
 
195 195
         // Valid fields.
196 196
         $fields = array( 'key', 'number', 'transaction_id' );
197 197
 
198
-		// Ensure a field has been passed.
199
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
200
-			return 0;
201
-		}
198
+        // Ensure a field has been passed.
199
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
200
+            return 0;
201
+        }
202 202
 
203
-		// Maybe retrieve from the cache.
204
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
205
-		if ( false !== $invoice_id ) {
206
-			return $invoice_id;
207
-		}
203
+        // Maybe retrieve from the cache.
204
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
205
+        if ( false !== $invoice_id ) {
206
+            return $invoice_id;
207
+        }
208 208
 
209 209
         // Fetch from the db.
210 210
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
213 213
         );
214 214
 
215
-		// Update the cache with our data
216
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
+        // Update the cache with our data
216
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
217 217
 
218
-		return $invoice_id;
218
+        return $invoice_id;
219 219
     }
220 220
 
221 221
     /**
@@ -241,80 +241,80 @@  discard block
 block discarded – undo
241 241
     */
242 242
 
243 243
     /**
244
-	 * Get parent invoice ID.
245
-	 *
246
-	 * @since 1.0.19
247
-	 * @param  string $context View or edit context.
248
-	 * @return int
249
-	 */
250
-	public function get_parent_id( $context = 'view' ) {
251
-		return (int) $this->get_prop( 'parent_id', $context );
244
+     * Get parent invoice ID.
245
+     *
246
+     * @since 1.0.19
247
+     * @param  string $context View or edit context.
248
+     * @return int
249
+     */
250
+    public function get_parent_id( $context = 'view' ) {
251
+        return (int) $this->get_prop( 'parent_id', $context );
252 252
     }
253 253
 
254 254
     /**
255
-	 * Get parent invoice.
256
-	 *
257
-	 * @since 1.0.19
258
-	 * @return WPInv_Invoice
259
-	 */
255
+     * Get parent invoice.
256
+     *
257
+     * @since 1.0.19
258
+     * @return WPInv_Invoice
259
+     */
260 260
     public function get_parent_payment() {
261 261
         return new WPInv_Invoice( $this->get_parent_id() );
262 262
     }
263 263
 
264 264
     /**
265
-	 * Alias for self::get_parent_payment().
266
-	 *
267
-	 * @since 1.0.19
268
-	 * @return WPInv_Invoice
269
-	 */
265
+     * Alias for self::get_parent_payment().
266
+     *
267
+     * @since 1.0.19
268
+     * @return WPInv_Invoice
269
+     */
270 270
     public function get_parent() {
271 271
         return $this->get_parent_payment();
272 272
     }
273 273
 
274 274
     /**
275
-	 * Get invoice status.
276
-	 *
277
-	 * @since 1.0.19
278
-	 * @param  string $context View or edit context.
279
-	 * @return string
280
-	 */
281
-	public function get_status( $context = 'view' ) {
282
-		return $this->get_prop( 'status', $context );
283
-	}
275
+     * Get invoice status.
276
+     *
277
+     * @since 1.0.19
278
+     * @param  string $context View or edit context.
279
+     * @return string
280
+     */
281
+    public function get_status( $context = 'view' ) {
282
+        return $this->get_prop( 'status', $context );
283
+    }
284 284
 	
285
-	/**
286
-	 * Retrieves an array of possible invoice statuses.
287
-	 *
288
-	 * @since 1.0.19
289
-	 * @return array
290
-	 */
291
-	public function get_all_statuses() {
292
-
293
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
294
-
295
-		// For backwards compatibility.
296
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
285
+    /**
286
+     * Retrieves an array of possible invoice statuses.
287
+     *
288
+     * @since 1.0.19
289
+     * @return array
290
+     */
291
+    public function get_all_statuses() {
292
+
293
+        $statuses = wpinv_get_invoice_statuses( true, true, $this );
294
+
295
+        // For backwards compatibility.
296
+        if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
297 297
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
298
-		}
298
+        }
299 299
 
300
-		return $statuses;
300
+        return $statuses;
301 301
     }
302 302
 
303 303
     /**
304
-	 * Get invoice status nice name.
305
-	 *
306
-	 * @since 1.0.19
307
-	 * @return string
308
-	 */
304
+     * Get invoice status nice name.
305
+     *
306
+     * @since 1.0.19
307
+     * @return string
308
+     */
309 309
     public function get_status_nicename() {
310
-		$statuses = $this->get_all_statuses();
310
+        $statuses = $this->get_all_statuses();
311 311
 
312 312
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
313 313
 
314 314
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
315 315
     }
316 316
 
317
-	/**
317
+    /**
318 318
      * Retrieves the invoice status label html
319 319
      *
320 320
      * @since  1.0.0
@@ -322,262 +322,262 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public function get_status_label_html() {
324 324
 
325
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
326
-		$status       = sanitize_html_class( $this->get_status() );
325
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
326
+        $status       = sanitize_html_class( $this->get_status() );
327 327
 
328
-		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
329
-	}
328
+        return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
329
+    }
330 330
 
331 331
     /**
332
-	 * Get plugin version when the invoice was created.
333
-	 *
334
-	 * @since 1.0.19
335
-	 * @param  string $context View or edit context.
336
-	 * @return string
337
-	 */
338
-	public function get_version( $context = 'view' ) {
339
-		return $this->get_prop( 'version', $context );
340
-	}
332
+     * Get plugin version when the invoice was created.
333
+     *
334
+     * @since 1.0.19
335
+     * @param  string $context View or edit context.
336
+     * @return string
337
+     */
338
+    public function get_version( $context = 'view' ) {
339
+        return $this->get_prop( 'version', $context );
340
+    }
341 341
 
342
-	/**
343
-	 * @deprecated
344
-	 */
345
-	public function get_invoice_date( $format = true ) {
346
-		$date      = getpaid_format_date( $this->get_date_completed() );
347
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
348
-		$formatted = getpaid_format_date( $date );
342
+    /**
343
+     * @deprecated
344
+     */
345
+    public function get_invoice_date( $format = true ) {
346
+        $date      = getpaid_format_date( $this->get_date_completed() );
347
+        $date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
348
+        $formatted = getpaid_format_date( $date );
349 349
 
350
-		if ( $format ) {
351
-			return $formatted;
352
-		}
350
+        if ( $format ) {
351
+            return $formatted;
352
+        }
353 353
 
354
-		return empty( $formatted ) ? '' : $date;
354
+        return empty( $formatted ) ? '' : $date;
355 355
 
356 356
     }
357 357
 
358 358
     /**
359
-	 * Get date when the invoice was created.
360
-	 *
361
-	 * @since 1.0.19
362
-	 * @param  string $context View or edit context.
363
-	 * @return string
364
-	 */
365
-	public function get_date_created( $context = 'view' ) {
366
-		return $this->get_prop( 'date_created', $context );
367
-	}
359
+     * Get date when the invoice was created.
360
+     *
361
+     * @since 1.0.19
362
+     * @param  string $context View or edit context.
363
+     * @return string
364
+     */
365
+    public function get_date_created( $context = 'view' ) {
366
+        return $this->get_prop( 'date_created', $context );
367
+    }
368 368
 	
369
-	/**
370
-	 * Alias for self::get_date_created().
371
-	 *
372
-	 * @since 1.0.19
373
-	 * @param  string $context View or edit context.
374
-	 * @return string
375
-	 */
376
-	public function get_created_date( $context = 'view' ) {
377
-		return $this->get_date_created( $context );
378
-    }
379
-
380
-    /**
381
-	 * Get GMT date when the invoice was created.
382
-	 *
383
-	 * @since 1.0.19
384
-	 * @param  string $context View or edit context.
385
-	 * @return string
386
-	 */
387
-	public function get_date_created_gmt( $context = 'view' ) {
369
+    /**
370
+     * Alias for self::get_date_created().
371
+     *
372
+     * @since 1.0.19
373
+     * @param  string $context View or edit context.
374
+     * @return string
375
+     */
376
+    public function get_created_date( $context = 'view' ) {
377
+        return $this->get_date_created( $context );
378
+    }
379
+
380
+    /**
381
+     * Get GMT date when the invoice was created.
382
+     *
383
+     * @since 1.0.19
384
+     * @param  string $context View or edit context.
385
+     * @return string
386
+     */
387
+    public function get_date_created_gmt( $context = 'view' ) {
388 388
         $date = $this->get_date_created( $context );
389 389
 
390 390
         if ( $date ) {
391 391
             $date = get_gmt_from_date( $date );
392 392
         }
393
-		return $date;
393
+        return $date;
394 394
     }
395 395
 
396 396
     /**
397
-	 * Get date when the invoice was last modified.
398
-	 *
399
-	 * @since 1.0.19
400
-	 * @param  string $context View or edit context.
401
-	 * @return string
402
-	 */
403
-	public function get_date_modified( $context = 'view' ) {
404
-		return $this->get_prop( 'date_modified', $context );
405
-	}
397
+     * Get date when the invoice was last modified.
398
+     *
399
+     * @since 1.0.19
400
+     * @param  string $context View or edit context.
401
+     * @return string
402
+     */
403
+    public function get_date_modified( $context = 'view' ) {
404
+        return $this->get_prop( 'date_modified', $context );
405
+    }
406 406
 
407
-	/**
408
-	 * Alias for self::get_date_modified().
409
-	 *
410
-	 * @since 1.0.19
411
-	 * @param  string $context View or edit context.
412
-	 * @return string
413
-	 */
414
-	public function get_modified_date( $context = 'view' ) {
415
-		return $this->get_date_modified( $context );
407
+    /**
408
+     * Alias for self::get_date_modified().
409
+     *
410
+     * @since 1.0.19
411
+     * @param  string $context View or edit context.
412
+     * @return string
413
+     */
414
+    public function get_modified_date( $context = 'view' ) {
415
+        return $this->get_date_modified( $context );
416 416
     }
417 417
 
418 418
     /**
419
-	 * Get GMT date when the invoice was last modified.
420
-	 *
421
-	 * @since 1.0.19
422
-	 * @param  string $context View or edit context.
423
-	 * @return string
424
-	 */
425
-	public function get_date_modified_gmt( $context = 'view' ) {
419
+     * Get GMT date when the invoice was last modified.
420
+     *
421
+     * @since 1.0.19
422
+     * @param  string $context View or edit context.
423
+     * @return string
424
+     */
425
+    public function get_date_modified_gmt( $context = 'view' ) {
426 426
         $date = $this->get_date_modified( $context );
427 427
 
428 428
         if ( $date ) {
429 429
             $date = get_gmt_from_date( $date );
430 430
         }
431
-		return $date;
431
+        return $date;
432 432
     }
433 433
 
434 434
     /**
435
-	 * Get the invoice due date.
436
-	 *
437
-	 * @since 1.0.19
438
-	 * @param  string $context View or edit context.
439
-	 * @return string
440
-	 */
441
-	public function get_due_date( $context = 'view' ) {
442
-		return $this->get_prop( 'due_date', $context );
435
+     * Get the invoice due date.
436
+     *
437
+     * @since 1.0.19
438
+     * @param  string $context View or edit context.
439
+     * @return string
440
+     */
441
+    public function get_due_date( $context = 'view' ) {
442
+        return $this->get_prop( 'due_date', $context );
443 443
     }
444 444
 
445 445
     /**
446
-	 * Alias for self::get_due_date().
447
-	 *
448
-	 * @since 1.0.19
449
-	 * @param  string $context View or edit context.
450
-	 * @return string
451
-	 */
452
-	public function get_date_due( $context = 'view' ) {
453
-		return $this->get_due_date( $context );
446
+     * Alias for self::get_due_date().
447
+     *
448
+     * @since 1.0.19
449
+     * @param  string $context View or edit context.
450
+     * @return string
451
+     */
452
+    public function get_date_due( $context = 'view' ) {
453
+        return $this->get_due_date( $context );
454 454
     }
455 455
 
456 456
     /**
457
-	 * Get the invoice GMT due date.
458
-	 *
459
-	 * @since 1.0.19
460
-	 * @param  string $context View or edit context.
461
-	 * @return string
462
-	 */
463
-	public function get_due_date_gmt( $context = 'view' ) {
457
+     * Get the invoice GMT due date.
458
+     *
459
+     * @since 1.0.19
460
+     * @param  string $context View or edit context.
461
+     * @return string
462
+     */
463
+    public function get_due_date_gmt( $context = 'view' ) {
464 464
         $date = $this->get_due_date( $context );
465 465
 
466 466
         if ( $date ) {
467 467
             $date = get_gmt_from_date( $date );
468 468
         }
469
-		return $date;
469
+        return $date;
470 470
     }
471 471
 
472 472
     /**
473
-	 * Alias for self::get_due_date_gmt().
474
-	 *
475
-	 * @since 1.0.19
476
-	 * @param  string $context View or edit context.
477
-	 * @return string
478
-	 */
479
-	public function get_gmt_date_due( $context = 'view' ) {
480
-		return $this->get_due_date_gmt( $context );
473
+     * Alias for self::get_due_date_gmt().
474
+     *
475
+     * @since 1.0.19
476
+     * @param  string $context View or edit context.
477
+     * @return string
478
+     */
479
+    public function get_gmt_date_due( $context = 'view' ) {
480
+        return $this->get_due_date_gmt( $context );
481 481
     }
482 482
 
483 483
     /**
484
-	 * Get date when the invoice was completed.
485
-	 *
486
-	 * @since 1.0.19
487
-	 * @param  string $context View or edit context.
488
-	 * @return string
489
-	 */
490
-	public function get_completed_date( $context = 'view' ) {
491
-		return $this->get_prop( 'completed_date', $context );
484
+     * Get date when the invoice was completed.
485
+     *
486
+     * @since 1.0.19
487
+     * @param  string $context View or edit context.
488
+     * @return string
489
+     */
490
+    public function get_completed_date( $context = 'view' ) {
491
+        return $this->get_prop( 'completed_date', $context );
492 492
     }
493 493
 
494 494
     /**
495
-	 * Alias for self::get_completed_date().
496
-	 *
497
-	 * @since 1.0.19
498
-	 * @param  string $context View or edit context.
499
-	 * @return string
500
-	 */
501
-	public function get_date_completed( $context = 'view' ) {
502
-		return $this->get_completed_date( $context );
495
+     * Alias for self::get_completed_date().
496
+     *
497
+     * @since 1.0.19
498
+     * @param  string $context View or edit context.
499
+     * @return string
500
+     */
501
+    public function get_date_completed( $context = 'view' ) {
502
+        return $this->get_completed_date( $context );
503 503
     }
504 504
 
505 505
     /**
506
-	 * Get GMT date when the invoice was was completed.
507
-	 *
508
-	 * @since 1.0.19
509
-	 * @param  string $context View or edit context.
510
-	 * @return string
511
-	 */
512
-	public function get_completed_date_gmt( $context = 'view' ) {
506
+     * Get GMT date when the invoice was was completed.
507
+     *
508
+     * @since 1.0.19
509
+     * @param  string $context View or edit context.
510
+     * @return string
511
+     */
512
+    public function get_completed_date_gmt( $context = 'view' ) {
513 513
         $date = $this->get_completed_date( $context );
514 514
 
515 515
         if ( $date ) {
516 516
             $date = get_gmt_from_date( $date );
517 517
         }
518
-		return $date;
518
+        return $date;
519 519
     }
520 520
 
521 521
     /**
522
-	 * Alias for self::get_completed_date_gmt().
523
-	 *
524
-	 * @since 1.0.19
525
-	 * @param  string $context View or edit context.
526
-	 * @return string
527
-	 */
528
-	public function get_gmt_completed_date( $context = 'view' ) {
529
-		return $this->get_completed_date_gmt( $context );
522
+     * Alias for self::get_completed_date_gmt().
523
+     *
524
+     * @since 1.0.19
525
+     * @param  string $context View or edit context.
526
+     * @return string
527
+     */
528
+    public function get_gmt_completed_date( $context = 'view' ) {
529
+        return $this->get_completed_date_gmt( $context );
530 530
     }
531 531
 
532 532
     /**
533
-	 * Get the invoice number.
534
-	 *
535
-	 * @since 1.0.19
536
-	 * @param  string $context View or edit context.
537
-	 * @return string
538
-	 */
539
-	public function get_number( $context = 'view' ) {
540
-		$number = $this->get_prop( 'number', $context );
533
+     * Get the invoice number.
534
+     *
535
+     * @since 1.0.19
536
+     * @param  string $context View or edit context.
537
+     * @return string
538
+     */
539
+    public function get_number( $context = 'view' ) {
540
+        $number = $this->get_prop( 'number', $context );
541 541
 
542
-		if ( empty( $number ) ) {
543
-			$number = $this->generate_number();
544
-			$this->set_number( $this->generate_number() );
545
-		}
542
+        if ( empty( $number ) ) {
543
+            $number = $this->generate_number();
544
+            $this->set_number( $this->generate_number() );
545
+        }
546 546
 
547
-		return $number;
547
+        return $number;
548 548
     }
549 549
 
550
-	/**
551
-	 * Set the invoice number.
552
-	 *
553
-	 * @since 1.0.19
554
-	 */
555
-	public function maybe_set_number() {
550
+    /**
551
+     * Set the invoice number.
552
+     *
553
+     * @since 1.0.19
554
+     */
555
+    public function maybe_set_number() {
556 556
         $number = $this->get_number();
557 557
 
558 558
         if ( empty( $number ) || $this->get_id() == $number ) {
559
-			$this->set_number( $this->generate_number() );
559
+            $this->set_number( $this->generate_number() );
560 560
         }
561 561
 
562
-	}
562
+    }
563 563
 
564 564
     /**
565
-	 * Get the invoice key.
566
-	 *
567
-	 * @since 1.0.19
568
-	 * @param  string $context View or edit context.
569
-	 * @return string
570
-	 */
571
-	public function get_key( $context = 'view' ) {
565
+     * Get the invoice key.
566
+     *
567
+     * @since 1.0.19
568
+     * @param  string $context View or edit context.
569
+     * @return string
570
+     */
571
+    public function get_key( $context = 'view' ) {
572 572
         return $this->get_prop( 'key', $context );
573
-	}
574
-
575
-	/**
576
-	 * Set the invoice key.
577
-	 *
578
-	 * @since 1.0.19
579
-	 */
580
-	public function maybe_set_key() {
573
+    }
574
+
575
+    /**
576
+     * Set the invoice key.
577
+     *
578
+     * @since 1.0.19
579
+     */
580
+    public function maybe_set_key() {
581 581
         $key = $this->get_key();
582 582
 
583 583
         if ( empty( $key ) ) {
@@ -588,126 +588,126 @@  discard block
 block discarded – undo
588 588
     }
589 589
 
590 590
     /**
591
-	 * Get the invoice type.
592
-	 *
593
-	 * @since 1.0.19
594
-	 * @param  string $context View or edit context.
595
-	 * @return string
596
-	 */
597
-	public function get_type( $context = 'view' ) {
591
+     * Get the invoice type.
592
+     *
593
+     * @since 1.0.19
594
+     * @param  string $context View or edit context.
595
+     * @return string
596
+     */
597
+    public function get_type( $context = 'view' ) {
598 598
         return $this->get_prop( 'type', $context );
599
-	}
599
+    }
600 600
 
601
-	/**
602
-	 * @deprecated
603
-	 */
604
-	public function get_invoice_quote_type() {
601
+    /**
602
+     * @deprecated
603
+     */
604
+    public function get_invoice_quote_type() {
605 605
         ucfirst( $this->get_type() );
606 606
     }
607 607
 
608 608
     /**
609
-	 * Get the invoice post type.
610
-	 *
611
-	 * @since 1.0.19
612
-	 * @param  string $context View or edit context.
613
-	 * @return string
614
-	 */
615
-	public function get_post_type( $context = 'view' ) {
609
+     * Get the invoice post type.
610
+     *
611
+     * @since 1.0.19
612
+     * @param  string $context View or edit context.
613
+     * @return string
614
+     */
615
+    public function get_post_type( $context = 'view' ) {
616 616
         return $this->get_prop( 'post_type', $context );
617 617
     }
618 618
 
619 619
     /**
620
-	 * Get the invoice mode.
621
-	 *
622
-	 * @since 1.0.19
623
-	 * @param  string $context View or edit context.
624
-	 * @return string
625
-	 */
626
-	public function get_mode( $context = 'view' ) {
620
+     * Get the invoice mode.
621
+     *
622
+     * @since 1.0.19
623
+     * @param  string $context View or edit context.
624
+     * @return string
625
+     */
626
+    public function get_mode( $context = 'view' ) {
627 627
         return $this->get_prop( 'mode', $context );
628 628
     }
629 629
 
630 630
     /**
631
-	 * Get the invoice path.
632
-	 *
633
-	 * @since 1.0.19
634
-	 * @param  string $context View or edit context.
635
-	 * @return string
636
-	 */
637
-	public function get_path( $context = 'view' ) {
631
+     * Get the invoice path.
632
+     *
633
+     * @since 1.0.19
634
+     * @param  string $context View or edit context.
635
+     * @return string
636
+     */
637
+    public function get_path( $context = 'view' ) {
638 638
         $path   = $this->get_prop( 'path', $context );
639
-		$prefix = wpinv_post_name_prefix( $this->get_post_type() );
639
+        $prefix = wpinv_post_name_prefix( $this->get_post_type() );
640 640
 
641
-		if ( 0 !== strpos( $path, $prefix ) ) {
642
-			$path = sanitize_title(  $prefix . $this->get_id()  );
643
-			$this->set_path( $path );
644
-		}
641
+        if ( 0 !== strpos( $path, $prefix ) ) {
642
+            $path = sanitize_title(  $prefix . $this->get_id()  );
643
+            $this->set_path( $path );
644
+        }
645 645
 
646
-		return $path;
646
+        return $path;
647 647
     }
648 648
 
649 649
     /**
650
-	 * Get the invoice name/title.
651
-	 *
652
-	 * @since 1.0.19
653
-	 * @param  string $context View or edit context.
654
-	 * @return string
655
-	 */
656
-	public function get_name( $context = 'view' ) {
650
+     * Get the invoice name/title.
651
+     *
652
+     * @since 1.0.19
653
+     * @param  string $context View or edit context.
654
+     * @return string
655
+     */
656
+    public function get_name( $context = 'view' ) {
657 657
         return $this->get_prop( 'title', $context );
658 658
     }
659 659
 
660 660
     /**
661
-	 * Alias of self::get_name().
662
-	 *
663
-	 * @since 1.0.19
664
-	 * @param  string $context View or edit context.
665
-	 * @return string
666
-	 */
667
-	public function get_title( $context = 'view' ) {
668
-		return $this->get_name( $context );
661
+     * Alias of self::get_name().
662
+     *
663
+     * @since 1.0.19
664
+     * @param  string $context View or edit context.
665
+     * @return string
666
+     */
667
+    public function get_title( $context = 'view' ) {
668
+        return $this->get_name( $context );
669 669
     }
670 670
 
671 671
     /**
672
-	 * Get the invoice description.
673
-	 *
674
-	 * @since 1.0.19
675
-	 * @param  string $context View or edit context.
676
-	 * @return string
677
-	 */
678
-	public function get_description( $context = 'view' ) {
679
-		return $this->get_prop( 'description', $context );
672
+     * Get the invoice description.
673
+     *
674
+     * @since 1.0.19
675
+     * @param  string $context View or edit context.
676
+     * @return string
677
+     */
678
+    public function get_description( $context = 'view' ) {
679
+        return $this->get_prop( 'description', $context );
680 680
     }
681 681
 
682 682
     /**
683
-	 * Alias of self::get_description().
684
-	 *
685
-	 * @since 1.0.19
686
-	 * @param  string $context View or edit context.
687
-	 * @return string
688
-	 */
689
-	public function get_excerpt( $context = 'view' ) {
690
-		return $this->get_description( $context );
683
+     * Alias of self::get_description().
684
+     *
685
+     * @since 1.0.19
686
+     * @param  string $context View or edit context.
687
+     * @return string
688
+     */
689
+    public function get_excerpt( $context = 'view' ) {
690
+        return $this->get_description( $context );
691 691
     }
692 692
 
693 693
     /**
694
-	 * Alias of self::get_description().
695
-	 *
696
-	 * @since 1.0.19
697
-	 * @param  string $context View or edit context.
698
-	 * @return string
699
-	 */
700
-	public function get_summary( $context = 'view' ) {
701
-		return $this->get_description( $context );
694
+     * Alias of self::get_description().
695
+     *
696
+     * @since 1.0.19
697
+     * @param  string $context View or edit context.
698
+     * @return string
699
+     */
700
+    public function get_summary( $context = 'view' ) {
701
+        return $this->get_description( $context );
702 702
     }
703 703
 
704 704
     /**
705
-	 * Returns the user info.
706
-	 *
707
-	 * @since 1.0.19
705
+     * Returns the user info.
706
+     *
707
+     * @since 1.0.19
708 708
      * @param  string $context View or edit context.
709
-	 * @return array
710
-	 */
709
+     * @return array
710
+     */
711 711
     public function get_user_info( $context = 'view' ) {
712 712
 
713 713
         $user_info = array(
@@ -724,605 +724,605 @@  discard block
 block discarded – undo
724 724
             'company'    => $this->get_company( $context ),
725 725
             'vat_number' => $this->get_vat_number( $context ),
726 726
             'discount'   => $this->get_discount_code( $context ),
727
-		);
727
+        );
728 728
 
729
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
729
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
730 730
 
731 731
     }
732 732
 
733 733
     /**
734
-	 * Get the customer id.
735
-	 *
736
-	 * @since 1.0.19
737
-	 * @param  string $context View or edit context.
738
-	 * @return int
739
-	 */
740
-	public function get_author( $context = 'view' ) {
741
-		return (int) $this->get_prop( 'author', $context );
734
+     * Get the customer id.
735
+     *
736
+     * @since 1.0.19
737
+     * @param  string $context View or edit context.
738
+     * @return int
739
+     */
740
+    public function get_author( $context = 'view' ) {
741
+        return (int) $this->get_prop( 'author', $context );
742 742
     }
743 743
 
744 744
     /**
745
-	 * Alias of self::get_author().
746
-	 *
747
-	 * @since 1.0.19
748
-	 * @param  string $context View or edit context.
749
-	 * @return int
750
-	 */
751
-	public function get_user_id( $context = 'view' ) {
752
-		return $this->get_author( $context );
745
+     * Alias of self::get_author().
746
+     *
747
+     * @since 1.0.19
748
+     * @param  string $context View or edit context.
749
+     * @return int
750
+     */
751
+    public function get_user_id( $context = 'view' ) {
752
+        return $this->get_author( $context );
753 753
     }
754 754
 
755
-     /**
756
-	 * Alias of self::get_author().
757
-	 *
758
-	 * @since 1.0.19
759
-	 * @param  string $context View or edit context.
760
-	 * @return int
761
-	 */
762
-	public function get_customer_id( $context = 'view' ) {
763
-		return $this->get_author( $context );
755
+        /**
756
+         * Alias of self::get_author().
757
+         *
758
+         * @since 1.0.19
759
+         * @param  string $context View or edit context.
760
+         * @return int
761
+         */
762
+    public function get_customer_id( $context = 'view' ) {
763
+        return $this->get_author( $context );
764 764
     }
765 765
 
766 766
     /**
767
-	 * Get the customer's ip.
768
-	 *
769
-	 * @since 1.0.19
770
-	 * @param  string $context View or edit context.
771
-	 * @return string
772
-	 */
773
-	public function get_ip( $context = 'view' ) {
774
-		return $this->get_prop( 'user_ip', $context );
767
+     * Get the customer's ip.
768
+     *
769
+     * @since 1.0.19
770
+     * @param  string $context View or edit context.
771
+     * @return string
772
+     */
773
+    public function get_ip( $context = 'view' ) {
774
+        return $this->get_prop( 'user_ip', $context );
775 775
     }
776 776
 
777 777
     /**
778
-	 * Alias of self::get_ip().
779
-	 *
780
-	 * @since 1.0.19
781
-	 * @param  string $context View or edit context.
782
-	 * @return string
783
-	 */
784
-	public function get_user_ip( $context = 'view' ) {
785
-		return $this->get_ip( $context );
778
+     * Alias of self::get_ip().
779
+     *
780
+     * @since 1.0.19
781
+     * @param  string $context View or edit context.
782
+     * @return string
783
+     */
784
+    public function get_user_ip( $context = 'view' ) {
785
+        return $this->get_ip( $context );
786 786
     }
787 787
 
788
-     /**
789
-	 * Alias of self::get_ip().
790
-	 *
791
-	 * @since 1.0.19
792
-	 * @param  string $context View or edit context.
793
-	 * @return string
794
-	 */
795
-	public function get_customer_ip( $context = 'view' ) {
796
-		return $this->get_ip( $context );
788
+        /**
789
+         * Alias of self::get_ip().
790
+         *
791
+         * @since 1.0.19
792
+         * @param  string $context View or edit context.
793
+         * @return string
794
+         */
795
+    public function get_customer_ip( $context = 'view' ) {
796
+        return $this->get_ip( $context );
797 797
     }
798 798
 
799 799
     /**
800
-	 * Get the customer's first name.
801
-	 *
802
-	 * @since 1.0.19
803
-	 * @param  string $context View or edit context.
804
-	 * @return string
805
-	 */
806
-	public function get_first_name( $context = 'view' ) {
807
-		return $this->get_prop( 'first_name', $context );
800
+     * Get the customer's first name.
801
+     *
802
+     * @since 1.0.19
803
+     * @param  string $context View or edit context.
804
+     * @return string
805
+     */
806
+    public function get_first_name( $context = 'view' ) {
807
+        return $this->get_prop( 'first_name', $context );
808 808
     }
809 809
 
810 810
     /**
811
-	 * Alias of self::get_first_name().
812
-	 *
813
-	 * @since 1.0.19
814
-	 * @param  string $context View or edit context.
815
-	 * @return int
816
-	 */
817
-	public function get_user_first_name( $context = 'view' ) {
818
-		return $this->get_first_name( $context );
811
+     * Alias of self::get_first_name().
812
+     *
813
+     * @since 1.0.19
814
+     * @param  string $context View or edit context.
815
+     * @return int
816
+     */
817
+    public function get_user_first_name( $context = 'view' ) {
818
+        return $this->get_first_name( $context );
819 819
     }
820 820
 
821
-     /**
822
-	 * Alias of self::get_first_name().
823
-	 *
824
-	 * @since 1.0.19
825
-	 * @param  string $context View or edit context.
826
-	 * @return int
827
-	 */
828
-	public function get_customer_first_name( $context = 'view' ) {
829
-		return $this->get_first_name( $context );
821
+        /**
822
+         * Alias of self::get_first_name().
823
+         *
824
+         * @since 1.0.19
825
+         * @param  string $context View or edit context.
826
+         * @return int
827
+         */
828
+    public function get_customer_first_name( $context = 'view' ) {
829
+        return $this->get_first_name( $context );
830 830
     }
831 831
 
832 832
     /**
833
-	 * Get the customer's last name.
834
-	 *
835
-	 * @since 1.0.19
836
-	 * @param  string $context View or edit context.
837
-	 * @return string
838
-	 */
839
-	public function get_last_name( $context = 'view' ) {
840
-		return $this->get_prop( 'last_name', $context );
833
+     * Get the customer's last name.
834
+     *
835
+     * @since 1.0.19
836
+     * @param  string $context View or edit context.
837
+     * @return string
838
+     */
839
+    public function get_last_name( $context = 'view' ) {
840
+        return $this->get_prop( 'last_name', $context );
841 841
     }
842 842
 
843 843
     /**
844
-	 * Alias of self::get_last_name().
845
-	 *
846
-	 * @since 1.0.19
847
-	 * @param  string $context View or edit context.
848
-	 * @return int
849
-	 */
850
-	public function get_user_last_name( $context = 'view' ) {
851
-		return $this->get_last_name( $context );
844
+     * Alias of self::get_last_name().
845
+     *
846
+     * @since 1.0.19
847
+     * @param  string $context View or edit context.
848
+     * @return int
849
+     */
850
+    public function get_user_last_name( $context = 'view' ) {
851
+        return $this->get_last_name( $context );
852 852
     }
853 853
 
854 854
     /**
855
-	 * Alias of self::get_last_name().
856
-	 *
857
-	 * @since 1.0.19
858
-	 * @param  string $context View or edit context.
859
-	 * @return int
860
-	 */
861
-	public function get_customer_last_name( $context = 'view' ) {
862
-		return $this->get_last_name( $context );
855
+     * Alias of self::get_last_name().
856
+     *
857
+     * @since 1.0.19
858
+     * @param  string $context View or edit context.
859
+     * @return int
860
+     */
861
+    public function get_customer_last_name( $context = 'view' ) {
862
+        return $this->get_last_name( $context );
863 863
     }
864 864
 
865 865
     /**
866
-	 * Get the customer's full name.
867
-	 *
868
-	 * @since 1.0.19
869
-	 * @param  string $context View or edit context.
870
-	 * @return string
871
-	 */
872
-	public function get_full_name( $context = 'view' ) {
873
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
866
+     * Get the customer's full name.
867
+     *
868
+     * @since 1.0.19
869
+     * @param  string $context View or edit context.
870
+     * @return string
871
+     */
872
+    public function get_full_name( $context = 'view' ) {
873
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
874 874
     }
875 875
 
876 876
     /**
877
-	 * Alias of self::get_full_name().
878
-	 *
879
-	 * @since 1.0.19
880
-	 * @param  string $context View or edit context.
881
-	 * @return int
882
-	 */
883
-	public function get_user_full_name( $context = 'view' ) {
884
-		return $this->get_full_name( $context );
877
+     * Alias of self::get_full_name().
878
+     *
879
+     * @since 1.0.19
880
+     * @param  string $context View or edit context.
881
+     * @return int
882
+     */
883
+    public function get_user_full_name( $context = 'view' ) {
884
+        return $this->get_full_name( $context );
885 885
     }
886 886
 
887 887
     /**
888
-	 * Alias of self::get_full_name().
889
-	 *
890
-	 * @since 1.0.19
891
-	 * @param  string $context View or edit context.
892
-	 * @return int
893
-	 */
894
-	public function get_customer_full_name( $context = 'view' ) {
895
-		return $this->get_full_name( $context );
888
+     * Alias of self::get_full_name().
889
+     *
890
+     * @since 1.0.19
891
+     * @param  string $context View or edit context.
892
+     * @return int
893
+     */
894
+    public function get_customer_full_name( $context = 'view' ) {
895
+        return $this->get_full_name( $context );
896 896
     }
897 897
 
898 898
     /**
899
-	 * Get the customer's phone number.
900
-	 *
901
-	 * @since 1.0.19
902
-	 * @param  string $context View or edit context.
903
-	 * @return string
904
-	 */
905
-	public function get_phone( $context = 'view' ) {
906
-		return $this->get_prop( 'phone', $context );
899
+     * Get the customer's phone number.
900
+     *
901
+     * @since 1.0.19
902
+     * @param  string $context View or edit context.
903
+     * @return string
904
+     */
905
+    public function get_phone( $context = 'view' ) {
906
+        return $this->get_prop( 'phone', $context );
907 907
     }
908 908
 
909 909
     /**
910
-	 * Alias of self::get_phone().
911
-	 *
912
-	 * @since 1.0.19
913
-	 * @param  string $context View or edit context.
914
-	 * @return int
915
-	 */
916
-	public function get_phone_number( $context = 'view' ) {
917
-		return $this->get_phone( $context );
910
+     * Alias of self::get_phone().
911
+     *
912
+     * @since 1.0.19
913
+     * @param  string $context View or edit context.
914
+     * @return int
915
+     */
916
+    public function get_phone_number( $context = 'view' ) {
917
+        return $this->get_phone( $context );
918 918
     }
919 919
 
920 920
     /**
921
-	 * Alias of self::get_phone().
922
-	 *
923
-	 * @since 1.0.19
924
-	 * @param  string $context View or edit context.
925
-	 * @return int
926
-	 */
927
-	public function get_user_phone( $context = 'view' ) {
928
-		return $this->get_phone( $context );
921
+     * Alias of self::get_phone().
922
+     *
923
+     * @since 1.0.19
924
+     * @param  string $context View or edit context.
925
+     * @return int
926
+     */
927
+    public function get_user_phone( $context = 'view' ) {
928
+        return $this->get_phone( $context );
929 929
     }
930 930
 
931 931
     /**
932
-	 * Alias of self::get_phone().
933
-	 *
934
-	 * @since 1.0.19
935
-	 * @param  string $context View or edit context.
936
-	 * @return int
937
-	 */
938
-	public function get_customer_phone( $context = 'view' ) {
939
-		return $this->get_phone( $context );
932
+     * Alias of self::get_phone().
933
+     *
934
+     * @since 1.0.19
935
+     * @param  string $context View or edit context.
936
+     * @return int
937
+     */
938
+    public function get_customer_phone( $context = 'view' ) {
939
+        return $this->get_phone( $context );
940 940
     }
941 941
 
942 942
     /**
943
-	 * Get the customer's email address.
944
-	 *
945
-	 * @since 1.0.19
946
-	 * @param  string $context View or edit context.
947
-	 * @return string
948
-	 */
949
-	public function get_email( $context = 'view' ) {
950
-		return $this->get_prop( 'email', $context );
943
+     * Get the customer's email address.
944
+     *
945
+     * @since 1.0.19
946
+     * @param  string $context View or edit context.
947
+     * @return string
948
+     */
949
+    public function get_email( $context = 'view' ) {
950
+        return $this->get_prop( 'email', $context );
951 951
     }
952 952
 
953 953
     /**
954
-	 * Alias of self::get_email().
955
-	 *
956
-	 * @since 1.0.19
957
-	 * @param  string $context View or edit context.
958
-	 * @return string
959
-	 */
960
-	public function get_email_address( $context = 'view' ) {
961
-		return $this->get_email( $context );
954
+     * Alias of self::get_email().
955
+     *
956
+     * @since 1.0.19
957
+     * @param  string $context View or edit context.
958
+     * @return string
959
+     */
960
+    public function get_email_address( $context = 'view' ) {
961
+        return $this->get_email( $context );
962 962
     }
963 963
 
964 964
     /**
965
-	 * Alias of self::get_email().
966
-	 *
967
-	 * @since 1.0.19
968
-	 * @param  string $context View or edit context.
969
-	 * @return int
970
-	 */
971
-	public function get_user_email( $context = 'view' ) {
972
-		return $this->get_email( $context );
965
+     * Alias of self::get_email().
966
+     *
967
+     * @since 1.0.19
968
+     * @param  string $context View or edit context.
969
+     * @return int
970
+     */
971
+    public function get_user_email( $context = 'view' ) {
972
+        return $this->get_email( $context );
973 973
     }
974 974
 
975 975
     /**
976
-	 * Alias of self::get_email().
977
-	 *
978
-	 * @since 1.0.19
979
-	 * @param  string $context View or edit context.
980
-	 * @return int
981
-	 */
982
-	public function get_customer_email( $context = 'view' ) {
983
-		return $this->get_email( $context );
976
+     * Alias of self::get_email().
977
+     *
978
+     * @since 1.0.19
979
+     * @param  string $context View or edit context.
980
+     * @return int
981
+     */
982
+    public function get_customer_email( $context = 'view' ) {
983
+        return $this->get_email( $context );
984 984
     }
985 985
 
986 986
     /**
987
-	 * Get the customer's country.
988
-	 *
989
-	 * @since 1.0.19
990
-	 * @param  string $context View or edit context.
991
-	 * @return string
992
-	 */
993
-	public function get_country( $context = 'view' ) {
994
-		$country = $this->get_prop( 'country', $context );
995
-		return empty( $country ) ? wpinv_get_default_country() : $country;
987
+     * Get the customer's country.
988
+     *
989
+     * @since 1.0.19
990
+     * @param  string $context View or edit context.
991
+     * @return string
992
+     */
993
+    public function get_country( $context = 'view' ) {
994
+        $country = $this->get_prop( 'country', $context );
995
+        return empty( $country ) ? wpinv_get_default_country() : $country;
996 996
     }
997 997
 
998 998
     /**
999
-	 * Alias of self::get_country().
1000
-	 *
1001
-	 * @since 1.0.19
1002
-	 * @param  string $context View or edit context.
1003
-	 * @return int
1004
-	 */
1005
-	public function get_user_country( $context = 'view' ) {
1006
-		return $this->get_country( $context );
999
+     * Alias of self::get_country().
1000
+     *
1001
+     * @since 1.0.19
1002
+     * @param  string $context View or edit context.
1003
+     * @return int
1004
+     */
1005
+    public function get_user_country( $context = 'view' ) {
1006
+        return $this->get_country( $context );
1007 1007
     }
1008 1008
 
1009 1009
     /**
1010
-	 * Alias of self::get_country().
1011
-	 *
1012
-	 * @since 1.0.19
1013
-	 * @param  string $context View or edit context.
1014
-	 * @return int
1015
-	 */
1016
-	public function get_customer_country( $context = 'view' ) {
1017
-		return $this->get_country( $context );
1010
+     * Alias of self::get_country().
1011
+     *
1012
+     * @since 1.0.19
1013
+     * @param  string $context View or edit context.
1014
+     * @return int
1015
+     */
1016
+    public function get_customer_country( $context = 'view' ) {
1017
+        return $this->get_country( $context );
1018 1018
     }
1019 1019
 
1020 1020
     /**
1021
-	 * Get the customer's state.
1022
-	 *
1023
-	 * @since 1.0.19
1024
-	 * @param  string $context View or edit context.
1025
-	 * @return string
1026
-	 */
1027
-	public function get_state( $context = 'view' ) {
1028
-		$state = $this->get_prop( 'state', $context );
1029
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1021
+     * Get the customer's state.
1022
+     *
1023
+     * @since 1.0.19
1024
+     * @param  string $context View or edit context.
1025
+     * @return string
1026
+     */
1027
+    public function get_state( $context = 'view' ) {
1028
+        $state = $this->get_prop( 'state', $context );
1029
+        return empty( $state ) ? wpinv_get_default_state() : $state;
1030 1030
     }
1031 1031
 
1032 1032
     /**
1033
-	 * Alias of self::get_state().
1034
-	 *
1035
-	 * @since 1.0.19
1036
-	 * @param  string $context View or edit context.
1037
-	 * @return int
1038
-	 */
1039
-	public function get_user_state( $context = 'view' ) {
1040
-		return $this->get_state( $context );
1033
+     * Alias of self::get_state().
1034
+     *
1035
+     * @since 1.0.19
1036
+     * @param  string $context View or edit context.
1037
+     * @return int
1038
+     */
1039
+    public function get_user_state( $context = 'view' ) {
1040
+        return $this->get_state( $context );
1041 1041
     }
1042 1042
 
1043 1043
     /**
1044
-	 * Alias of self::get_state().
1045
-	 *
1046
-	 * @since 1.0.19
1047
-	 * @param  string $context View or edit context.
1048
-	 * @return int
1049
-	 */
1050
-	public function get_customer_state( $context = 'view' ) {
1051
-		return $this->get_state( $context );
1044
+     * Alias of self::get_state().
1045
+     *
1046
+     * @since 1.0.19
1047
+     * @param  string $context View or edit context.
1048
+     * @return int
1049
+     */
1050
+    public function get_customer_state( $context = 'view' ) {
1051
+        return $this->get_state( $context );
1052 1052
     }
1053 1053
 
1054 1054
     /**
1055
-	 * Get the customer's city.
1056
-	 *
1057
-	 * @since 1.0.19
1058
-	 * @param  string $context View or edit context.
1059
-	 * @return string
1060
-	 */
1061
-	public function get_city( $context = 'view' ) {
1062
-		return $this->get_prop( 'city', $context );
1055
+     * Get the customer's city.
1056
+     *
1057
+     * @since 1.0.19
1058
+     * @param  string $context View or edit context.
1059
+     * @return string
1060
+     */
1061
+    public function get_city( $context = 'view' ) {
1062
+        return $this->get_prop( 'city', $context );
1063 1063
     }
1064 1064
 
1065 1065
     /**
1066
-	 * Alias of self::get_city().
1067
-	 *
1068
-	 * @since 1.0.19
1069
-	 * @param  string $context View or edit context.
1070
-	 * @return string
1071
-	 */
1072
-	public function get_user_city( $context = 'view' ) {
1073
-		return $this->get_city( $context );
1066
+     * Alias of self::get_city().
1067
+     *
1068
+     * @since 1.0.19
1069
+     * @param  string $context View or edit context.
1070
+     * @return string
1071
+     */
1072
+    public function get_user_city( $context = 'view' ) {
1073
+        return $this->get_city( $context );
1074 1074
     }
1075 1075
 
1076 1076
     /**
1077
-	 * Alias of self::get_city().
1078
-	 *
1079
-	 * @since 1.0.19
1080
-	 * @param  string $context View or edit context.
1081
-	 * @return string
1082
-	 */
1083
-	public function get_customer_city( $context = 'view' ) {
1084
-		return $this->get_city( $context );
1077
+     * Alias of self::get_city().
1078
+     *
1079
+     * @since 1.0.19
1080
+     * @param  string $context View or edit context.
1081
+     * @return string
1082
+     */
1083
+    public function get_customer_city( $context = 'view' ) {
1084
+        return $this->get_city( $context );
1085 1085
     }
1086 1086
 
1087 1087
     /**
1088
-	 * Get the customer's zip.
1089
-	 *
1090
-	 * @since 1.0.19
1091
-	 * @param  string $context View or edit context.
1092
-	 * @return string
1093
-	 */
1094
-	public function get_zip( $context = 'view' ) {
1095
-		return $this->get_prop( 'zip', $context );
1088
+     * Get the customer's zip.
1089
+     *
1090
+     * @since 1.0.19
1091
+     * @param  string $context View or edit context.
1092
+     * @return string
1093
+     */
1094
+    public function get_zip( $context = 'view' ) {
1095
+        return $this->get_prop( 'zip', $context );
1096 1096
     }
1097 1097
 
1098 1098
     /**
1099
-	 * Alias of self::get_zip().
1100
-	 *
1101
-	 * @since 1.0.19
1102
-	 * @param  string $context View or edit context.
1103
-	 * @return string
1104
-	 */
1105
-	public function get_user_zip( $context = 'view' ) {
1106
-		return $this->get_zip( $context );
1099
+     * Alias of self::get_zip().
1100
+     *
1101
+     * @since 1.0.19
1102
+     * @param  string $context View or edit context.
1103
+     * @return string
1104
+     */
1105
+    public function get_user_zip( $context = 'view' ) {
1106
+        return $this->get_zip( $context );
1107 1107
     }
1108 1108
 
1109 1109
     /**
1110
-	 * Alias of self::get_zip().
1111
-	 *
1112
-	 * @since 1.0.19
1113
-	 * @param  string $context View or edit context.
1114
-	 * @return string
1115
-	 */
1116
-	public function get_customer_zip( $context = 'view' ) {
1117
-		return $this->get_zip( $context );
1110
+     * Alias of self::get_zip().
1111
+     *
1112
+     * @since 1.0.19
1113
+     * @param  string $context View or edit context.
1114
+     * @return string
1115
+     */
1116
+    public function get_customer_zip( $context = 'view' ) {
1117
+        return $this->get_zip( $context );
1118 1118
     }
1119 1119
 
1120 1120
     /**
1121
-	 * Get the customer's company.
1122
-	 *
1123
-	 * @since 1.0.19
1124
-	 * @param  string $context View or edit context.
1125
-	 * @return string
1126
-	 */
1127
-	public function get_company( $context = 'view' ) {
1128
-		return $this->get_prop( 'company', $context );
1121
+     * Get the customer's company.
1122
+     *
1123
+     * @since 1.0.19
1124
+     * @param  string $context View or edit context.
1125
+     * @return string
1126
+     */
1127
+    public function get_company( $context = 'view' ) {
1128
+        return $this->get_prop( 'company', $context );
1129
+    }
1130
+
1131
+    /**
1132
+     * Alias of self::get_company().
1133
+     *
1134
+     * @since 1.0.19
1135
+     * @param  string $context View or edit context.
1136
+     * @return string
1137
+     */
1138
+    public function get_user_company( $context = 'view' ) {
1139
+        return $this->get_company( $context );
1140
+    }
1141
+
1142
+    /**
1143
+     * Alias of self::get_company().
1144
+     *
1145
+     * @since 1.0.19
1146
+     * @param  string $context View or edit context.
1147
+     * @return string
1148
+     */
1149
+    public function get_customer_company( $context = 'view' ) {
1150
+        return $this->get_company( $context );
1151
+    }
1152
+
1153
+    /**
1154
+     * Get the customer's vat number.
1155
+     *
1156
+     * @since 1.0.19
1157
+     * @param  string $context View or edit context.
1158
+     * @return string
1159
+     */
1160
+    public function get_vat_number( $context = 'view' ) {
1161
+        return $this->get_prop( 'vat_number', $context );
1162
+    }
1163
+
1164
+    /**
1165
+     * Alias of self::get_vat_number().
1166
+     *
1167
+     * @since 1.0.19
1168
+     * @param  string $context View or edit context.
1169
+     * @return string
1170
+     */
1171
+    public function get_user_vat_number( $context = 'view' ) {
1172
+        return $this->get_vat_number( $context );
1173
+    }
1174
+
1175
+    /**
1176
+     * Alias of self::get_vat_number().
1177
+     *
1178
+     * @since 1.0.19
1179
+     * @param  string $context View or edit context.
1180
+     * @return string
1181
+     */
1182
+    public function get_customer_vat_number( $context = 'view' ) {
1183
+        return $this->get_vat_number( $context );
1184
+    }
1185
+
1186
+    /**
1187
+     * Get the customer's vat rate.
1188
+     *
1189
+     * @since 1.0.19
1190
+     * @param  string $context View or edit context.
1191
+     * @return string
1192
+     */
1193
+    public function get_vat_rate( $context = 'view' ) {
1194
+        return $this->get_prop( 'vat_rate', $context );
1195
+    }
1196
+
1197
+    /**
1198
+     * Alias of self::get_vat_rate().
1199
+     *
1200
+     * @since 1.0.19
1201
+     * @param  string $context View or edit context.
1202
+     * @return string
1203
+     */
1204
+    public function get_user_vat_rate( $context = 'view' ) {
1205
+        return $this->get_vat_rate( $context );
1129 1206
     }
1130 1207
 
1131 1208
     /**
1132
-	 * Alias of self::get_company().
1133
-	 *
1134
-	 * @since 1.0.19
1135
-	 * @param  string $context View or edit context.
1136
-	 * @return string
1137
-	 */
1138
-	public function get_user_company( $context = 'view' ) {
1139
-		return $this->get_company( $context );
1209
+     * Alias of self::get_vat_rate().
1210
+     *
1211
+     * @since 1.0.19
1212
+     * @param  string $context View or edit context.
1213
+     * @return string
1214
+     */
1215
+    public function get_customer_vat_rate( $context = 'view' ) {
1216
+        return $this->get_vat_rate( $context );
1140 1217
     }
1141 1218
 
1142 1219
     /**
1143
-	 * Alias of self::get_company().
1144
-	 *
1145
-	 * @since 1.0.19
1146
-	 * @param  string $context View or edit context.
1147
-	 * @return string
1148
-	 */
1149
-	public function get_customer_company( $context = 'view' ) {
1150
-		return $this->get_company( $context );
1220
+     * Get the customer's address.
1221
+     *
1222
+     * @since 1.0.19
1223
+     * @param  string $context View or edit context.
1224
+     * @return string
1225
+     */
1226
+    public function get_address( $context = 'view' ) {
1227
+        return $this->get_prop( 'address', $context );
1151 1228
     }
1152 1229
 
1153 1230
     /**
1154
-	 * Get the customer's vat number.
1155
-	 *
1156
-	 * @since 1.0.19
1157
-	 * @param  string $context View or edit context.
1158
-	 * @return string
1159
-	 */
1160
-	public function get_vat_number( $context = 'view' ) {
1161
-		return $this->get_prop( 'vat_number', $context );
1231
+     * Alias of self::get_address().
1232
+     *
1233
+     * @since 1.0.19
1234
+     * @param  string $context View or edit context.
1235
+     * @return string
1236
+     */
1237
+    public function get_user_address( $context = 'view' ) {
1238
+        return $this->get_address( $context );
1162 1239
     }
1163 1240
 
1164 1241
     /**
1165
-	 * Alias of self::get_vat_number().
1166
-	 *
1167
-	 * @since 1.0.19
1168
-	 * @param  string $context View or edit context.
1169
-	 * @return string
1170
-	 */
1171
-	public function get_user_vat_number( $context = 'view' ) {
1172
-		return $this->get_vat_number( $context );
1242
+     * Alias of self::get_address().
1243
+     *
1244
+     * @since 1.0.19
1245
+     * @param  string $context View or edit context.
1246
+     * @return string
1247
+     */
1248
+    public function get_customer_address( $context = 'view' ) {
1249
+        return $this->get_address( $context );
1173 1250
     }
1174 1251
 
1175 1252
     /**
1176
-	 * Alias of self::get_vat_number().
1177
-	 *
1178
-	 * @since 1.0.19
1179
-	 * @param  string $context View or edit context.
1180
-	 * @return string
1181
-	 */
1182
-	public function get_customer_vat_number( $context = 'view' ) {
1183
-		return $this->get_vat_number( $context );
1253
+     * Get whether the customer has viewed the invoice or not.
1254
+     *
1255
+     * @since 1.0.19
1256
+     * @param  string $context View or edit context.
1257
+     * @return bool
1258
+     */
1259
+    public function get_is_viewed( $context = 'view' ) {
1260
+        return (bool) $this->get_prop( 'is_viewed', $context );
1184 1261
     }
1185 1262
 
1186 1263
     /**
1187
-	 * Get the customer's vat rate.
1188
-	 *
1189
-	 * @since 1.0.19
1190
-	 * @param  string $context View or edit context.
1191
-	 * @return string
1192
-	 */
1193
-	public function get_vat_rate( $context = 'view' ) {
1194
-		return $this->get_prop( 'vat_rate', $context );
1264
+     * Get other recipients for invoice communications.
1265
+     *
1266
+     * @since 1.0.19
1267
+     * @param  string $context View or edit context.
1268
+     * @return bool
1269
+     */
1270
+    public function get_email_cc( $context = 'view' ) {
1271
+        return $this->get_prop( 'email_cc', $context );
1195 1272
     }
1196 1273
 
1197 1274
     /**
1198
-	 * Alias of self::get_vat_rate().
1199
-	 *
1200
-	 * @since 1.0.19
1201
-	 * @param  string $context View or edit context.
1202
-	 * @return string
1203
-	 */
1204
-	public function get_user_vat_rate( $context = 'view' ) {
1205
-		return $this->get_vat_rate( $context );
1275
+     * Get invoice template.
1276
+     *
1277
+     * @since 1.0.19
1278
+     * @param  string $context View or edit context.
1279
+     * @return bool
1280
+     */
1281
+    public function get_template( $context = 'view' ) {
1282
+        return $this->get_prop( 'template', $context );
1283
+    }
1284
+
1285
+    /**
1286
+     * Get whether the customer has confirmed their address.
1287
+     *
1288
+     * @since 1.0.19
1289
+     * @param  string $context View or edit context.
1290
+     * @return bool
1291
+     */
1292
+    public function get_address_confirmed( $context = 'view' ) {
1293
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1294
+    }
1295
+
1296
+    /**
1297
+     * Alias of self::get_address_confirmed().
1298
+     *
1299
+     * @since 1.0.19
1300
+     * @param  string $context View or edit context.
1301
+     * @return bool
1302
+     */
1303
+    public function get_user_address_confirmed( $context = 'view' ) {
1304
+        return $this->get_address_confirmed( $context );
1206 1305
     }
1207 1306
 
1208 1307
     /**
1209
-	 * Alias of self::get_vat_rate().
1210
-	 *
1211
-	 * @since 1.0.19
1212
-	 * @param  string $context View or edit context.
1213
-	 * @return string
1214
-	 */
1215
-	public function get_customer_vat_rate( $context = 'view' ) {
1216
-		return $this->get_vat_rate( $context );
1308
+     * Alias of self::get_address().
1309
+     *
1310
+     * @since 1.0.19
1311
+     * @param  string $context View or edit context.
1312
+     * @return bool
1313
+     */
1314
+    public function get_customer_address_confirmed( $context = 'view' ) {
1315
+        return $this->get_address_confirmed( $context );
1217 1316
     }
1218 1317
 
1219 1318
     /**
1220
-	 * Get the customer's address.
1221
-	 *
1222
-	 * @since 1.0.19
1223
-	 * @param  string $context View or edit context.
1224
-	 * @return string
1225
-	 */
1226
-	public function get_address( $context = 'view' ) {
1227
-		return $this->get_prop( 'address', $context );
1228
-    }
1229
-
1230
-    /**
1231
-	 * Alias of self::get_address().
1232
-	 *
1233
-	 * @since 1.0.19
1234
-	 * @param  string $context View or edit context.
1235
-	 * @return string
1236
-	 */
1237
-	public function get_user_address( $context = 'view' ) {
1238
-		return $this->get_address( $context );
1239
-    }
1240
-
1241
-    /**
1242
-	 * Alias of self::get_address().
1243
-	 *
1244
-	 * @since 1.0.19
1245
-	 * @param  string $context View or edit context.
1246
-	 * @return string
1247
-	 */
1248
-	public function get_customer_address( $context = 'view' ) {
1249
-		return $this->get_address( $context );
1250
-    }
1251
-
1252
-    /**
1253
-	 * Get whether the customer has viewed the invoice or not.
1254
-	 *
1255
-	 * @since 1.0.19
1256
-	 * @param  string $context View or edit context.
1257
-	 * @return bool
1258
-	 */
1259
-	public function get_is_viewed( $context = 'view' ) {
1260
-		return (bool) $this->get_prop( 'is_viewed', $context );
1261
-	}
1262
-
1263
-	/**
1264
-	 * Get other recipients for invoice communications.
1265
-	 *
1266
-	 * @since 1.0.19
1267
-	 * @param  string $context View or edit context.
1268
-	 * @return bool
1269
-	 */
1270
-	public function get_email_cc( $context = 'view' ) {
1271
-		return $this->get_prop( 'email_cc', $context );
1272
-	}
1273
-
1274
-	/**
1275
-	 * Get invoice template.
1276
-	 *
1277
-	 * @since 1.0.19
1278
-	 * @param  string $context View or edit context.
1279
-	 * @return bool
1280
-	 */
1281
-	public function get_template( $context = 'view' ) {
1282
-		return $this->get_prop( 'template', $context );
1283
-	}
1284
-
1285
-	/**
1286
-	 * Get whether the customer has confirmed their address.
1287
-	 *
1288
-	 * @since 1.0.19
1289
-	 * @param  string $context View or edit context.
1290
-	 * @return bool
1291
-	 */
1292
-	public function get_address_confirmed( $context = 'view' ) {
1293
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1294
-    }
1295
-
1296
-    /**
1297
-	 * Alias of self::get_address_confirmed().
1298
-	 *
1299
-	 * @since 1.0.19
1300
-	 * @param  string $context View or edit context.
1301
-	 * @return bool
1302
-	 */
1303
-	public function get_user_address_confirmed( $context = 'view' ) {
1304
-		return $this->get_address_confirmed( $context );
1305
-    }
1306
-
1307
-    /**
1308
-	 * Alias of self::get_address().
1309
-	 *
1310
-	 * @since 1.0.19
1311
-	 * @param  string $context View or edit context.
1312
-	 * @return bool
1313
-	 */
1314
-	public function get_customer_address_confirmed( $context = 'view' ) {
1315
-		return $this->get_address_confirmed( $context );
1316
-    }
1317
-
1318
-    /**
1319
-	 * Get the invoice subtotal.
1320
-	 *
1321
-	 * @since 1.0.19
1322
-	 * @param  string $context View or edit context.
1323
-	 * @return float
1324
-	 */
1325
-	public function get_subtotal( $context = 'view' ) {
1319
+     * Get the invoice subtotal.
1320
+     *
1321
+     * @since 1.0.19
1322
+     * @param  string $context View or edit context.
1323
+     * @return float
1324
+     */
1325
+    public function get_subtotal( $context = 'view' ) {
1326 1326
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1327 1327
 
1328 1328
         // Backwards compatibility.
@@ -1334,165 +1334,165 @@  discard block
 block discarded – undo
1334 1334
     }
1335 1335
 
1336 1336
     /**
1337
-	 * Get the invoice discount total.
1338
-	 *
1339
-	 * @since 1.0.19
1340
-	 * @param  string $context View or edit context.
1341
-	 * @return float
1342
-	 */
1343
-	public function get_total_discount( $context = 'view' ) {
1344
-		return (float) $this->get_prop( 'total_discount', $context );
1337
+     * Get the invoice discount total.
1338
+     *
1339
+     * @since 1.0.19
1340
+     * @param  string $context View or edit context.
1341
+     * @return float
1342
+     */
1343
+    public function get_total_discount( $context = 'view' ) {
1344
+        return (float) $this->get_prop( 'total_discount', $context );
1345
+    }
1346
+
1347
+    /**
1348
+     * Get the invoice tax total.
1349
+     *
1350
+     * @since 1.0.19
1351
+     * @param  string $context View or edit context.
1352
+     * @return float
1353
+     */
1354
+    public function get_total_tax( $context = 'view' ) {
1355
+        return (float) $this->get_prop( 'total_tax', $context );
1345 1356
     }
1346 1357
 
1347 1358
     /**
1348
-	 * Get the invoice tax total.
1349
-	 *
1350
-	 * @since 1.0.19
1351
-	 * @param  string $context View or edit context.
1352
-	 * @return float
1353
-	 */
1354
-	public function get_total_tax( $context = 'view' ) {
1355
-		return (float) $this->get_prop( 'total_tax', $context );
1356
-	}
1357
-
1358
-	/**
1359
-	 * @deprecated
1360
-	 */
1361
-	public function get_final_tax( $currency = false ) {
1362
-		$tax = $this->get_total_tax();
1359
+     * @deprecated
1360
+     */
1361
+    public function get_final_tax( $currency = false ) {
1362
+        $tax = $this->get_total_tax();
1363 1363
 
1364 1364
         if ( $currency ) {
1365
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1365
+            return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1366 1366
         }
1367 1367
 
1368 1368
         return $tax;
1369 1369
     }
1370 1370
 
1371 1371
     /**
1372
-	 * Get the invoice fees total.
1373
-	 *
1374
-	 * @since 1.0.19
1375
-	 * @param  string $context View or edit context.
1376
-	 * @return float
1377
-	 */
1378
-	public function get_total_fees( $context = 'view' ) {
1379
-		return (float) $this->get_prop( 'total_fees', $context );
1372
+     * Get the invoice fees total.
1373
+     *
1374
+     * @since 1.0.19
1375
+     * @param  string $context View or edit context.
1376
+     * @return float
1377
+     */
1378
+    public function get_total_fees( $context = 'view' ) {
1379
+        return (float) $this->get_prop( 'total_fees', $context );
1380 1380
     }
1381 1381
 
1382 1382
     /**
1383
-	 * Alias for self::get_total_fees().
1384
-	 *
1385
-	 * @since 1.0.19
1386
-	 * @param  string $context View or edit context.
1387
-	 * @return float
1388
-	 */
1389
-	public function get_fees_total( $context = 'view' ) {
1390
-		return $this->get_total_fees( $context );
1383
+     * Alias for self::get_total_fees().
1384
+     *
1385
+     * @since 1.0.19
1386
+     * @param  string $context View or edit context.
1387
+     * @return float
1388
+     */
1389
+    public function get_fees_total( $context = 'view' ) {
1390
+        return $this->get_total_fees( $context );
1391 1391
     }
1392 1392
 
1393 1393
     /**
1394
-	 * Get the invoice total.
1395
-	 *
1396
-	 * @since 1.0.19
1394
+     * Get the invoice total.
1395
+     *
1396
+     * @since 1.0.19
1397 1397
      * @return float
1398
-	 */
1399
-	public function get_total() {
1400
-		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1401
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1402
-	}
1398
+     */
1399
+    public function get_total() {
1400
+        $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1401
+        return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1402
+    }
1403 1403
 	
1404
-	/**
1405
-	 * Get the invoice totals.
1406
-	 *
1407
-	 * @since 1.0.19
1404
+    /**
1405
+     * Get the invoice totals.
1406
+     *
1407
+     * @since 1.0.19
1408 1408
      * @return float
1409
-	 */
1410
-	public function get_totals() {
1411
-		return $this->totals;
1409
+     */
1410
+    public function get_totals() {
1411
+        return $this->totals;
1412 1412
     }
1413 1413
 
1414 1414
     /**
1415
-	 * Get the initial invoice total.
1416
-	 *
1417
-	 * @since 1.0.19
1415
+     * Get the initial invoice total.
1416
+     *
1417
+     * @since 1.0.19
1418 1418
      * @param  string $context View or edit context.
1419 1419
      * @return float
1420
-	 */
1420
+     */
1421 1421
     public function get_initial_total() {
1422 1422
 
1423
-		if ( empty( $this->totals ) ) {
1424
-			$this->recalculate_total();
1425
-		}
1423
+        if ( empty( $this->totals ) ) {
1424
+            $this->recalculate_total();
1425
+        }
1426 1426
 
1427
-		$tax      = $this->totals['tax']['initial'];
1428
-		$fee      = $this->totals['fee']['initial'];
1429
-		$discount = $this->totals['discount']['initial'];
1430
-		$subtotal = $this->totals['subtotal']['initial'];
1431
-		$total    = $tax + $fee - $discount + $subtotal;
1427
+        $tax      = $this->totals['tax']['initial'];
1428
+        $fee      = $this->totals['fee']['initial'];
1429
+        $discount = $this->totals['discount']['initial'];
1430
+        $subtotal = $this->totals['subtotal']['initial'];
1431
+        $total    = $tax + $fee - $discount + $subtotal;
1432 1432
 
1433
-		if ( 0 > $total ) {
1434
-			$total = 0;
1435
-		}
1433
+        if ( 0 > $total ) {
1434
+            $total = 0;
1435
+        }
1436 1436
 
1437 1437
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1438
-	}
1438
+    }
1439 1439
 
1440
-	/**
1441
-	 * Get the recurring invoice total.
1442
-	 *
1443
-	 * @since 1.0.19
1440
+    /**
1441
+     * Get the recurring invoice total.
1442
+     *
1443
+     * @since 1.0.19
1444 1444
      * @param  string $context View or edit context.
1445 1445
      * @return float
1446
-	 */
1446
+     */
1447 1447
     public function get_recurring_total() {
1448 1448
 
1449
-		if ( empty( $this->totals ) ) {
1450
-			$this->recalculate_total();
1451
-		}
1449
+        if ( empty( $this->totals ) ) {
1450
+            $this->recalculate_total();
1451
+        }
1452 1452
 
1453
-		$tax      = $this->totals['tax']['recurring'];
1454
-		$fee      = $this->totals['fee']['recurring'];
1455
-		$discount = $this->totals['discount']['recurring'];
1456
-		$subtotal = $this->totals['subtotal']['recurring'];
1457
-		$total    = $tax + $fee - $discount + $subtotal;
1453
+        $tax      = $this->totals['tax']['recurring'];
1454
+        $fee      = $this->totals['fee']['recurring'];
1455
+        $discount = $this->totals['discount']['recurring'];
1456
+        $subtotal = $this->totals['subtotal']['recurring'];
1457
+        $total    = $tax + $fee - $discount + $subtotal;
1458 1458
 
1459
-		if ( 0 > $total ) {
1460
-			$total = 0;
1461
-		}
1459
+        if ( 0 > $total ) {
1460
+            $total = 0;
1461
+        }
1462 1462
 
1463 1463
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1464
-	}
1464
+    }
1465 1465
 
1466
-	/**
1467
-	 * Returns recurring payment details.
1468
-	 *
1469
-	 * @since 1.0.19
1466
+    /**
1467
+     * Returns recurring payment details.
1468
+     *
1469
+     * @since 1.0.19
1470 1470
      * @param  string $field Optionally provide a field to return.
1471
-	 * @param string $currency Whether to include the currency.
1471
+     * @param string $currency Whether to include the currency.
1472 1472
      * @return float
1473
-	 */
1473
+     */
1474 1474
     public function get_recurring_details( $field = '', $currency = false ) {
1475 1475
 
1476
-		// Maybe recalculate totals.
1477
-		if ( empty( $this->totals ) ) {
1478
-			$this->recalculate_total();
1479
-		}
1476
+        // Maybe recalculate totals.
1477
+        if ( empty( $this->totals ) ) {
1478
+            $this->recalculate_total();
1479
+        }
1480 1480
 
1481
-		// Prepare recurring totals.
1481
+        // Prepare recurring totals.
1482 1482
         $data = apply_filters(
1483
-			'wpinv_get_invoice_recurring_details',
1484
-			array(
1485
-				'cart_details' => $this->get_cart_details(),
1486
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1487
-				'discount'     => $this->totals['discount']['recurring'],
1488
-				'tax'          => $this->totals['tax']['recurring'],
1489
-				'fee'          => $this->totals['fee']['recurring'],
1490
-				'total'        => $this->get_recurring_total(),
1491
-			),
1492
-			$this,
1493
-			$field,
1494
-			$currency
1495
-		);
1483
+            'wpinv_get_invoice_recurring_details',
1484
+            array(
1485
+                'cart_details' => $this->get_cart_details(),
1486
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1487
+                'discount'     => $this->totals['discount']['recurring'],
1488
+                'tax'          => $this->totals['tax']['recurring'],
1489
+                'fee'          => $this->totals['fee']['recurring'],
1490
+                'total'        => $this->get_recurring_total(),
1491
+            ),
1492
+            $this,
1493
+            $field,
1494
+            $currency
1495
+        );
1496 1496
 
1497 1497
         if ( isset( $data[$field] ) ) {
1498 1498
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1502,156 +1502,156 @@  discard block
 block discarded – undo
1502 1502
     }
1503 1503
 
1504 1504
     /**
1505
-	 * Get the invoice fees.
1506
-	 *
1507
-	 * @since 1.0.19
1508
-	 * @param  string $context View or edit context.
1509
-	 * @return array
1510
-	 */
1511
-	public function get_fees( $context = 'view' ) {
1512
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1505
+     * Get the invoice fees.
1506
+     *
1507
+     * @since 1.0.19
1508
+     * @param  string $context View or edit context.
1509
+     * @return array
1510
+     */
1511
+    public function get_fees( $context = 'view' ) {
1512
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1513 1513
     }
1514 1514
 
1515 1515
     /**
1516
-	 * Get the invoice discounts.
1517
-	 *
1518
-	 * @since 1.0.19
1519
-	 * @param  string $context View or edit context.
1520
-	 * @return array
1521
-	 */
1522
-	public function get_discounts( $context = 'view' ) {
1523
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1516
+     * Get the invoice discounts.
1517
+     *
1518
+     * @since 1.0.19
1519
+     * @param  string $context View or edit context.
1520
+     * @return array
1521
+     */
1522
+    public function get_discounts( $context = 'view' ) {
1523
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1524 1524
     }
1525 1525
 
1526 1526
     /**
1527
-	 * Get the invoice taxes.
1528
-	 *
1529
-	 * @since 1.0.19
1530
-	 * @param  string $context View or edit context.
1531
-	 * @return array
1532
-	 */
1533
-	public function get_taxes( $context = 'view' ) {
1534
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1527
+     * Get the invoice taxes.
1528
+     *
1529
+     * @since 1.0.19
1530
+     * @param  string $context View or edit context.
1531
+     * @return array
1532
+     */
1533
+    public function get_taxes( $context = 'view' ) {
1534
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1535 1535
     }
1536 1536
 
1537 1537
     /**
1538
-	 * Get the invoice items.
1539
-	 *
1540
-	 * @since 1.0.19
1541
-	 * @param  string $context View or edit context.
1542
-	 * @return GetPaid_Form_Item[]
1543
-	 */
1544
-	public function get_items( $context = 'view' ) {
1538
+     * Get the invoice items.
1539
+     *
1540
+     * @since 1.0.19
1541
+     * @param  string $context View or edit context.
1542
+     * @return GetPaid_Form_Item[]
1543
+     */
1544
+    public function get_items( $context = 'view' ) {
1545 1545
         return $this->get_prop( 'items', $context );
1546 1546
     }
1547 1547
 
1548 1548
     /**
1549
-	 * Get the invoice's payment form.
1550
-	 *
1551
-	 * @since 1.0.19
1552
-	 * @param  string $context View or edit context.
1553
-	 * @return int
1554
-	 */
1555
-	public function get_payment_form( $context = 'view' ) {
1556
-		return intval( $this->get_prop( 'payment_form', $context ) );
1549
+     * Get the invoice's payment form.
1550
+     *
1551
+     * @since 1.0.19
1552
+     * @param  string $context View or edit context.
1553
+     * @return int
1554
+     */
1555
+    public function get_payment_form( $context = 'view' ) {
1556
+        return intval( $this->get_prop( 'payment_form', $context ) );
1557 1557
     }
1558 1558
 
1559 1559
     /**
1560
-	 * Get the invoice's submission id.
1561
-	 *
1562
-	 * @since 1.0.19
1563
-	 * @param  string $context View or edit context.
1564
-	 * @return string
1565
-	 */
1566
-	public function get_submission_id( $context = 'view' ) {
1567
-		return $this->get_prop( 'submission_id', $context );
1560
+     * Get the invoice's submission id.
1561
+     *
1562
+     * @since 1.0.19
1563
+     * @param  string $context View or edit context.
1564
+     * @return string
1565
+     */
1566
+    public function get_submission_id( $context = 'view' ) {
1567
+        return $this->get_prop( 'submission_id', $context );
1568 1568
     }
1569 1569
 
1570 1570
     /**
1571
-	 * Get the invoice's discount code.
1572
-	 *
1573
-	 * @since 1.0.19
1574
-	 * @param  string $context View or edit context.
1575
-	 * @return string
1576
-	 */
1577
-	public function get_discount_code( $context = 'view' ) {
1578
-		return $this->get_prop( 'discount_code', $context );
1571
+     * Get the invoice's discount code.
1572
+     *
1573
+     * @since 1.0.19
1574
+     * @param  string $context View or edit context.
1575
+     * @return string
1576
+     */
1577
+    public function get_discount_code( $context = 'view' ) {
1578
+        return $this->get_prop( 'discount_code', $context );
1579 1579
     }
1580 1580
 
1581 1581
     /**
1582
-	 * Get the invoice's gateway.
1583
-	 *
1584
-	 * @since 1.0.19
1585
-	 * @param  string $context View or edit context.
1586
-	 * @return string
1587
-	 */
1588
-	public function get_gateway( $context = 'view' ) {
1589
-		return $this->get_prop( 'gateway', $context );
1582
+     * Get the invoice's gateway.
1583
+     *
1584
+     * @since 1.0.19
1585
+     * @param  string $context View or edit context.
1586
+     * @return string
1587
+     */
1588
+    public function get_gateway( $context = 'view' ) {
1589
+        return $this->get_prop( 'gateway', $context );
1590 1590
     }
1591 1591
 
1592 1592
     /**
1593
-	 * Get the invoice's gateway display title.
1594
-	 *
1595
-	 * @since 1.0.19
1596
-	 * @return string
1597
-	 */
1593
+     * Get the invoice's gateway display title.
1594
+     *
1595
+     * @since 1.0.19
1596
+     * @return string
1597
+     */
1598 1598
     public function get_gateway_title() {
1599 1599
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1600 1600
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1601 1601
     }
1602 1602
 
1603 1603
     /**
1604
-	 * Get the invoice's transaction id.
1605
-	 *
1606
-	 * @since 1.0.19
1607
-	 * @param  string $context View or edit context.
1608
-	 * @return string
1609
-	 */
1610
-	public function get_transaction_id( $context = 'view' ) {
1611
-		return $this->get_prop( 'transaction_id', $context );
1604
+     * Get the invoice's transaction id.
1605
+     *
1606
+     * @since 1.0.19
1607
+     * @param  string $context View or edit context.
1608
+     * @return string
1609
+     */
1610
+    public function get_transaction_id( $context = 'view' ) {
1611
+        return $this->get_prop( 'transaction_id', $context );
1612 1612
     }
1613 1613
 
1614 1614
     /**
1615
-	 * Get the invoice's currency.
1616
-	 *
1617
-	 * @since 1.0.19
1618
-	 * @param  string $context View or edit context.
1619
-	 * @return string
1620
-	 */
1621
-	public function get_currency( $context = 'view' ) {
1615
+     * Get the invoice's currency.
1616
+     *
1617
+     * @since 1.0.19
1618
+     * @param  string $context View or edit context.
1619
+     * @return string
1620
+     */
1621
+    public function get_currency( $context = 'view' ) {
1622 1622
         $currency = $this->get_prop( 'currency', $context );
1623 1623
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1624 1624
     }
1625 1625
 
1626 1626
     /**
1627
-	 * Checks if we are charging taxes for this invoice.
1628
-	 *
1629
-	 * @since 1.0.19
1630
-	 * @param  string $context View or edit context.
1631
-	 * @return bool
1632
-	 */
1633
-	public function get_disable_taxes( $context = 'view' ) {
1627
+     * Checks if we are charging taxes for this invoice.
1628
+     *
1629
+     * @since 1.0.19
1630
+     * @param  string $context View or edit context.
1631
+     * @return bool
1632
+     */
1633
+    public function get_disable_taxes( $context = 'view' ) {
1634 1634
         return (bool) $this->get_prop( 'disable_taxes', $context );
1635 1635
     }
1636 1636
 
1637 1637
     /**
1638
-	 * Retrieves the subscription id for an invoice.
1639
-	 *
1640
-	 * @since 1.0.19
1641
-	 * @param  string $context View or edit context.
1642
-	 * @return int
1643
-	 */
1638
+     * Retrieves the subscription id for an invoice.
1639
+     *
1640
+     * @since 1.0.19
1641
+     * @param  string $context View or edit context.
1642
+     * @return int
1643
+     */
1644 1644
     public function get_subscription_id( $context = 'view' ) {
1645
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1646
-	}
1647
-
1648
-	/**
1649
-	 * Retrieves the remote subscription id for an invoice.
1650
-	 *
1651
-	 * @since 1.0.19
1652
-	 * @param  string $context View or edit context.
1653
-	 * @return int
1654
-	 */
1645
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1646
+    }
1647
+
1648
+    /**
1649
+     * Retrieves the remote subscription id for an invoice.
1650
+     *
1651
+     * @since 1.0.19
1652
+     * @param  string $context View or edit context.
1653
+     * @return int
1654
+     */
1655 1655
     public function get_remote_subscription_id( $context = 'view' ) {
1656 1656
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1657 1657
 
@@ -1664,12 +1664,12 @@  discard block
 block discarded – undo
1664 1664
     }
1665 1665
 
1666 1666
     /**
1667
-	 * Retrieves the payment meta for an invoice.
1668
-	 *
1669
-	 * @since 1.0.19
1670
-	 * @param  string $context View or edit context.
1671
-	 * @return array
1672
-	 */
1667
+     * Retrieves the payment meta for an invoice.
1668
+     *
1669
+     * @since 1.0.19
1670
+     * @param  string $context View or edit context.
1671
+     * @return array
1672
+     */
1673 1673
     public function get_payment_meta( $context = 'view' ) {
1674 1674
 
1675 1675
         return array(
@@ -1689,31 +1689,31 @@  discard block
 block discarded – undo
1689 1689
     }
1690 1690
 
1691 1691
     /**
1692
-	 * Retrieves the cart details for an invoice.
1693
-	 *
1694
-	 * @since 1.0.19
1695
-	 * @return array
1696
-	 */
1692
+     * Retrieves the cart details for an invoice.
1693
+     *
1694
+     * @since 1.0.19
1695
+     * @return array
1696
+     */
1697 1697
     public function get_cart_details() {
1698 1698
         $items        = $this->get_items();
1699 1699
         $cart_details = array();
1700 1700
 
1701 1701
         foreach ( $items as $item_id => $item ) {
1702
-			$item->invoice_id = $this->get_id();
1702
+            $item->invoice_id = $this->get_id();
1703 1703
             $cart_details[]   = $item->prepare_data_for_saving();
1704 1704
         }
1705 1705
 
1706 1706
         return $cart_details;
1707
-	}
1707
+    }
1708 1708
 
1709
-	/**
1710
-	 * Retrieves the recurring item.
1711
-	 *
1712
-	 * @return null|GetPaid_Form_Item|int
1713
-	 */
1714
-	public function get_recurring( $object = false ) {
1709
+    /**
1710
+     * Retrieves the recurring item.
1711
+     *
1712
+     * @return null|GetPaid_Form_Item|int
1713
+     */
1714
+    public function get_recurring( $object = false ) {
1715 1715
 
1716
-		// Are we returning an object?
1716
+        // Are we returning an object?
1717 1717
         if ( $object ) {
1718 1718
             return $this->get_item( $this->recurring_item );
1719 1719
         }
@@ -1721,100 +1721,100 @@  discard block
 block discarded – undo
1721 1721
         return $this->recurring_item;
1722 1722
     }
1723 1723
 
1724
-	/**
1725
-	 * Retrieves the subscription name.
1726
-	 *
1727
-	 * @since 1.0.19
1728
-	 * @return string
1729
-	 */
1730
-	public function get_subscription_name() {
1724
+    /**
1725
+     * Retrieves the subscription name.
1726
+     *
1727
+     * @since 1.0.19
1728
+     * @return string
1729
+     */
1730
+    public function get_subscription_name() {
1731 1731
 
1732
-		// Retrieve the recurring name
1732
+        // Retrieve the recurring name
1733 1733
         $item = $this->get_recurring( true );
1734 1734
 
1735
-		// Abort if it does not exist.
1735
+        // Abort if it does not exist.
1736 1736
         if ( empty( $item ) ) {
1737 1737
             return '';
1738 1738
         }
1739 1739
 
1740
-		// Return the item name.
1740
+        // Return the item name.
1741 1741
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1742
-	}
1743
-
1744
-	/**
1745
-	 * Retrieves the view url.
1746
-	 *
1747
-	 * @since 1.0.19
1748
-	 * @return string
1749
-	 */
1750
-	public function get_view_url() {
1742
+    }
1743
+
1744
+    /**
1745
+     * Retrieves the view url.
1746
+     *
1747
+     * @since 1.0.19
1748
+     * @return string
1749
+     */
1750
+    public function get_view_url() {
1751 1751
         $invoice_url = get_permalink( $this->get_id() );
1752
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1752
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1753 1753
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1754
-	}
1754
+    }
1755 1755
 
1756
-	/**
1757
-	 * Retrieves the payment url.
1758
-	 *
1759
-	 * @since 1.0.19
1760
-	 * @return string
1761
-	 */
1762
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1756
+    /**
1757
+     * Retrieves the payment url.
1758
+     *
1759
+     * @since 1.0.19
1760
+     * @return string
1761
+     */
1762
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1763 1763
 
1764
-		// Retrieve the checkout url.
1764
+        // Retrieve the checkout url.
1765 1765
         $pay_url = wpinv_get_checkout_uri();
1766 1766
 
1767
-		// Maybe force ssl.
1767
+        // Maybe force ssl.
1768 1768
         if ( is_ssl() ) {
1769 1769
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1770 1770
         }
1771 1771
 
1772
-		// Add the invoice key.
1773
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1772
+        // Add the invoice key.
1773
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1774 1774
 
1775
-		// (Maybe?) add a secret
1775
+        // (Maybe?) add a secret
1776 1776
         if ( $secret ) {
1777 1777
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1778 1778
         }
1779 1779
 
1780 1780
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1781
-	}
1781
+    }
1782 1782
 	
1783
-	/**
1784
-	 * Retrieves the receipt url.
1785
-	 *
1786
-	 * @since 1.0.19
1787
-	 * @return string
1788
-	 */
1789
-	public function get_receipt_url() {
1790
-
1791
-		// Retrieve the checkout url.
1783
+    /**
1784
+     * Retrieves the receipt url.
1785
+     *
1786
+     * @since 1.0.19
1787
+     * @return string
1788
+     */
1789
+    public function get_receipt_url() {
1790
+
1791
+        // Retrieve the checkout url.
1792 1792
         $receipt_url = wpinv_get_success_page_uri();
1793 1793
 
1794
-		// Maybe force ssl.
1794
+        // Maybe force ssl.
1795 1795
         if ( is_ssl() ) {
1796 1796
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1797 1797
         }
1798 1798
 
1799
-		// Add the invoice key.
1800
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1799
+        // Add the invoice key.
1800
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1801 1801
 
1802 1802
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1803 1803
     }
1804 1804
 
1805 1805
     /**
1806
-	 * Magic method for accessing invoice properties.
1807
-	 *
1808
-	 * @since 1.0.15
1809
-	 * @access public
1810
-	 *
1811
-	 * @param string $key Discount data to retrieve
1812
-	 * @param  string $context View or edit context.
1813
-	 * @return mixed Value of the given invoice property (if set).
1814
-	 */
1815
-	public function get( $key, $context = 'view' ) {
1806
+     * Magic method for accessing invoice properties.
1807
+     *
1808
+     * @since 1.0.15
1809
+     * @access public
1810
+     *
1811
+     * @param string $key Discount data to retrieve
1812
+     * @param  string $context View or edit context.
1813
+     * @return mixed Value of the given invoice property (if set).
1814
+     */
1815
+    public function get( $key, $context = 'view' ) {
1816 1816
         return $this->get_prop( $key, $context );
1817
-	}
1817
+    }
1818 1818
 
1819 1819
     /*
1820 1820
 	|--------------------------------------------------------------------------
@@ -1827,130 +1827,130 @@  discard block
 block discarded – undo
1827 1827
     */
1828 1828
 
1829 1829
     /**
1830
-	 * Magic method for setting invoice properties.
1831
-	 *
1832
-	 * @since 1.0.19
1833
-	 * @access public
1834
-	 *
1835
-	 * @param string $key Discount data to retrieve
1836
-	 * @param  mixed $value new value.
1837
-	 * @return mixed Value of the given invoice property (if set).
1838
-	 */
1839
-	public function set( $key, $value ) {
1830
+     * Magic method for setting invoice properties.
1831
+     *
1832
+     * @since 1.0.19
1833
+     * @access public
1834
+     *
1835
+     * @param string $key Discount data to retrieve
1836
+     * @param  mixed $value new value.
1837
+     * @return mixed Value of the given invoice property (if set).
1838
+     */
1839
+    public function set( $key, $value ) {
1840 1840
 
1841 1841
         $setter = "set_$key";
1842 1842
         if ( is_callable( array( $this, $setter ) ) ) {
1843 1843
             $this->{$setter}( $value );
1844 1844
         }
1845 1845
 
1846
-	}
1846
+    }
1847 1847
 
1848
-	/**
1849
-	 * Sets item status.
1850
-	 *
1851
-	 * @since 1.0.19
1852
-	 * @param string $new_status    New status.
1853
-	 * @param string $note          Optional note to add.
1854
-	 * @param bool   $manual_update Is this a manual status change?.
1855
-	 * @return array details of change.
1856
-	 */
1857
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1858
-		$old_status = $this->get_status();
1848
+    /**
1849
+     * Sets item status.
1850
+     *
1851
+     * @since 1.0.19
1852
+     * @param string $new_status    New status.
1853
+     * @param string $note          Optional note to add.
1854
+     * @param bool   $manual_update Is this a manual status change?.
1855
+     * @return array details of change.
1856
+     */
1857
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1858
+        $old_status = $this->get_status();
1859 1859
 
1860
-		$statuses = $this->get_all_statuses();
1860
+        $statuses = $this->get_all_statuses();
1861 1861
 
1862
-		if ( isset( $statuses[ 'draft' ] ) ) {
1863
-			unset( $statuses[ 'draft' ] );
1864
-		}
1862
+        if ( isset( $statuses[ 'draft' ] ) ) {
1863
+            unset( $statuses[ 'draft' ] );
1864
+        }
1865 1865
 
1866
-		$this->set_prop( 'status', $new_status );
1866
+        $this->set_prop( 'status', $new_status );
1867 1867
 
1868
-		// If setting the status, ensure it's set to a valid status.
1869
-		if ( true === $this->object_read ) {
1868
+        // If setting the status, ensure it's set to a valid status.
1869
+        if ( true === $this->object_read ) {
1870 1870
 
1871
-			// Only allow valid new status.
1872
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1873
-				$new_status = 'wpi-pending';
1874
-			}
1871
+            // Only allow valid new status.
1872
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1873
+                $new_status = 'wpi-pending';
1874
+            }
1875 1875
 
1876
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1877
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1878
-				$old_status = 'wpi-pending';
1879
-			}
1876
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1877
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1878
+                $old_status = 'wpi-pending';
1879
+            }
1880 1880
 
1881
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1882
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1883
-				$old_status = 'wpi-pending';
1884
-			}
1881
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1882
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1883
+                $old_status = 'wpi-pending';
1884
+            }
1885 1885
 
1886
-		}
1886
+        }
1887 1887
 
1888
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1889
-			$this->status_transition = array(
1890
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1891
-				'to'     => $new_status,
1892
-				'note'   => $note,
1893
-				'manual' => (bool) $manual_update,
1894
-			);
1888
+        if ( true === $this->object_read && $old_status !== $new_status ) {
1889
+            $this->status_transition = array(
1890
+                'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1891
+                'to'     => $new_status,
1892
+                'note'   => $note,
1893
+                'manual' => (bool) $manual_update,
1894
+            );
1895 1895
 
1896
-			if ( $manual_update ) {
1897
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1898
-			}
1896
+            if ( $manual_update ) {
1897
+                do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1898
+            }
1899 1899
 
1900
-			$this->maybe_set_date_paid();
1900
+            $this->maybe_set_date_paid();
1901 1901
 
1902
-		}
1902
+        }
1903 1903
 
1904
-		return array(
1905
-			'from' => $old_status,
1906
-			'to'   => $new_status,
1907
-		);
1908
-	}
1904
+        return array(
1905
+            'from' => $old_status,
1906
+            'to'   => $new_status,
1907
+        );
1908
+    }
1909 1909
 
1910
-	/**
1911
-	 * Maybe set date paid.
1912
-	 *
1913
-	 * Sets the date paid variable when transitioning to the payment complete
1914
-	 * order status.
1915
-	 *
1916
-	 * @since 1.0.19
1917
-	 */
1918
-	public function maybe_set_date_paid() {
1910
+    /**
1911
+     * Maybe set date paid.
1912
+     *
1913
+     * Sets the date paid variable when transitioning to the payment complete
1914
+     * order status.
1915
+     *
1916
+     * @since 1.0.19
1917
+     */
1918
+    public function maybe_set_date_paid() {
1919 1919
 
1920
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1921
-			$this->set_date_completed( current_time( 'mysql' ) );
1922
-		}
1923
-	}
1920
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1921
+            $this->set_date_completed( current_time( 'mysql' ) );
1922
+        }
1923
+    }
1924 1924
 
1925 1925
     /**
1926
-	 * Set parent invoice ID.
1927
-	 *
1928
-	 * @since 1.0.19
1929
-	 */
1930
-	public function set_parent_id( $value ) {
1931
-		if ( $value && ( $value === $this->get_id() ) ) {
1932
-			return;
1933
-		}
1934
-		$this->set_prop( 'parent_id', absint( $value ) );
1926
+     * Set parent invoice ID.
1927
+     *
1928
+     * @since 1.0.19
1929
+     */
1930
+    public function set_parent_id( $value ) {
1931
+        if ( $value && ( $value === $this->get_id() ) ) {
1932
+            return;
1933
+        }
1934
+        $this->set_prop( 'parent_id', absint( $value ) );
1935 1935
     }
1936 1936
 
1937 1937
     /**
1938
-	 * Set plugin version when the invoice was created.
1939
-	 *
1940
-	 * @since 1.0.19
1941
-	 */
1942
-	public function set_version( $value ) {
1943
-		$this->set_prop( 'version', $value );
1938
+     * Set plugin version when the invoice was created.
1939
+     *
1940
+     * @since 1.0.19
1941
+     */
1942
+    public function set_version( $value ) {
1943
+        $this->set_prop( 'version', $value );
1944 1944
     }
1945
-
1946
-    /**
1947
-	 * Set date when the invoice was created.
1948
-	 *
1949
-	 * @since 1.0.19
1950
-	 * @param string $value Value to set.
1945
+
1946
+    /**
1947
+     * Set date when the invoice was created.
1948
+     *
1949
+     * @since 1.0.19
1950
+     * @param string $value Value to set.
1951 1951
      * @return bool Whether or not the date was set.
1952
-	 */
1953
-	public function set_date_created( $value ) {
1952
+     */
1953
+    public function set_date_created( $value ) {
1954 1954
         $date = strtotime( $value );
1955 1955
 
1956 1956
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1963,13 +1963,13 @@  discard block
 block discarded – undo
1963 1963
     }
1964 1964
 
1965 1965
     /**
1966
-	 * Set date invoice due date.
1967
-	 *
1968
-	 * @since 1.0.19
1969
-	 * @param string $value Value to set.
1966
+     * Set date invoice due date.
1967
+     *
1968
+     * @since 1.0.19
1969
+     * @param string $value Value to set.
1970 1970
      * @return bool Whether or not the date was set.
1971
-	 */
1972
-	public function set_due_date( $value ) {
1971
+     */
1972
+    public function set_due_date( $value ) {
1973 1973
         $date = strtotime( $value );
1974 1974
 
1975 1975
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1977,29 +1977,29 @@  discard block
 block discarded – undo
1977 1977
             return true;
1978 1978
         }
1979 1979
 
1980
-		$this->set_prop( 'due_date', '' );
1980
+        $this->set_prop( 'due_date', '' );
1981 1981
         return false;
1982 1982
 
1983 1983
     }
1984 1984
 
1985 1985
     /**
1986
-	 * Alias of self::set_due_date().
1987
-	 *
1988
-	 * @since 1.0.19
1989
-	 * @param  string $value New name.
1990
-	 */
1991
-	public function set_date_due( $value ) {
1992
-		$this->set_due_date( $value );
1986
+     * Alias of self::set_due_date().
1987
+     *
1988
+     * @since 1.0.19
1989
+     * @param  string $value New name.
1990
+     */
1991
+    public function set_date_due( $value ) {
1992
+        $this->set_due_date( $value );
1993 1993
     }
1994 1994
 
1995 1995
     /**
1996
-	 * Set date invoice was completed.
1997
-	 *
1998
-	 * @since 1.0.19
1999
-	 * @param string $value Value to set.
1996
+     * Set date invoice was completed.
1997
+     *
1998
+     * @since 1.0.19
1999
+     * @param string $value Value to set.
2000 2000
      * @return bool Whether or not the date was set.
2001
-	 */
2002
-	public function set_completed_date( $value ) {
2001
+     */
2002
+    public function set_completed_date( $value ) {
2003 2003
         $date = strtotime( $value );
2004 2004
 
2005 2005
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -2007,29 +2007,29 @@  discard block
 block discarded – undo
2007 2007
             return true;
2008 2008
         }
2009 2009
 
2010
-		$this->set_prop( 'completed_date', '' );
2010
+        $this->set_prop( 'completed_date', '' );
2011 2011
         return false;
2012 2012
 
2013 2013
     }
2014 2014
 
2015 2015
     /**
2016
-	 * Alias of self::set_completed_date().
2017
-	 *
2018
-	 * @since 1.0.19
2019
-	 * @param  string $value New name.
2020
-	 */
2021
-	public function set_date_completed( $value ) {
2022
-		$this->set_completed_date( $value );
2016
+     * Alias of self::set_completed_date().
2017
+     *
2018
+     * @since 1.0.19
2019
+     * @param  string $value New name.
2020
+     */
2021
+    public function set_date_completed( $value ) {
2022
+        $this->set_completed_date( $value );
2023 2023
     }
2024 2024
 
2025 2025
     /**
2026
-	 * Set date when the invoice was last modified.
2027
-	 *
2028
-	 * @since 1.0.19
2029
-	 * @param string $value Value to set.
2026
+     * Set date when the invoice was last modified.
2027
+     *
2028
+     * @since 1.0.19
2029
+     * @param string $value Value to set.
2030 2030
      * @return bool Whether or not the date was set.
2031
-	 */
2032
-	public function set_date_modified( $value ) {
2031
+     */
2032
+    public function set_date_modified( $value ) {
2033 2033
         $date = strtotime( $value );
2034 2034
 
2035 2035
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2037,753 +2037,753 @@  discard block
 block discarded – undo
2037 2037
             return true;
2038 2038
         }
2039 2039
 
2040
-		$this->set_prop( 'date_modified', '' );
2040
+        $this->set_prop( 'date_modified', '' );
2041 2041
         return false;
2042 2042
 
2043 2043
     }
2044 2044
 
2045 2045
     /**
2046
-	 * Set the invoice number.
2047
-	 *
2048
-	 * @since 1.0.19
2049
-	 * @param  string $value New number.
2050
-	 */
2051
-	public function set_number( $value ) {
2046
+     * Set the invoice number.
2047
+     *
2048
+     * @since 1.0.19
2049
+     * @param  string $value New number.
2050
+     */
2051
+    public function set_number( $value ) {
2052 2052
         $number = sanitize_text_field( $value );
2053
-		$this->set_prop( 'number', $number );
2053
+        $this->set_prop( 'number', $number );
2054 2054
     }
2055 2055
 
2056 2056
     /**
2057
-	 * Set the invoice type.
2058
-	 *
2059
-	 * @since 1.0.19
2060
-	 * @param  string $value Type.
2061
-	 */
2062
-	public function set_type( $value ) {
2057
+     * Set the invoice type.
2058
+     *
2059
+     * @since 1.0.19
2060
+     * @param  string $value Type.
2061
+     */
2062
+    public function set_type( $value ) {
2063 2063
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2064
-		$this->set_prop( 'type', $type );
2065
-	}
2064
+        $this->set_prop( 'type', $type );
2065
+    }
2066 2066
 
2067 2067
     /**
2068
-	 * Set the invoice post type.
2069
-	 *
2070
-	 * @since 1.0.19
2071
-	 * @param  string $value Post type.
2072
-	 */
2073
-	public function set_post_type( $value ) {
2068
+     * Set the invoice post type.
2069
+     *
2070
+     * @since 1.0.19
2071
+     * @param  string $value Post type.
2072
+     */
2073
+    public function set_post_type( $value ) {
2074 2074
         if ( getpaid_is_invoice_post_type( $value ) ) {
2075
-			$this->set_type( $value );
2075
+            $this->set_type( $value );
2076 2076
             $this->set_prop( 'post_type', $value );
2077 2077
         }
2078 2078
     }
2079 2079
 
2080 2080
     /**
2081
-	 * Set the invoice key.
2082
-	 *
2083
-	 * @since 1.0.19
2084
-	 * @param  string $value New key.
2085
-	 */
2086
-	public function set_key( $value ) {
2081
+     * Set the invoice key.
2082
+     *
2083
+     * @since 1.0.19
2084
+     * @param  string $value New key.
2085
+     */
2086
+    public function set_key( $value ) {
2087 2087
         $key = sanitize_text_field( $value );
2088
-		$this->set_prop( 'key', $key );
2088
+        $this->set_prop( 'key', $key );
2089 2089
     }
2090 2090
 
2091 2091
     /**
2092
-	 * Set the invoice mode.
2093
-	 *
2094
-	 * @since 1.0.19
2095
-	 * @param  string $value mode.
2096
-	 */
2097
-	public function set_mode( $value ) {
2092
+     * Set the invoice mode.
2093
+     *
2094
+     * @since 1.0.19
2095
+     * @param  string $value mode.
2096
+     */
2097
+    public function set_mode( $value ) {
2098 2098
         if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2099 2099
             $this->set_prop( 'value', $value );
2100 2100
         }
2101 2101
     }
2102 2102
 
2103 2103
     /**
2104
-	 * Set the invoice path.
2105
-	 *
2106
-	 * @since 1.0.19
2107
-	 * @param  string $value path.
2108
-	 */
2109
-	public function set_path( $value ) {
2104
+     * Set the invoice path.
2105
+     *
2106
+     * @since 1.0.19
2107
+     * @param  string $value path.
2108
+     */
2109
+    public function set_path( $value ) {
2110 2110
         $this->set_prop( 'path', $value );
2111 2111
     }
2112 2112
 
2113 2113
     /**
2114
-	 * Set the invoice name.
2115
-	 *
2116
-	 * @since 1.0.19
2117
-	 * @param  string $value New name.
2118
-	 */
2119
-	public function set_name( $value ) {
2114
+     * Set the invoice name.
2115
+     *
2116
+     * @since 1.0.19
2117
+     * @param  string $value New name.
2118
+     */
2119
+    public function set_name( $value ) {
2120 2120
         $name = sanitize_text_field( $value );
2121
-		$this->set_prop( 'name', $name );
2121
+        $this->set_prop( 'name', $name );
2122 2122
     }
2123 2123
 
2124 2124
     /**
2125
-	 * Alias of self::set_name().
2126
-	 *
2127
-	 * @since 1.0.19
2128
-	 * @param  string $value New name.
2129
-	 */
2130
-	public function set_title( $value ) {
2131
-		$this->set_name( $value );
2125
+     * Alias of self::set_name().
2126
+     *
2127
+     * @since 1.0.19
2128
+     * @param  string $value New name.
2129
+     */
2130
+    public function set_title( $value ) {
2131
+        $this->set_name( $value );
2132 2132
     }
2133 2133
 
2134 2134
     /**
2135
-	 * Set the invoice description.
2136
-	 *
2137
-	 * @since 1.0.19
2138
-	 * @param  string $value New description.
2139
-	 */
2140
-	public function set_description( $value ) {
2135
+     * Set the invoice description.
2136
+     *
2137
+     * @since 1.0.19
2138
+     * @param  string $value New description.
2139
+     */
2140
+    public function set_description( $value ) {
2141 2141
         $description = wp_kses_post( $value );
2142
-		return $this->set_prop( 'description', $description );
2142
+        return $this->set_prop( 'description', $description );
2143 2143
     }
2144 2144
 
2145 2145
     /**
2146
-	 * Alias of self::set_description().
2147
-	 *
2148
-	 * @since 1.0.19
2149
-	 * @param  string $value New description.
2150
-	 */
2151
-	public function set_excerpt( $value ) {
2152
-		$this->set_description( $value );
2146
+     * Alias of self::set_description().
2147
+     *
2148
+     * @since 1.0.19
2149
+     * @param  string $value New description.
2150
+     */
2151
+    public function set_excerpt( $value ) {
2152
+        $this->set_description( $value );
2153 2153
     }
2154 2154
 
2155 2155
     /**
2156
-	 * Alias of self::set_description().
2157
-	 *
2158
-	 * @since 1.0.19
2159
-	 * @param  string $value New description.
2160
-	 */
2161
-	public function set_summary( $value ) {
2162
-		$this->set_description( $value );
2156
+     * Alias of self::set_description().
2157
+     *
2158
+     * @since 1.0.19
2159
+     * @param  string $value New description.
2160
+     */
2161
+    public function set_summary( $value ) {
2162
+        $this->set_description( $value );
2163 2163
     }
2164 2164
 
2165 2165
     /**
2166
-	 * Set the receiver of the invoice.
2167
-	 *
2168
-	 * @since 1.0.19
2169
-	 * @param  int $value New author.
2170
-	 */
2171
-	public function set_author( $value ) {
2172
-		$user = get_user_by( 'id', (int) $value );
2166
+     * Set the receiver of the invoice.
2167
+     *
2168
+     * @since 1.0.19
2169
+     * @param  int $value New author.
2170
+     */
2171
+    public function set_author( $value ) {
2172
+        $user = get_user_by( 'id', (int) $value );
2173 2173
 
2174
-		if ( $user && $user->ID ) {
2175
-			$this->set_prop( 'author', $user->ID );
2176
-			$this->set_prop( 'email', $user->user_email );
2177
-		}
2174
+        if ( $user && $user->ID ) {
2175
+            $this->set_prop( 'author', $user->ID );
2176
+            $this->set_prop( 'email', $user->user_email );
2177
+        }
2178 2178
 		
2179 2179
     }
2180 2180
 
2181 2181
     /**
2182
-	 * Alias of self::set_author().
2183
-	 *
2184
-	 * @since 1.0.19
2185
-	 * @param  int $value New user id.
2186
-	 */
2187
-	public function set_user_id( $value ) {
2188
-		$this->set_author( $value );
2182
+     * Alias of self::set_author().
2183
+     *
2184
+     * @since 1.0.19
2185
+     * @param  int $value New user id.
2186
+     */
2187
+    public function set_user_id( $value ) {
2188
+        $this->set_author( $value );
2189
+    }
2190
+
2191
+    /**
2192
+     * Alias of self::set_author().
2193
+     *
2194
+     * @since 1.0.19
2195
+     * @param  int $value New user id.
2196
+     */
2197
+    public function set_customer_id( $value ) {
2198
+        $this->set_author( $value );
2199
+    }
2200
+
2201
+    /**
2202
+     * Set the customer's ip.
2203
+     *
2204
+     * @since 1.0.19
2205
+     * @param  string $value ip address.
2206
+     */
2207
+    public function set_ip( $value ) {
2208
+        $this->set_prop( 'ip', $value );
2209
+    }
2210
+
2211
+    /**
2212
+     * Alias of self::set_ip().
2213
+     *
2214
+     * @since 1.0.19
2215
+     * @param  string $value ip address.
2216
+     */
2217
+    public function set_user_ip( $value ) {
2218
+        $this->set_ip( $value );
2189 2219
     }
2190 2220
 
2191 2221
     /**
2192
-	 * Alias of self::set_author().
2193
-	 *
2194
-	 * @since 1.0.19
2195
-	 * @param  int $value New user id.
2196
-	 */
2197
-	public function set_customer_id( $value ) {
2198
-		$this->set_author( $value );
2222
+     * Set the customer's first name.
2223
+     *
2224
+     * @since 1.0.19
2225
+     * @param  string $value first name.
2226
+     */
2227
+    public function set_first_name( $value ) {
2228
+        $this->set_prop( 'first_name', $value );
2199 2229
     }
2200 2230
 
2201 2231
     /**
2202
-	 * Set the customer's ip.
2203
-	 *
2204
-	 * @since 1.0.19
2205
-	 * @param  string $value ip address.
2206
-	 */
2207
-	public function set_ip( $value ) {
2208
-		$this->set_prop( 'ip', $value );
2232
+     * Alias of self::set_first_name().
2233
+     *
2234
+     * @since 1.0.19
2235
+     * @param  string $value first name.
2236
+     */
2237
+    public function set_user_first_name( $value ) {
2238
+        $this->set_first_name( $value );
2209 2239
     }
2210 2240
 
2211 2241
     /**
2212
-	 * Alias of self::set_ip().
2213
-	 *
2214
-	 * @since 1.0.19
2215
-	 * @param  string $value ip address.
2216
-	 */
2217
-	public function set_user_ip( $value ) {
2218
-		$this->set_ip( $value );
2242
+     * Alias of self::set_first_name().
2243
+     *
2244
+     * @since 1.0.19
2245
+     * @param  string $value first name.
2246
+     */
2247
+    public function set_customer_first_name( $value ) {
2248
+        $this->set_first_name( $value );
2219 2249
     }
2220 2250
 
2221 2251
     /**
2222
-	 * Set the customer's first name.
2223
-	 *
2224
-	 * @since 1.0.19
2225
-	 * @param  string $value first name.
2226
-	 */
2227
-	public function set_first_name( $value ) {
2228
-		$this->set_prop( 'first_name', $value );
2252
+     * Set the customer's last name.
2253
+     *
2254
+     * @since 1.0.19
2255
+     * @param  string $value last name.
2256
+     */
2257
+    public function set_last_name( $value ) {
2258
+        $this->set_prop( 'last_name', $value );
2229 2259
     }
2230 2260
 
2231 2261
     /**
2232
-	 * Alias of self::set_first_name().
2233
-	 *
2234
-	 * @since 1.0.19
2235
-	 * @param  string $value first name.
2236
-	 */
2237
-	public function set_user_first_name( $value ) {
2238
-		$this->set_first_name( $value );
2262
+     * Alias of self::set_last_name().
2263
+     *
2264
+     * @since 1.0.19
2265
+     * @param  string $value last name.
2266
+     */
2267
+    public function set_user_last_name( $value ) {
2268
+        $this->set_last_name( $value );
2239 2269
     }
2240 2270
 
2241 2271
     /**
2242
-	 * Alias of self::set_first_name().
2243
-	 *
2244
-	 * @since 1.0.19
2245
-	 * @param  string $value first name.
2246
-	 */
2247
-	public function set_customer_first_name( $value ) {
2248
-		$this->set_first_name( $value );
2272
+     * Alias of self::set_last_name().
2273
+     *
2274
+     * @since 1.0.19
2275
+     * @param  string $value last name.
2276
+     */
2277
+    public function set_customer_last_name( $value ) {
2278
+        $this->set_last_name( $value );
2249 2279
     }
2250 2280
 
2251 2281
     /**
2252
-	 * Set the customer's last name.
2253
-	 *
2254
-	 * @since 1.0.19
2255
-	 * @param  string $value last name.
2256
-	 */
2257
-	public function set_last_name( $value ) {
2258
-		$this->set_prop( 'last_name', $value );
2282
+     * Set the customer's phone number.
2283
+     *
2284
+     * @since 1.0.19
2285
+     * @param  string $value phone.
2286
+     */
2287
+    public function set_phone( $value ) {
2288
+        $this->set_prop( 'phone', $value );
2259 2289
     }
2260 2290
 
2261 2291
     /**
2262
-	 * Alias of self::set_last_name().
2263
-	 *
2264
-	 * @since 1.0.19
2265
-	 * @param  string $value last name.
2266
-	 */
2267
-	public function set_user_last_name( $value ) {
2268
-		$this->set_last_name( $value );
2292
+     * Alias of self::set_phone().
2293
+     *
2294
+     * @since 1.0.19
2295
+     * @param  string $value phone.
2296
+     */
2297
+    public function set_user_phone( $value ) {
2298
+        $this->set_phone( $value );
2269 2299
     }
2270 2300
 
2271 2301
     /**
2272
-	 * Alias of self::set_last_name().
2273
-	 *
2274
-	 * @since 1.0.19
2275
-	 * @param  string $value last name.
2276
-	 */
2277
-	public function set_customer_last_name( $value ) {
2278
-		$this->set_last_name( $value );
2302
+     * Alias of self::set_phone().
2303
+     *
2304
+     * @since 1.0.19
2305
+     * @param  string $value phone.
2306
+     */
2307
+    public function set_customer_phone( $value ) {
2308
+        $this->set_phone( $value );
2279 2309
     }
2280 2310
 
2281 2311
     /**
2282
-	 * Set the customer's phone number.
2283
-	 *
2284
-	 * @since 1.0.19
2285
-	 * @param  string $value phone.
2286
-	 */
2287
-	public function set_phone( $value ) {
2288
-		$this->set_prop( 'phone', $value );
2312
+     * Alias of self::set_phone().
2313
+     *
2314
+     * @since 1.0.19
2315
+     * @param  string $value phone.
2316
+     */
2317
+    public function set_phone_number( $value ) {
2318
+        $this->set_phone( $value );
2289 2319
     }
2290 2320
 
2291 2321
     /**
2292
-	 * Alias of self::set_phone().
2293
-	 *
2294
-	 * @since 1.0.19
2295
-	 * @param  string $value phone.
2296
-	 */
2297
-	public function set_user_phone( $value ) {
2298
-		$this->set_phone( $value );
2322
+     * Set the customer's email address.
2323
+     *
2324
+     * @since 1.0.19
2325
+     * @param  string $value email address.
2326
+     */
2327
+    public function set_email( $value ) {
2328
+        $this->set_prop( 'email', $value );
2299 2329
     }
2300 2330
 
2301 2331
     /**
2302
-	 * Alias of self::set_phone().
2303
-	 *
2304
-	 * @since 1.0.19
2305
-	 * @param  string $value phone.
2306
-	 */
2307
-	public function set_customer_phone( $value ) {
2308
-		$this->set_phone( $value );
2332
+     * Alias of self::set_email().
2333
+     *
2334
+     * @since 1.0.19
2335
+     * @param  string $value email address.
2336
+     */
2337
+    public function set_user_email( $value ) {
2338
+        $this->set_email( $value );
2309 2339
     }
2310 2340
 
2311 2341
     /**
2312
-	 * Alias of self::set_phone().
2313
-	 *
2314
-	 * @since 1.0.19
2315
-	 * @param  string $value phone.
2316
-	 */
2317
-	public function set_phone_number( $value ) {
2318
-		$this->set_phone( $value );
2342
+     * Alias of self::set_email().
2343
+     *
2344
+     * @since 1.0.19
2345
+     * @param  string $value email address.
2346
+     */
2347
+    public function set_email_address( $value ) {
2348
+        $this->set_email( $value );
2319 2349
     }
2320 2350
 
2321 2351
     /**
2322
-	 * Set the customer's email address.
2323
-	 *
2324
-	 * @since 1.0.19
2325
-	 * @param  string $value email address.
2326
-	 */
2327
-	public function set_email( $value ) {
2328
-		$this->set_prop( 'email', $value );
2352
+     * Alias of self::set_email().
2353
+     *
2354
+     * @since 1.0.19
2355
+     * @param  string $value email address.
2356
+     */
2357
+    public function set_customer_email( $value ) {
2358
+        $this->set_email( $value );
2329 2359
     }
2330 2360
 
2331 2361
     /**
2332
-	 * Alias of self::set_email().
2333
-	 *
2334
-	 * @since 1.0.19
2335
-	 * @param  string $value email address.
2336
-	 */
2337
-	public function set_user_email( $value ) {
2338
-		$this->set_email( $value );
2362
+     * Set the customer's country.
2363
+     *
2364
+     * @since 1.0.19
2365
+     * @param  string $value country.
2366
+     */
2367
+    public function set_country( $value ) {
2368
+        $this->set_prop( 'country', $value );
2339 2369
     }
2340 2370
 
2341 2371
     /**
2342
-	 * Alias of self::set_email().
2343
-	 *
2344
-	 * @since 1.0.19
2345
-	 * @param  string $value email address.
2346
-	 */
2347
-	public function set_email_address( $value ) {
2348
-		$this->set_email( $value );
2372
+     * Alias of self::set_country().
2373
+     *
2374
+     * @since 1.0.19
2375
+     * @param  string $value country.
2376
+     */
2377
+    public function set_user_country( $value ) {
2378
+        $this->set_country( $value );
2349 2379
     }
2350 2380
 
2351 2381
     /**
2352
-	 * Alias of self::set_email().
2353
-	 *
2354
-	 * @since 1.0.19
2355
-	 * @param  string $value email address.
2356
-	 */
2357
-	public function set_customer_email( $value ) {
2358
-		$this->set_email( $value );
2382
+     * Alias of self::set_country().
2383
+     *
2384
+     * @since 1.0.19
2385
+     * @param  string $value country.
2386
+     */
2387
+    public function set_customer_country( $value ) {
2388
+        $this->set_country( $value );
2359 2389
     }
2360 2390
 
2361 2391
     /**
2362
-	 * Set the customer's country.
2363
-	 *
2364
-	 * @since 1.0.19
2365
-	 * @param  string $value country.
2366
-	 */
2367
-	public function set_country( $value ) {
2368
-		$this->set_prop( 'country', $value );
2392
+     * Set the customer's state.
2393
+     *
2394
+     * @since 1.0.19
2395
+     * @param  string $value state.
2396
+     */
2397
+    public function set_state( $value ) {
2398
+        $this->set_prop( 'state', $value );
2369 2399
     }
2370 2400
 
2371 2401
     /**
2372
-	 * Alias of self::set_country().
2373
-	 *
2374
-	 * @since 1.0.19
2375
-	 * @param  string $value country.
2376
-	 */
2377
-	public function set_user_country( $value ) {
2378
-		$this->set_country( $value );
2402
+     * Alias of self::set_state().
2403
+     *
2404
+     * @since 1.0.19
2405
+     * @param  string $value state.
2406
+     */
2407
+    public function set_user_state( $value ) {
2408
+        $this->set_state( $value );
2379 2409
     }
2380 2410
 
2381 2411
     /**
2382
-	 * Alias of self::set_country().
2383
-	 *
2384
-	 * @since 1.0.19
2385
-	 * @param  string $value country.
2386
-	 */
2387
-	public function set_customer_country( $value ) {
2388
-		$this->set_country( $value );
2412
+     * Alias of self::set_state().
2413
+     *
2414
+     * @since 1.0.19
2415
+     * @param  string $value state.
2416
+     */
2417
+    public function set_customer_state( $value ) {
2418
+        $this->set_state( $value );
2389 2419
     }
2390 2420
 
2391 2421
     /**
2392
-	 * Set the customer's state.
2393
-	 *
2394
-	 * @since 1.0.19
2395
-	 * @param  string $value state.
2396
-	 */
2397
-	public function set_state( $value ) {
2398
-		$this->set_prop( 'state', $value );
2422
+     * Set the customer's city.
2423
+     *
2424
+     * @since 1.0.19
2425
+     * @param  string $value city.
2426
+     */
2427
+    public function set_city( $value ) {
2428
+        $this->set_prop( 'city', $value );
2399 2429
     }
2400 2430
 
2401 2431
     /**
2402
-	 * Alias of self::set_state().
2403
-	 *
2404
-	 * @since 1.0.19
2405
-	 * @param  string $value state.
2406
-	 */
2407
-	public function set_user_state( $value ) {
2408
-		$this->set_state( $value );
2432
+     * Alias of self::set_city().
2433
+     *
2434
+     * @since 1.0.19
2435
+     * @param  string $value city.
2436
+     */
2437
+    public function set_user_city( $value ) {
2438
+        $this->set_city( $value );
2409 2439
     }
2410 2440
 
2411 2441
     /**
2412
-	 * Alias of self::set_state().
2413
-	 *
2414
-	 * @since 1.0.19
2415
-	 * @param  string $value state.
2416
-	 */
2417
-	public function set_customer_state( $value ) {
2418
-		$this->set_state( $value );
2442
+     * Alias of self::set_city().
2443
+     *
2444
+     * @since 1.0.19
2445
+     * @param  string $value city.
2446
+     */
2447
+    public function set_customer_city( $value ) {
2448
+        $this->set_city( $value );
2419 2449
     }
2420 2450
 
2421 2451
     /**
2422
-	 * Set the customer's city.
2423
-	 *
2424
-	 * @since 1.0.19
2425
-	 * @param  string $value city.
2426
-	 */
2427
-	public function set_city( $value ) {
2428
-		$this->set_prop( 'city', $value );
2452
+     * Set the customer's zip code.
2453
+     *
2454
+     * @since 1.0.19
2455
+     * @param  string $value zip.
2456
+     */
2457
+    public function set_zip( $value ) {
2458
+        $this->set_prop( 'zip', $value );
2429 2459
     }
2430 2460
 
2431 2461
     /**
2432
-	 * Alias of self::set_city().
2433
-	 *
2434
-	 * @since 1.0.19
2435
-	 * @param  string $value city.
2436
-	 */
2437
-	public function set_user_city( $value ) {
2438
-		$this->set_city( $value );
2462
+     * Alias of self::set_zip().
2463
+     *
2464
+     * @since 1.0.19
2465
+     * @param  string $value zip.
2466
+     */
2467
+    public function set_user_zip( $value ) {
2468
+        $this->set_zip( $value );
2439 2469
     }
2440 2470
 
2441 2471
     /**
2442
-	 * Alias of self::set_city().
2443
-	 *
2444
-	 * @since 1.0.19
2445
-	 * @param  string $value city.
2446
-	 */
2447
-	public function set_customer_city( $value ) {
2448
-		$this->set_city( $value );
2472
+     * Alias of self::set_zip().
2473
+     *
2474
+     * @since 1.0.19
2475
+     * @param  string $value zip.
2476
+     */
2477
+    public function set_customer_zip( $value ) {
2478
+        $this->set_zip( $value );
2449 2479
     }
2450 2480
 
2451 2481
     /**
2452
-	 * Set the customer's zip code.
2453
-	 *
2454
-	 * @since 1.0.19
2455
-	 * @param  string $value zip.
2456
-	 */
2457
-	public function set_zip( $value ) {
2458
-		$this->set_prop( 'zip', $value );
2482
+     * Set the customer's company.
2483
+     *
2484
+     * @since 1.0.19
2485
+     * @param  string $value company.
2486
+     */
2487
+    public function set_company( $value ) {
2488
+        $this->set_prop( 'company', $value );
2459 2489
     }
2460 2490
 
2461 2491
     /**
2462
-	 * Alias of self::set_zip().
2463
-	 *
2464
-	 * @since 1.0.19
2465
-	 * @param  string $value zip.
2466
-	 */
2467
-	public function set_user_zip( $value ) {
2468
-		$this->set_zip( $value );
2492
+     * Alias of self::set_company().
2493
+     *
2494
+     * @since 1.0.19
2495
+     * @param  string $value company.
2496
+     */
2497
+    public function set_user_company( $value ) {
2498
+        $this->set_company( $value );
2469 2499
     }
2470 2500
 
2471 2501
     /**
2472
-	 * Alias of self::set_zip().
2473
-	 *
2474
-	 * @since 1.0.19
2475
-	 * @param  string $value zip.
2476
-	 */
2477
-	public function set_customer_zip( $value ) {
2478
-		$this->set_zip( $value );
2502
+     * Alias of self::set_company().
2503
+     *
2504
+     * @since 1.0.19
2505
+     * @param  string $value company.
2506
+     */
2507
+    public function set_customer_company( $value ) {
2508
+        $this->set_company( $value );
2479 2509
     }
2480 2510
 
2481 2511
     /**
2482
-	 * Set the customer's company.
2483
-	 *
2484
-	 * @since 1.0.19
2485
-	 * @param  string $value company.
2486
-	 */
2487
-	public function set_company( $value ) {
2488
-		$this->set_prop( 'company', $value );
2512
+     * Set the customer's var number.
2513
+     *
2514
+     * @since 1.0.19
2515
+     * @param  string $value var number.
2516
+     */
2517
+    public function set_vat_number( $value ) {
2518
+        $this->set_prop( 'vat_number', $value );
2489 2519
     }
2490 2520
 
2491 2521
     /**
2492
-	 * Alias of self::set_company().
2493
-	 *
2494
-	 * @since 1.0.19
2495
-	 * @param  string $value company.
2496
-	 */
2497
-	public function set_user_company( $value ) {
2498
-		$this->set_company( $value );
2522
+     * Alias of self::set_vat_number().
2523
+     *
2524
+     * @since 1.0.19
2525
+     * @param  string $value var number.
2526
+     */
2527
+    public function set_user_vat_number( $value ) {
2528
+        $this->set_vat_number( $value );
2499 2529
     }
2500 2530
 
2501 2531
     /**
2502
-	 * Alias of self::set_company().
2503
-	 *
2504
-	 * @since 1.0.19
2505
-	 * @param  string $value company.
2506
-	 */
2507
-	public function set_customer_company( $value ) {
2508
-		$this->set_company( $value );
2532
+     * Alias of self::set_vat_number().
2533
+     *
2534
+     * @since 1.0.19
2535
+     * @param  string $value var number.
2536
+     */
2537
+    public function set_customer_vat_number( $value ) {
2538
+        $this->set_vat_number( $value );
2509 2539
     }
2510 2540
 
2511 2541
     /**
2512
-	 * Set the customer's var number.
2513
-	 *
2514
-	 * @since 1.0.19
2515
-	 * @param  string $value var number.
2516
-	 */
2517
-	public function set_vat_number( $value ) {
2518
-		$this->set_prop( 'vat_number', $value );
2542
+     * Set the customer's vat rate.
2543
+     *
2544
+     * @since 1.0.19
2545
+     * @param  string $value var rate.
2546
+     */
2547
+    public function set_vat_rate( $value ) {
2548
+        $this->set_prop( 'vat_rate', $value );
2519 2549
     }
2520 2550
 
2521 2551
     /**
2522
-	 * Alias of self::set_vat_number().
2523
-	 *
2524
-	 * @since 1.0.19
2525
-	 * @param  string $value var number.
2526
-	 */
2527
-	public function set_user_vat_number( $value ) {
2528
-		$this->set_vat_number( $value );
2552
+     * Alias of self::set_vat_rate().
2553
+     *
2554
+     * @since 1.0.19
2555
+     * @param  string $value var number.
2556
+     */
2557
+    public function set_user_vat_rate( $value ) {
2558
+        $this->set_vat_rate( $value );
2529 2559
     }
2530 2560
 
2531 2561
     /**
2532
-	 * Alias of self::set_vat_number().
2533
-	 *
2534
-	 * @since 1.0.19
2535
-	 * @param  string $value var number.
2536
-	 */
2537
-	public function set_customer_vat_number( $value ) {
2538
-		$this->set_vat_number( $value );
2562
+     * Alias of self::set_vat_rate().
2563
+     *
2564
+     * @since 1.0.19
2565
+     * @param  string $value var number.
2566
+     */
2567
+    public function set_customer_vat_rate( $value ) {
2568
+        $this->set_vat_rate( $value );
2539 2569
     }
2540 2570
 
2541 2571
     /**
2542
-	 * Set the customer's vat rate.
2543
-	 *
2544
-	 * @since 1.0.19
2545
-	 * @param  string $value var rate.
2546
-	 */
2547
-	public function set_vat_rate( $value ) {
2548
-		$this->set_prop( 'vat_rate', $value );
2572
+     * Set the customer's address.
2573
+     *
2574
+     * @since 1.0.19
2575
+     * @param  string $value address.
2576
+     */
2577
+    public function set_address( $value ) {
2578
+        $this->set_prop( 'address', $value );
2549 2579
     }
2550 2580
 
2551 2581
     /**
2552
-	 * Alias of self::set_vat_rate().
2553
-	 *
2554
-	 * @since 1.0.19
2555
-	 * @param  string $value var number.
2556
-	 */
2557
-	public function set_user_vat_rate( $value ) {
2558
-		$this->set_vat_rate( $value );
2582
+     * Alias of self::set_address().
2583
+     *
2584
+     * @since 1.0.19
2585
+     * @param  string $value address.
2586
+     */
2587
+    public function set_user_address( $value ) {
2588
+        $this->set_address( $value );
2559 2589
     }
2560 2590
 
2561 2591
     /**
2562
-	 * Alias of self::set_vat_rate().
2563
-	 *
2564
-	 * @since 1.0.19
2565
-	 * @param  string $value var number.
2566
-	 */
2567
-	public function set_customer_vat_rate( $value ) {
2568
-		$this->set_vat_rate( $value );
2592
+     * Alias of self::set_address().
2593
+     *
2594
+     * @since 1.0.19
2595
+     * @param  string $value address.
2596
+     */
2597
+    public function set_customer_address( $value ) {
2598
+        $this->set_address( $value );
2569 2599
     }
2570 2600
 
2571 2601
     /**
2572
-	 * Set the customer's address.
2573
-	 *
2574
-	 * @since 1.0.19
2575
-	 * @param  string $value address.
2576
-	 */
2577
-	public function set_address( $value ) {
2578
-		$this->set_prop( 'address', $value );
2602
+     * Set whether the customer has viewed the invoice or not.
2603
+     *
2604
+     * @since 1.0.19
2605
+     * @param  int|bool $value confirmed.
2606
+     */
2607
+    public function set_is_viewed( $value ) {
2608
+        $this->set_prop( 'is_viewed', $value );
2579 2609
     }
2580 2610
 
2581 2611
     /**
2582
-	 * Alias of self::set_address().
2583
-	 *
2584
-	 * @since 1.0.19
2585
-	 * @param  string $value address.
2586
-	 */
2587
-	public function set_user_address( $value ) {
2588
-		$this->set_address( $value );
2612
+     * Set extra email recipients.
2613
+     *
2614
+     * @since 1.0.19
2615
+     * @param  string $value email recipients.
2616
+     */
2617
+    public function set_email_cc( $value ) {
2618
+        $this->set_prop( 'email_cc', $value );
2589 2619
     }
2590 2620
 
2591 2621
     /**
2592
-	 * Alias of self::set_address().
2593
-	 *
2594
-	 * @since 1.0.19
2595
-	 * @param  string $value address.
2596
-	 */
2597
-	public function set_customer_address( $value ) {
2598
-		$this->set_address( $value );
2622
+     * Set the invoice template.
2623
+     *
2624
+     * @since 1.0.19
2625
+     * @param  string $value email recipients.
2626
+     */
2627
+    public function set_template( $value ) {
2628
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2629
+            $this->set_prop( 'template', $value );
2630
+        }
2599 2631
     }
2600 2632
 
2601 2633
     /**
2602
-	 * Set whether the customer has viewed the invoice or not.
2603
-	 *
2604
-	 * @since 1.0.19
2605
-	 * @param  int|bool $value confirmed.
2606
-	 */
2607
-	public function set_is_viewed( $value ) {
2608
-		$this->set_prop( 'is_viewed', $value );
2609
-	}
2610
-
2611
-	/**
2612
-	 * Set extra email recipients.
2613
-	 *
2614
-	 * @since 1.0.19
2615
-	 * @param  string $value email recipients.
2616
-	 */
2617
-	public function set_email_cc( $value ) {
2618
-		$this->set_prop( 'email_cc', $value );
2619
-	}
2620
-
2621
-	/**
2622
-	 * Set the invoice template.
2623
-	 *
2624
-	 * @since 1.0.19
2625
-	 * @param  string $value email recipients.
2626
-	 */
2627
-	public function set_template( $value ) {
2628
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2629
-			$this->set_prop( 'template', $value );
2630
-		}
2631
-	}
2632
-
2633
-	/**
2634
-	 * Set the customer's address confirmed status.
2635
-	 *
2636
-	 * @since 1.0.19
2637
-	 * @param  int|bool $value confirmed.
2638
-	 */
2639
-	public function set_address_confirmed( $value ) {
2640
-		$this->set_prop( 'address_confirmed', $value );
2634
+     * Set the customer's address confirmed status.
2635
+     *
2636
+     * @since 1.0.19
2637
+     * @param  int|bool $value confirmed.
2638
+     */
2639
+    public function set_address_confirmed( $value ) {
2640
+        $this->set_prop( 'address_confirmed', $value );
2641 2641
     }
2642 2642
 
2643 2643
     /**
2644
-	 * Alias of self::set_address_confirmed().
2645
-	 *
2646
-	 * @since 1.0.19
2647
-	 * @param  int|bool $value confirmed.
2648
-	 */
2649
-	public function set_user_address_confirmed( $value ) {
2650
-		$this->set_address_confirmed( $value );
2644
+     * Alias of self::set_address_confirmed().
2645
+     *
2646
+     * @since 1.0.19
2647
+     * @param  int|bool $value confirmed.
2648
+     */
2649
+    public function set_user_address_confirmed( $value ) {
2650
+        $this->set_address_confirmed( $value );
2651 2651
     }
2652 2652
 
2653 2653
     /**
2654
-	 * Alias of self::set_address_confirmed().
2655
-	 *
2656
-	 * @since 1.0.19
2657
-	 * @param  int|bool $value confirmed.
2658
-	 */
2659
-	public function set_customer_address_confirmed( $value ) {
2660
-		$this->set_address_confirmed( $value );
2654
+     * Alias of self::set_address_confirmed().
2655
+     *
2656
+     * @since 1.0.19
2657
+     * @param  int|bool $value confirmed.
2658
+     */
2659
+    public function set_customer_address_confirmed( $value ) {
2660
+        $this->set_address_confirmed( $value );
2661 2661
     }
2662 2662
 
2663 2663
     /**
2664
-	 * Set the invoice sub total.
2665
-	 *
2666
-	 * @since 1.0.19
2667
-	 * @param  float $value sub total.
2668
-	 */
2669
-	public function set_subtotal( $value ) {
2670
-		$this->set_prop( 'subtotal', $value );
2664
+     * Set the invoice sub total.
2665
+     *
2666
+     * @since 1.0.19
2667
+     * @param  float $value sub total.
2668
+     */
2669
+    public function set_subtotal( $value ) {
2670
+        $this->set_prop( 'subtotal', $value );
2671 2671
     }
2672 2672
 
2673 2673
     /**
2674
-	 * Set the invoice discount amount.
2675
-	 *
2676
-	 * @since 1.0.19
2677
-	 * @param  float $value discount total.
2678
-	 */
2679
-	public function set_total_discount( $value ) {
2680
-		$this->set_prop( 'total_discount', $value );
2674
+     * Set the invoice discount amount.
2675
+     *
2676
+     * @since 1.0.19
2677
+     * @param  float $value discount total.
2678
+     */
2679
+    public function set_total_discount( $value ) {
2680
+        $this->set_prop( 'total_discount', $value );
2681 2681
     }
2682 2682
 
2683 2683
     /**
2684
-	 * Alias of self::set_total_discount().
2685
-	 *
2686
-	 * @since 1.0.19
2687
-	 * @param  float $value discount total.
2688
-	 */
2689
-	public function set_discount( $value ) {
2690
-		$this->set_total_discount( $value );
2684
+     * Alias of self::set_total_discount().
2685
+     *
2686
+     * @since 1.0.19
2687
+     * @param  float $value discount total.
2688
+     */
2689
+    public function set_discount( $value ) {
2690
+        $this->set_total_discount( $value );
2691 2691
     }
2692 2692
 
2693 2693
     /**
2694
-	 * Set the invoice tax amount.
2695
-	 *
2696
-	 * @since 1.0.19
2697
-	 * @param  float $value tax total.
2698
-	 */
2699
-	public function set_total_tax( $value ) {
2700
-		$this->set_prop( 'total_tax', $value );
2694
+     * Set the invoice tax amount.
2695
+     *
2696
+     * @since 1.0.19
2697
+     * @param  float $value tax total.
2698
+     */
2699
+    public function set_total_tax( $value ) {
2700
+        $this->set_prop( 'total_tax', $value );
2701 2701
     }
2702 2702
 
2703 2703
     /**
2704
-	 * Alias of self::set_total_tax().
2705
-	 *
2706
-	 * @since 1.0.19
2707
-	 * @param  float $value tax total.
2708
-	 */
2709
-	public function set_tax_total( $value ) {
2710
-		$this->set_total_tax( $value );
2704
+     * Alias of self::set_total_tax().
2705
+     *
2706
+     * @since 1.0.19
2707
+     * @param  float $value tax total.
2708
+     */
2709
+    public function set_tax_total( $value ) {
2710
+        $this->set_total_tax( $value );
2711 2711
     }
2712 2712
 
2713 2713
     /**
2714
-	 * Set the invoice fees amount.
2715
-	 *
2716
-	 * @since 1.0.19
2717
-	 * @param  float $value fees total.
2718
-	 */
2719
-	public function set_total_fees( $value ) {
2720
-		$this->set_prop( 'total_fees', $value );
2714
+     * Set the invoice fees amount.
2715
+     *
2716
+     * @since 1.0.19
2717
+     * @param  float $value fees total.
2718
+     */
2719
+    public function set_total_fees( $value ) {
2720
+        $this->set_prop( 'total_fees', $value );
2721 2721
     }
2722 2722
 
2723 2723
     /**
2724
-	 * Alias of self::set_total_fees().
2725
-	 *
2726
-	 * @since 1.0.19
2727
-	 * @param  float $value fees total.
2728
-	 */
2729
-	public function set_fees_total( $value ) {
2730
-		$this->set_total_fees( $value );
2724
+     * Alias of self::set_total_fees().
2725
+     *
2726
+     * @since 1.0.19
2727
+     * @param  float $value fees total.
2728
+     */
2729
+    public function set_fees_total( $value ) {
2730
+        $this->set_total_fees( $value );
2731 2731
     }
2732 2732
 
2733 2733
     /**
2734
-	 * Set the invoice fees.
2735
-	 *
2736
-	 * @since 1.0.19
2737
-	 * @param  array $value fees.
2738
-	 */
2739
-	public function set_fees( $value ) {
2734
+     * Set the invoice fees.
2735
+     *
2736
+     * @since 1.0.19
2737
+     * @param  array $value fees.
2738
+     */
2739
+    public function set_fees( $value ) {
2740 2740
 
2741
-		if ( ! is_array( $value ) ) {
2742
-			$value = array();
2743
-		}
2741
+        if ( ! is_array( $value ) ) {
2742
+            $value = array();
2743
+        }
2744 2744
 
2745
-		$this->set_prop( 'fees', $value );
2745
+        $this->set_prop( 'fees', $value );
2746 2746
 
2747 2747
     }
2748 2748
 
2749 2749
     /**
2750
-	 * Set the invoice taxes.
2751
-	 *
2752
-	 * @since 1.0.19
2753
-	 * @param  array $value taxes.
2754
-	 */
2755
-	public function set_taxes( $value ) {
2750
+     * Set the invoice taxes.
2751
+     *
2752
+     * @since 1.0.19
2753
+     * @param  array $value taxes.
2754
+     */
2755
+    public function set_taxes( $value ) {
2756 2756
 
2757
-		if ( ! is_array( $value ) ) {
2758
-			$value = array();
2759
-		}
2757
+        if ( ! is_array( $value ) ) {
2758
+            $value = array();
2759
+        }
2760 2760
 
2761
-		$this->set_prop( 'taxes', $value );
2761
+        $this->set_prop( 'taxes', $value );
2762 2762
 
2763 2763
     }
2764 2764
 
2765 2765
     /**
2766
-	 * Set the invoice discounts.
2767
-	 *
2768
-	 * @since 1.0.19
2769
-	 * @param  array $value discounts.
2770
-	 */
2771
-	public function set_discounts( $value ) {
2766
+     * Set the invoice discounts.
2767
+     *
2768
+     * @since 1.0.19
2769
+     * @param  array $value discounts.
2770
+     */
2771
+    public function set_discounts( $value ) {
2772 2772
 
2773
-		if ( ! is_array( $value ) ) {
2774
-			$value = array();
2775
-		}
2773
+        if ( ! is_array( $value ) ) {
2774
+            $value = array();
2775
+        }
2776 2776
 
2777
-		$this->set_prop( 'discounts', $value );
2777
+        $this->set_prop( 'discounts', $value );
2778 2778
     }
2779 2779
 
2780 2780
     /**
2781
-	 * Set the invoice items.
2782
-	 *
2783
-	 * @since 1.0.19
2784
-	 * @param  GetPaid_Form_Item[] $value items.
2785
-	 */
2786
-	public function set_items( $value ) {
2781
+     * Set the invoice items.
2782
+     *
2783
+     * @since 1.0.19
2784
+     * @param  GetPaid_Form_Item[] $value items.
2785
+     */
2786
+    public function set_items( $value ) {
2787 2787
 
2788 2788
         // Remove existing items.
2789 2789
         $this->set_prop( 'items', array() );
@@ -2800,95 +2800,95 @@  discard block
 block discarded – undo
2800 2800
     }
2801 2801
 
2802 2802
     /**
2803
-	 * Set the payment form.
2804
-	 *
2805
-	 * @since 1.0.19
2806
-	 * @param  int $value payment form.
2807
-	 */
2808
-	public function set_payment_form( $value ) {
2809
-		$this->set_prop( 'payment_form', $value );
2803
+     * Set the payment form.
2804
+     *
2805
+     * @since 1.0.19
2806
+     * @param  int $value payment form.
2807
+     */
2808
+    public function set_payment_form( $value ) {
2809
+        $this->set_prop( 'payment_form', $value );
2810 2810
     }
2811 2811
 
2812 2812
     /**
2813
-	 * Set the submission id.
2814
-	 *
2815
-	 * @since 1.0.19
2816
-	 * @param  string $value submission id.
2817
-	 */
2818
-	public function set_submission_id( $value ) {
2819
-		$this->set_prop( 'submission_id', $value );
2813
+     * Set the submission id.
2814
+     *
2815
+     * @since 1.0.19
2816
+     * @param  string $value submission id.
2817
+     */
2818
+    public function set_submission_id( $value ) {
2819
+        $this->set_prop( 'submission_id', $value );
2820 2820
     }
2821 2821
 
2822 2822
     /**
2823
-	 * Set the discount code.
2824
-	 *
2825
-	 * @since 1.0.19
2826
-	 * @param  string $value discount code.
2827
-	 */
2828
-	public function set_discount_code( $value ) {
2829
-		$this->set_prop( 'discount_code', $value );
2823
+     * Set the discount code.
2824
+     *
2825
+     * @since 1.0.19
2826
+     * @param  string $value discount code.
2827
+     */
2828
+    public function set_discount_code( $value ) {
2829
+        $this->set_prop( 'discount_code', $value );
2830 2830
     }
2831 2831
 
2832 2832
     /**
2833
-	 * Set the gateway.
2834
-	 *
2835
-	 * @since 1.0.19
2836
-	 * @param  string $value gateway.
2837
-	 */
2838
-	public function set_gateway( $value ) {
2839
-		$this->set_prop( 'gateway', $value );
2833
+     * Set the gateway.
2834
+     *
2835
+     * @since 1.0.19
2836
+     * @param  string $value gateway.
2837
+     */
2838
+    public function set_gateway( $value ) {
2839
+        $this->set_prop( 'gateway', $value );
2840 2840
     }
2841 2841
 
2842 2842
     /**
2843
-	 * Set the transaction id.
2844
-	 *
2845
-	 * @since 1.0.19
2846
-	 * @param  string $value transaction id.
2847
-	 */
2848
-	public function set_transaction_id( $value ) {
2849
-		if ( ! empty( $value ) ) {
2850
-			$this->set_prop( 'transaction_id', $value );
2851
-		}
2843
+     * Set the transaction id.
2844
+     *
2845
+     * @since 1.0.19
2846
+     * @param  string $value transaction id.
2847
+     */
2848
+    public function set_transaction_id( $value ) {
2849
+        if ( ! empty( $value ) ) {
2850
+            $this->set_prop( 'transaction_id', $value );
2851
+        }
2852 2852
     }
2853 2853
 
2854 2854
     /**
2855
-	 * Set the currency id.
2856
-	 *
2857
-	 * @since 1.0.19
2858
-	 * @param  string $value currency id.
2859
-	 */
2860
-	public function set_currency( $value ) {
2861
-		$this->set_prop( 'currency', $value );
2855
+     * Set the currency id.
2856
+     *
2857
+     * @since 1.0.19
2858
+     * @param  string $value currency id.
2859
+     */
2860
+    public function set_currency( $value ) {
2861
+        $this->set_prop( 'currency', $value );
2862 2862
     }
2863 2863
 
2864
-	/**
2865
-	 * Set whether to disable taxes.
2866
-	 *
2867
-	 * @since 1.0.19
2868
-	 * @param  bool $value value.
2869
-	 */
2870
-	public function set_disable_taxes( $value ) {
2871
-		$this->set_prop( 'disable_taxes', (bool) $value );
2872
-	}
2864
+    /**
2865
+     * Set whether to disable taxes.
2866
+     *
2867
+     * @since 1.0.19
2868
+     * @param  bool $value value.
2869
+     */
2870
+    public function set_disable_taxes( $value ) {
2871
+        $this->set_prop( 'disable_taxes', (bool) $value );
2872
+    }
2873 2873
 
2874 2874
     /**
2875
-	 * Set the subscription id.
2876
-	 *
2877
-	 * @since 1.0.19
2878
-	 * @param  string $value subscription id.
2879
-	 */
2880
-	public function set_subscription_id( $value ) {
2881
-		$this->set_prop( 'subscription_id', $value );
2882
-	}
2875
+     * Set the subscription id.
2876
+     *
2877
+     * @since 1.0.19
2878
+     * @param  string $value subscription id.
2879
+     */
2880
+    public function set_subscription_id( $value ) {
2881
+        $this->set_prop( 'subscription_id', $value );
2882
+    }
2883 2883
 	
2884
-	/**
2885
-	 * Set the remote subscription id.
2886
-	 *
2887
-	 * @since 1.0.19
2888
-	 * @param  string $value subscription id.
2889
-	 */
2890
-	public function set_remote_subscription_id( $value ) {
2891
-		$this->set_prop( 'remote_subscription_id', $value );
2884
+    /**
2885
+     * Set the remote subscription id.
2886
+     *
2887
+     * @since 1.0.19
2888
+     * @param  string $value subscription id.
2889
+     */
2890
+    public function set_remote_subscription_id( $value ) {
2891
+        $this->set_prop( 'remote_subscription_id', $value );
2892 2892
     }
2893 2893
 
2894 2894
     /*
@@ -2927,12 +2927,12 @@  discard block
 block discarded – undo
2927 2927
      */
2928 2928
     public function is_taxable() {
2929 2929
         return ! $this->get_disable_taxes();
2930
-	}
2930
+    }
2931 2931
 
2932
-	/**
2933
-	 * @deprecated
2934
-	 */
2935
-	public function has_vat() {
2932
+    /**
2933
+     * @deprecated
2934
+     */
2935
+    public function has_vat() {
2936 2936
         global $wpinv_euvat, $wpi_country;
2937 2937
 
2938 2938
         $requires_vat = false;
@@ -2943,17 +2943,17 @@  discard block
 block discarded – undo
2943 2943
         }
2944 2944
 
2945 2945
         return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2946
-	}
2946
+    }
2947 2947
 
2948
-	/**
2949
-	 * Checks to see if the invoice requires payment.
2950
-	 */
2951
-	public function is_free() {
2948
+    /**
2949
+     * Checks to see if the invoice requires payment.
2950
+     */
2951
+    public function is_free() {
2952 2952
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2953 2953
 
2954
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2955
-			$is_free = false;
2956
-		}
2954
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2955
+            $is_free = false;
2956
+        }
2957 2957
 
2958 2958
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2959 2959
     }
@@ -2964,46 +2964,46 @@  discard block
 block discarded – undo
2964 2964
     public function is_paid() {
2965 2965
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2966 2966
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2967
-	}
2967
+    }
2968 2968
 
2969
-	/**
2969
+    /**
2970 2970
      * Checks if the invoice needs payment.
2971 2971
      */
2972
-	public function needs_payment() {
2973
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2972
+    public function needs_payment() {
2973
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2974 2974
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2975 2975
     }
2976 2976
   
2977
-	/**
2977
+    /**
2978 2978
      * Checks if the invoice is refunded.
2979 2979
      */
2980
-	public function is_refunded() {
2980
+    public function is_refunded() {
2981 2981
         $is_refunded = $this->has_status( 'wpi-refunded' );
2982 2982
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2983
-	}
2983
+    }
2984 2984
 
2985
-	/**
2985
+    /**
2986 2986
      * Checks if the invoice is held.
2987 2987
      */
2988
-	public function is_held() {
2988
+    public function is_held() {
2989 2989
         $is_held = $this->has_status( 'wpi-onhold' );
2990 2990
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2991
-	}
2991
+    }
2992 2992
 
2993
-	/**
2993
+    /**
2994 2994
      * Checks if the invoice is due.
2995 2995
      */
2996
-	public function is_due() {
2997
-		$due_date = $this->get_due_date();
2998
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2999
-	}
2996
+    public function is_due() {
2997
+        $due_date = $this->get_due_date();
2998
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2999
+    }
3000 3000
 
3001
-	/**
3001
+    /**
3002 3002
      * Checks if the invoice is draft.
3003 3003
      */
3004
-	public function is_draft() {
3004
+    public function is_draft() {
3005 3005
         return $this->has_status( 'draft, auto-draft' );
3006
-	}
3006
+    }
3007 3007
 
3008 3008
     /**
3009 3009
      * Checks if the invoice has a given status.
@@ -3011,9 +3011,9 @@  discard block
 block discarded – undo
3011 3011
     public function has_status( $status ) {
3012 3012
         $status = wpinv_parse_list( $status );
3013 3013
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3014
-	}
3014
+    }
3015 3015
 
3016
-	/**
3016
+    /**
3017 3017
      * Checks if the invoice is of a given type.
3018 3018
      */
3019 3019
     public function is_type( $type ) {
@@ -3036,25 +3036,25 @@  discard block
 block discarded – undo
3036 3036
      */
3037 3037
     public function has_free_trial() {
3038 3038
         return $this->is_recurring() && 0 == $this->get_initial_total();
3039
-	}
3039
+    }
3040 3040
 
3041
-	/**
3041
+    /**
3042 3042
      * @deprecated
3043 3043
      */
3044 3044
     public function is_free_trial() {
3045 3045
         $this->has_free_trial();
3046 3046
     }
3047 3047
 
3048
-	/**
3048
+    /**
3049 3049
      * Check if the initial payment if 0.
3050 3050
      *
3051 3051
      */
3052
-	public function is_initial_free() {
3052
+    public function is_initial_free() {
3053 3053
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3054 3054
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3055 3055
     }
3056 3056
 	
3057
-	/**
3057
+    /**
3058 3058
      * Check if the recurring item has a free trial.
3059 3059
      *
3060 3060
      */
@@ -3067,21 +3067,21 @@  discard block
 block discarded – undo
3067 3067
 
3068 3068
         $item = $this->get_recurring( true );
3069 3069
         return $item->has_free_trial();
3070
-	}
3070
+    }
3071 3071
 
3072
-	/**
3072
+    /**
3073 3073
      * Check if the free trial is a result of a discount.
3074 3074
      */
3075 3075
     public function is_free_trial_from_discount() {
3076
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3077
-	}
3076
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3077
+    }
3078 3078
 	
3079
-	/**
3079
+    /**
3080 3080
      * @deprecated
3081 3081
      */
3082 3082
     public function discount_first_payment_only() {
3083 3083
 
3084
-		$discount_code = $this->get_discount_code();
3084
+        $discount_code = $this->get_discount_code();
3085 3085
         if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3086 3086
             return true;
3087 3087
         }
@@ -3112,28 +3112,28 @@  discard block
 block discarded – undo
3112 3112
      */
3113 3113
     public function add_item( $item ) {
3114 3114
 
3115
-		if ( is_array( $item ) ) {
3116
-			$item = $this->process_array_item( $item );
3117
-		}
3115
+        if ( is_array( $item ) ) {
3116
+            $item = $this->process_array_item( $item );
3117
+        }
3118 3118
 
3119
-		if ( is_numeric( $item ) ) {
3120
-			$item = new GetPaid_Form_Item( $item );
3121
-		}
3119
+        if ( is_numeric( $item ) ) {
3120
+            $item = new GetPaid_Form_Item( $item );
3121
+        }
3122 3122
 
3123 3123
         // Make sure that it is available for purchase.
3124
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3125
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3124
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3125
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3126 3126
         }
3127 3127
 
3128 3128
         // Do we have a recurring item?
3129
-		if ( $item->is_recurring() ) {
3129
+        if ( $item->is_recurring() ) {
3130 3130
 
3131
-			// An invoice can only contain one recurring item.
3132
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3133
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3134
-			}
3131
+            // An invoice can only contain one recurring item.
3132
+            if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3133
+                return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3134
+            }
3135 3135
 
3136
-			$this->recurring_item = $item->get_id();
3136
+            $this->recurring_item = $item->get_id();
3137 3137
         }
3138 3138
 
3139 3139
         // Invoice id.
@@ -3144,60 +3144,60 @@  discard block
 block discarded – undo
3144 3144
         $items[ (int) $item->get_id() ] = $item;
3145 3145
 
3146 3146
         $this->set_prop( 'items', $items );
3147
-		return true;
3148
-	}
3147
+        return true;
3148
+    }
3149 3149
 	
3150
-	/**
3151
-	 * Converts an array to an item.
3152
-	 *
3153
-	 * @since 1.0.19
3154
-	 * @return GetPaid_Form_Item
3155
-	 */
3156
-	protected function process_array_item( $array ) {
3157
-
3158
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3159
-		$item    = new GetPaid_Form_Item( $item_id );
3160
-
3161
-		// Set item data.
3162
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3163
-			if ( isset( $array[ "item_$key" ] ) ) {
3164
-				$method = "set_$key";
3165
-				$item->$method( $array[ "item_$key" ] );
3166
-			}
3167
-		}
3168
-
3169
-		if ( isset( $array['quantity'] ) ) {
3170
-			$item->set_quantity( $array['quantity'] );
3171
-		}
3172
-
3173
-		// Set item meta.
3174
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3175
-			$item->set_item_meta( $array['meta'] );
3176
-		}
3177
-
3178
-		return $item;
3179
-
3180
-	}
3181
-
3182
-    /**
3183
-	 * Retrieves a specific item.
3184
-	 *
3185
-	 * @since 1.0.19
3186
-	 */
3187
-	public function get_item( $item_id ) {
3188
-		$items   = $this->get_items();
3189
-		$item_id = (int) $item_id;
3190
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3191
-    }
3192
-
3193
-    /**
3194
-	 * Removes a specific item.
3195
-	 *
3196
-	 * @since 1.0.19
3197
-	 */
3198
-	public function remove_item( $item_id ) {
3199
-		$items   = $this->get_items();
3200
-		$item_id = (int) $item_id;
3150
+    /**
3151
+     * Converts an array to an item.
3152
+     *
3153
+     * @since 1.0.19
3154
+     * @return GetPaid_Form_Item
3155
+     */
3156
+    protected function process_array_item( $array ) {
3157
+
3158
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3159
+        $item    = new GetPaid_Form_Item( $item_id );
3160
+
3161
+        // Set item data.
3162
+        foreach( array( 'name', 'price', 'description' ) as $key ) {
3163
+            if ( isset( $array[ "item_$key" ] ) ) {
3164
+                $method = "set_$key";
3165
+                $item->$method( $array[ "item_$key" ] );
3166
+            }
3167
+        }
3168
+
3169
+        if ( isset( $array['quantity'] ) ) {
3170
+            $item->set_quantity( $array['quantity'] );
3171
+        }
3172
+
3173
+        // Set item meta.
3174
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3175
+            $item->set_item_meta( $array['meta'] );
3176
+        }
3177
+
3178
+        return $item;
3179
+
3180
+    }
3181
+
3182
+    /**
3183
+     * Retrieves a specific item.
3184
+     *
3185
+     * @since 1.0.19
3186
+     */
3187
+    public function get_item( $item_id ) {
3188
+        $items   = $this->get_items();
3189
+        $item_id = (int) $item_id;
3190
+        return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3191
+    }
3192
+
3193
+    /**
3194
+     * Removes a specific item.
3195
+     *
3196
+     * @since 1.0.19
3197
+     */
3198
+    public function remove_item( $item_id ) {
3199
+        $items   = $this->get_items();
3200
+        $item_id = (int) $item_id;
3201 3201
 
3202 3202
         if ( $item_id == $this->recurring_item ) {
3203 3203
             $this->recurring_item = null;
@@ -3210,35 +3210,35 @@  discard block
 block discarded – undo
3210 3210
     }
3211 3211
 
3212 3212
     /**
3213
-	 * Adds a fee to the invoice.
3214
-	 *
3215
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3216
-	 * @since 1.0.19
3217
-	 */
3213
+     * Adds a fee to the invoice.
3214
+     *
3215
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3216
+     * @since 1.0.19
3217
+     */
3218 3218
     public function add_fee( $fee ) {
3219 3219
 
3220
-		$fees = $this->get_fees();
3221
-		$fees[ $fee['name'] ] = $fee;
3222
-		$this->set_prop( 'fees', $fees );
3220
+        $fees = $this->get_fees();
3221
+        $fees[ $fee['name'] ] = $fee;
3222
+        $this->set_prop( 'fees', $fees );
3223 3223
 
3224 3224
     }
3225 3225
 
3226 3226
     /**
3227
-	 * Retrieves a specific fee.
3228
-	 *
3229
-	 * @since 1.0.19
3230
-	 */
3231
-	public function get_fee( $fee ) {
3227
+     * Retrieves a specific fee.
3228
+     *
3229
+     * @since 1.0.19
3230
+     */
3231
+    public function get_fee( $fee ) {
3232 3232
         $fees = $this->get_fees();
3233
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3233
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3234 3234
     }
3235 3235
 
3236 3236
     /**
3237
-	 * Removes a specific fee.
3238
-	 *
3239
-	 * @since 1.0.19
3240
-	 */
3241
-	public function remove_fee( $fee ) {
3237
+     * Removes a specific fee.
3238
+     *
3239
+     * @since 1.0.19
3240
+     */
3241
+    public function remove_fee( $fee ) {
3242 3242
         $fees = $this->get_fees();
3243 3243
         if ( isset( $fees[ $fee ] ) ) {
3244 3244
             unset( $fees[ $fee ] );
@@ -3246,43 +3246,43 @@  discard block
 block discarded – undo
3246 3246
         }
3247 3247
     }
3248 3248
 
3249
-	/**
3250
-	 * Adds a discount to the invoice.
3251
-	 *
3252
-	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3253
-	 * @since 1.0.19
3254
-	 */
3255
-	public function add_discount( $discount ) {
3249
+    /**
3250
+     * Adds a discount to the invoice.
3251
+     *
3252
+     * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3253
+     * @since 1.0.19
3254
+     */
3255
+    public function add_discount( $discount ) {
3256 3256
 
3257
-		$discounts = $this->get_discounts();
3258
-		$discounts[ $discount['name'] ] = $discount;
3259
-		$this->set_prop( 'discounts', $discounts );
3257
+        $discounts = $this->get_discounts();
3258
+        $discounts[ $discount['name'] ] = $discount;
3259
+        $this->set_prop( 'discounts', $discounts );
3260 3260
 
3261
-	}
3261
+    }
3262 3262
 
3263 3263
     /**
3264
-	 * Retrieves a specific discount.
3265
-	 *
3266
-	 * @since 1.0.19
3267
-	 * @return float
3268
-	 */
3269
-	public function get_discount( $discount = false ) {
3264
+     * Retrieves a specific discount.
3265
+     *
3266
+     * @since 1.0.19
3267
+     * @return float
3268
+     */
3269
+    public function get_discount( $discount = false ) {
3270 3270
 
3271
-		// Backwards compatibilty.
3272
-		if ( empty( $discount ) ) {
3273
-			return $this->get_total_discount();
3274
-		}
3271
+        // Backwards compatibilty.
3272
+        if ( empty( $discount ) ) {
3273
+            return $this->get_total_discount();
3274
+        }
3275 3275
 
3276 3276
         $discounts = $this->get_discounts();
3277
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3277
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3278 3278
     }
3279 3279
 
3280 3280
     /**
3281
-	 * Removes a specific discount.
3282
-	 *
3283
-	 * @since 1.0.19
3284
-	 */
3285
-	public function remove_discount( $discount ) {
3281
+     * Removes a specific discount.
3282
+     *
3283
+     * @since 1.0.19
3284
+     */
3285
+    public function remove_discount( $discount ) {
3286 3286
         $discounts = $this->get_discounts();
3287 3287
         if ( isset( $discounts[ $discount ] ) ) {
3288 3288
             unset( $discounts[ $discount ] );
@@ -3301,35 +3301,35 @@  discard block
 block discarded – undo
3301 3301
         if ( $this->is_taxable() ) {
3302 3302
 
3303 3303
             $taxes                 = $this->get_taxes();
3304
-			$taxes[ $tax['name'] ] = $tax;
3305
-			$this->set_prop( 'taxes', $tax );
3304
+            $taxes[ $tax['name'] ] = $tax;
3305
+            $this->set_prop( 'taxes', $tax );
3306 3306
 
3307 3307
         }
3308 3308
 
3309 3309
     }
3310 3310
 
3311 3311
     /**
3312
-	 * Retrieves a specific tax.
3313
-	 *
3314
-	 * @since 1.0.19
3315
-	 */
3316
-	public function get_tax( $tax = null ) {
3312
+     * Retrieves a specific tax.
3313
+     *
3314
+     * @since 1.0.19
3315
+     */
3316
+    public function get_tax( $tax = null ) {
3317 3317
 
3318
-		// Backwards compatility.
3319
-		if ( empty( $tax ) ) {
3320
-			return $this->get_total_tax();
3321
-		}
3318
+        // Backwards compatility.
3319
+        if ( empty( $tax ) ) {
3320
+            return $this->get_total_tax();
3321
+        }
3322 3322
 
3323 3323
         $taxes = $this->get_taxes();
3324
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3324
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3325 3325
     }
3326 3326
 
3327 3327
     /**
3328
-	 * Removes a specific tax.
3329
-	 *
3330
-	 * @since 1.0.19
3331
-	 */
3332
-	public function remove_tax( $tax ) {
3328
+     * Removes a specific tax.
3329
+     *
3330
+     * @since 1.0.19
3331
+     */
3332
+    public function remove_tax( $tax ) {
3333 3333
         $taxes = $this->get_taxes();
3334 3334
         if ( isset( $taxes[ $tax ] ) ) {
3335 3335
             unset( $taxes[ $tax ] );
@@ -3338,160 +3338,160 @@  discard block
 block discarded – undo
3338 3338
     }
3339 3339
 
3340 3340
     /**
3341
-	 * Recalculates the invoice subtotal.
3342
-	 *
3343
-	 * @since 1.0.19
3344
-	 * @return float The recalculated subtotal
3345
-	 */
3346
-	public function recalculate_subtotal() {
3341
+     * Recalculates the invoice subtotal.
3342
+     *
3343
+     * @since 1.0.19
3344
+     * @return float The recalculated subtotal
3345
+     */
3346
+    public function recalculate_subtotal() {
3347 3347
         $items     = $this->get_items();
3348
-		$subtotal  = 0;
3349
-		$recurring = 0;
3348
+        $subtotal  = 0;
3349
+        $recurring = 0;
3350 3350
 
3351 3351
         foreach ( $items as $item ) {
3352
-			$subtotal  += $item->get_sub_total();
3353
-			$recurring += $item->get_recurring_sub_total();
3352
+            $subtotal  += $item->get_sub_total();
3353
+            $recurring += $item->get_recurring_sub_total();
3354 3354
         }
3355 3355
 
3356
-		if ( $this->is_renewal() ) {
3357
-			$this->set_subtotal( $recurring );
3358
-		} else {
3359
-			$this->set_subtotal( $subtotal );
3360
-		}
3356
+        if ( $this->is_renewal() ) {
3357
+            $this->set_subtotal( $recurring );
3358
+        } else {
3359
+            $this->set_subtotal( $subtotal );
3360
+        }
3361 3361
 
3362
-		$this->totals['subtotal'] = array(
3363
-			'initial'   => $subtotal,
3364
-			'recurring' => $recurring,
3365
-		);
3362
+        $this->totals['subtotal'] = array(
3363
+            'initial'   => $subtotal,
3364
+            'recurring' => $recurring,
3365
+        );
3366 3366
 
3367 3367
         return $this->is_renewal() ? $recurring : $subtotal;
3368 3368
     }
3369 3369
 
3370 3370
     /**
3371
-	 * Recalculates the invoice discount total.
3372
-	 *
3373
-	 * @since 1.0.19
3374
-	 * @return float The recalculated discount
3375
-	 */
3376
-	public function recalculate_total_discount() {
3371
+     * Recalculates the invoice discount total.
3372
+     *
3373
+     * @since 1.0.19
3374
+     * @return float The recalculated discount
3375
+     */
3376
+    public function recalculate_total_discount() {
3377 3377
         $discounts = $this->get_discounts();
3378
-		$discount  = 0;
3379
-		$recurring = 0;
3378
+        $discount  = 0;
3379
+        $recurring = 0;
3380 3380
 
3381 3381
         foreach ( $discounts as $data ) {
3382 3382
 
3383
-			if ( $data['recurring'] ) {
3384
-				$recurring += $data['amount'];
3385
-			} else {
3386
-				$discount += $data['amount'];
3387
-			}
3383
+            if ( $data['recurring'] ) {
3384
+                $recurring += $data['amount'];
3385
+            } else {
3386
+                $discount += $data['amount'];
3387
+            }
3388 3388
 
3389
-		}
3389
+        }
3390 3390
 
3391
-		if ( $this->is_renewal() ) {
3392
-			$this->set_total_discount( $recurring );
3393
-		} else {
3394
-			$this->set_total_discount( $discount );
3395
-		}
3391
+        if ( $this->is_renewal() ) {
3392
+            $this->set_total_discount( $recurring );
3393
+        } else {
3394
+            $this->set_total_discount( $discount );
3395
+        }
3396 3396
 
3397
-		$this->totals['discount'] = array(
3398
-			'initial'   => $discount,
3399
-			'recurring' => $recurring,
3400
-		);
3397
+        $this->totals['discount'] = array(
3398
+            'initial'   => $discount,
3399
+            'recurring' => $recurring,
3400
+        );
3401 3401
 
3402
-		return $this->is_renewal() ? $recurring : $discount;
3402
+        return $this->is_renewal() ? $recurring : $discount;
3403 3403
 
3404 3404
     }
3405 3405
 
3406 3406
     /**
3407
-	 * Recalculates the invoice tax total.
3408
-	 *
3409
-	 * @since 1.0.19
3410
-	 * @return float The recalculated tax
3411
-	 */
3412
-	public function recalculate_total_tax() {
3407
+     * Recalculates the invoice tax total.
3408
+     *
3409
+     * @since 1.0.19
3410
+     * @return float The recalculated tax
3411
+     */
3412
+    public function recalculate_total_tax() {
3413 3413
         $taxes     = $this->get_taxes();
3414
-		$tax       = 0;
3415
-		$recurring = 0;
3414
+        $tax       = 0;
3415
+        $recurring = 0;
3416 3416
 
3417 3417
         foreach ( $taxes as $data ) {
3418 3418
 
3419
-			if ( $data['recurring'] ) {
3420
-				$recurring += $data['amount'];
3421
-			} else {
3422
-				$tax += $data['amount'];
3423
-			}
3419
+            if ( $data['recurring'] ) {
3420
+                $recurring += $data['amount'];
3421
+            } else {
3422
+                $tax += $data['amount'];
3423
+            }
3424 3424
 
3425
-		}
3425
+        }
3426 3426
 
3427
-		if ( $this->is_renewal() ) {
3428
-			$this->set_total_tax( $recurring );
3429
-		} else {
3430
-			$this->set_total_tax( $tax );
3431
-		}
3427
+        if ( $this->is_renewal() ) {
3428
+            $this->set_total_tax( $recurring );
3429
+        } else {
3430
+            $this->set_total_tax( $tax );
3431
+        }
3432 3432
 
3433
-		$this->totals['tax'] = array(
3434
-			'initial'   => $tax,
3435
-			'recurring' => $recurring,
3436
-		);
3433
+        $this->totals['tax'] = array(
3434
+            'initial'   => $tax,
3435
+            'recurring' => $recurring,
3436
+        );
3437 3437
 
3438
-		return $this->is_renewal() ? $recurring : $tax;
3438
+        return $this->is_renewal() ? $recurring : $tax;
3439 3439
 
3440 3440
     }
3441 3441
 
3442 3442
     /**
3443
-	 * Recalculates the invoice fees total.
3444
-	 *
3445
-	 * @since 1.0.19
3446
-	 * @return float The recalculated fee
3447
-	 */
3448
-	public function recalculate_total_fees() {
3449
-		$fees      = $this->get_fees();
3450
-		$fee       = 0;
3451
-		$recurring = 0;
3443
+     * Recalculates the invoice fees total.
3444
+     *
3445
+     * @since 1.0.19
3446
+     * @return float The recalculated fee
3447
+     */
3448
+    public function recalculate_total_fees() {
3449
+        $fees      = $this->get_fees();
3450
+        $fee       = 0;
3451
+        $recurring = 0;
3452 3452
 
3453 3453
         foreach ( $fees as $data ) {
3454 3454
 
3455
-			if ( $data['recurring'] ) {
3456
-				$recurring += $data['amount'];
3457
-			} else {
3458
-				$fee += $data['amount'];
3459
-			}
3455
+            if ( $data['recurring'] ) {
3456
+                $recurring += $data['amount'];
3457
+            } else {
3458
+                $fee += $data['amount'];
3459
+            }
3460 3460
 
3461
-		}
3461
+        }
3462 3462
 
3463 3463
         if ( $this->is_renewal() ) {
3464
-			$this->set_total_fees( $recurring );
3465
-		} else {
3466
-			$this->set_total_fees( $fee );
3467
-		}
3464
+            $this->set_total_fees( $recurring );
3465
+        } else {
3466
+            $this->set_total_fees( $fee );
3467
+        }
3468 3468
 
3469
-		$this->totals['fee'] = array(
3470
-			'initial'   => $fee,
3471
-			'recurring' => $recurring,
3472
-		);
3469
+        $this->totals['fee'] = array(
3470
+            'initial'   => $fee,
3471
+            'recurring' => $recurring,
3472
+        );
3473 3473
 
3474 3474
         $this->set_total_fees( $fee );
3475 3475
         return $this->is_renewal() ? $recurring : $fee;
3476 3476
     }
3477 3477
 
3478 3478
     /**
3479
-	 * Recalculates the invoice total.
3480
-	 *
3481
-	 * @since 1.0.19
3479
+     * Recalculates the invoice total.
3480
+     *
3481
+     * @since 1.0.19
3482 3482
      * @return float The invoice total
3483
-	 */
3484
-	public function recalculate_total() {
3483
+     */
3484
+    public function recalculate_total() {
3485 3485
         $this->recalculate_subtotal();
3486 3486
         $this->recalculate_total_fees();
3487 3487
         $this->recalculate_total_discount();
3488 3488
         $this->recalculate_total_tax();
3489
-		return $this->get_total();
3490
-	}
3489
+        return $this->get_total();
3490
+    }
3491 3491
 
3492
-	/**
3493
-	 * @deprecated
3494
-	 */
3492
+    /**
3493
+     * @deprecated
3494
+     */
3495 3495
     public function recalculate_totals( $temp = false ) {
3496 3496
         $this->update_items( $temp );
3497 3497
         $this->save( true );
@@ -3509,7 +3509,7 @@  discard block
 block discarded – undo
3509 3509
      * Adds a note to an invoice.
3510 3510
      *
3511 3511
      * @param string $note The note being added.
3512
-	 * @return int|false The new note's ID on success, false on failure.
3512
+     * @return int|false The new note's ID on success, false on failure.
3513 3513
      *
3514 3514
      */
3515 3515
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3519,21 +3519,21 @@  discard block
 block discarded – undo
3519 3519
             return false;
3520 3520
         }
3521 3521
 
3522
-		$author       = 'System';
3523
-		$author_email = '[email protected]';
3522
+        $author       = 'System';
3523
+        $author_email = '[email protected]';
3524 3524
 
3525
-		// If this is an admin comment or it has been added by the user.
3526
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3527
-			$user         = get_user_by( 'id', get_current_user_id() );
3525
+        // If this is an admin comment or it has been added by the user.
3526
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3527
+            $user         = get_user_by( 'id', get_current_user_id() );
3528 3528
             $author       = $user->display_name;
3529 3529
             $author_email = $user->user_email;
3530
-		}
3530
+        }
3531 3531
 
3532
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3532
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3533 3533
 
3534
-	}
3534
+    }
3535 3535
 
3536
-	/**
3536
+    /**
3537 3537
      * Generates a unique key for the invoice.
3538 3538
      */
3539 3539
     public function generate_key( $string = '' ) {
@@ -3553,113 +3553,113 @@  discard block
 block discarded – undo
3553 3553
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3554 3554
         }
3555 3555
 
3556
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3557
-
3558
-	}
3559
-
3560
-	/**
3561
-	 * Handle the status transition.
3562
-	 */
3563
-	protected function status_transition() {
3564
-		$status_transition = $this->status_transition;
3565
-
3566
-		// Reset status transition variable.
3567
-		$this->status_transition = false;
3568
-
3569
-		if ( $status_transition ) {
3570
-			try {
3571
-
3572
-				// Fire a hook for the status change.
3573
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3556
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3574 3557
 
3575
-				// @deprecated this is deprecated and will be removed in the future.
3576
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3577
-
3578
-				if ( ! empty( $status_transition['from'] ) ) {
3579
-
3580
-					/* translators: 1: old invoice status 2: new invoice status */
3581
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3582
-
3583
-					// Fire another hook.
3584
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3585
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3586
-
3587
-					// @deprecated this is deprecated and will be removed in the future.
3588
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3589
-
3590
-					// Note the transition occurred.
3591
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3592
-
3593
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3594
-					if (
3595
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3596
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3597
-					) {
3598
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3599
-					}
3600
-
3601
-					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3602
-					if (
3603
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3604
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3605
-					) {
3606
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3607
-					}
3608
-				} else {
3609
-					/* translators: %s: new invoice status */
3610
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3611
-
3612
-					// Note the transition occurred.
3613
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3558
+    }
3614 3559
 
3615
-				}
3616
-			} catch ( Exception $e ) {
3617
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3618
-			}
3619
-		}
3620
-	}
3560
+    /**
3561
+     * Handle the status transition.
3562
+     */
3563
+    protected function status_transition() {
3564
+        $status_transition = $this->status_transition;
3565
+
3566
+        // Reset status transition variable.
3567
+        $this->status_transition = false;
3568
+
3569
+        if ( $status_transition ) {
3570
+            try {
3571
+
3572
+                // Fire a hook for the status change.
3573
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3574
+
3575
+                // @deprecated this is deprecated and will be removed in the future.
3576
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3577
+
3578
+                if ( ! empty( $status_transition['from'] ) ) {
3579
+
3580
+                    /* translators: 1: old invoice status 2: new invoice status */
3581
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3582
+
3583
+                    // Fire another hook.
3584
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3585
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3586
+
3587
+                    // @deprecated this is deprecated and will be removed in the future.
3588
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3589
+
3590
+                    // Note the transition occurred.
3591
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3592
+
3593
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3594
+                    if (
3595
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3596
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3597
+                    ) {
3598
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3599
+                    }
3600
+
3601
+                    // Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3602
+                    if (
3603
+                        in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3604
+                        && in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3605
+                    ) {
3606
+                        do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3607
+                    }
3608
+                } else {
3609
+                    /* translators: %s: new invoice status */
3610
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3611
+
3612
+                    // Note the transition occurred.
3613
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3614
+
3615
+                }
3616
+            } catch ( Exception $e ) {
3617
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3618
+            }
3619
+        }
3620
+    }
3621 3621
 
3622
-	/**
3623
-	 * Updates an invoice status.
3624
-	 */
3625
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3622
+    /**
3623
+     * Updates an invoice status.
3624
+     */
3625
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3626 3626
 
3627
-		// Fires before updating a status.
3628
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3627
+        // Fires before updating a status.
3628
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3629 3629
 
3630
-		// Update the status.
3631
-		$this->set_status( $new_status, $note, $manual );
3630
+        // Update the status.
3631
+        $this->set_status( $new_status, $note, $manual );
3632 3632
 
3633
-		// Save the order.
3634
-		return $this->save();
3633
+        // Save the order.
3634
+        return $this->save();
3635 3635
 
3636
-	}
3636
+    }
3637 3637
 
3638
-	/**
3639
-	 * @deprecated
3640
-	 */
3641
-	public function refresh_item_ids() {
3638
+    /**
3639
+     * @deprecated
3640
+     */
3641
+    public function refresh_item_ids() {
3642 3642
         $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3643 3643
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3644
-	}
3644
+    }
3645 3645
 
3646
-	/**
3647
-	 * @deprecated
3648
-	 */
3649
-	public function update_items( $temp = false ) {
3646
+    /**
3647
+     * @deprecated
3648
+     */
3649
+    public function update_items( $temp = false ) {
3650 3650
 
3651
-		$this->set_items( $this->get_items() );
3651
+        $this->set_items( $this->get_items() );
3652 3652
 
3653
-		if ( ! $temp ) {
3654
-			$this->save();
3655
-		}
3653
+        if ( ! $temp ) {
3654
+            $this->save();
3655
+        }
3656 3656
 
3657 3657
         return $this;
3658
-	}
3658
+    }
3659 3659
 
3660
-	/**
3661
-	 * @deprecated
3662
-	 */
3660
+    /**
3661
+     * @deprecated
3662
+     */
3663 3663
     public function validate_discount() {
3664 3664
 
3665 3665
         $discount_code = $this->get_discount_code();
@@ -3675,97 +3675,97 @@  discard block
 block discarded – undo
3675 3675
 
3676 3676
     }
3677 3677
 
3678
-	/**
3679
-	 * Refunds an invoice.
3680
-	 */
3678
+    /**
3679
+     * Refunds an invoice.
3680
+     */
3681 3681
     public function refund() {
3682
-		$this->set_status( 'wpi-refunded' );
3682
+        $this->set_status( 'wpi-refunded' );
3683 3683
         $this->save();
3684
-	}
3684
+    }
3685 3685
 
3686
-	/**
3687
-	 * Marks an invoice as paid.
3688
-	 * 
3689
-	 * @param string $transaction_id
3690
-	 */
3686
+    /**
3687
+     * Marks an invoice as paid.
3688
+     * 
3689
+     * @param string $transaction_id
3690
+     */
3691 3691
     public function mark_paid( $transaction_id = null, $note = '' ) {
3692 3692
 
3693
-		// Set the transaction id.
3694
-		if ( empty( $transaction_id ) ) {
3695
-			$transaction_id = $this->generate_key('trans_');
3696
-		}
3693
+        // Set the transaction id.
3694
+        if ( empty( $transaction_id ) ) {
3695
+            $transaction_id = $this->generate_key('trans_');
3696
+        }
3697 3697
 
3698
-		if ( ! $this->get_transaction_id() ) {
3699
-			$this->set_transaction_id( $transaction_id );
3700
-		}
3698
+        if ( ! $this->get_transaction_id() ) {
3699
+            $this->set_transaction_id( $transaction_id );
3700
+        }
3701 3701
 
3702
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3703
-			return $this->save();
3704
-		}
3702
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3703
+            return $this->save();
3704
+        }
3705 3705
 
3706
-		// Set the completed date.
3707
-		$this->set_date_completed( current_time( 'mysql' ) );
3706
+        // Set the completed date.
3707
+        $this->set_date_completed( current_time( 'mysql' ) );
3708 3708
 
3709
-		// Set the new status.
3710
-		if ( $this->is_renewal() ) {
3709
+        // Set the new status.
3710
+        if ( $this->is_renewal() ) {
3711 3711
 
3712
-			$_note = sprintf(
3713
-				__( 'Renewed via %s', 'invoicing' ),
3714
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3715
-			);
3712
+            $_note = sprintf(
3713
+                __( 'Renewed via %s', 'invoicing' ),
3714
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3715
+            );
3716 3716
 
3717
-			if ( 'none' == $this->get_gateway() ) {
3718
-				$_note = $note;
3719
-			}
3717
+            if ( 'none' == $this->get_gateway() ) {
3718
+                $_note = $note;
3719
+            }
3720 3720
 
3721
-			$this->set_status( 'wpi-renewal', $_note );
3721
+            $this->set_status( 'wpi-renewal', $_note );
3722 3722
 
3723
-		} else {
3723
+        } else {
3724 3724
 
3725
-			$_note = sprintf(
3726
-				__( 'Paid via %s', 'invoicing' ),
3727
-				$this->get_gateway() . empty( $note ) ? '' : " ($note)"
3728
-			);
3725
+            $_note = sprintf(
3726
+                __( 'Paid via %s', 'invoicing' ),
3727
+                $this->get_gateway() . empty( $note ) ? '' : " ($note)"
3728
+            );
3729 3729
 
3730
-			if ( 'none' == $this->get_gateway() ) {
3731
-				$_note = $note;
3732
-			}
3730
+            if ( 'none' == $this->get_gateway() ) {
3731
+                $_note = $note;
3732
+            }
3733 3733
 
3734
-			$this->set_status( 'publish',$_note );
3734
+            $this->set_status( 'publish',$_note );
3735 3735
 
3736
-		}
3736
+        }
3737 3737
 
3738
-		// Set checkout mode.
3739
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3740
-		$this->set_mode( $mode );
3738
+        // Set checkout mode.
3739
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3740
+        $this->set_mode( $mode );
3741 3741
 
3742
-		// Save the invoice.
3742
+        // Save the invoice.
3743 3743
         $this->save();
3744
-	}
3745
-
3746
-
3747
-	/**
3748
-	 * Save data to the database.
3749
-	 *
3750
-	 * @since 1.0.19
3751
-	 * @return int invoice ID
3752
-	 */
3753
-	public function save() {
3754
-		$this->maybe_set_date_paid();
3755
-		$this->maybe_set_key();
3756
-		parent::save();
3757
-		$this->clear_cache();
3758
-		$this->status_transition();
3759
-		return $this->get_id();
3760
-	}
3761
-
3762
-	/**
3744
+    }
3745
+
3746
+
3747
+    /**
3748
+     * Save data to the database.
3749
+     *
3750
+     * @since 1.0.19
3751
+     * @return int invoice ID
3752
+     */
3753
+    public function save() {
3754
+        $this->maybe_set_date_paid();
3755
+        $this->maybe_set_key();
3756
+        parent::save();
3757
+        $this->clear_cache();
3758
+        $this->status_transition();
3759
+        return $this->get_id();
3760
+    }
3761
+
3762
+    /**
3763 3763
      * Clears the subscription's cache.
3764 3764
      */
3765 3765
     public function clear_cache() {
3766
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3767
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3768
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3769
-	}
3766
+        wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3767
+        wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3768
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3769
+    }
3770 3770
 
3771 3771
 }
Please login to merge, or discard this patch.
Spacing   +746 added lines, -746 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @package Invoicing
7 7
  */
8 8
 
9
-defined( 'ABSPATH' ) || exit;
9
+defined('ABSPATH') || exit;
10 10
 
11 11
 /**
12 12
  * Invoice class.
@@ -134,40 +134,40 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
136 136
 	 */
137
-    public function __construct( $invoice = false ) {
137
+    public function __construct($invoice = false) {
138 138
 
139
-        parent::__construct( $invoice );
139
+        parent::__construct($invoice);
140 140
 
141
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
142
-			$this->set_id( $invoice );
143
-		} elseif ( $invoice instanceof self ) {
144
-			$this->set_id( $invoice->get_id() );
145
-		} elseif ( ! empty( $invoice->ID ) ) {
146
-			$this->set_id( $invoice->ID );
147
-		} elseif ( is_array( $invoice ) ) {
148
-			$this->set_props( $invoice );
141
+		if (!empty($invoice) && is_numeric($invoice) && getpaid_is_invoice_post_type(get_post_type($invoice))) {
142
+			$this->set_id($invoice);
143
+		} elseif ($invoice instanceof self) {
144
+			$this->set_id($invoice->get_id());
145
+		} elseif (!empty($invoice->ID)) {
146
+			$this->set_id($invoice->ID);
147
+		} elseif (is_array($invoice)) {
148
+			$this->set_props($invoice);
149 149
 
150
-			if ( isset( $invoice['ID'] ) ) {
151
-				$this->set_id( $invoice['ID'] );
150
+			if (isset($invoice['ID'])) {
151
+				$this->set_id($invoice['ID']);
152 152
 			}
153 153
 
154
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
155
-			$this->set_id( $invoice_id );
156
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
157
-			$this->set_id( $invoice_id );
158
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
159
-			$this->set_id( $invoice_id );
160
-		}else {
161
-			$this->set_object_read( true );
154
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'key')) {
155
+			$this->set_id($invoice_id);
156
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'number')) {
157
+			$this->set_id($invoice_id);
158
+		} elseif (is_scalar($invoice) && $invoice_id = self::get_invoice_id_by_field($invoice, 'transaction_id')) {
159
+			$this->set_id($invoice_id);
160
+		} else {
161
+			$this->set_object_read(true);
162 162
 		}
163 163
 
164 164
         // Load the datastore.
165
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
165
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
166 166
 
167
-		if ( $this->get_id() > 0 ) {
168
-            $this->post = get_post( $this->get_id() );
167
+		if ($this->get_id() > 0) {
168
+            $this->post = get_post($this->get_id());
169 169
             $this->ID   = $this->get_id();
170
-			$this->data_store->read( $this );
170
+			$this->data_store->read($this);
171 171
         }
172 172
 
173 173
     }
@@ -182,38 +182,38 @@  discard block
 block discarded – undo
182 182
 	 * @since 1.0.15
183 183
 	 * @return int
184 184
 	 */
185
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
185
+	public static function get_invoice_id_by_field($value, $field = 'key') {
186 186
         global $wpdb;
187 187
 
188 188
 		// Trim the value.
189
-		$value = trim( $value );
189
+		$value = trim($value);
190 190
 
191
-		if ( empty( $value ) ) {
191
+		if (empty($value)) {
192 192
 			return 0;
193 193
 		}
194 194
 
195 195
         // Valid fields.
196
-        $fields = array( 'key', 'number', 'transaction_id' );
196
+        $fields = array('key', 'number', 'transaction_id');
197 197
 
198 198
 		// Ensure a field has been passed.
199
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
199
+		if (empty($field) || !in_array($field, $fields)) {
200 200
 			return 0;
201 201
 		}
202 202
 
203 203
 		// Maybe retrieve from the cache.
204
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
205
-		if ( false !== $invoice_id ) {
204
+		$invoice_id = wp_cache_get($value, "getpaid_invoice_{$field}s_to_invoice_ids");
205
+		if (false !== $invoice_id) {
206 206
 			return $invoice_id;
207 207
 		}
208 208
 
209 209
         // Fetch from the db.
210 210
         $table       = $wpdb->prefix . 'getpaid_invoices';
211 211
         $invoice_id  = (int) $wpdb->get_var(
212
-            $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
212
+            $wpdb->prepare("SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value)
213 213
         );
214 214
 
215 215
 		// Update the cache with our data
216
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
216
+		wp_cache_set($value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids");
217 217
 
218 218
 		return $invoice_id;
219 219
     }
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
     /**
222 222
      * Checks if an invoice key is set.
223 223
      */
224
-    public function _isset( $key ) {
225
-        return isset( $this->data[$key] ) || method_exists( $this, "get_$key" );
224
+    public function _isset($key) {
225
+        return isset($this->data[$key]) || method_exists($this, "get_$key");
226 226
     }
227 227
 
228 228
     /*
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
 	 * @param  string $context View or edit context.
248 248
 	 * @return int
249 249
 	 */
250
-	public function get_parent_id( $context = 'view' ) {
251
-		return (int) $this->get_prop( 'parent_id', $context );
250
+	public function get_parent_id($context = 'view') {
251
+		return (int) $this->get_prop('parent_id', $context);
252 252
     }
253 253
 
254 254
     /**
@@ -258,7 +258,7 @@  discard block
 block discarded – undo
258 258
 	 * @return WPInv_Invoice
259 259
 	 */
260 260
     public function get_parent_payment() {
261
-        return new WPInv_Invoice( $this->get_parent_id() );
261
+        return new WPInv_Invoice($this->get_parent_id());
262 262
     }
263 263
 
264 264
     /**
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
 	 * @param  string $context View or edit context.
279 279
 	 * @return string
280 280
 	 */
281
-	public function get_status( $context = 'view' ) {
282
-		return $this->get_prop( 'status', $context );
281
+	public function get_status($context = 'view') {
282
+		return $this->get_prop('status', $context);
283 283
 	}
284 284
 	
285 285
 	/**
@@ -290,10 +290,10 @@  discard block
 block discarded – undo
290 290
 	 */
291 291
 	public function get_all_statuses() {
292 292
 
293
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
293
+		$statuses = wpinv_get_invoice_statuses(true, true, $this);
294 294
 
295 295
 		// For backwards compatibility.
296
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
296
+		if ($this->is_quote() && class_exists('Wpinv_Quotes_Shared')) {
297 297
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
298 298
 		}
299 299
 
@@ -309,9 +309,9 @@  discard block
 block discarded – undo
309 309
     public function get_status_nicename() {
310 310
 		$statuses = $this->get_all_statuses();
311 311
 
312
-        $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
312
+        $status = isset($statuses[$this->get_status()]) ? $statuses[$this->get_status()] : $this->get_status();
313 313
 
314
-        return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
314
+        return apply_filters('wpinv_get_invoice_status_nicename', $status, $this);
315 315
     }
316 316
 
317 317
 	/**
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public function get_status_label_html() {
324 324
 
325
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
326
-		$status       = sanitize_html_class( $this->get_status() );
325
+		$status_label = sanitize_text_field($this->get_status_nicename());
326
+		$status       = sanitize_html_class($this->get_status());
327 327
 
328 328
 		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
329 329
 	}
@@ -335,23 +335,23 @@  discard block
 block discarded – undo
335 335
 	 * @param  string $context View or edit context.
336 336
 	 * @return string
337 337
 	 */
338
-	public function get_version( $context = 'view' ) {
339
-		return $this->get_prop( 'version', $context );
338
+	public function get_version($context = 'view') {
339
+		return $this->get_prop('version', $context);
340 340
 	}
341 341
 
342 342
 	/**
343 343
 	 * @deprecated
344 344
 	 */
345
-	public function get_invoice_date( $format = true ) {
346
-		$date      = getpaid_format_date( $this->get_date_completed() );
347
-		$date      = empty( $date ) ? $this->get_date_created() : $this->get_date_completed();
348
-		$formatted = getpaid_format_date( $date );
345
+	public function get_invoice_date($format = true) {
346
+		$date      = getpaid_format_date($this->get_date_completed());
347
+		$date      = empty($date) ? $this->get_date_created() : $this->get_date_completed();
348
+		$formatted = getpaid_format_date($date);
349 349
 
350
-		if ( $format ) {
350
+		if ($format) {
351 351
 			return $formatted;
352 352
 		}
353 353
 
354
-		return empty( $formatted ) ? '' : $date;
354
+		return empty($formatted) ? '' : $date;
355 355
 
356 356
     }
357 357
 
@@ -362,8 +362,8 @@  discard block
 block discarded – undo
362 362
 	 * @param  string $context View or edit context.
363 363
 	 * @return string
364 364
 	 */
365
-	public function get_date_created( $context = 'view' ) {
366
-		return $this->get_prop( 'date_created', $context );
365
+	public function get_date_created($context = 'view') {
366
+		return $this->get_prop('date_created', $context);
367 367
 	}
368 368
 	
369 369
 	/**
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	 * @param  string $context View or edit context.
374 374
 	 * @return string
375 375
 	 */
376
-	public function get_created_date( $context = 'view' ) {
377
-		return $this->get_date_created( $context );
376
+	public function get_created_date($context = 'view') {
377
+		return $this->get_date_created($context);
378 378
     }
379 379
 
380 380
     /**
@@ -384,11 +384,11 @@  discard block
 block discarded – undo
384 384
 	 * @param  string $context View or edit context.
385 385
 	 * @return string
386 386
 	 */
387
-	public function get_date_created_gmt( $context = 'view' ) {
388
-        $date = $this->get_date_created( $context );
387
+	public function get_date_created_gmt($context = 'view') {
388
+        $date = $this->get_date_created($context);
389 389
 
390
-        if ( $date ) {
391
-            $date = get_gmt_from_date( $date );
390
+        if ($date) {
391
+            $date = get_gmt_from_date($date);
392 392
         }
393 393
 		return $date;
394 394
     }
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
 	 * @param  string $context View or edit context.
401 401
 	 * @return string
402 402
 	 */
403
-	public function get_date_modified( $context = 'view' ) {
404
-		return $this->get_prop( 'date_modified', $context );
403
+	public function get_date_modified($context = 'view') {
404
+		return $this->get_prop('date_modified', $context);
405 405
 	}
406 406
 
407 407
 	/**
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
 	 * @param  string $context View or edit context.
412 412
 	 * @return string
413 413
 	 */
414
-	public function get_modified_date( $context = 'view' ) {
415
-		return $this->get_date_modified( $context );
414
+	public function get_modified_date($context = 'view') {
415
+		return $this->get_date_modified($context);
416 416
     }
417 417
 
418 418
     /**
@@ -422,11 +422,11 @@  discard block
 block discarded – undo
422 422
 	 * @param  string $context View or edit context.
423 423
 	 * @return string
424 424
 	 */
425
-	public function get_date_modified_gmt( $context = 'view' ) {
426
-        $date = $this->get_date_modified( $context );
425
+	public function get_date_modified_gmt($context = 'view') {
426
+        $date = $this->get_date_modified($context);
427 427
 
428
-        if ( $date ) {
429
-            $date = get_gmt_from_date( $date );
428
+        if ($date) {
429
+            $date = get_gmt_from_date($date);
430 430
         }
431 431
 		return $date;
432 432
     }
@@ -438,8 +438,8 @@  discard block
 block discarded – undo
438 438
 	 * @param  string $context View or edit context.
439 439
 	 * @return string
440 440
 	 */
441
-	public function get_due_date( $context = 'view' ) {
442
-		return $this->get_prop( 'due_date', $context );
441
+	public function get_due_date($context = 'view') {
442
+		return $this->get_prop('due_date', $context);
443 443
     }
444 444
 
445 445
     /**
@@ -449,8 +449,8 @@  discard block
 block discarded – undo
449 449
 	 * @param  string $context View or edit context.
450 450
 	 * @return string
451 451
 	 */
452
-	public function get_date_due( $context = 'view' ) {
453
-		return $this->get_due_date( $context );
452
+	public function get_date_due($context = 'view') {
453
+		return $this->get_due_date($context);
454 454
     }
455 455
 
456 456
     /**
@@ -460,11 +460,11 @@  discard block
 block discarded – undo
460 460
 	 * @param  string $context View or edit context.
461 461
 	 * @return string
462 462
 	 */
463
-	public function get_due_date_gmt( $context = 'view' ) {
464
-        $date = $this->get_due_date( $context );
463
+	public function get_due_date_gmt($context = 'view') {
464
+        $date = $this->get_due_date($context);
465 465
 
466
-        if ( $date ) {
467
-            $date = get_gmt_from_date( $date );
466
+        if ($date) {
467
+            $date = get_gmt_from_date($date);
468 468
         }
469 469
 		return $date;
470 470
     }
@@ -476,8 +476,8 @@  discard block
 block discarded – undo
476 476
 	 * @param  string $context View or edit context.
477 477
 	 * @return string
478 478
 	 */
479
-	public function get_gmt_date_due( $context = 'view' ) {
480
-		return $this->get_due_date_gmt( $context );
479
+	public function get_gmt_date_due($context = 'view') {
480
+		return $this->get_due_date_gmt($context);
481 481
     }
482 482
 
483 483
     /**
@@ -487,8 +487,8 @@  discard block
 block discarded – undo
487 487
 	 * @param  string $context View or edit context.
488 488
 	 * @return string
489 489
 	 */
490
-	public function get_completed_date( $context = 'view' ) {
491
-		return $this->get_prop( 'completed_date', $context );
490
+	public function get_completed_date($context = 'view') {
491
+		return $this->get_prop('completed_date', $context);
492 492
     }
493 493
 
494 494
     /**
@@ -498,8 +498,8 @@  discard block
 block discarded – undo
498 498
 	 * @param  string $context View or edit context.
499 499
 	 * @return string
500 500
 	 */
501
-	public function get_date_completed( $context = 'view' ) {
502
-		return $this->get_completed_date( $context );
501
+	public function get_date_completed($context = 'view') {
502
+		return $this->get_completed_date($context);
503 503
     }
504 504
 
505 505
     /**
@@ -509,11 +509,11 @@  discard block
 block discarded – undo
509 509
 	 * @param  string $context View or edit context.
510 510
 	 * @return string
511 511
 	 */
512
-	public function get_completed_date_gmt( $context = 'view' ) {
513
-        $date = $this->get_completed_date( $context );
512
+	public function get_completed_date_gmt($context = 'view') {
513
+        $date = $this->get_completed_date($context);
514 514
 
515
-        if ( $date ) {
516
-            $date = get_gmt_from_date( $date );
515
+        if ($date) {
516
+            $date = get_gmt_from_date($date);
517 517
         }
518 518
 		return $date;
519 519
     }
@@ -525,8 +525,8 @@  discard block
 block discarded – undo
525 525
 	 * @param  string $context View or edit context.
526 526
 	 * @return string
527 527
 	 */
528
-	public function get_gmt_completed_date( $context = 'view' ) {
529
-		return $this->get_completed_date_gmt( $context );
528
+	public function get_gmt_completed_date($context = 'view') {
529
+		return $this->get_completed_date_gmt($context);
530 530
     }
531 531
 
532 532
     /**
@@ -536,12 +536,12 @@  discard block
 block discarded – undo
536 536
 	 * @param  string $context View or edit context.
537 537
 	 * @return string
538 538
 	 */
539
-	public function get_number( $context = 'view' ) {
540
-		$number = $this->get_prop( 'number', $context );
539
+	public function get_number($context = 'view') {
540
+		$number = $this->get_prop('number', $context);
541 541
 
542
-		if ( empty( $number ) ) {
542
+		if (empty($number)) {
543 543
 			$number = $this->generate_number();
544
-			$this->set_number( $this->generate_number() );
544
+			$this->set_number($this->generate_number());
545 545
 		}
546 546
 
547 547
 		return $number;
@@ -555,8 +555,8 @@  discard block
 block discarded – undo
555 555
 	public function maybe_set_number() {
556 556
         $number = $this->get_number();
557 557
 
558
-        if ( empty( $number ) || $this->get_id() == $number ) {
559
-			$this->set_number( $this->generate_number() );
558
+        if (empty($number) || $this->get_id() == $number) {
559
+			$this->set_number($this->generate_number());
560 560
         }
561 561
 
562 562
 	}
@@ -568,8 +568,8 @@  discard block
 block discarded – undo
568 568
 	 * @param  string $context View or edit context.
569 569
 	 * @return string
570 570
 	 */
571
-	public function get_key( $context = 'view' ) {
572
-        return $this->get_prop( 'key', $context );
571
+	public function get_key($context = 'view') {
572
+        return $this->get_prop('key', $context);
573 573
 	}
574 574
 
575 575
 	/**
@@ -580,9 +580,9 @@  discard block
 block discarded – undo
580 580
 	public function maybe_set_key() {
581 581
         $key = $this->get_key();
582 582
 
583
-        if ( empty( $key ) ) {
584
-            $key = $this->generate_key( $this->get_type() . '_' );
585
-            $this->set_key( $key );
583
+        if (empty($key)) {
584
+            $key = $this->generate_key($this->get_type() . '_');
585
+            $this->set_key($key);
586 586
         }
587 587
 
588 588
     }
@@ -594,15 +594,15 @@  discard block
 block discarded – undo
594 594
 	 * @param  string $context View or edit context.
595 595
 	 * @return string
596 596
 	 */
597
-	public function get_type( $context = 'view' ) {
598
-        return $this->get_prop( 'type', $context );
597
+	public function get_type($context = 'view') {
598
+        return $this->get_prop('type', $context);
599 599
 	}
600 600
 
601 601
 	/**
602 602
 	 * @deprecated
603 603
 	 */
604 604
 	public function get_invoice_quote_type() {
605
-        ucfirst( $this->get_type() );
605
+        ucfirst($this->get_type());
606 606
     }
607 607
 
608 608
     /**
@@ -612,8 +612,8 @@  discard block
 block discarded – undo
612 612
 	 * @param  string $context View or edit context.
613 613
 	 * @return string
614 614
 	 */
615
-	public function get_post_type( $context = 'view' ) {
616
-        return $this->get_prop( 'post_type', $context );
615
+	public function get_post_type($context = 'view') {
616
+        return $this->get_prop('post_type', $context);
617 617
     }
618 618
 
619 619
     /**
@@ -623,8 +623,8 @@  discard block
 block discarded – undo
623 623
 	 * @param  string $context View or edit context.
624 624
 	 * @return string
625 625
 	 */
626
-	public function get_mode( $context = 'view' ) {
627
-        return $this->get_prop( 'mode', $context );
626
+	public function get_mode($context = 'view') {
627
+        return $this->get_prop('mode', $context);
628 628
     }
629 629
 
630 630
     /**
@@ -634,13 +634,13 @@  discard block
 block discarded – undo
634 634
 	 * @param  string $context View or edit context.
635 635
 	 * @return string
636 636
 	 */
637
-	public function get_path( $context = 'view' ) {
638
-        $path   = $this->get_prop( 'path', $context );
639
-		$prefix = wpinv_post_name_prefix( $this->get_post_type() );
637
+	public function get_path($context = 'view') {
638
+        $path = $this->get_prop('path', $context);
639
+		$prefix = wpinv_post_name_prefix($this->get_post_type());
640 640
 
641
-		if ( 0 !== strpos( $path, $prefix ) ) {
642
-			$path = sanitize_title(  $prefix . $this->get_id()  );
643
-			$this->set_path( $path );
641
+		if (0 !== strpos($path, $prefix)) {
642
+			$path = sanitize_title($prefix . $this->get_id());
643
+			$this->set_path($path);
644 644
 		}
645 645
 
646 646
 		return $path;
@@ -653,8 +653,8 @@  discard block
 block discarded – undo
653 653
 	 * @param  string $context View or edit context.
654 654
 	 * @return string
655 655
 	 */
656
-	public function get_name( $context = 'view' ) {
657
-        return $this->get_prop( 'title', $context );
656
+	public function get_name($context = 'view') {
657
+        return $this->get_prop('title', $context);
658 658
     }
659 659
 
660 660
     /**
@@ -664,8 +664,8 @@  discard block
 block discarded – undo
664 664
 	 * @param  string $context View or edit context.
665 665
 	 * @return string
666 666
 	 */
667
-	public function get_title( $context = 'view' ) {
668
-		return $this->get_name( $context );
667
+	public function get_title($context = 'view') {
668
+		return $this->get_name($context);
669 669
     }
670 670
 
671 671
     /**
@@ -675,8 +675,8 @@  discard block
 block discarded – undo
675 675
 	 * @param  string $context View or edit context.
676 676
 	 * @return string
677 677
 	 */
678
-	public function get_description( $context = 'view' ) {
679
-		return $this->get_prop( 'description', $context );
678
+	public function get_description($context = 'view') {
679
+		return $this->get_prop('description', $context);
680 680
     }
681 681
 
682 682
     /**
@@ -686,8 +686,8 @@  discard block
 block discarded – undo
686 686
 	 * @param  string $context View or edit context.
687 687
 	 * @return string
688 688
 	 */
689
-	public function get_excerpt( $context = 'view' ) {
690
-		return $this->get_description( $context );
689
+	public function get_excerpt($context = 'view') {
690
+		return $this->get_description($context);
691 691
     }
692 692
 
693 693
     /**
@@ -697,8 +697,8 @@  discard block
 block discarded – undo
697 697
 	 * @param  string $context View or edit context.
698 698
 	 * @return string
699 699
 	 */
700
-	public function get_summary( $context = 'view' ) {
701
-		return $this->get_description( $context );
700
+	public function get_summary($context = 'view') {
701
+		return $this->get_description($context);
702 702
     }
703 703
 
704 704
     /**
@@ -708,25 +708,25 @@  discard block
 block discarded – undo
708 708
      * @param  string $context View or edit context.
709 709
 	 * @return array
710 710
 	 */
711
-    public function get_user_info( $context = 'view' ) {
711
+    public function get_user_info($context = 'view') {
712 712
 
713 713
         $user_info = array(
714
-            'user_id'    => $this->get_user_id( $context ),
715
-            'email'      => $this->get_email( $context ),
716
-            'first_name' => $this->get_first_name( $context ),
717
-            'last_name'  => $this->get_last_name( $context ),
718
-            'address'    => $this->get_address( $context ),
719
-            'phone'      => $this->get_phone( $context ),
720
-            'city'       => $this->get_city( $context ),
721
-            'country'    => $this->get_country( $context ),
722
-            'state'      => $this->get_state( $context ),
723
-            'zip'        => $this->get_zip( $context ),
724
-            'company'    => $this->get_company( $context ),
725
-            'vat_number' => $this->get_vat_number( $context ),
726
-            'discount'   => $this->get_discount_code( $context ),
714
+            'user_id'    => $this->get_user_id($context),
715
+            'email'      => $this->get_email($context),
716
+            'first_name' => $this->get_first_name($context),
717
+            'last_name'  => $this->get_last_name($context),
718
+            'address'    => $this->get_address($context),
719
+            'phone'      => $this->get_phone($context),
720
+            'city'       => $this->get_city($context),
721
+            'country'    => $this->get_country($context),
722
+            'state'      => $this->get_state($context),
723
+            'zip'        => $this->get_zip($context),
724
+            'company'    => $this->get_company($context),
725
+            'vat_number' => $this->get_vat_number($context),
726
+            'discount'   => $this->get_discount_code($context),
727 727
 		);
728 728
 
729
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
729
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
730 730
 
731 731
     }
732 732
 
@@ -737,8 +737,8 @@  discard block
 block discarded – undo
737 737
 	 * @param  string $context View or edit context.
738 738
 	 * @return int
739 739
 	 */
740
-	public function get_author( $context = 'view' ) {
741
-		return (int) $this->get_prop( 'author', $context );
740
+	public function get_author($context = 'view') {
741
+		return (int) $this->get_prop('author', $context);
742 742
     }
743 743
 
744 744
     /**
@@ -748,8 +748,8 @@  discard block
 block discarded – undo
748 748
 	 * @param  string $context View or edit context.
749 749
 	 * @return int
750 750
 	 */
751
-	public function get_user_id( $context = 'view' ) {
752
-		return $this->get_author( $context );
751
+	public function get_user_id($context = 'view') {
752
+		return $this->get_author($context);
753 753
     }
754 754
 
755 755
      /**
@@ -759,8 +759,8 @@  discard block
 block discarded – undo
759 759
 	 * @param  string $context View or edit context.
760 760
 	 * @return int
761 761
 	 */
762
-	public function get_customer_id( $context = 'view' ) {
763
-		return $this->get_author( $context );
762
+	public function get_customer_id($context = 'view') {
763
+		return $this->get_author($context);
764 764
     }
765 765
 
766 766
     /**
@@ -770,8 +770,8 @@  discard block
 block discarded – undo
770 770
 	 * @param  string $context View or edit context.
771 771
 	 * @return string
772 772
 	 */
773
-	public function get_ip( $context = 'view' ) {
774
-		return $this->get_prop( 'user_ip', $context );
773
+	public function get_ip($context = 'view') {
774
+		return $this->get_prop('user_ip', $context);
775 775
     }
776 776
 
777 777
     /**
@@ -781,8 +781,8 @@  discard block
 block discarded – undo
781 781
 	 * @param  string $context View or edit context.
782 782
 	 * @return string
783 783
 	 */
784
-	public function get_user_ip( $context = 'view' ) {
785
-		return $this->get_ip( $context );
784
+	public function get_user_ip($context = 'view') {
785
+		return $this->get_ip($context);
786 786
     }
787 787
 
788 788
      /**
@@ -792,8 +792,8 @@  discard block
 block discarded – undo
792 792
 	 * @param  string $context View or edit context.
793 793
 	 * @return string
794 794
 	 */
795
-	public function get_customer_ip( $context = 'view' ) {
796
-		return $this->get_ip( $context );
795
+	public function get_customer_ip($context = 'view') {
796
+		return $this->get_ip($context);
797 797
     }
798 798
 
799 799
     /**
@@ -803,8 +803,8 @@  discard block
 block discarded – undo
803 803
 	 * @param  string $context View or edit context.
804 804
 	 * @return string
805 805
 	 */
806
-	public function get_first_name( $context = 'view' ) {
807
-		return $this->get_prop( 'first_name', $context );
806
+	public function get_first_name($context = 'view') {
807
+		return $this->get_prop('first_name', $context);
808 808
     }
809 809
 
810 810
     /**
@@ -814,8 +814,8 @@  discard block
 block discarded – undo
814 814
 	 * @param  string $context View or edit context.
815 815
 	 * @return int
816 816
 	 */
817
-	public function get_user_first_name( $context = 'view' ) {
818
-		return $this->get_first_name( $context );
817
+	public function get_user_first_name($context = 'view') {
818
+		return $this->get_first_name($context);
819 819
     }
820 820
 
821 821
      /**
@@ -825,8 +825,8 @@  discard block
 block discarded – undo
825 825
 	 * @param  string $context View or edit context.
826 826
 	 * @return int
827 827
 	 */
828
-	public function get_customer_first_name( $context = 'view' ) {
829
-		return $this->get_first_name( $context );
828
+	public function get_customer_first_name($context = 'view') {
829
+		return $this->get_first_name($context);
830 830
     }
831 831
 
832 832
     /**
@@ -836,8 +836,8 @@  discard block
 block discarded – undo
836 836
 	 * @param  string $context View or edit context.
837 837
 	 * @return string
838 838
 	 */
839
-	public function get_last_name( $context = 'view' ) {
840
-		return $this->get_prop( 'last_name', $context );
839
+	public function get_last_name($context = 'view') {
840
+		return $this->get_prop('last_name', $context);
841 841
     }
842 842
 
843 843
     /**
@@ -847,8 +847,8 @@  discard block
 block discarded – undo
847 847
 	 * @param  string $context View or edit context.
848 848
 	 * @return int
849 849
 	 */
850
-	public function get_user_last_name( $context = 'view' ) {
851
-		return $this->get_last_name( $context );
850
+	public function get_user_last_name($context = 'view') {
851
+		return $this->get_last_name($context);
852 852
     }
853 853
 
854 854
     /**
@@ -858,8 +858,8 @@  discard block
 block discarded – undo
858 858
 	 * @param  string $context View or edit context.
859 859
 	 * @return int
860 860
 	 */
861
-	public function get_customer_last_name( $context = 'view' ) {
862
-		return $this->get_last_name( $context );
861
+	public function get_customer_last_name($context = 'view') {
862
+		return $this->get_last_name($context);
863 863
     }
864 864
 
865 865
     /**
@@ -869,8 +869,8 @@  discard block
 block discarded – undo
869 869
 	 * @param  string $context View or edit context.
870 870
 	 * @return string
871 871
 	 */
872
-	public function get_full_name( $context = 'view' ) {
873
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
872
+	public function get_full_name($context = 'view') {
873
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
874 874
     }
875 875
 
876 876
     /**
@@ -880,8 +880,8 @@  discard block
 block discarded – undo
880 880
 	 * @param  string $context View or edit context.
881 881
 	 * @return int
882 882
 	 */
883
-	public function get_user_full_name( $context = 'view' ) {
884
-		return $this->get_full_name( $context );
883
+	public function get_user_full_name($context = 'view') {
884
+		return $this->get_full_name($context);
885 885
     }
886 886
 
887 887
     /**
@@ -891,8 +891,8 @@  discard block
 block discarded – undo
891 891
 	 * @param  string $context View or edit context.
892 892
 	 * @return int
893 893
 	 */
894
-	public function get_customer_full_name( $context = 'view' ) {
895
-		return $this->get_full_name( $context );
894
+	public function get_customer_full_name($context = 'view') {
895
+		return $this->get_full_name($context);
896 896
     }
897 897
 
898 898
     /**
@@ -902,8 +902,8 @@  discard block
 block discarded – undo
902 902
 	 * @param  string $context View or edit context.
903 903
 	 * @return string
904 904
 	 */
905
-	public function get_phone( $context = 'view' ) {
906
-		return $this->get_prop( 'phone', $context );
905
+	public function get_phone($context = 'view') {
906
+		return $this->get_prop('phone', $context);
907 907
     }
908 908
 
909 909
     /**
@@ -913,8 +913,8 @@  discard block
 block discarded – undo
913 913
 	 * @param  string $context View or edit context.
914 914
 	 * @return int
915 915
 	 */
916
-	public function get_phone_number( $context = 'view' ) {
917
-		return $this->get_phone( $context );
916
+	public function get_phone_number($context = 'view') {
917
+		return $this->get_phone($context);
918 918
     }
919 919
 
920 920
     /**
@@ -924,8 +924,8 @@  discard block
 block discarded – undo
924 924
 	 * @param  string $context View or edit context.
925 925
 	 * @return int
926 926
 	 */
927
-	public function get_user_phone( $context = 'view' ) {
928
-		return $this->get_phone( $context );
927
+	public function get_user_phone($context = 'view') {
928
+		return $this->get_phone($context);
929 929
     }
930 930
 
931 931
     /**
@@ -935,8 +935,8 @@  discard block
 block discarded – undo
935 935
 	 * @param  string $context View or edit context.
936 936
 	 * @return int
937 937
 	 */
938
-	public function get_customer_phone( $context = 'view' ) {
939
-		return $this->get_phone( $context );
938
+	public function get_customer_phone($context = 'view') {
939
+		return $this->get_phone($context);
940 940
     }
941 941
 
942 942
     /**
@@ -946,8 +946,8 @@  discard block
 block discarded – undo
946 946
 	 * @param  string $context View or edit context.
947 947
 	 * @return string
948 948
 	 */
949
-	public function get_email( $context = 'view' ) {
950
-		return $this->get_prop( 'email', $context );
949
+	public function get_email($context = 'view') {
950
+		return $this->get_prop('email', $context);
951 951
     }
952 952
 
953 953
     /**
@@ -957,8 +957,8 @@  discard block
 block discarded – undo
957 957
 	 * @param  string $context View or edit context.
958 958
 	 * @return string
959 959
 	 */
960
-	public function get_email_address( $context = 'view' ) {
961
-		return $this->get_email( $context );
960
+	public function get_email_address($context = 'view') {
961
+		return $this->get_email($context);
962 962
     }
963 963
 
964 964
     /**
@@ -968,8 +968,8 @@  discard block
 block discarded – undo
968 968
 	 * @param  string $context View or edit context.
969 969
 	 * @return int
970 970
 	 */
971
-	public function get_user_email( $context = 'view' ) {
972
-		return $this->get_email( $context );
971
+	public function get_user_email($context = 'view') {
972
+		return $this->get_email($context);
973 973
     }
974 974
 
975 975
     /**
@@ -979,8 +979,8 @@  discard block
 block discarded – undo
979 979
 	 * @param  string $context View or edit context.
980 980
 	 * @return int
981 981
 	 */
982
-	public function get_customer_email( $context = 'view' ) {
983
-		return $this->get_email( $context );
982
+	public function get_customer_email($context = 'view') {
983
+		return $this->get_email($context);
984 984
     }
985 985
 
986 986
     /**
@@ -990,9 +990,9 @@  discard block
 block discarded – undo
990 990
 	 * @param  string $context View or edit context.
991 991
 	 * @return string
992 992
 	 */
993
-	public function get_country( $context = 'view' ) {
994
-		$country = $this->get_prop( 'country', $context );
995
-		return empty( $country ) ? wpinv_get_default_country() : $country;
993
+	public function get_country($context = 'view') {
994
+		$country = $this->get_prop('country', $context);
995
+		return empty($country) ? wpinv_get_default_country() : $country;
996 996
     }
997 997
 
998 998
     /**
@@ -1002,8 +1002,8 @@  discard block
 block discarded – undo
1002 1002
 	 * @param  string $context View or edit context.
1003 1003
 	 * @return int
1004 1004
 	 */
1005
-	public function get_user_country( $context = 'view' ) {
1006
-		return $this->get_country( $context );
1005
+	public function get_user_country($context = 'view') {
1006
+		return $this->get_country($context);
1007 1007
     }
1008 1008
 
1009 1009
     /**
@@ -1013,8 +1013,8 @@  discard block
 block discarded – undo
1013 1013
 	 * @param  string $context View or edit context.
1014 1014
 	 * @return int
1015 1015
 	 */
1016
-	public function get_customer_country( $context = 'view' ) {
1017
-		return $this->get_country( $context );
1016
+	public function get_customer_country($context = 'view') {
1017
+		return $this->get_country($context);
1018 1018
     }
1019 1019
 
1020 1020
     /**
@@ -1024,9 +1024,9 @@  discard block
 block discarded – undo
1024 1024
 	 * @param  string $context View or edit context.
1025 1025
 	 * @return string
1026 1026
 	 */
1027
-	public function get_state( $context = 'view' ) {
1028
-		$state = $this->get_prop( 'state', $context );
1029
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1027
+	public function get_state($context = 'view') {
1028
+		$state = $this->get_prop('state', $context);
1029
+		return empty($state) ? wpinv_get_default_state() : $state;
1030 1030
     }
1031 1031
 
1032 1032
     /**
@@ -1036,8 +1036,8 @@  discard block
 block discarded – undo
1036 1036
 	 * @param  string $context View or edit context.
1037 1037
 	 * @return int
1038 1038
 	 */
1039
-	public function get_user_state( $context = 'view' ) {
1040
-		return $this->get_state( $context );
1039
+	public function get_user_state($context = 'view') {
1040
+		return $this->get_state($context);
1041 1041
     }
1042 1042
 
1043 1043
     /**
@@ -1047,8 +1047,8 @@  discard block
 block discarded – undo
1047 1047
 	 * @param  string $context View or edit context.
1048 1048
 	 * @return int
1049 1049
 	 */
1050
-	public function get_customer_state( $context = 'view' ) {
1051
-		return $this->get_state( $context );
1050
+	public function get_customer_state($context = 'view') {
1051
+		return $this->get_state($context);
1052 1052
     }
1053 1053
 
1054 1054
     /**
@@ -1058,8 +1058,8 @@  discard block
 block discarded – undo
1058 1058
 	 * @param  string $context View or edit context.
1059 1059
 	 * @return string
1060 1060
 	 */
1061
-	public function get_city( $context = 'view' ) {
1062
-		return $this->get_prop( 'city', $context );
1061
+	public function get_city($context = 'view') {
1062
+		return $this->get_prop('city', $context);
1063 1063
     }
1064 1064
 
1065 1065
     /**
@@ -1069,8 +1069,8 @@  discard block
 block discarded – undo
1069 1069
 	 * @param  string $context View or edit context.
1070 1070
 	 * @return string
1071 1071
 	 */
1072
-	public function get_user_city( $context = 'view' ) {
1073
-		return $this->get_city( $context );
1072
+	public function get_user_city($context = 'view') {
1073
+		return $this->get_city($context);
1074 1074
     }
1075 1075
 
1076 1076
     /**
@@ -1080,8 +1080,8 @@  discard block
 block discarded – undo
1080 1080
 	 * @param  string $context View or edit context.
1081 1081
 	 * @return string
1082 1082
 	 */
1083
-	public function get_customer_city( $context = 'view' ) {
1084
-		return $this->get_city( $context );
1083
+	public function get_customer_city($context = 'view') {
1084
+		return $this->get_city($context);
1085 1085
     }
1086 1086
 
1087 1087
     /**
@@ -1091,8 +1091,8 @@  discard block
 block discarded – undo
1091 1091
 	 * @param  string $context View or edit context.
1092 1092
 	 * @return string
1093 1093
 	 */
1094
-	public function get_zip( $context = 'view' ) {
1095
-		return $this->get_prop( 'zip', $context );
1094
+	public function get_zip($context = 'view') {
1095
+		return $this->get_prop('zip', $context);
1096 1096
     }
1097 1097
 
1098 1098
     /**
@@ -1102,8 +1102,8 @@  discard block
 block discarded – undo
1102 1102
 	 * @param  string $context View or edit context.
1103 1103
 	 * @return string
1104 1104
 	 */
1105
-	public function get_user_zip( $context = 'view' ) {
1106
-		return $this->get_zip( $context );
1105
+	public function get_user_zip($context = 'view') {
1106
+		return $this->get_zip($context);
1107 1107
     }
1108 1108
 
1109 1109
     /**
@@ -1113,8 +1113,8 @@  discard block
 block discarded – undo
1113 1113
 	 * @param  string $context View or edit context.
1114 1114
 	 * @return string
1115 1115
 	 */
1116
-	public function get_customer_zip( $context = 'view' ) {
1117
-		return $this->get_zip( $context );
1116
+	public function get_customer_zip($context = 'view') {
1117
+		return $this->get_zip($context);
1118 1118
     }
1119 1119
 
1120 1120
     /**
@@ -1124,8 +1124,8 @@  discard block
 block discarded – undo
1124 1124
 	 * @param  string $context View or edit context.
1125 1125
 	 * @return string
1126 1126
 	 */
1127
-	public function get_company( $context = 'view' ) {
1128
-		return $this->get_prop( 'company', $context );
1127
+	public function get_company($context = 'view') {
1128
+		return $this->get_prop('company', $context);
1129 1129
     }
1130 1130
 
1131 1131
     /**
@@ -1135,8 +1135,8 @@  discard block
 block discarded – undo
1135 1135
 	 * @param  string $context View or edit context.
1136 1136
 	 * @return string
1137 1137
 	 */
1138
-	public function get_user_company( $context = 'view' ) {
1139
-		return $this->get_company( $context );
1138
+	public function get_user_company($context = 'view') {
1139
+		return $this->get_company($context);
1140 1140
     }
1141 1141
 
1142 1142
     /**
@@ -1146,8 +1146,8 @@  discard block
 block discarded – undo
1146 1146
 	 * @param  string $context View or edit context.
1147 1147
 	 * @return string
1148 1148
 	 */
1149
-	public function get_customer_company( $context = 'view' ) {
1150
-		return $this->get_company( $context );
1149
+	public function get_customer_company($context = 'view') {
1150
+		return $this->get_company($context);
1151 1151
     }
1152 1152
 
1153 1153
     /**
@@ -1157,8 +1157,8 @@  discard block
 block discarded – undo
1157 1157
 	 * @param  string $context View or edit context.
1158 1158
 	 * @return string
1159 1159
 	 */
1160
-	public function get_vat_number( $context = 'view' ) {
1161
-		return $this->get_prop( 'vat_number', $context );
1160
+	public function get_vat_number($context = 'view') {
1161
+		return $this->get_prop('vat_number', $context);
1162 1162
     }
1163 1163
 
1164 1164
     /**
@@ -1168,8 +1168,8 @@  discard block
 block discarded – undo
1168 1168
 	 * @param  string $context View or edit context.
1169 1169
 	 * @return string
1170 1170
 	 */
1171
-	public function get_user_vat_number( $context = 'view' ) {
1172
-		return $this->get_vat_number( $context );
1171
+	public function get_user_vat_number($context = 'view') {
1172
+		return $this->get_vat_number($context);
1173 1173
     }
1174 1174
 
1175 1175
     /**
@@ -1179,8 +1179,8 @@  discard block
 block discarded – undo
1179 1179
 	 * @param  string $context View or edit context.
1180 1180
 	 * @return string
1181 1181
 	 */
1182
-	public function get_customer_vat_number( $context = 'view' ) {
1183
-		return $this->get_vat_number( $context );
1182
+	public function get_customer_vat_number($context = 'view') {
1183
+		return $this->get_vat_number($context);
1184 1184
     }
1185 1185
 
1186 1186
     /**
@@ -1190,8 +1190,8 @@  discard block
 block discarded – undo
1190 1190
 	 * @param  string $context View or edit context.
1191 1191
 	 * @return string
1192 1192
 	 */
1193
-	public function get_vat_rate( $context = 'view' ) {
1194
-		return $this->get_prop( 'vat_rate', $context );
1193
+	public function get_vat_rate($context = 'view') {
1194
+		return $this->get_prop('vat_rate', $context);
1195 1195
     }
1196 1196
 
1197 1197
     /**
@@ -1201,8 +1201,8 @@  discard block
 block discarded – undo
1201 1201
 	 * @param  string $context View or edit context.
1202 1202
 	 * @return string
1203 1203
 	 */
1204
-	public function get_user_vat_rate( $context = 'view' ) {
1205
-		return $this->get_vat_rate( $context );
1204
+	public function get_user_vat_rate($context = 'view') {
1205
+		return $this->get_vat_rate($context);
1206 1206
     }
1207 1207
 
1208 1208
     /**
@@ -1212,8 +1212,8 @@  discard block
 block discarded – undo
1212 1212
 	 * @param  string $context View or edit context.
1213 1213
 	 * @return string
1214 1214
 	 */
1215
-	public function get_customer_vat_rate( $context = 'view' ) {
1216
-		return $this->get_vat_rate( $context );
1215
+	public function get_customer_vat_rate($context = 'view') {
1216
+		return $this->get_vat_rate($context);
1217 1217
     }
1218 1218
 
1219 1219
     /**
@@ -1223,8 +1223,8 @@  discard block
 block discarded – undo
1223 1223
 	 * @param  string $context View or edit context.
1224 1224
 	 * @return string
1225 1225
 	 */
1226
-	public function get_address( $context = 'view' ) {
1227
-		return $this->get_prop( 'address', $context );
1226
+	public function get_address($context = 'view') {
1227
+		return $this->get_prop('address', $context);
1228 1228
     }
1229 1229
 
1230 1230
     /**
@@ -1234,8 +1234,8 @@  discard block
 block discarded – undo
1234 1234
 	 * @param  string $context View or edit context.
1235 1235
 	 * @return string
1236 1236
 	 */
1237
-	public function get_user_address( $context = 'view' ) {
1238
-		return $this->get_address( $context );
1237
+	public function get_user_address($context = 'view') {
1238
+		return $this->get_address($context);
1239 1239
     }
1240 1240
 
1241 1241
     /**
@@ -1245,8 +1245,8 @@  discard block
 block discarded – undo
1245 1245
 	 * @param  string $context View or edit context.
1246 1246
 	 * @return string
1247 1247
 	 */
1248
-	public function get_customer_address( $context = 'view' ) {
1249
-		return $this->get_address( $context );
1248
+	public function get_customer_address($context = 'view') {
1249
+		return $this->get_address($context);
1250 1250
     }
1251 1251
 
1252 1252
     /**
@@ -1256,8 +1256,8 @@  discard block
 block discarded – undo
1256 1256
 	 * @param  string $context View or edit context.
1257 1257
 	 * @return bool
1258 1258
 	 */
1259
-	public function get_is_viewed( $context = 'view' ) {
1260
-		return (bool) $this->get_prop( 'is_viewed', $context );
1259
+	public function get_is_viewed($context = 'view') {
1260
+		return (bool) $this->get_prop('is_viewed', $context);
1261 1261
 	}
1262 1262
 
1263 1263
 	/**
@@ -1267,8 +1267,8 @@  discard block
 block discarded – undo
1267 1267
 	 * @param  string $context View or edit context.
1268 1268
 	 * @return bool
1269 1269
 	 */
1270
-	public function get_email_cc( $context = 'view' ) {
1271
-		return $this->get_prop( 'email_cc', $context );
1270
+	public function get_email_cc($context = 'view') {
1271
+		return $this->get_prop('email_cc', $context);
1272 1272
 	}
1273 1273
 
1274 1274
 	/**
@@ -1278,8 +1278,8 @@  discard block
 block discarded – undo
1278 1278
 	 * @param  string $context View or edit context.
1279 1279
 	 * @return bool
1280 1280
 	 */
1281
-	public function get_template( $context = 'view' ) {
1282
-		return $this->get_prop( 'template', $context );
1281
+	public function get_template($context = 'view') {
1282
+		return $this->get_prop('template', $context);
1283 1283
 	}
1284 1284
 
1285 1285
 	/**
@@ -1289,8 +1289,8 @@  discard block
 block discarded – undo
1289 1289
 	 * @param  string $context View or edit context.
1290 1290
 	 * @return bool
1291 1291
 	 */
1292
-	public function get_address_confirmed( $context = 'view' ) {
1293
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1292
+	public function get_address_confirmed($context = 'view') {
1293
+		return (bool) $this->get_prop('address_confirmed', $context);
1294 1294
     }
1295 1295
 
1296 1296
     /**
@@ -1300,8 +1300,8 @@  discard block
 block discarded – undo
1300 1300
 	 * @param  string $context View or edit context.
1301 1301
 	 * @return bool
1302 1302
 	 */
1303
-	public function get_user_address_confirmed( $context = 'view' ) {
1304
-		return $this->get_address_confirmed( $context );
1303
+	public function get_user_address_confirmed($context = 'view') {
1304
+		return $this->get_address_confirmed($context);
1305 1305
     }
1306 1306
 
1307 1307
     /**
@@ -1311,8 +1311,8 @@  discard block
 block discarded – undo
1311 1311
 	 * @param  string $context View or edit context.
1312 1312
 	 * @return bool
1313 1313
 	 */
1314
-	public function get_customer_address_confirmed( $context = 'view' ) {
1315
-		return $this->get_address_confirmed( $context );
1314
+	public function get_customer_address_confirmed($context = 'view') {
1315
+		return $this->get_address_confirmed($context);
1316 1316
     }
1317 1317
 
1318 1318
     /**
@@ -1322,12 +1322,12 @@  discard block
 block discarded – undo
1322 1322
 	 * @param  string $context View or edit context.
1323 1323
 	 * @return float
1324 1324
 	 */
1325
-	public function get_subtotal( $context = 'view' ) {
1326
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1325
+	public function get_subtotal($context = 'view') {
1326
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1327 1327
 
1328 1328
         // Backwards compatibility.
1329
-        if ( is_bool( $context ) && $context ) {
1330
-            return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() );
1329
+        if (is_bool($context) && $context) {
1330
+            return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency());
1331 1331
         }
1332 1332
 
1333 1333
         return $subtotal;
@@ -1340,8 +1340,8 @@  discard block
 block discarded – undo
1340 1340
 	 * @param  string $context View or edit context.
1341 1341
 	 * @return float
1342 1342
 	 */
1343
-	public function get_total_discount( $context = 'view' ) {
1344
-		return (float) $this->get_prop( 'total_discount', $context );
1343
+	public function get_total_discount($context = 'view') {
1344
+		return (float) $this->get_prop('total_discount', $context);
1345 1345
     }
1346 1346
 
1347 1347
     /**
@@ -1351,18 +1351,18 @@  discard block
 block discarded – undo
1351 1351
 	 * @param  string $context View or edit context.
1352 1352
 	 * @return float
1353 1353
 	 */
1354
-	public function get_total_tax( $context = 'view' ) {
1355
-		return (float) $this->get_prop( 'total_tax', $context );
1354
+	public function get_total_tax($context = 'view') {
1355
+		return (float) $this->get_prop('total_tax', $context);
1356 1356
 	}
1357 1357
 
1358 1358
 	/**
1359 1359
 	 * @deprecated
1360 1360
 	 */
1361
-	public function get_final_tax( $currency = false ) {
1361
+	public function get_final_tax($currency = false) {
1362 1362
 		$tax = $this->get_total_tax();
1363 1363
 
1364
-        if ( $currency ) {
1365
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1364
+        if ($currency) {
1365
+			return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency());
1366 1366
         }
1367 1367
 
1368 1368
         return $tax;
@@ -1375,8 +1375,8 @@  discard block
 block discarded – undo
1375 1375
 	 * @param  string $context View or edit context.
1376 1376
 	 * @return float
1377 1377
 	 */
1378
-	public function get_total_fees( $context = 'view' ) {
1379
-		return (float) $this->get_prop( 'total_fees', $context );
1378
+	public function get_total_fees($context = 'view') {
1379
+		return (float) $this->get_prop('total_fees', $context);
1380 1380
     }
1381 1381
 
1382 1382
     /**
@@ -1386,8 +1386,8 @@  discard block
 block discarded – undo
1386 1386
 	 * @param  string $context View or edit context.
1387 1387
 	 * @return float
1388 1388
 	 */
1389
-	public function get_fees_total( $context = 'view' ) {
1390
-		return $this->get_total_fees( $context );
1389
+	public function get_fees_total($context = 'view') {
1390
+		return $this->get_total_fees($context);
1391 1391
     }
1392 1392
 
1393 1393
     /**
@@ -1398,7 +1398,7 @@  discard block
 block discarded – undo
1398 1398
 	 */
1399 1399
 	public function get_total() {
1400 1400
 		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1401
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1401
+		return apply_filters('getpaid_get_invoice_total_amount', $total, $this);
1402 1402
 	}
1403 1403
 	
1404 1404
 	/**
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
 	 */
1421 1421
     public function get_initial_total() {
1422 1422
 
1423
-		if ( empty( $this->totals ) ) {
1423
+		if (empty($this->totals)) {
1424 1424
 			$this->recalculate_total();
1425 1425
 		}
1426 1426
 
@@ -1430,11 +1430,11 @@  discard block
 block discarded – undo
1430 1430
 		$subtotal = $this->totals['subtotal']['initial'];
1431 1431
 		$total    = $tax + $fee - $discount + $subtotal;
1432 1432
 
1433
-		if ( 0 > $total ) {
1433
+		if (0 > $total) {
1434 1434
 			$total = 0;
1435 1435
 		}
1436 1436
 
1437
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1437
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1438 1438
 	}
1439 1439
 
1440 1440
 	/**
@@ -1446,7 +1446,7 @@  discard block
 block discarded – undo
1446 1446
 	 */
1447 1447
     public function get_recurring_total() {
1448 1448
 
1449
-		if ( empty( $this->totals ) ) {
1449
+		if (empty($this->totals)) {
1450 1450
 			$this->recalculate_total();
1451 1451
 		}
1452 1452
 
@@ -1456,11 +1456,11 @@  discard block
 block discarded – undo
1456 1456
 		$subtotal = $this->totals['subtotal']['recurring'];
1457 1457
 		$total    = $tax + $fee - $discount + $subtotal;
1458 1458
 
1459
-		if ( 0 > $total ) {
1459
+		if (0 > $total) {
1460 1460
 			$total = 0;
1461 1461
 		}
1462 1462
 
1463
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1463
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1464 1464
 	}
1465 1465
 
1466 1466
 	/**
@@ -1471,10 +1471,10 @@  discard block
 block discarded – undo
1471 1471
 	 * @param string $currency Whether to include the currency.
1472 1472
      * @return float
1473 1473
 	 */
1474
-    public function get_recurring_details( $field = '', $currency = false ) {
1474
+    public function get_recurring_details($field = '', $currency = false) {
1475 1475
 
1476 1476
 		// Maybe recalculate totals.
1477
-		if ( empty( $this->totals ) ) {
1477
+		if (empty($this->totals)) {
1478 1478
 			$this->recalculate_total();
1479 1479
 		}
1480 1480
 
@@ -1494,8 +1494,8 @@  discard block
 block discarded – undo
1494 1494
 			$currency
1495 1495
 		);
1496 1496
 
1497
-        if ( isset( $data[$field] ) ) {
1498
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1497
+        if (isset($data[$field])) {
1498
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1499 1499
         }
1500 1500
 
1501 1501
         return $data;
@@ -1508,8 +1508,8 @@  discard block
 block discarded – undo
1508 1508
 	 * @param  string $context View or edit context.
1509 1509
 	 * @return array
1510 1510
 	 */
1511
-	public function get_fees( $context = 'view' ) {
1512
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1511
+	public function get_fees($context = 'view') {
1512
+		return wpinv_parse_list($this->get_prop('fees', $context));
1513 1513
     }
1514 1514
 
1515 1515
     /**
@@ -1519,8 +1519,8 @@  discard block
 block discarded – undo
1519 1519
 	 * @param  string $context View or edit context.
1520 1520
 	 * @return array
1521 1521
 	 */
1522
-	public function get_discounts( $context = 'view' ) {
1523
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1522
+	public function get_discounts($context = 'view') {
1523
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1524 1524
     }
1525 1525
 
1526 1526
     /**
@@ -1530,8 +1530,8 @@  discard block
 block discarded – undo
1530 1530
 	 * @param  string $context View or edit context.
1531 1531
 	 * @return array
1532 1532
 	 */
1533
-	public function get_taxes( $context = 'view' ) {
1534
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1533
+	public function get_taxes($context = 'view') {
1534
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1535 1535
     }
1536 1536
 
1537 1537
     /**
@@ -1541,8 +1541,8 @@  discard block
 block discarded – undo
1541 1541
 	 * @param  string $context View or edit context.
1542 1542
 	 * @return GetPaid_Form_Item[]
1543 1543
 	 */
1544
-	public function get_items( $context = 'view' ) {
1545
-        return $this->get_prop( 'items', $context );
1544
+	public function get_items($context = 'view') {
1545
+        return $this->get_prop('items', $context);
1546 1546
     }
1547 1547
 
1548 1548
     /**
@@ -1552,8 +1552,8 @@  discard block
 block discarded – undo
1552 1552
 	 * @param  string $context View or edit context.
1553 1553
 	 * @return int
1554 1554
 	 */
1555
-	public function get_payment_form( $context = 'view' ) {
1556
-		return intval( $this->get_prop( 'payment_form', $context ) );
1555
+	public function get_payment_form($context = 'view') {
1556
+		return intval($this->get_prop('payment_form', $context));
1557 1557
     }
1558 1558
 
1559 1559
     /**
@@ -1563,8 +1563,8 @@  discard block
 block discarded – undo
1563 1563
 	 * @param  string $context View or edit context.
1564 1564
 	 * @return string
1565 1565
 	 */
1566
-	public function get_submission_id( $context = 'view' ) {
1567
-		return $this->get_prop( 'submission_id', $context );
1566
+	public function get_submission_id($context = 'view') {
1567
+		return $this->get_prop('submission_id', $context);
1568 1568
     }
1569 1569
 
1570 1570
     /**
@@ -1574,8 +1574,8 @@  discard block
 block discarded – undo
1574 1574
 	 * @param  string $context View or edit context.
1575 1575
 	 * @return string
1576 1576
 	 */
1577
-	public function get_discount_code( $context = 'view' ) {
1578
-		return $this->get_prop( 'discount_code', $context );
1577
+	public function get_discount_code($context = 'view') {
1578
+		return $this->get_prop('discount_code', $context);
1579 1579
     }
1580 1580
 
1581 1581
     /**
@@ -1585,8 +1585,8 @@  discard block
 block discarded – undo
1585 1585
 	 * @param  string $context View or edit context.
1586 1586
 	 * @return string
1587 1587
 	 */
1588
-	public function get_gateway( $context = 'view' ) {
1589
-		return $this->get_prop( 'gateway', $context );
1588
+	public function get_gateway($context = 'view') {
1589
+		return $this->get_prop('gateway', $context);
1590 1590
     }
1591 1591
 
1592 1592
     /**
@@ -1596,8 +1596,8 @@  discard block
 block discarded – undo
1596 1596
 	 * @return string
1597 1597
 	 */
1598 1598
     public function get_gateway_title() {
1599
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1600
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1599
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1600
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1601 1601
     }
1602 1602
 
1603 1603
     /**
@@ -1607,8 +1607,8 @@  discard block
 block discarded – undo
1607 1607
 	 * @param  string $context View or edit context.
1608 1608
 	 * @return string
1609 1609
 	 */
1610
-	public function get_transaction_id( $context = 'view' ) {
1611
-		return $this->get_prop( 'transaction_id', $context );
1610
+	public function get_transaction_id($context = 'view') {
1611
+		return $this->get_prop('transaction_id', $context);
1612 1612
     }
1613 1613
 
1614 1614
     /**
@@ -1618,9 +1618,9 @@  discard block
 block discarded – undo
1618 1618
 	 * @param  string $context View or edit context.
1619 1619
 	 * @return string
1620 1620
 	 */
1621
-	public function get_currency( $context = 'view' ) {
1622
-        $currency = $this->get_prop( 'currency', $context );
1623
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1621
+	public function get_currency($context = 'view') {
1622
+        $currency = $this->get_prop('currency', $context);
1623
+        return empty($currency) ? wpinv_get_currency() : $currency;
1624 1624
     }
1625 1625
 
1626 1626
     /**
@@ -1630,8 +1630,8 @@  discard block
 block discarded – undo
1630 1630
 	 * @param  string $context View or edit context.
1631 1631
 	 * @return bool
1632 1632
 	 */
1633
-	public function get_disable_taxes( $context = 'view' ) {
1634
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1633
+	public function get_disable_taxes($context = 'view') {
1634
+        return (bool) $this->get_prop('disable_taxes', $context);
1635 1635
     }
1636 1636
 
1637 1637
     /**
@@ -1641,8 +1641,8 @@  discard block
 block discarded – undo
1641 1641
 	 * @param  string $context View or edit context.
1642 1642
 	 * @return int
1643 1643
 	 */
1644
-    public function get_subscription_id( $context = 'view' ) {
1645
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1644
+    public function get_subscription_id($context = 'view') {
1645
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1646 1646
 	}
1647 1647
 
1648 1648
 	/**
@@ -1652,12 +1652,12 @@  discard block
 block discarded – undo
1652 1652
 	 * @param  string $context View or edit context.
1653 1653
 	 * @return int
1654 1654
 	 */
1655
-    public function get_remote_subscription_id( $context = 'view' ) {
1656
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1655
+    public function get_remote_subscription_id($context = 'view') {
1656
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1657 1657
 
1658
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1658
+        if (empty($subscription_id) && $this->is_renewal()) {
1659 1659
             $parent = $this->get_parent();
1660
-            return $parent->get_subscription_id( $context );
1660
+            return $parent->get_subscription_id($context);
1661 1661
         }
1662 1662
 
1663 1663
         return $subscription_id;
@@ -1670,20 +1670,20 @@  discard block
 block discarded – undo
1670 1670
 	 * @param  string $context View or edit context.
1671 1671
 	 * @return array
1672 1672
 	 */
1673
-    public function get_payment_meta( $context = 'view' ) {
1673
+    public function get_payment_meta($context = 'view') {
1674 1674
 
1675 1675
         return array(
1676
-            'price'        => $this->get_total( $context ),
1677
-            'date'         => $this->get_date_created( $context ),
1678
-            'user_email'   => $this->get_email( $context ),
1679
-            'invoice_key'  => $this->get_key( $context ),
1680
-            'currency'     => $this->get_currency( $context ),
1681
-            'items'        => $this->get_items( $context ),
1682
-            'user_info'    => $this->get_user_info( $context ),
1676
+            'price'        => $this->get_total($context),
1677
+            'date'         => $this->get_date_created($context),
1678
+            'user_email'   => $this->get_email($context),
1679
+            'invoice_key'  => $this->get_key($context),
1680
+            'currency'     => $this->get_currency($context),
1681
+            'items'        => $this->get_items($context),
1682
+            'user_info'    => $this->get_user_info($context),
1683 1683
             'cart_details' => $this->get_cart_details(),
1684
-            'status'       => $this->get_status( $context ),
1685
-            'fees'         => $this->get_fees( $context ),
1686
-            'taxes'        => $this->get_taxes( $context ),
1684
+            'status'       => $this->get_status($context),
1685
+            'fees'         => $this->get_fees($context),
1686
+            'taxes'        => $this->get_taxes($context),
1687 1687
         );
1688 1688
 
1689 1689
     }
@@ -1698,9 +1698,9 @@  discard block
 block discarded – undo
1698 1698
         $items        = $this->get_items();
1699 1699
         $cart_details = array();
1700 1700
 
1701
-        foreach ( $items as $item_id => $item ) {
1701
+        foreach ($items as $item_id => $item) {
1702 1702
 			$item->invoice_id = $this->get_id();
1703
-            $cart_details[]   = $item->prepare_data_for_saving();
1703
+            $cart_details[] = $item->prepare_data_for_saving();
1704 1704
         }
1705 1705
 
1706 1706
         return $cart_details;
@@ -1711,11 +1711,11 @@  discard block
 block discarded – undo
1711 1711
 	 *
1712 1712
 	 * @return null|GetPaid_Form_Item|int
1713 1713
 	 */
1714
-	public function get_recurring( $object = false ) {
1714
+	public function get_recurring($object = false) {
1715 1715
 
1716 1716
 		// Are we returning an object?
1717
-        if ( $object ) {
1718
-            return $this->get_item( $this->recurring_item );
1717
+        if ($object) {
1718
+            return $this->get_item($this->recurring_item);
1719 1719
         }
1720 1720
 
1721 1721
         return $this->recurring_item;
@@ -1730,15 +1730,15 @@  discard block
 block discarded – undo
1730 1730
 	public function get_subscription_name() {
1731 1731
 
1732 1732
 		// Retrieve the recurring name
1733
-        $item = $this->get_recurring( true );
1733
+        $item = $this->get_recurring(true);
1734 1734
 
1735 1735
 		// Abort if it does not exist.
1736
-        if ( empty( $item ) ) {
1736
+        if (empty($item)) {
1737 1737
             return '';
1738 1738
         }
1739 1739
 
1740 1740
 		// Return the item name.
1741
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1741
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1742 1742
 	}
1743 1743
 
1744 1744
 	/**
@@ -1748,9 +1748,9 @@  discard block
 block discarded – undo
1748 1748
 	 * @return string
1749 1749
 	 */
1750 1750
 	public function get_view_url() {
1751
-        $invoice_url = get_permalink( $this->get_id() );
1752
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1753
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1751
+        $invoice_url = get_permalink($this->get_id());
1752
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1753
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1754 1754
 	}
1755 1755
 
1756 1756
 	/**
@@ -1759,25 +1759,25 @@  discard block
 block discarded – undo
1759 1759
 	 * @since 1.0.19
1760 1760
 	 * @return string
1761 1761
 	 */
1762
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1762
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1763 1763
 
1764 1764
 		// Retrieve the checkout url.
1765 1765
         $pay_url = wpinv_get_checkout_uri();
1766 1766
 
1767 1767
 		// Maybe force ssl.
1768
-        if ( is_ssl() ) {
1769
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1768
+        if (is_ssl()) {
1769
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1770 1770
         }
1771 1771
 
1772 1772
 		// Add the invoice key.
1773
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1773
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1774 1774
 
1775 1775
 		// (Maybe?) add a secret
1776
-        if ( $secret ) {
1777
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1776
+        if ($secret) {
1777
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1778 1778
         }
1779 1779
 
1780
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1780
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1781 1781
 	}
1782 1782
 	
1783 1783
 	/**
@@ -1792,14 +1792,14 @@  discard block
 block discarded – undo
1792 1792
         $receipt_url = wpinv_get_success_page_uri();
1793 1793
 
1794 1794
 		// Maybe force ssl.
1795
-        if ( is_ssl() ) {
1796
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1795
+        if (is_ssl()) {
1796
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1797 1797
         }
1798 1798
 
1799 1799
 		// Add the invoice key.
1800
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1800
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1801 1801
 
1802
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1802
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1803 1803
     }
1804 1804
 
1805 1805
     /**
@@ -1812,8 +1812,8 @@  discard block
 block discarded – undo
1812 1812
 	 * @param  string $context View or edit context.
1813 1813
 	 * @return mixed Value of the given invoice property (if set).
1814 1814
 	 */
1815
-	public function get( $key, $context = 'view' ) {
1816
-        return $this->get_prop( $key, $context );
1815
+	public function get($key, $context = 'view') {
1816
+        return $this->get_prop($key, $context);
1817 1817
 	}
1818 1818
 
1819 1819
     /*
@@ -1836,11 +1836,11 @@  discard block
 block discarded – undo
1836 1836
 	 * @param  mixed $value new value.
1837 1837
 	 * @return mixed Value of the given invoice property (if set).
1838 1838
 	 */
1839
-	public function set( $key, $value ) {
1839
+	public function set($key, $value) {
1840 1840
 
1841 1841
         $setter = "set_$key";
1842
-        if ( is_callable( array( $this, $setter ) ) ) {
1843
-            $this->{$setter}( $value );
1842
+        if (is_callable(array($this, $setter))) {
1843
+            $this->{$setter}($value);
1844 1844
         }
1845 1845
 
1846 1846
 	}
@@ -1854,47 +1854,47 @@  discard block
 block discarded – undo
1854 1854
 	 * @param bool   $manual_update Is this a manual status change?.
1855 1855
 	 * @return array details of change.
1856 1856
 	 */
1857
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1857
+	public function set_status($new_status, $note = '', $manual_update = false) {
1858 1858
 		$old_status = $this->get_status();
1859 1859
 
1860 1860
 		$statuses = $this->get_all_statuses();
1861 1861
 
1862
-		if ( isset( $statuses[ 'draft' ] ) ) {
1863
-			unset( $statuses[ 'draft' ] );
1862
+		if (isset($statuses['draft'])) {
1863
+			unset($statuses['draft']);
1864 1864
 		}
1865 1865
 
1866
-		$this->set_prop( 'status', $new_status );
1866
+		$this->set_prop('status', $new_status);
1867 1867
 
1868 1868
 		// If setting the status, ensure it's set to a valid status.
1869
-		if ( true === $this->object_read ) {
1869
+		if (true === $this->object_read) {
1870 1870
 
1871 1871
 			// Only allow valid new status.
1872
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1872
+			if (!array_key_exists($new_status, $statuses)) {
1873 1873
 				$new_status = 'wpi-pending';
1874 1874
 			}
1875 1875
 
1876 1876
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1877
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1877
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
1878 1878
 				$old_status = 'wpi-pending';
1879 1879
 			}
1880 1880
 
1881 1881
 			// Paid - Renewal (i.e when duplicating a parent invoice )
1882
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1882
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
1883 1883
 				$old_status = 'wpi-pending';
1884 1884
 			}
1885 1885
 
1886 1886
 		}
1887 1887
 
1888
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1888
+		if (true === $this->object_read && $old_status !== $new_status) {
1889 1889
 			$this->status_transition = array(
1890
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1890
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
1891 1891
 				'to'     => $new_status,
1892 1892
 				'note'   => $note,
1893 1893
 				'manual' => (bool) $manual_update,
1894 1894
 			);
1895 1895
 
1896
-			if ( $manual_update ) {
1897
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1896
+			if ($manual_update) {
1897
+				do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
1898 1898
 			}
1899 1899
 
1900 1900
 			$this->maybe_set_date_paid();
@@ -1917,8 +1917,8 @@  discard block
 block discarded – undo
1917 1917
 	 */
1918 1918
 	public function maybe_set_date_paid() {
1919 1919
 
1920
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1921
-			$this->set_date_completed( current_time( 'mysql' ) );
1920
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
1921
+			$this->set_date_completed(current_time('mysql'));
1922 1922
 		}
1923 1923
 	}
1924 1924
 
@@ -1927,11 +1927,11 @@  discard block
 block discarded – undo
1927 1927
 	 *
1928 1928
 	 * @since 1.0.19
1929 1929
 	 */
1930
-	public function set_parent_id( $value ) {
1931
-		if ( $value && ( $value === $this->get_id() ) ) {
1930
+	public function set_parent_id($value) {
1931
+		if ($value && ($value === $this->get_id())) {
1932 1932
 			return;
1933 1933
 		}
1934
-		$this->set_prop( 'parent_id', absint( $value ) );
1934
+		$this->set_prop('parent_id', absint($value));
1935 1935
     }
1936 1936
 
1937 1937
     /**
@@ -1939,8 +1939,8 @@  discard block
 block discarded – undo
1939 1939
 	 *
1940 1940
 	 * @since 1.0.19
1941 1941
 	 */
1942
-	public function set_version( $value ) {
1943
-		$this->set_prop( 'version', $value );
1942
+	public function set_version($value) {
1943
+		$this->set_prop('version', $value);
1944 1944
     }
1945 1945
 
1946 1946
     /**
@@ -1950,15 +1950,15 @@  discard block
 block discarded – undo
1950 1950
 	 * @param string $value Value to set.
1951 1951
      * @return bool Whether or not the date was set.
1952 1952
 	 */
1953
-	public function set_date_created( $value ) {
1954
-        $date = strtotime( $value );
1953
+	public function set_date_created($value) {
1954
+        $date = strtotime($value);
1955 1955
 
1956
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1957
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
1956
+        if ($date && $value !== '0000-00-00 00:00:00') {
1957
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
1958 1958
             return true;
1959 1959
         }
1960 1960
 
1961
-        return $this->set_prop( 'date_created', '' );
1961
+        return $this->set_prop('date_created', '');
1962 1962
 
1963 1963
     }
1964 1964
 
@@ -1969,15 +1969,15 @@  discard block
 block discarded – undo
1969 1969
 	 * @param string $value Value to set.
1970 1970
      * @return bool Whether or not the date was set.
1971 1971
 	 */
1972
-	public function set_due_date( $value ) {
1973
-        $date = strtotime( $value );
1972
+	public function set_due_date($value) {
1973
+        $date = strtotime($value);
1974 1974
 
1975
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1976
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
1975
+        if ($date && $value !== '0000-00-00 00:00:00') {
1976
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
1977 1977
             return true;
1978 1978
         }
1979 1979
 
1980
-		$this->set_prop( 'due_date', '' );
1980
+		$this->set_prop('due_date', '');
1981 1981
         return false;
1982 1982
 
1983 1983
     }
@@ -1988,8 +1988,8 @@  discard block
 block discarded – undo
1988 1988
 	 * @since 1.0.19
1989 1989
 	 * @param  string $value New name.
1990 1990
 	 */
1991
-	public function set_date_due( $value ) {
1992
-		$this->set_due_date( $value );
1991
+	public function set_date_due($value) {
1992
+		$this->set_due_date($value);
1993 1993
     }
1994 1994
 
1995 1995
     /**
@@ -1999,15 +1999,15 @@  discard block
 block discarded – undo
1999 1999
 	 * @param string $value Value to set.
2000 2000
      * @return bool Whether or not the date was set.
2001 2001
 	 */
2002
-	public function set_completed_date( $value ) {
2003
-        $date = strtotime( $value );
2002
+	public function set_completed_date($value) {
2003
+        $date = strtotime($value);
2004 2004
 
2005
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
2006
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2005
+        if ($date && $value !== '0000-00-00 00:00:00') {
2006
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2007 2007
             return true;
2008 2008
         }
2009 2009
 
2010
-		$this->set_prop( 'completed_date', '' );
2010
+		$this->set_prop('completed_date', '');
2011 2011
         return false;
2012 2012
 
2013 2013
     }
@@ -2018,8 +2018,8 @@  discard block
 block discarded – undo
2018 2018
 	 * @since 1.0.19
2019 2019
 	 * @param  string $value New name.
2020 2020
 	 */
2021
-	public function set_date_completed( $value ) {
2022
-		$this->set_completed_date( $value );
2021
+	public function set_date_completed($value) {
2022
+		$this->set_completed_date($value);
2023 2023
     }
2024 2024
 
2025 2025
     /**
@@ -2029,15 +2029,15 @@  discard block
 block discarded – undo
2029 2029
 	 * @param string $value Value to set.
2030 2030
      * @return bool Whether or not the date was set.
2031 2031
 	 */
2032
-	public function set_date_modified( $value ) {
2033
-        $date = strtotime( $value );
2032
+	public function set_date_modified($value) {
2033
+        $date = strtotime($value);
2034 2034
 
2035
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2036
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2035
+        if ($date && $value !== '0000-00-00 00:00:00') {
2036
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2037 2037
             return true;
2038 2038
         }
2039 2039
 
2040
-		$this->set_prop( 'date_modified', '' );
2040
+		$this->set_prop('date_modified', '');
2041 2041
         return false;
2042 2042
 
2043 2043
     }
@@ -2048,9 +2048,9 @@  discard block
 block discarded – undo
2048 2048
 	 * @since 1.0.19
2049 2049
 	 * @param  string $value New number.
2050 2050
 	 */
2051
-	public function set_number( $value ) {
2052
-        $number = sanitize_text_field( $value );
2053
-		$this->set_prop( 'number', $number );
2051
+	public function set_number($value) {
2052
+        $number = sanitize_text_field($value);
2053
+		$this->set_prop('number', $number);
2054 2054
     }
2055 2055
 
2056 2056
     /**
@@ -2059,9 +2059,9 @@  discard block
 block discarded – undo
2059 2059
 	 * @since 1.0.19
2060 2060
 	 * @param  string $value Type.
2061 2061
 	 */
2062
-	public function set_type( $value ) {
2063
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2064
-		$this->set_prop( 'type', $type );
2062
+	public function set_type($value) {
2063
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2064
+		$this->set_prop('type', $type);
2065 2065
 	}
2066 2066
 
2067 2067
     /**
@@ -2070,10 +2070,10 @@  discard block
 block discarded – undo
2070 2070
 	 * @since 1.0.19
2071 2071
 	 * @param  string $value Post type.
2072 2072
 	 */
2073
-	public function set_post_type( $value ) {
2074
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2075
-			$this->set_type( $value );
2076
-            $this->set_prop( 'post_type', $value );
2073
+	public function set_post_type($value) {
2074
+        if (getpaid_is_invoice_post_type($value)) {
2075
+			$this->set_type($value);
2076
+            $this->set_prop('post_type', $value);
2077 2077
         }
2078 2078
     }
2079 2079
 
@@ -2083,9 +2083,9 @@  discard block
 block discarded – undo
2083 2083
 	 * @since 1.0.19
2084 2084
 	 * @param  string $value New key.
2085 2085
 	 */
2086
-	public function set_key( $value ) {
2087
-        $key = sanitize_text_field( $value );
2088
-		$this->set_prop( 'key', $key );
2086
+	public function set_key($value) {
2087
+        $key = sanitize_text_field($value);
2088
+		$this->set_prop('key', $key);
2089 2089
     }
2090 2090
 
2091 2091
     /**
@@ -2094,9 +2094,9 @@  discard block
 block discarded – undo
2094 2094
 	 * @since 1.0.19
2095 2095
 	 * @param  string $value mode.
2096 2096
 	 */
2097
-	public function set_mode( $value ) {
2098
-        if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2099
-            $this->set_prop( 'value', $value );
2097
+	public function set_mode($value) {
2098
+        if (!in_array($value, array('live', 'test'))) {
2099
+            $this->set_prop('value', $value);
2100 2100
         }
2101 2101
     }
2102 2102
 
@@ -2106,8 +2106,8 @@  discard block
 block discarded – undo
2106 2106
 	 * @since 1.0.19
2107 2107
 	 * @param  string $value path.
2108 2108
 	 */
2109
-	public function set_path( $value ) {
2110
-        $this->set_prop( 'path', $value );
2109
+	public function set_path($value) {
2110
+        $this->set_prop('path', $value);
2111 2111
     }
2112 2112
 
2113 2113
     /**
@@ -2116,9 +2116,9 @@  discard block
 block discarded – undo
2116 2116
 	 * @since 1.0.19
2117 2117
 	 * @param  string $value New name.
2118 2118
 	 */
2119
-	public function set_name( $value ) {
2120
-        $name = sanitize_text_field( $value );
2121
-		$this->set_prop( 'name', $name );
2119
+	public function set_name($value) {
2120
+        $name = sanitize_text_field($value);
2121
+		$this->set_prop('name', $name);
2122 2122
     }
2123 2123
 
2124 2124
     /**
@@ -2127,8 +2127,8 @@  discard block
 block discarded – undo
2127 2127
 	 * @since 1.0.19
2128 2128
 	 * @param  string $value New name.
2129 2129
 	 */
2130
-	public function set_title( $value ) {
2131
-		$this->set_name( $value );
2130
+	public function set_title($value) {
2131
+		$this->set_name($value);
2132 2132
     }
2133 2133
 
2134 2134
     /**
@@ -2137,9 +2137,9 @@  discard block
 block discarded – undo
2137 2137
 	 * @since 1.0.19
2138 2138
 	 * @param  string $value New description.
2139 2139
 	 */
2140
-	public function set_description( $value ) {
2141
-        $description = wp_kses_post( $value );
2142
-		return $this->set_prop( 'description', $description );
2140
+	public function set_description($value) {
2141
+        $description = wp_kses_post($value);
2142
+		return $this->set_prop('description', $description);
2143 2143
     }
2144 2144
 
2145 2145
     /**
@@ -2148,8 +2148,8 @@  discard block
 block discarded – undo
2148 2148
 	 * @since 1.0.19
2149 2149
 	 * @param  string $value New description.
2150 2150
 	 */
2151
-	public function set_excerpt( $value ) {
2152
-		$this->set_description( $value );
2151
+	public function set_excerpt($value) {
2152
+		$this->set_description($value);
2153 2153
     }
2154 2154
 
2155 2155
     /**
@@ -2158,8 +2158,8 @@  discard block
 block discarded – undo
2158 2158
 	 * @since 1.0.19
2159 2159
 	 * @param  string $value New description.
2160 2160
 	 */
2161
-	public function set_summary( $value ) {
2162
-		$this->set_description( $value );
2161
+	public function set_summary($value) {
2162
+		$this->set_description($value);
2163 2163
     }
2164 2164
 
2165 2165
     /**
@@ -2168,12 +2168,12 @@  discard block
 block discarded – undo
2168 2168
 	 * @since 1.0.19
2169 2169
 	 * @param  int $value New author.
2170 2170
 	 */
2171
-	public function set_author( $value ) {
2172
-		$user = get_user_by( 'id', (int) $value );
2171
+	public function set_author($value) {
2172
+		$user = get_user_by('id', (int) $value);
2173 2173
 
2174
-		if ( $user && $user->ID ) {
2175
-			$this->set_prop( 'author', $user->ID );
2176
-			$this->set_prop( 'email', $user->user_email );
2174
+		if ($user && $user->ID) {
2175
+			$this->set_prop('author', $user->ID);
2176
+			$this->set_prop('email', $user->user_email);
2177 2177
 		}
2178 2178
 		
2179 2179
     }
@@ -2184,8 +2184,8 @@  discard block
 block discarded – undo
2184 2184
 	 * @since 1.0.19
2185 2185
 	 * @param  int $value New user id.
2186 2186
 	 */
2187
-	public function set_user_id( $value ) {
2188
-		$this->set_author( $value );
2187
+	public function set_user_id($value) {
2188
+		$this->set_author($value);
2189 2189
     }
2190 2190
 
2191 2191
     /**
@@ -2194,8 +2194,8 @@  discard block
 block discarded – undo
2194 2194
 	 * @since 1.0.19
2195 2195
 	 * @param  int $value New user id.
2196 2196
 	 */
2197
-	public function set_customer_id( $value ) {
2198
-		$this->set_author( $value );
2197
+	public function set_customer_id($value) {
2198
+		$this->set_author($value);
2199 2199
     }
2200 2200
 
2201 2201
     /**
@@ -2204,8 +2204,8 @@  discard block
 block discarded – undo
2204 2204
 	 * @since 1.0.19
2205 2205
 	 * @param  string $value ip address.
2206 2206
 	 */
2207
-	public function set_ip( $value ) {
2208
-		$this->set_prop( 'ip', $value );
2207
+	public function set_ip($value) {
2208
+		$this->set_prop('ip', $value);
2209 2209
     }
2210 2210
 
2211 2211
     /**
@@ -2214,8 +2214,8 @@  discard block
 block discarded – undo
2214 2214
 	 * @since 1.0.19
2215 2215
 	 * @param  string $value ip address.
2216 2216
 	 */
2217
-	public function set_user_ip( $value ) {
2218
-		$this->set_ip( $value );
2217
+	public function set_user_ip($value) {
2218
+		$this->set_ip($value);
2219 2219
     }
2220 2220
 
2221 2221
     /**
@@ -2224,8 +2224,8 @@  discard block
 block discarded – undo
2224 2224
 	 * @since 1.0.19
2225 2225
 	 * @param  string $value first name.
2226 2226
 	 */
2227
-	public function set_first_name( $value ) {
2228
-		$this->set_prop( 'first_name', $value );
2227
+	public function set_first_name($value) {
2228
+		$this->set_prop('first_name', $value);
2229 2229
     }
2230 2230
 
2231 2231
     /**
@@ -2234,8 +2234,8 @@  discard block
 block discarded – undo
2234 2234
 	 * @since 1.0.19
2235 2235
 	 * @param  string $value first name.
2236 2236
 	 */
2237
-	public function set_user_first_name( $value ) {
2238
-		$this->set_first_name( $value );
2237
+	public function set_user_first_name($value) {
2238
+		$this->set_first_name($value);
2239 2239
     }
2240 2240
 
2241 2241
     /**
@@ -2244,8 +2244,8 @@  discard block
 block discarded – undo
2244 2244
 	 * @since 1.0.19
2245 2245
 	 * @param  string $value first name.
2246 2246
 	 */
2247
-	public function set_customer_first_name( $value ) {
2248
-		$this->set_first_name( $value );
2247
+	public function set_customer_first_name($value) {
2248
+		$this->set_first_name($value);
2249 2249
     }
2250 2250
 
2251 2251
     /**
@@ -2254,8 +2254,8 @@  discard block
 block discarded – undo
2254 2254
 	 * @since 1.0.19
2255 2255
 	 * @param  string $value last name.
2256 2256
 	 */
2257
-	public function set_last_name( $value ) {
2258
-		$this->set_prop( 'last_name', $value );
2257
+	public function set_last_name($value) {
2258
+		$this->set_prop('last_name', $value);
2259 2259
     }
2260 2260
 
2261 2261
     /**
@@ -2264,8 +2264,8 @@  discard block
 block discarded – undo
2264 2264
 	 * @since 1.0.19
2265 2265
 	 * @param  string $value last name.
2266 2266
 	 */
2267
-	public function set_user_last_name( $value ) {
2268
-		$this->set_last_name( $value );
2267
+	public function set_user_last_name($value) {
2268
+		$this->set_last_name($value);
2269 2269
     }
2270 2270
 
2271 2271
     /**
@@ -2274,8 +2274,8 @@  discard block
 block discarded – undo
2274 2274
 	 * @since 1.0.19
2275 2275
 	 * @param  string $value last name.
2276 2276
 	 */
2277
-	public function set_customer_last_name( $value ) {
2278
-		$this->set_last_name( $value );
2277
+	public function set_customer_last_name($value) {
2278
+		$this->set_last_name($value);
2279 2279
     }
2280 2280
 
2281 2281
     /**
@@ -2284,8 +2284,8 @@  discard block
 block discarded – undo
2284 2284
 	 * @since 1.0.19
2285 2285
 	 * @param  string $value phone.
2286 2286
 	 */
2287
-	public function set_phone( $value ) {
2288
-		$this->set_prop( 'phone', $value );
2287
+	public function set_phone($value) {
2288
+		$this->set_prop('phone', $value);
2289 2289
     }
2290 2290
 
2291 2291
     /**
@@ -2294,8 +2294,8 @@  discard block
 block discarded – undo
2294 2294
 	 * @since 1.0.19
2295 2295
 	 * @param  string $value phone.
2296 2296
 	 */
2297
-	public function set_user_phone( $value ) {
2298
-		$this->set_phone( $value );
2297
+	public function set_user_phone($value) {
2298
+		$this->set_phone($value);
2299 2299
     }
2300 2300
 
2301 2301
     /**
@@ -2304,8 +2304,8 @@  discard block
 block discarded – undo
2304 2304
 	 * @since 1.0.19
2305 2305
 	 * @param  string $value phone.
2306 2306
 	 */
2307
-	public function set_customer_phone( $value ) {
2308
-		$this->set_phone( $value );
2307
+	public function set_customer_phone($value) {
2308
+		$this->set_phone($value);
2309 2309
     }
2310 2310
 
2311 2311
     /**
@@ -2314,8 +2314,8 @@  discard block
 block discarded – undo
2314 2314
 	 * @since 1.0.19
2315 2315
 	 * @param  string $value phone.
2316 2316
 	 */
2317
-	public function set_phone_number( $value ) {
2318
-		$this->set_phone( $value );
2317
+	public function set_phone_number($value) {
2318
+		$this->set_phone($value);
2319 2319
     }
2320 2320
 
2321 2321
     /**
@@ -2324,8 +2324,8 @@  discard block
 block discarded – undo
2324 2324
 	 * @since 1.0.19
2325 2325
 	 * @param  string $value email address.
2326 2326
 	 */
2327
-	public function set_email( $value ) {
2328
-		$this->set_prop( 'email', $value );
2327
+	public function set_email($value) {
2328
+		$this->set_prop('email', $value);
2329 2329
     }
2330 2330
 
2331 2331
     /**
@@ -2334,8 +2334,8 @@  discard block
 block discarded – undo
2334 2334
 	 * @since 1.0.19
2335 2335
 	 * @param  string $value email address.
2336 2336
 	 */
2337
-	public function set_user_email( $value ) {
2338
-		$this->set_email( $value );
2337
+	public function set_user_email($value) {
2338
+		$this->set_email($value);
2339 2339
     }
2340 2340
 
2341 2341
     /**
@@ -2344,8 +2344,8 @@  discard block
 block discarded – undo
2344 2344
 	 * @since 1.0.19
2345 2345
 	 * @param  string $value email address.
2346 2346
 	 */
2347
-	public function set_email_address( $value ) {
2348
-		$this->set_email( $value );
2347
+	public function set_email_address($value) {
2348
+		$this->set_email($value);
2349 2349
     }
2350 2350
 
2351 2351
     /**
@@ -2354,8 +2354,8 @@  discard block
 block discarded – undo
2354 2354
 	 * @since 1.0.19
2355 2355
 	 * @param  string $value email address.
2356 2356
 	 */
2357
-	public function set_customer_email( $value ) {
2358
-		$this->set_email( $value );
2357
+	public function set_customer_email($value) {
2358
+		$this->set_email($value);
2359 2359
     }
2360 2360
 
2361 2361
     /**
@@ -2364,8 +2364,8 @@  discard block
 block discarded – undo
2364 2364
 	 * @since 1.0.19
2365 2365
 	 * @param  string $value country.
2366 2366
 	 */
2367
-	public function set_country( $value ) {
2368
-		$this->set_prop( 'country', $value );
2367
+	public function set_country($value) {
2368
+		$this->set_prop('country', $value);
2369 2369
     }
2370 2370
 
2371 2371
     /**
@@ -2374,8 +2374,8 @@  discard block
 block discarded – undo
2374 2374
 	 * @since 1.0.19
2375 2375
 	 * @param  string $value country.
2376 2376
 	 */
2377
-	public function set_user_country( $value ) {
2378
-		$this->set_country( $value );
2377
+	public function set_user_country($value) {
2378
+		$this->set_country($value);
2379 2379
     }
2380 2380
 
2381 2381
     /**
@@ -2384,8 +2384,8 @@  discard block
 block discarded – undo
2384 2384
 	 * @since 1.0.19
2385 2385
 	 * @param  string $value country.
2386 2386
 	 */
2387
-	public function set_customer_country( $value ) {
2388
-		$this->set_country( $value );
2387
+	public function set_customer_country($value) {
2388
+		$this->set_country($value);
2389 2389
     }
2390 2390
 
2391 2391
     /**
@@ -2394,8 +2394,8 @@  discard block
 block discarded – undo
2394 2394
 	 * @since 1.0.19
2395 2395
 	 * @param  string $value state.
2396 2396
 	 */
2397
-	public function set_state( $value ) {
2398
-		$this->set_prop( 'state', $value );
2397
+	public function set_state($value) {
2398
+		$this->set_prop('state', $value);
2399 2399
     }
2400 2400
 
2401 2401
     /**
@@ -2404,8 +2404,8 @@  discard block
 block discarded – undo
2404 2404
 	 * @since 1.0.19
2405 2405
 	 * @param  string $value state.
2406 2406
 	 */
2407
-	public function set_user_state( $value ) {
2408
-		$this->set_state( $value );
2407
+	public function set_user_state($value) {
2408
+		$this->set_state($value);
2409 2409
     }
2410 2410
 
2411 2411
     /**
@@ -2414,8 +2414,8 @@  discard block
 block discarded – undo
2414 2414
 	 * @since 1.0.19
2415 2415
 	 * @param  string $value state.
2416 2416
 	 */
2417
-	public function set_customer_state( $value ) {
2418
-		$this->set_state( $value );
2417
+	public function set_customer_state($value) {
2418
+		$this->set_state($value);
2419 2419
     }
2420 2420
 
2421 2421
     /**
@@ -2424,8 +2424,8 @@  discard block
 block discarded – undo
2424 2424
 	 * @since 1.0.19
2425 2425
 	 * @param  string $value city.
2426 2426
 	 */
2427
-	public function set_city( $value ) {
2428
-		$this->set_prop( 'city', $value );
2427
+	public function set_city($value) {
2428
+		$this->set_prop('city', $value);
2429 2429
     }
2430 2430
 
2431 2431
     /**
@@ -2434,8 +2434,8 @@  discard block
 block discarded – undo
2434 2434
 	 * @since 1.0.19
2435 2435
 	 * @param  string $value city.
2436 2436
 	 */
2437
-	public function set_user_city( $value ) {
2438
-		$this->set_city( $value );
2437
+	public function set_user_city($value) {
2438
+		$this->set_city($value);
2439 2439
     }
2440 2440
 
2441 2441
     /**
@@ -2444,8 +2444,8 @@  discard block
 block discarded – undo
2444 2444
 	 * @since 1.0.19
2445 2445
 	 * @param  string $value city.
2446 2446
 	 */
2447
-	public function set_customer_city( $value ) {
2448
-		$this->set_city( $value );
2447
+	public function set_customer_city($value) {
2448
+		$this->set_city($value);
2449 2449
     }
2450 2450
 
2451 2451
     /**
@@ -2454,8 +2454,8 @@  discard block
 block discarded – undo
2454 2454
 	 * @since 1.0.19
2455 2455
 	 * @param  string $value zip.
2456 2456
 	 */
2457
-	public function set_zip( $value ) {
2458
-		$this->set_prop( 'zip', $value );
2457
+	public function set_zip($value) {
2458
+		$this->set_prop('zip', $value);
2459 2459
     }
2460 2460
 
2461 2461
     /**
@@ -2464,8 +2464,8 @@  discard block
 block discarded – undo
2464 2464
 	 * @since 1.0.19
2465 2465
 	 * @param  string $value zip.
2466 2466
 	 */
2467
-	public function set_user_zip( $value ) {
2468
-		$this->set_zip( $value );
2467
+	public function set_user_zip($value) {
2468
+		$this->set_zip($value);
2469 2469
     }
2470 2470
 
2471 2471
     /**
@@ -2474,8 +2474,8 @@  discard block
 block discarded – undo
2474 2474
 	 * @since 1.0.19
2475 2475
 	 * @param  string $value zip.
2476 2476
 	 */
2477
-	public function set_customer_zip( $value ) {
2478
-		$this->set_zip( $value );
2477
+	public function set_customer_zip($value) {
2478
+		$this->set_zip($value);
2479 2479
     }
2480 2480
 
2481 2481
     /**
@@ -2484,8 +2484,8 @@  discard block
 block discarded – undo
2484 2484
 	 * @since 1.0.19
2485 2485
 	 * @param  string $value company.
2486 2486
 	 */
2487
-	public function set_company( $value ) {
2488
-		$this->set_prop( 'company', $value );
2487
+	public function set_company($value) {
2488
+		$this->set_prop('company', $value);
2489 2489
     }
2490 2490
 
2491 2491
     /**
@@ -2494,8 +2494,8 @@  discard block
 block discarded – undo
2494 2494
 	 * @since 1.0.19
2495 2495
 	 * @param  string $value company.
2496 2496
 	 */
2497
-	public function set_user_company( $value ) {
2498
-		$this->set_company( $value );
2497
+	public function set_user_company($value) {
2498
+		$this->set_company($value);
2499 2499
     }
2500 2500
 
2501 2501
     /**
@@ -2504,8 +2504,8 @@  discard block
 block discarded – undo
2504 2504
 	 * @since 1.0.19
2505 2505
 	 * @param  string $value company.
2506 2506
 	 */
2507
-	public function set_customer_company( $value ) {
2508
-		$this->set_company( $value );
2507
+	public function set_customer_company($value) {
2508
+		$this->set_company($value);
2509 2509
     }
2510 2510
 
2511 2511
     /**
@@ -2514,8 +2514,8 @@  discard block
 block discarded – undo
2514 2514
 	 * @since 1.0.19
2515 2515
 	 * @param  string $value var number.
2516 2516
 	 */
2517
-	public function set_vat_number( $value ) {
2518
-		$this->set_prop( 'vat_number', $value );
2517
+	public function set_vat_number($value) {
2518
+		$this->set_prop('vat_number', $value);
2519 2519
     }
2520 2520
 
2521 2521
     /**
@@ -2524,8 +2524,8 @@  discard block
 block discarded – undo
2524 2524
 	 * @since 1.0.19
2525 2525
 	 * @param  string $value var number.
2526 2526
 	 */
2527
-	public function set_user_vat_number( $value ) {
2528
-		$this->set_vat_number( $value );
2527
+	public function set_user_vat_number($value) {
2528
+		$this->set_vat_number($value);
2529 2529
     }
2530 2530
 
2531 2531
     /**
@@ -2534,8 +2534,8 @@  discard block
 block discarded – undo
2534 2534
 	 * @since 1.0.19
2535 2535
 	 * @param  string $value var number.
2536 2536
 	 */
2537
-	public function set_customer_vat_number( $value ) {
2538
-		$this->set_vat_number( $value );
2537
+	public function set_customer_vat_number($value) {
2538
+		$this->set_vat_number($value);
2539 2539
     }
2540 2540
 
2541 2541
     /**
@@ -2544,8 +2544,8 @@  discard block
 block discarded – undo
2544 2544
 	 * @since 1.0.19
2545 2545
 	 * @param  string $value var rate.
2546 2546
 	 */
2547
-	public function set_vat_rate( $value ) {
2548
-		$this->set_prop( 'vat_rate', $value );
2547
+	public function set_vat_rate($value) {
2548
+		$this->set_prop('vat_rate', $value);
2549 2549
     }
2550 2550
 
2551 2551
     /**
@@ -2554,8 +2554,8 @@  discard block
 block discarded – undo
2554 2554
 	 * @since 1.0.19
2555 2555
 	 * @param  string $value var number.
2556 2556
 	 */
2557
-	public function set_user_vat_rate( $value ) {
2558
-		$this->set_vat_rate( $value );
2557
+	public function set_user_vat_rate($value) {
2558
+		$this->set_vat_rate($value);
2559 2559
     }
2560 2560
 
2561 2561
     /**
@@ -2564,8 +2564,8 @@  discard block
 block discarded – undo
2564 2564
 	 * @since 1.0.19
2565 2565
 	 * @param  string $value var number.
2566 2566
 	 */
2567
-	public function set_customer_vat_rate( $value ) {
2568
-		$this->set_vat_rate( $value );
2567
+	public function set_customer_vat_rate($value) {
2568
+		$this->set_vat_rate($value);
2569 2569
     }
2570 2570
 
2571 2571
     /**
@@ -2574,8 +2574,8 @@  discard block
 block discarded – undo
2574 2574
 	 * @since 1.0.19
2575 2575
 	 * @param  string $value address.
2576 2576
 	 */
2577
-	public function set_address( $value ) {
2578
-		$this->set_prop( 'address', $value );
2577
+	public function set_address($value) {
2578
+		$this->set_prop('address', $value);
2579 2579
     }
2580 2580
 
2581 2581
     /**
@@ -2584,8 +2584,8 @@  discard block
 block discarded – undo
2584 2584
 	 * @since 1.0.19
2585 2585
 	 * @param  string $value address.
2586 2586
 	 */
2587
-	public function set_user_address( $value ) {
2588
-		$this->set_address( $value );
2587
+	public function set_user_address($value) {
2588
+		$this->set_address($value);
2589 2589
     }
2590 2590
 
2591 2591
     /**
@@ -2594,8 +2594,8 @@  discard block
 block discarded – undo
2594 2594
 	 * @since 1.0.19
2595 2595
 	 * @param  string $value address.
2596 2596
 	 */
2597
-	public function set_customer_address( $value ) {
2598
-		$this->set_address( $value );
2597
+	public function set_customer_address($value) {
2598
+		$this->set_address($value);
2599 2599
     }
2600 2600
 
2601 2601
     /**
@@ -2604,8 +2604,8 @@  discard block
 block discarded – undo
2604 2604
 	 * @since 1.0.19
2605 2605
 	 * @param  int|bool $value confirmed.
2606 2606
 	 */
2607
-	public function set_is_viewed( $value ) {
2608
-		$this->set_prop( 'is_viewed', $value );
2607
+	public function set_is_viewed($value) {
2608
+		$this->set_prop('is_viewed', $value);
2609 2609
 	}
2610 2610
 
2611 2611
 	/**
@@ -2614,8 +2614,8 @@  discard block
 block discarded – undo
2614 2614
 	 * @since 1.0.19
2615 2615
 	 * @param  string $value email recipients.
2616 2616
 	 */
2617
-	public function set_email_cc( $value ) {
2618
-		$this->set_prop( 'email_cc', $value );
2617
+	public function set_email_cc($value) {
2618
+		$this->set_prop('email_cc', $value);
2619 2619
 	}
2620 2620
 
2621 2621
 	/**
@@ -2624,9 +2624,9 @@  discard block
 block discarded – undo
2624 2624
 	 * @since 1.0.19
2625 2625
 	 * @param  string $value email recipients.
2626 2626
 	 */
2627
-	public function set_template( $value ) {
2628
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2629
-			$this->set_prop( 'template', $value );
2627
+	public function set_template($value) {
2628
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2629
+			$this->set_prop('template', $value);
2630 2630
 		}
2631 2631
 	}
2632 2632
 
@@ -2636,8 +2636,8 @@  discard block
 block discarded – undo
2636 2636
 	 * @since 1.0.19
2637 2637
 	 * @param  int|bool $value confirmed.
2638 2638
 	 */
2639
-	public function set_address_confirmed( $value ) {
2640
-		$this->set_prop( 'address_confirmed', $value );
2639
+	public function set_address_confirmed($value) {
2640
+		$this->set_prop('address_confirmed', $value);
2641 2641
     }
2642 2642
 
2643 2643
     /**
@@ -2646,8 +2646,8 @@  discard block
 block discarded – undo
2646 2646
 	 * @since 1.0.19
2647 2647
 	 * @param  int|bool $value confirmed.
2648 2648
 	 */
2649
-	public function set_user_address_confirmed( $value ) {
2650
-		$this->set_address_confirmed( $value );
2649
+	public function set_user_address_confirmed($value) {
2650
+		$this->set_address_confirmed($value);
2651 2651
     }
2652 2652
 
2653 2653
     /**
@@ -2656,8 +2656,8 @@  discard block
 block discarded – undo
2656 2656
 	 * @since 1.0.19
2657 2657
 	 * @param  int|bool $value confirmed.
2658 2658
 	 */
2659
-	public function set_customer_address_confirmed( $value ) {
2660
-		$this->set_address_confirmed( $value );
2659
+	public function set_customer_address_confirmed($value) {
2660
+		$this->set_address_confirmed($value);
2661 2661
     }
2662 2662
 
2663 2663
     /**
@@ -2666,8 +2666,8 @@  discard block
 block discarded – undo
2666 2666
 	 * @since 1.0.19
2667 2667
 	 * @param  float $value sub total.
2668 2668
 	 */
2669
-	public function set_subtotal( $value ) {
2670
-		$this->set_prop( 'subtotal', $value );
2669
+	public function set_subtotal($value) {
2670
+		$this->set_prop('subtotal', $value);
2671 2671
     }
2672 2672
 
2673 2673
     /**
@@ -2676,8 +2676,8 @@  discard block
 block discarded – undo
2676 2676
 	 * @since 1.0.19
2677 2677
 	 * @param  float $value discount total.
2678 2678
 	 */
2679
-	public function set_total_discount( $value ) {
2680
-		$this->set_prop( 'total_discount', $value );
2679
+	public function set_total_discount($value) {
2680
+		$this->set_prop('total_discount', $value);
2681 2681
     }
2682 2682
 
2683 2683
     /**
@@ -2686,8 +2686,8 @@  discard block
 block discarded – undo
2686 2686
 	 * @since 1.0.19
2687 2687
 	 * @param  float $value discount total.
2688 2688
 	 */
2689
-	public function set_discount( $value ) {
2690
-		$this->set_total_discount( $value );
2689
+	public function set_discount($value) {
2690
+		$this->set_total_discount($value);
2691 2691
     }
2692 2692
 
2693 2693
     /**
@@ -2696,8 +2696,8 @@  discard block
 block discarded – undo
2696 2696
 	 * @since 1.0.19
2697 2697
 	 * @param  float $value tax total.
2698 2698
 	 */
2699
-	public function set_total_tax( $value ) {
2700
-		$this->set_prop( 'total_tax', $value );
2699
+	public function set_total_tax($value) {
2700
+		$this->set_prop('total_tax', $value);
2701 2701
     }
2702 2702
 
2703 2703
     /**
@@ -2706,8 +2706,8 @@  discard block
 block discarded – undo
2706 2706
 	 * @since 1.0.19
2707 2707
 	 * @param  float $value tax total.
2708 2708
 	 */
2709
-	public function set_tax_total( $value ) {
2710
-		$this->set_total_tax( $value );
2709
+	public function set_tax_total($value) {
2710
+		$this->set_total_tax($value);
2711 2711
     }
2712 2712
 
2713 2713
     /**
@@ -2716,8 +2716,8 @@  discard block
 block discarded – undo
2716 2716
 	 * @since 1.0.19
2717 2717
 	 * @param  float $value fees total.
2718 2718
 	 */
2719
-	public function set_total_fees( $value ) {
2720
-		$this->set_prop( 'total_fees', $value );
2719
+	public function set_total_fees($value) {
2720
+		$this->set_prop('total_fees', $value);
2721 2721
     }
2722 2722
 
2723 2723
     /**
@@ -2726,8 +2726,8 @@  discard block
 block discarded – undo
2726 2726
 	 * @since 1.0.19
2727 2727
 	 * @param  float $value fees total.
2728 2728
 	 */
2729
-	public function set_fees_total( $value ) {
2730
-		$this->set_total_fees( $value );
2729
+	public function set_fees_total($value) {
2730
+		$this->set_total_fees($value);
2731 2731
     }
2732 2732
 
2733 2733
     /**
@@ -2736,13 +2736,13 @@  discard block
 block discarded – undo
2736 2736
 	 * @since 1.0.19
2737 2737
 	 * @param  array $value fees.
2738 2738
 	 */
2739
-	public function set_fees( $value ) {
2739
+	public function set_fees($value) {
2740 2740
 
2741
-		if ( ! is_array( $value ) ) {
2741
+		if (!is_array($value)) {
2742 2742
 			$value = array();
2743 2743
 		}
2744 2744
 
2745
-		$this->set_prop( 'fees', $value );
2745
+		$this->set_prop('fees', $value);
2746 2746
 
2747 2747
     }
2748 2748
 
@@ -2752,13 +2752,13 @@  discard block
 block discarded – undo
2752 2752
 	 * @since 1.0.19
2753 2753
 	 * @param  array $value taxes.
2754 2754
 	 */
2755
-	public function set_taxes( $value ) {
2755
+	public function set_taxes($value) {
2756 2756
 
2757
-		if ( ! is_array( $value ) ) {
2757
+		if (!is_array($value)) {
2758 2758
 			$value = array();
2759 2759
 		}
2760 2760
 
2761
-		$this->set_prop( 'taxes', $value );
2761
+		$this->set_prop('taxes', $value);
2762 2762
 
2763 2763
     }
2764 2764
 
@@ -2768,13 +2768,13 @@  discard block
 block discarded – undo
2768 2768
 	 * @since 1.0.19
2769 2769
 	 * @param  array $value discounts.
2770 2770
 	 */
2771
-	public function set_discounts( $value ) {
2771
+	public function set_discounts($value) {
2772 2772
 
2773
-		if ( ! is_array( $value ) ) {
2773
+		if (!is_array($value)) {
2774 2774
 			$value = array();
2775 2775
 		}
2776 2776
 
2777
-		$this->set_prop( 'discounts', $value );
2777
+		$this->set_prop('discounts', $value);
2778 2778
     }
2779 2779
 
2780 2780
     /**
@@ -2783,18 +2783,18 @@  discard block
 block discarded – undo
2783 2783
 	 * @since 1.0.19
2784 2784
 	 * @param  GetPaid_Form_Item[] $value items.
2785 2785
 	 */
2786
-	public function set_items( $value ) {
2786
+	public function set_items($value) {
2787 2787
 
2788 2788
         // Remove existing items.
2789
-        $this->set_prop( 'items', array() );
2789
+        $this->set_prop('items', array());
2790 2790
 
2791 2791
         // Ensure that we have an array.
2792
-        if ( ! is_array( $value ) ) {
2792
+        if (!is_array($value)) {
2793 2793
             return;
2794 2794
         }
2795 2795
 
2796
-        foreach ( $value as $item ) {
2797
-            $this->add_item( $item );
2796
+        foreach ($value as $item) {
2797
+            $this->add_item($item);
2798 2798
         }
2799 2799
 
2800 2800
     }
@@ -2805,8 +2805,8 @@  discard block
 block discarded – undo
2805 2805
 	 * @since 1.0.19
2806 2806
 	 * @param  int $value payment form.
2807 2807
 	 */
2808
-	public function set_payment_form( $value ) {
2809
-		$this->set_prop( 'payment_form', $value );
2808
+	public function set_payment_form($value) {
2809
+		$this->set_prop('payment_form', $value);
2810 2810
     }
2811 2811
 
2812 2812
     /**
@@ -2815,8 +2815,8 @@  discard block
 block discarded – undo
2815 2815
 	 * @since 1.0.19
2816 2816
 	 * @param  string $value submission id.
2817 2817
 	 */
2818
-	public function set_submission_id( $value ) {
2819
-		$this->set_prop( 'submission_id', $value );
2818
+	public function set_submission_id($value) {
2819
+		$this->set_prop('submission_id', $value);
2820 2820
     }
2821 2821
 
2822 2822
     /**
@@ -2825,8 +2825,8 @@  discard block
 block discarded – undo
2825 2825
 	 * @since 1.0.19
2826 2826
 	 * @param  string $value discount code.
2827 2827
 	 */
2828
-	public function set_discount_code( $value ) {
2829
-		$this->set_prop( 'discount_code', $value );
2828
+	public function set_discount_code($value) {
2829
+		$this->set_prop('discount_code', $value);
2830 2830
     }
2831 2831
 
2832 2832
     /**
@@ -2835,8 +2835,8 @@  discard block
 block discarded – undo
2835 2835
 	 * @since 1.0.19
2836 2836
 	 * @param  string $value gateway.
2837 2837
 	 */
2838
-	public function set_gateway( $value ) {
2839
-		$this->set_prop( 'gateway', $value );
2838
+	public function set_gateway($value) {
2839
+		$this->set_prop('gateway', $value);
2840 2840
     }
2841 2841
 
2842 2842
     /**
@@ -2845,9 +2845,9 @@  discard block
 block discarded – undo
2845 2845
 	 * @since 1.0.19
2846 2846
 	 * @param  string $value transaction id.
2847 2847
 	 */
2848
-	public function set_transaction_id( $value ) {
2849
-		if ( ! empty( $value ) ) {
2850
-			$this->set_prop( 'transaction_id', $value );
2848
+	public function set_transaction_id($value) {
2849
+		if (!empty($value)) {
2850
+			$this->set_prop('transaction_id', $value);
2851 2851
 		}
2852 2852
     }
2853 2853
 
@@ -2857,8 +2857,8 @@  discard block
 block discarded – undo
2857 2857
 	 * @since 1.0.19
2858 2858
 	 * @param  string $value currency id.
2859 2859
 	 */
2860
-	public function set_currency( $value ) {
2861
-		$this->set_prop( 'currency', $value );
2860
+	public function set_currency($value) {
2861
+		$this->set_prop('currency', $value);
2862 2862
     }
2863 2863
 
2864 2864
 	/**
@@ -2867,8 +2867,8 @@  discard block
 block discarded – undo
2867 2867
 	 * @since 1.0.19
2868 2868
 	 * @param  bool $value value.
2869 2869
 	 */
2870
-	public function set_disable_taxes( $value ) {
2871
-		$this->set_prop( 'disable_taxes', (bool) $value );
2870
+	public function set_disable_taxes($value) {
2871
+		$this->set_prop('disable_taxes', (bool) $value);
2872 2872
 	}
2873 2873
 
2874 2874
     /**
@@ -2877,8 +2877,8 @@  discard block
 block discarded – undo
2877 2877
 	 * @since 1.0.19
2878 2878
 	 * @param  string $value subscription id.
2879 2879
 	 */
2880
-	public function set_subscription_id( $value ) {
2881
-		$this->set_prop( 'subscription_id', $value );
2880
+	public function set_subscription_id($value) {
2881
+		$this->set_prop('subscription_id', $value);
2882 2882
 	}
2883 2883
 	
2884 2884
 	/**
@@ -2887,8 +2887,8 @@  discard block
 block discarded – undo
2887 2887
 	 * @since 1.0.19
2888 2888
 	 * @param  string $value subscription id.
2889 2889
 	 */
2890
-	public function set_remote_subscription_id( $value ) {
2891
-		$this->set_prop( 'remote_subscription_id', $value );
2890
+	public function set_remote_subscription_id($value) {
2891
+		$this->set_prop('remote_subscription_id', $value);
2892 2892
     }
2893 2893
 
2894 2894
     /*
@@ -2905,28 +2905,28 @@  discard block
 block discarded – undo
2905 2905
      */
2906 2906
     public function is_parent() {
2907 2907
         $parent = $this->get_parent_id();
2908
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
2908
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
2909 2909
     }
2910 2910
 
2911 2911
     /**
2912 2912
      * Checks if this is a renewal invoice.
2913 2913
      */
2914 2914
     public function is_renewal() {
2915
-        return ! $this->is_parent();
2915
+        return !$this->is_parent();
2916 2916
     }
2917 2917
 
2918 2918
     /**
2919 2919
      * Checks if this is a recurring invoice.
2920 2920
      */
2921 2921
     public function is_recurring() {
2922
-        return $this->is_renewal() || ! empty( $this->recurring_item );
2922
+        return $this->is_renewal() || !empty($this->recurring_item);
2923 2923
     }
2924 2924
 
2925 2925
     /**
2926 2926
      * Checks if this is a taxable invoice.
2927 2927
      */
2928 2928
     public function is_taxable() {
2929
-        return ! $this->get_disable_taxes();
2929
+        return !$this->get_disable_taxes();
2930 2930
 	}
2931 2931
 
2932 2932
 	/**
@@ -2937,57 +2937,57 @@  discard block
 block discarded – undo
2937 2937
 
2938 2938
         $requires_vat = false;
2939 2939
 
2940
-        if ( $this->country ) {
2940
+        if ($this->country) {
2941 2941
             $wpi_country        = $this->country;
2942
-            $requires_vat       = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) );
2942
+            $requires_vat       = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this));
2943 2943
         }
2944 2944
 
2945
-        return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2945
+        return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this);
2946 2946
 	}
2947 2947
 
2948 2948
 	/**
2949 2949
 	 * Checks to see if the invoice requires payment.
2950 2950
 	 */
2951 2951
 	public function is_free() {
2952
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2952
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
2953 2953
 
2954
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2954
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
2955 2955
 			$is_free = false;
2956 2956
 		}
2957 2957
 
2958
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2958
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2959 2959
     }
2960 2960
 
2961 2961
     /**
2962 2962
      * Checks if the invoice is paid.
2963 2963
      */
2964 2964
     public function is_paid() {
2965
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2966
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2965
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2966
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2967 2967
 	}
2968 2968
 
2969 2969
 	/**
2970 2970
      * Checks if the invoice needs payment.
2971 2971
      */
2972 2972
 	public function needs_payment() {
2973
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2974
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2973
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
2974
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
2975 2975
     }
2976 2976
   
2977 2977
 	/**
2978 2978
      * Checks if the invoice is refunded.
2979 2979
      */
2980 2980
 	public function is_refunded() {
2981
-        $is_refunded = $this->has_status( 'wpi-refunded' );
2982
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2981
+        $is_refunded = $this->has_status('wpi-refunded');
2982
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
2983 2983
 	}
2984 2984
 
2985 2985
 	/**
2986 2986
      * Checks if the invoice is held.
2987 2987
      */
2988 2988
 	public function is_held() {
2989
-        $is_held = $this->has_status( 'wpi-onhold' );
2990
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2989
+        $is_held = $this->has_status('wpi-onhold');
2990
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
2991 2991
 	}
2992 2992
 
2993 2993
 	/**
@@ -2995,30 +2995,30 @@  discard block
 block discarded – undo
2995 2995
      */
2996 2996
 	public function is_due() {
2997 2997
 		$due_date = $this->get_due_date();
2998
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2998
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
2999 2999
 	}
3000 3000
 
3001 3001
 	/**
3002 3002
      * Checks if the invoice is draft.
3003 3003
      */
3004 3004
 	public function is_draft() {
3005
-        return $this->has_status( 'draft, auto-draft' );
3005
+        return $this->has_status('draft, auto-draft');
3006 3006
 	}
3007 3007
 
3008 3008
     /**
3009 3009
      * Checks if the invoice has a given status.
3010 3010
      */
3011
-    public function has_status( $status ) {
3012
-        $status = wpinv_parse_list( $status );
3013
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3011
+    public function has_status($status) {
3012
+        $status = wpinv_parse_list($status);
3013
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3014 3014
 	}
3015 3015
 
3016 3016
 	/**
3017 3017
      * Checks if the invoice is of a given type.
3018 3018
      */
3019
-    public function is_type( $type ) {
3020
-        $type = wpinv_parse_list( $type );
3021
-        return in_array( $this->get_type(), $type );
3019
+    public function is_type($type) {
3020
+        $type = wpinv_parse_list($type);
3021
+        return in_array($this->get_type(), $type);
3022 3022
     }
3023 3023
 
3024 3024
     /**
@@ -3050,8 +3050,8 @@  discard block
 block discarded – undo
3050 3050
      *
3051 3051
      */
3052 3052
 	public function is_initial_free() {
3053
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3054
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3053
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3054
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3055 3055
     }
3056 3056
 	
3057 3057
 	/**
@@ -3061,11 +3061,11 @@  discard block
 block discarded – undo
3061 3061
     public function item_has_free_trial() {
3062 3062
 
3063 3063
         // Ensure we have a recurring item.
3064
-        if ( ! $this->is_recurring() ) {
3064
+        if (!$this->is_recurring()) {
3065 3065
             return false;
3066 3066
         }
3067 3067
 
3068
-        $item = $this->get_recurring( true );
3068
+        $item = $this->get_recurring(true);
3069 3069
         return $item->has_free_trial();
3070 3070
 	}
3071 3071
 
@@ -3073,7 +3073,7 @@  discard block
 block discarded – undo
3073 3073
      * Check if the free trial is a result of a discount.
3074 3074
      */
3075 3075
     public function is_free_trial_from_discount() {
3076
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3076
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3077 3077
 	}
3078 3078
 	
3079 3079
 	/**
@@ -3082,17 +3082,17 @@  discard block
 block discarded – undo
3082 3082
     public function discount_first_payment_only() {
3083 3083
 
3084 3084
 		$discount_code = $this->get_discount_code();
3085
-        if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3085
+        if (empty($this->discount_code) || !$this->is_recurring()) {
3086 3086
             return true;
3087 3087
         }
3088 3088
 
3089
-        $discount = wpinv_get_discount_obj( $discount_code );
3089
+        $discount = wpinv_get_discount_obj($discount_code);
3090 3090
 
3091
-        if ( ! $discount || ! $discount->exists() ) {
3091
+        if (!$discount || !$discount->exists()) {
3092 3092
             return true;
3093 3093
         }
3094 3094
 
3095
-        return ! $discount->get_is_recurring();
3095
+        return !$discount->get_is_recurring();
3096 3096
     }
3097 3097
 
3098 3098
     /*
@@ -3110,27 +3110,27 @@  discard block
 block discarded – undo
3110 3110
      * @param GetPaid_Form_Item|array $item
3111 3111
      * @return WP_Error|Bool
3112 3112
      */
3113
-    public function add_item( $item ) {
3113
+    public function add_item($item) {
3114 3114
 
3115
-		if ( is_array( $item ) ) {
3116
-			$item = $this->process_array_item( $item );
3115
+		if (is_array($item)) {
3116
+			$item = $this->process_array_item($item);
3117 3117
 		}
3118 3118
 
3119
-		if ( is_numeric( $item ) ) {
3120
-			$item = new GetPaid_Form_Item( $item );
3119
+		if (is_numeric($item)) {
3120
+			$item = new GetPaid_Form_Item($item);
3121 3121
 		}
3122 3122
 
3123 3123
         // Make sure that it is available for purchase.
3124
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3125
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3124
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3125
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3126 3126
         }
3127 3127
 
3128 3128
         // Do we have a recurring item?
3129
-		if ( $item->is_recurring() ) {
3129
+		if ($item->is_recurring()) {
3130 3130
 
3131 3131
 			// An invoice can only contain one recurring item.
3132
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3133
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3132
+			if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) {
3133
+				return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing'));
3134 3134
 			}
3135 3135
 
3136 3136
 			$this->recurring_item = $item->get_id();
@@ -3141,9 +3141,9 @@  discard block
 block discarded – undo
3141 3141
 
3142 3142
         // Retrieve all items.
3143 3143
         $items = $this->get_items();
3144
-        $items[ (int) $item->get_id() ] = $item;
3144
+        $items[(int) $item->get_id()] = $item;
3145 3145
 
3146
-        $this->set_prop( 'items', $items );
3146
+        $this->set_prop('items', $items);
3147 3147
 		return true;
3148 3148
 	}
3149 3149
 	
@@ -3153,26 +3153,26 @@  discard block
 block discarded – undo
3153 3153
 	 * @since 1.0.19
3154 3154
 	 * @return GetPaid_Form_Item
3155 3155
 	 */
3156
-	protected function process_array_item( $array ) {
3156
+	protected function process_array_item($array) {
3157 3157
 
3158
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3159
-		$item    = new GetPaid_Form_Item( $item_id );
3158
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3159
+		$item    = new GetPaid_Form_Item($item_id);
3160 3160
 
3161 3161
 		// Set item data.
3162
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3163
-			if ( isset( $array[ "item_$key" ] ) ) {
3162
+		foreach (array('name', 'price', 'description') as $key) {
3163
+			if (isset($array["item_$key"])) {
3164 3164
 				$method = "set_$key";
3165
-				$item->$method( $array[ "item_$key" ] );
3165
+				$item->$method($array["item_$key"]);
3166 3166
 			}
3167 3167
 		}
3168 3168
 
3169
-		if ( isset( $array['quantity'] ) ) {
3170
-			$item->set_quantity( $array['quantity'] );
3169
+		if (isset($array['quantity'])) {
3170
+			$item->set_quantity($array['quantity']);
3171 3171
 		}
3172 3172
 
3173 3173
 		// Set item meta.
3174
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3175
-			$item->set_item_meta( $array['meta'] );
3174
+		if (isset($array['meta']) && is_array($array['meta'])) {
3175
+			$item->set_item_meta($array['meta']);
3176 3176
 		}
3177 3177
 
3178 3178
 		return $item;
@@ -3184,10 +3184,10 @@  discard block
 block discarded – undo
3184 3184
 	 *
3185 3185
 	 * @since 1.0.19
3186 3186
 	 */
3187
-	public function get_item( $item_id ) {
3187
+	public function get_item($item_id) {
3188 3188
 		$items   = $this->get_items();
3189 3189
 		$item_id = (int) $item_id;
3190
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3190
+		return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null;
3191 3191
     }
3192 3192
 
3193 3193
     /**
@@ -3195,17 +3195,17 @@  discard block
 block discarded – undo
3195 3195
 	 *
3196 3196
 	 * @since 1.0.19
3197 3197
 	 */
3198
-	public function remove_item( $item_id ) {
3198
+	public function remove_item($item_id) {
3199 3199
 		$items   = $this->get_items();
3200 3200
 		$item_id = (int) $item_id;
3201 3201
 
3202
-        if ( $item_id == $this->recurring_item ) {
3202
+        if ($item_id == $this->recurring_item) {
3203 3203
             $this->recurring_item = null;
3204 3204
         }
3205 3205
 
3206
-        if ( isset( $items[ $item_id ] ) ) {
3207
-            unset( $items[ $item_id ] );
3208
-            $this->set_prop( 'items', $items );
3206
+        if (isset($items[$item_id])) {
3207
+            unset($items[$item_id]);
3208
+            $this->set_prop('items', $items);
3209 3209
         }
3210 3210
     }
3211 3211
 
@@ -3215,11 +3215,11 @@  discard block
 block discarded – undo
3215 3215
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
3216 3216
 	 * @since 1.0.19
3217 3217
 	 */
3218
-    public function add_fee( $fee ) {
3218
+    public function add_fee($fee) {
3219 3219
 
3220 3220
 		$fees = $this->get_fees();
3221
-		$fees[ $fee['name'] ] = $fee;
3222
-		$this->set_prop( 'fees', $fees );
3221
+		$fees[$fee['name']] = $fee;
3222
+		$this->set_prop('fees', $fees);
3223 3223
 
3224 3224
     }
3225 3225
 
@@ -3228,9 +3228,9 @@  discard block
 block discarded – undo
3228 3228
 	 *
3229 3229
 	 * @since 1.0.19
3230 3230
 	 */
3231
-	public function get_fee( $fee ) {
3231
+	public function get_fee($fee) {
3232 3232
         $fees = $this->get_fees();
3233
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3233
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3234 3234
     }
3235 3235
 
3236 3236
     /**
@@ -3238,11 +3238,11 @@  discard block
 block discarded – undo
3238 3238
 	 *
3239 3239
 	 * @since 1.0.19
3240 3240
 	 */
3241
-	public function remove_fee( $fee ) {
3241
+	public function remove_fee($fee) {
3242 3242
         $fees = $this->get_fees();
3243
-        if ( isset( $fees[ $fee ] ) ) {
3244
-            unset( $fees[ $fee ] );
3245
-            $this->set_prop( 'fees', $fees );
3243
+        if (isset($fees[$fee])) {
3244
+            unset($fees[$fee]);
3245
+            $this->set_prop('fees', $fees);
3246 3246
         }
3247 3247
     }
3248 3248
 
@@ -3252,11 +3252,11 @@  discard block
 block discarded – undo
3252 3252
 	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
3253 3253
 	 * @since 1.0.19
3254 3254
 	 */
3255
-	public function add_discount( $discount ) {
3255
+	public function add_discount($discount) {
3256 3256
 
3257 3257
 		$discounts = $this->get_discounts();
3258
-		$discounts[ $discount['name'] ] = $discount;
3259
-		$this->set_prop( 'discounts', $discounts );
3258
+		$discounts[$discount['name']] = $discount;
3259
+		$this->set_prop('discounts', $discounts);
3260 3260
 
3261 3261
 	}
3262 3262
 
@@ -3266,15 +3266,15 @@  discard block
 block discarded – undo
3266 3266
 	 * @since 1.0.19
3267 3267
 	 * @return float
3268 3268
 	 */
3269
-	public function get_discount( $discount = false ) {
3269
+	public function get_discount($discount = false) {
3270 3270
 
3271 3271
 		// Backwards compatibilty.
3272
-		if ( empty( $discount ) ) {
3272
+		if (empty($discount)) {
3273 3273
 			return $this->get_total_discount();
3274 3274
 		}
3275 3275
 
3276 3276
         $discounts = $this->get_discounts();
3277
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3277
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3278 3278
     }
3279 3279
 
3280 3280
     /**
@@ -3282,11 +3282,11 @@  discard block
 block discarded – undo
3282 3282
 	 *
3283 3283
 	 * @since 1.0.19
3284 3284
 	 */
3285
-	public function remove_discount( $discount ) {
3285
+	public function remove_discount($discount) {
3286 3286
         $discounts = $this->get_discounts();
3287
-        if ( isset( $discounts[ $discount ] ) ) {
3288
-            unset( $discounts[ $discount ] );
3289
-            $this->set_prop( 'discounts', $discounts );
3287
+        if (isset($discounts[$discount])) {
3288
+            unset($discounts[$discount]);
3289
+            $this->set_prop('discounts', $discounts);
3290 3290
         }
3291 3291
     }
3292 3292
 
@@ -3296,13 +3296,13 @@  discard block
 block discarded – undo
3296 3296
      * @param string $tax
3297 3297
      * @param float $value
3298 3298
      */
3299
-    public function add_tax( $tax, $value, $recurring = true ) {
3299
+    public function add_tax($tax, $value, $recurring = true) {
3300 3300
 
3301
-        if ( $this->is_taxable() ) {
3301
+        if ($this->is_taxable()) {
3302 3302
 
3303
-            $taxes                 = $this->get_taxes();
3304
-			$taxes[ $tax['name'] ] = $tax;
3305
-			$this->set_prop( 'taxes', $tax );
3303
+            $taxes = $this->get_taxes();
3304
+			$taxes[$tax['name']] = $tax;
3305
+			$this->set_prop('taxes', $tax);
3306 3306
 
3307 3307
         }
3308 3308
 
@@ -3313,15 +3313,15 @@  discard block
 block discarded – undo
3313 3313
 	 *
3314 3314
 	 * @since 1.0.19
3315 3315
 	 */
3316
-	public function get_tax( $tax = null ) {
3316
+	public function get_tax($tax = null) {
3317 3317
 
3318 3318
 		// Backwards compatility.
3319
-		if ( empty( $tax ) ) {
3319
+		if (empty($tax)) {
3320 3320
 			return $this->get_total_tax();
3321 3321
 		}
3322 3322
 
3323 3323
         $taxes = $this->get_taxes();
3324
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3324
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3325 3325
     }
3326 3326
 
3327 3327
     /**
@@ -3329,11 +3329,11 @@  discard block
 block discarded – undo
3329 3329
 	 *
3330 3330
 	 * @since 1.0.19
3331 3331
 	 */
3332
-	public function remove_tax( $tax ) {
3332
+	public function remove_tax($tax) {
3333 3333
         $taxes = $this->get_taxes();
3334
-        if ( isset( $taxes[ $tax ] ) ) {
3335
-            unset( $taxes[ $tax ] );
3336
-            $this->set_prop( 'taxes', $taxes );
3334
+        if (isset($taxes[$tax])) {
3335
+            unset($taxes[$tax]);
3336
+            $this->set_prop('taxes', $taxes);
3337 3337
         }
3338 3338
     }
3339 3339
 
@@ -3344,19 +3344,19 @@  discard block
 block discarded – undo
3344 3344
 	 * @return float The recalculated subtotal
3345 3345
 	 */
3346 3346
 	public function recalculate_subtotal() {
3347
-        $items     = $this->get_items();
3347
+        $items = $this->get_items();
3348 3348
 		$subtotal  = 0;
3349 3349
 		$recurring = 0;
3350 3350
 
3351
-        foreach ( $items as $item ) {
3351
+        foreach ($items as $item) {
3352 3352
 			$subtotal  += $item->get_sub_total();
3353 3353
 			$recurring += $item->get_recurring_sub_total();
3354 3354
         }
3355 3355
 
3356
-		if ( $this->is_renewal() ) {
3357
-			$this->set_subtotal( $recurring );
3356
+		if ($this->is_renewal()) {
3357
+			$this->set_subtotal($recurring);
3358 3358
 		} else {
3359
-			$this->set_subtotal( $subtotal );
3359
+			$this->set_subtotal($subtotal);
3360 3360
 		}
3361 3361
 
3362 3362
 		$this->totals['subtotal'] = array(
@@ -3378,9 +3378,9 @@  discard block
 block discarded – undo
3378 3378
 		$discount  = 0;
3379 3379
 		$recurring = 0;
3380 3380
 
3381
-        foreach ( $discounts as $data ) {
3381
+        foreach ($discounts as $data) {
3382 3382
 
3383
-			if ( $data['recurring'] ) {
3383
+			if ($data['recurring']) {
3384 3384
 				$recurring += $data['amount'];
3385 3385
 			} else {
3386 3386
 				$discount += $data['amount'];
@@ -3388,10 +3388,10 @@  discard block
 block discarded – undo
3388 3388
 
3389 3389
 		}
3390 3390
 
3391
-		if ( $this->is_renewal() ) {
3392
-			$this->set_total_discount( $recurring );
3391
+		if ($this->is_renewal()) {
3392
+			$this->set_total_discount($recurring);
3393 3393
 		} else {
3394
-			$this->set_total_discount( $discount );
3394
+			$this->set_total_discount($discount);
3395 3395
 		}
3396 3396
 
3397 3397
 		$this->totals['discount'] = array(
@@ -3410,13 +3410,13 @@  discard block
 block discarded – undo
3410 3410
 	 * @return float The recalculated tax
3411 3411
 	 */
3412 3412
 	public function recalculate_total_tax() {
3413
-        $taxes     = $this->get_taxes();
3413
+        $taxes = $this->get_taxes();
3414 3414
 		$tax       = 0;
3415 3415
 		$recurring = 0;
3416 3416
 
3417
-        foreach ( $taxes as $data ) {
3417
+        foreach ($taxes as $data) {
3418 3418
 
3419
-			if ( $data['recurring'] ) {
3419
+			if ($data['recurring']) {
3420 3420
 				$recurring += $data['amount'];
3421 3421
 			} else {
3422 3422
 				$tax += $data['amount'];
@@ -3424,10 +3424,10 @@  discard block
 block discarded – undo
3424 3424
 
3425 3425
 		}
3426 3426
 
3427
-		if ( $this->is_renewal() ) {
3428
-			$this->set_total_tax( $recurring );
3427
+		if ($this->is_renewal()) {
3428
+			$this->set_total_tax($recurring);
3429 3429
 		} else {
3430
-			$this->set_total_tax( $tax );
3430
+			$this->set_total_tax($tax);
3431 3431
 		}
3432 3432
 
3433 3433
 		$this->totals['tax'] = array(
@@ -3450,9 +3450,9 @@  discard block
 block discarded – undo
3450 3450
 		$fee       = 0;
3451 3451
 		$recurring = 0;
3452 3452
 
3453
-        foreach ( $fees as $data ) {
3453
+        foreach ($fees as $data) {
3454 3454
 
3455
-			if ( $data['recurring'] ) {
3455
+			if ($data['recurring']) {
3456 3456
 				$recurring += $data['amount'];
3457 3457
 			} else {
3458 3458
 				$fee += $data['amount'];
@@ -3460,10 +3460,10 @@  discard block
 block discarded – undo
3460 3460
 
3461 3461
 		}
3462 3462
 
3463
-        if ( $this->is_renewal() ) {
3464
-			$this->set_total_fees( $recurring );
3463
+        if ($this->is_renewal()) {
3464
+			$this->set_total_fees($recurring);
3465 3465
 		} else {
3466
-			$this->set_total_fees( $fee );
3466
+			$this->set_total_fees($fee);
3467 3467
 		}
3468 3468
 
3469 3469
 		$this->totals['fee'] = array(
@@ -3471,7 +3471,7 @@  discard block
 block discarded – undo
3471 3471
 			'recurring' => $recurring,
3472 3472
 		);
3473 3473
 
3474
-        $this->set_total_fees( $fee );
3474
+        $this->set_total_fees($fee);
3475 3475
         return $this->is_renewal() ? $recurring : $fee;
3476 3476
     }
3477 3477
 
@@ -3492,9 +3492,9 @@  discard block
 block discarded – undo
3492 3492
 	/**
3493 3493
 	 * @deprecated
3494 3494
 	 */
3495
-    public function recalculate_totals( $temp = false ) {
3496
-        $this->update_items( $temp );
3497
-        $this->save( true );
3495
+    public function recalculate_totals($temp = false) {
3496
+        $this->update_items($temp);
3497
+        $this->save(true);
3498 3498
         return $this;
3499 3499
     }
3500 3500
 
@@ -3512,10 +3512,10 @@  discard block
 block discarded – undo
3512 3512
 	 * @return int|false The new note's ID on success, false on failure.
3513 3513
      *
3514 3514
      */
3515
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3515
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3516 3516
 
3517 3517
         // Bail if no note specified or this invoice is not yet saved.
3518
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3518
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3519 3519
             return false;
3520 3520
         }
3521 3521
 
@@ -3523,23 +3523,23 @@  discard block
 block discarded – undo
3523 3523
 		$author_email = '[email protected]';
3524 3524
 
3525 3525
 		// If this is an admin comment or it has been added by the user.
3526
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3527
-			$user         = get_user_by( 'id', get_current_user_id() );
3526
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3527
+			$user = get_user_by('id', get_current_user_id());
3528 3528
             $author       = $user->display_name;
3529 3529
             $author_email = $user->user_email;
3530 3530
 		}
3531 3531
 
3532
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3532
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3533 3533
 
3534 3534
 	}
3535 3535
 
3536 3536
 	/**
3537 3537
      * Generates a unique key for the invoice.
3538 3538
      */
3539
-    public function generate_key( $string = '' ) {
3540
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3539
+    public function generate_key($string = '') {
3540
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3541 3541
         return strtolower(
3542
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3542
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3543 3543
         );
3544 3544
     }
3545 3545
 
@@ -3549,11 +3549,11 @@  discard block
 block discarded – undo
3549 3549
     public function generate_number() {
3550 3550
         $number = $this->get_id();
3551 3551
 
3552
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3553
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3552
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3553
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3554 3554
         }
3555 3555
 
3556
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3556
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3557 3557
 
3558 3558
 	}
3559 3559
 
@@ -3566,55 +3566,55 @@  discard block
 block discarded – undo
3566 3566
 		// Reset status transition variable.
3567 3567
 		$this->status_transition = false;
3568 3568
 
3569
-		if ( $status_transition ) {
3569
+		if ($status_transition) {
3570 3570
 			try {
3571 3571
 
3572 3572
 				// Fire a hook for the status change.
3573
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3573
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3574 3574
 
3575 3575
 				// @deprecated this is deprecated and will be removed in the future.
3576
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3576
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3577 3577
 
3578
-				if ( ! empty( $status_transition['from'] ) ) {
3578
+				if (!empty($status_transition['from'])) {
3579 3579
 
3580 3580
 					/* translators: 1: old invoice status 2: new invoice status */
3581
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3581
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to']));
3582 3582
 
3583 3583
 					// Fire another hook.
3584
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3585
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3584
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3585
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3586 3586
 
3587 3587
 					// @deprecated this is deprecated and will be removed in the future.
3588
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3588
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3589 3589
 
3590 3590
 					// Note the transition occurred.
3591
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3591
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3592 3592
 
3593 3593
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3594 3594
 					if (
3595
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3596
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3595
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3596
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3597 3597
 					) {
3598
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3598
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3599 3599
 					}
3600 3600
 
3601 3601
 					// Work out if this was for a payment reversal, and trigger a payment_status_reversed hook instead.
3602 3602
 					if (
3603
-						in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3604
-						&& in_array( $status_transition['to'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold' ), true )
3603
+						in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3604
+						&& in_array($status_transition['to'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded', 'wpi-onhold'), true)
3605 3605
 					) {
3606
-						do_action( 'getpaid_invoice_payment_status_reversed', $this, $status_transition );
3606
+						do_action('getpaid_invoice_payment_status_reversed', $this, $status_transition);
3607 3607
 					}
3608 3608
 				} else {
3609 3609
 					/* translators: %s: new invoice status */
3610
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3610
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to']));
3611 3611
 
3612 3612
 					// Note the transition occurred.
3613
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3613
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3614 3614
 
3615 3615
 				}
3616
-			} catch ( Exception $e ) {
3617
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3616
+			} catch (Exception $e) {
3617
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3618 3618
 			}
3619 3619
 		}
3620 3620
 	}
@@ -3622,13 +3622,13 @@  discard block
 block discarded – undo
3622 3622
 	/**
3623 3623
 	 * Updates an invoice status.
3624 3624
 	 */
3625
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3625
+	public function update_status($new_status = false, $note = '', $manual = false) {
3626 3626
 
3627 3627
 		// Fires before updating a status.
3628
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3628
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3629 3629
 
3630 3630
 		// Update the status.
3631
-		$this->set_status( $new_status, $note, $manual );
3631
+		$this->set_status($new_status, $note, $manual);
3632 3632
 
3633 3633
 		// Save the order.
3634 3634
 		return $this->save();
@@ -3639,18 +3639,18 @@  discard block
 block discarded – undo
3639 3639
 	 * @deprecated
3640 3640
 	 */
3641 3641
 	public function refresh_item_ids() {
3642
-        $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3643
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3642
+        $item_ids = implode(',', array_unique(array_keys($this->get_items())));
3643
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3644 3644
 	}
3645 3645
 
3646 3646
 	/**
3647 3647
 	 * @deprecated
3648 3648
 	 */
3649
-	public function update_items( $temp = false ) {
3649
+	public function update_items($temp = false) {
3650 3650
 
3651
-		$this->set_items( $this->get_items() );
3651
+		$this->set_items($this->get_items());
3652 3652
 
3653
-		if ( ! $temp ) {
3653
+		if (!$temp) {
3654 3654
 			$this->save();
3655 3655
 		}
3656 3656
 
@@ -3664,11 +3664,11 @@  discard block
 block discarded – undo
3664 3664
 
3665 3665
         $discount_code = $this->get_discount_code();
3666 3666
 
3667
-        if ( empty( $discount_code ) ) {
3667
+        if (empty($discount_code)) {
3668 3668
             return false;
3669 3669
         }
3670 3670
 
3671
-        $discount = wpinv_get_discount_obj( $discount_code );
3671
+        $discount = wpinv_get_discount_obj($discount_code);
3672 3672
 
3673 3673
         // Ensure it is active.
3674 3674
         return $discount->exists();
@@ -3679,7 +3679,7 @@  discard block
 block discarded – undo
3679 3679
 	 * Refunds an invoice.
3680 3680
 	 */
3681 3681
     public function refund() {
3682
-		$this->set_status( 'wpi-refunded' );
3682
+		$this->set_status('wpi-refunded');
3683 3683
         $this->save();
3684 3684
 	}
3685 3685
 
@@ -3688,56 +3688,56 @@  discard block
 block discarded – undo
3688 3688
 	 * 
3689 3689
 	 * @param string $transaction_id
3690 3690
 	 */
3691
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3691
+    public function mark_paid($transaction_id = null, $note = '') {
3692 3692
 
3693 3693
 		// Set the transaction id.
3694
-		if ( empty( $transaction_id ) ) {
3694
+		if (empty($transaction_id)) {
3695 3695
 			$transaction_id = $this->generate_key('trans_');
3696 3696
 		}
3697 3697
 
3698
-		if ( ! $this->get_transaction_id() ) {
3699
-			$this->set_transaction_id( $transaction_id );
3698
+		if (!$this->get_transaction_id()) {
3699
+			$this->set_transaction_id($transaction_id);
3700 3700
 		}
3701 3701
 
3702
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3702
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3703 3703
 			return $this->save();
3704 3704
 		}
3705 3705
 
3706 3706
 		// Set the completed date.
3707
-		$this->set_date_completed( current_time( 'mysql' ) );
3707
+		$this->set_date_completed(current_time('mysql'));
3708 3708
 
3709 3709
 		// Set the new status.
3710
-		if ( $this->is_renewal() ) {
3710
+		if ($this->is_renewal()) {
3711 3711
 
3712 3712
 			$_note = sprintf(
3713
-				__( 'Renewed via %s', 'invoicing' ),
3714
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3713
+				__('Renewed via %s', 'invoicing'),
3714
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3715 3715
 			);
3716 3716
 
3717
-			if ( 'none' == $this->get_gateway() ) {
3717
+			if ('none' == $this->get_gateway()) {
3718 3718
 				$_note = $note;
3719 3719
 			}
3720 3720
 
3721
-			$this->set_status( 'wpi-renewal', $_note );
3721
+			$this->set_status('wpi-renewal', $_note);
3722 3722
 
3723 3723
 		} else {
3724 3724
 
3725 3725
 			$_note = sprintf(
3726
-				__( 'Paid via %s', 'invoicing' ),
3727
-				$this->get_gateway() . empty( $note ) ? '' : " ($note)"
3726
+				__('Paid via %s', 'invoicing'),
3727
+				$this->get_gateway() . empty($note) ? '' : " ($note)"
3728 3728
 			);
3729 3729
 
3730
-			if ( 'none' == $this->get_gateway() ) {
3730
+			if ('none' == $this->get_gateway()) {
3731 3731
 				$_note = $note;
3732 3732
 			}
3733 3733
 
3734
-			$this->set_status( 'publish',$_note );
3734
+			$this->set_status('publish', $_note);
3735 3735
 
3736 3736
 		}
3737 3737
 
3738 3738
 		// Set checkout mode.
3739
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3740
-		$this->set_mode( $mode );
3739
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3740
+		$this->set_mode($mode);
3741 3741
 
3742 3742
 		// Save the invoice.
3743 3743
         $this->save();
@@ -3763,9 +3763,9 @@  discard block
 block discarded – undo
3763 3763
      * Clears the subscription's cache.
3764 3764
      */
3765 3765
     public function clear_cache() {
3766
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3767
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3768
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3766
+		wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
3767
+		wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
3768
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
3769 3769
 	}
3770 3770
 
3771 3771
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-fees.php 2 patches
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -12,119 +12,119 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Fees {
14 14
 
15
-	/**
16
-	 * The fee validation error.
17
-	 * @var string
18
-	 */
19
-	public $fee_error;
20
-
21
-	/**
22
-	 * Submission fees.
23
-	 * @var array
24
-	 */
25
-	public $fees = array();
15
+    /**
16
+     * The fee validation error.
17
+     * @var string
18
+     */
19
+    public $fee_error;
20
+
21
+    /**
22
+     * Submission fees.
23
+     * @var array
24
+     */
25
+    public $fees = array();
26
+
27
+    /**
28
+     * Class constructor
29
+     *
30
+     * @param GetPaid_Payment_Form_Submission $submission
31
+     */
32
+    public function __construct( $submission ) {
33
+
34
+        // Process any existing invoice fees.
35
+        if ( $submission->has_invoice() ) {
36
+            $this->fees = $submission->get_invoice()->get_fees();
37
+        }
38
+
39
+        // Process price fields.
40
+        $data         = $submission->get_data();
41
+        $payment_form = $submission->get_payment_form();
42
+
43
+        foreach ( $payment_form->get_elements() as $element ) {
44
+
45
+            if ( 'price_input' == $element['type'] ) {
46
+                $this->process_price_input( $element, $data );
47
+            }
48
+
49
+            if ( 'price_select' == $element['type'] ) {
50
+                $this->process_price_select( $element, $data );
51
+            }
52
+
53
+        }
54
+
55
+    }
56
+
57
+    /**
58
+     * Process a price input field.
59
+     *
60
+     * @param array $element
61
+     * @param array $data
62
+     */
63
+    public function process_price_input( $element, $data ) {
64
+
65
+        // Abort if not passed.
66
+        if ( empty( $data[ $element['id'] ] ) ) {
67
+            return;
68
+        }
69
+
70
+        $amount  = (float) wpinv_sanitize_amount( $data[ $element['id'] ] );
71
+        $minimum = (float) wpinv_sanitize_amount( $element['minimum'] );
72
+
73
+        if ( $amount < $minimum ) {
74
+            return $this->set_error( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), $minimum ) );
75
+        }
76
+
77
+        $this['fees'][ $element['label'] ] = array(
78
+            'name'          => $element['label'],
79
+            'initial_fee'   => $amount,
80
+            'recurring_fee' => 0,
81
+        );
82
+
83
+    }
84
+
85
+    /**
86
+     * Process a price select field.
87
+     *
88
+     * @param array $element
89
+     * @param array $data
90
+     */
91
+    public function process_price_select( $element, $data ) {
92
+
93
+        // Abort if not passed.
94
+        if ( empty( $data[ $element['id'] ] ) ) {
95
+            return;
96
+        }
97
+
98
+        $options  = getpaid_convert_price_string_to_options( $element['options'] );
99
+        $selected = wpinv_parse_list( $data[ $element['id'] ] );
100
+        $total    = 0;
101
+
102
+        foreach ( $selected as $price ) {
103
+
104
+            if ( ! isset( $options[ $price ] ) ) {
105
+                return $this->set_error( __( 'You have selected an invalid amount', 'invoicing' ) );
106
+            }
107
+
108
+            $total += (float) wpinv_sanitize_amount( $price );
109
+        }
110
+
111
+        $this['fees'][ $element['label'] ] = array(
112
+            'name'          => $element['label'],
113
+            'initial_fee'   => $total,
114
+            'recurring_fee' => 0,
115
+        );
116
+
117
+    }
26 118
 
27 119
     /**
28
-	 * Class constructor
29
-	 *
30
-	 * @param GetPaid_Payment_Form_Submission $submission
31
-	 */
32
-	public function __construct( $submission ) {
33
-
34
-		// Process any existing invoice fees.
35
-		if ( $submission->has_invoice() ) {
36
-			$this->fees = $submission->get_invoice()->get_fees();
37
-		}
38
-
39
-		// Process price fields.
40
-		$data         = $submission->get_data();
41
-		$payment_form = $submission->get_payment_form();
42
-
43
-		foreach ( $payment_form->get_elements() as $element ) {
44
-
45
-			if ( 'price_input' == $element['type'] ) {
46
-				$this->process_price_input( $element, $data );
47
-			}
48
-
49
-			if ( 'price_select' == $element['type'] ) {
50
-				$this->process_price_select( $element, $data );
51
-			}
52
-
53
-		}
54
-
55
-	}
56
-
57
-	/**
58
-	 * Process a price input field.
59
-	 *
60
-	 * @param array $element
61
-	 * @param array $data
62
-	 */
63
-	public function process_price_input( $element, $data ) {
64
-
65
-		// Abort if not passed.
66
-		if ( empty( $data[ $element['id'] ] ) ) {
67
-			return;
68
-		}
69
-
70
-		$amount  = (float) wpinv_sanitize_amount( $data[ $element['id'] ] );
71
-		$minimum = (float) wpinv_sanitize_amount( $element['minimum'] );
72
-
73
-		if ( $amount < $minimum ) {
74
-			return $this->set_error( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), $minimum ) );
75
-		}
76
-
77
-		$this['fees'][ $element['label'] ] = array(
78
-			'name'          => $element['label'],
79
-			'initial_fee'   => $amount,
80
-			'recurring_fee' => 0,
81
-		);
82
-
83
-	}
84
-
85
-	/**
86
-	 * Process a price select field.
87
-	 *
88
-	 * @param array $element
89
-	 * @param array $data
90
-	 */
91
-	public function process_price_select( $element, $data ) {
92
-
93
-		// Abort if not passed.
94
-		if ( empty( $data[ $element['id'] ] ) ) {
95
-			return;
96
-		}
97
-
98
-		$options  = getpaid_convert_price_string_to_options( $element['options'] );
99
-		$selected = wpinv_parse_list( $data[ $element['id'] ] );
100
-		$total    = 0;
101
-
102
-		foreach ( $selected as $price ) {
103
-
104
-			if ( ! isset( $options[ $price ] ) ) {
105
-				return $this->set_error( __( 'You have selected an invalid amount', 'invoicing' ) );
106
-			}
107
-
108
-			$total += (float) wpinv_sanitize_amount( $price );
109
-		}
110
-
111
-		$this['fees'][ $element['label'] ] = array(
112
-			'name'          => $element['label'],
113
-			'initial_fee'   => $total,
114
-			'recurring_fee' => 0,
115
-		);
116
-
117
-	}
118
-
119
-	/**
120
-	 * Sets an error without overwriting the previous error.
121
-	 *
122
-	 * @param string $error
123
-	 */
124
-	public function set_error( $error ) {
125
-		if ( empty( $this->fee_error ) ) {
126
-			$this->fee_error    = $error;
127
-		}
128
-	}
120
+     * Sets an error without overwriting the previous error.
121
+     *
122
+     * @param string $error
123
+     */
124
+    public function set_error( $error ) {
125
+        if ( empty( $this->fee_error ) ) {
126
+            $this->fee_error    = $error;
127
+        }
128
+    }
129 129
 
130 130
 }
Please login to merge, or discard this patch.
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission fees class
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 	 *
30 30
 	 * @param GetPaid_Payment_Form_Submission $submission
31 31
 	 */
32
-	public function __construct( $submission ) {
32
+	public function __construct($submission) {
33 33
 
34 34
 		// Process any existing invoice fees.
35
-		if ( $submission->has_invoice() ) {
35
+		if ($submission->has_invoice()) {
36 36
 			$this->fees = $submission->get_invoice()->get_fees();
37 37
 		}
38 38
 
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
 		$data         = $submission->get_data();
41 41
 		$payment_form = $submission->get_payment_form();
42 42
 
43
-		foreach ( $payment_form->get_elements() as $element ) {
43
+		foreach ($payment_form->get_elements() as $element) {
44 44
 
45
-			if ( 'price_input' == $element['type'] ) {
46
-				$this->process_price_input( $element, $data );
45
+			if ('price_input' == $element['type']) {
46
+				$this->process_price_input($element, $data);
47 47
 			}
48 48
 
49
-			if ( 'price_select' == $element['type'] ) {
50
-				$this->process_price_select( $element, $data );
49
+			if ('price_select' == $element['type']) {
50
+				$this->process_price_select($element, $data);
51 51
 			}
52 52
 
53 53
 		}
@@ -60,21 +60,21 @@  discard block
 block discarded – undo
60 60
 	 * @param array $element
61 61
 	 * @param array $data
62 62
 	 */
63
-	public function process_price_input( $element, $data ) {
63
+	public function process_price_input($element, $data) {
64 64
 
65 65
 		// Abort if not passed.
66
-		if ( empty( $data[ $element['id'] ] ) ) {
66
+		if (empty($data[$element['id']])) {
67 67
 			return;
68 68
 		}
69 69
 
70
-		$amount  = (float) wpinv_sanitize_amount( $data[ $element['id'] ] );
71
-		$minimum = (float) wpinv_sanitize_amount( $element['minimum'] );
70
+		$amount  = (float) wpinv_sanitize_amount($data[$element['id']]);
71
+		$minimum = (float) wpinv_sanitize_amount($element['minimum']);
72 72
 
73
-		if ( $amount < $minimum ) {
74
-			return $this->set_error( sprintf( __( 'The minimum allowed amount is %s', 'invoicing' ), $minimum ) );
73
+		if ($amount < $minimum) {
74
+			return $this->set_error(sprintf(__('The minimum allowed amount is %s', 'invoicing'), $minimum));
75 75
 		}
76 76
 
77
-		$this['fees'][ $element['label'] ] = array(
77
+		$this['fees'][$element['label']] = array(
78 78
 			'name'          => $element['label'],
79 79
 			'initial_fee'   => $amount,
80 80
 			'recurring_fee' => 0,
@@ -88,27 +88,27 @@  discard block
 block discarded – undo
88 88
 	 * @param array $element
89 89
 	 * @param array $data
90 90
 	 */
91
-	public function process_price_select( $element, $data ) {
91
+	public function process_price_select($element, $data) {
92 92
 
93 93
 		// Abort if not passed.
94
-		if ( empty( $data[ $element['id'] ] ) ) {
94
+		if (empty($data[$element['id']])) {
95 95
 			return;
96 96
 		}
97 97
 
98
-		$options  = getpaid_convert_price_string_to_options( $element['options'] );
99
-		$selected = wpinv_parse_list( $data[ $element['id'] ] );
98
+		$options  = getpaid_convert_price_string_to_options($element['options']);
99
+		$selected = wpinv_parse_list($data[$element['id']]);
100 100
 		$total    = 0;
101 101
 
102
-		foreach ( $selected as $price ) {
102
+		foreach ($selected as $price) {
103 103
 
104
-			if ( ! isset( $options[ $price ] ) ) {
105
-				return $this->set_error( __( 'You have selected an invalid amount', 'invoicing' ) );
104
+			if (!isset($options[$price])) {
105
+				return $this->set_error(__('You have selected an invalid amount', 'invoicing'));
106 106
 			}
107 107
 
108
-			$total += (float) wpinv_sanitize_amount( $price );
108
+			$total += (float) wpinv_sanitize_amount($price);
109 109
 		}
110 110
 
111
-		$this['fees'][ $element['label'] ] = array(
111
+		$this['fees'][$element['label']] = array(
112 112
 			'name'          => $element['label'],
113 113
 			'initial_fee'   => $total,
114 114
 			'recurring_fee' => 0,
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
 	 *
122 122
 	 * @param string $error
123 123
 	 */
124
-	public function set_error( $error ) {
125
-		if ( empty( $this->fee_error ) ) {
126
-			$this->fee_error    = $error;
124
+	public function set_error($error) {
125
+		if (empty($this->fee_error)) {
126
+			$this->fee_error = $error;
127 127
 		}
128 128
 	}
129 129
 
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-taxes.php 2 patches
Indentation   +233 added lines, -233 removed lines patch added patch discarded remove patch
@@ -12,252 +12,252 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Taxes {
14 14
 
15
-	/**
16
-	 * The tax validation error.
17
-	 * @var string
18
-	 */
19
-	public $tax_error;
20
-
21
-	/**
22
-	 * Submission taxes.
23
-	 * @var array
24
-	 */
25
-	public $taxes = array();
26
-
27
-	/**
28
-	 * Initial tax.
29
-	 * @var float
30
-	 */
31
-	protected $initial_tax = 0;
32
-
33
-	/**
34
-	 * Recurring tax.
35
-	 * @var float
36
-	 */
37
-	protected $recurring_tax = 0;
15
+    /**
16
+     * The tax validation error.
17
+     * @var string
18
+     */
19
+    public $tax_error;
20
+
21
+    /**
22
+     * Submission taxes.
23
+     * @var array
24
+     */
25
+    public $taxes = array();
26
+
27
+    /**
28
+     * Initial tax.
29
+     * @var float
30
+     */
31
+    protected $initial_tax = 0;
32
+
33
+    /**
34
+     * Recurring tax.
35
+     * @var float
36
+     */
37
+    protected $recurring_tax = 0;
38
+
39
+    /**
40
+     * Class constructor
41
+     *
42
+     * @param GetPaid_Payment_Form_Submission $submission
43
+     */
44
+    public function __construct( $submission ) {
45
+
46
+        // Make sure that taxes are enabled.
47
+        if ( ! $submission->use_taxes() ) {
48
+            return;
49
+        }
50
+
51
+        // Validate VAT number.
52
+        $this->validate_vat( $submission );
53
+
54
+        foreach ( $submission->get_items() as $item ) {
55
+            $this->process_item_tax( $item, $submission );
56
+        }
57
+
58
+        // Process any existing invoice taxes.
59
+        if ( $submission->has_invoice() ) {
60
+            $this->taxes = $submission->get_invoice()->get_taxes();
61
+        }
62
+
63
+        // Add VAT.
64
+        $this->taxes['vat'] = array(
65
+            'name'          => 'vat',
66
+            'initial_tax'   => $this->initial_tax,
67
+            'recurring_tax' => $this->recurring_tax,
68
+        );
69
+
70
+    }
71
+
72
+    /**
73
+     * Maybe process tax.
74
+     *
75
+     * @since 1.0.19
76
+     * @param GetPaid_Form_Item $item
77
+     * @param GetPaid_Payment_Form_Submission $submission
78
+     */
79
+    public function process_item_tax( $item, $submission ) {
80
+
81
+        // Abort early if an error occurred.
82
+        if ( ! empty( $this->tax_error ) ) {
83
+            return;
84
+        }
85
+
86
+        $rate     = wpinv_get_tax_rate( $submission->country, $submission->state, $item->get_id() );
87
+        $price    = $item->get_sub_total();
88
+        $item_tax = $price * $rate * 0.01;
89
+
90
+        if ( wpinv_prices_include_tax() ) {
91
+            $item_tax = $price - ( $price - $price * $rate * 0.01 );
92
+        }
93
+
94
+        $this->initial_tax += $item_tax;
95
+
96
+        if ( $item->is_recurring() ) {
97
+            $this->recurring_tax += $item_tax;
98
+        }
99
+
100
+    }
101
+
102
+    /**
103
+     * Sets an error without overwriting the previous error.
104
+     *
105
+     * @param string $error
106
+     */
107
+    public function set_error( $error ) {
108
+        if ( empty( $this->tax_error ) ) {
109
+            $this->tax_error = $error;
110
+        }
111
+    }
112
+
113
+    /**
114
+     * Checks if the submission has a digital item.
115
+     *
116
+     * @param GetPaid_Payment_Form_Submission $submission
117
+     * @since 1.0.19
118
+     * @return bool
119
+     */
120
+    public function has_digital_item( $submission ) {
121
+
122
+        foreach ( $submission->get_items() as $item ) {
123
+
124
+            if ( 'digital' == $item->get_vat_rule() ) {
125
+                return true;
126
+                break;
127
+            }
128
+
129
+        }
130
+
131
+        return false;
132
+    }
133
+
134
+    /**
135
+     * Checks if this is an eu purchase.
136
+     *
137
+     * @param GetPaid_Payment_Form_Submission $submission
138
+     * @param bool                            $has_digital
139
+     * @since 1.0.19
140
+     * @return bool
141
+     */
142
+    public function is_eu_transaction( $submission, $has_digital ) {
143
+
144
+        // Both from EU.
145
+        if ( getpaid_is_eu_state( $submission->country ) && ( getpaid_is_eu_state( wpinv_get_default_country() ) || $has_digital ) ) {
146
+            return true;
147
+        }
148
+
149
+        // Both from GST.
150
+        if ( getpaid_is_gst_country( $submission->country ) && getpaid_is_gst_country( wpinv_get_default_country() ) ) {
151
+            return true;
152
+        }
153
+
154
+        return false;
155
+    }
156
+
157
+    /**
158
+     * Retrieves the vat number.
159
+     *
160
+     * @param GetPaid_Payment_Form_Submission $submission
161
+     * @since 1.0.19
162
+     * @return string
163
+     */
164
+    public function get_vat_number( $submission ) {
165
+
166
+        $data = $submission->get_data();
167
+
168
+        // Retrieve from the posted number.
169
+        if ( ! empty( $data['wpinv_vat_number'] ) ) {
170
+            return wpinv_clean( $data['wpinv_vat_number'] );
171
+        }
172
+
173
+        // Retrieve from the invoice.
174
+        return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : '';
175
+    }
176
+
177
+    /**
178
+     * Retrieves the company.
179
+     *
180
+     * @param GetPaid_Payment_Form_Submission $submission
181
+     * @since 1.0.19
182
+     * @return string
183
+     */
184
+    public function get_company( $submission ) {
185
+
186
+        $data = $submission->get_data();
187
+
188
+        // Retrieve from the posted data.
189
+        if ( ! empty( $data['wpinv_company'] ) ) {
190
+            return wpinv_clean( $data['wpinv_company'] );
191
+        }
192
+
193
+        // Retrieve from the invoice.
194
+        return $submission->has_invoice() ? $submission->get_invoice()->get_company() : '';
195
+    }
196
+
197
+    /**
198
+     * Retrieves the company.
199
+     *
200
+     * @param bool $ip_in_eu Whether the selected IP is from the EU
201
+     * @param bool $country_in_eu Whether the selected country is from the EU
202
+     * @since 1.0.19
203
+     * @return string
204
+     */
205
+    public function requires_vat( $ip_in_eu, $country_in_eu ) {
206
+
207
+        $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
208
+        $prevent_b2c = ! empty( $prevent_b2c );
209
+        $is_eu       = $ip_in_eu || $country_in_eu;
210
+
211
+        return $prevent_b2c && $is_eu;
212
+    }
38 213
 
39 214
     /**
40
-	 * Class constructor
41
-	 *
42
-	 * @param GetPaid_Payment_Form_Submission $submission
43
-	 */
44
-	public function __construct( $submission ) {
45
-
46
-		// Make sure that taxes are enabled.
47
-		if ( ! $submission->use_taxes() ) {
48
-			return;
49
-		}
50
-
51
-		// Validate VAT number.
52
-		$this->validate_vat( $submission );
53
-
54
-		foreach ( $submission->get_items() as $item ) {
55
-			$this->process_item_tax( $item, $submission );
56
-		}
57
-
58
-		// Process any existing invoice taxes.
59
-		if ( $submission->has_invoice() ) {
60
-			$this->taxes = $submission->get_invoice()->get_taxes();
61
-		}
62
-
63
-		// Add VAT.
64
-		$this->taxes['vat'] = array(
65
-			'name'          => 'vat',
66
-			'initial_tax'   => $this->initial_tax,
67
-			'recurring_tax' => $this->recurring_tax,
68
-		);
69
-
70
-	}
71
-
72
-	/**
73
-	 * Maybe process tax.
74
-	 *
75
-	 * @since 1.0.19
76
-	 * @param GetPaid_Form_Item $item
77
-	 * @param GetPaid_Payment_Form_Submission $submission
78
-	 */
79
-	public function process_item_tax( $item, $submission ) {
80
-
81
-		// Abort early if an error occurred.
82
-		if ( ! empty( $this->tax_error ) ) {
83
-			return;
84
-		}
85
-
86
-		$rate     = wpinv_get_tax_rate( $submission->country, $submission->state, $item->get_id() );
87
-		$price    = $item->get_sub_total();
88
-		$item_tax = $price * $rate * 0.01;
89
-
90
-		if ( wpinv_prices_include_tax() ) {
91
-			$item_tax = $price - ( $price - $price * $rate * 0.01 );
92
-		}
93
-
94
-		$this->initial_tax += $item_tax;
95
-
96
-		if ( $item->is_recurring() ) {
97
-			$this->recurring_tax += $item_tax;
98
-		}
99
-
100
-	}
101
-
102
-	/**
103
-	 * Sets an error without overwriting the previous error.
104
-	 *
105
-	 * @param string $error
106
-	 */
107
-	public function set_error( $error ) {
108
-		if ( empty( $this->tax_error ) ) {
109
-			$this->tax_error = $error;
110
-		}
111
-	}
112
-
113
-	/**
114
-	 * Checks if the submission has a digital item.
115
-	 *
116
-	 * @param GetPaid_Payment_Form_Submission $submission
117
-	 * @since 1.0.19
118
-	 * @return bool
119
-	 */
120
-	public function has_digital_item( $submission ) {
121
-
122
-		foreach ( $submission->get_items() as $item ) {
123
-
124
-			if ( 'digital' == $item->get_vat_rule() ) {
125
-				return true;
126
-				break;
127
-			}
128
-
129
-		}
130
-
131
-		return false;
132
-	}
133
-
134
-	/**
135
-	 * Checks if this is an eu purchase.
136
-	 *
137
-	 * @param GetPaid_Payment_Form_Submission $submission
138
-	 * @param bool                            $has_digital
139
-	 * @since 1.0.19
140
-	 * @return bool
141
-	 */
142
-	public function is_eu_transaction( $submission, $has_digital ) {
143
-
144
-		// Both from EU.
145
-		if ( getpaid_is_eu_state( $submission->country ) && ( getpaid_is_eu_state( wpinv_get_default_country() ) || $has_digital ) ) {
146
-			return true;
147
-		}
148
-
149
-		// Both from GST.
150
-		if ( getpaid_is_gst_country( $submission->country ) && getpaid_is_gst_country( wpinv_get_default_country() ) ) {
151
-			return true;
152
-		}
153
-
154
-		return false;
155
-	}
156
-
157
-	/**
158
-	 * Retrieves the vat number.
159
-	 *
160
-	 * @param GetPaid_Payment_Form_Submission $submission
161
-	 * @since 1.0.19
162
-	 * @return string
163
-	 */
164
-	public function get_vat_number( $submission ) {
165
-
166
-		$data = $submission->get_data();
167
-
168
-		// Retrieve from the posted number.
169
-		if ( ! empty( $data['wpinv_vat_number'] ) ) {
170
-			return wpinv_clean( $data['wpinv_vat_number'] );
171
-		}
172
-
173
-		// Retrieve from the invoice.
174
-		return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : '';
175
-	}
176
-
177
-	/**
178
-	 * Retrieves the company.
179
-	 *
180
-	 * @param GetPaid_Payment_Form_Submission $submission
181
-	 * @since 1.0.19
182
-	 * @return string
183
-	 */
184
-	public function get_company( $submission ) {
185
-
186
-		$data = $submission->get_data();
187
-
188
-		// Retrieve from the posted data.
189
-		if ( ! empty( $data['wpinv_company'] ) ) {
190
-			return wpinv_clean( $data['wpinv_company'] );
191
-		}
192
-
193
-		// Retrieve from the invoice.
194
-		return $submission->has_invoice() ? $submission->get_invoice()->get_company() : '';
195
-	}
196
-
197
-	/**
198
-	 * Retrieves the company.
199
-	 *
200
-	 * @param bool $ip_in_eu Whether the selected IP is from the EU
201
-	 * @param bool $country_in_eu Whether the selected country is from the EU
202
-	 * @since 1.0.19
203
-	 * @return string
204
-	 */
205
-	public function requires_vat( $ip_in_eu, $country_in_eu ) {
206
-
207
-		$prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
208
-		$prevent_b2c = ! empty( $prevent_b2c );
209
-		$is_eu       = $ip_in_eu || $country_in_eu;
210
-
211
-		return $prevent_b2c && $is_eu;
212
-	}
213
-
214
-	/**
215
-	 * Validate VAT data.
216
-	 *
217
-	 * @param GetPaid_Payment_Form_Submission $submission
218
-	 * @since 1.0.19
219
-	 */
220
-	public function validate_vat( $submission ) {
221
-
222
-		$has_digital = $this->has_digital_item( $submission );
223
-		$in_eu       = $this->is_eu_transaction( $submission, $has_digital );
224
-
225
-		// Abort if we are not validating vat numbers.
226
-		if ( ! $has_digital && ! $in_eu ) {
215
+     * Validate VAT data.
216
+     *
217
+     * @param GetPaid_Payment_Form_Submission $submission
218
+     * @since 1.0.19
219
+     */
220
+    public function validate_vat( $submission ) {
221
+
222
+        $has_digital = $this->has_digital_item( $submission );
223
+        $in_eu       = $this->is_eu_transaction( $submission, $has_digital );
224
+
225
+        // Abort if we are not validating vat numbers.
226
+        if ( ! $has_digital && ! $in_eu ) {
227 227
             return;
228
-		}
228
+        }
229 229
 
230
-		// Prepare variables.
231
-		$vat_number  = $this->get_vat_number( $submission );
232
-		$company     = $this->get_company( $submission );
233
-		$ip_country  = WPInv_EUVat::get_country_by_ip();
230
+        // Prepare variables.
231
+        $vat_number  = $this->get_vat_number( $submission );
232
+        $company     = $this->get_company( $submission );
233
+        $ip_country  = WPInv_EUVat::get_country_by_ip();
234 234
         $is_eu       = getpaid_is_eu_state( $submission->country );
235 235
         $is_ip_eu    = getpaid_is_eu_state( $ip_country );
236 236
 
237
-		// If we're preventing business to consumer purchases, ensure
238
-		if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
237
+        // If we're preventing business to consumer purchases, ensure
238
+        if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
239 239
 
240
-			// Ensure that a vat number has been specified.
241
-			return $this->set_error(
242
-				wp_sprintf(
243
-					__( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
244
-					getpaid_vat_name()
245
-				)
246
-			);
240
+            // Ensure that a vat number has been specified.
241
+            return $this->set_error(
242
+                wp_sprintf(
243
+                    __( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
244
+                    getpaid_vat_name()
245
+                )
246
+            );
247 247
 
248
-		}
248
+        }
249 249
 
250
-		// Abort if we are not validating vat (vat number should exist, user should be in eu and business too).
251
-		if ( ! $is_eu || ! $in_eu || empty( $vat_number ) ) {
250
+        // Abort if we are not validating vat (vat number should exist, user should be in eu and business too).
251
+        if ( ! $is_eu || ! $in_eu || empty( $vat_number ) ) {
252 252
             return;
253
-		}
253
+        }
254 254
 
255
-		$is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $submission->country );
255
+        $is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $submission->country );
256 256
 
257
-		if ( is_string( $is_valid ) ) {
258
-			$this->set_error( $is_valid );
259
-		}
257
+        if ( is_string( $is_valid ) ) {
258
+            $this->set_error( $is_valid );
259
+        }
260 260
 
261
-	}
261
+    }
262 262
 
263 263
 }
Please login to merge, or discard this patch.
Spacing   +44 added lines, -44 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission taxes class
@@ -41,22 +41,22 @@  discard block
 block discarded – undo
41 41
 	 *
42 42
 	 * @param GetPaid_Payment_Form_Submission $submission
43 43
 	 */
44
-	public function __construct( $submission ) {
44
+	public function __construct($submission) {
45 45
 
46 46
 		// Make sure that taxes are enabled.
47
-		if ( ! $submission->use_taxes() ) {
47
+		if (!$submission->use_taxes()) {
48 48
 			return;
49 49
 		}
50 50
 
51 51
 		// Validate VAT number.
52
-		$this->validate_vat( $submission );
52
+		$this->validate_vat($submission);
53 53
 
54
-		foreach ( $submission->get_items() as $item ) {
55
-			$this->process_item_tax( $item, $submission );
54
+		foreach ($submission->get_items() as $item) {
55
+			$this->process_item_tax($item, $submission);
56 56
 		}
57 57
 
58 58
 		// Process any existing invoice taxes.
59
-		if ( $submission->has_invoice() ) {
59
+		if ($submission->has_invoice()) {
60 60
 			$this->taxes = $submission->get_invoice()->get_taxes();
61 61
 		}
62 62
 
@@ -76,24 +76,24 @@  discard block
 block discarded – undo
76 76
 	 * @param GetPaid_Form_Item $item
77 77
 	 * @param GetPaid_Payment_Form_Submission $submission
78 78
 	 */
79
-	public function process_item_tax( $item, $submission ) {
79
+	public function process_item_tax($item, $submission) {
80 80
 
81 81
 		// Abort early if an error occurred.
82
-		if ( ! empty( $this->tax_error ) ) {
82
+		if (!empty($this->tax_error)) {
83 83
 			return;
84 84
 		}
85 85
 
86
-		$rate     = wpinv_get_tax_rate( $submission->country, $submission->state, $item->get_id() );
86
+		$rate     = wpinv_get_tax_rate($submission->country, $submission->state, $item->get_id());
87 87
 		$price    = $item->get_sub_total();
88 88
 		$item_tax = $price * $rate * 0.01;
89 89
 
90
-		if ( wpinv_prices_include_tax() ) {
91
-			$item_tax = $price - ( $price - $price * $rate * 0.01 );
90
+		if (wpinv_prices_include_tax()) {
91
+			$item_tax = $price - ($price - $price * $rate * 0.01);
92 92
 		}
93 93
 
94 94
 		$this->initial_tax += $item_tax;
95 95
 
96
-		if ( $item->is_recurring() ) {
96
+		if ($item->is_recurring()) {
97 97
 			$this->recurring_tax += $item_tax;
98 98
 		}
99 99
 
@@ -104,8 +104,8 @@  discard block
 block discarded – undo
104 104
 	 *
105 105
 	 * @param string $error
106 106
 	 */
107
-	public function set_error( $error ) {
108
-		if ( empty( $this->tax_error ) ) {
107
+	public function set_error($error) {
108
+		if (empty($this->tax_error)) {
109 109
 			$this->tax_error = $error;
110 110
 		}
111 111
 	}
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 	 * @since 1.0.19
118 118
 	 * @return bool
119 119
 	 */
120
-	public function has_digital_item( $submission ) {
120
+	public function has_digital_item($submission) {
121 121
 
122
-		foreach ( $submission->get_items() as $item ) {
122
+		foreach ($submission->get_items() as $item) {
123 123
 
124
-			if ( 'digital' == $item->get_vat_rule() ) {
124
+			if ('digital' == $item->get_vat_rule()) {
125 125
 				return true;
126 126
 				break;
127 127
 			}
@@ -139,15 +139,15 @@  discard block
 block discarded – undo
139 139
 	 * @since 1.0.19
140 140
 	 * @return bool
141 141
 	 */
142
-	public function is_eu_transaction( $submission, $has_digital ) {
142
+	public function is_eu_transaction($submission, $has_digital) {
143 143
 
144 144
 		// Both from EU.
145
-		if ( getpaid_is_eu_state( $submission->country ) && ( getpaid_is_eu_state( wpinv_get_default_country() ) || $has_digital ) ) {
145
+		if (getpaid_is_eu_state($submission->country) && (getpaid_is_eu_state(wpinv_get_default_country()) || $has_digital)) {
146 146
 			return true;
147 147
 		}
148 148
 
149 149
 		// Both from GST.
150
-		if ( getpaid_is_gst_country( $submission->country ) && getpaid_is_gst_country( wpinv_get_default_country() ) ) {
150
+		if (getpaid_is_gst_country($submission->country) && getpaid_is_gst_country(wpinv_get_default_country())) {
151 151
 			return true;
152 152
 		}
153 153
 
@@ -161,13 +161,13 @@  discard block
 block discarded – undo
161 161
 	 * @since 1.0.19
162 162
 	 * @return string
163 163
 	 */
164
-	public function get_vat_number( $submission ) {
164
+	public function get_vat_number($submission) {
165 165
 
166 166
 		$data = $submission->get_data();
167 167
 
168 168
 		// Retrieve from the posted number.
169
-		if ( ! empty( $data['wpinv_vat_number'] ) ) {
170
-			return wpinv_clean( $data['wpinv_vat_number'] );
169
+		if (!empty($data['wpinv_vat_number'])) {
170
+			return wpinv_clean($data['wpinv_vat_number']);
171 171
 		}
172 172
 
173 173
 		// Retrieve from the invoice.
@@ -181,13 +181,13 @@  discard block
 block discarded – undo
181 181
 	 * @since 1.0.19
182 182
 	 * @return string
183 183
 	 */
184
-	public function get_company( $submission ) {
184
+	public function get_company($submission) {
185 185
 
186 186
 		$data = $submission->get_data();
187 187
 
188 188
 		// Retrieve from the posted data.
189
-		if ( ! empty( $data['wpinv_company'] ) ) {
190
-			return wpinv_clean( $data['wpinv_company'] );
189
+		if (!empty($data['wpinv_company'])) {
190
+			return wpinv_clean($data['wpinv_company']);
191 191
 		}
192 192
 
193 193
 		// Retrieve from the invoice.
@@ -202,10 +202,10 @@  discard block
 block discarded – undo
202 202
 	 * @since 1.0.19
203 203
 	 * @return string
204 204
 	 */
205
-	public function requires_vat( $ip_in_eu, $country_in_eu ) {
205
+	public function requires_vat($ip_in_eu, $country_in_eu) {
206 206
 
207
-		$prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' );
208
-		$prevent_b2c = ! empty( $prevent_b2c );
207
+		$prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase');
208
+		$prevent_b2c = !empty($prevent_b2c);
209 209
 		$is_eu       = $ip_in_eu || $country_in_eu;
210 210
 
211 211
 		return $prevent_b2c && $is_eu;
@@ -217,30 +217,30 @@  discard block
 block discarded – undo
217 217
 	 * @param GetPaid_Payment_Form_Submission $submission
218 218
 	 * @since 1.0.19
219 219
 	 */
220
-	public function validate_vat( $submission ) {
220
+	public function validate_vat($submission) {
221 221
 
222
-		$has_digital = $this->has_digital_item( $submission );
223
-		$in_eu       = $this->is_eu_transaction( $submission, $has_digital );
222
+		$has_digital = $this->has_digital_item($submission);
223
+		$in_eu       = $this->is_eu_transaction($submission, $has_digital);
224 224
 
225 225
 		// Abort if we are not validating vat numbers.
226
-		if ( ! $has_digital && ! $in_eu ) {
226
+		if (!$has_digital && !$in_eu) {
227 227
             return;
228 228
 		}
229 229
 
230 230
 		// Prepare variables.
231
-		$vat_number  = $this->get_vat_number( $submission );
232
-		$company     = $this->get_company( $submission );
231
+		$vat_number  = $this->get_vat_number($submission);
232
+		$company     = $this->get_company($submission);
233 233
 		$ip_country  = WPInv_EUVat::get_country_by_ip();
234
-        $is_eu       = getpaid_is_eu_state( $submission->country );
235
-        $is_ip_eu    = getpaid_is_eu_state( $ip_country );
234
+        $is_eu       = getpaid_is_eu_state($submission->country);
235
+        $is_ip_eu    = getpaid_is_eu_state($ip_country);
236 236
 
237 237
 		// If we're preventing business to consumer purchases, ensure
238
-		if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) {
238
+		if ($this->requires_vat($is_ip_eu, $is_eu) && empty($vat_number)) {
239 239
 
240 240
 			// Ensure that a vat number has been specified.
241 241
 			return $this->set_error(
242 242
 				wp_sprintf(
243
-					__( 'Please enter your %s number to verify your purchase is by an EU business.', 'invoicing' ),
243
+					__('Please enter your %s number to verify your purchase is by an EU business.', 'invoicing'),
244 244
 					getpaid_vat_name()
245 245
 				)
246 246
 			);
@@ -248,14 +248,14 @@  discard block
 block discarded – undo
248 248
 		}
249 249
 
250 250
 		// Abort if we are not validating vat (vat number should exist, user should be in eu and business too).
251
-		if ( ! $is_eu || ! $in_eu || empty( $vat_number ) ) {
251
+		if (!$is_eu || !$in_eu || empty($vat_number)) {
252 252
             return;
253 253
 		}
254 254
 
255
-		$is_valid = WPInv_EUVat::validate_vat_number( $vat_number, $company, $submission->country );
255
+		$is_valid = WPInv_EUVat::validate_vat_number($vat_number, $company, $submission->country);
256 256
 
257
-		if ( is_string( $is_valid ) ) {
258
-			$this->set_error( $is_valid );
257
+		if (is_string($is_valid)) {
258
+			$this->set_error($is_valid);
259 259
 		}
260 260
 
261 261
 	}
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission.php 2 patches
Indentation   +686 added lines, -686 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,395 +10,395 @@  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 raw submission data.
50
-	 *
51
-	 * @var array
52
-	 */
53
-	protected $data = null;
54
-
55
-	/**
56
-	 * Whether this submission contains a recurring item.
57
-	 *
58
-	 * @var bool
59
-	 */
60
-	public $has_recurring = false;
61
-
62
-	/**
63
-	 * The sub total amount for the submission.
64
-	 *
65
-	 * @var float
66
-	 */
67
-	public $subtotal_amount = 0;
68
-
69
-	/**
70
-	 * The total discount amount for the submission.
71
-	 *
72
-	 * @var float
73
-	 */
74
-	protected $total_discount_amount = 0;
75
-
76
-	/**
77
-	 * The total recurring discount amount for the submission.
78
-	 *
79
-	 * @var float
80
-	 */
81
-	protected $total_recurring_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 recurring tax amount for the submission.
92
-	 *
93
-	 * @var float
94
-	 */
95
-	protected $total_recurring_tax_amount = 0;
96
-
97
-	/**
98
-	 * An array of fees for the submission.
99
-	 *
100
-	 * @var array
101
-	 */
102
-	protected $fees = array();
103
-
104
-	/**
105
-	 * The total fees amount for the submission.
106
-	 *
107
-	 * @var float
108
-	 */
109
-	protected $total_fees_amount = 0;
110
-
111
-	/**
112
-	 * The total fees amount for the submission.
113
-	 *
114
-	 * @var float
115
-	 */
116
-	protected $total_recurring_fees_amount = 0;
117
-
118
-	/**
119
-	 * An array of discounts for the submission.
120
-	 *
121
-	 * @var array
122
-	 */
123
-	protected $discounts = array();
124
-
125
-	/**
126
-	 * An array of taxes for the submission.
127
-	 *
128
-	 * @var array
129
-	 */
130
-	protected $taxes = array();
131
-
132
-	/**
133
-	 * An array of items for the submission.
134
-	 *
135
-	 * @var GetPaid_Form_Item[]
136
-	 */
137
-	protected $items = array();
138
-
139
-	/**
140
-	 * The last error.
141
-	 *
142
-	 * @var string
143
-	 */
144
-	public $last_error = null;
145
-
146
-	/**
147
-	 * Is the discount valid?
148
-	 *
149
-	 * @var bool
150
-	 */
151
-	public $is_discount_valid = true;
152
-
153
-    /**
154
-	 * Class constructor.
155
-	 *
156
-	 */
157
-	public function __construct() {
158
-
159
-		// Set the state and country to the default state and country.
160
-		$this->country = wpinv_default_billing_country();
161
-		$this->state = wpinv_get_default_state();
162
-
163
-		// Do we have an actual submission?
164
-		if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
165
-			$this->load_data( $_POST );
166
-		}
167
-
168
-	}
169
-
170
-	/**
171
-	 * Loads submission data.
172
-	 *
173
-	 * @param array $data
174
-	 */
175
-	public function load_data( $data ) {
176
-
177
-		// Prepare submitted data...
178
-		$data = wp_unslash( $data );
179
-
180
-		// Filter the data.
181
-		$data = apply_filters( 'getpaid_submission_data', $data, $this );
182
-
183
-		$this->data = $data;
184
-
185
-		$this->id = md5( wp_json_encode( $data ) );
186
-
187
-		// Every submission needs an active payment form.
188
-		if ( empty( $data['form_id'] ) ) {
189
-			$this->last_error = __( 'Missing payment form', 'invoicing' );
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 raw submission data.
50
+     *
51
+     * @var array
52
+     */
53
+    protected $data = null;
54
+
55
+    /**
56
+     * Whether this submission contains a recurring item.
57
+     *
58
+     * @var bool
59
+     */
60
+    public $has_recurring = false;
61
+
62
+    /**
63
+     * The sub total amount for the submission.
64
+     *
65
+     * @var float
66
+     */
67
+    public $subtotal_amount = 0;
68
+
69
+    /**
70
+     * The total discount amount for the submission.
71
+     *
72
+     * @var float
73
+     */
74
+    protected $total_discount_amount = 0;
75
+
76
+    /**
77
+     * The total recurring discount amount for the submission.
78
+     *
79
+     * @var float
80
+     */
81
+    protected $total_recurring_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 recurring tax amount for the submission.
92
+     *
93
+     * @var float
94
+     */
95
+    protected $total_recurring_tax_amount = 0;
96
+
97
+    /**
98
+     * An array of fees for the submission.
99
+     *
100
+     * @var array
101
+     */
102
+    protected $fees = array();
103
+
104
+    /**
105
+     * The total fees amount for the submission.
106
+     *
107
+     * @var float
108
+     */
109
+    protected $total_fees_amount = 0;
110
+
111
+    /**
112
+     * The total fees amount for the submission.
113
+     *
114
+     * @var float
115
+     */
116
+    protected $total_recurring_fees_amount = 0;
117
+
118
+    /**
119
+     * An array of discounts for the submission.
120
+     *
121
+     * @var array
122
+     */
123
+    protected $discounts = array();
124
+
125
+    /**
126
+     * An array of taxes for the submission.
127
+     *
128
+     * @var array
129
+     */
130
+    protected $taxes = array();
131
+
132
+    /**
133
+     * An array of items for the submission.
134
+     *
135
+     * @var GetPaid_Form_Item[]
136
+     */
137
+    protected $items = array();
138
+
139
+    /**
140
+     * The last error.
141
+     *
142
+     * @var string
143
+     */
144
+    public $last_error = null;
145
+
146
+    /**
147
+     * Is the discount valid?
148
+     *
149
+     * @var bool
150
+     */
151
+    public $is_discount_valid = true;
152
+
153
+    /**
154
+     * Class constructor.
155
+     *
156
+     */
157
+    public function __construct() {
158
+
159
+        // Set the state and country to the default state and country.
160
+        $this->country = wpinv_default_billing_country();
161
+        $this->state = wpinv_get_default_state();
162
+
163
+        // Do we have an actual submission?
164
+        if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
165
+            $this->load_data( $_POST );
166
+        }
167
+
168
+    }
169
+
170
+    /**
171
+     * Loads submission data.
172
+     *
173
+     * @param array $data
174
+     */
175
+    public function load_data( $data ) {
176
+
177
+        // Prepare submitted data...
178
+        $data = wp_unslash( $data );
179
+
180
+        // Filter the data.
181
+        $data = apply_filters( 'getpaid_submission_data', $data, $this );
182
+
183
+        $this->data = $data;
184
+
185
+        $this->id = md5( wp_json_encode( $data ) );
186
+
187
+        // Every submission needs an active payment form.
188
+        if ( empty( $data['form_id'] ) ) {
189
+            $this->last_error = __( 'Missing payment form', 'invoicing' );
190 190
             return;
191
-		}
191
+        }
192 192
 
193
-		// Fetch the payment form.
194
-		$form = new GetPaid_Payment_Form( $data['form_id'] );
193
+        // Fetch the payment form.
194
+        $form = new GetPaid_Payment_Form( $data['form_id'] );
195 195
 
196
-		if ( ! $form->is_active() ) {
197
-			$this->last_error = __( 'Payment form not active', 'invoicing' );
198
-			return;
199
-		}
196
+        if ( ! $form->is_active() ) {
197
+            $this->last_error = __( 'Payment form not active', 'invoicing' );
198
+            return;
199
+        }
200 200
 
201
-		// Fetch the payment form.
202
-		$this->payment_form = $form;
201
+        // Fetch the payment form.
202
+        $this->payment_form = $form;
203 203
 
204
-		// For existing invoices, make sure that it is valid.
204
+        // For existing invoices, make sure that it is valid.
205 205
         if ( ! empty( $data['invoice_id'] ) ) {
206 206
             $invoice = wpinv_get_invoice( $data['invoice_id'] );
207 207
 
208 208
             if ( empty( $invoice ) ) {
209
-				$this->last_error = __( 'Invalid invoice', 'invoicing' );
209
+                $this->last_error = __( 'Invalid invoice', 'invoicing' );
210 210
                 return;
211
-			}
211
+            }
212 212
 
213
-			if ( $invoice->is_paid() ) {
214
-				$this->last_error = __( 'This invoice is already paid for.', 'invoicing' );
213
+            if ( $invoice->is_paid() ) {
214
+                $this->last_error = __( 'This invoice is already paid for.', 'invoicing' );
215 215
                 return;
216
-			}
216
+            }
217 217
 
218
-			$this->payment_form->set_items( $invoice->get_items() );
218
+            $this->payment_form->set_items( $invoice->get_items() );
219 219
 
220
-			$this->country = $invoice->get_country();
221
-			$this->state   = $invoice->get_state();
222
-			$this->invoice = $invoice;
220
+            $this->country = $invoice->get_country();
221
+            $this->state   = $invoice->get_state();
222
+            $this->invoice = $invoice;
223 223
 
224
-		// Default forms do not have items.
224
+        // Default forms do not have items.
225 225
         } else if ( $form->is_default() && isset( $data['getpaid-items'] ) ) {
226
-			$this->payment_form->set_items( wpinv_clean( $data['getpaid-items'] ) );
227
-		}
228
-
229
-		// User's country.
230
-		if ( ! empty( $data['wpinv_country'] ) ) {
231
-			$this->country = $data['wpinv_country'];
232
-		}
233
-
234
-		// User's state.
235
-		if ( ! empty( $data['wpinv_state'] ) ) {
236
-			$this->country = $data['wpinv_state'];
237
-		}
238
-
239
-		// Handle items.
240
-		$selected_items = array();
241
-		if ( ! empty( $data['getpaid-items'] ) ) {
242
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
243
-		}
244
-
245
-		foreach ( $this->payment_form->get_items() as $item ) {
246
-
247
-			// Continue if this is an optional item and it has not been selected.
248
-			if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
249
-				continue;
250
-			}
251
-
252
-			// (maybe) let customers change the quantities and prices.
253
-			if ( isset( $selected_items[ $item->get_id() ] ) ) {
254
-
255
-				// Maybe change the quantities.
256
-				if ( $item->allows_quantities() && is_numeric( $selected_items[ $item->get_id() ]['quantity'] ) ) {
257
-					$item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
258
-				}
259
-
260
-				// Maybe change the price.
261
-				if ( $item->user_can_set_their_price() ) {
262
-					$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
263
-
264
-					// But don't get lower than the minimum price.
265
-					if ( $price < $item->get_minimum_price() ) {
266
-						$price = $item->get_minimum_price();
267
-					}
268
-
269
-					$item->set_price( $price );
270
-
271
-				}
272
-
273
-			}
274
-
275
-			// Add the item to the form.
276
-			$this->add_item( $item );
277
-
278
-		}
279
-
280
-		// Fired when we are done processing a submission.
281
-		do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
282
-
283
-		// Handle discounts.
284
-		$this->process_discount();
285
-
286
-	}
287
-
288
-    /**
289
-	 * Returns the payment form.
290
-	 *
291
-	 * @since 1.0.19
292
-	 * @return GetPaid_Payment_Form
293
-	 */
294
-	public function get_payment_form() {
295
-		return $this->payment_form;
296
-	}
297
-
298
-	/**
299
-	 * Returns the associated invoice.
300
-	 *
301
-	 * @since 1.0.19
302
-	 * @return WPInv_Invoice
303
-	 */
304
-	public function get_invoice() {
305
-		return $this->invoice;
306
-	}
307
-
308
-	/**
309
-	 * Checks whether there is an invoice associated with this submission.
310
-	 *
311
-	 * @since 1.0.19
312
-	 * @return bool
313
-	 */
314
-	public function has_invoice() {
315
-		return ! empty( $this->invoice );
316
-	}
317
-
318
-	/**
319
-	 * Returns the appropriate currency for the submission.
320
-	 *
321
-	 * @since 1.0.19
322
-	 * @return string
323
-	 */
324
-	public function get_currency() {
325
-		if ( $this->has_invoice() ) {
326
-			return $this->invoice->get_currency();
327
-		}
328
-		return wpinv_get_currency();
329
-    }
330
-
331
-    /**
332
-	 * Returns the raw submission data.
333
-	 *
334
-	 * @since 1.0.19
335
-	 * @return array
336
-	 */
337
-	public function get_data() {
338
-		return $this->data;
339
-	}
340
-
341
-	/**
342
-	 * Checks if a required field is set.
343
-	 *
344
-	 * @since 1.0.19
345
-	 */
346
-	public function is_required_field_set( $field ) {
347
-		return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
348
-	}
349
-
350
-	///////// Items //////////////
351
-
352
-	/**
353
-	 * Adds an item to the submission.
354
-	 *
355
-	 * @since 1.0.19
356
-	 * @param GetPaid_Form_Item $item
357
-	 */
358
-	public function add_item( $item ) {
359
-
360
-		// Make sure that it is available for purchase.
361
-		if ( ! $item->can_purchase() ) {
362
-			return;
363
-		}
364
-
365
-		// Do we have a recurring item?
366
-		if ( $item->is_recurring() ) {
367
-
368
-			if ( $this->has_recurring ) {
369
-				$this->last_error = __( 'You can only buy one recurring item at a time.', 'invoicing' );
370
-			}
371
-
372
-			$this->has_recurring = true;
373
-
374
-		}
375
-
376
-		$this->items[ $item->get_id() ] = $item;
377
-
378
-		$this->subtotal_amount += $item->get_sub_total();
379
-
380
-	}
381
-
382
-	/**
383
-	 * Retrieves a specific item.
384
-	 *
385
-	 * @since 1.0.19
386
-	 */
387
-	public function get_item( $item_id ) {
388
-		return isset( $this->items[ $item_id ] ) ? $this->items[ $item_id ] : null;
389
-	}
390
-
391
-	/**
392
-	 * Returns all items.
393
-	 *
394
-	 * @since 1.0.19
395
-	 * @return GetPaid_Form_Item[]
396
-	 */
397
-	public function get_items() {
398
-		return $this->items;
399
-	}
400
-
401
-	/*
226
+            $this->payment_form->set_items( wpinv_clean( $data['getpaid-items'] ) );
227
+        }
228
+
229
+        // User's country.
230
+        if ( ! empty( $data['wpinv_country'] ) ) {
231
+            $this->country = $data['wpinv_country'];
232
+        }
233
+
234
+        // User's state.
235
+        if ( ! empty( $data['wpinv_state'] ) ) {
236
+            $this->country = $data['wpinv_state'];
237
+        }
238
+
239
+        // Handle items.
240
+        $selected_items = array();
241
+        if ( ! empty( $data['getpaid-items'] ) ) {
242
+            $selected_items = wpinv_clean( $data['getpaid-items'] );
243
+        }
244
+
245
+        foreach ( $this->payment_form->get_items() as $item ) {
246
+
247
+            // Continue if this is an optional item and it has not been selected.
248
+            if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
249
+                continue;
250
+            }
251
+
252
+            // (maybe) let customers change the quantities and prices.
253
+            if ( isset( $selected_items[ $item->get_id() ] ) ) {
254
+
255
+                // Maybe change the quantities.
256
+                if ( $item->allows_quantities() && is_numeric( $selected_items[ $item->get_id() ]['quantity'] ) ) {
257
+                    $item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
258
+                }
259
+
260
+                // Maybe change the price.
261
+                if ( $item->user_can_set_their_price() ) {
262
+                    $price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
263
+
264
+                    // But don't get lower than the minimum price.
265
+                    if ( $price < $item->get_minimum_price() ) {
266
+                        $price = $item->get_minimum_price();
267
+                    }
268
+
269
+                    $item->set_price( $price );
270
+
271
+                }
272
+
273
+            }
274
+
275
+            // Add the item to the form.
276
+            $this->add_item( $item );
277
+
278
+        }
279
+
280
+        // Fired when we are done processing a submission.
281
+        do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
282
+
283
+        // Handle discounts.
284
+        $this->process_discount();
285
+
286
+    }
287
+
288
+    /**
289
+     * Returns the payment form.
290
+     *
291
+     * @since 1.0.19
292
+     * @return GetPaid_Payment_Form
293
+     */
294
+    public function get_payment_form() {
295
+        return $this->payment_form;
296
+    }
297
+
298
+    /**
299
+     * Returns the associated invoice.
300
+     *
301
+     * @since 1.0.19
302
+     * @return WPInv_Invoice
303
+     */
304
+    public function get_invoice() {
305
+        return $this->invoice;
306
+    }
307
+
308
+    /**
309
+     * Checks whether there is an invoice associated with this submission.
310
+     *
311
+     * @since 1.0.19
312
+     * @return bool
313
+     */
314
+    public function has_invoice() {
315
+        return ! empty( $this->invoice );
316
+    }
317
+
318
+    /**
319
+     * Returns the appropriate currency for the submission.
320
+     *
321
+     * @since 1.0.19
322
+     * @return string
323
+     */
324
+    public function get_currency() {
325
+        if ( $this->has_invoice() ) {
326
+            return $this->invoice->get_currency();
327
+        }
328
+        return wpinv_get_currency();
329
+    }
330
+
331
+    /**
332
+     * Returns the raw submission data.
333
+     *
334
+     * @since 1.0.19
335
+     * @return array
336
+     */
337
+    public function get_data() {
338
+        return $this->data;
339
+    }
340
+
341
+    /**
342
+     * Checks if a required field is set.
343
+     *
344
+     * @since 1.0.19
345
+     */
346
+    public function is_required_field_set( $field ) {
347
+        return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
348
+    }
349
+
350
+    ///////// Items //////////////
351
+
352
+    /**
353
+     * Adds an item to the submission.
354
+     *
355
+     * @since 1.0.19
356
+     * @param GetPaid_Form_Item $item
357
+     */
358
+    public function add_item( $item ) {
359
+
360
+        // Make sure that it is available for purchase.
361
+        if ( ! $item->can_purchase() ) {
362
+            return;
363
+        }
364
+
365
+        // Do we have a recurring item?
366
+        if ( $item->is_recurring() ) {
367
+
368
+            if ( $this->has_recurring ) {
369
+                $this->last_error = __( 'You can only buy one recurring item at a time.', 'invoicing' );
370
+            }
371
+
372
+            $this->has_recurring = true;
373
+
374
+        }
375
+
376
+        $this->items[ $item->get_id() ] = $item;
377
+
378
+        $this->subtotal_amount += $item->get_sub_total();
379
+
380
+    }
381
+
382
+    /**
383
+     * Retrieves a specific item.
384
+     *
385
+     * @since 1.0.19
386
+     */
387
+    public function get_item( $item_id ) {
388
+        return isset( $this->items[ $item_id ] ) ? $this->items[ $item_id ] : null;
389
+    }
390
+
391
+    /**
392
+     * Returns all items.
393
+     *
394
+     * @since 1.0.19
395
+     * @return GetPaid_Form_Item[]
396
+     */
397
+    public function get_items() {
398
+        return $this->items;
399
+    }
400
+
401
+    /*
402 402
 	|--------------------------------------------------------------------------
403 403
 	| Taxes
404 404
 	|--------------------------------------------------------------------------
@@ -407,86 +407,86 @@  discard block
 block discarded – undo
407 407
 	| or only one-time.
408 408
     */
409 409
 
410
-	/**
411
-	 * Prepares the submission's taxes.
412
-	 *
413
-	 * @since 1.0.19
414
-	 */
415
-	public function process_taxes() {
416
-
417
-		$tax_processor = new GetPaid_Payment_Form_Submission_Taxes( $this );
418
-
419
-		if ( ! empty( $tax_processor->tax_error) ) {
420
-			$this->last_error = $tax_processor->tax_error;
421
-			return;
422
-		}
423
-
424
-		foreach ( $tax_processor->taxes as $tax ) {
425
-			$this->add_tax( $tax );
426
-		}
427
-
428
-		do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) );
429
-	}
430
-
431
-	/**
432
-	 * Adds a tax to the submission.
433
-	 *
434
-	 * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
435
-	 * @since 1.0.19
436
-	 */
437
-	public function add_tax( $tax ) {
438
-
439
-		$this->total_tax_amount           += wpinv_sanitize_amount( $tax['initial_tax'] );
440
-		$this->total_recurring_tax_amount += wpinv_sanitize_amount( $tax['recurring_tax'] );
441
-		$this->taxes[ $tax['name'] ]       = $tax;
442
-
443
-	}
444
-
445
-	/**
446
-	 * Whether or not we'll use taxes for the submission.
447
-	 *
448
-	 * @since 1.0.19
449
-	 */
450
-	public function use_taxes() {
451
-
452
-		$use_taxes = wpinv_use_taxes();
453
-
454
-		if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) {
455
-			$use_taxes = false;
456
-		}
457
-
458
-		return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
459
-
460
-	}
461
-
462
-	/**
463
-	 * Returns the total tax amount.
464
-	 *
465
-	 * @since 1.0.19
466
-	 */
467
-	public function get_total_tax() {
468
-		return $this->total_tax_amount;
469
-	}
470
-
471
-	/**
472
-	 * Returns the total recurring tax amount.
473
-	 *
474
-	 * @since 1.0.19
475
-	 */
476
-	public function get_total_recurring_tax() {
477
-		return $this->total_recurring_tax_amount;
478
-	}
479
-
480
-	/**
481
-	 * Returns all taxes.
482
-	 *
483
-	 * @since 1.0.19
484
-	 */
485
-	public function get_taxes() {
486
-		return $this->taxes;
487
-	}
488
-
489
-	/*
410
+    /**
411
+     * Prepares the submission's taxes.
412
+     *
413
+     * @since 1.0.19
414
+     */
415
+    public function process_taxes() {
416
+
417
+        $tax_processor = new GetPaid_Payment_Form_Submission_Taxes( $this );
418
+
419
+        if ( ! empty( $tax_processor->tax_error) ) {
420
+            $this->last_error = $tax_processor->tax_error;
421
+            return;
422
+        }
423
+
424
+        foreach ( $tax_processor->taxes as $tax ) {
425
+            $this->add_tax( $tax );
426
+        }
427
+
428
+        do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) );
429
+    }
430
+
431
+    /**
432
+     * Adds a tax to the submission.
433
+     *
434
+     * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
435
+     * @since 1.0.19
436
+     */
437
+    public function add_tax( $tax ) {
438
+
439
+        $this->total_tax_amount           += wpinv_sanitize_amount( $tax['initial_tax'] );
440
+        $this->total_recurring_tax_amount += wpinv_sanitize_amount( $tax['recurring_tax'] );
441
+        $this->taxes[ $tax['name'] ]       = $tax;
442
+
443
+    }
444
+
445
+    /**
446
+     * Whether or not we'll use taxes for the submission.
447
+     *
448
+     * @since 1.0.19
449
+     */
450
+    public function use_taxes() {
451
+
452
+        $use_taxes = wpinv_use_taxes();
453
+
454
+        if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) {
455
+            $use_taxes = false;
456
+        }
457
+
458
+        return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
459
+
460
+    }
461
+
462
+    /**
463
+     * Returns the total tax amount.
464
+     *
465
+     * @since 1.0.19
466
+     */
467
+    public function get_total_tax() {
468
+        return $this->total_tax_amount;
469
+    }
470
+
471
+    /**
472
+     * Returns the total recurring tax amount.
473
+     *
474
+     * @since 1.0.19
475
+     */
476
+    public function get_total_recurring_tax() {
477
+        return $this->total_recurring_tax_amount;
478
+    }
479
+
480
+    /**
481
+     * Returns all taxes.
482
+     *
483
+     * @since 1.0.19
484
+     */
485
+    public function get_taxes() {
486
+        return $this->taxes;
487
+    }
488
+
489
+    /*
490 490
 	|--------------------------------------------------------------------------
491 491
 	| Discounts
492 492
 	|--------------------------------------------------------------------------
@@ -495,116 +495,116 @@  discard block
 block discarded – undo
495 495
 	| or only one-time. They also do not have to come from a discount code.
496 496
     */
497 497
 
498
-	/**
499
-	 * Prepares the submission's discount.
500
-	 *
501
-	 * @since 1.0.19
502
-	 */
503
-	public function process_discount() {
504
-
505
-		$total            = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax();
506
-		$discount_handler = new GetPaid_Payment_Form_Submission_Discount( $this, $total );
507
-
508
-		if ( ! $discount_handler->is_discount_valid ) {
509
-			$this->last_error = $discount_handler->discount_error;
510
-			return;
511
-		}
512
-
513
-		// Process any existing invoice discounts.
514
-		if ( $this->has_invoice() ) {
515
-			$discounts = $this->get_invoice()->get_discounts();
516
-
517
-			foreach ( $discounts as $discount ) {
518
-				$this->add_discount( $discount );
519
-			}
520
-
521
-		}
522
-
523
-		if ( $discount_handler->has_discount ) {
524
-			$this->add_discount( $discount_handler->calculate_discount( $this ) );
525
-		}
526
-
527
-		do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) );
528
-	}
529
-
530
-	/**
531
-	 * Adds a discount to the submission.
532
-	 *
533
-	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
534
-	 * @since 1.0.19
535
-	 */
536
-	public function add_discount( $discount ) {
537
-
538
-		$this->total_discount_amount           += wpinv_sanitize_amount( $discount['initial_discount'] );
539
-		$this->total_recurring_discount_amount += wpinv_sanitize_amount( $discount['recurring_discount'] );
540
-		$this->discounts[ $discount['name'] ]   = $discount;
541
-
542
-	}
543
-
544
-	/**
545
-	 * Removes a discount from the submission.
546
-	 *
547
-	 * @since 1.0.19
548
-	 */
549
-	public function remove_discount( $name ) {
550
-
551
-		if ( isset( $this->discounts[ $name ] ) ) {
552
-			$discount                               = $this->discounts[ $name ];
553
-			$this->total_discount_amount           -= $discount['initial_discount'];
554
-			$this->total_recurring_discount_amount -= $discount['recurring_discount'];
555
-			unset( $this->discounts[ $name ] );
556
-		}
557
-
558
-	}
559
-
560
-	/**
561
-	 * Checks whether there is a discount code associated with this submission.
562
-	 *
563
-	 * @since 1.0.19
564
-	 * @return bool
565
-	 */
566
-	public function has_discount_code() {
567
-		return ! empty( $this->discounts['discount_code'] );
568
-	}
569
-
570
-	/**
571
-	 * Returns the discount code.
572
-	 *
573
-	 * @since 1.0.19
574
-	 * @return string
575
-	 */
576
-	public function get_discount_code() {
577
-		return $this->has_discount_code() ? $this->discounts['discount_code']['discount_code'] : '';
578
-	}
579
-
580
-	/**
581
-	 * Returns the total discount amount.
582
-	 *
583
-	 * @since 1.0.19
584
-	 */
585
-	public function get_total_discount() {
586
-		return $this->total_discount_amount;
587
-	}
588
-
589
-	/**
590
-	 * Returns the total recurring discount amount.
591
-	 *
592
-	 * @since 1.0.19
593
-	 */
594
-	public function get_total_recurring_discount() {
595
-		return $this->total_recurring_discount_amount;
596
-	}
597
-
598
-	/**
599
-	 * Returns all discounts.
600
-	 *
601
-	 * @since 1.0.19
602
-	 */
603
-	public function get_discounts() {
604
-		return $this->discounts;
605
-	}
606
-
607
-	/*
498
+    /**
499
+     * Prepares the submission's discount.
500
+     *
501
+     * @since 1.0.19
502
+     */
503
+    public function process_discount() {
504
+
505
+        $total            = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax();
506
+        $discount_handler = new GetPaid_Payment_Form_Submission_Discount( $this, $total );
507
+
508
+        if ( ! $discount_handler->is_discount_valid ) {
509
+            $this->last_error = $discount_handler->discount_error;
510
+            return;
511
+        }
512
+
513
+        // Process any existing invoice discounts.
514
+        if ( $this->has_invoice() ) {
515
+            $discounts = $this->get_invoice()->get_discounts();
516
+
517
+            foreach ( $discounts as $discount ) {
518
+                $this->add_discount( $discount );
519
+            }
520
+
521
+        }
522
+
523
+        if ( $discount_handler->has_discount ) {
524
+            $this->add_discount( $discount_handler->calculate_discount( $this ) );
525
+        }
526
+
527
+        do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) );
528
+    }
529
+
530
+    /**
531
+     * Adds a discount to the submission.
532
+     *
533
+     * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
534
+     * @since 1.0.19
535
+     */
536
+    public function add_discount( $discount ) {
537
+
538
+        $this->total_discount_amount           += wpinv_sanitize_amount( $discount['initial_discount'] );
539
+        $this->total_recurring_discount_amount += wpinv_sanitize_amount( $discount['recurring_discount'] );
540
+        $this->discounts[ $discount['name'] ]   = $discount;
541
+
542
+    }
543
+
544
+    /**
545
+     * Removes a discount from the submission.
546
+     *
547
+     * @since 1.0.19
548
+     */
549
+    public function remove_discount( $name ) {
550
+
551
+        if ( isset( $this->discounts[ $name ] ) ) {
552
+            $discount                               = $this->discounts[ $name ];
553
+            $this->total_discount_amount           -= $discount['initial_discount'];
554
+            $this->total_recurring_discount_amount -= $discount['recurring_discount'];
555
+            unset( $this->discounts[ $name ] );
556
+        }
557
+
558
+    }
559
+
560
+    /**
561
+     * Checks whether there is a discount code associated with this submission.
562
+     *
563
+     * @since 1.0.19
564
+     * @return bool
565
+     */
566
+    public function has_discount_code() {
567
+        return ! empty( $this->discounts['discount_code'] );
568
+    }
569
+
570
+    /**
571
+     * Returns the discount code.
572
+     *
573
+     * @since 1.0.19
574
+     * @return string
575
+     */
576
+    public function get_discount_code() {
577
+        return $this->has_discount_code() ? $this->discounts['discount_code']['discount_code'] : '';
578
+    }
579
+
580
+    /**
581
+     * Returns the total discount amount.
582
+     *
583
+     * @since 1.0.19
584
+     */
585
+    public function get_total_discount() {
586
+        return $this->total_discount_amount;
587
+    }
588
+
589
+    /**
590
+     * Returns the total recurring discount amount.
591
+     *
592
+     * @since 1.0.19
593
+     */
594
+    public function get_total_recurring_discount() {
595
+        return $this->total_recurring_discount_amount;
596
+    }
597
+
598
+    /**
599
+     * Returns all discounts.
600
+     *
601
+     * @since 1.0.19
602
+     */
603
+    public function get_discounts() {
604
+        return $this->discounts;
605
+    }
606
+
607
+    /*
608 608
 	|--------------------------------------------------------------------------
609 609
 	| Fees
610 610
 	|--------------------------------------------------------------------------
@@ -614,131 +614,131 @@  discard block
 block discarded – undo
614 614
 	| fees.
615 615
     */
616 616
 
617
-	/**
618
-	 * Prepares the submission's fees.
619
-	 *
620
-	 * @since 1.0.19
621
-	 */
622
-	public function process_fees() {
623
-
624
-		$fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this );
625
-
626
-		if ( ! empty( $fees_processor->fee_error) ) {
627
-			$this->last_error = $fees_processor->fee_error;
628
-			return;
629
-		}
630
-
631
-		foreach ( $fees_processor->fees as $fee ) {
632
-			$this->add_fee( $fee );
633
-		}
634
-
635
-		do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) );
636
-	}
637
-
638
-	/**
639
-	 * Adds a fee to the submission.
640
-	 *
641
-	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
642
-	 * @since 1.0.19
643
-	 */
644
-	public function add_fee( $fee ) {
645
-
646
-		$this->total_fees_amount           += wpinv_sanitize_amount( $fee['initial_fee'] );
647
-		$this->total_recurring_fees_amount += wpinv_sanitize_amount( $fee['recurring_fee'] );
648
-		$this->fees[ $fee['name'] ]         = $fee;
649
-
650
-	}
651
-
652
-	/**
653
-	 * Removes a fee from the submission.
654
-	 *
655
-	 * @since 1.0.19
656
-	 */
657
-	public function remove_fee( $name ) {
658
-
659
-		if ( isset( $this->fees[ $name ] ) ) {
660
-			$fee                                = $this->fees[ $name ];
661
-			$this->total_fees_amount           -= $fee['initial_fee'];
662
-			$this->total_recurring_fees_amount -= $fee['recurring_fee'];
663
-			unset( $this->fees[ $name ] );
664
-		}
665
-
666
-	}
667
-
668
-	/**
669
-	 * Returns the total fees amount.
670
-	 *
671
-	 * @since 1.0.19
672
-	 */
673
-	public function get_total_fees() {
674
-		return $this->total_fees_amount;
675
-	}
676
-
677
-	/**
678
-	 * Returns the total recurring fees amount.
679
-	 *
680
-	 * @since 1.0.19
681
-	 */
682
-	public function get_total_recurring_fees() {
683
-		return $this->total_recurring_fees_amount;
684
-	}
685
-
686
-	/**
687
-	 * Returns all fees.
688
-	 *
689
-	 * @since 1.0.19
690
-	 */
691
-	public function get_fees() {
692
-		return $this->fees;
693
-	}
694
-
695
-	// MISC //
696
-
697
-	/**
698
-	 * Returns the total amount to collect for this submission.
699
-	 *
700
-	 * @since 1.0.19
701
-	 */
702
-	public function get_total() {
703
-		$total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
704
-		$total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this  );
705
-		return wpinv_sanitize_amount( $total );
706
-	}
707
-
708
-	/**
709
-	 * Whether payment details should be collected for this submission.
710
-	 *
711
-	 * @since 1.0.19
712
-	 */
713
-	public function get_payment_details() {
714
-		$collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
715
-
716
-		if ( $this->has_recurring ) {
717
-			$collect = true;
718
-		}
719
-
720
-		$collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this  );
721
-		return $collect;
722
-	}
723
-
724
-	/**
725
-	 * Returns the billing email of the user.
726
-	 *
727
-	 * @since 1.0.19
728
-	 */
729
-	public function get_billing_email() {
730
-		$billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email'];
731
-		return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this  );
732
-	}
733
-
734
-	/**
735
-	 * Checks if the submitter has a billing email.
736
-	 *
737
-	 * @since 1.0.19
738
-	 */
739
-	public function has_billing_email() {
740
-		$billing_email = $this->get_billing_email();
741
-		return ! empty( $billing_email );
742
-	}
617
+    /**
618
+     * Prepares the submission's fees.
619
+     *
620
+     * @since 1.0.19
621
+     */
622
+    public function process_fees() {
623
+
624
+        $fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this );
625
+
626
+        if ( ! empty( $fees_processor->fee_error) ) {
627
+            $this->last_error = $fees_processor->fee_error;
628
+            return;
629
+        }
630
+
631
+        foreach ( $fees_processor->fees as $fee ) {
632
+            $this->add_fee( $fee );
633
+        }
634
+
635
+        do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) );
636
+    }
637
+
638
+    /**
639
+     * Adds a fee to the submission.
640
+     *
641
+     * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
642
+     * @since 1.0.19
643
+     */
644
+    public function add_fee( $fee ) {
645
+
646
+        $this->total_fees_amount           += wpinv_sanitize_amount( $fee['initial_fee'] );
647
+        $this->total_recurring_fees_amount += wpinv_sanitize_amount( $fee['recurring_fee'] );
648
+        $this->fees[ $fee['name'] ]         = $fee;
649
+
650
+    }
651
+
652
+    /**
653
+     * Removes a fee from the submission.
654
+     *
655
+     * @since 1.0.19
656
+     */
657
+    public function remove_fee( $name ) {
658
+
659
+        if ( isset( $this->fees[ $name ] ) ) {
660
+            $fee                                = $this->fees[ $name ];
661
+            $this->total_fees_amount           -= $fee['initial_fee'];
662
+            $this->total_recurring_fees_amount -= $fee['recurring_fee'];
663
+            unset( $this->fees[ $name ] );
664
+        }
665
+
666
+    }
667
+
668
+    /**
669
+     * Returns the total fees amount.
670
+     *
671
+     * @since 1.0.19
672
+     */
673
+    public function get_total_fees() {
674
+        return $this->total_fees_amount;
675
+    }
676
+
677
+    /**
678
+     * Returns the total recurring fees amount.
679
+     *
680
+     * @since 1.0.19
681
+     */
682
+    public function get_total_recurring_fees() {
683
+        return $this->total_recurring_fees_amount;
684
+    }
685
+
686
+    /**
687
+     * Returns all fees.
688
+     *
689
+     * @since 1.0.19
690
+     */
691
+    public function get_fees() {
692
+        return $this->fees;
693
+    }
694
+
695
+    // MISC //
696
+
697
+    /**
698
+     * Returns the total amount to collect for this submission.
699
+     *
700
+     * @since 1.0.19
701
+     */
702
+    public function get_total() {
703
+        $total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
704
+        $total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this  );
705
+        return wpinv_sanitize_amount( $total );
706
+    }
707
+
708
+    /**
709
+     * Whether payment details should be collected for this submission.
710
+     *
711
+     * @since 1.0.19
712
+     */
713
+    public function get_payment_details() {
714
+        $collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
715
+
716
+        if ( $this->has_recurring ) {
717
+            $collect = true;
718
+        }
719
+
720
+        $collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this  );
721
+        return $collect;
722
+    }
723
+
724
+    /**
725
+     * Returns the billing email of the user.
726
+     *
727
+     * @since 1.0.19
728
+     */
729
+    public function get_billing_email() {
730
+        $billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email'];
731
+        return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this  );
732
+    }
733
+
734
+    /**
735
+     * Checks if the submitter has a billing email.
736
+     *
737
+     * @since 1.0.19
738
+     */
739
+    public function has_billing_email() {
740
+        $billing_email = $this->get_billing_email();
741
+        return ! empty( $billing_email );
742
+    }
743 743
 
744 744
 }
Please login to merge, or discard this patch.
Spacing   +96 added lines, -96 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 		$this->state = wpinv_get_default_state();
162 162
 
163 163
 		// Do we have an actual submission?
164
-		if ( isset( $_POST['getpaid_payment_form_submission'] ) ) {
165
-			$this->load_data( $_POST );
164
+		if (isset($_POST['getpaid_payment_form_submission'])) {
165
+			$this->load_data($_POST);
166 166
 		}
167 167
 
168 168
 	}
@@ -172,29 +172,29 @@  discard block
 block discarded – undo
172 172
 	 *
173 173
 	 * @param array $data
174 174
 	 */
175
-	public function load_data( $data ) {
175
+	public function load_data($data) {
176 176
 
177 177
 		// Prepare submitted data...
178
-		$data = wp_unslash( $data );
178
+		$data = wp_unslash($data);
179 179
 
180 180
 		// Filter the data.
181
-		$data = apply_filters( 'getpaid_submission_data', $data, $this );
181
+		$data = apply_filters('getpaid_submission_data', $data, $this);
182 182
 
183 183
 		$this->data = $data;
184 184
 
185
-		$this->id = md5( wp_json_encode( $data ) );
185
+		$this->id = md5(wp_json_encode($data));
186 186
 
187 187
 		// Every submission needs an active payment form.
188
-		if ( empty( $data['form_id'] ) ) {
189
-			$this->last_error = __( 'Missing payment form', 'invoicing' );
188
+		if (empty($data['form_id'])) {
189
+			$this->last_error = __('Missing payment form', 'invoicing');
190 190
             return;
191 191
 		}
192 192
 
193 193
 		// Fetch the payment form.
194
-		$form = new GetPaid_Payment_Form( $data['form_id'] );
194
+		$form = new GetPaid_Payment_Form($data['form_id']);
195 195
 
196
-		if ( ! $form->is_active() ) {
197
-			$this->last_error = __( 'Payment form not active', 'invoicing' );
196
+		if (!$form->is_active()) {
197
+			$this->last_error = __('Payment form not active', 'invoicing');
198 198
 			return;
199 199
 		}
200 200
 
@@ -202,83 +202,83 @@  discard block
 block discarded – undo
202 202
 		$this->payment_form = $form;
203 203
 
204 204
 		// For existing invoices, make sure that it is valid.
205
-        if ( ! empty( $data['invoice_id'] ) ) {
206
-            $invoice = wpinv_get_invoice( $data['invoice_id'] );
205
+        if (!empty($data['invoice_id'])) {
206
+            $invoice = wpinv_get_invoice($data['invoice_id']);
207 207
 
208
-            if ( empty( $invoice ) ) {
209
-				$this->last_error = __( 'Invalid invoice', 'invoicing' );
208
+            if (empty($invoice)) {
209
+				$this->last_error = __('Invalid invoice', 'invoicing');
210 210
                 return;
211 211
 			}
212 212
 
213
-			if ( $invoice->is_paid() ) {
214
-				$this->last_error = __( 'This invoice is already paid for.', 'invoicing' );
213
+			if ($invoice->is_paid()) {
214
+				$this->last_error = __('This invoice is already paid for.', 'invoicing');
215 215
                 return;
216 216
 			}
217 217
 
218
-			$this->payment_form->set_items( $invoice->get_items() );
218
+			$this->payment_form->set_items($invoice->get_items());
219 219
 
220 220
 			$this->country = $invoice->get_country();
221 221
 			$this->state   = $invoice->get_state();
222 222
 			$this->invoice = $invoice;
223 223
 
224 224
 		// Default forms do not have items.
225
-        } else if ( $form->is_default() && isset( $data['getpaid-items'] ) ) {
226
-			$this->payment_form->set_items( wpinv_clean( $data['getpaid-items'] ) );
225
+        } else if ($form->is_default() && isset($data['getpaid-items'])) {
226
+			$this->payment_form->set_items(wpinv_clean($data['getpaid-items']));
227 227
 		}
228 228
 
229 229
 		// User's country.
230
-		if ( ! empty( $data['wpinv_country'] ) ) {
230
+		if (!empty($data['wpinv_country'])) {
231 231
 			$this->country = $data['wpinv_country'];
232 232
 		}
233 233
 
234 234
 		// User's state.
235
-		if ( ! empty( $data['wpinv_state'] ) ) {
235
+		if (!empty($data['wpinv_state'])) {
236 236
 			$this->country = $data['wpinv_state'];
237 237
 		}
238 238
 
239 239
 		// Handle items.
240 240
 		$selected_items = array();
241
-		if ( ! empty( $data['getpaid-items'] ) ) {
242
-			$selected_items = wpinv_clean( $data['getpaid-items'] );
241
+		if (!empty($data['getpaid-items'])) {
242
+			$selected_items = wpinv_clean($data['getpaid-items']);
243 243
 		}
244 244
 
245
-		foreach ( $this->payment_form->get_items() as $item ) {
245
+		foreach ($this->payment_form->get_items() as $item) {
246 246
 
247 247
 			// Continue if this is an optional item and it has not been selected.
248
-			if ( ! $item->is_required() && ! isset( $selected_items[ $item->get_id() ] ) ) {
248
+			if (!$item->is_required() && !isset($selected_items[$item->get_id()])) {
249 249
 				continue;
250 250
 			}
251 251
 
252 252
 			// (maybe) let customers change the quantities and prices.
253
-			if ( isset( $selected_items[ $item->get_id() ] ) ) {
253
+			if (isset($selected_items[$item->get_id()])) {
254 254
 
255 255
 				// Maybe change the quantities.
256
-				if ( $item->allows_quantities() && is_numeric( $selected_items[ $item->get_id() ]['quantity'] ) ) {
257
-					$item->set_quantity( (int) $selected_items[ $item->get_id() ]['quantity'] );
256
+				if ($item->allows_quantities() && is_numeric($selected_items[$item->get_id()]['quantity'])) {
257
+					$item->set_quantity((int) $selected_items[$item->get_id()]['quantity']);
258 258
 				}
259 259
 
260 260
 				// Maybe change the price.
261
-				if ( $item->user_can_set_their_price() ) {
262
-					$price = (float) wpinv_sanitize_amount( $selected_items[ $item->get_id() ]['price'] );
261
+				if ($item->user_can_set_their_price()) {
262
+					$price = (float) wpinv_sanitize_amount($selected_items[$item->get_id()]['price']);
263 263
 
264 264
 					// But don't get lower than the minimum price.
265
-					if ( $price < $item->get_minimum_price() ) {
265
+					if ($price < $item->get_minimum_price()) {
266 266
 						$price = $item->get_minimum_price();
267 267
 					}
268 268
 
269
-					$item->set_price( $price );
269
+					$item->set_price($price);
270 270
 
271 271
 				}
272 272
 
273 273
 			}
274 274
 
275 275
 			// Add the item to the form.
276
-			$this->add_item( $item );
276
+			$this->add_item($item);
277 277
 
278 278
 		}
279 279
 
280 280
 		// Fired when we are done processing a submission.
281
-		do_action_ref_array( 'getpaid_process_submission', array( &$this ) );
281
+		do_action_ref_array('getpaid_process_submission', array(&$this));
282 282
 
283 283
 		// Handle discounts.
284 284
 		$this->process_discount();
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
 	 * @return bool
313 313
 	 */
314 314
 	public function has_invoice() {
315
-		return ! empty( $this->invoice );
315
+		return !empty($this->invoice);
316 316
 	}
317 317
 
318 318
 	/**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 * @return string
323 323
 	 */
324 324
 	public function get_currency() {
325
-		if ( $this->has_invoice() ) {
325
+		if ($this->has_invoice()) {
326 326
 			return $this->invoice->get_currency();
327 327
 		}
328 328
 		return wpinv_get_currency();
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	 *
344 344
 	 * @since 1.0.19
345 345
 	 */
346
-	public function is_required_field_set( $field ) {
347
-		return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] );
346
+	public function is_required_field_set($field) {
347
+		return empty($field['required']) || !empty($this->data[$field['id']]);
348 348
 	}
349 349
 
350 350
 	///////// Items //////////////
@@ -355,25 +355,25 @@  discard block
 block discarded – undo
355 355
 	 * @since 1.0.19
356 356
 	 * @param GetPaid_Form_Item $item
357 357
 	 */
358
-	public function add_item( $item ) {
358
+	public function add_item($item) {
359 359
 
360 360
 		// Make sure that it is available for purchase.
361
-		if ( ! $item->can_purchase() ) {
361
+		if (!$item->can_purchase()) {
362 362
 			return;
363 363
 		}
364 364
 
365 365
 		// Do we have a recurring item?
366
-		if ( $item->is_recurring() ) {
366
+		if ($item->is_recurring()) {
367 367
 
368
-			if ( $this->has_recurring ) {
369
-				$this->last_error = __( 'You can only buy one recurring item at a time.', 'invoicing' );
368
+			if ($this->has_recurring) {
369
+				$this->last_error = __('You can only buy one recurring item at a time.', 'invoicing');
370 370
 			}
371 371
 
372 372
 			$this->has_recurring = true;
373 373
 
374 374
 		}
375 375
 
376
-		$this->items[ $item->get_id() ] = $item;
376
+		$this->items[$item->get_id()] = $item;
377 377
 
378 378
 		$this->subtotal_amount += $item->get_sub_total();
379 379
 
@@ -384,8 +384,8 @@  discard block
 block discarded – undo
384 384
 	 *
385 385
 	 * @since 1.0.19
386 386
 	 */
387
-	public function get_item( $item_id ) {
388
-		return isset( $this->items[ $item_id ] ) ? $this->items[ $item_id ] : null;
387
+	public function get_item($item_id) {
388
+		return isset($this->items[$item_id]) ? $this->items[$item_id] : null;
389 389
 	}
390 390
 
391 391
 	/**
@@ -414,18 +414,18 @@  discard block
 block discarded – undo
414 414
 	 */
415 415
 	public function process_taxes() {
416 416
 
417
-		$tax_processor = new GetPaid_Payment_Form_Submission_Taxes( $this );
417
+		$tax_processor = new GetPaid_Payment_Form_Submission_Taxes($this);
418 418
 
419
-		if ( ! empty( $tax_processor->tax_error) ) {
419
+		if (!empty($tax_processor->tax_error)) {
420 420
 			$this->last_error = $tax_processor->tax_error;
421 421
 			return;
422 422
 		}
423 423
 
424
-		foreach ( $tax_processor->taxes as $tax ) {
425
-			$this->add_tax( $tax );
424
+		foreach ($tax_processor->taxes as $tax) {
425
+			$this->add_tax($tax);
426 426
 		}
427 427
 
428
-		do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) );
428
+		do_action_ref_array('getpaid_submissions_process_taxes', array(&$this));
429 429
 	}
430 430
 
431 431
 	/**
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
 	 * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required.
435 435
 	 * @since 1.0.19
436 436
 	 */
437
-	public function add_tax( $tax ) {
437
+	public function add_tax($tax) {
438 438
 
439
-		$this->total_tax_amount           += wpinv_sanitize_amount( $tax['initial_tax'] );
440
-		$this->total_recurring_tax_amount += wpinv_sanitize_amount( $tax['recurring_tax'] );
441
-		$this->taxes[ $tax['name'] ]       = $tax;
439
+		$this->total_tax_amount           += wpinv_sanitize_amount($tax['initial_tax']);
440
+		$this->total_recurring_tax_amount += wpinv_sanitize_amount($tax['recurring_tax']);
441
+		$this->taxes[$tax['name']]       = $tax;
442 442
 
443 443
 	}
444 444
 
@@ -451,11 +451,11 @@  discard block
 block discarded – undo
451 451
 
452 452
 		$use_taxes = wpinv_use_taxes();
453 453
 
454
-		if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) {
454
+		if ($this->has_invoice() && !$this->invoice->is_taxable()) {
455 455
 			$use_taxes = false;
456 456
 		}
457 457
 
458
-		return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this );
458
+		return apply_filters('getpaid_submission_use_taxes', $use_taxes, $this);
459 459
 
460 460
 	}
461 461
 
@@ -503,28 +503,28 @@  discard block
 block discarded – undo
503 503
 	public function process_discount() {
504 504
 
505 505
 		$total            = $this->subtotal_amount + $this->get_total_fees() + $this->get_total_tax();
506
-		$discount_handler = new GetPaid_Payment_Form_Submission_Discount( $this, $total );
506
+		$discount_handler = new GetPaid_Payment_Form_Submission_Discount($this, $total);
507 507
 
508
-		if ( ! $discount_handler->is_discount_valid ) {
508
+		if (!$discount_handler->is_discount_valid) {
509 509
 			$this->last_error = $discount_handler->discount_error;
510 510
 			return;
511 511
 		}
512 512
 
513 513
 		// Process any existing invoice discounts.
514
-		if ( $this->has_invoice() ) {
514
+		if ($this->has_invoice()) {
515 515
 			$discounts = $this->get_invoice()->get_discounts();
516 516
 
517
-			foreach ( $discounts as $discount ) {
518
-				$this->add_discount( $discount );
517
+			foreach ($discounts as $discount) {
518
+				$this->add_discount($discount);
519 519
 			}
520 520
 
521 521
 		}
522 522
 
523
-		if ( $discount_handler->has_discount ) {
524
-			$this->add_discount( $discount_handler->calculate_discount( $this ) );
523
+		if ($discount_handler->has_discount) {
524
+			$this->add_discount($discount_handler->calculate_discount($this));
525 525
 		}
526 526
 
527
-		do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) );
527
+		do_action_ref_array('getpaid_submissions_process_discounts', array(&$this));
528 528
 	}
529 529
 
530 530
 	/**
@@ -533,11 +533,11 @@  discard block
 block discarded – undo
533 533
 	 * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code.
534 534
 	 * @since 1.0.19
535 535
 	 */
536
-	public function add_discount( $discount ) {
536
+	public function add_discount($discount) {
537 537
 
538
-		$this->total_discount_amount           += wpinv_sanitize_amount( $discount['initial_discount'] );
539
-		$this->total_recurring_discount_amount += wpinv_sanitize_amount( $discount['recurring_discount'] );
540
-		$this->discounts[ $discount['name'] ]   = $discount;
538
+		$this->total_discount_amount           += wpinv_sanitize_amount($discount['initial_discount']);
539
+		$this->total_recurring_discount_amount += wpinv_sanitize_amount($discount['recurring_discount']);
540
+		$this->discounts[$discount['name']]   = $discount;
541 541
 
542 542
 	}
543 543
 
@@ -546,13 +546,13 @@  discard block
 block discarded – undo
546 546
 	 *
547 547
 	 * @since 1.0.19
548 548
 	 */
549
-	public function remove_discount( $name ) {
549
+	public function remove_discount($name) {
550 550
 
551
-		if ( isset( $this->discounts[ $name ] ) ) {
552
-			$discount                               = $this->discounts[ $name ];
551
+		if (isset($this->discounts[$name])) {
552
+			$discount                               = $this->discounts[$name];
553 553
 			$this->total_discount_amount           -= $discount['initial_discount'];
554 554
 			$this->total_recurring_discount_amount -= $discount['recurring_discount'];
555
-			unset( $this->discounts[ $name ] );
555
+			unset($this->discounts[$name]);
556 556
 		}
557 557
 
558 558
 	}
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
 	 * @return bool
565 565
 	 */
566 566
 	public function has_discount_code() {
567
-		return ! empty( $this->discounts['discount_code'] );
567
+		return !empty($this->discounts['discount_code']);
568 568
 	}
569 569
 
570 570
 	/**
@@ -621,18 +621,18 @@  discard block
 block discarded – undo
621 621
 	 */
622 622
 	public function process_fees() {
623 623
 
624
-		$fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this );
624
+		$fees_processor = new GetPaid_Payment_Form_Submission_Fees($this);
625 625
 
626
-		if ( ! empty( $fees_processor->fee_error) ) {
626
+		if (!empty($fees_processor->fee_error)) {
627 627
 			$this->last_error = $fees_processor->fee_error;
628 628
 			return;
629 629
 		}
630 630
 
631
-		foreach ( $fees_processor->fees as $fee ) {
632
-			$this->add_fee( $fee );
631
+		foreach ($fees_processor->fees as $fee) {
632
+			$this->add_fee($fee);
633 633
 		}
634 634
 
635
-		do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) );
635
+		do_action_ref_array('getpaid_submissions_process_fees', array(&$this));
636 636
 	}
637 637
 
638 638
 	/**
@@ -641,11 +641,11 @@  discard block
 block discarded – undo
641 641
 	 * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required.
642 642
 	 * @since 1.0.19
643 643
 	 */
644
-	public function add_fee( $fee ) {
644
+	public function add_fee($fee) {
645 645
 
646
-		$this->total_fees_amount           += wpinv_sanitize_amount( $fee['initial_fee'] );
647
-		$this->total_recurring_fees_amount += wpinv_sanitize_amount( $fee['recurring_fee'] );
648
-		$this->fees[ $fee['name'] ]         = $fee;
646
+		$this->total_fees_amount           += wpinv_sanitize_amount($fee['initial_fee']);
647
+		$this->total_recurring_fees_amount += wpinv_sanitize_amount($fee['recurring_fee']);
648
+		$this->fees[$fee['name']]         = $fee;
649 649
 
650 650
 	}
651 651
 
@@ -654,13 +654,13 @@  discard block
 block discarded – undo
654 654
 	 *
655 655
 	 * @since 1.0.19
656 656
 	 */
657
-	public function remove_fee( $name ) {
657
+	public function remove_fee($name) {
658 658
 
659
-		if ( isset( $this->fees[ $name ] ) ) {
660
-			$fee                                = $this->fees[ $name ];
659
+		if (isset($this->fees[$name])) {
660
+			$fee                                = $this->fees[$name];
661 661
 			$this->total_fees_amount           -= $fee['initial_fee'];
662 662
 			$this->total_recurring_fees_amount -= $fee['recurring_fee'];
663
-			unset( $this->fees[ $name ] );
663
+			unset($this->fees[$name]);
664 664
 		}
665 665
 
666 666
 	}
@@ -701,8 +701,8 @@  discard block
 block discarded – undo
701 701
 	 */
702 702
 	public function get_total() {
703 703
 		$total = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
704
-		$total = apply_filters( 'getpaid_get_submission_total_amount', $total, $this  );
705
-		return wpinv_sanitize_amount( $total );
704
+		$total = apply_filters('getpaid_get_submission_total_amount', $total, $this);
705
+		return wpinv_sanitize_amount($total);
706 706
 	}
707 707
 
708 708
 	/**
@@ -713,11 +713,11 @@  discard block
 block discarded – undo
713 713
 	public function get_payment_details() {
714 714
 		$collect = $this->subtotal_amount + $this->get_total_fees() - $this->get_total_discount() + $this->get_total_tax();
715 715
 
716
-		if ( $this->has_recurring ) {
716
+		if ($this->has_recurring) {
717 717
 			$collect = true;
718 718
 		}
719 719
 
720
-		$collect = apply_filters( 'getpaid_submission_collect_payment_details', $collect, $this  );
720
+		$collect = apply_filters('getpaid_submission_collect_payment_details', $collect, $this);
721 721
 		return $collect;
722 722
 	}
723 723
 
@@ -727,8 +727,8 @@  discard block
 block discarded – undo
727 727
 	 * @since 1.0.19
728 728
 	 */
729 729
 	public function get_billing_email() {
730
-		$billing_email = empty( $this->data['billing_email'] ) ? '' : $this->data['billing_email'];
731
-		return apply_filters( 'getpaid_get_submission_billing_email', $billing_email, $this  );
730
+		$billing_email = empty($this->data['billing_email']) ? '' : $this->data['billing_email'];
731
+		return apply_filters('getpaid_get_submission_billing_email', $billing_email, $this);
732 732
 	}
733 733
 
734 734
 	/**
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
 	 */
739 739
 	public function has_billing_email() {
740 740
 		$billing_email = $this->get_billing_email();
741
-		return ! empty( $billing_email );
741
+		return !empty($billing_email);
742 742
 	}
743 743
 
744 744
 }
Please login to merge, or discard this patch.
includes/payments/class-getpaid-payment-form-submission-discount.php 2 patches
Indentation   +190 added lines, -190 removed lines patch added patch discarded remove patch
@@ -12,199 +12,199 @@
 block discarded – undo
12 12
  */
13 13
 class GetPaid_Payment_Form_Submission_Discount {
14 14
 
15
-	/**
16
-	 * Whether or not the submission has a discount.
17
-	 * @var bool.
18
-	 */
19
-	public $has_discount = false;
20
-
21
-	/**
22
-	 * Whether or not the discount is valid.
23
-	 * @var bool
24
-	 */
25
-	public $is_discount_valid = true;
26
-
27
-	/**
28
-	 * The discount validation error.
29
-	 * @var string
30
-	 */
31
-	public $discount_error;
32
-
33
-	/**
34
-	 * The discount.
35
-	 * @var WPInv_Discount
36
-	 */
37
-	public $discount;
15
+    /**
16
+     * Whether or not the submission has a discount.
17
+     * @var bool.
18
+     */
19
+    public $has_discount = false;
20
+
21
+    /**
22
+     * Whether or not the discount is valid.
23
+     * @var bool
24
+     */
25
+    public $is_discount_valid = true;
26
+
27
+    /**
28
+     * The discount validation error.
29
+     * @var string
30
+     */
31
+    public $discount_error;
32
+
33
+    /**
34
+     * The discount.
35
+     * @var WPInv_Discount
36
+     */
37
+    public $discount;
38 38
 
39 39
     /**
40
-	 * Class constructor
41
-	 *
42
-	 * @param GetPaid_Payment_Form_Submission $submission
43
-	 * @param float                           $amount
44
-	 */
45
-	public function __construct( $submission, $amount ) {
46
-
47
-		// Do we have a discount?
48
-		$submission_data = $submission->get_data();
49
-		if ( ! empty( $submission_data['discount'] ) ) {
50
-			$this->has_discount = true;
51
-			$this->pre_process_discount( $submission, $submission_data['discount'], $amount );
52
-		}
53
-
54
-	}
55
-
56
-	/**
57
-	 * Preprocesses a submission discount.
58
-	 *
59
-	 * @param GetPaid_Payment_Form_Submission $submission
60
-	 * @param string                          $discount
61
-	 * @param float                           $amount
62
-	 */
63
-	public function pre_process_discount( $submission, $discount, $amount ) {
64
-
65
-		// Fetch the discount.
66
-		$this->discount = new WPInv_Discount( $discount );
67
-
68
-		// Ensure it is active.
40
+     * Class constructor
41
+     *
42
+     * @param GetPaid_Payment_Form_Submission $submission
43
+     * @param float                           $amount
44
+     */
45
+    public function __construct( $submission, $amount ) {
46
+
47
+        // Do we have a discount?
48
+        $submission_data = $submission->get_data();
49
+        if ( ! empty( $submission_data['discount'] ) ) {
50
+            $this->has_discount = true;
51
+            $this->pre_process_discount( $submission, $submission_data['discount'], $amount );
52
+        }
53
+
54
+    }
55
+
56
+    /**
57
+     * Preprocesses a submission discount.
58
+     *
59
+     * @param GetPaid_Payment_Form_Submission $submission
60
+     * @param string                          $discount
61
+     * @param float                           $amount
62
+     */
63
+    public function pre_process_discount( $submission, $discount, $amount ) {
64
+
65
+        // Fetch the discount.
66
+        $this->discount = new WPInv_Discount( $discount );
67
+
68
+        // Ensure it is active.
69 69
         if ( ! $this->is_discount_active( $this->discount ) ) {
70
-			return $this->set_error( __( 'Invalid or expired discount code', 'invoicing' ) );
71
-		}
72
-
73
-		// Exceeded limit.
74
-		if ( $this->discount->has_exceeded_limit() ) {
75
-			return $this->set_error( __( 'This discount code has been used up', 'invoicing' ) );
76
-		}
77
-
78
-		// Validate usages.
79
-		$this->validate_single_use_discount( $submission, $this->discount );
80
-
81
-		// Validate amount.
82
-		$this->validate_discount_amount( $submission, $this->discount, $amount );
83
-	}
84
-
85
-	/**
86
-	 * Validates a single use discount.
87
-	 *
88
-	 * @param WPInv_Discount                  $discount
89
-	 * @return bool
90
-	 */
91
-	public function is_discount_active(  $discount ) {
92
-		return $discount->exists() && $discount->is_active() && $discount->has_started() && ! $discount->is_expired();
93
-	}
94
-
95
-	/**
96
-	 * Sets an error without overwriting the previous error.
97
-	 *
98
-	 * @param string $error
99
-	 */
100
-	public function set_error( $error ) {
101
-		if ( $this->is_discount_valid ) {
102
-			$this->is_discount_valid = false;
103
-			$this->discount_error    = $error;
104
-		}
105
-	}
106
-
107
-	/**
108
-	 * Returns a user's id or email.
109
-	 *
110
-	 * @param string $email
111
-	 * @return int|string|false
112
-	 */
113
-	public function get_user_id_or_email( $email ) {
114
-
115
-		if ( is_user_logged_in() ) {
116
-			return get_current_user_id();
117
-		}
118
-
119
-		return empty( $email ) ? false : sanitize_email( $email );
120
-	}
121
-
122
-	/**
123
-	 * Validates a single use discount.
124
-	 *
125
-	 * @param GetPaid_Payment_Form_Submission $submission
126
-	 * @param WPInv_Discount                  $discount
127
-	 */
128
-	public function validate_single_use_discount( $submission, $discount ) {
129
-
130
-		// Abort if it is not a single use discount.
131
-		if ( ! $discount->is_single_use() ) {
132
-			return;
133
-		}
134
-
135
-		// Ensure there is a valid billing email.
136
-		$user = $this->get_user_id_or_email( $submission->get_billing_email() );
137
-		if ( ! empty( $user ) ) {
138
-			$this->set_error( __( 'You need to either log in or enter your billing email before applying this discount', 'invoicing' ) );
139
-		}
140
-
141
-		// Has the user used this discount code before?
142
-		if ( ! $discount->is_valid_for_user( $user ) ) {
143
-			return $this->set_error( __( 'You have already used this discount', 'invoicing' ) );
144
-		}
145
-
146
-	}
147
-
148
-	/**
149
-	 * Validates the discount's amount.
150
-	 *
151
-	 * @param GetPaid_Payment_Form_Submission $submission
152
-	 * @param WPInv_Discount         $discount
153
-	 * @param float                  $amount
154
-	 */
155
-	public function validate_discount_amount( $submission, $discount, $amount ) {
156
-
157
-		// Validate minimum amount.
158
-		if ( ! $discount->is_minimum_amount_met( $amount ) ) {
70
+            return $this->set_error( __( 'Invalid or expired discount code', 'invoicing' ) );
71
+        }
72
+
73
+        // Exceeded limit.
74
+        if ( $this->discount->has_exceeded_limit() ) {
75
+            return $this->set_error( __( 'This discount code has been used up', 'invoicing' ) );
76
+        }
77
+
78
+        // Validate usages.
79
+        $this->validate_single_use_discount( $submission, $this->discount );
80
+
81
+        // Validate amount.
82
+        $this->validate_discount_amount( $submission, $this->discount, $amount );
83
+    }
84
+
85
+    /**
86
+     * Validates a single use discount.
87
+     *
88
+     * @param WPInv_Discount                  $discount
89
+     * @return bool
90
+     */
91
+    public function is_discount_active(  $discount ) {
92
+        return $discount->exists() && $discount->is_active() && $discount->has_started() && ! $discount->is_expired();
93
+    }
94
+
95
+    /**
96
+     * Sets an error without overwriting the previous error.
97
+     *
98
+     * @param string $error
99
+     */
100
+    public function set_error( $error ) {
101
+        if ( $this->is_discount_valid ) {
102
+            $this->is_discount_valid = false;
103
+            $this->discount_error    = $error;
104
+        }
105
+    }
106
+
107
+    /**
108
+     * Returns a user's id or email.
109
+     *
110
+     * @param string $email
111
+     * @return int|string|false
112
+     */
113
+    public function get_user_id_or_email( $email ) {
114
+
115
+        if ( is_user_logged_in() ) {
116
+            return get_current_user_id();
117
+        }
118
+
119
+        return empty( $email ) ? false : sanitize_email( $email );
120
+    }
121
+
122
+    /**
123
+     * Validates a single use discount.
124
+     *
125
+     * @param GetPaid_Payment_Form_Submission $submission
126
+     * @param WPInv_Discount                  $discount
127
+     */
128
+    public function validate_single_use_discount( $submission, $discount ) {
129
+
130
+        // Abort if it is not a single use discount.
131
+        if ( ! $discount->is_single_use() ) {
132
+            return;
133
+        }
134
+
135
+        // Ensure there is a valid billing email.
136
+        $user = $this->get_user_id_or_email( $submission->get_billing_email() );
137
+        if ( ! empty( $user ) ) {
138
+            $this->set_error( __( 'You need to either log in or enter your billing email before applying this discount', 'invoicing' ) );
139
+        }
140
+
141
+        // Has the user used this discount code before?
142
+        if ( ! $discount->is_valid_for_user( $user ) ) {
143
+            return $this->set_error( __( 'You have already used this discount', 'invoicing' ) );
144
+        }
145
+
146
+    }
147
+
148
+    /**
149
+     * Validates the discount's amount.
150
+     *
151
+     * @param GetPaid_Payment_Form_Submission $submission
152
+     * @param WPInv_Discount         $discount
153
+     * @param float                  $amount
154
+     */
155
+    public function validate_discount_amount( $submission, $discount, $amount ) {
156
+
157
+        // Validate minimum amount.
158
+        if ( ! $discount->is_minimum_amount_met( $amount ) ) {
159 159
             $min = wpinv_price( $discount->get_minimum_total(), $submission->get_currency() );
160
-			return $this->set_error( sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ) );
161
-		}
162
-
163
-		// Validate the maximum amount.
164
-		if ( ! $discount->is_maximum_amount_met( $amount ) ) {
165
-			$max = wpinv_price( $discount->get_maximum_total(), $submission->get_currency() );
166
-			return $this->set_error( sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ) );
167
-		}
168
-
169
-	}
170
-
171
-	/**
172
-	 * Calculates the discount code's amount.
173
-	 *
174
-	 * Ensure that the discount exists and has been validated before calling this method.
175
-	 *
176
-	 * @param GetPaid_Payment_Form_Submission $submission
177
-	 * @return array
178
-	 */
179
-	public function calculate_discount( $submission ) {
180
-
181
-		$initial_discount   = 0;
182
-		$recurring_discount = 0;
183
-
184
-		foreach ( $submission->get_items() as $item ) {
185
-
186
-			// Abort if it is not valid for this item.
187
-			if ( ! $this->discount->is_valid_for_items( array( $item->get_id() ) ) ) {
188
-				continue;
189
-			}
190
-
191
-			// Calculate the initial amount...
192
-			$initial_discount += $this->discount->get_discounted_amount( $item->get_initial_price() * $item->get_quantity() );
193
-
194
-			// ... and maybe the recurring amount.
195
-			if ( $item->is_recurring() && $this->discount->is_recurring() ) {
196
-				$recurring_discount += $this->discount->get_discounted_amount( $item->get_recurring_price() * $item->get_quantity() );
197
-			}
198
-
199
-		}
200
-
201
-		return array(
202
-			'name'               => 'discount_code',
203
-			'discount_code'      => $this->discount->get_code(),
204
-			'initial_discount'   => $initial_discount,
205
-			'recurring_discount' => $recurring_discount,
206
-		);
207
-
208
-	}
160
+            return $this->set_error( sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ) );
161
+        }
162
+
163
+        // Validate the maximum amount.
164
+        if ( ! $discount->is_maximum_amount_met( $amount ) ) {
165
+            $max = wpinv_price( $discount->get_maximum_total(), $submission->get_currency() );
166
+            return $this->set_error( sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ) );
167
+        }
168
+
169
+    }
170
+
171
+    /**
172
+     * Calculates the discount code's amount.
173
+     *
174
+     * Ensure that the discount exists and has been validated before calling this method.
175
+     *
176
+     * @param GetPaid_Payment_Form_Submission $submission
177
+     * @return array
178
+     */
179
+    public function calculate_discount( $submission ) {
180
+
181
+        $initial_discount   = 0;
182
+        $recurring_discount = 0;
183
+
184
+        foreach ( $submission->get_items() as $item ) {
185
+
186
+            // Abort if it is not valid for this item.
187
+            if ( ! $this->discount->is_valid_for_items( array( $item->get_id() ) ) ) {
188
+                continue;
189
+            }
190
+
191
+            // Calculate the initial amount...
192
+            $initial_discount += $this->discount->get_discounted_amount( $item->get_initial_price() * $item->get_quantity() );
193
+
194
+            // ... and maybe the recurring amount.
195
+            if ( $item->is_recurring() && $this->discount->is_recurring() ) {
196
+                $recurring_discount += $this->discount->get_discounted_amount( $item->get_recurring_price() * $item->get_quantity() );
197
+            }
198
+
199
+        }
200
+
201
+        return array(
202
+            'name'               => 'discount_code',
203
+            'discount_code'      => $this->discount->get_code(),
204
+            'initial_discount'   => $initial_discount,
205
+            'recurring_discount' => $recurring_discount,
206
+        );
207
+
208
+    }
209 209
 
210 210
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  *
5 5
  */
6 6
 
7
-defined( 'ABSPATH' ) || exit;
7
+defined('ABSPATH') || exit;
8 8
 
9 9
 /**
10 10
  * Payment form submission discount class
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
 	 * @param GetPaid_Payment_Form_Submission $submission
43 43
 	 * @param float                           $amount
44 44
 	 */
45
-	public function __construct( $submission, $amount ) {
45
+	public function __construct($submission, $amount) {
46 46
 
47 47
 		// Do we have a discount?
48 48
 		$submission_data = $submission->get_data();
49
-		if ( ! empty( $submission_data['discount'] ) ) {
49
+		if (!empty($submission_data['discount'])) {
50 50
 			$this->has_discount = true;
51
-			$this->pre_process_discount( $submission, $submission_data['discount'], $amount );
51
+			$this->pre_process_discount($submission, $submission_data['discount'], $amount);
52 52
 		}
53 53
 
54 54
 	}
@@ -60,26 +60,26 @@  discard block
 block discarded – undo
60 60
 	 * @param string                          $discount
61 61
 	 * @param float                           $amount
62 62
 	 */
63
-	public function pre_process_discount( $submission, $discount, $amount ) {
63
+	public function pre_process_discount($submission, $discount, $amount) {
64 64
 
65 65
 		// Fetch the discount.
66
-		$this->discount = new WPInv_Discount( $discount );
66
+		$this->discount = new WPInv_Discount($discount);
67 67
 
68 68
 		// Ensure it is active.
69
-        if ( ! $this->is_discount_active( $this->discount ) ) {
70
-			return $this->set_error( __( 'Invalid or expired discount code', 'invoicing' ) );
69
+        if (!$this->is_discount_active($this->discount)) {
70
+			return $this->set_error(__('Invalid or expired discount code', 'invoicing'));
71 71
 		}
72 72
 
73 73
 		// Exceeded limit.
74
-		if ( $this->discount->has_exceeded_limit() ) {
75
-			return $this->set_error( __( 'This discount code has been used up', 'invoicing' ) );
74
+		if ($this->discount->has_exceeded_limit()) {
75
+			return $this->set_error(__('This discount code has been used up', 'invoicing'));
76 76
 		}
77 77
 
78 78
 		// Validate usages.
79
-		$this->validate_single_use_discount( $submission, $this->discount );
79
+		$this->validate_single_use_discount($submission, $this->discount);
80 80
 
81 81
 		// Validate amount.
82
-		$this->validate_discount_amount( $submission, $this->discount, $amount );
82
+		$this->validate_discount_amount($submission, $this->discount, $amount);
83 83
 	}
84 84
 
85 85
 	/**
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	 * @param WPInv_Discount                  $discount
89 89
 	 * @return bool
90 90
 	 */
91
-	public function is_discount_active(  $discount ) {
92
-		return $discount->exists() && $discount->is_active() && $discount->has_started() && ! $discount->is_expired();
91
+	public function is_discount_active($discount) {
92
+		return $discount->exists() && $discount->is_active() && $discount->has_started() && !$discount->is_expired();
93 93
 	}
94 94
 
95 95
 	/**
@@ -97,8 +97,8 @@  discard block
 block discarded – undo
97 97
 	 *
98 98
 	 * @param string $error
99 99
 	 */
100
-	public function set_error( $error ) {
101
-		if ( $this->is_discount_valid ) {
100
+	public function set_error($error) {
101
+		if ($this->is_discount_valid) {
102 102
 			$this->is_discount_valid = false;
103 103
 			$this->discount_error    = $error;
104 104
 		}
@@ -110,13 +110,13 @@  discard block
 block discarded – undo
110 110
 	 * @param string $email
111 111
 	 * @return int|string|false
112 112
 	 */
113
-	public function get_user_id_or_email( $email ) {
113
+	public function get_user_id_or_email($email) {
114 114
 
115
-		if ( is_user_logged_in() ) {
115
+		if (is_user_logged_in()) {
116 116
 			return get_current_user_id();
117 117
 		}
118 118
 
119
-		return empty( $email ) ? false : sanitize_email( $email );
119
+		return empty($email) ? false : sanitize_email($email);
120 120
 	}
121 121
 
122 122
 	/**
@@ -125,22 +125,22 @@  discard block
 block discarded – undo
125 125
 	 * @param GetPaid_Payment_Form_Submission $submission
126 126
 	 * @param WPInv_Discount                  $discount
127 127
 	 */
128
-	public function validate_single_use_discount( $submission, $discount ) {
128
+	public function validate_single_use_discount($submission, $discount) {
129 129
 
130 130
 		// Abort if it is not a single use discount.
131
-		if ( ! $discount->is_single_use() ) {
131
+		if (!$discount->is_single_use()) {
132 132
 			return;
133 133
 		}
134 134
 
135 135
 		// Ensure there is a valid billing email.
136
-		$user = $this->get_user_id_or_email( $submission->get_billing_email() );
137
-		if ( ! empty( $user ) ) {
138
-			$this->set_error( __( 'You need to either log in or enter your billing email before applying this discount', 'invoicing' ) );
136
+		$user = $this->get_user_id_or_email($submission->get_billing_email());
137
+		if (!empty($user)) {
138
+			$this->set_error(__('You need to either log in or enter your billing email before applying this discount', 'invoicing'));
139 139
 		}
140 140
 
141 141
 		// Has the user used this discount code before?
142
-		if ( ! $discount->is_valid_for_user( $user ) ) {
143
-			return $this->set_error( __( 'You have already used this discount', 'invoicing' ) );
142
+		if (!$discount->is_valid_for_user($user)) {
143
+			return $this->set_error(__('You have already used this discount', 'invoicing'));
144 144
 		}
145 145
 
146 146
 	}
@@ -152,18 +152,18 @@  discard block
 block discarded – undo
152 152
 	 * @param WPInv_Discount         $discount
153 153
 	 * @param float                  $amount
154 154
 	 */
155
-	public function validate_discount_amount( $submission, $discount, $amount ) {
155
+	public function validate_discount_amount($submission, $discount, $amount) {
156 156
 
157 157
 		// Validate minimum amount.
158
-		if ( ! $discount->is_minimum_amount_met( $amount ) ) {
159
-            $min = wpinv_price( $discount->get_minimum_total(), $submission->get_currency() );
160
-			return $this->set_error( sprintf( __( 'The minimum total for using this discount is %s', 'invoicing' ), $min ) );
158
+		if (!$discount->is_minimum_amount_met($amount)) {
159
+            $min = wpinv_price($discount->get_minimum_total(), $submission->get_currency());
160
+			return $this->set_error(sprintf(__('The minimum total for using this discount is %s', 'invoicing'), $min));
161 161
 		}
162 162
 
163 163
 		// Validate the maximum amount.
164
-		if ( ! $discount->is_maximum_amount_met( $amount ) ) {
165
-			$max = wpinv_price( $discount->get_maximum_total(), $submission->get_currency() );
166
-			return $this->set_error( sprintf( __( 'The maximum total for using this discount is %s', 'invoicing' ), $max ) );
164
+		if (!$discount->is_maximum_amount_met($amount)) {
165
+			$max = wpinv_price($discount->get_maximum_total(), $submission->get_currency());
166
+			return $this->set_error(sprintf(__('The maximum total for using this discount is %s', 'invoicing'), $max));
167 167
 		}
168 168
 
169 169
 	}
@@ -176,24 +176,24 @@  discard block
 block discarded – undo
176 176
 	 * @param GetPaid_Payment_Form_Submission $submission
177 177
 	 * @return array
178 178
 	 */
179
-	public function calculate_discount( $submission ) {
179
+	public function calculate_discount($submission) {
180 180
 
181 181
 		$initial_discount   = 0;
182 182
 		$recurring_discount = 0;
183 183
 
184
-		foreach ( $submission->get_items() as $item ) {
184
+		foreach ($submission->get_items() as $item) {
185 185
 
186 186
 			// Abort if it is not valid for this item.
187
-			if ( ! $this->discount->is_valid_for_items( array( $item->get_id() ) ) ) {
187
+			if (!$this->discount->is_valid_for_items(array($item->get_id()))) {
188 188
 				continue;
189 189
 			}
190 190
 
191 191
 			// Calculate the initial amount...
192
-			$initial_discount += $this->discount->get_discounted_amount( $item->get_initial_price() * $item->get_quantity() );
192
+			$initial_discount += $this->discount->get_discounted_amount($item->get_initial_price() * $item->get_quantity());
193 193
 
194 194
 			// ... and maybe the recurring amount.
195
-			if ( $item->is_recurring() && $this->discount->is_recurring() ) {
196
-				$recurring_discount += $this->discount->get_discounted_amount( $item->get_recurring_price() * $item->get_quantity() );
195
+			if ($item->is_recurring() && $this->discount->is_recurring()) {
196
+				$recurring_discount += $this->discount->get_discounted_amount($item->get_recurring_price() * $item->get_quantity());
197 197
 			}
198 198
 
199 199
 		}
Please login to merge, or discard this patch.