Passed
Push — master ( 66bb46...81484a )
by Brian
06:04
created
includes/class-wpinv-item.php 2 patches
Indentation   +736 added lines, -736 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,30 +10,30 @@  discard block
 block discarded – undo
10 10
 class WPInv_Item  extends GetPaid_Data {
11 11
 
12 12
     /**
13
-	 * Which data store to load.
14
-	 *
15
-	 * @var string
16
-	 */
13
+     * Which data store to load.
14
+     *
15
+     * @var string
16
+     */
17 17
     protected $data_store_name = 'item';
18 18
 
19 19
     /**
20
-	 * This is the name of this object type.
21
-	 *
22
-	 * @var string
23
-	 */
24
-	protected $object_type = 'item';
20
+     * This is the name of this object type.
21
+     *
22
+     * @var string
23
+     */
24
+    protected $object_type = 'item';
25 25
 
26 26
     /**
27
-	 * Item Data array. This is the core item data exposed in APIs.
28
-	 *
29
-	 * @since 1.0.19
30
-	 * @var array
31
-	 */
32
-	protected $data = array(
33
-		'parent_id'            => 0,
34
-		'status'               => 'draft',
35
-		'version'              => '',
36
-		'date_created'         => null,
27
+     * Item Data array. This is the core item data exposed in APIs.
28
+     *
29
+     * @since 1.0.19
30
+     * @var array
31
+     */
32
+    protected $data = array(
33
+        'parent_id'            => 0,
34
+        'status'               => 'draft',
35
+        'version'              => '',
36
+        'date_created'         => null,
37 37
         'date_modified'        => null,
38 38
         'name'                 => '',
39 39
         'description'          => '',
@@ -58,13 +58,13 @@  discard block
 block discarded – undo
58 58
     );
59 59
 
60 60
     /**
61
-	 * Stores meta in cache for future reads.
62
-	 *
63
-	 * A group must be set to to enable caching.
64
-	 *
65
-	 * @var string
66
-	 */
67
-	protected $cache_group = 'getpaid_items';
61
+     * Stores meta in cache for future reads.
62
+     *
63
+     * A group must be set to to enable caching.
64
+     *
65
+     * @var string
66
+     */
67
+    protected $cache_group = 'getpaid_items';
68 68
 
69 69
     /**
70 70
      * Stores a reference to the original WP_Post object
@@ -74,37 +74,37 @@  discard block
 block discarded – undo
74 74
     protected $post = null;
75 75
 
76 76
     /**
77
-	 * Get the item if ID is passed, otherwise the item is new and empty.
78
-	 *
79
-	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80
-	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
83
-
84
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
90
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
-			$this->set_id( $item_id );
92
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
-			$this->set_id( $item_id );
94
-		} else {
95
-			$this->set_object_read( true );
96
-		}
77
+     * Get the item if ID is passed, otherwise the item is new and empty.
78
+     *
79
+     * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80
+     */
81
+    public function __construct( $item = 0 ) {
82
+        parent::__construct( $item );
83
+
84
+        if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
+            $this->set_id( $item );
86
+        } elseif ( $item instanceof self ) {
87
+            $this->set_id( $item->get_id() );
88
+        } elseif ( ! empty( $item->ID ) ) {
89
+            $this->set_id( $item->ID );
90
+        } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
+            $this->set_id( $item_id );
92
+        } elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
+            $this->set_id( $item_id );
94
+        } else {
95
+            $this->set_object_read( true );
96
+        }
97 97
 
98 98
         // Load the datastore.
99
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
99
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
100 100
 
101
-		if ( $this->get_id() > 0 ) {
101
+        if ( $this->get_id() > 0 ) {
102 102
             $this->post = get_post( $this->get_id() );
103 103
             $this->ID   = $this->get_id();
104
-			$this->data_store->read( $this );
104
+            $this->data_store->read( $this );
105 105
         }
106 106
 
107
-	}
107
+    }
108 108
 
109 109
     /*
110 110
 	|--------------------------------------------------------------------------
@@ -122,401 +122,401 @@  discard block
 block discarded – undo
122 122
     */
123 123
 
124 124
     /**
125
-	 * Get parent item ID.
126
-	 *
127
-	 * @since 1.0.19
128
-	 * @param  string $context View or edit context.
129
-	 * @return int
130
-	 */
131
-	public function get_parent_id( $context = 'view' ) {
132
-		return (int) $this->get_prop( 'parent_id', $context );
125
+     * Get parent item ID.
126
+     *
127
+     * @since 1.0.19
128
+     * @param  string $context View or edit context.
129
+     * @return int
130
+     */
131
+    public function get_parent_id( $context = 'view' ) {
132
+        return (int) $this->get_prop( 'parent_id', $context );
133 133
     }
134 134
 
135 135
     /**
136
-	 * Get item status.
137
-	 *
138
-	 * @since 1.0.19
139
-	 * @param  string $context View or edit context.
140
-	 * @return string
141
-	 */
142
-	public function get_status( $context = 'view' ) {
143
-		return $this->get_prop( 'status', $context );
136
+     * Get item status.
137
+     *
138
+     * @since 1.0.19
139
+     * @param  string $context View or edit context.
140
+     * @return string
141
+     */
142
+    public function get_status( $context = 'view' ) {
143
+        return $this->get_prop( 'status', $context );
144 144
     }
145 145
 
146 146
     /**
147
-	 * Get plugin version when the item was created.
148
-	 *
149
-	 * @since 1.0.19
150
-	 * @param  string $context View or edit context.
151
-	 * @return string
152
-	 */
153
-	public function get_version( $context = 'view' ) {
154
-		return $this->get_prop( 'version', $context );
147
+     * Get plugin version when the item was created.
148
+     *
149
+     * @since 1.0.19
150
+     * @param  string $context View or edit context.
151
+     * @return string
152
+     */
153
+    public function get_version( $context = 'view' ) {
154
+        return $this->get_prop( 'version', $context );
155 155
     }
156 156
 
157 157
     /**
158
-	 * Get date when the item was created.
159
-	 *
160
-	 * @since 1.0.19
161
-	 * @param  string $context View or edit context.
162
-	 * @return string
163
-	 */
164
-	public function get_date_created( $context = 'view' ) {
165
-		return $this->get_prop( 'date_created', $context );
158
+     * Get date when the item was created.
159
+     *
160
+     * @since 1.0.19
161
+     * @param  string $context View or edit context.
162
+     * @return string
163
+     */
164
+    public function get_date_created( $context = 'view' ) {
165
+        return $this->get_prop( 'date_created', $context );
166 166
     }
167 167
 
168 168
     /**
169
-	 * Get GMT date when the item was created.
170
-	 *
171
-	 * @since 1.0.19
172
-	 * @param  string $context View or edit context.
173
-	 * @return string
174
-	 */
175
-	public function get_date_created_gmt( $context = 'view' ) {
169
+     * Get GMT date when the item was created.
170
+     *
171
+     * @since 1.0.19
172
+     * @param  string $context View or edit context.
173
+     * @return string
174
+     */
175
+    public function get_date_created_gmt( $context = 'view' ) {
176 176
         $date = $this->get_date_created( $context );
177 177
 
178 178
         if ( $date ) {
179 179
             $date = get_gmt_from_date( $date );
180 180
         }
181
-		return $date;
181
+        return $date;
182 182
     }
183 183
 
184 184
     /**
185
-	 * Get date when the item was last modified.
186
-	 *
187
-	 * @since 1.0.19
188
-	 * @param  string $context View or edit context.
189
-	 * @return string
190
-	 */
191
-	public function get_date_modified( $context = 'view' ) {
192
-		return $this->get_prop( 'date_modified', $context );
185
+     * Get date when the item was last modified.
186
+     *
187
+     * @since 1.0.19
188
+     * @param  string $context View or edit context.
189
+     * @return string
190
+     */
191
+    public function get_date_modified( $context = 'view' ) {
192
+        return $this->get_prop( 'date_modified', $context );
193 193
     }
194 194
 
195 195
     /**
196
-	 * Get GMT date when the item was last modified.
197
-	 *
198
-	 * @since 1.0.19
199
-	 * @param  string $context View or edit context.
200
-	 * @return string
201
-	 */
202
-	public function get_date_modified_gmt( $context = 'view' ) {
196
+     * Get GMT date when the item was last modified.
197
+     *
198
+     * @since 1.0.19
199
+     * @param  string $context View or edit context.
200
+     * @return string
201
+     */
202
+    public function get_date_modified_gmt( $context = 'view' ) {
203 203
         $date = $this->get_date_modified( $context );
204 204
 
205 205
         if ( $date ) {
206 206
             $date = get_gmt_from_date( $date );
207 207
         }
208
-		return $date;
208
+        return $date;
209 209
     }
210 210
 
211 211
     /**
212
-	 * Get the item name.
213
-	 *
214
-	 * @since 1.0.19
215
-	 * @param  string $context View or edit context.
216
-	 * @return string
217
-	 */
218
-	public function get_name( $context = 'view' ) {
219
-		return $this->get_prop( 'name', $context );
212
+     * Get the item name.
213
+     *
214
+     * @since 1.0.19
215
+     * @param  string $context View or edit context.
216
+     * @return string
217
+     */
218
+    public function get_name( $context = 'view' ) {
219
+        return $this->get_prop( 'name', $context );
220 220
     }
221 221
 
222 222
     /**
223
-	 * Alias of self::get_name().
224
-	 *
225
-	 * @since 1.0.19
226
-	 * @param  string $context View or edit context.
227
-	 * @return string
228
-	 */
229
-	public function get_title( $context = 'view' ) {
230
-		return $this->get_name( $context );
223
+     * Alias of self::get_name().
224
+     *
225
+     * @since 1.0.19
226
+     * @param  string $context View or edit context.
227
+     * @return string
228
+     */
229
+    public function get_title( $context = 'view' ) {
230
+        return $this->get_name( $context );
231 231
     }
232 232
 
233 233
     /**
234
-	 * Get the item description.
235
-	 *
236
-	 * @since 1.0.19
237
-	 * @param  string $context View or edit context.
238
-	 * @return string
239
-	 */
240
-	public function get_description( $context = 'view' ) {
241
-		return $this->get_prop( 'description', $context );
234
+     * Get the item description.
235
+     *
236
+     * @since 1.0.19
237
+     * @param  string $context View or edit context.
238
+     * @return string
239
+     */
240
+    public function get_description( $context = 'view' ) {
241
+        return $this->get_prop( 'description', $context );
242 242
     }
243 243
 
244 244
     /**
245
-	 * Alias of self::get_description().
246
-	 *
247
-	 * @since 1.0.19
248
-	 * @param  string $context View or edit context.
249
-	 * @return string
250
-	 */
251
-	public function get_excerpt( $context = 'view' ) {
252
-		return $this->get_description( $context );
245
+     * Alias of self::get_description().
246
+     *
247
+     * @since 1.0.19
248
+     * @param  string $context View or edit context.
249
+     * @return string
250
+     */
251
+    public function get_excerpt( $context = 'view' ) {
252
+        return $this->get_description( $context );
253 253
     }
254 254
 
255 255
     /**
256
-	 * Alias of self::get_description().
257
-	 *
258
-	 * @since 1.0.19
259
-	 * @param  string $context View or edit context.
260
-	 * @return string
261
-	 */
262
-	public function get_summary( $context = 'view' ) {
263
-		return $this->get_description( $context );
256
+     * Alias of self::get_description().
257
+     *
258
+     * @since 1.0.19
259
+     * @param  string $context View or edit context.
260
+     * @return string
261
+     */
262
+    public function get_summary( $context = 'view' ) {
263
+        return $this->get_description( $context );
264 264
     }
265 265
 
266 266
     /**
267
-	 * Get the owner of the item.
268
-	 *
269
-	 * @since 1.0.19
270
-	 * @param  string $context View or edit context.
271
-	 * @return int
272
-	 */
273
-	public function get_author( $context = 'view' ) {
274
-		return (int) $this->get_prop( 'author', $context );
275
-	}
267
+     * Get the owner of the item.
268
+     *
269
+     * @since 1.0.19
270
+     * @param  string $context View or edit context.
271
+     * @return int
272
+     */
273
+    public function get_author( $context = 'view' ) {
274
+        return (int) $this->get_prop( 'author', $context );
275
+    }
276 276
 	
277
-	/**
278
-	 * Alias of self::get_author().
279
-	 *
280
-	 * @since 1.0.19
281
-	 * @param  string $context View or edit context.
282
-	 * @return int
283
-	 */
284
-	public function get_owner( $context = 'view' ) {
285
-		return $this->get_author( $context );
286
-    }
287
-
288
-    /**
289
-	 * Get the price of the item.
290
-	 *
291
-	 * @since 1.0.19
292
-	 * @param  string $context View or edit context.
293
-	 * @return float
294
-	 */
295
-	public function get_price( $context = 'view' ) {
277
+    /**
278
+     * Alias of self::get_author().
279
+     *
280
+     * @since 1.0.19
281
+     * @param  string $context View or edit context.
282
+     * @return int
283
+     */
284
+    public function get_owner( $context = 'view' ) {
285
+        return $this->get_author( $context );
286
+    }
287
+
288
+    /**
289
+     * Get the price of the item.
290
+     *
291
+     * @since 1.0.19
292
+     * @param  string $context View or edit context.
293
+     * @return float
294
+     */
295
+    public function get_price( $context = 'view' ) {
296 296
         return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
297
-	}
297
+    }
298 298
 	
299
-	/**
300
-	 * Get the inital price of the item.
301
-	 *
302
-	 * @since 1.0.19
303
-	 * @param  string $context View or edit context.
304
-	 * @return float
305
-	 */
306
-	public function get_initial_price( $context = 'view' ) {
299
+    /**
300
+     * Get the inital price of the item.
301
+     *
302
+     * @since 1.0.19
303
+     * @param  string $context View or edit context.
304
+     * @return float
305
+     */
306
+    public function get_initial_price( $context = 'view' ) {
307 307
 
308
-		$price = (float) $this->get_price( $context );
308
+        $price = (float) $this->get_price( $context );
309 309
 
310
-		if ( $this->has_free_trial() ) {
311
-			$price = 0;
312
-		}
310
+        if ( $this->has_free_trial() ) {
311
+            $price = 0;
312
+        }
313 313
 
314 314
         return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
315 315
     }
316 316
 
317 317
     /**
318
-	 * Returns a formated price.
319
-	 *
320
-	 * @since 1.0.19
321
-	 * @param  string $context View or edit context.
322
-	 * @return string
323
-	 */
318
+     * Returns a formated price.
319
+     *
320
+     * @since 1.0.19
321
+     * @param  string $context View or edit context.
322
+     * @return string
323
+     */
324 324
     public function get_the_price() {
325 325
         return wpinv_price( wpinv_format_amount( $this->get_price() ) );
326
-	}
327
-
328
-	/**
329
-	 * Returns the formated initial price.
330
-	 *
331
-	 * @since 1.0.19
332
-	 * @param  string $context View or edit context.
333
-	 * @return string
334
-	 */
326
+    }
327
+
328
+    /**
329
+     * Returns the formated initial price.
330
+     *
331
+     * @since 1.0.19
332
+     * @param  string $context View or edit context.
333
+     * @return string
334
+     */
335 335
     public function get_the_initial_price() {
336 336
         return wpinv_price( wpinv_format_amount( $this->get_initial_price() ) );
337 337
     }
338 338
 
339 339
     /**
340
-	 * Get the VAT rule of the item.
341
-	 *
342
-	 * @since 1.0.19
343
-	 * @param  string $context View or edit context.
344
-	 * @return string
345
-	 */
346
-	public function get_vat_rule( $context = 'view' ) {
340
+     * Get the VAT rule of the item.
341
+     *
342
+     * @since 1.0.19
343
+     * @param  string $context View or edit context.
344
+     * @return string
345
+     */
346
+    public function get_vat_rule( $context = 'view' ) {
347 347
         return $this->get_prop( 'vat_rule', $context );
348 348
     }
349 349
 
350 350
     /**
351
-	 * Get the VAT class of the item.
352
-	 *
353
-	 * @since 1.0.19
354
-	 * @param  string $context View or edit context.
355
-	 * @return string
356
-	 */
357
-	public function get_vat_class( $context = 'view' ) {
351
+     * Get the VAT class of the item.
352
+     *
353
+     * @since 1.0.19
354
+     * @param  string $context View or edit context.
355
+     * @return string
356
+     */
357
+    public function get_vat_class( $context = 'view' ) {
358 358
         return $this->get_prop( 'vat_class', $context );
359 359
     }
360 360
 
361 361
     /**
362
-	 * Get the type of the item.
363
-	 *
364
-	 * @since 1.0.19
365
-	 * @param  string $context View or edit context.
366
-	 * @return string
367
-	 */
368
-	public function get_type( $context = 'view' ) {
362
+     * Get the type of the item.
363
+     *
364
+     * @since 1.0.19
365
+     * @param  string $context View or edit context.
366
+     * @return string
367
+     */
368
+    public function get_type( $context = 'view' ) {
369 369
         return $this->get_prop( 'type', $context );
370 370
     }
371 371
 
372 372
     /**
373
-	 * Get the custom id of the item.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_custom_id( $context = 'view' ) {
373
+     * Get the custom id of the item.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_custom_id( $context = 'view' ) {
380 380
         return $this->get_prop( 'custom_id', $context );
381 381
     }
382 382
 
383 383
     /**
384
-	 * Get the custom name of the item.
385
-	 *
386
-	 * @since 1.0.19
387
-	 * @param  string $context View or edit context.
388
-	 * @return string
389
-	 */
390
-	public function get_custom_name( $context = 'view' ) {
384
+     * Get the custom name of the item.
385
+     *
386
+     * @since 1.0.19
387
+     * @param  string $context View or edit context.
388
+     * @return string
389
+     */
390
+    public function get_custom_name( $context = 'view' ) {
391 391
         return $this->get_prop( 'custom_name', $context );
392 392
     }
393 393
 
394 394
     /**
395
-	 * Get the custom singular name of the item.
396
-	 *
397
-	 * @since 1.0.19
398
-	 * @param  string $context View or edit context.
399
-	 * @return string
400
-	 */
401
-	public function get_custom_singular_name( $context = 'view' ) {
395
+     * Get the custom singular name of the item.
396
+     *
397
+     * @since 1.0.19
398
+     * @param  string $context View or edit context.
399
+     * @return string
400
+     */
401
+    public function get_custom_singular_name( $context = 'view' ) {
402 402
         return $this->get_prop( 'custom_singular_name', $context );
403 403
     }
404 404
 
405 405
     /**
406
-	 * Checks if an item is editable..
407
-	 *
408
-	 * @since 1.0.19
409
-	 * @param  string $context View or edit context.
410
-	 * @return int
411
-	 */
412
-	public function get_is_editable( $context = 'view' ) {
406
+     * Checks if an item is editable..
407
+     *
408
+     * @since 1.0.19
409
+     * @param  string $context View or edit context.
410
+     * @return int
411
+     */
412
+    public function get_is_editable( $context = 'view' ) {
413 413
         return (int) $this->get_prop( 'is_editable', $context );
414 414
     }
415 415
 
416 416
     /**
417
-	 * Alias of self::get_is_editable().
418
-	 *
419
-	 * @since 1.0.19
420
-	 * @param  string $context View or edit context.
421
-	 * @return int
422
-	 */
423
-	public function get_editable( $context = 'view' ) {
424
-		return $this->get_is_editable( $context );
417
+     * Alias of self::get_is_editable().
418
+     *
419
+     * @since 1.0.19
420
+     * @param  string $context View or edit context.
421
+     * @return int
422
+     */
423
+    public function get_editable( $context = 'view' ) {
424
+        return $this->get_is_editable( $context );
425 425
     }
426 426
 
427 427
     /**
428
-	 * Checks if dynamic pricing is enabled.
429
-	 *
430
-	 * @since 1.0.19
431
-	 * @param  string $context View or edit context.
432
-	 * @return int
433
-	 */
434
-	public function get_is_dynamic_pricing( $context = 'view' ) {
428
+     * Checks if dynamic pricing is enabled.
429
+     *
430
+     * @since 1.0.19
431
+     * @param  string $context View or edit context.
432
+     * @return int
433
+     */
434
+    public function get_is_dynamic_pricing( $context = 'view' ) {
435 435
         return (int) $this->get_prop( 'is_dynamic_pricing', $context );
436 436
     }
437 437
 
438 438
     /**
439
-	 * Returns the minimum price if dynamic pricing is enabled.
440
-	 *
441
-	 * @since 1.0.19
442
-	 * @param  string $context View or edit context.
443
-	 * @return float
444
-	 */
445
-	public function get_minimum_price( $context = 'view' ) {
439
+     * Returns the minimum price if dynamic pricing is enabled.
440
+     *
441
+     * @since 1.0.19
442
+     * @param  string $context View or edit context.
443
+     * @return float
444
+     */
445
+    public function get_minimum_price( $context = 'view' ) {
446 446
         return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
447 447
     }
448 448
 
449 449
     /**
450
-	 * Checks if this is a recurring item.
451
-	 *
452
-	 * @since 1.0.19
453
-	 * @param  string $context View or edit context.
454
-	 * @return int
455
-	 */
456
-	public function get_is_recurring( $context = 'view' ) {
450
+     * Checks if this is a recurring item.
451
+     *
452
+     * @since 1.0.19
453
+     * @param  string $context View or edit context.
454
+     * @return int
455
+     */
456
+    public function get_is_recurring( $context = 'view' ) {
457 457
         return (int) $this->get_prop( 'is_recurring', $context );
458
-	}
458
+    }
459 459
 	
460
-	/**
461
-	 * Get the recurring price of the item.
462
-	 *
463
-	 * @since 1.0.19
464
-	 * @param  string $context View or edit context.
465
-	 * @return float
466
-	 */
467
-	public function get_recurring_price( $context = 'view' ) {
468
-		$price = $this->get_price( $context );
460
+    /**
461
+     * Get the recurring price of the item.
462
+     *
463
+     * @since 1.0.19
464
+     * @param  string $context View or edit context.
465
+     * @return float
466
+     */
467
+    public function get_recurring_price( $context = 'view' ) {
468
+        $price = $this->get_price( $context );
469 469
         return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
470
-	}
471
-
472
-	/**
473
-	 * Get the formatted recurring price of the item.
474
-	 *
475
-	 * @since 1.0.19
476
-	 * @param  string $context View or edit context.
477
-	 * @return string
478
-	 */
470
+    }
471
+
472
+    /**
473
+     * Get the formatted recurring price of the item.
474
+     *
475
+     * @since 1.0.19
476
+     * @param  string $context View or edit context.
477
+     * @return string
478
+     */
479 479
     public function get_the_recurring_price() {
480 480
         return wpinv_price( wpinv_format_amount( $this->get_recurring_price() ) );
481
-	}
482
-
483
-	/**
484
-	 * Get the first renewal date (in timestamps) of the item.
485
-	 *
486
-	 * @since 1.0.19
487
-	 * @return int
488
-	 */
489
-	public function get_first_renewal_date() {
490
-
491
-		$periods = array(
492
-			'D' => 'days',
493
-			'W' => 'weeks',
494
-			'M' => 'months',
495
-			'Y' => 'years',
496
-		);
497
-
498
-		$period   = $this->get_recurring_period();
499
-		$interval = $this->get_recurring_interval();
500
-
501
-		if ( $this->has_free_trial() ) {
502
-			$period   = $this->get_trial_period();
503
-			$interval = $this->get_trial_interval();
504
-		}
505
-
506
-		$period       = $periods[ $period ];
507
-		$interval     = empty( $interval ) ? 1 : $interval;
508
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
481
+    }
482
+
483
+    /**
484
+     * Get the first renewal date (in timestamps) of the item.
485
+     *
486
+     * @since 1.0.19
487
+     * @return int
488
+     */
489
+    public function get_first_renewal_date() {
490
+
491
+        $periods = array(
492
+            'D' => 'days',
493
+            'W' => 'weeks',
494
+            'M' => 'months',
495
+            'Y' => 'years',
496
+        );
497
+
498
+        $period   = $this->get_recurring_period();
499
+        $interval = $this->get_recurring_interval();
500
+
501
+        if ( $this->has_free_trial() ) {
502
+            $period   = $this->get_trial_period();
503
+            $interval = $this->get_trial_interval();
504
+        }
505
+
506
+        $period       = $periods[ $period ];
507
+        $interval     = empty( $interval ) ? 1 : $interval;
508
+        $next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
509 509
         return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
510 510
     }
511 511
 
512 512
     /**
513
-	 * Get the recurring period.
514
-	 *
515
-	 * @since 1.0.19
516
-	 * @param  bool $full Return abbreviation or in full.
517
-	 * @return string
518
-	 */
519
-	public function get_recurring_period( $full = false ) {
513
+     * Get the recurring period.
514
+     *
515
+     * @since 1.0.19
516
+     * @param  bool $full Return abbreviation or in full.
517
+     * @return string
518
+     */
519
+    public function get_recurring_period( $full = false ) {
520 520
         $period = $this->get_prop( 'recurring_period', 'view' );
521 521
 
522 522
         if ( $full && ! is_bool( $full ) ) {
@@ -527,63 +527,63 @@  discard block
 block discarded – undo
527 527
     }
528 528
 
529 529
     /**
530
-	 * Get the recurring interval.
531
-	 *
532
-	 * @since 1.0.19
533
-	 * @param  string $context View or edit context.
534
-	 * @return int
535
-	 */
536
-	public function get_recurring_interval( $context = 'view' ) {
537
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
530
+     * Get the recurring interval.
531
+     *
532
+     * @since 1.0.19
533
+     * @param  string $context View or edit context.
534
+     * @return int
535
+     */
536
+    public function get_recurring_interval( $context = 'view' ) {
537
+        $interval = absint( $this->get_prop( 'recurring_interval', $context ) );
538 538
 
539
-		if ( $interval < 1 ) {
540
-			$interval = 1;
541
-		}
539
+        if ( $interval < 1 ) {
540
+            $interval = 1;
541
+        }
542 542
 
543 543
         return $interval;
544 544
     }
545 545
 
546 546
     /**
547
-	 * Get the recurring limit.
548
-	 *
549
-	 * @since 1.0.19
550
-	 * @param  string $context View or edit context.
551
-	 * @return int
552
-	 */
553
-	public function get_recurring_limit( $context = 'view' ) {
547
+     * Get the recurring limit.
548
+     *
549
+     * @since 1.0.19
550
+     * @param  string $context View or edit context.
551
+     * @return int
552
+     */
553
+    public function get_recurring_limit( $context = 'view' ) {
554 554
         return (int) $this->get_prop( 'recurring_limit', $context );
555 555
     }
556 556
 
557 557
     /**
558
-	 * Checks if we have a free trial.
559
-	 *
560
-	 * @since 1.0.19
561
-	 * @param  string $context View or edit context.
562
-	 * @return int
563
-	 */
564
-	public function get_is_free_trial( $context = 'view' ) {
558
+     * Checks if we have a free trial.
559
+     *
560
+     * @since 1.0.19
561
+     * @param  string $context View or edit context.
562
+     * @return int
563
+     */
564
+    public function get_is_free_trial( $context = 'view' ) {
565 565
         return (int) $this->get_prop( 'is_free_trial', $context );
566 566
     }
567 567
 
568 568
     /**
569
-	 * Alias for self::get_is_free_trial().
570
-	 *
571
-	 * @since 1.0.19
572
-	 * @param  string $context View or edit context.
573
-	 * @return int
574
-	 */
575
-	public function get_free_trial( $context = 'view' ) {
569
+     * Alias for self::get_is_free_trial().
570
+     *
571
+     * @since 1.0.19
572
+     * @param  string $context View or edit context.
573
+     * @return int
574
+     */
575
+    public function get_free_trial( $context = 'view' ) {
576 576
         return $this->get_is_free_trial( $context );
577 577
     }
578 578
 
579 579
     /**
580
-	 * Get the trial period.
581
-	 *
582
-	 * @since 1.0.19
583
-	 * @param  bool $full Return abbreviation or in full.
584
-	 * @return string
585
-	 */
586
-	public function get_trial_period( $full = false ) {
580
+     * Get the trial period.
581
+     *
582
+     * @since 1.0.19
583
+     * @param  bool $full Return abbreviation or in full.
584
+     * @return string
585
+     */
586
+    public function get_trial_period( $full = false ) {
587 587
         $period = $this->get_prop( 'trial_period', 'view' );
588 588
 
589 589
         if ( $full && ! is_bool( $full ) ) {
@@ -594,105 +594,105 @@  discard block
 block discarded – undo
594 594
     }
595 595
 
596 596
     /**
597
-	 * Get the trial interval.
598
-	 *
599
-	 * @since 1.0.19
600
-	 * @param  string $context View or edit context.
601
-	 * @return int
602
-	 */
603
-	public function get_trial_interval( $context = 'view' ) {
597
+     * Get the trial interval.
598
+     *
599
+     * @since 1.0.19
600
+     * @param  string $context View or edit context.
601
+     * @return int
602
+     */
603
+    public function get_trial_interval( $context = 'view' ) {
604 604
         return (int) $this->get_prop( 'trial_interval', $context );
605
-	}
605
+    }
606 606
 	
607
-	/**
608
-	 * Get the item's edit url.
609
-	 *
610
-	 * @since 1.0.19
611
-	 * @return string
612
-	 */
613
-	public function get_edit_url() {
607
+    /**
608
+     * Get the item's edit url.
609
+     *
610
+     * @since 1.0.19
611
+     * @return string
612
+     */
613
+    public function get_edit_url() {
614 614
         return get_edit_post_link( $this->get_id() );
615
-	}
616
-
617
-	/**
618
-	 * Given an item's name/custom id, it returns its id.
619
-	 *
620
-	 *
621
-	 * @static
622
-	 * @param string $value The item name or custom id.
623
-	 * @param string $field Either name or custom_id.
624
-	 * @param string $type in case you need to search for a given type.
625
-	 * @since 1.0.15
626
-	 * @return int
627
-	 */
628
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
629
-
630
-		// Trim the value.
631
-		$value = sanitize_text_field( $value );
632
-
633
-		if ( empty( $value ) ) {
634
-			return 0;
635
-		}
615
+    }
616
+
617
+    /**
618
+     * Given an item's name/custom id, it returns its id.
619
+     *
620
+     *
621
+     * @static
622
+     * @param string $value The item name or custom id.
623
+     * @param string $field Either name or custom_id.
624
+     * @param string $type in case you need to search for a given type.
625
+     * @since 1.0.15
626
+     * @return int
627
+     */
628
+    public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
629
+
630
+        // Trim the value.
631
+        $value = sanitize_text_field( $value );
632
+
633
+        if ( empty( $value ) ) {
634
+            return 0;
635
+        }
636 636
 
637 637
         // Valid fields.
638 638
         $fields = array( 'custom_id', 'name', 'slug' );
639 639
 
640
-		// Ensure a field has been passed.
641
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
642
-			return 0;
643
-		}
644
-
645
-		if ( $field == 'name' ) {
646
-			$field = 'slug';
647
-		} 
648
-
649
-		// Maybe retrieve from the cache.
650
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
651
-		if ( ! empty( $item_id ) ) {
652
-			return $item_id;
653
-		}
654
-
655
-		// Fetch from the db.
656
-		$items = array();
657
-		if ( $field =='slug' ) {
658
-			$items = get_posts(
659
-				array(
660
-					'post_type'      => 'wpi_item',
661
-					'name'           => $value,
662
-					'posts_per_page' => 1,
663
-					'post_status'    => 'any',
664
-				)
665
-			);
666
-		}
667
-
668
-		if ( $field =='custom_id' ) {
669
-			$items = get_posts(
670
-				array(
671
-					'post_type'      => 'wpi_item',
672
-					'posts_per_page' => 1,
673
-					'post_status'    => 'any',
674
-					'meta_query'     => array(
675
-						array(
676
-							'key'   => '_wpinv_type',
677
-                			'value' => $type,
678
-						),
679
-						array(
680
-							'key'   => '_wpinv_custom_id',
681
-                			'value' => $type,
682
-						)
683
-					)
684
-				)
685
-			);
686
-		}
687
-
688
-		if ( empty( $items ) ) {
689
-			return 0;
690
-		}
691
-
692
-		// Update the cache with our data
693
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
694
-
695
-		return $items[0]->ID;
640
+        // Ensure a field has been passed.
641
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
642
+            return 0;
643
+        }
644
+
645
+        if ( $field == 'name' ) {
646
+            $field = 'slug';
647
+        } 
648
+
649
+        // Maybe retrieve from the cache.
650
+        $item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
651
+        if ( ! empty( $item_id ) ) {
652
+            return $item_id;
653
+        }
654
+
655
+        // Fetch from the db.
656
+        $items = array();
657
+        if ( $field =='slug' ) {
658
+            $items = get_posts(
659
+                array(
660
+                    'post_type'      => 'wpi_item',
661
+                    'name'           => $value,
662
+                    'posts_per_page' => 1,
663
+                    'post_status'    => 'any',
664
+                )
665
+            );
666
+        }
667
+
668
+        if ( $field =='custom_id' ) {
669
+            $items = get_posts(
670
+                array(
671
+                    'post_type'      => 'wpi_item',
672
+                    'posts_per_page' => 1,
673
+                    'post_status'    => 'any',
674
+                    'meta_query'     => array(
675
+                        array(
676
+                            'key'   => '_wpinv_type',
677
+                            'value' => $type,
678
+                        ),
679
+                        array(
680
+                            'key'   => '_wpinv_custom_id',
681
+                            'value' => $type,
682
+                        )
683
+                    )
684
+                )
685
+            );
686
+        }
687
+
688
+        if ( empty( $items ) ) {
689
+            return 0;
690
+        }
691
+
692
+        // Update the cache with our data
693
+        wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
694
+
695
+        return $items[0]->ID;
696 696
     }
697 697
 
698 698
     /**
@@ -725,52 +725,52 @@  discard block
 block discarded – undo
725 725
     */
726 726
 
727 727
     /**
728
-	 * Set parent order ID.
729
-	 *
730
-	 * @since 1.0.19
731
-	 */
732
-	public function set_parent_id( $value ) {
733
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
734
-			return;
735
-		}
736
-		$this->set_prop( 'parent_id', absint( $value ) );
737
-	}
738
-
739
-    /**
740
-	 * Sets item status.
741
-	 *
742
-	 * @since 1.0.19
743
-	 * @param  string $status New status.
744
-	 * @return array details of change.
745
-	 */
746
-	public function set_status( $status ) {
728
+     * Set parent order ID.
729
+     *
730
+     * @since 1.0.19
731
+     */
732
+    public function set_parent_id( $value ) {
733
+        if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
734
+            return;
735
+        }
736
+        $this->set_prop( 'parent_id', absint( $value ) );
737
+    }
738
+
739
+    /**
740
+     * Sets item status.
741
+     *
742
+     * @since 1.0.19
743
+     * @param  string $status New status.
744
+     * @return array details of change.
745
+     */
746
+    public function set_status( $status ) {
747 747
         $old_status = $this->get_status();
748 748
 
749 749
         $this->set_prop( 'status', $status );
750 750
 
751
-		return array(
752
-			'from' => $old_status,
753
-			'to'   => $status,
754
-		);
751
+        return array(
752
+            'from' => $old_status,
753
+            'to'   => $status,
754
+        );
755 755
     }
756 756
 
757 757
     /**
758
-	 * Set plugin version when the item was created.
759
-	 *
760
-	 * @since 1.0.19
761
-	 */
762
-	public function set_version( $value ) {
763
-		$this->set_prop( 'version', $value );
758
+     * Set plugin version when the item was created.
759
+     *
760
+     * @since 1.0.19
761
+     */
762
+    public function set_version( $value ) {
763
+        $this->set_prop( 'version', $value );
764 764
     }
765 765
 
766 766
     /**
767
-	 * Set date when the item was created.
768
-	 *
769
-	 * @since 1.0.19
770
-	 * @param string $value Value to set.
767
+     * Set date when the item was created.
768
+     *
769
+     * @since 1.0.19
770
+     * @param string $value Value to set.
771 771
      * @return bool Whether or not the date was set.
772
-	 */
773
-	public function set_date_created( $value ) {
772
+     */
773
+    public function set_date_created( $value ) {
774 774
         $date = strtotime( $value );
775 775
 
776 776
         if ( $date ) {
@@ -783,13 +783,13 @@  discard block
 block discarded – undo
783 783
     }
784 784
 
785 785
     /**
786
-	 * Set date when the item was last modified.
787
-	 *
788
-	 * @since 1.0.19
789
-	 * @param string $value Value to set.
786
+     * Set date when the item was last modified.
787
+     *
788
+     * @since 1.0.19
789
+     * @param string $value Value to set.
790 790
      * @return bool Whether or not the date was set.
791
-	 */
792
-	public function set_date_modified( $value ) {
791
+     */
792
+    public function set_date_modified( $value ) {
793 793
         $date = strtotime( $value );
794 794
 
795 795
         if ( $date ) {
@@ -802,115 +802,115 @@  discard block
 block discarded – undo
802 802
     }
803 803
 
804 804
     /**
805
-	 * Set the item name.
806
-	 *
807
-	 * @since 1.0.19
808
-	 * @param  string $value New name.
809
-	 */
810
-	public function set_name( $value ) {
805
+     * Set the item name.
806
+     *
807
+     * @since 1.0.19
808
+     * @param  string $value New name.
809
+     */
810
+    public function set_name( $value ) {
811 811
         $name = sanitize_text_field( $value );
812
-		$this->set_prop( 'name', $name );
812
+        $this->set_prop( 'name', $name );
813 813
     }
814 814
 
815 815
     /**
816
-	 * Alias of self::set_name().
817
-	 *
818
-	 * @since 1.0.19
819
-	 * @param  string $value New name.
820
-	 */
821
-	public function set_title( $value ) {
822
-		$this->set_name( $value );
816
+     * Alias of self::set_name().
817
+     *
818
+     * @since 1.0.19
819
+     * @param  string $value New name.
820
+     */
821
+    public function set_title( $value ) {
822
+        $this->set_name( $value );
823 823
     }
824 824
 
825 825
     /**
826
-	 * Set the item description.
827
-	 *
828
-	 * @since 1.0.19
829
-	 * @param  string $value New description.
830
-	 */
831
-	public function set_description( $value ) {
826
+     * Set the item description.
827
+     *
828
+     * @since 1.0.19
829
+     * @param  string $value New description.
830
+     */
831
+    public function set_description( $value ) {
832 832
         $description = wp_kses_post( $value );
833
-		return $this->set_prop( 'description', $description );
833
+        return $this->set_prop( 'description', $description );
834 834
     }
835 835
 
836 836
     /**
837
-	 * Alias of self::set_description().
838
-	 *
839
-	 * @since 1.0.19
840
-	 * @param  string $value New description.
841
-	 */
842
-	public function set_excerpt( $value ) {
843
-		$this->set_description( $value );
837
+     * Alias of self::set_description().
838
+     *
839
+     * @since 1.0.19
840
+     * @param  string $value New description.
841
+     */
842
+    public function set_excerpt( $value ) {
843
+        $this->set_description( $value );
844 844
     }
845 845
 
846 846
     /**
847
-	 * Alias of self::set_description().
848
-	 *
849
-	 * @since 1.0.19
850
-	 * @param  string $value New description.
851
-	 */
852
-	public function set_summary( $value ) {
853
-		$this->set_description( $value );
847
+     * Alias of self::set_description().
848
+     *
849
+     * @since 1.0.19
850
+     * @param  string $value New description.
851
+     */
852
+    public function set_summary( $value ) {
853
+        $this->set_description( $value );
854 854
     }
855 855
 
856 856
     /**
857
-	 * Set the owner of the item.
858
-	 *
859
-	 * @since 1.0.19
860
-	 * @param  int $value New author.
861
-	 */
862
-	public function set_author( $value ) {
863
-		$this->set_prop( 'author', (int) $value );
864
-	}
857
+     * Set the owner of the item.
858
+     *
859
+     * @since 1.0.19
860
+     * @param  int $value New author.
861
+     */
862
+    public function set_author( $value ) {
863
+        $this->set_prop( 'author', (int) $value );
864
+    }
865 865
 	
866
-	/**
867
-	 * Alias of self::set_author().
868
-	 *
869
-	 * @since 1.0.19
870
-	 * @param  int $value New author.
871
-	 */
872
-	public function set_owner( $value ) {
873
-		$this->set_author( $value );
874
-    }
875
-
876
-    /**
877
-	 * Set the price of the item.
878
-	 *
879
-	 * @since 1.0.19
880
-	 * @param  float $value New price.
881
-	 */
882
-	public function set_price( $value ) {
866
+    /**
867
+     * Alias of self::set_author().
868
+     *
869
+     * @since 1.0.19
870
+     * @param  int $value New author.
871
+     */
872
+    public function set_owner( $value ) {
873
+        $this->set_author( $value );
874
+    }
875
+
876
+    /**
877
+     * Set the price of the item.
878
+     *
879
+     * @since 1.0.19
880
+     * @param  float $value New price.
881
+     */
882
+    public function set_price( $value ) {
883 883
         $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
884 884
     }
885 885
 
886 886
     /**
887
-	 * Set the VAT rule of the item.
888
-	 *
889
-	 * @since 1.0.19
890
-	 * @param  string $value new rule.
891
-	 */
892
-	public function set_vat_rule( $value ) {
887
+     * Set the VAT rule of the item.
888
+     *
889
+     * @since 1.0.19
890
+     * @param  string $value new rule.
891
+     */
892
+    public function set_vat_rule( $value ) {
893 893
         $this->set_prop( 'vat_rule', $value );
894 894
     }
895 895
 
896 896
     /**
897
-	 * Set the VAT class of the item.
898
-	 *
899
-	 * @since 1.0.19
900
-	 * @param  string $value new class.
901
-	 */
902
-	public function set_vat_class( $value ) {
897
+     * Set the VAT class of the item.
898
+     *
899
+     * @since 1.0.19
900
+     * @param  string $value new class.
901
+     */
902
+    public function set_vat_class( $value ) {
903 903
         $this->set_prop( 'vat_class', $value );
904 904
     }
905 905
 
906 906
     /**
907
-	 * Set the type of the item.
908
-	 *
909
-	 * @since 1.0.19
910
-	 * @param  string $value new item type.
911
-	 * @return string
912
-	 */
913
-	public function set_type( $value ) {
907
+     * Set the type of the item.
908
+     *
909
+     * @since 1.0.19
910
+     * @param  string $value new item type.
911
+     * @return string
912
+     */
913
+    public function set_type( $value ) {
914 914
 
915 915
         if ( empty( $value ) ) {
916 916
             $value = 'custom';
@@ -920,134 +920,134 @@  discard block
 block discarded – undo
920 920
     }
921 921
 
922 922
     /**
923
-	 * Set the custom id of the item.
924
-	 *
925
-	 * @since 1.0.19
926
-	 * @param  string $value new custom id.
927
-	 */
928
-	public function set_custom_id( $value ) {
923
+     * Set the custom id of the item.
924
+     *
925
+     * @since 1.0.19
926
+     * @param  string $value new custom id.
927
+     */
928
+    public function set_custom_id( $value ) {
929 929
         $this->set_prop( 'custom_id', $value );
930 930
     }
931 931
 
932 932
     /**
933
-	 * Set the custom name of the item.
934
-	 *
935
-	 * @since 1.0.19
936
-	 * @param  string $value new custom name.
937
-	 */
938
-	public function set_custom_name( $value ) {
933
+     * Set the custom name of the item.
934
+     *
935
+     * @since 1.0.19
936
+     * @param  string $value new custom name.
937
+     */
938
+    public function set_custom_name( $value ) {
939 939
         $this->set_prop( 'custom_name', $value );
940 940
     }
941 941
 
942 942
     /**
943
-	 * Set the custom singular name of the item.
944
-	 *
945
-	 * @since 1.0.19
946
-	 * @param  string $value new custom singular name.
947
-	 */
948
-	public function set_custom_singular_name( $value ) {
943
+     * Set the custom singular name of the item.
944
+     *
945
+     * @since 1.0.19
946
+     * @param  string $value new custom singular name.
947
+     */
948
+    public function set_custom_singular_name( $value ) {
949 949
         $this->set_prop( 'custom_singular_name', $value );
950 950
     }
951 951
 
952 952
     /**
953
-	 * Sets if an item is editable..
954
-	 *
955
-	 * @since 1.0.19
956
-	 * @param  int|bool $value whether or not the item is editable.
957
-	 */
958
-	public function set_is_editable( $value ) {
959
-		if ( is_numeric( $value ) ) {
960
-			$this->set_prop( 'is_editable', (int) $value );
961
-		}
953
+     * Sets if an item is editable..
954
+     *
955
+     * @since 1.0.19
956
+     * @param  int|bool $value whether or not the item is editable.
957
+     */
958
+    public function set_is_editable( $value ) {
959
+        if ( is_numeric( $value ) ) {
960
+            $this->set_prop( 'is_editable', (int) $value );
961
+        }
962 962
     }
963 963
 
964 964
     /**
965
-	 * Sets if dynamic pricing is enabled.
966
-	 *
967
-	 * @since 1.0.19
968
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
969
-	 */
970
-	public function set_is_dynamic_pricing( $value ) {
965
+     * Sets if dynamic pricing is enabled.
966
+     *
967
+     * @since 1.0.19
968
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
969
+     */
970
+    public function set_is_dynamic_pricing( $value ) {
971 971
         $this->set_prop( 'is_dynamic_pricing', (int) $value );
972 972
     }
973 973
 
974 974
     /**
975
-	 * Sets the minimum price if dynamic pricing is enabled.
976
-	 *
977
-	 * @since 1.0.19
978
-	 * @param  float $value minimum price.
979
-	 */
980
-	public function set_minimum_price( $value ) {
975
+     * Sets the minimum price if dynamic pricing is enabled.
976
+     *
977
+     * @since 1.0.19
978
+     * @param  float $value minimum price.
979
+     */
980
+    public function set_minimum_price( $value ) {
981 981
         $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
982 982
     }
983 983
 
984 984
     /**
985
-	 * Sets if this is a recurring item.
986
-	 *
987
-	 * @since 1.0.19
988
-	 * @param  int|bool $value whether or not dynamic pricing is allowed.
989
-	 */
990
-	public function set_is_recurring( $value ) {
985
+     * Sets if this is a recurring item.
986
+     *
987
+     * @since 1.0.19
988
+     * @param  int|bool $value whether or not dynamic pricing is allowed.
989
+     */
990
+    public function set_is_recurring( $value ) {
991 991
         $this->set_prop( 'is_recurring', (int) $value );
992 992
     }
993 993
 
994 994
     /**
995
-	 * Set the recurring period.
996
-	 *
997
-	 * @since 1.0.19
998
-	 * @param  string $value new period.
999
-	 */
1000
-	public function set_recurring_period( $value ) {
995
+     * Set the recurring period.
996
+     *
997
+     * @since 1.0.19
998
+     * @param  string $value new period.
999
+     */
1000
+    public function set_recurring_period( $value ) {
1001 1001
         $this->set_prop( 'recurring_period', $value );
1002 1002
     }
1003 1003
 
1004 1004
     /**
1005
-	 * Set the recurring interval.
1006
-	 *
1007
-	 * @since 1.0.19
1008
-	 * @param  int $value recurring interval.
1009
-	 */
1010
-	public function set_recurring_interval( $value ) {
1005
+     * Set the recurring interval.
1006
+     *
1007
+     * @since 1.0.19
1008
+     * @param  int $value recurring interval.
1009
+     */
1010
+    public function set_recurring_interval( $value ) {
1011 1011
         return $this->set_prop( 'recurring_interval', (int) $value );
1012 1012
     }
1013 1013
 
1014 1014
     /**
1015
-	 * Get the recurring limit.
1016
-	 * @since 1.0.19
1017
-	 * @param  int $value The recurring limit.
1018
-	 * @return int
1019
-	 */
1020
-	public function set_recurring_limit( $value ) {
1015
+     * Get the recurring limit.
1016
+     * @since 1.0.19
1017
+     * @param  int $value The recurring limit.
1018
+     * @return int
1019
+     */
1020
+    public function set_recurring_limit( $value ) {
1021 1021
         $this->set_prop( 'recurring_limit', (int) $value );
1022 1022
     }
1023 1023
 
1024 1024
     /**
1025
-	 * Checks if we have a free trial.
1026
-	 *
1027
-	 * @since 1.0.19
1028
-	 * @param  int|bool $value whether or not it has a free trial.
1029
-	 */
1030
-	public function set_is_free_trial( $value ) {
1025
+     * Checks if we have a free trial.
1026
+     *
1027
+     * @since 1.0.19
1028
+     * @param  int|bool $value whether or not it has a free trial.
1029
+     */
1030
+    public function set_is_free_trial( $value ) {
1031 1031
         $this->set_prop( 'is_free_trial', (int) $value );
1032 1032
     }
1033 1033
 
1034 1034
     /**
1035
-	 * Set the trial period.
1036
-	 *
1037
-	 * @since 1.0.19
1038
-	 * @param  string $value trial period.
1039
-	 */
1040
-	public function set_trial_period( $value ) {
1035
+     * Set the trial period.
1036
+     *
1037
+     * @since 1.0.19
1038
+     * @param  string $value trial period.
1039
+     */
1040
+    public function set_trial_period( $value ) {
1041 1041
         $this->set_prop( 'trial_period', $value );
1042 1042
     }
1043 1043
 
1044 1044
     /**
1045
-	 * Set the trial interval.
1046
-	 *
1047
-	 * @since 1.0.19
1048
-	 * @param  int $value trial interval.
1049
-	 */
1050
-	public function set_trial_interval( $value ) {
1045
+     * Set the trial interval.
1046
+     *
1047
+     * @since 1.0.19
1048
+     * @param  int $value trial interval.
1049
+     */
1050
+    public function set_trial_interval( $value ) {
1051 1051
         $this->set_prop( 'trial_interval', $value );
1052 1052
     }
1053 1053
 
@@ -1055,17 +1055,17 @@  discard block
 block discarded – undo
1055 1055
      * Create an item. For backwards compatibilty.
1056 1056
      * 
1057 1057
      * @deprecated
1058
-	 * @return int item id
1058
+     * @return int item id
1059 1059
      */
1060 1060
     public function create( $data = array() ) {
1061 1061
 
1062
-		// Set the properties.
1063
-		if ( is_array( $data ) ) {
1064
-			$this->set_props( $data );
1065
-		}
1062
+        // Set the properties.
1063
+        if ( is_array( $data ) ) {
1064
+            $this->set_props( $data );
1065
+        }
1066 1066
 
1067
-		// Save the item.
1068
-		return $this->save();
1067
+        // Save the item.
1068
+        return $this->save();
1069 1069
 
1070 1070
     }
1071 1071
 
@@ -1073,7 +1073,7 @@  discard block
 block discarded – undo
1073 1073
      * Updates an item. For backwards compatibilty.
1074 1074
      * 
1075 1075
      * @deprecated
1076
-	 * @return int item id
1076
+     * @return int item id
1077 1077
      */
1078 1078
     public function update( $data = array() ) {
1079 1079
         return $this->create( $data );
@@ -1089,84 +1089,84 @@  discard block
 block discarded – undo
1089 1089
 	*/
1090 1090
 
1091 1091
     /**
1092
-	 * Checks whether the item has enabled dynamic pricing.
1093
-	 *
1094
-	 * @since 1.0.19
1095
-	 * @return bool
1096
-	 */
1097
-	public function user_can_set_their_price() {
1092
+     * Checks whether the item has enabled dynamic pricing.
1093
+     *
1094
+     * @since 1.0.19
1095
+     * @return bool
1096
+     */
1097
+    public function user_can_set_their_price() {
1098 1098
         return (bool) $this->get_is_dynamic_pricing();
1099
-	}
1099
+    }
1100 1100
 	
1101
-	/**
1102
-	 * Checks whether the item is recurring.
1103
-	 *
1104
-	 * @since 1.0.19
1105
-	 * @return bool
1106
-	 */
1107
-	public function is_recurring() {
1101
+    /**
1102
+     * Checks whether the item is recurring.
1103
+     *
1104
+     * @since 1.0.19
1105
+     * @return bool
1106
+     */
1107
+    public function is_recurring() {
1108 1108
         return (bool) $this->get_is_recurring();
1109 1109
     }
1110 1110
 
1111 1111
     /**
1112
-	 * Checks whether the item has a free trial.
1113
-	 *
1114
-	 * @since 1.0.19
1115
-	 * @return bool
1116
-	 */
1112
+     * Checks whether the item has a free trial.
1113
+     *
1114
+     * @since 1.0.19
1115
+     * @return bool
1116
+     */
1117 1117
     public function has_free_trial() {
1118 1118
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1119 1119
         return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1120 1120
     }
1121 1121
 
1122 1122
     /**
1123
-	 * Checks whether the item is free.
1124
-	 *
1125
-	 * @since 1.0.19
1126
-	 * @return bool
1127
-	 */
1123
+     * Checks whether the item is free.
1124
+     *
1125
+     * @since 1.0.19
1126
+     * @return bool
1127
+     */
1128 1128
     public function is_free() {
1129 1129
         $is_free   = $this->get_price() == 0;
1130 1130
         return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1131 1131
     }
1132 1132
 
1133 1133
     /**
1134
-	 * Checks the item status against a passed in status.
1135
-	 *
1136
-	 * @param array|string $status Status to check.
1137
-	 * @return bool
1138
-	 */
1139
-	public function has_status( $status ) {
1140
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1141
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1134
+     * Checks the item status against a passed in status.
1135
+     *
1136
+     * @param array|string $status Status to check.
1137
+     * @return bool
1138
+     */
1139
+    public function has_status( $status ) {
1140
+        $has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1141
+        return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1142 1142
     }
1143 1143
 
1144 1144
     /**
1145
-	 * Checks the item type against a passed in types.
1146
-	 *
1147
-	 * @param array|string $type Type to check.
1148
-	 * @return bool
1149
-	 */
1150
-	public function is_type( $type ) {
1151
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1152
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1153
-	}
1145
+     * Checks the item type against a passed in types.
1146
+     *
1147
+     * @param array|string $type Type to check.
1148
+     * @return bool
1149
+     */
1150
+    public function is_type( $type ) {
1151
+        $is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1152
+        return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1153
+    }
1154 1154
 
1155 1155
     /**
1156
-	 * Checks whether the item is editable.
1157
-	 *
1158
-	 * @since 1.0.19
1159
-	 * @return bool
1160
-	 */
1156
+     * Checks whether the item is editable.
1157
+     *
1158
+     * @since 1.0.19
1159
+     * @return bool
1160
+     */
1161 1161
     public function is_editable() {
1162 1162
         $is_editable = $this->get_is_editable();
1163 1163
         return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1164
-	}
1164
+    }
1165 1165
 
1166
-	/**
1167
-	 * Returns an array of cart fees.
1168
-	 */
1169
-	public function get_fees( $type = 'fee', $item_id = 0 ) {
1166
+    /**
1167
+     * Returns an array of cart fees.
1168
+     */
1169
+    public function get_fees( $type = 'fee', $item_id = 0 ) {
1170 1170
         
1171 1171
         $fees = getpaid_session()->get( 'wpi_cart_fees' );
1172 1172
 
@@ -1209,11 +1209,11 @@  discard block
 block discarded – undo
1209 1209
     }
1210 1210
 
1211 1211
     /**
1212
-	 * Checks whether the item is purchasable.
1213
-	 *
1214
-	 * @since 1.0.19
1215
-	 * @return bool
1216
-	 */
1212
+     * Checks whether the item is purchasable.
1213
+     *
1214
+     * @since 1.0.19
1215
+     * @return bool
1216
+     */
1217 1217
     public function can_purchase() {
1218 1218
         $can_purchase = null !== $this->get_id();
1219 1219
 
@@ -1225,11 +1225,11 @@  discard block
 block discarded – undo
1225 1225
     }
1226 1226
 
1227 1227
     /**
1228
-	 * Checks whether the item supports dynamic pricing.
1229
-	 *
1230
-	 * @since 1.0.19
1231
-	 * @return bool
1232
-	 */
1228
+     * Checks whether the item supports dynamic pricing.
1229
+     *
1230
+     * @since 1.0.19
1231
+     * @return bool
1232
+     */
1233 1233
     public function supports_dynamic_pricing() {
1234 1234
         return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1235 1235
     }
Please login to merge, or discard this patch.
Spacing   +229 added lines, -229 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'ABSPATH' ) ) {
2
+if (!defined('ABSPATH')) {
3 3
 	exit;
4 4
 }
5 5
 
@@ -78,30 +78,30 @@  discard block
 block discarded – undo
78 78
 	 *
79 79
 	 * @param  int|object|WPInv_Item|WP_Post $item Item to read.
80 80
 	 */
81
-	public function __construct( $item = 0 ) {
82
-		parent::__construct( $item );
83
-
84
-		if ( ! empty( $item ) && is_numeric( $item ) && 'wpi_item' == get_post_type( $item ) ) {
85
-			$this->set_id( $item );
86
-		} elseif ( $item instanceof self ) {
87
-			$this->set_id( $item->get_id() );
88
-		} elseif ( ! empty( $item->ID ) ) {
89
-			$this->set_id( $item->ID );
90
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'custom_id' ) ) {
91
-			$this->set_id( $item_id );
92
-		} elseif ( is_scalar( $item ) && $item_id = self::get_item_id_by_field( $item, 'name' ) ) {
93
-			$this->set_id( $item_id );
81
+	public function __construct($item = 0) {
82
+		parent::__construct($item);
83
+
84
+		if (!empty($item) && is_numeric($item) && 'wpi_item' == get_post_type($item)) {
85
+			$this->set_id($item);
86
+		} elseif ($item instanceof self) {
87
+			$this->set_id($item->get_id());
88
+		} elseif (!empty($item->ID)) {
89
+			$this->set_id($item->ID);
90
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'custom_id')) {
91
+			$this->set_id($item_id);
92
+		} elseif (is_scalar($item) && $item_id = self::get_item_id_by_field($item, 'name')) {
93
+			$this->set_id($item_id);
94 94
 		} else {
95
-			$this->set_object_read( true );
95
+			$this->set_object_read(true);
96 96
 		}
97 97
 
98 98
         // Load the datastore.
99
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
99
+		$this->data_store = GetPaid_Data_Store::load($this->data_store_name);
100 100
 
101
-		if ( $this->get_id() > 0 ) {
102
-            $this->post = get_post( $this->get_id() );
101
+		if ($this->get_id() > 0) {
102
+            $this->post = get_post($this->get_id());
103 103
             $this->ID   = $this->get_id();
104
-			$this->data_store->read( $this );
104
+			$this->data_store->read($this);
105 105
         }
106 106
 
107 107
 	}
@@ -128,8 +128,8 @@  discard block
 block discarded – undo
128 128
 	 * @param  string $context View or edit context.
129 129
 	 * @return int
130 130
 	 */
131
-	public function get_parent_id( $context = 'view' ) {
132
-		return (int) $this->get_prop( 'parent_id', $context );
131
+	public function get_parent_id($context = 'view') {
132
+		return (int) $this->get_prop('parent_id', $context);
133 133
     }
134 134
 
135 135
     /**
@@ -139,8 +139,8 @@  discard block
 block discarded – undo
139 139
 	 * @param  string $context View or edit context.
140 140
 	 * @return string
141 141
 	 */
142
-	public function get_status( $context = 'view' ) {
143
-		return $this->get_prop( 'status', $context );
142
+	public function get_status($context = 'view') {
143
+		return $this->get_prop('status', $context);
144 144
     }
145 145
 
146 146
     /**
@@ -150,8 +150,8 @@  discard block
 block discarded – undo
150 150
 	 * @param  string $context View or edit context.
151 151
 	 * @return string
152 152
 	 */
153
-	public function get_version( $context = 'view' ) {
154
-		return $this->get_prop( 'version', $context );
153
+	public function get_version($context = 'view') {
154
+		return $this->get_prop('version', $context);
155 155
     }
156 156
 
157 157
     /**
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 * @param  string $context View or edit context.
162 162
 	 * @return string
163 163
 	 */
164
-	public function get_date_created( $context = 'view' ) {
165
-		return $this->get_prop( 'date_created', $context );
164
+	public function get_date_created($context = 'view') {
165
+		return $this->get_prop('date_created', $context);
166 166
     }
167 167
 
168 168
     /**
@@ -172,11 +172,11 @@  discard block
 block discarded – undo
172 172
 	 * @param  string $context View or edit context.
173 173
 	 * @return string
174 174
 	 */
175
-	public function get_date_created_gmt( $context = 'view' ) {
176
-        $date = $this->get_date_created( $context );
175
+	public function get_date_created_gmt($context = 'view') {
176
+        $date = $this->get_date_created($context);
177 177
 
178
-        if ( $date ) {
179
-            $date = get_gmt_from_date( $date );
178
+        if ($date) {
179
+            $date = get_gmt_from_date($date);
180 180
         }
181 181
 		return $date;
182 182
     }
@@ -188,8 +188,8 @@  discard block
 block discarded – undo
188 188
 	 * @param  string $context View or edit context.
189 189
 	 * @return string
190 190
 	 */
191
-	public function get_date_modified( $context = 'view' ) {
192
-		return $this->get_prop( 'date_modified', $context );
191
+	public function get_date_modified($context = 'view') {
192
+		return $this->get_prop('date_modified', $context);
193 193
     }
194 194
 
195 195
     /**
@@ -199,11 +199,11 @@  discard block
 block discarded – undo
199 199
 	 * @param  string $context View or edit context.
200 200
 	 * @return string
201 201
 	 */
202
-	public function get_date_modified_gmt( $context = 'view' ) {
203
-        $date = $this->get_date_modified( $context );
202
+	public function get_date_modified_gmt($context = 'view') {
203
+        $date = $this->get_date_modified($context);
204 204
 
205
-        if ( $date ) {
206
-            $date = get_gmt_from_date( $date );
205
+        if ($date) {
206
+            $date = get_gmt_from_date($date);
207 207
         }
208 208
 		return $date;
209 209
     }
@@ -215,8 +215,8 @@  discard block
 block discarded – undo
215 215
 	 * @param  string $context View or edit context.
216 216
 	 * @return string
217 217
 	 */
218
-	public function get_name( $context = 'view' ) {
219
-		return $this->get_prop( 'name', $context );
218
+	public function get_name($context = 'view') {
219
+		return $this->get_prop('name', $context);
220 220
     }
221 221
 
222 222
     /**
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 * @param  string $context View or edit context.
227 227
 	 * @return string
228 228
 	 */
229
-	public function get_title( $context = 'view' ) {
230
-		return $this->get_name( $context );
229
+	public function get_title($context = 'view') {
230
+		return $this->get_name($context);
231 231
     }
232 232
 
233 233
     /**
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 * @param  string $context View or edit context.
238 238
 	 * @return string
239 239
 	 */
240
-	public function get_description( $context = 'view' ) {
241
-		return $this->get_prop( 'description', $context );
240
+	public function get_description($context = 'view') {
241
+		return $this->get_prop('description', $context);
242 242
     }
243 243
 
244 244
     /**
@@ -248,8 +248,8 @@  discard block
 block discarded – undo
248 248
 	 * @param  string $context View or edit context.
249 249
 	 * @return string
250 250
 	 */
251
-	public function get_excerpt( $context = 'view' ) {
252
-		return $this->get_description( $context );
251
+	public function get_excerpt($context = 'view') {
252
+		return $this->get_description($context);
253 253
     }
254 254
 
255 255
     /**
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 	 * @param  string $context View or edit context.
260 260
 	 * @return string
261 261
 	 */
262
-	public function get_summary( $context = 'view' ) {
263
-		return $this->get_description( $context );
262
+	public function get_summary($context = 'view') {
263
+		return $this->get_description($context);
264 264
     }
265 265
 
266 266
     /**
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 * @param  string $context View or edit context.
271 271
 	 * @return int
272 272
 	 */
273
-	public function get_author( $context = 'view' ) {
274
-		return (int) $this->get_prop( 'author', $context );
273
+	public function get_author($context = 'view') {
274
+		return (int) $this->get_prop('author', $context);
275 275
 	}
276 276
 	
277 277
 	/**
@@ -281,8 +281,8 @@  discard block
 block discarded – undo
281 281
 	 * @param  string $context View or edit context.
282 282
 	 * @return int
283 283
 	 */
284
-	public function get_owner( $context = 'view' ) {
285
-		return $this->get_author( $context );
284
+	public function get_owner($context = 'view') {
285
+		return $this->get_author($context);
286 286
     }
287 287
 
288 288
     /**
@@ -292,8 +292,8 @@  discard block
 block discarded – undo
292 292
 	 * @param  string $context View or edit context.
293 293
 	 * @return float
294 294
 	 */
295
-	public function get_price( $context = 'view' ) {
296
-        return wpinv_sanitize_amount( $this->get_prop( 'price', $context ) );
295
+	public function get_price($context = 'view') {
296
+        return wpinv_sanitize_amount($this->get_prop('price', $context));
297 297
 	}
298 298
 	
299 299
 	/**
@@ -303,15 +303,15 @@  discard block
 block discarded – undo
303 303
 	 * @param  string $context View or edit context.
304 304
 	 * @return float
305 305
 	 */
306
-	public function get_initial_price( $context = 'view' ) {
306
+	public function get_initial_price($context = 'view') {
307 307
 
308
-		$price = (float) $this->get_price( $context );
308
+		$price = (float) $this->get_price($context);
309 309
 
310
-		if ( $this->has_free_trial() ) {
310
+		if ($this->has_free_trial()) {
311 311
 			$price = 0;
312 312
 		}
313 313
 
314
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_initial_item_price', $price, $this ) );
314
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_initial_item_price', $price, $this));
315 315
     }
316 316
 
317 317
     /**
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	 * @return string
323 323
 	 */
324 324
     public function get_the_price() {
325
-        return wpinv_price( wpinv_format_amount( $this->get_price() ) );
325
+        return wpinv_price(wpinv_format_amount($this->get_price()));
326 326
 	}
327 327
 
328 328
 	/**
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 	 * @return string
334 334
 	 */
335 335
     public function get_the_initial_price() {
336
-        return wpinv_price( wpinv_format_amount( $this->get_initial_price() ) );
336
+        return wpinv_price(wpinv_format_amount($this->get_initial_price()));
337 337
     }
338 338
 
339 339
     /**
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	 * @param  string $context View or edit context.
344 344
 	 * @return string
345 345
 	 */
346
-	public function get_vat_rule( $context = 'view' ) {
347
-        return $this->get_prop( 'vat_rule', $context );
346
+	public function get_vat_rule($context = 'view') {
347
+        return $this->get_prop('vat_rule', $context);
348 348
     }
349 349
 
350 350
     /**
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 	 * @param  string $context View or edit context.
355 355
 	 * @return string
356 356
 	 */
357
-	public function get_vat_class( $context = 'view' ) {
358
-        return $this->get_prop( 'vat_class', $context );
357
+	public function get_vat_class($context = 'view') {
358
+        return $this->get_prop('vat_class', $context);
359 359
     }
360 360
 
361 361
     /**
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @param  string $context View or edit context.
366 366
 	 * @return string
367 367
 	 */
368
-	public function get_type( $context = 'view' ) {
369
-        return $this->get_prop( 'type', $context );
368
+	public function get_type($context = 'view') {
369
+        return $this->get_prop('type', $context);
370 370
     }
371 371
 
372 372
     /**
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	 * @param  string $context View or edit context.
377 377
 	 * @return string
378 378
 	 */
379
-	public function get_custom_id( $context = 'view' ) {
380
-        return $this->get_prop( 'custom_id', $context );
379
+	public function get_custom_id($context = 'view') {
380
+        return $this->get_prop('custom_id', $context);
381 381
     }
382 382
 
383 383
     /**
@@ -387,8 +387,8 @@  discard block
 block discarded – undo
387 387
 	 * @param  string $context View or edit context.
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_custom_name( $context = 'view' ) {
391
-        return $this->get_prop( 'custom_name', $context );
390
+	public function get_custom_name($context = 'view') {
391
+        return $this->get_prop('custom_name', $context);
392 392
     }
393 393
 
394 394
     /**
@@ -398,8 +398,8 @@  discard block
 block discarded – undo
398 398
 	 * @param  string $context View or edit context.
399 399
 	 * @return string
400 400
 	 */
401
-	public function get_custom_singular_name( $context = 'view' ) {
402
-        return $this->get_prop( 'custom_singular_name', $context );
401
+	public function get_custom_singular_name($context = 'view') {
402
+        return $this->get_prop('custom_singular_name', $context);
403 403
     }
404 404
 
405 405
     /**
@@ -409,8 +409,8 @@  discard block
 block discarded – undo
409 409
 	 * @param  string $context View or edit context.
410 410
 	 * @return int
411 411
 	 */
412
-	public function get_is_editable( $context = 'view' ) {
413
-        return (int) $this->get_prop( 'is_editable', $context );
412
+	public function get_is_editable($context = 'view') {
413
+        return (int) $this->get_prop('is_editable', $context);
414 414
     }
415 415
 
416 416
     /**
@@ -420,8 +420,8 @@  discard block
 block discarded – undo
420 420
 	 * @param  string $context View or edit context.
421 421
 	 * @return int
422 422
 	 */
423
-	public function get_editable( $context = 'view' ) {
424
-		return $this->get_is_editable( $context );
423
+	public function get_editable($context = 'view') {
424
+		return $this->get_is_editable($context);
425 425
     }
426 426
 
427 427
     /**
@@ -431,8 +431,8 @@  discard block
 block discarded – undo
431 431
 	 * @param  string $context View or edit context.
432 432
 	 * @return int
433 433
 	 */
434
-	public function get_is_dynamic_pricing( $context = 'view' ) {
435
-        return (int) $this->get_prop( 'is_dynamic_pricing', $context );
434
+	public function get_is_dynamic_pricing($context = 'view') {
435
+        return (int) $this->get_prop('is_dynamic_pricing', $context);
436 436
     }
437 437
 
438 438
     /**
@@ -442,8 +442,8 @@  discard block
 block discarded – undo
442 442
 	 * @param  string $context View or edit context.
443 443
 	 * @return float
444 444
 	 */
445
-	public function get_minimum_price( $context = 'view' ) {
446
-        return wpinv_sanitize_amount( $this->get_prop( 'minimum_price', $context ) );
445
+	public function get_minimum_price($context = 'view') {
446
+        return wpinv_sanitize_amount($this->get_prop('minimum_price', $context));
447 447
     }
448 448
 
449 449
     /**
@@ -453,8 +453,8 @@  discard block
 block discarded – undo
453 453
 	 * @param  string $context View or edit context.
454 454
 	 * @return int
455 455
 	 */
456
-	public function get_is_recurring( $context = 'view' ) {
457
-        return (int) $this->get_prop( 'is_recurring', $context );
456
+	public function get_is_recurring($context = 'view') {
457
+        return (int) $this->get_prop('is_recurring', $context);
458 458
 	}
459 459
 	
460 460
 	/**
@@ -464,9 +464,9 @@  discard block
 block discarded – undo
464 464
 	 * @param  string $context View or edit context.
465 465
 	 * @return float
466 466
 	 */
467
-	public function get_recurring_price( $context = 'view' ) {
468
-		$price = $this->get_price( $context );
469
-        return wpinv_sanitize_amount( apply_filters( 'wpinv_get_recurring_item_price', $price, $this->ID ) );
467
+	public function get_recurring_price($context = 'view') {
468
+		$price = $this->get_price($context);
469
+        return wpinv_sanitize_amount(apply_filters('wpinv_get_recurring_item_price', $price, $this->ID));
470 470
 	}
471 471
 
472 472
 	/**
@@ -477,7 +477,7 @@  discard block
 block discarded – undo
477 477
 	 * @return string
478 478
 	 */
479 479
     public function get_the_recurring_price() {
480
-        return wpinv_price( wpinv_format_amount( $this->get_recurring_price() ) );
480
+        return wpinv_price(wpinv_format_amount($this->get_recurring_price()));
481 481
 	}
482 482
 
483 483
 	/**
@@ -498,15 +498,15 @@  discard block
 block discarded – undo
498 498
 		$period   = $this->get_recurring_period();
499 499
 		$interval = $this->get_recurring_interval();
500 500
 
501
-		if ( $this->has_free_trial() ) {
501
+		if ($this->has_free_trial()) {
502 502
 			$period   = $this->get_trial_period();
503 503
 			$interval = $this->get_trial_interval();
504 504
 		}
505 505
 
506
-		$period       = $periods[ $period ];
507
-		$interval     = empty( $interval ) ? 1 : $interval;
508
-		$next_renewal = strtotime( "+$interval $period", current_time( 'timestamp' ) );
509
-        return apply_filters( 'wpinv_get_first_renewal_date', $next_renewal, $this );
506
+		$period       = $periods[$period];
507
+		$interval     = empty($interval) ? 1 : $interval;
508
+		$next_renewal = strtotime("+$interval $period", current_time('timestamp'));
509
+        return apply_filters('wpinv_get_first_renewal_date', $next_renewal, $this);
510 510
     }
511 511
 
512 512
     /**
@@ -516,14 +516,14 @@  discard block
 block discarded – undo
516 516
 	 * @param  bool $full Return abbreviation or in full.
517 517
 	 * @return string
518 518
 	 */
519
-	public function get_recurring_period( $full = false ) {
520
-        $period = $this->get_prop( 'recurring_period', 'view' );
519
+	public function get_recurring_period($full = false) {
520
+        $period = $this->get_prop('recurring_period', 'view');
521 521
 
522
-        if ( $full && ! is_bool( $full ) ) {
522
+        if ($full && !is_bool($full)) {
523 523
             $full = false;
524 524
         }
525 525
 
526
-        return getpaid_sanitize_recurring_period( $period, $full );
526
+        return getpaid_sanitize_recurring_period($period, $full);
527 527
     }
528 528
 
529 529
     /**
@@ -533,10 +533,10 @@  discard block
 block discarded – undo
533 533
 	 * @param  string $context View or edit context.
534 534
 	 * @return int
535 535
 	 */
536
-	public function get_recurring_interval( $context = 'view' ) {
537
-		$interval = absint( $this->get_prop( 'recurring_interval', $context ) );
536
+	public function get_recurring_interval($context = 'view') {
537
+		$interval = absint($this->get_prop('recurring_interval', $context));
538 538
 
539
-		if ( $interval < 1 ) {
539
+		if ($interval < 1) {
540 540
 			$interval = 1;
541 541
 		}
542 542
 
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
 	 * @param  string $context View or edit context.
551 551
 	 * @return int
552 552
 	 */
553
-	public function get_recurring_limit( $context = 'view' ) {
554
-        return (int) $this->get_prop( 'recurring_limit', $context );
553
+	public function get_recurring_limit($context = 'view') {
554
+        return (int) $this->get_prop('recurring_limit', $context);
555 555
     }
556 556
 
557 557
     /**
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 	 * @param  string $context View or edit context.
562 562
 	 * @return int
563 563
 	 */
564
-	public function get_is_free_trial( $context = 'view' ) {
565
-        return (int) $this->get_prop( 'is_free_trial', $context );
564
+	public function get_is_free_trial($context = 'view') {
565
+        return (int) $this->get_prop('is_free_trial', $context);
566 566
     }
567 567
 
568 568
     /**
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 	 * @param  string $context View or edit context.
573 573
 	 * @return int
574 574
 	 */
575
-	public function get_free_trial( $context = 'view' ) {
576
-        return $this->get_is_free_trial( $context );
575
+	public function get_free_trial($context = 'view') {
576
+        return $this->get_is_free_trial($context);
577 577
     }
578 578
 
579 579
     /**
@@ -583,14 +583,14 @@  discard block
 block discarded – undo
583 583
 	 * @param  bool $full Return abbreviation or in full.
584 584
 	 * @return string
585 585
 	 */
586
-	public function get_trial_period( $full = false ) {
587
-        $period = $this->get_prop( 'trial_period', 'view' );
586
+	public function get_trial_period($full = false) {
587
+        $period = $this->get_prop('trial_period', 'view');
588 588
 
589
-        if ( $full && ! is_bool( $full ) ) {
589
+        if ($full && !is_bool($full)) {
590 590
             $full = false;
591 591
         }
592 592
 
593
-        return getpaid_sanitize_recurring_period( $period, $full );
593
+        return getpaid_sanitize_recurring_period($period, $full);
594 594
     }
595 595
 
596 596
     /**
@@ -600,8 +600,8 @@  discard block
 block discarded – undo
600 600
 	 * @param  string $context View or edit context.
601 601
 	 * @return int
602 602
 	 */
603
-	public function get_trial_interval( $context = 'view' ) {
604
-        return (int) $this->get_prop( 'trial_interval', $context );
603
+	public function get_trial_interval($context = 'view') {
604
+        return (int) $this->get_prop('trial_interval', $context);
605 605
 	}
606 606
 	
607 607
 	/**
@@ -611,7 +611,7 @@  discard block
 block discarded – undo
611 611
 	 * @return string
612 612
 	 */
613 613
 	public function get_edit_url() {
614
-        return get_edit_post_link( $this->get_id() );
614
+        return get_edit_post_link($this->get_id());
615 615
 	}
616 616
 
617 617
 	/**
@@ -625,36 +625,36 @@  discard block
 block discarded – undo
625 625
 	 * @since 1.0.15
626 626
 	 * @return int
627 627
 	 */
628
-	public static function get_item_id_by_field( $value, $field = 'custom_id', $type = '' ) {
628
+	public static function get_item_id_by_field($value, $field = 'custom_id', $type = '') {
629 629
 
630 630
 		// Trim the value.
631
-		$value = sanitize_text_field( $value );
631
+		$value = sanitize_text_field($value);
632 632
 
633
-		if ( empty( $value ) ) {
633
+		if (empty($value)) {
634 634
 			return 0;
635 635
 		}
636 636
 
637 637
         // Valid fields.
638
-        $fields = array( 'custom_id', 'name', 'slug' );
638
+        $fields = array('custom_id', 'name', 'slug');
639 639
 
640 640
 		// Ensure a field has been passed.
641
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
641
+		if (empty($field) || !in_array($field, $fields)) {
642 642
 			return 0;
643 643
 		}
644 644
 
645
-		if ( $field == 'name' ) {
645
+		if ($field == 'name') {
646 646
 			$field = 'slug';
647 647
 		} 
648 648
 
649 649
 		// Maybe retrieve from the cache.
650
-		$item_id = wp_cache_get( $value, "getpaid_{$type}_item_{$field}s_to_item_ids" );
651
-		if ( ! empty( $item_id ) ) {
650
+		$item_id = wp_cache_get($value, "getpaid_{$type}_item_{$field}s_to_item_ids");
651
+		if (!empty($item_id)) {
652 652
 			return $item_id;
653 653
 		}
654 654
 
655 655
 		// Fetch from the db.
656 656
 		$items = array();
657
-		if ( $field =='slug' ) {
657
+		if ($field == 'slug') {
658 658
 			$items = get_posts(
659 659
 				array(
660 660
 					'post_type'      => 'wpi_item',
@@ -665,7 +665,7 @@  discard block
 block discarded – undo
665 665
 			);
666 666
 		}
667 667
 
668
-		if ( $field =='custom_id' ) {
668
+		if ($field == 'custom_id') {
669 669
 			$items = get_posts(
670 670
 				array(
671 671
 					'post_type'      => 'wpi_item',
@@ -685,12 +685,12 @@  discard block
 block discarded – undo
685 685
 			);
686 686
 		}
687 687
 
688
-		if ( empty( $items ) ) {
688
+		if (empty($items)) {
689 689
 			return 0;
690 690
 		}
691 691
 
692 692
 		// Update the cache with our data
693
-		wp_cache_set( $value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids" );
693
+		wp_cache_set($value, $items[0]->ID, "getpaid_{$type}_item_{$field}s_to_item_ids");
694 694
 
695 695
 		return $items[0]->ID;
696 696
     }
@@ -698,19 +698,19 @@  discard block
 block discarded – undo
698 698
     /**
699 699
      * Margic method for retrieving a property.
700 700
      */
701
-    public function __get( $key ) {
701
+    public function __get($key) {
702 702
 
703 703
         // Check if we have a helper method for that.
704
-        if ( method_exists( $this, 'get_' . $key ) ) {
705
-            return call_user_func( array( $this, 'get_' . $key ) );
704
+        if (method_exists($this, 'get_' . $key)) {
705
+            return call_user_func(array($this, 'get_' . $key));
706 706
         }
707 707
 
708 708
         // Check if the key is in the associated $post object.
709
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
709
+        if (!empty($this->post) && isset($this->post->$key)) {
710 710
             return $this->post->$key;
711 711
         }
712 712
 
713
-        return $this->get_prop( $key );
713
+        return $this->get_prop($key);
714 714
 
715 715
     }
716 716
 
@@ -729,11 +729,11 @@  discard block
 block discarded – undo
729 729
 	 *
730 730
 	 * @since 1.0.19
731 731
 	 */
732
-	public function set_parent_id( $value ) {
733
-		if ( $value && ( $value === $this->get_id() || ! get_post( $value ) ) ) {
732
+	public function set_parent_id($value) {
733
+		if ($value && ($value === $this->get_id() || !get_post($value))) {
734 734
 			return;
735 735
 		}
736
-		$this->set_prop( 'parent_id', absint( $value ) );
736
+		$this->set_prop('parent_id', absint($value));
737 737
 	}
738 738
 
739 739
     /**
@@ -743,10 +743,10 @@  discard block
 block discarded – undo
743 743
 	 * @param  string $status New status.
744 744
 	 * @return array details of change.
745 745
 	 */
746
-	public function set_status( $status ) {
746
+	public function set_status($status) {
747 747
         $old_status = $this->get_status();
748 748
 
749
-        $this->set_prop( 'status', $status );
749
+        $this->set_prop('status', $status);
750 750
 
751 751
 		return array(
752 752
 			'from' => $old_status,
@@ -759,8 +759,8 @@  discard block
 block discarded – undo
759 759
 	 *
760 760
 	 * @since 1.0.19
761 761
 	 */
762
-	public function set_version( $value ) {
763
-		$this->set_prop( 'version', $value );
762
+	public function set_version($value) {
763
+		$this->set_prop('version', $value);
764 764
     }
765 765
 
766 766
     /**
@@ -770,11 +770,11 @@  discard block
 block discarded – undo
770 770
 	 * @param string $value Value to set.
771 771
      * @return bool Whether or not the date was set.
772 772
 	 */
773
-	public function set_date_created( $value ) {
774
-        $date = strtotime( $value );
773
+	public function set_date_created($value) {
774
+        $date = strtotime($value);
775 775
 
776
-        if ( $date ) {
777
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
776
+        if ($date) {
777
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
778 778
             return true;
779 779
         }
780 780
 
@@ -789,11 +789,11 @@  discard block
 block discarded – undo
789 789
 	 * @param string $value Value to set.
790 790
      * @return bool Whether or not the date was set.
791 791
 	 */
792
-	public function set_date_modified( $value ) {
793
-        $date = strtotime( $value );
792
+	public function set_date_modified($value) {
793
+        $date = strtotime($value);
794 794
 
795
-        if ( $date ) {
796
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
795
+        if ($date) {
796
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
797 797
             return true;
798 798
         }
799 799
 
@@ -807,9 +807,9 @@  discard block
 block discarded – undo
807 807
 	 * @since 1.0.19
808 808
 	 * @param  string $value New name.
809 809
 	 */
810
-	public function set_name( $value ) {
811
-        $name = sanitize_text_field( $value );
812
-		$this->set_prop( 'name', $name );
810
+	public function set_name($value) {
811
+        $name = sanitize_text_field($value);
812
+		$this->set_prop('name', $name);
813 813
     }
814 814
 
815 815
     /**
@@ -818,8 +818,8 @@  discard block
 block discarded – undo
818 818
 	 * @since 1.0.19
819 819
 	 * @param  string $value New name.
820 820
 	 */
821
-	public function set_title( $value ) {
822
-		$this->set_name( $value );
821
+	public function set_title($value) {
822
+		$this->set_name($value);
823 823
     }
824 824
 
825 825
     /**
@@ -828,9 +828,9 @@  discard block
 block discarded – undo
828 828
 	 * @since 1.0.19
829 829
 	 * @param  string $value New description.
830 830
 	 */
831
-	public function set_description( $value ) {
832
-        $description = wp_kses_post( $value );
833
-		return $this->set_prop( 'description', $description );
831
+	public function set_description($value) {
832
+        $description = wp_kses_post($value);
833
+		return $this->set_prop('description', $description);
834 834
     }
835 835
 
836 836
     /**
@@ -839,8 +839,8 @@  discard block
 block discarded – undo
839 839
 	 * @since 1.0.19
840 840
 	 * @param  string $value New description.
841 841
 	 */
842
-	public function set_excerpt( $value ) {
843
-		$this->set_description( $value );
842
+	public function set_excerpt($value) {
843
+		$this->set_description($value);
844 844
     }
845 845
 
846 846
     /**
@@ -849,8 +849,8 @@  discard block
 block discarded – undo
849 849
 	 * @since 1.0.19
850 850
 	 * @param  string $value New description.
851 851
 	 */
852
-	public function set_summary( $value ) {
853
-		$this->set_description( $value );
852
+	public function set_summary($value) {
853
+		$this->set_description($value);
854 854
     }
855 855
 
856 856
     /**
@@ -859,8 +859,8 @@  discard block
 block discarded – undo
859 859
 	 * @since 1.0.19
860 860
 	 * @param  int $value New author.
861 861
 	 */
862
-	public function set_author( $value ) {
863
-		$this->set_prop( 'author', (int) $value );
862
+	public function set_author($value) {
863
+		$this->set_prop('author', (int) $value);
864 864
 	}
865 865
 	
866 866
 	/**
@@ -869,8 +869,8 @@  discard block
 block discarded – undo
869 869
 	 * @since 1.0.19
870 870
 	 * @param  int $value New author.
871 871
 	 */
872
-	public function set_owner( $value ) {
873
-		$this->set_author( $value );
872
+	public function set_owner($value) {
873
+		$this->set_author($value);
874 874
     }
875 875
 
876 876
     /**
@@ -879,8 +879,8 @@  discard block
 block discarded – undo
879 879
 	 * @since 1.0.19
880 880
 	 * @param  float $value New price.
881 881
 	 */
882
-	public function set_price( $value ) {
883
-        $this->set_prop( 'price', (float) wpinv_sanitize_amount( $value ) );
882
+	public function set_price($value) {
883
+        $this->set_prop('price', (float) wpinv_sanitize_amount($value));
884 884
     }
885 885
 
886 886
     /**
@@ -889,8 +889,8 @@  discard block
 block discarded – undo
889 889
 	 * @since 1.0.19
890 890
 	 * @param  string $value new rule.
891 891
 	 */
892
-	public function set_vat_rule( $value ) {
893
-        $this->set_prop( 'vat_rule', $value );
892
+	public function set_vat_rule($value) {
893
+        $this->set_prop('vat_rule', $value);
894 894
     }
895 895
 
896 896
     /**
@@ -899,8 +899,8 @@  discard block
 block discarded – undo
899 899
 	 * @since 1.0.19
900 900
 	 * @param  string $value new class.
901 901
 	 */
902
-	public function set_vat_class( $value ) {
903
-        $this->set_prop( 'vat_class', $value );
902
+	public function set_vat_class($value) {
903
+        $this->set_prop('vat_class', $value);
904 904
     }
905 905
 
906 906
     /**
@@ -910,13 +910,13 @@  discard block
 block discarded – undo
910 910
 	 * @param  string $value new item type.
911 911
 	 * @return string
912 912
 	 */
913
-	public function set_type( $value ) {
913
+	public function set_type($value) {
914 914
 
915
-        if ( empty( $value ) ) {
915
+        if (empty($value)) {
916 916
             $value = 'custom';
917 917
         }
918 918
 
919
-        $this->set_prop( 'type', $value );
919
+        $this->set_prop('type', $value);
920 920
     }
921 921
 
922 922
     /**
@@ -925,8 +925,8 @@  discard block
 block discarded – undo
925 925
 	 * @since 1.0.19
926 926
 	 * @param  string $value new custom id.
927 927
 	 */
928
-	public function set_custom_id( $value ) {
929
-        $this->set_prop( 'custom_id', $value );
928
+	public function set_custom_id($value) {
929
+        $this->set_prop('custom_id', $value);
930 930
     }
931 931
 
932 932
     /**
@@ -935,8 +935,8 @@  discard block
 block discarded – undo
935 935
 	 * @since 1.0.19
936 936
 	 * @param  string $value new custom name.
937 937
 	 */
938
-	public function set_custom_name( $value ) {
939
-        $this->set_prop( 'custom_name', $value );
938
+	public function set_custom_name($value) {
939
+        $this->set_prop('custom_name', $value);
940 940
     }
941 941
 
942 942
     /**
@@ -945,8 +945,8 @@  discard block
 block discarded – undo
945 945
 	 * @since 1.0.19
946 946
 	 * @param  string $value new custom singular name.
947 947
 	 */
948
-	public function set_custom_singular_name( $value ) {
949
-        $this->set_prop( 'custom_singular_name', $value );
948
+	public function set_custom_singular_name($value) {
949
+        $this->set_prop('custom_singular_name', $value);
950 950
     }
951 951
 
952 952
     /**
@@ -955,9 +955,9 @@  discard block
 block discarded – undo
955 955
 	 * @since 1.0.19
956 956
 	 * @param  int|bool $value whether or not the item is editable.
957 957
 	 */
958
-	public function set_is_editable( $value ) {
959
-		if ( is_numeric( $value ) ) {
960
-			$this->set_prop( 'is_editable', (int) $value );
958
+	public function set_is_editable($value) {
959
+		if (is_numeric($value)) {
960
+			$this->set_prop('is_editable', (int) $value);
961 961
 		}
962 962
     }
963 963
 
@@ -967,8 +967,8 @@  discard block
 block discarded – undo
967 967
 	 * @since 1.0.19
968 968
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
969 969
 	 */
970
-	public function set_is_dynamic_pricing( $value ) {
971
-        $this->set_prop( 'is_dynamic_pricing', (int) $value );
970
+	public function set_is_dynamic_pricing($value) {
971
+        $this->set_prop('is_dynamic_pricing', (int) $value);
972 972
     }
973 973
 
974 974
     /**
@@ -977,8 +977,8 @@  discard block
 block discarded – undo
977 977
 	 * @since 1.0.19
978 978
 	 * @param  float $value minimum price.
979 979
 	 */
980
-	public function set_minimum_price( $value ) {
981
-        $this->set_prop( 'minimum_price',  (float) wpinv_sanitize_amount( $value ) );
980
+	public function set_minimum_price($value) {
981
+        $this->set_prop('minimum_price', (float) wpinv_sanitize_amount($value));
982 982
     }
983 983
 
984 984
     /**
@@ -987,8 +987,8 @@  discard block
 block discarded – undo
987 987
 	 * @since 1.0.19
988 988
 	 * @param  int|bool $value whether or not dynamic pricing is allowed.
989 989
 	 */
990
-	public function set_is_recurring( $value ) {
991
-        $this->set_prop( 'is_recurring', (int) $value );
990
+	public function set_is_recurring($value) {
991
+        $this->set_prop('is_recurring', (int) $value);
992 992
     }
993 993
 
994 994
     /**
@@ -997,8 +997,8 @@  discard block
 block discarded – undo
997 997
 	 * @since 1.0.19
998 998
 	 * @param  string $value new period.
999 999
 	 */
1000
-	public function set_recurring_period( $value ) {
1001
-        $this->set_prop( 'recurring_period', $value );
1000
+	public function set_recurring_period($value) {
1001
+        $this->set_prop('recurring_period', $value);
1002 1002
     }
1003 1003
 
1004 1004
     /**
@@ -1007,8 +1007,8 @@  discard block
 block discarded – undo
1007 1007
 	 * @since 1.0.19
1008 1008
 	 * @param  int $value recurring interval.
1009 1009
 	 */
1010
-	public function set_recurring_interval( $value ) {
1011
-        return $this->set_prop( 'recurring_interval', (int) $value );
1010
+	public function set_recurring_interval($value) {
1011
+        return $this->set_prop('recurring_interval', (int) $value);
1012 1012
     }
1013 1013
 
1014 1014
     /**
@@ -1017,8 +1017,8 @@  discard block
 block discarded – undo
1017 1017
 	 * @param  int $value The recurring limit.
1018 1018
 	 * @return int
1019 1019
 	 */
1020
-	public function set_recurring_limit( $value ) {
1021
-        $this->set_prop( 'recurring_limit', (int) $value );
1020
+	public function set_recurring_limit($value) {
1021
+        $this->set_prop('recurring_limit', (int) $value);
1022 1022
     }
1023 1023
 
1024 1024
     /**
@@ -1027,8 +1027,8 @@  discard block
 block discarded – undo
1027 1027
 	 * @since 1.0.19
1028 1028
 	 * @param  int|bool $value whether or not it has a free trial.
1029 1029
 	 */
1030
-	public function set_is_free_trial( $value ) {
1031
-        $this->set_prop( 'is_free_trial', (int) $value );
1030
+	public function set_is_free_trial($value) {
1031
+        $this->set_prop('is_free_trial', (int) $value);
1032 1032
     }
1033 1033
 
1034 1034
     /**
@@ -1037,8 +1037,8 @@  discard block
 block discarded – undo
1037 1037
 	 * @since 1.0.19
1038 1038
 	 * @param  string $value trial period.
1039 1039
 	 */
1040
-	public function set_trial_period( $value ) {
1041
-        $this->set_prop( 'trial_period', $value );
1040
+	public function set_trial_period($value) {
1041
+        $this->set_prop('trial_period', $value);
1042 1042
     }
1043 1043
 
1044 1044
     /**
@@ -1047,8 +1047,8 @@  discard block
 block discarded – undo
1047 1047
 	 * @since 1.0.19
1048 1048
 	 * @param  int $value trial interval.
1049 1049
 	 */
1050
-	public function set_trial_interval( $value ) {
1051
-        $this->set_prop( 'trial_interval', $value );
1050
+	public function set_trial_interval($value) {
1051
+        $this->set_prop('trial_interval', $value);
1052 1052
     }
1053 1053
 
1054 1054
     /**
@@ -1057,11 +1057,11 @@  discard block
 block discarded – undo
1057 1057
      * @deprecated
1058 1058
 	 * @return int item id
1059 1059
      */
1060
-    public function create( $data = array() ) {
1060
+    public function create($data = array()) {
1061 1061
 
1062 1062
 		// Set the properties.
1063
-		if ( is_array( $data ) ) {
1064
-			$this->set_props( $data );
1063
+		if (is_array($data)) {
1064
+			$this->set_props($data);
1065 1065
 		}
1066 1066
 
1067 1067
 		// Save the item.
@@ -1075,8 +1075,8 @@  discard block
 block discarded – undo
1075 1075
      * @deprecated
1076 1076
 	 * @return int item id
1077 1077
      */
1078
-    public function update( $data = array() ) {
1079
-        return $this->create( $data );
1078
+    public function update($data = array()) {
1079
+        return $this->create($data);
1080 1080
     }
1081 1081
 
1082 1082
     /*
@@ -1116,7 +1116,7 @@  discard block
 block discarded – undo
1116 1116
 	 */
1117 1117
     public function has_free_trial() {
1118 1118
         $has_trial = $this->is_recurring() && (bool) $this->get_free_trial() ? true : false;
1119
-        return (bool) apply_filters( 'wpinv_item_has_free_trial', $has_trial, $this->ID, $this );
1119
+        return (bool) apply_filters('wpinv_item_has_free_trial', $has_trial, $this->ID, $this);
1120 1120
     }
1121 1121
 
1122 1122
     /**
@@ -1126,8 +1126,8 @@  discard block
 block discarded – undo
1126 1126
 	 * @return bool
1127 1127
 	 */
1128 1128
     public function is_free() {
1129
-        $is_free   = $this->get_price() == 0;
1130
-        return (bool) apply_filters( 'wpinv_is_free_item', $is_free, $this->ID, $this );
1129
+        $is_free = $this->get_price() == 0;
1130
+        return (bool) apply_filters('wpinv_is_free_item', $is_free, $this->ID, $this);
1131 1131
     }
1132 1132
 
1133 1133
     /**
@@ -1136,9 +1136,9 @@  discard block
 block discarded – undo
1136 1136
 	 * @param array|string $status Status to check.
1137 1137
 	 * @return bool
1138 1138
 	 */
1139
-	public function has_status( $status ) {
1140
-		$has_status = ( is_array( $status ) && in_array( $this->get_status(), $status, true ) ) || $this->get_status() === $status;
1141
-		return (bool) apply_filters( 'getpaid_item_has_status', $has_status, $this, $status );
1139
+	public function has_status($status) {
1140
+		$has_status = (is_array($status) && in_array($this->get_status(), $status, true)) || $this->get_status() === $status;
1141
+		return (bool) apply_filters('getpaid_item_has_status', $has_status, $this, $status);
1142 1142
     }
1143 1143
 
1144 1144
     /**
@@ -1147,9 +1147,9 @@  discard block
 block discarded – undo
1147 1147
 	 * @param array|string $type Type to check.
1148 1148
 	 * @return bool
1149 1149
 	 */
1150
-	public function is_type( $type ) {
1151
-		$is_type = ( is_array( $type ) && in_array( $this->get_type(), $type, true ) ) || $this->get_type() === $type;
1152
-		return (bool) apply_filters( 'getpaid_item_is_type', $is_type, $this, $type );
1150
+	public function is_type($type) {
1151
+		$is_type = (is_array($type) && in_array($this->get_type(), $type, true)) || $this->get_type() === $type;
1152
+		return (bool) apply_filters('getpaid_item_is_type', $is_type, $this, $type);
1153 1153
 	}
1154 1154
 
1155 1155
     /**
@@ -1160,52 +1160,52 @@  discard block
 block discarded – undo
1160 1160
 	 */
1161 1161
     public function is_editable() {
1162 1162
         $is_editable = $this->get_is_editable();
1163
-        return (bool) apply_filters( 'wpinv_item_is_editable', $is_editable, $this->ID, $this );
1163
+        return (bool) apply_filters('wpinv_item_is_editable', $is_editable, $this->ID, $this);
1164 1164
 	}
1165 1165
 
1166 1166
 	/**
1167 1167
 	 * Returns an array of cart fees.
1168 1168
 	 */
1169
-	public function get_fees( $type = 'fee', $item_id = 0 ) {
1169
+	public function get_fees($type = 'fee', $item_id = 0) {
1170 1170
         
1171
-        $fees = getpaid_session()->get( 'wpi_cart_fees' );
1171
+        $fees = getpaid_session()->get('wpi_cart_fees');
1172 1172
 
1173
-        if ( ! wpinv_get_cart_contents() ) {
1173
+        if (!wpinv_get_cart_contents()) {
1174 1174
             // We can only get item type fees when the cart is empty
1175 1175
             $type = 'custom';
1176 1176
         }
1177 1177
 
1178
-        if ( ! empty( $fees ) && ! empty( $type ) && 'all' !== $type ) {
1179
-            foreach( $fees as $key => $fee ) {
1180
-                if( ! empty( $fee['type'] ) && $type != $fee['type'] ) {
1181
-                    unset( $fees[ $key ] );
1178
+        if (!empty($fees) && !empty($type) && 'all' !== $type) {
1179
+            foreach ($fees as $key => $fee) {
1180
+                if (!empty($fee['type']) && $type != $fee['type']) {
1181
+                    unset($fees[$key]);
1182 1182
                 }
1183 1183
             }
1184 1184
         }
1185 1185
 
1186
-        if ( ! empty( $fees ) && ! empty( $item_id ) ) {
1186
+        if (!empty($fees) && !empty($item_id)) {
1187 1187
             // Remove fees that don't belong to the specified Item
1188
-            foreach ( $fees as $key => $fee ) {
1189
-                if ( (int) $item_id !== (int)$fee['custom_id'] ) {
1190
-                    unset( $fees[ $key ] );
1188
+            foreach ($fees as $key => $fee) {
1189
+                if ((int) $item_id !== (int) $fee['custom_id']) {
1190
+                    unset($fees[$key]);
1191 1191
                 }
1192 1192
             }
1193 1193
         }
1194 1194
 
1195
-        if ( ! empty( $fees ) ) {
1195
+        if (!empty($fees)) {
1196 1196
             // Remove fees that belong to a specific item but are not in the cart
1197
-            foreach( $fees as $key => $fee ) {
1198
-                if( empty( $fee['custom_id'] ) ) {
1197
+            foreach ($fees as $key => $fee) {
1198
+                if (empty($fee['custom_id'])) {
1199 1199
                     continue;
1200 1200
                 }
1201 1201
 
1202
-                if ( !wpinv_item_in_cart( $fee['custom_id'] ) ) {
1203
-                    unset( $fees[ $key ] );
1202
+                if (!wpinv_item_in_cart($fee['custom_id'])) {
1203
+                    unset($fees[$key]);
1204 1204
                 }
1205 1205
             }
1206 1206
         }
1207 1207
 
1208
-        return ! empty( $fees ) ? $fees : array();
1208
+        return !empty($fees) ? $fees : array();
1209 1209
     }
1210 1210
 
1211 1211
     /**
@@ -1217,11 +1217,11 @@  discard block
 block discarded – undo
1217 1217
     public function can_purchase() {
1218 1218
         $can_purchase = null !== $this->get_id();
1219 1219
 
1220
-        if ( ! current_user_can( 'edit_post', $this->ID ) && $this->post_status != 'publish' ) {
1220
+        if (!current_user_can('edit_post', $this->ID) && $this->post_status != 'publish') {
1221 1221
             $can_purchase = false;
1222 1222
         }
1223 1223
 
1224
-        return (bool) apply_filters( 'wpinv_can_purchase_item', $can_purchase, $this );
1224
+        return (bool) apply_filters('wpinv_can_purchase_item', $can_purchase, $this);
1225 1225
     }
1226 1226
 
1227 1227
     /**
@@ -1231,6 +1231,6 @@  discard block
 block discarded – undo
1231 1231
 	 * @return bool
1232 1232
 	 */
1233 1233
     public function supports_dynamic_pricing() {
1234
-        return (bool) apply_filters( 'wpinv_item_supports_dynamic_pricing', true, $this );
1234
+        return (bool) apply_filters('wpinv_item_supports_dynamic_pricing', true, $this);
1235 1235
     }
1236 1236
 }
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-data.php 2 patches
Indentation   +860 added lines, -860 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@  discard block
 block discarded – undo
9 9
  */
10 10
 
11 11
 if ( ! defined( 'ABSPATH' ) ) {
12
-	exit;
12
+    exit;
13 13
 }
14 14
 
15 15
 /**
@@ -21,356 +21,356 @@  discard block
 block discarded – undo
21 21
  */
22 22
 abstract class GetPaid_Data {
23 23
 
24
-	/**
25
-	 * ID for this object.
26
-	 *
27
-	 * @since 1.0.19
28
-	 * @var int
29
-	 */
30
-	protected $id = 0;
31
-
32
-	/**
33
-	 * Core data for this object. Name value pairs (name + default value).
34
-	 *
35
-	 * @since 1.0.19
36
-	 * @var array
37
-	 */
38
-	protected $data = array();
39
-
40
-	/**
41
-	 * Core data changes for this object.
42
-	 *
43
-	 * @since 1.0.19
44
-	 * @var array
45
-	 */
46
-	protected $changes = array();
47
-
48
-	/**
49
-	 * This is false until the object is read from the DB.
50
-	 *
51
-	 * @since 1.0.19
52
-	 * @var bool
53
-	 */
54
-	protected $object_read = false;
55
-
56
-	/**
57
-	 * This is the name of this object type.
58
-	 *
59
-	 * @since 1.0.19
60
-	 * @var string
61
-	 */
62
-	protected $object_type = 'data';
63
-
64
-	/**
65
-	 * Extra data for this object. Name value pairs (name + default value).
66
-	 * Used as a standard way for sub classes (like item types) to add
67
-	 * additional information to an inherited class.
68
-	 *
69
-	 * @since 1.0.19
70
-	 * @var array
71
-	 */
72
-	protected $extra_data = array();
73
-
74
-	/**
75
-	 * Set to _data on construct so we can track and reset data if needed.
76
-	 *
77
-	 * @since 1.0.19
78
-	 * @var array
79
-	 */
80
-	protected $default_data = array();
81
-
82
-	/**
83
-	 * Contains a reference to the data store for this class.
84
-	 *
85
-	 * @since 1.0.19
86
-	 * @var GetPaid_Data_Store
87
-	 */
88
-	protected $data_store;
89
-
90
-	/**
91
-	 * Stores meta in cache for future reads.
92
-	 * A group must be set to to enable caching.
93
-	 *
94
-	 * @since 1.0.19
95
-	 * @var string
96
-	 */
97
-	protected $cache_group = '';
98
-
99
-	/**
100
-	 * Stores the last error.
101
-	 *
102
-	 * @since 1.0.19
103
-	 * @var string
104
-	 */
105
-	public $last_error = '';
106
-
107
-	/**
108
-	 * Stores additional meta data.
109
-	 *
110
-	 * @since 1.0.19
111
-	 * @var array
112
-	 */
113
-	protected $meta_data = null;
114
-
115
-	/**
116
-	 * Default constructor.
117
-	 *
118
-	 * @param int|object|array $read ID to load from the DB (optional) or already queried data.
119
-	 */
120
-	public function __construct( $read = 0 ) {
121
-		$this->data         = array_merge( $this->data, $this->extra_data );
122
-		$this->default_data = $this->data;
123
-	}
124
-
125
-	/**
126
-	 * Only store the object ID to avoid serializing the data object instance.
127
-	 *
128
-	 * @return array
129
-	 */
130
-	public function __sleep() {
131
-		return array( 'id' );
132
-	}
133
-
134
-	/**
135
-	 * Re-run the constructor with the object ID.
136
-	 *
137
-	 * If the object no longer exists, remove the ID.
138
-	 */
139
-	public function __wakeup() {
140
-		$this->__construct( absint( $this->id ) );
141
-
142
-		if ( ! empty( $this->last_error ) ) {
143
-			$this->set_id( 0 );
144
-		}
145
-
146
-	}
147
-
148
-	/**
149
-	 * When the object is cloned, make sure meta is duplicated correctly.
150
-	 *
151
-	 * @since 1.0.19
152
-	 */
153
-	public function __clone() {
154
-		$this->maybe_read_meta_data();
155
-		if ( ! empty( $this->meta_data ) ) {
156
-			foreach ( $this->meta_data as $array_key => $meta ) {
157
-				$this->meta_data[ $array_key ] = clone $meta;
158
-				if ( ! empty( $meta->id ) ) {
159
-					$this->meta_data[ $array_key ]->id = null;
160
-				}
161
-			}
162
-		}
163
-	}
164
-
165
-	/**
166
-	 * Get the data store.
167
-	 *
168
-	 * @since  1.0.19
169
-	 * @return object
170
-	 */
171
-	public function get_data_store() {
172
-		return $this->data_store;
173
-	}
174
-
175
-	/**
176
-	 * Get the object type.
177
-	 *
178
-	 * @since  1.0.19
179
-	 * @return string
180
-	 */
181
-	public function get_object_type() {
182
-		return $this->object_type;
183
-	}
184
-
185
-	/**
186
-	 * Returns the unique ID for this object.
187
-	 *
188
-	 * @since  1.0.19
189
-	 * @return int
190
-	 */
191
-	public function get_id() {
192
-		return $this->id;
193
-	}
194
-
195
-	/**
196
-	 * Get form status.
197
-	 *
198
-	 * @since 1.0.19
199
-	 * @param  string $context View or edit context.
200
-	 * @return string
201
-	 */
202
-	public function get_status( $context = 'view' ) {
203
-		return $this->get_prop( 'status', $context );
204
-    }
205
-
206
-	/**
207
-	 * Delete an object, set the ID to 0, and return result.
208
-	 *
209
-	 * @since  1.0.19
210
-	 * @param  bool $force_delete Should the data be deleted permanently.
211
-	 * @return bool result
212
-	 */
213
-	public function delete( $force_delete = false ) {
214
-		if ( $this->data_store && $this->get_id() ) {
215
-			$this->data_store->delete( $this, array( 'force_delete' => $force_delete ) );
216
-			$this->set_id( 0 );
217
-			return true;
218
-		}
219
-		return false;
220
-	}
221
-
222
-	/**
223
-	 * Save should create or update based on object existence.
224
-	 *
225
-	 * @since  1.0.19
226
-	 * @return int
227
-	 */
228
-	public function save() {
229
-		if ( ! $this->data_store ) {
230
-			return $this->get_id();
231
-		}
232
-
233
-		/**
234
-		 * Trigger action before saving to the DB. Allows you to adjust object props before save.
235
-		 *
236
-		 * @param GetPaid_Data          $this The object being saved.
237
-		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
238
-		 */
239
-		do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store );
240
-
241
-		if ( $this->get_id() ) {
242
-			$this->data_store->update( $this );
243
-		} else {
244
-			$this->data_store->create( $this );
245
-		}
246
-
247
-		/**
248
-		 * Trigger action after saving to the DB.
249
-		 *
250
-		 * @param GetPaid_Data          $this The object being saved.
251
-		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
252
-		 */
253
-		do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store );
254
-
255
-		return $this->get_id();
256
-	}
257
-
258
-	/**
259
-	 * Change data to JSON format.
260
-	 *
261
-	 * @since  1.0.19
262
-	 * @return string Data in JSON format.
263
-	 */
264
-	public function __toString() {
265
-		return wp_json_encode( $this->get_data() );
266
-	}
267
-
268
-	/**
269
-	 * Returns all data for this object.
270
-	 *
271
-	 * @since  1.0.19
272
-	 * @return array
273
-	 */
274
-	public function get_data() {
275
-		return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) );
276
-	}
277
-
278
-	/**
279
-	 * Returns array of expected data keys for this object.
280
-	 *
281
-	 * @since   1.0.19
282
-	 * @return array
283
-	 */
284
-	public function get_data_keys() {
285
-		return array_keys( $this->data );
286
-	}
287
-
288
-	/**
289
-	 * Returns all "extra" data keys for an object (for sub objects like item types).
290
-	 *
291
-	 * @since  1.0.19
292
-	 * @return array
293
-	 */
294
-	public function get_extra_data_keys() {
295
-		return array_keys( $this->extra_data );
296
-	}
297
-
298
-	/**
299
-	 * Filter null meta values from array.
300
-	 *
301
-	 * @since  1.0.19
302
-	 * @param mixed $meta Meta value to check.
303
-	 * @return bool
304
-	 */
305
-	protected function filter_null_meta( $meta ) {
306
-		return ! is_null( $meta->value );
307
-	}
308
-
309
-	/**
310
-	 * Get All Meta Data.
311
-	 *
312
-	 * @since 1.0.19
313
-	 * @return array of objects.
314
-	 */
315
-	public function get_meta_data() {
316
-		$this->maybe_read_meta_data();
317
-		return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) );
318
-	}
319
-
320
-	/**
321
-	 * Check if the key is an internal one.
322
-	 *
323
-	 * @since  1.0.19
324
-	 * @param  string $key Key to check.
325
-	 * @return bool   true if it's an internal key, false otherwise
326
-	 */
327
-	protected function is_internal_meta_key( $key ) {
328
-		$internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true );
329
-
330
-		if ( ! $internal_meta_key ) {
331
-			return false;
332
-		}
333
-
334
-		$has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) );
335
-
336
-		if ( ! $has_setter_or_getter ) {
337
-			return false;
338
-		}
339
-
340
-		/* translators: %s: $key Key to check */
341
-		getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
342
-
343
-		return true;
344
-	}
345
-
346
-	/**
347
-	 * Magic method for setting data fields.
348
-	 *
349
-	 * This method does not update custom fields in the database.
350
-	 *
351
-	 * @since 1.0.19
352
-	 * @access public
353
-	 *
354
-	 */
355
-	public function __set( $key, $value ) {
356
-
357
-		if ( 'id' == strtolower( $key ) ) {
358
-			return $this->set_id( $value );
359
-		}
360
-
361
-		if ( method_exists( $this, "set_$key") ) {
362
-
363
-			/* translators: %s: $key Key to set */
364
-			getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
365
-
366
-			call_user_func( array( $this, "set_$key" ), $value );
367
-		} else {
368
-			$this->set_prop( $key, $value );
369
-		}
370
-
371
-	}
372
-
373
-	/**
24
+    /**
25
+     * ID for this object.
26
+     *
27
+     * @since 1.0.19
28
+     * @var int
29
+     */
30
+    protected $id = 0;
31
+
32
+    /**
33
+     * Core data for this object. Name value pairs (name + default value).
34
+     *
35
+     * @since 1.0.19
36
+     * @var array
37
+     */
38
+    protected $data = array();
39
+
40
+    /**
41
+     * Core data changes for this object.
42
+     *
43
+     * @since 1.0.19
44
+     * @var array
45
+     */
46
+    protected $changes = array();
47
+
48
+    /**
49
+     * This is false until the object is read from the DB.
50
+     *
51
+     * @since 1.0.19
52
+     * @var bool
53
+     */
54
+    protected $object_read = false;
55
+
56
+    /**
57
+     * This is the name of this object type.
58
+     *
59
+     * @since 1.0.19
60
+     * @var string
61
+     */
62
+    protected $object_type = 'data';
63
+
64
+    /**
65
+     * Extra data for this object. Name value pairs (name + default value).
66
+     * Used as a standard way for sub classes (like item types) to add
67
+     * additional information to an inherited class.
68
+     *
69
+     * @since 1.0.19
70
+     * @var array
71
+     */
72
+    protected $extra_data = array();
73
+
74
+    /**
75
+     * Set to _data on construct so we can track and reset data if needed.
76
+     *
77
+     * @since 1.0.19
78
+     * @var array
79
+     */
80
+    protected $default_data = array();
81
+
82
+    /**
83
+     * Contains a reference to the data store for this class.
84
+     *
85
+     * @since 1.0.19
86
+     * @var GetPaid_Data_Store
87
+     */
88
+    protected $data_store;
89
+
90
+    /**
91
+     * Stores meta in cache for future reads.
92
+     * A group must be set to to enable caching.
93
+     *
94
+     * @since 1.0.19
95
+     * @var string
96
+     */
97
+    protected $cache_group = '';
98
+
99
+    /**
100
+     * Stores the last error.
101
+     *
102
+     * @since 1.0.19
103
+     * @var string
104
+     */
105
+    public $last_error = '';
106
+
107
+    /**
108
+     * Stores additional meta data.
109
+     *
110
+     * @since 1.0.19
111
+     * @var array
112
+     */
113
+    protected $meta_data = null;
114
+
115
+    /**
116
+     * Default constructor.
117
+     *
118
+     * @param int|object|array $read ID to load from the DB (optional) or already queried data.
119
+     */
120
+    public function __construct( $read = 0 ) {
121
+        $this->data         = array_merge( $this->data, $this->extra_data );
122
+        $this->default_data = $this->data;
123
+    }
124
+
125
+    /**
126
+     * Only store the object ID to avoid serializing the data object instance.
127
+     *
128
+     * @return array
129
+     */
130
+    public function __sleep() {
131
+        return array( 'id' );
132
+    }
133
+
134
+    /**
135
+     * Re-run the constructor with the object ID.
136
+     *
137
+     * If the object no longer exists, remove the ID.
138
+     */
139
+    public function __wakeup() {
140
+        $this->__construct( absint( $this->id ) );
141
+
142
+        if ( ! empty( $this->last_error ) ) {
143
+            $this->set_id( 0 );
144
+        }
145
+
146
+    }
147
+
148
+    /**
149
+     * When the object is cloned, make sure meta is duplicated correctly.
150
+     *
151
+     * @since 1.0.19
152
+     */
153
+    public function __clone() {
154
+        $this->maybe_read_meta_data();
155
+        if ( ! empty( $this->meta_data ) ) {
156
+            foreach ( $this->meta_data as $array_key => $meta ) {
157
+                $this->meta_data[ $array_key ] = clone $meta;
158
+                if ( ! empty( $meta->id ) ) {
159
+                    $this->meta_data[ $array_key ]->id = null;
160
+                }
161
+            }
162
+        }
163
+    }
164
+
165
+    /**
166
+     * Get the data store.
167
+     *
168
+     * @since  1.0.19
169
+     * @return object
170
+     */
171
+    public function get_data_store() {
172
+        return $this->data_store;
173
+    }
174
+
175
+    /**
176
+     * Get the object type.
177
+     *
178
+     * @since  1.0.19
179
+     * @return string
180
+     */
181
+    public function get_object_type() {
182
+        return $this->object_type;
183
+    }
184
+
185
+    /**
186
+     * Returns the unique ID for this object.
187
+     *
188
+     * @since  1.0.19
189
+     * @return int
190
+     */
191
+    public function get_id() {
192
+        return $this->id;
193
+    }
194
+
195
+    /**
196
+     * Get form status.
197
+     *
198
+     * @since 1.0.19
199
+     * @param  string $context View or edit context.
200
+     * @return string
201
+     */
202
+    public function get_status( $context = 'view' ) {
203
+        return $this->get_prop( 'status', $context );
204
+    }
205
+
206
+    /**
207
+     * Delete an object, set the ID to 0, and return result.
208
+     *
209
+     * @since  1.0.19
210
+     * @param  bool $force_delete Should the data be deleted permanently.
211
+     * @return bool result
212
+     */
213
+    public function delete( $force_delete = false ) {
214
+        if ( $this->data_store && $this->get_id() ) {
215
+            $this->data_store->delete( $this, array( 'force_delete' => $force_delete ) );
216
+            $this->set_id( 0 );
217
+            return true;
218
+        }
219
+        return false;
220
+    }
221
+
222
+    /**
223
+     * Save should create or update based on object existence.
224
+     *
225
+     * @since  1.0.19
226
+     * @return int
227
+     */
228
+    public function save() {
229
+        if ( ! $this->data_store ) {
230
+            return $this->get_id();
231
+        }
232
+
233
+        /**
234
+         * Trigger action before saving to the DB. Allows you to adjust object props before save.
235
+         *
236
+         * @param GetPaid_Data          $this The object being saved.
237
+         * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
238
+         */
239
+        do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store );
240
+
241
+        if ( $this->get_id() ) {
242
+            $this->data_store->update( $this );
243
+        } else {
244
+            $this->data_store->create( $this );
245
+        }
246
+
247
+        /**
248
+         * Trigger action after saving to the DB.
249
+         *
250
+         * @param GetPaid_Data          $this The object being saved.
251
+         * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
252
+         */
253
+        do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store );
254
+
255
+        return $this->get_id();
256
+    }
257
+
258
+    /**
259
+     * Change data to JSON format.
260
+     *
261
+     * @since  1.0.19
262
+     * @return string Data in JSON format.
263
+     */
264
+    public function __toString() {
265
+        return wp_json_encode( $this->get_data() );
266
+    }
267
+
268
+    /**
269
+     * Returns all data for this object.
270
+     *
271
+     * @since  1.0.19
272
+     * @return array
273
+     */
274
+    public function get_data() {
275
+        return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) );
276
+    }
277
+
278
+    /**
279
+     * Returns array of expected data keys for this object.
280
+     *
281
+     * @since   1.0.19
282
+     * @return array
283
+     */
284
+    public function get_data_keys() {
285
+        return array_keys( $this->data );
286
+    }
287
+
288
+    /**
289
+     * Returns all "extra" data keys for an object (for sub objects like item types).
290
+     *
291
+     * @since  1.0.19
292
+     * @return array
293
+     */
294
+    public function get_extra_data_keys() {
295
+        return array_keys( $this->extra_data );
296
+    }
297
+
298
+    /**
299
+     * Filter null meta values from array.
300
+     *
301
+     * @since  1.0.19
302
+     * @param mixed $meta Meta value to check.
303
+     * @return bool
304
+     */
305
+    protected function filter_null_meta( $meta ) {
306
+        return ! is_null( $meta->value );
307
+    }
308
+
309
+    /**
310
+     * Get All Meta Data.
311
+     *
312
+     * @since 1.0.19
313
+     * @return array of objects.
314
+     */
315
+    public function get_meta_data() {
316
+        $this->maybe_read_meta_data();
317
+        return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) );
318
+    }
319
+
320
+    /**
321
+     * Check if the key is an internal one.
322
+     *
323
+     * @since  1.0.19
324
+     * @param  string $key Key to check.
325
+     * @return bool   true if it's an internal key, false otherwise
326
+     */
327
+    protected function is_internal_meta_key( $key ) {
328
+        $internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true );
329
+
330
+        if ( ! $internal_meta_key ) {
331
+            return false;
332
+        }
333
+
334
+        $has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) );
335
+
336
+        if ( ! $has_setter_or_getter ) {
337
+            return false;
338
+        }
339
+
340
+        /* translators: %s: $key Key to check */
341
+        getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
342
+
343
+        return true;
344
+    }
345
+
346
+    /**
347
+     * Magic method for setting data fields.
348
+     *
349
+     * This method does not update custom fields in the database.
350
+     *
351
+     * @since 1.0.19
352
+     * @access public
353
+     *
354
+     */
355
+    public function __set( $key, $value ) {
356
+
357
+        if ( 'id' == strtolower( $key ) ) {
358
+            return $this->set_id( $value );
359
+        }
360
+
361
+        if ( method_exists( $this, "set_$key") ) {
362
+
363
+            /* translators: %s: $key Key to set */
364
+            getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
365
+
366
+            call_user_func( array( $this, "set_$key" ), $value );
367
+        } else {
368
+            $this->set_prop( $key, $value );
369
+        }
370
+
371
+    }
372
+
373
+    /**
374 374
      * Margic method for retrieving a property.
375 375
      */
376 376
     public function __get( $key ) {
@@ -378,10 +378,10 @@  discard block
 block discarded – undo
378 378
         // Check if we have a helper method for that.
379 379
         if ( method_exists( $this, 'get_' . $key ) ) {
380 380
 
381
-			if ( 'post_type' != $key ) {
382
-				/* translators: %s: $key Key to set */
383
-				getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
384
-			}
381
+            if ( 'post_type' != $key ) {
382
+                /* translators: %s: $key Key to set */
383
+                getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
384
+            }
385 385
 
386 386
             return call_user_func( array( $this, 'get_' . $key ) );
387 387
         }
@@ -391,512 +391,512 @@  discard block
 block discarded – undo
391 391
             return $this->post->$key;
392 392
         }
393 393
 
394
-		return $this->get_prop( $key );
395
-
396
-    }
397
-
398
-	/**
399
-	 * Get Meta Data by Key.
400
-	 *
401
-	 * @since  1.0.19
402
-	 * @param  string $key Meta Key.
403
-	 * @param  bool   $single return first found meta with key, or all with $key.
404
-	 * @param  string $context What the value is for. Valid values are view and edit.
405
-	 * @return mixed
406
-	 */
407
-	public function get_meta( $key = '', $single = true, $context = 'view' ) {
408
-
409
-		// Check if this is an internal meta key.
410
-		$_key = str_replace( '_wpinv', '', $key );
411
-		$_key = str_replace( 'wpinv', '', $_key );
412
-		if ( $this->is_internal_meta_key( $_key ) ) {
413
-			$function = 'get_' . $_key;
414
-
415
-			if ( is_callable( array( $this, $function ) ) ) {
416
-				return $this->{$function}();
417
-			}
418
-		}
419
-
420
-		// Read the meta data if not yet read.
421
-		$this->maybe_read_meta_data();
422
-		$meta_data  = $this->get_meta_data();
423
-		$array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true );
424
-		$value      = $single ? '' : array();
425
-
426
-		if ( ! empty( $array_keys ) ) {
427
-			// We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()).
428
-			if ( $single ) {
429
-				$value = $meta_data[ current( $array_keys ) ]->value;
430
-			} else {
431
-				$value = array_intersect_key( $meta_data, array_flip( $array_keys ) );
432
-			}
433
-		}
434
-
435
-		if ( 'view' === $context ) {
436
-			$value = apply_filters( $this->get_hook_prefix() . $key, $value, $this );
437
-		}
438
-
439
-		return $value;
440
-	}
441
-
442
-	/**
443
-	 * See if meta data exists, since get_meta always returns a '' or array().
444
-	 *
445
-	 * @since  1.0.19
446
-	 * @param  string $key Meta Key.
447
-	 * @return boolean
448
-	 */
449
-	public function meta_exists( $key = '' ) {
450
-		$this->maybe_read_meta_data();
451
-		$array_keys = wp_list_pluck( $this->get_meta_data(), 'key' );
452
-		return in_array( $key, $array_keys, true );
453
-	}
454
-
455
-	/**
456
-	 * Set all meta data from array.
457
-	 *
458
-	 * @since 1.0.19
459
-	 * @param array $data Key/Value pairs.
460
-	 */
461
-	public function set_meta_data( $data ) {
462
-		if ( ! empty( $data ) && is_array( $data ) ) {
463
-			$this->maybe_read_meta_data();
464
-			foreach ( $data as $meta ) {
465
-				$meta = (array) $meta;
466
-				if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) {
467
-					$this->meta_data[] = new GetPaid_Meta_Data(
468
-						array(
469
-							'id'    => $meta['id'],
470
-							'key'   => $meta['key'],
471
-							'value' => $meta['value'],
472
-						)
473
-					);
474
-				}
475
-			}
476
-		}
477
-	}
478
-
479
-	/**
480
-	 * Add meta data.
481
-	 *
482
-	 * @since 1.0.19
483
-	 *
484
-	 * @param string       $key Meta key.
485
-	 * @param string|array $value Meta value.
486
-	 * @param bool         $unique Should this be a unique key?.
487
-	 */
488
-	public function add_meta_data( $key, $value, $unique = false ) {
489
-		if ( $this->is_internal_meta_key( $key ) ) {
490
-			$function = 'set_' . $key;
491
-
492
-			if ( is_callable( array( $this, $function ) ) ) {
493
-				return $this->{$function}( $value );
494
-			}
495
-		}
496
-
497
-		$this->maybe_read_meta_data();
498
-		if ( $unique ) {
499
-			$this->delete_meta_data( $key );
500
-		}
501
-		$this->meta_data[] = new GetPaid_Meta_Data(
502
-			array(
503
-				'key'   => $key,
504
-				'value' => $value,
505
-			)
506
-		);
507
-	}
508
-
509
-	/**
510
-	 * Update meta data by key or ID, if provided.
511
-	 *
512
-	 * @since  1.0.19
513
-	 *
514
-	 * @param  string       $key Meta key.
515
-	 * @param  string|array $value Meta value.
516
-	 * @param  int          $meta_id Meta ID.
517
-	 */
518
-	public function update_meta_data( $key, $value, $meta_id = 0 ) {
519
-		if ( $this->is_internal_meta_key( $key ) ) {
520
-			$function = 'set_' . $key;
521
-
522
-			if ( is_callable( array( $this, $function ) ) ) {
523
-				return $this->{$function}( $value );
524
-			}
525
-		}
526
-
527
-		$this->maybe_read_meta_data();
528
-
529
-		$array_key = false;
530
-
531
-		if ( $meta_id ) {
532
-			$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true );
533
-			$array_key  = $array_keys ? current( $array_keys ) : false;
534
-		} else {
535
-			// Find matches by key.
536
-			$matches = array();
537
-			foreach ( $this->meta_data as $meta_data_array_key => $meta ) {
538
-				if ( $meta->key === $key ) {
539
-					$matches[] = $meta_data_array_key;
540
-				}
541
-			}
542
-
543
-			if ( ! empty( $matches ) ) {
544
-				// Set matches to null so only one key gets the new value.
545
-				foreach ( $matches as $meta_data_array_key ) {
546
-					$this->meta_data[ $meta_data_array_key ]->value = null;
547
-				}
548
-				$array_key = current( $matches );
549
-			}
550
-		}
551
-
552
-		if ( false !== $array_key ) {
553
-			$meta        = $this->meta_data[ $array_key ];
554
-			$meta->key   = $key;
555
-			$meta->value = $value;
556
-		} else {
557
-			$this->add_meta_data( $key, $value, true );
558
-		}
559
-	}
560
-
561
-	/**
562
-	 * Delete meta data.
563
-	 *
564
-	 * @since 1.0.19
565
-	 * @param string $key Meta key.
566
-	 */
567
-	public function delete_meta_data( $key ) {
568
-		$this->maybe_read_meta_data();
569
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true );
570
-
571
-		if ( $array_keys ) {
572
-			foreach ( $array_keys as $array_key ) {
573
-				$this->meta_data[ $array_key ]->value = null;
574
-			}
575
-		}
576
-	}
577
-
578
-	/**
579
-	 * Delete meta data.
580
-	 *
581
-	 * @since 1.0.19
582
-	 * @param int $mid Meta ID.
583
-	 */
584
-	public function delete_meta_data_by_mid( $mid ) {
585
-		$this->maybe_read_meta_data();
586
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true );
587
-
588
-		if ( $array_keys ) {
589
-			foreach ( $array_keys as $array_key ) {
590
-				$this->meta_data[ $array_key ]->value = null;
591
-			}
592
-		}
593
-	}
594
-
595
-	/**
596
-	 * Read meta data if null.
597
-	 *
598
-	 * @since 1.0.19
599
-	 */
600
-	protected function maybe_read_meta_data() {
601
-		if ( is_null( $this->meta_data ) ) {
602
-			$this->read_meta_data();
603
-		}
604
-	}
605
-
606
-	/**
607
-	 * Read Meta Data from the database. Ignore any internal properties.
608
-	 * Uses it's own caches because get_metadata does not provide meta_ids.
609
-	 *
610
-	 * @since 1.0.19
611
-	 * @param bool $force_read True to force a new DB read (and update cache).
612
-	 */
613
-	public function read_meta_data( $force_read = false ) {
614
-
615
-		// Reset meta data.
616
-		$this->meta_data = array();
617
-
618
-		// Maybe abort early.
619
-		if ( ! $this->get_id() || ! $this->data_store ) {
620
-			return;
621
-		}
622
-
623
-		// Only read from cache if the cache key is set.
624
-		$cache_key = null;
625
-		if ( ! $force_read && ! empty( $this->cache_group ) ) {
626
-			$cache_key     = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
627
-			$raw_meta_data = wp_cache_get( $cache_key, $this->cache_group );
628
-		}
629
-
630
-		// Should we force read?
631
-		if ( empty( $raw_meta_data ) ) {
632
-			$raw_meta_data = $this->data_store->read_meta( $this );
633
-
634
-			if ( ! empty( $cache_key ) ) {
635
-				wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group );
636
-			}
637
-
638
-		}
639
-
640
-		// Set meta data.
641
-		if ( is_array( $raw_meta_data ) ) {
642
-
643
-			foreach ( $raw_meta_data as $meta ) {
644
-				$this->meta_data[] = new GetPaid_Meta_Data(
645
-					array(
646
-						'id'    => (int) $meta->meta_id,
647
-						'key'   => $meta->meta_key,
648
-						'value' => maybe_unserialize( $meta->meta_value ),
649
-					)
650
-				);
651
-			}
652
-
653
-		}
654
-
655
-	}
656
-
657
-	/**
658
-	 * Update Meta Data in the database.
659
-	 *
660
-	 * @since 1.0.19
661
-	 */
662
-	public function save_meta_data() {
663
-		if ( ! $this->data_store || is_null( $this->meta_data ) ) {
664
-			return;
665
-		}
666
-		foreach ( $this->meta_data as $array_key => $meta ) {
667
-			if ( is_null( $meta->value ) ) {
668
-				if ( ! empty( $meta->id ) ) {
669
-					$this->data_store->delete_meta( $this, $meta );
670
-					unset( $this->meta_data[ $array_key ] );
671
-				}
672
-			} elseif ( empty( $meta->id ) ) {
673
-				$meta->id = $this->data_store->add_meta( $this, $meta );
674
-				$meta->apply_changes();
675
-			} else {
676
-				if ( $meta->get_changes() ) {
677
-					$this->data_store->update_meta( $this, $meta );
678
-					$meta->apply_changes();
679
-				}
680
-			}
681
-		}
682
-		if ( ! empty( $this->cache_group ) ) {
683
-			$cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
684
-			wp_cache_delete( $cache_key, $this->cache_group );
685
-		}
686
-	}
687
-
688
-	/**
689
-	 * Set ID.
690
-	 *
691
-	 * @since 1.0.19
692
-	 * @param int $id ID.
693
-	 */
694
-	public function set_id( $id ) {
695
-		$this->id = absint( $id );
696
-	}
697
-
698
-	/**
699
-	 * Sets item status.
700
-	 *
701
-	 * @since 1.0.19
702
-	 * @param string $status New status.
703
-	 * @return array details of change.
704
-	 */
705
-	public function set_status( $status ) {
394
+        return $this->get_prop( $key );
395
+
396
+    }
397
+
398
+    /**
399
+     * Get Meta Data by Key.
400
+     *
401
+     * @since  1.0.19
402
+     * @param  string $key Meta Key.
403
+     * @param  bool   $single return first found meta with key, or all with $key.
404
+     * @param  string $context What the value is for. Valid values are view and edit.
405
+     * @return mixed
406
+     */
407
+    public function get_meta( $key = '', $single = true, $context = 'view' ) {
408
+
409
+        // Check if this is an internal meta key.
410
+        $_key = str_replace( '_wpinv', '', $key );
411
+        $_key = str_replace( 'wpinv', '', $_key );
412
+        if ( $this->is_internal_meta_key( $_key ) ) {
413
+            $function = 'get_' . $_key;
414
+
415
+            if ( is_callable( array( $this, $function ) ) ) {
416
+                return $this->{$function}();
417
+            }
418
+        }
419
+
420
+        // Read the meta data if not yet read.
421
+        $this->maybe_read_meta_data();
422
+        $meta_data  = $this->get_meta_data();
423
+        $array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true );
424
+        $value      = $single ? '' : array();
425
+
426
+        if ( ! empty( $array_keys ) ) {
427
+            // We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()).
428
+            if ( $single ) {
429
+                $value = $meta_data[ current( $array_keys ) ]->value;
430
+            } else {
431
+                $value = array_intersect_key( $meta_data, array_flip( $array_keys ) );
432
+            }
433
+        }
434
+
435
+        if ( 'view' === $context ) {
436
+            $value = apply_filters( $this->get_hook_prefix() . $key, $value, $this );
437
+        }
438
+
439
+        return $value;
440
+    }
441
+
442
+    /**
443
+     * See if meta data exists, since get_meta always returns a '' or array().
444
+     *
445
+     * @since  1.0.19
446
+     * @param  string $key Meta Key.
447
+     * @return boolean
448
+     */
449
+    public function meta_exists( $key = '' ) {
450
+        $this->maybe_read_meta_data();
451
+        $array_keys = wp_list_pluck( $this->get_meta_data(), 'key' );
452
+        return in_array( $key, $array_keys, true );
453
+    }
454
+
455
+    /**
456
+     * Set all meta data from array.
457
+     *
458
+     * @since 1.0.19
459
+     * @param array $data Key/Value pairs.
460
+     */
461
+    public function set_meta_data( $data ) {
462
+        if ( ! empty( $data ) && is_array( $data ) ) {
463
+            $this->maybe_read_meta_data();
464
+            foreach ( $data as $meta ) {
465
+                $meta = (array) $meta;
466
+                if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) {
467
+                    $this->meta_data[] = new GetPaid_Meta_Data(
468
+                        array(
469
+                            'id'    => $meta['id'],
470
+                            'key'   => $meta['key'],
471
+                            'value' => $meta['value'],
472
+                        )
473
+                    );
474
+                }
475
+            }
476
+        }
477
+    }
478
+
479
+    /**
480
+     * Add meta data.
481
+     *
482
+     * @since 1.0.19
483
+     *
484
+     * @param string       $key Meta key.
485
+     * @param string|array $value Meta value.
486
+     * @param bool         $unique Should this be a unique key?.
487
+     */
488
+    public function add_meta_data( $key, $value, $unique = false ) {
489
+        if ( $this->is_internal_meta_key( $key ) ) {
490
+            $function = 'set_' . $key;
491
+
492
+            if ( is_callable( array( $this, $function ) ) ) {
493
+                return $this->{$function}( $value );
494
+            }
495
+        }
496
+
497
+        $this->maybe_read_meta_data();
498
+        if ( $unique ) {
499
+            $this->delete_meta_data( $key );
500
+        }
501
+        $this->meta_data[] = new GetPaid_Meta_Data(
502
+            array(
503
+                'key'   => $key,
504
+                'value' => $value,
505
+            )
506
+        );
507
+    }
508
+
509
+    /**
510
+     * Update meta data by key or ID, if provided.
511
+     *
512
+     * @since  1.0.19
513
+     *
514
+     * @param  string       $key Meta key.
515
+     * @param  string|array $value Meta value.
516
+     * @param  int          $meta_id Meta ID.
517
+     */
518
+    public function update_meta_data( $key, $value, $meta_id = 0 ) {
519
+        if ( $this->is_internal_meta_key( $key ) ) {
520
+            $function = 'set_' . $key;
521
+
522
+            if ( is_callable( array( $this, $function ) ) ) {
523
+                return $this->{$function}( $value );
524
+            }
525
+        }
526
+
527
+        $this->maybe_read_meta_data();
528
+
529
+        $array_key = false;
530
+
531
+        if ( $meta_id ) {
532
+            $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true );
533
+            $array_key  = $array_keys ? current( $array_keys ) : false;
534
+        } else {
535
+            // Find matches by key.
536
+            $matches = array();
537
+            foreach ( $this->meta_data as $meta_data_array_key => $meta ) {
538
+                if ( $meta->key === $key ) {
539
+                    $matches[] = $meta_data_array_key;
540
+                }
541
+            }
542
+
543
+            if ( ! empty( $matches ) ) {
544
+                // Set matches to null so only one key gets the new value.
545
+                foreach ( $matches as $meta_data_array_key ) {
546
+                    $this->meta_data[ $meta_data_array_key ]->value = null;
547
+                }
548
+                $array_key = current( $matches );
549
+            }
550
+        }
551
+
552
+        if ( false !== $array_key ) {
553
+            $meta        = $this->meta_data[ $array_key ];
554
+            $meta->key   = $key;
555
+            $meta->value = $value;
556
+        } else {
557
+            $this->add_meta_data( $key, $value, true );
558
+        }
559
+    }
560
+
561
+    /**
562
+     * Delete meta data.
563
+     *
564
+     * @since 1.0.19
565
+     * @param string $key Meta key.
566
+     */
567
+    public function delete_meta_data( $key ) {
568
+        $this->maybe_read_meta_data();
569
+        $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true );
570
+
571
+        if ( $array_keys ) {
572
+            foreach ( $array_keys as $array_key ) {
573
+                $this->meta_data[ $array_key ]->value = null;
574
+            }
575
+        }
576
+    }
577
+
578
+    /**
579
+     * Delete meta data.
580
+     *
581
+     * @since 1.0.19
582
+     * @param int $mid Meta ID.
583
+     */
584
+    public function delete_meta_data_by_mid( $mid ) {
585
+        $this->maybe_read_meta_data();
586
+        $array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true );
587
+
588
+        if ( $array_keys ) {
589
+            foreach ( $array_keys as $array_key ) {
590
+                $this->meta_data[ $array_key ]->value = null;
591
+            }
592
+        }
593
+    }
594
+
595
+    /**
596
+     * Read meta data if null.
597
+     *
598
+     * @since 1.0.19
599
+     */
600
+    protected function maybe_read_meta_data() {
601
+        if ( is_null( $this->meta_data ) ) {
602
+            $this->read_meta_data();
603
+        }
604
+    }
605
+
606
+    /**
607
+     * Read Meta Data from the database. Ignore any internal properties.
608
+     * Uses it's own caches because get_metadata does not provide meta_ids.
609
+     *
610
+     * @since 1.0.19
611
+     * @param bool $force_read True to force a new DB read (and update cache).
612
+     */
613
+    public function read_meta_data( $force_read = false ) {
614
+
615
+        // Reset meta data.
616
+        $this->meta_data = array();
617
+
618
+        // Maybe abort early.
619
+        if ( ! $this->get_id() || ! $this->data_store ) {
620
+            return;
621
+        }
622
+
623
+        // Only read from cache if the cache key is set.
624
+        $cache_key = null;
625
+        if ( ! $force_read && ! empty( $this->cache_group ) ) {
626
+            $cache_key     = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
627
+            $raw_meta_data = wp_cache_get( $cache_key, $this->cache_group );
628
+        }
629
+
630
+        // Should we force read?
631
+        if ( empty( $raw_meta_data ) ) {
632
+            $raw_meta_data = $this->data_store->read_meta( $this );
633
+
634
+            if ( ! empty( $cache_key ) ) {
635
+                wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group );
636
+            }
637
+
638
+        }
639
+
640
+        // Set meta data.
641
+        if ( is_array( $raw_meta_data ) ) {
642
+
643
+            foreach ( $raw_meta_data as $meta ) {
644
+                $this->meta_data[] = new GetPaid_Meta_Data(
645
+                    array(
646
+                        'id'    => (int) $meta->meta_id,
647
+                        'key'   => $meta->meta_key,
648
+                        'value' => maybe_unserialize( $meta->meta_value ),
649
+                    )
650
+                );
651
+            }
652
+
653
+        }
654
+
655
+    }
656
+
657
+    /**
658
+     * Update Meta Data in the database.
659
+     *
660
+     * @since 1.0.19
661
+     */
662
+    public function save_meta_data() {
663
+        if ( ! $this->data_store || is_null( $this->meta_data ) ) {
664
+            return;
665
+        }
666
+        foreach ( $this->meta_data as $array_key => $meta ) {
667
+            if ( is_null( $meta->value ) ) {
668
+                if ( ! empty( $meta->id ) ) {
669
+                    $this->data_store->delete_meta( $this, $meta );
670
+                    unset( $this->meta_data[ $array_key ] );
671
+                }
672
+            } elseif ( empty( $meta->id ) ) {
673
+                $meta->id = $this->data_store->add_meta( $this, $meta );
674
+                $meta->apply_changes();
675
+            } else {
676
+                if ( $meta->get_changes() ) {
677
+                    $this->data_store->update_meta( $this, $meta );
678
+                    $meta->apply_changes();
679
+                }
680
+            }
681
+        }
682
+        if ( ! empty( $this->cache_group ) ) {
683
+            $cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
684
+            wp_cache_delete( $cache_key, $this->cache_group );
685
+        }
686
+    }
687
+
688
+    /**
689
+     * Set ID.
690
+     *
691
+     * @since 1.0.19
692
+     * @param int $id ID.
693
+     */
694
+    public function set_id( $id ) {
695
+        $this->id = absint( $id );
696
+    }
697
+
698
+    /**
699
+     * Sets item status.
700
+     *
701
+     * @since 1.0.19
702
+     * @param string $status New status.
703
+     * @return array details of change.
704
+     */
705
+    public function set_status( $status ) {
706 706
         $old_status = $this->get_status();
707 707
 
708
-		$this->set_prop( 'status', $status );
709
-
710
-		return array(
711
-			'from' => $old_status,
712
-			'to'   => $status,
713
-		);
714
-    }
715
-
716
-	/**
717
-	 * Set all props to default values.
718
-	 *
719
-	 * @since 1.0.19
720
-	 */
721
-	public function set_defaults() {
722
-		$this->data    = $this->default_data;
723
-		$this->changes = array();
724
-		$this->set_object_read( false );
725
-	}
726
-
727
-	/**
728
-	 * Set object read property.
729
-	 *
730
-	 * @since 1.0.19
731
-	 * @param boolean $read Should read?.
732
-	 */
733
-	public function set_object_read( $read = true ) {
734
-		$this->object_read = (bool) $read;
735
-	}
736
-
737
-	/**
738
-	 * Get object read property.
739
-	 *
740
-	 * @since  1.0.19
741
-	 * @return boolean
742
-	 */
743
-	public function get_object_read() {
744
-		return (bool) $this->object_read;
745
-	}
746
-
747
-	/**
748
-	 * Set a collection of props in one go, collect any errors, and return the result.
749
-	 * Only sets using public methods.
750
-	 *
751
-	 * @since  1.0.19
752
-	 *
753
-	 * @param array  $props Key value pairs to set. Key is the prop and should map to a setter function name.
754
-	 * @param string $context In what context to run this.
755
-	 *
756
-	 * @return bool|WP_Error
757
-	 */
758
-	public function set_props( $props, $context = 'set' ) {
759
-		$errors = false;
760
-
761
-		foreach ( $props as $prop => $value ) {
762
-			try {
763
-				/**
764
-				 * Checks if the prop being set is allowed, and the value is not null.
765
-				 */
766
-				if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
767
-					continue;
768
-				}
769
-				$setter = "set_$prop";
770
-
771
-				if ( is_callable( array( $this, $setter ) ) ) {
772
-					$this->{$setter}( $value );
773
-				}
774
-			} catch ( Exception $e ) {
775
-				if ( ! $errors ) {
776
-					$errors = new WP_Error();
777
-				}
778
-				$errors->add( $e->getCode(), $e->getMessage() );
779
-				$this->last_error = $e->getMessage();
780
-			}
781
-		}
782
-
783
-		return $errors && count( $errors->get_error_codes() ) ? $errors : true;
784
-	}
785
-
786
-	/**
787
-	 * Sets a prop for a setter method.
788
-	 *
789
-	 * This stores changes in a special array so we can track what needs saving
790
-	 * the the DB later.
791
-	 *
792
-	 * @since 1.0.19
793
-	 * @param string $prop Name of prop to set.
794
-	 * @param mixed  $value Value of the prop.
795
-	 */
796
-	protected function set_prop( $prop, $value ) {
797
-		if ( array_key_exists( $prop, $this->data ) ) {
798
-			if ( true === $this->object_read ) {
799
-				if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
800
-					$this->changes[ $prop ] = $value;
801
-				}
802
-			} else {
803
-				$this->data[ $prop ] = $value;
804
-			}
805
-		}
806
-	}
807
-
808
-	/**
809
-	 * Return data changes only.
810
-	 *
811
-	 * @since 1.0.19
812
-	 * @return array
813
-	 */
814
-	public function get_changes() {
815
-		return $this->changes;
816
-	}
817
-
818
-	/**
819
-	 * Merge changes with data and clear.
820
-	 *
821
-	 * @since 1.0.19
822
-	 */
823
-	public function apply_changes() {
824
-		$this->data    = array_replace_recursive( $this->data, $this->changes );
825
-		$this->changes = array();
826
-	}
827
-
828
-	/**
829
-	 * Prefix for action and filter hooks on data.
830
-	 *
831
-	 * @since  1.0.19
832
-	 * @return string
833
-	 */
834
-	protected function get_hook_prefix() {
835
-		return 'wpinv_get_' . $this->object_type . '_';
836
-	}
837
-
838
-	/**
839
-	 * Gets a prop for a getter method.
840
-	 *
841
-	 * Gets the value from either current pending changes, or the data itself.
842
-	 * Context controls what happens to the value before it's returned.
843
-	 *
844
-	 * @since  1.0.19
845
-	 * @param  string $prop Name of prop to get.
846
-	 * @param  string $context What the value is for. Valid values are view and edit.
847
-	 * @return mixed
848
-	 */
849
-	protected function get_prop( $prop, $context = 'view' ) {
850
-		$value = null;
851
-
852
-		if ( array_key_exists( $prop, $this->data ) ) {
853
-			$value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ];
854
-
855
-			if ( 'view' === $context ) {
856
-				$value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
857
-			}
858
-		}
859
-
860
-		return $value;
861
-	}
862
-
863
-	/**
864
-	 * Sets a date prop whilst handling formatting and datetime objects.
865
-	 *
866
-	 * @since 1.0.19
867
-	 * @param string         $prop Name of prop to set.
868
-	 * @param string|integer $value Value of the prop.
869
-	 */
870
-	protected function set_date_prop( $prop, $value ) {
871
-
872
-		if ( empty( $value ) ) {
873
-			$this->set_prop( $prop, null );
874
-			return;
875
-		}
876
-		$this->set_prop( $prop, $value );
877
-
878
-	}
879
-
880
-	/**
881
-	 * When invalid data is found, throw an exception unless reading from the DB.
882
-	 *
883
-	 * @since 1.0.19
884
-	 * @param string $code             Error code.
885
-	 * @param string $message          Error message.
886
-	 */
887
-	protected function error( $code, $message ) {
888
-		$this->last_error = $message;
889
-	}
890
-
891
-	/**
892
-	 * Checks if the object is saved in the database
893
-	 *
894
-	 * @since 1.0.19
895
-	 * @return bool
896
-	 */
897
-	public function exists() {
898
-		$id = $this->get_id();
899
-		return ! empty( $id );
900
-	}
708
+        $this->set_prop( 'status', $status );
709
+
710
+        return array(
711
+            'from' => $old_status,
712
+            'to'   => $status,
713
+        );
714
+    }
715
+
716
+    /**
717
+     * Set all props to default values.
718
+     *
719
+     * @since 1.0.19
720
+     */
721
+    public function set_defaults() {
722
+        $this->data    = $this->default_data;
723
+        $this->changes = array();
724
+        $this->set_object_read( false );
725
+    }
726
+
727
+    /**
728
+     * Set object read property.
729
+     *
730
+     * @since 1.0.19
731
+     * @param boolean $read Should read?.
732
+     */
733
+    public function set_object_read( $read = true ) {
734
+        $this->object_read = (bool) $read;
735
+    }
736
+
737
+    /**
738
+     * Get object read property.
739
+     *
740
+     * @since  1.0.19
741
+     * @return boolean
742
+     */
743
+    public function get_object_read() {
744
+        return (bool) $this->object_read;
745
+    }
746
+
747
+    /**
748
+     * Set a collection of props in one go, collect any errors, and return the result.
749
+     * Only sets using public methods.
750
+     *
751
+     * @since  1.0.19
752
+     *
753
+     * @param array  $props Key value pairs to set. Key is the prop and should map to a setter function name.
754
+     * @param string $context In what context to run this.
755
+     *
756
+     * @return bool|WP_Error
757
+     */
758
+    public function set_props( $props, $context = 'set' ) {
759
+        $errors = false;
760
+
761
+        foreach ( $props as $prop => $value ) {
762
+            try {
763
+                /**
764
+                 * Checks if the prop being set is allowed, and the value is not null.
765
+                 */
766
+                if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
767
+                    continue;
768
+                }
769
+                $setter = "set_$prop";
770
+
771
+                if ( is_callable( array( $this, $setter ) ) ) {
772
+                    $this->{$setter}( $value );
773
+                }
774
+            } catch ( Exception $e ) {
775
+                if ( ! $errors ) {
776
+                    $errors = new WP_Error();
777
+                }
778
+                $errors->add( $e->getCode(), $e->getMessage() );
779
+                $this->last_error = $e->getMessage();
780
+            }
781
+        }
782
+
783
+        return $errors && count( $errors->get_error_codes() ) ? $errors : true;
784
+    }
785
+
786
+    /**
787
+     * Sets a prop for a setter method.
788
+     *
789
+     * This stores changes in a special array so we can track what needs saving
790
+     * the the DB later.
791
+     *
792
+     * @since 1.0.19
793
+     * @param string $prop Name of prop to set.
794
+     * @param mixed  $value Value of the prop.
795
+     */
796
+    protected function set_prop( $prop, $value ) {
797
+        if ( array_key_exists( $prop, $this->data ) ) {
798
+            if ( true === $this->object_read ) {
799
+                if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
800
+                    $this->changes[ $prop ] = $value;
801
+                }
802
+            } else {
803
+                $this->data[ $prop ] = $value;
804
+            }
805
+        }
806
+    }
807
+
808
+    /**
809
+     * Return data changes only.
810
+     *
811
+     * @since 1.0.19
812
+     * @return array
813
+     */
814
+    public function get_changes() {
815
+        return $this->changes;
816
+    }
817
+
818
+    /**
819
+     * Merge changes with data and clear.
820
+     *
821
+     * @since 1.0.19
822
+     */
823
+    public function apply_changes() {
824
+        $this->data    = array_replace_recursive( $this->data, $this->changes );
825
+        $this->changes = array();
826
+    }
827
+
828
+    /**
829
+     * Prefix for action and filter hooks on data.
830
+     *
831
+     * @since  1.0.19
832
+     * @return string
833
+     */
834
+    protected function get_hook_prefix() {
835
+        return 'wpinv_get_' . $this->object_type . '_';
836
+    }
837
+
838
+    /**
839
+     * Gets a prop for a getter method.
840
+     *
841
+     * Gets the value from either current pending changes, or the data itself.
842
+     * Context controls what happens to the value before it's returned.
843
+     *
844
+     * @since  1.0.19
845
+     * @param  string $prop Name of prop to get.
846
+     * @param  string $context What the value is for. Valid values are view and edit.
847
+     * @return mixed
848
+     */
849
+    protected function get_prop( $prop, $context = 'view' ) {
850
+        $value = null;
851
+
852
+        if ( array_key_exists( $prop, $this->data ) ) {
853
+            $value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ];
854
+
855
+            if ( 'view' === $context ) {
856
+                $value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
857
+            }
858
+        }
859
+
860
+        return $value;
861
+    }
862
+
863
+    /**
864
+     * Sets a date prop whilst handling formatting and datetime objects.
865
+     *
866
+     * @since 1.0.19
867
+     * @param string         $prop Name of prop to set.
868
+     * @param string|integer $value Value of the prop.
869
+     */
870
+    protected function set_date_prop( $prop, $value ) {
871
+
872
+        if ( empty( $value ) ) {
873
+            $this->set_prop( $prop, null );
874
+            return;
875
+        }
876
+        $this->set_prop( $prop, $value );
877
+
878
+    }
879
+
880
+    /**
881
+     * When invalid data is found, throw an exception unless reading from the DB.
882
+     *
883
+     * @since 1.0.19
884
+     * @param string $code             Error code.
885
+     * @param string $message          Error message.
886
+     */
887
+    protected function error( $code, $message ) {
888
+        $this->last_error = $message;
889
+    }
890
+
891
+    /**
892
+     * Checks if the object is saved in the database
893
+     *
894
+     * @since 1.0.19
895
+     * @return bool
896
+     */
897
+    public function exists() {
898
+        $id = $this->get_id();
899
+        return ! empty( $id );
900
+    }
901 901
 
902 902
 }
Please login to merge, or discard this patch.
Spacing   +161 added lines, -161 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@  discard block
 block discarded – undo
8 8
  *
9 9
  */
10 10
 
11
-if ( ! defined( 'ABSPATH' ) ) {
11
+if (!defined('ABSPATH')) {
12 12
 	exit;
13 13
 }
14 14
 
@@ -117,8 +117,8 @@  discard block
 block discarded – undo
117 117
 	 *
118 118
 	 * @param int|object|array $read ID to load from the DB (optional) or already queried data.
119 119
 	 */
120
-	public function __construct( $read = 0 ) {
121
-		$this->data         = array_merge( $this->data, $this->extra_data );
120
+	public function __construct($read = 0) {
121
+		$this->data         = array_merge($this->data, $this->extra_data);
122 122
 		$this->default_data = $this->data;
123 123
 	}
124 124
 
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
 	 * @return array
129 129
 	 */
130 130
 	public function __sleep() {
131
-		return array( 'id' );
131
+		return array('id');
132 132
 	}
133 133
 
134 134
 	/**
@@ -137,10 +137,10 @@  discard block
 block discarded – undo
137 137
 	 * If the object no longer exists, remove the ID.
138 138
 	 */
139 139
 	public function __wakeup() {
140
-		$this->__construct( absint( $this->id ) );
140
+		$this->__construct(absint($this->id));
141 141
 
142
-		if ( ! empty( $this->last_error ) ) {
143
-			$this->set_id( 0 );
142
+		if (!empty($this->last_error)) {
143
+			$this->set_id(0);
144 144
 		}
145 145
 
146 146
 	}
@@ -152,11 +152,11 @@  discard block
 block discarded – undo
152 152
 	 */
153 153
 	public function __clone() {
154 154
 		$this->maybe_read_meta_data();
155
-		if ( ! empty( $this->meta_data ) ) {
156
-			foreach ( $this->meta_data as $array_key => $meta ) {
157
-				$this->meta_data[ $array_key ] = clone $meta;
158
-				if ( ! empty( $meta->id ) ) {
159
-					$this->meta_data[ $array_key ]->id = null;
155
+		if (!empty($this->meta_data)) {
156
+			foreach ($this->meta_data as $array_key => $meta) {
157
+				$this->meta_data[$array_key] = clone $meta;
158
+				if (!empty($meta->id)) {
159
+					$this->meta_data[$array_key]->id = null;
160 160
 				}
161 161
 			}
162 162
 		}
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	 * @param  string $context View or edit context.
200 200
 	 * @return string
201 201
 	 */
202
-	public function get_status( $context = 'view' ) {
203
-		return $this->get_prop( 'status', $context );
202
+	public function get_status($context = 'view') {
203
+		return $this->get_prop('status', $context);
204 204
     }
205 205
 
206 206
 	/**
@@ -210,10 +210,10 @@  discard block
 block discarded – undo
210 210
 	 * @param  bool $force_delete Should the data be deleted permanently.
211 211
 	 * @return bool result
212 212
 	 */
213
-	public function delete( $force_delete = false ) {
214
-		if ( $this->data_store && $this->get_id() ) {
215
-			$this->data_store->delete( $this, array( 'force_delete' => $force_delete ) );
216
-			$this->set_id( 0 );
213
+	public function delete($force_delete = false) {
214
+		if ($this->data_store && $this->get_id()) {
215
+			$this->data_store->delete($this, array('force_delete' => $force_delete));
216
+			$this->set_id(0);
217 217
 			return true;
218 218
 		}
219 219
 		return false;
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 	 * @return int
227 227
 	 */
228 228
 	public function save() {
229
-		if ( ! $this->data_store ) {
229
+		if (!$this->data_store) {
230 230
 			return $this->get_id();
231 231
 		}
232 232
 
@@ -236,12 +236,12 @@  discard block
 block discarded – undo
236 236
 		 * @param GetPaid_Data          $this The object being saved.
237 237
 		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
238 238
 		 */
239
-		do_action( 'getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store );
239
+		do_action('getpaid_before_' . $this->object_type . '_object_save', $this, $this->data_store);
240 240
 
241
-		if ( $this->get_id() ) {
242
-			$this->data_store->update( $this );
241
+		if ($this->get_id()) {
242
+			$this->data_store->update($this);
243 243
 		} else {
244
-			$this->data_store->create( $this );
244
+			$this->data_store->create($this);
245 245
 		}
246 246
 
247 247
 		/**
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 		 * @param GetPaid_Data          $this The object being saved.
251 251
 		 * @param GetPaid_Data_Store_WP $data_store The data store persisting the data.
252 252
 		 */
253
-		do_action( 'getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store );
253
+		do_action('getpaid_after_' . $this->object_type . '_object_save', $this, $this->data_store);
254 254
 
255 255
 		return $this->get_id();
256 256
 	}
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
 	 * @return string Data in JSON format.
263 263
 	 */
264 264
 	public function __toString() {
265
-		return wp_json_encode( $this->get_data() );
265
+		return wp_json_encode($this->get_data());
266 266
 	}
267 267
 
268 268
 	/**
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 	 * @return array
273 273
 	 */
274 274
 	public function get_data() {
275
-		return array_merge( array( 'id' => $this->get_id() ), $this->data, array( 'meta_data' => $this->get_meta_data() ) );
275
+		return array_merge(array('id' => $this->get_id()), $this->data, array('meta_data' => $this->get_meta_data()));
276 276
 	}
277 277
 
278 278
 	/**
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
 	 * @return array
283 283
 	 */
284 284
 	public function get_data_keys() {
285
-		return array_keys( $this->data );
285
+		return array_keys($this->data);
286 286
 	}
287 287
 
288 288
 	/**
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 	 * @return array
293 293
 	 */
294 294
 	public function get_extra_data_keys() {
295
-		return array_keys( $this->extra_data );
295
+		return array_keys($this->extra_data);
296 296
 	}
297 297
 
298 298
 	/**
@@ -302,8 +302,8 @@  discard block
 block discarded – undo
302 302
 	 * @param mixed $meta Meta value to check.
303 303
 	 * @return bool
304 304
 	 */
305
-	protected function filter_null_meta( $meta ) {
306
-		return ! is_null( $meta->value );
305
+	protected function filter_null_meta($meta) {
306
+		return !is_null($meta->value);
307 307
 	}
308 308
 
309 309
 	/**
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
 	 */
315 315
 	public function get_meta_data() {
316 316
 		$this->maybe_read_meta_data();
317
-		return array_values( array_filter( $this->meta_data, array( $this, 'filter_null_meta' ) ) );
317
+		return array_values(array_filter($this->meta_data, array($this, 'filter_null_meta')));
318 318
 	}
319 319
 
320 320
 	/**
@@ -324,21 +324,21 @@  discard block
 block discarded – undo
324 324
 	 * @param  string $key Key to check.
325 325
 	 * @return bool   true if it's an internal key, false otherwise
326 326
 	 */
327
-	protected function is_internal_meta_key( $key ) {
328
-		$internal_meta_key = ! empty( $key ) && $this->data_store && in_array( $key, $this->data_store->get_internal_meta_keys(), true );
327
+	protected function is_internal_meta_key($key) {
328
+		$internal_meta_key = !empty($key) && $this->data_store && in_array($key, $this->data_store->get_internal_meta_keys(), true);
329 329
 
330
-		if ( ! $internal_meta_key ) {
330
+		if (!$internal_meta_key) {
331 331
 			return false;
332 332
 		}
333 333
 
334
-		$has_setter_or_getter = is_callable( array( $this, 'set_' . $key ) ) || is_callable( array( $this, 'get_' . $key ) );
334
+		$has_setter_or_getter = is_callable(array($this, 'set_' . $key)) || is_callable(array($this, 'get_' . $key));
335 335
 
336
-		if ( ! $has_setter_or_getter ) {
336
+		if (!$has_setter_or_getter) {
337 337
 			return false;
338 338
 		}
339 339
 
340 340
 		/* translators: %s: $key Key to check */
341
-		getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
341
+		getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Generic add/update/get meta methods should not be used for internal meta data, including "%s". Use getters and setters.', 'getpaid'), $key), '1.0.19');
342 342
 
343 343
 		return true;
344 344
 	}
@@ -352,20 +352,20 @@  discard block
 block discarded – undo
352 352
 	 * @access public
353 353
 	 *
354 354
 	 */
355
-	public function __set( $key, $value ) {
355
+	public function __set($key, $value) {
356 356
 
357
-		if ( 'id' == strtolower( $key ) ) {
358
-			return $this->set_id( $value );
357
+		if ('id' == strtolower($key)) {
358
+			return $this->set_id($value);
359 359
 		}
360 360
 
361
-		if ( method_exists( $this, "set_$key") ) {
361
+		if (method_exists($this, "set_$key")) {
362 362
 
363 363
 			/* translators: %s: $key Key to set */
364
-			getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
364
+			getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid'), $key), '1.0.19');
365 365
 
366
-			call_user_func( array( $this, "set_$key" ), $value );
366
+			call_user_func(array($this, "set_$key"), $value);
367 367
 		} else {
368
-			$this->set_prop( $key, $value );
368
+			$this->set_prop($key, $value);
369 369
 		}
370 370
 
371 371
 	}
@@ -373,25 +373,25 @@  discard block
 block discarded – undo
373 373
 	/**
374 374
      * Margic method for retrieving a property.
375 375
      */
376
-    public function __get( $key ) {
376
+    public function __get($key) {
377 377
 
378 378
         // Check if we have a helper method for that.
379
-        if ( method_exists( $this, 'get_' . $key ) ) {
379
+        if (method_exists($this, 'get_' . $key)) {
380 380
 
381
-			if ( 'post_type' != $key ) {
381
+			if ('post_type' != $key) {
382 382
 				/* translators: %s: $key Key to set */
383
-				getpaid_doing_it_wrong( __FUNCTION__, sprintf( __( 'Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid' ), $key ), '1.0.19' );
383
+				getpaid_doing_it_wrong(__FUNCTION__, sprintf(__('Object data such as "%s" should not be accessed directly. Use getters and setters.', 'getpaid'), $key), '1.0.19');
384 384
 			}
385 385
 
386
-            return call_user_func( array( $this, 'get_' . $key ) );
386
+            return call_user_func(array($this, 'get_' . $key));
387 387
         }
388 388
 
389 389
         // Check if the key is in the associated $post object.
390
-        if ( ! empty( $this->post ) && isset( $this->post->$key ) ) {
390
+        if (!empty($this->post) && isset($this->post->$key)) {
391 391
             return $this->post->$key;
392 392
         }
393 393
 
394
-		return $this->get_prop( $key );
394
+		return $this->get_prop($key);
395 395
 
396 396
     }
397 397
 
@@ -404,15 +404,15 @@  discard block
 block discarded – undo
404 404
 	 * @param  string $context What the value is for. Valid values are view and edit.
405 405
 	 * @return mixed
406 406
 	 */
407
-	public function get_meta( $key = '', $single = true, $context = 'view' ) {
407
+	public function get_meta($key = '', $single = true, $context = 'view') {
408 408
 
409 409
 		// Check if this is an internal meta key.
410
-		$_key = str_replace( '_wpinv', '', $key );
411
-		$_key = str_replace( 'wpinv', '', $_key );
412
-		if ( $this->is_internal_meta_key( $_key ) ) {
410
+		$_key = str_replace('_wpinv', '', $key);
411
+		$_key = str_replace('wpinv', '', $_key);
412
+		if ($this->is_internal_meta_key($_key)) {
413 413
 			$function = 'get_' . $_key;
414 414
 
415
-			if ( is_callable( array( $this, $function ) ) ) {
415
+			if (is_callable(array($this, $function))) {
416 416
 				return $this->{$function}();
417 417
 			}
418 418
 		}
@@ -420,20 +420,20 @@  discard block
 block discarded – undo
420 420
 		// Read the meta data if not yet read.
421 421
 		$this->maybe_read_meta_data();
422 422
 		$meta_data  = $this->get_meta_data();
423
-		$array_keys = array_keys( wp_list_pluck( $meta_data, 'key' ), $key, true );
423
+		$array_keys = array_keys(wp_list_pluck($meta_data, 'key'), $key, true);
424 424
 		$value      = $single ? '' : array();
425 425
 
426
-		if ( ! empty( $array_keys ) ) {
426
+		if (!empty($array_keys)) {
427 427
 			// We don't use the $this->meta_data property directly here because we don't want meta with a null value (i.e. meta which has been deleted via $this->delete_meta_data()).
428
-			if ( $single ) {
429
-				$value = $meta_data[ current( $array_keys ) ]->value;
428
+			if ($single) {
429
+				$value = $meta_data[current($array_keys)]->value;
430 430
 			} else {
431
-				$value = array_intersect_key( $meta_data, array_flip( $array_keys ) );
431
+				$value = array_intersect_key($meta_data, array_flip($array_keys));
432 432
 			}
433 433
 		}
434 434
 
435
-		if ( 'view' === $context ) {
436
-			$value = apply_filters( $this->get_hook_prefix() . $key, $value, $this );
435
+		if ('view' === $context) {
436
+			$value = apply_filters($this->get_hook_prefix() . $key, $value, $this);
437 437
 		}
438 438
 
439 439
 		return $value;
@@ -446,10 +446,10 @@  discard block
 block discarded – undo
446 446
 	 * @param  string $key Meta Key.
447 447
 	 * @return boolean
448 448
 	 */
449
-	public function meta_exists( $key = '' ) {
449
+	public function meta_exists($key = '') {
450 450
 		$this->maybe_read_meta_data();
451
-		$array_keys = wp_list_pluck( $this->get_meta_data(), 'key' );
452
-		return in_array( $key, $array_keys, true );
451
+		$array_keys = wp_list_pluck($this->get_meta_data(), 'key');
452
+		return in_array($key, $array_keys, true);
453 453
 	}
454 454
 
455 455
 	/**
@@ -458,12 +458,12 @@  discard block
 block discarded – undo
458 458
 	 * @since 1.0.19
459 459
 	 * @param array $data Key/Value pairs.
460 460
 	 */
461
-	public function set_meta_data( $data ) {
462
-		if ( ! empty( $data ) && is_array( $data ) ) {
461
+	public function set_meta_data($data) {
462
+		if (!empty($data) && is_array($data)) {
463 463
 			$this->maybe_read_meta_data();
464
-			foreach ( $data as $meta ) {
464
+			foreach ($data as $meta) {
465 465
 				$meta = (array) $meta;
466
-				if ( isset( $meta['key'], $meta['value'], $meta['id'] ) ) {
466
+				if (isset($meta['key'], $meta['value'], $meta['id'])) {
467 467
 					$this->meta_data[] = new GetPaid_Meta_Data(
468 468
 						array(
469 469
 							'id'    => $meta['id'],
@@ -485,18 +485,18 @@  discard block
 block discarded – undo
485 485
 	 * @param string|array $value Meta value.
486 486
 	 * @param bool         $unique Should this be a unique key?.
487 487
 	 */
488
-	public function add_meta_data( $key, $value, $unique = false ) {
489
-		if ( $this->is_internal_meta_key( $key ) ) {
488
+	public function add_meta_data($key, $value, $unique = false) {
489
+		if ($this->is_internal_meta_key($key)) {
490 490
 			$function = 'set_' . $key;
491 491
 
492
-			if ( is_callable( array( $this, $function ) ) ) {
493
-				return $this->{$function}( $value );
492
+			if (is_callable(array($this, $function))) {
493
+				return $this->{$function}($value);
494 494
 			}
495 495
 		}
496 496
 
497 497
 		$this->maybe_read_meta_data();
498
-		if ( $unique ) {
499
-			$this->delete_meta_data( $key );
498
+		if ($unique) {
499
+			$this->delete_meta_data($key);
500 500
 		}
501 501
 		$this->meta_data[] = new GetPaid_Meta_Data(
502 502
 			array(
@@ -515,12 +515,12 @@  discard block
 block discarded – undo
515 515
 	 * @param  string|array $value Meta value.
516 516
 	 * @param  int          $meta_id Meta ID.
517 517
 	 */
518
-	public function update_meta_data( $key, $value, $meta_id = 0 ) {
519
-		if ( $this->is_internal_meta_key( $key ) ) {
518
+	public function update_meta_data($key, $value, $meta_id = 0) {
519
+		if ($this->is_internal_meta_key($key)) {
520 520
 			$function = 'set_' . $key;
521 521
 
522
-			if ( is_callable( array( $this, $function ) ) ) {
523
-				return $this->{$function}( $value );
522
+			if (is_callable(array($this, $function))) {
523
+				return $this->{$function}($value);
524 524
 			}
525 525
 		}
526 526
 
@@ -528,33 +528,33 @@  discard block
 block discarded – undo
528 528
 
529 529
 		$array_key = false;
530 530
 
531
-		if ( $meta_id ) {
532
-			$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), $meta_id, true );
533
-			$array_key  = $array_keys ? current( $array_keys ) : false;
531
+		if ($meta_id) {
532
+			$array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), $meta_id, true);
533
+			$array_key  = $array_keys ? current($array_keys) : false;
534 534
 		} else {
535 535
 			// Find matches by key.
536 536
 			$matches = array();
537
-			foreach ( $this->meta_data as $meta_data_array_key => $meta ) {
538
-				if ( $meta->key === $key ) {
537
+			foreach ($this->meta_data as $meta_data_array_key => $meta) {
538
+				if ($meta->key === $key) {
539 539
 					$matches[] = $meta_data_array_key;
540 540
 				}
541 541
 			}
542 542
 
543
-			if ( ! empty( $matches ) ) {
543
+			if (!empty($matches)) {
544 544
 				// Set matches to null so only one key gets the new value.
545
-				foreach ( $matches as $meta_data_array_key ) {
546
-					$this->meta_data[ $meta_data_array_key ]->value = null;
545
+				foreach ($matches as $meta_data_array_key) {
546
+					$this->meta_data[$meta_data_array_key]->value = null;
547 547
 				}
548
-				$array_key = current( $matches );
548
+				$array_key = current($matches);
549 549
 			}
550 550
 		}
551 551
 
552
-		if ( false !== $array_key ) {
553
-			$meta        = $this->meta_data[ $array_key ];
552
+		if (false !== $array_key) {
553
+			$meta        = $this->meta_data[$array_key];
554 554
 			$meta->key   = $key;
555 555
 			$meta->value = $value;
556 556
 		} else {
557
-			$this->add_meta_data( $key, $value, true );
557
+			$this->add_meta_data($key, $value, true);
558 558
 		}
559 559
 	}
560 560
 
@@ -564,13 +564,13 @@  discard block
 block discarded – undo
564 564
 	 * @since 1.0.19
565 565
 	 * @param string $key Meta key.
566 566
 	 */
567
-	public function delete_meta_data( $key ) {
567
+	public function delete_meta_data($key) {
568 568
 		$this->maybe_read_meta_data();
569
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'key' ), $key, true );
569
+		$array_keys = array_keys(wp_list_pluck($this->meta_data, 'key'), $key, true);
570 570
 
571
-		if ( $array_keys ) {
572
-			foreach ( $array_keys as $array_key ) {
573
-				$this->meta_data[ $array_key ]->value = null;
571
+		if ($array_keys) {
572
+			foreach ($array_keys as $array_key) {
573
+				$this->meta_data[$array_key]->value = null;
574 574
 			}
575 575
 		}
576 576
 	}
@@ -581,13 +581,13 @@  discard block
 block discarded – undo
581 581
 	 * @since 1.0.19
582 582
 	 * @param int $mid Meta ID.
583 583
 	 */
584
-	public function delete_meta_data_by_mid( $mid ) {
584
+	public function delete_meta_data_by_mid($mid) {
585 585
 		$this->maybe_read_meta_data();
586
-		$array_keys = array_keys( wp_list_pluck( $this->meta_data, 'id' ), (int) $mid, true );
586
+		$array_keys = array_keys(wp_list_pluck($this->meta_data, 'id'), (int) $mid, true);
587 587
 
588
-		if ( $array_keys ) {
589
-			foreach ( $array_keys as $array_key ) {
590
-				$this->meta_data[ $array_key ]->value = null;
588
+		if ($array_keys) {
589
+			foreach ($array_keys as $array_key) {
590
+				$this->meta_data[$array_key]->value = null;
591 591
 			}
592 592
 		}
593 593
 	}
@@ -598,7 +598,7 @@  discard block
 block discarded – undo
598 598
 	 * @since 1.0.19
599 599
 	 */
600 600
 	protected function maybe_read_meta_data() {
601
-		if ( is_null( $this->meta_data ) ) {
601
+		if (is_null($this->meta_data)) {
602 602
 			$this->read_meta_data();
603 603
 		}
604 604
 	}
@@ -610,42 +610,42 @@  discard block
 block discarded – undo
610 610
 	 * @since 1.0.19
611 611
 	 * @param bool $force_read True to force a new DB read (and update cache).
612 612
 	 */
613
-	public function read_meta_data( $force_read = false ) {
613
+	public function read_meta_data($force_read = false) {
614 614
 
615 615
 		// Reset meta data.
616 616
 		$this->meta_data = array();
617 617
 
618 618
 		// Maybe abort early.
619
-		if ( ! $this->get_id() || ! $this->data_store ) {
619
+		if (!$this->get_id() || !$this->data_store) {
620 620
 			return;
621 621
 		}
622 622
 
623 623
 		// Only read from cache if the cache key is set.
624 624
 		$cache_key = null;
625
-		if ( ! $force_read && ! empty( $this->cache_group ) ) {
626
-			$cache_key     = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
627
-			$raw_meta_data = wp_cache_get( $cache_key, $this->cache_group );
625
+		if (!$force_read && !empty($this->cache_group)) {
626
+			$cache_key     = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id();
627
+			$raw_meta_data = wp_cache_get($cache_key, $this->cache_group);
628 628
 		}
629 629
 
630 630
 		// Should we force read?
631
-		if ( empty( $raw_meta_data ) ) {
632
-			$raw_meta_data = $this->data_store->read_meta( $this );
631
+		if (empty($raw_meta_data)) {
632
+			$raw_meta_data = $this->data_store->read_meta($this);
633 633
 
634
-			if ( ! empty( $cache_key ) ) {
635
-				wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group );
634
+			if (!empty($cache_key)) {
635
+				wp_cache_set($cache_key, $raw_meta_data, $this->cache_group);
636 636
 			}
637 637
 
638 638
 		}
639 639
 
640 640
 		// Set meta data.
641
-		if ( is_array( $raw_meta_data ) ) {
641
+		if (is_array($raw_meta_data)) {
642 642
 
643
-			foreach ( $raw_meta_data as $meta ) {
643
+			foreach ($raw_meta_data as $meta) {
644 644
 				$this->meta_data[] = new GetPaid_Meta_Data(
645 645
 					array(
646 646
 						'id'    => (int) $meta->meta_id,
647 647
 						'key'   => $meta->meta_key,
648
-						'value' => maybe_unserialize( $meta->meta_value ),
648
+						'value' => maybe_unserialize($meta->meta_value),
649 649
 					)
650 650
 				);
651 651
 			}
@@ -660,28 +660,28 @@  discard block
 block discarded – undo
660 660
 	 * @since 1.0.19
661 661
 	 */
662 662
 	public function save_meta_data() {
663
-		if ( ! $this->data_store || is_null( $this->meta_data ) ) {
663
+		if (!$this->data_store || is_null($this->meta_data)) {
664 664
 			return;
665 665
 		}
666
-		foreach ( $this->meta_data as $array_key => $meta ) {
667
-			if ( is_null( $meta->value ) ) {
668
-				if ( ! empty( $meta->id ) ) {
669
-					$this->data_store->delete_meta( $this, $meta );
670
-					unset( $this->meta_data[ $array_key ] );
666
+		foreach ($this->meta_data as $array_key => $meta) {
667
+			if (is_null($meta->value)) {
668
+				if (!empty($meta->id)) {
669
+					$this->data_store->delete_meta($this, $meta);
670
+					unset($this->meta_data[$array_key]);
671 671
 				}
672
-			} elseif ( empty( $meta->id ) ) {
673
-				$meta->id = $this->data_store->add_meta( $this, $meta );
672
+			} elseif (empty($meta->id)) {
673
+				$meta->id = $this->data_store->add_meta($this, $meta);
674 674
 				$meta->apply_changes();
675 675
 			} else {
676
-				if ( $meta->get_changes() ) {
677
-					$this->data_store->update_meta( $this, $meta );
676
+				if ($meta->get_changes()) {
677
+					$this->data_store->update_meta($this, $meta);
678 678
 					$meta->apply_changes();
679 679
 				}
680 680
 			}
681 681
 		}
682
-		if ( ! empty( $this->cache_group ) ) {
683
-			$cache_key = GetPaid_Cache_Helper::get_cache_prefix( $this->cache_group ) . GetPaid_Cache_Helper::get_cache_prefix( 'object_' . $this->get_id() ) . 'object_meta_' . $this->get_id();
684
-			wp_cache_delete( $cache_key, $this->cache_group );
682
+		if (!empty($this->cache_group)) {
683
+			$cache_key = GetPaid_Cache_Helper::get_cache_prefix($this->cache_group) . GetPaid_Cache_Helper::get_cache_prefix('object_' . $this->get_id()) . 'object_meta_' . $this->get_id();
684
+			wp_cache_delete($cache_key, $this->cache_group);
685 685
 		}
686 686
 	}
687 687
 
@@ -691,8 +691,8 @@  discard block
 block discarded – undo
691 691
 	 * @since 1.0.19
692 692
 	 * @param int $id ID.
693 693
 	 */
694
-	public function set_id( $id ) {
695
-		$this->id = absint( $id );
694
+	public function set_id($id) {
695
+		$this->id = absint($id);
696 696
 	}
697 697
 
698 698
 	/**
@@ -702,10 +702,10 @@  discard block
 block discarded – undo
702 702
 	 * @param string $status New status.
703 703
 	 * @return array details of change.
704 704
 	 */
705
-	public function set_status( $status ) {
705
+	public function set_status($status) {
706 706
         $old_status = $this->get_status();
707 707
 
708
-		$this->set_prop( 'status', $status );
708
+		$this->set_prop('status', $status);
709 709
 
710 710
 		return array(
711 711
 			'from' => $old_status,
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
 	public function set_defaults() {
722 722
 		$this->data    = $this->default_data;
723 723
 		$this->changes = array();
724
-		$this->set_object_read( false );
724
+		$this->set_object_read(false);
725 725
 	}
726 726
 
727 727
 	/**
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
 	 * @since 1.0.19
731 731
 	 * @param boolean $read Should read?.
732 732
 	 */
733
-	public function set_object_read( $read = true ) {
733
+	public function set_object_read($read = true) {
734 734
 		$this->object_read = (bool) $read;
735 735
 	}
736 736
 
@@ -755,32 +755,32 @@  discard block
 block discarded – undo
755 755
 	 *
756 756
 	 * @return bool|WP_Error
757 757
 	 */
758
-	public function set_props( $props, $context = 'set' ) {
758
+	public function set_props($props, $context = 'set') {
759 759
 		$errors = false;
760 760
 
761
-		foreach ( $props as $prop => $value ) {
761
+		foreach ($props as $prop => $value) {
762 762
 			try {
763 763
 				/**
764 764
 				 * Checks if the prop being set is allowed, and the value is not null.
765 765
 				 */
766
-				if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
766
+				if (is_null($value) || in_array($prop, array('prop', 'date_prop', 'meta_data'), true)) {
767 767
 					continue;
768 768
 				}
769 769
 				$setter = "set_$prop";
770 770
 
771
-				if ( is_callable( array( $this, $setter ) ) ) {
772
-					$this->{$setter}( $value );
771
+				if (is_callable(array($this, $setter))) {
772
+					$this->{$setter}($value);
773 773
 				}
774
-			} catch ( Exception $e ) {
775
-				if ( ! $errors ) {
774
+			} catch (Exception $e) {
775
+				if (!$errors) {
776 776
 					$errors = new WP_Error();
777 777
 				}
778
-				$errors->add( $e->getCode(), $e->getMessage() );
778
+				$errors->add($e->getCode(), $e->getMessage());
779 779
 				$this->last_error = $e->getMessage();
780 780
 			}
781 781
 		}
782 782
 
783
-		return $errors && count( $errors->get_error_codes() ) ? $errors : true;
783
+		return $errors && count($errors->get_error_codes()) ? $errors : true;
784 784
 	}
785 785
 
786 786
 	/**
@@ -793,14 +793,14 @@  discard block
 block discarded – undo
793 793
 	 * @param string $prop Name of prop to set.
794 794
 	 * @param mixed  $value Value of the prop.
795 795
 	 */
796
-	protected function set_prop( $prop, $value ) {
797
-		if ( array_key_exists( $prop, $this->data ) ) {
798
-			if ( true === $this->object_read ) {
799
-				if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
800
-					$this->changes[ $prop ] = $value;
796
+	protected function set_prop($prop, $value) {
797
+		if (array_key_exists($prop, $this->data)) {
798
+			if (true === $this->object_read) {
799
+				if ($value !== $this->data[$prop] || array_key_exists($prop, $this->changes)) {
800
+					$this->changes[$prop] = $value;
801 801
 				}
802 802
 			} else {
803
-				$this->data[ $prop ] = $value;
803
+				$this->data[$prop] = $value;
804 804
 			}
805 805
 		}
806 806
 	}
@@ -821,7 +821,7 @@  discard block
 block discarded – undo
821 821
 	 * @since 1.0.19
822 822
 	 */
823 823
 	public function apply_changes() {
824
-		$this->data    = array_replace_recursive( $this->data, $this->changes );
824
+		$this->data    = array_replace_recursive($this->data, $this->changes);
825 825
 		$this->changes = array();
826 826
 	}
827 827
 
@@ -846,14 +846,14 @@  discard block
 block discarded – undo
846 846
 	 * @param  string $context What the value is for. Valid values are view and edit.
847 847
 	 * @return mixed
848 848
 	 */
849
-	protected function get_prop( $prop, $context = 'view' ) {
849
+	protected function get_prop($prop, $context = 'view') {
850 850
 		$value = null;
851 851
 
852
-		if ( array_key_exists( $prop, $this->data ) ) {
853
-			$value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ];
852
+		if (array_key_exists($prop, $this->data)) {
853
+			$value = array_key_exists($prop, $this->changes) ? $this->changes[$prop] : $this->data[$prop];
854 854
 
855
-			if ( 'view' === $context ) {
856
-				$value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
855
+			if ('view' === $context) {
856
+				$value = apply_filters($this->get_hook_prefix() . $prop, $value, $this);
857 857
 			}
858 858
 		}
859 859
 
@@ -867,13 +867,13 @@  discard block
 block discarded – undo
867 867
 	 * @param string         $prop Name of prop to set.
868 868
 	 * @param string|integer $value Value of the prop.
869 869
 	 */
870
-	protected function set_date_prop( $prop, $value ) {
870
+	protected function set_date_prop($prop, $value) {
871 871
 
872
-		if ( empty( $value ) ) {
873
-			$this->set_prop( $prop, null );
872
+		if (empty($value)) {
873
+			$this->set_prop($prop, null);
874 874
 			return;
875 875
 		}
876
-		$this->set_prop( $prop, $value );
876
+		$this->set_prop($prop, $value);
877 877
 
878 878
 	}
879 879
 
@@ -884,7 +884,7 @@  discard block
 block discarded – undo
884 884
 	 * @param string $code             Error code.
885 885
 	 * @param string $message          Error message.
886 886
 	 */
887
-	protected function error( $code, $message ) {
887
+	protected function error($code, $message) {
888 888
 		$this->last_error = $message;
889 889
 	}
890 890
 
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
 	 */
897 897
 	public function exists() {
898 898
 		$id = $this->get_id();
899
-		return ! empty( $id );
899
+		return !empty($id);
900 900
 	}
901 901
 
902 902
 }
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-subscription-data-store.php 2 patches
Indentation   +180 added lines, -180 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
  *
6 6
  */
7 7
 if ( ! defined( 'ABSPATH' ) ) {
8
-	exit;
8
+    exit;
9 9
 }
10 10
 
11 11
 /**
@@ -15,196 +15,196 @@  discard block
 block discarded – undo
15 15
  */
16 16
 class GetPaid_Subscription_Data_Store {
17 17
 
18
-	/**
19
-	 * A map of database fields to data types.
20
-	 *
21
-	 * @since 1.0.19
22
-	 * @var array
23
-	 */
24
-	protected $database_fields_to_data_type = array(
25
-		'id'                => '%d',
26
-		'customer_id'       => '%d',
27
-		'frequency'         => '%d',
28
-		'period'            => '%s',
29
-		'initial_amount'    => '%s',
30
-		'recurring_amount'  => '%s',
31
-		'bill_times'        => '%d',
32
-		'transaction_id'    => '%s',
33
-		'parent_payment_id' => '%d',
34
-		'product_id'        => '%d',
35
-		'created'           => '%s',
36
-		'expiration'        => '%s',
37
-		'trial_period'      => '%s',
38
-		'status'            => '%s',
39
-		'profile_id'        => '%s',
40
-	);
41
-
42
-	/*
18
+    /**
19
+     * A map of database fields to data types.
20
+     *
21
+     * @since 1.0.19
22
+     * @var array
23
+     */
24
+    protected $database_fields_to_data_type = array(
25
+        'id'                => '%d',
26
+        'customer_id'       => '%d',
27
+        'frequency'         => '%d',
28
+        'period'            => '%s',
29
+        'initial_amount'    => '%s',
30
+        'recurring_amount'  => '%s',
31
+        'bill_times'        => '%d',
32
+        'transaction_id'    => '%s',
33
+        'parent_payment_id' => '%d',
34
+        'product_id'        => '%d',
35
+        'created'           => '%s',
36
+        'expiration'        => '%s',
37
+        'trial_period'      => '%s',
38
+        'status'            => '%s',
39
+        'profile_id'        => '%s',
40
+    );
41
+
42
+    /*
43 43
 	|--------------------------------------------------------------------------
44 44
 	| CRUD Methods
45 45
 	|--------------------------------------------------------------------------
46 46
 	*/
47 47
 
48
-	/**
49
-	 * Method to create a new subscription in the database.
50
-	 *
51
-	 * @param WPInv_Subscription $subscription Subscription object.
52
-	 */
53
-	public function create( &$subscription ) {
54
-		global $wpdb;
55
-
56
-		$values  = array();
57
-		$formats = array();
58
-
59
-		$fields = $this->database_fields_to_data_type;
60
-		unset( $fields['id'] );
61
-
62
-		foreach ( $fields as $key => $format ) {
63
-			$method       = "get_$key";
64
-			$values[$key] = $subscription->$method( 'edit' );
65
-			$formats[]    = $format;
66
-		}
67
-
68
-		$result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $values, $formats );
69
-
70
-		if ( $result ) {
71
-			$subscription->set_id( $wpdb->insert_id );
72
-			$subscription->apply_changes();
73
-			$subscription->clear_cache();
74
-			update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() );
75
-			do_action( 'getpaid_new_subscription', $subscription );
76
-			return true;
77
-		}
78
-
79
-		return false;
80
-	}
81
-
82
-	/**
83
-	 * Method to read a subscription from the database.
84
-	 *
85
-	 * @param WPInv_Subscription $subscription Subscription object.
86
-	 *
87
-	 */
88
-	public function read( &$subscription ) {
89
-		global $wpdb;
90
-
91
-		$subscription->set_defaults();
92
-
93
-		if ( ! $subscription->get_id() ) {
94
-			$subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
95
-			$subscription->set_id( 0 );
96
-			return false;
97
-		}
98
-
99
-		// Maybe retrieve from the cache.
100
-		$raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' );
101
-
102
-		// If not found, retrieve from the db.
103
-		if ( false === $raw_subscription ) {
104
-
105
-			$raw_subscription = $wpdb->get_row(
106
-				$wpdb->prepare(
107
-					"SELECT * FROM {$wpdb->prefix}wpinv_subscriptions WHERE id = %d",
108
-					$subscription->get_id()
109
-				)
110
-			);
111
-
112
-			// Update the cache with our data
113
-			wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' );
114
-
115
-		}
116
-
117
-		if ( ! $raw_subscription ) {
118
-			$subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
119
-			return false;
120
-		}
121
-
122
-		foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) {
123
-			$method     = "set_$key";
124
-			$subscription->$method( $raw_subscription->$key );
125
-		}
126
-
127
-		$subscription->set_object_read( true );
128
-		do_action( 'getpaid_read_subscription', $subscription );
129
-
130
-	}
131
-
132
-	/**
133
-	 * Method to update a subscription in the database.
134
-	 *
135
-	 * @param WPInv_Subscription $subscription Subscription object.
136
-	 */
137
-	public function update( &$subscription ) {
138
-		global $wpdb;
139
-
140
-		$changes = $subscription->get_changes();
141
-		$values  = array();
142
-		$format  = array();
143
-
144
-		foreach ( $this->database_fields_to_data_type as $key => $format ) {
145
-			if ( array_key_exists( $key, $changes ) ) {
146
-				$method       = "get_$key";
147
-				$values[$key] = $subscription->$method( 'edit' );
148
-				$formats[]    = $format;
149
-			}
150
-		}
151
-
152
-		if ( empty( $values ) ) {
153
-			return;
154
-		}
155
-
156
-		$wpdb->update(
157
-			$wpdb->prefix . 'wpinv_subscriptions',
158
-			$values,
159
-			array(
160
-				'id' => $subscription->get_id(),
161
-			),
162
-			$formats,
163
-			'%d'
164
-		);
165
-
166
-		// Apply the changes.
167
-		$subscription->apply_changes();
168
-
169
-		// Delete cache.
170
-		$subscription->clear_cache();
171
-
172
-		update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id() );
173
-
174
-		// Fire a hook.
175
-		do_action( 'getpaid_update_subscription', $subscription );
176
-
177
-	}
178
-
179
-	/**
180
-	 * Method to delete a subscription from the database.
181
-	 *
182
-	 * @param WPInv_Subscription $subscription
183
-	 */
184
-	public function delete( &$subscription ) {
185
-		global $wpdb;
186
-
187
-		$wpdb->query(
188
-			$wpdb->prepare(
189
-				"DELETE FROM {$wpdb->prefix}getpaid_subscriptions
48
+    /**
49
+     * Method to create a new subscription in the database.
50
+     *
51
+     * @param WPInv_Subscription $subscription Subscription object.
52
+     */
53
+    public function create( &$subscription ) {
54
+        global $wpdb;
55
+
56
+        $values  = array();
57
+        $formats = array();
58
+
59
+        $fields = $this->database_fields_to_data_type;
60
+        unset( $fields['id'] );
61
+
62
+        foreach ( $fields as $key => $format ) {
63
+            $method       = "get_$key";
64
+            $values[$key] = $subscription->$method( 'edit' );
65
+            $formats[]    = $format;
66
+        }
67
+
68
+        $result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $values, $formats );
69
+
70
+        if ( $result ) {
71
+            $subscription->set_id( $wpdb->insert_id );
72
+            $subscription->apply_changes();
73
+            $subscription->clear_cache();
74
+            update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() );
75
+            do_action( 'getpaid_new_subscription', $subscription );
76
+            return true;
77
+        }
78
+
79
+        return false;
80
+    }
81
+
82
+    /**
83
+     * Method to read a subscription from the database.
84
+     *
85
+     * @param WPInv_Subscription $subscription Subscription object.
86
+     *
87
+     */
88
+    public function read( &$subscription ) {
89
+        global $wpdb;
90
+
91
+        $subscription->set_defaults();
92
+
93
+        if ( ! $subscription->get_id() ) {
94
+            $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
95
+            $subscription->set_id( 0 );
96
+            return false;
97
+        }
98
+
99
+        // Maybe retrieve from the cache.
100
+        $raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' );
101
+
102
+        // If not found, retrieve from the db.
103
+        if ( false === $raw_subscription ) {
104
+
105
+            $raw_subscription = $wpdb->get_row(
106
+                $wpdb->prepare(
107
+                    "SELECT * FROM {$wpdb->prefix}wpinv_subscriptions WHERE id = %d",
108
+                    $subscription->get_id()
109
+                )
110
+            );
111
+
112
+            // Update the cache with our data
113
+            wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' );
114
+
115
+        }
116
+
117
+        if ( ! $raw_subscription ) {
118
+            $subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
119
+            return false;
120
+        }
121
+
122
+        foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) {
123
+            $method     = "set_$key";
124
+            $subscription->$method( $raw_subscription->$key );
125
+        }
126
+
127
+        $subscription->set_object_read( true );
128
+        do_action( 'getpaid_read_subscription', $subscription );
129
+
130
+    }
131
+
132
+    /**
133
+     * Method to update a subscription in the database.
134
+     *
135
+     * @param WPInv_Subscription $subscription Subscription object.
136
+     */
137
+    public function update( &$subscription ) {
138
+        global $wpdb;
139
+
140
+        $changes = $subscription->get_changes();
141
+        $values  = array();
142
+        $format  = array();
143
+
144
+        foreach ( $this->database_fields_to_data_type as $key => $format ) {
145
+            if ( array_key_exists( $key, $changes ) ) {
146
+                $method       = "get_$key";
147
+                $values[$key] = $subscription->$method( 'edit' );
148
+                $formats[]    = $format;
149
+            }
150
+        }
151
+
152
+        if ( empty( $values ) ) {
153
+            return;
154
+        }
155
+
156
+        $wpdb->update(
157
+            $wpdb->prefix . 'wpinv_subscriptions',
158
+            $values,
159
+            array(
160
+                'id' => $subscription->get_id(),
161
+            ),
162
+            $formats,
163
+            '%d'
164
+        );
165
+
166
+        // Apply the changes.
167
+        $subscription->apply_changes();
168
+
169
+        // Delete cache.
170
+        $subscription->clear_cache();
171
+
172
+        update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id() );
173
+
174
+        // Fire a hook.
175
+        do_action( 'getpaid_update_subscription', $subscription );
176
+
177
+    }
178
+
179
+    /**
180
+     * Method to delete a subscription from the database.
181
+     *
182
+     * @param WPInv_Subscription $subscription
183
+     */
184
+    public function delete( &$subscription ) {
185
+        global $wpdb;
186
+
187
+        $wpdb->query(
188
+            $wpdb->prepare(
189
+                "DELETE FROM {$wpdb->prefix}getpaid_subscriptions
190 190
 				WHERE id = %d",
191
-				$subscription->get_id()
192
-			)
193
-		);
191
+                $subscription->get_id()
192
+            )
193
+        );
194 194
 
195
-		delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id' );
196
-		delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id' );
195
+        delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id' );
196
+        delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id' );
197 197
 
198
-		// Delete cache.
199
-		$subscription->clear_cache();
198
+        // Delete cache.
199
+        $subscription->clear_cache();
200 200
 
201
-		// Fire a hook.
202
-		do_action( 'getpaid_delete_subscription', $subscription );
201
+        // Fire a hook.
202
+        do_action( 'getpaid_delete_subscription', $subscription );
203 203
 
204
-		$subscription->set_id( 0 );
205
-	}
204
+        $subscription->set_id( 0 );
205
+    }
206 206
 
207
-	/*
207
+    /*
208 208
 	|--------------------------------------------------------------------------
209 209
 	| Additional Methods
210 210
 	|--------------------------------------------------------------------------
Please login to merge, or discard this patch.
Spacing   +36 added lines, -36 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
  * GetPaid_Subscription_Data_Store class file.
5 5
  *
6 6
  */
7
-if ( ! defined( 'ABSPATH' ) ) {
7
+if (!defined('ABSPATH')) {
8 8
 	exit;
9 9
 }
10 10
 
@@ -50,29 +50,29 @@  discard block
 block discarded – undo
50 50
 	 *
51 51
 	 * @param WPInv_Subscription $subscription Subscription object.
52 52
 	 */
53
-	public function create( &$subscription ) {
53
+	public function create(&$subscription) {
54 54
 		global $wpdb;
55 55
 
56 56
 		$values  = array();
57 57
 		$formats = array();
58 58
 
59 59
 		$fields = $this->database_fields_to_data_type;
60
-		unset( $fields['id'] );
60
+		unset($fields['id']);
61 61
 
62
-		foreach ( $fields as $key => $format ) {
62
+		foreach ($fields as $key => $format) {
63 63
 			$method       = "get_$key";
64
-			$values[$key] = $subscription->$method( 'edit' );
64
+			$values[$key] = $subscription->$method('edit');
65 65
 			$formats[]    = $format;
66 66
 		}
67 67
 
68
-		$result = $wpdb->insert( $wpdb->prefix . 'wpinv_subscriptions', $values, $formats );
68
+		$result = $wpdb->insert($wpdb->prefix . 'wpinv_subscriptions', $values, $formats);
69 69
 
70
-		if ( $result ) {
71
-			$subscription->set_id( $wpdb->insert_id );
70
+		if ($result) {
71
+			$subscription->set_id($wpdb->insert_id);
72 72
 			$subscription->apply_changes();
73 73
 			$subscription->clear_cache();
74
-			update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id() );
75
-			do_action( 'getpaid_new_subscription', $subscription );
74
+			update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id', $subscription->get_id());
75
+			do_action('getpaid_new_subscription', $subscription);
76 76
 			return true;
77 77
 		}
78 78
 
@@ -85,22 +85,22 @@  discard block
 block discarded – undo
85 85
 	 * @param WPInv_Subscription $subscription Subscription object.
86 86
 	 *
87 87
 	 */
88
-	public function read( &$subscription ) {
88
+	public function read(&$subscription) {
89 89
 		global $wpdb;
90 90
 
91 91
 		$subscription->set_defaults();
92 92
 
93
-		if ( ! $subscription->get_id() ) {
94
-			$subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
95
-			$subscription->set_id( 0 );
93
+		if (!$subscription->get_id()) {
94
+			$subscription->last_error = __('Invalid subscription ID.', 'invoicing');
95
+			$subscription->set_id(0);
96 96
 			return false;
97 97
 		}
98 98
 
99 99
 		// Maybe retrieve from the cache.
100
-		$raw_subscription = wp_cache_get( $subscription->get_id(), 'getpaid_subscriptions' );
100
+		$raw_subscription = wp_cache_get($subscription->get_id(), 'getpaid_subscriptions');
101 101
 
102 102
 		// If not found, retrieve from the db.
103
-		if ( false === $raw_subscription ) {
103
+		if (false === $raw_subscription) {
104 104
 
105 105
 			$raw_subscription = $wpdb->get_row(
106 106
 				$wpdb->prepare(
@@ -110,22 +110,22 @@  discard block
 block discarded – undo
110 110
 			);
111 111
 
112 112
 			// Update the cache with our data
113
-			wp_cache_set( $subscription->get_id(), $raw_subscription, 'getpaid_subscriptions' );
113
+			wp_cache_set($subscription->get_id(), $raw_subscription, 'getpaid_subscriptions');
114 114
 
115 115
 		}
116 116
 
117
-		if ( ! $raw_subscription ) {
118
-			$subscription->last_error = __( 'Invalid subscription ID.', 'invoicing' );
117
+		if (!$raw_subscription) {
118
+			$subscription->last_error = __('Invalid subscription ID.', 'invoicing');
119 119
 			return false;
120 120
 		}
121 121
 
122
-		foreach ( array_keys( $this->database_fields_to_data_type ) as $key ) {
123
-			$method     = "set_$key";
124
-			$subscription->$method( $raw_subscription->$key );
122
+		foreach (array_keys($this->database_fields_to_data_type) as $key) {
123
+			$method = "set_$key";
124
+			$subscription->$method($raw_subscription->$key);
125 125
 		}
126 126
 
127
-		$subscription->set_object_read( true );
128
-		do_action( 'getpaid_read_subscription', $subscription );
127
+		$subscription->set_object_read(true);
128
+		do_action('getpaid_read_subscription', $subscription);
129 129
 
130 130
 	}
131 131
 
@@ -134,22 +134,22 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @param WPInv_Subscription $subscription Subscription object.
136 136
 	 */
137
-	public function update( &$subscription ) {
137
+	public function update(&$subscription) {
138 138
 		global $wpdb;
139 139
 
140 140
 		$changes = $subscription->get_changes();
141 141
 		$values  = array();
142 142
 		$format  = array();
143 143
 
144
-		foreach ( $this->database_fields_to_data_type as $key => $format ) {
145
-			if ( array_key_exists( $key, $changes ) ) {
144
+		foreach ($this->database_fields_to_data_type as $key => $format) {
145
+			if (array_key_exists($key, $changes)) {
146 146
 				$method       = "get_$key";
147
-				$values[$key] = $subscription->$method( 'edit' );
147
+				$values[$key] = $subscription->$method('edit');
148 148
 				$formats[]    = $format;
149 149
 			}
150 150
 		}
151 151
 
152
-		if ( empty( $values ) ) {
152
+		if (empty($values)) {
153 153
 			return;
154 154
 		}
155 155
 
@@ -169,10 +169,10 @@  discard block
 block discarded – undo
169 169
 		// Delete cache.
170 170
 		$subscription->clear_cache();
171 171
 
172
-		update_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id() );
172
+		update_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id', $subscription->get_profile_id());
173 173
 
174 174
 		// Fire a hook.
175
-		do_action( 'getpaid_update_subscription', $subscription );
175
+		do_action('getpaid_update_subscription', $subscription);
176 176
 
177 177
 	}
178 178
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @param WPInv_Subscription $subscription
183 183
 	 */
184
-	public function delete( &$subscription ) {
184
+	public function delete(&$subscription) {
185 185
 		global $wpdb;
186 186
 
187 187
 		$wpdb->query(
@@ -192,16 +192,16 @@  discard block
 block discarded – undo
192 192
 			)
193 193
 		);
194 194
 
195
-		delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id' );
196
-		delete_post_meta( $subscription->get_parent_invoice_id(), '_wpinv_subscription_id' );
195
+		delete_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscr_profile_id');
196
+		delete_post_meta($subscription->get_parent_invoice_id(), '_wpinv_subscription_id');
197 197
 
198 198
 		// Delete cache.
199 199
 		$subscription->clear_cache();
200 200
 
201 201
 		// Fire a hook.
202
-		do_action( 'getpaid_delete_subscription', $subscription );
202
+		do_action('getpaid_delete_subscription', $subscription);
203 203
 
204
-		$subscription->set_id( 0 );
204
+		$subscription->set_id(0);
205 205
 	}
206 206
 
207 207
 	/*
Please login to merge, or discard this patch.
includes/admin/class-wpinv-subscriptions-list-table.php 2 patches
Indentation   +419 added lines, -419 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 if ( ! defined( 'ABSPATH' ) ) exit;
7 7
 
8 8
 if ( ! class_exists( 'WP_List_Table' ) ) {
9
-	include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
9
+    include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
10 10
 }
11 11
 
12 12
 /**
@@ -14,423 +14,423 @@  discard block
 block discarded – undo
14 14
  */
15 15
 class WPInv_Subscriptions_List_Table extends WP_List_Table {
16 16
 
17
-	/**
18
-	 * URL of this page
19
-	 *
20
-	 * @var   string
21
-	 * @since 1.0.19
22
-	 */
23
-	public $base_url;
24
-
25
-	/**
26
-	 * Query
27
-	 *
28
-	 * @var   GetPaid_Subscriptions_Query
29
-	 * @since 1.0.19
30
-	 */
31
-	public $query;
32
-
33
-	/**
34
-	 * Total subscriptions
35
-	 *
36
-	 * @var   string
37
-	 * @since 1.0.0
38
-	 */
39
-	public $total_count;
40
-
41
-	/**
42
-	 * Current status subscriptions
43
-	 *
44
-	 * @var   string
45
-	 * @since 1.0.0
46
-	 */
47
-	public $current_total_count;
48
-
49
-	/**
50
-	 * Status counts
51
-	 *
52
-	 * @var   array
53
-	 * @since 1.0.19
54
-	 */
55
-	public $status_counts;
56
-
57
-	/**
58
-	 * Number of results to show per page
59
-	 *
60
-	 * @var   int
61
-	 * @since 1.0.0
62
-	 */
63
-	public $per_page = 10;
64
-
65
-	/**
66
-	 *  Constructor function.
67
-	 */
68
-	public function __construct() {
69
-
70
-		parent::__construct(
71
-			array(
72
-				'singular' => 'subscription',
73
-				'plural'   => 'subscriptions',
74
-			)
75
-		);
76
-
77
-		$this->process_bulk_action();
78
-
79
-		$this->prepare_query();
80
-
81
-		$this->base_url = remove_query_arg( 'status' );
82
-
83
-	}
84
-
85
-	/**
86
-	 *  Prepares the display query
87
-	 */
88
-	public function prepare_query() {
89
-
90
-		// Prepare query args.
91
-		$query = array(
92
-			'number'  => $this->per_page,
93
-			'paged'   => $this->get_paged(),
94
-			'status'  => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? $_GET['status'] : 'all',
95
-			'orderby' => ( isset( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id',
96
-			'order'   => ( isset( $_GET['order'] ) ) ? $_GET['order'] : 'DESC',
97
-		);
98
-
99
-		// Prepare class properties.
100
-		$this->query               = new GetPaid_Subscriptions_Query( $query );
101
-		$this->total_count         = $this->query->get_total();
102
-		$this->current_total_count = $this->query->get_total();
103
-		$this->items               = $this->query->get_results();
104
-		$this->status_counts       = getpaid_get_subscription_status_counts( $query );
105
-
106
-		if ( 'all' != $query['status'] ) {
107
-			unset( $query['status'] );
108
-			$this->total_count   = getpaid_get_subscriptions( $query, 'count' );
109
-		}
110
-
111
-	}
112
-
113
-	/**
114
-	 * Gets the list of views available on this table.
115
-	 *
116
-	 * The format is an associative array:
117
-	 * - `'id' => 'link'`
118
-	 *
119
-	 * @since 1.0.0
120
-	 *
121
-	 * @return array
122
-	 */
123
-	protected function get_views() {
124
-
125
-		$current  = isset( $_GET['status'] ) ? $_GET['status'] : 'all';
126
-		$views    = array(
127
-
128
-			'all' => sprintf(
129
-				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
130
-				esc_url( add_query_arg( 'status', false, $this->base_url ) ),
131
-				$current === 'all' ? ' class="current"' : '',
132
-				__('All','invoicing' ),
133
-				$this->total_count
134
-			)
135
-
136
-		);
137
-
138
-		foreach ( array_filter( $this->status_counts ) as $status => $count ) {
139
-
140
-			$views[ $status ] = sprintf(
141
-				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
142
-				esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
143
-				$current === $status ? ' class="current"' : '',
144
-				sanitize_text_field( getpaid_get_subscription_status_label( $status ) ),
145
-				$count
146
-			);
147
-
148
-		}
149
-
150
-		return $views;
151
-
152
-	}
153
-
154
-	/**
155
-	 * Render most columns
156
-	 *
157
-	 * @access      private
158
-	 * @since       1.0.0
159
-	 * @return      string
160
-	 */
161
-	public function column_default( $item, $column_name ) {
162
-		return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
163
-	}
164
-
165
-	/**
166
-	 * This is how checkbox column renders.
167
-	 *
168
-	 * @param WPInv_Subscription $item
169
-	 * @return string
170
-	 */
171
-	public function column_cb( $item ) {
172
-		return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
173
-	}
174
-
175
-	/**
176
-	 * Status column
177
-	 *
178
-	 * @param WPInv_Subscription $item
179
-	 * @since       1.0.0
180
-	 * @return      string
181
-	 */
182
-	public function column_status( $item ) {
183
-		return $item->get_status_label_html();
184
-	}
185
-
186
-	/**
187
-	 * Subscription column
188
-	 *
189
-	 * @param WPInv_Subscription $item
190
-	 * @since       1.0.0
191
-	 * @return      string
192
-	 */
193
-	public function column_subscription( $item ) {
194
-
195
-		$username = __( '(Missing User)', 'invoicing' );
196
-
197
-		$user = get_userdata( $item->get_customer_id() );
198
-		if ( $user ) {
199
-
200
-			$username = sprintf(
201
-				'<a href="user-edit.php?user_id=%s">%s</a>',
202
-				absint( $user->ID ),
203
-				! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email )
204
-			);
205
-
206
-		}
207
-
208
-		// translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
209
-		$column_content = sprintf(
210
-			_x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
211
-			'<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
212
-			'<strong>' . esc_attr( $item->get_id() ) . '</strong>', '</a>',
213
-			$username
214
-		);
215
-
216
-		$row_actions = array();
217
-
218
-		// View subscription.
219
-		$view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ));
220
-		$row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
221
-
222
-		// View invoice.
223
-		$invoice = get_post( $item->get_parent_invoice_id() );
224
-
225
-		if ( ! empty( $invoice ) ) {
226
-			$view_url    = get_edit_post_link( $invoice );
227
-			$row_actions['invoice'] = '<a href="' . $view_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
228
-		}
229
-
230
-		$row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
231
-
232
-		return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
233
-	}
234
-
235
-	/**
236
-	 * Renewal date column
237
-	 *
238
-	 * @param WPInv_Subscription $item
239
-	 * @since       1.0.0
240
-	 * @return      string
241
-	 */
242
-	public function column_renewal_date( $item ) {
243
-
244
-		$expiration = $item->get_expiration();
245
-		if ( ! $item->is_active() || empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
246
-			return "&mdash;";
247
-		}
248
-
249
-		return date_i18n( /** @scrutinizer ignore-type */get_option( 'date_format' ), strtotime( $expiration ) );
250
-
251
-	}
252
-
253
-	/**
254
-	 * Start date column
255
-	 *
256
-	 * @param WPInv_Subscription $item
257
-	 * @since       1.0.0
258
-	 * @return      string
259
-	 */
260
-	public function column_start_date( $item ) {
261
-
262
-		$created = $item->get_date_created();
263
-		if ( empty( $created ) || '0000-00-00 00:00:00' == $created ) {
264
-			return "&mdash;";
265
-		}
266
-
267
-		return date_i18n( /** @scrutinizer ignore-type */get_option( 'date_format' ), strtotime( $created ) );
268
-
269
-	}
270
-
271
-	/**
272
-	 * Amount column
273
-	 *
274
-	 * @param WPInv_Subscription $item
275
-	 * @since       1.0.19
276
-	 * @return      string
277
-	 */
278
-	public function column_amount( $item ) {
279
-
280
-		$initial   = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_initial_amount() ) ), $item->get_parent_payment()->get_currency() );
281
-		$recurring = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_recurring_amount() ) ), $item->get_parent_payment()->get_currency() );
282
-		$period    = 1 == $item->get_frequency() ? getpaid_get_subscription_period_label( $item->get_period() ) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->get_period(),$item->get_frequency() );
283
-
284
-		if ( $item->has_trial_period() ) {
285
-
286
-			// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
287
-			$amount = sprintf(
288
-				_x( '%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
289
-				$initial,
290
-				sanitize_text_field( $item->get_trial_period() ),
291
-				$recurring,
292
-				sanitize_text_field( strtolower( $period ) )
293
-			);
294
-
295
-		} else if ( $initial != $recurring ) {
296
-
297
-			// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring perio
298
-			$amount = sprintf(
299
-				_x( 'Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing' ),
300
-				$initial,
301
-				$recurring,
302
-				sanitize_text_field( strtolower( $period ) )
303
-			);
304
-
305
-		} else {
306
-
307
-			// translators: $1: is the recurring amount, $2: is the recurring period
308
-			$amount = sprintf(
309
-				_x( '%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing' ),
310
-				$initial,
311
-				sanitize_text_field( strtolower( $period ) )
312
-			);
313
-
314
-		}
315
-
316
-		return "<span class='text-muted form-text mt-2 mb-2'>$amount</span>";
317
-	}
318
-
319
-	/**
320
-	 * Billing Times column
321
-	 *
322
-	 * @param WPInv_Subscription $item
323
-	 * @since       1.0.0
324
-	 * @return      string
325
-	 */
326
-	public function column_renewals( $item ) {
327
-		$max_bills = $item->get_bill_times();
328
-		return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
329
-	}
330
-
331
-	/**
332
-	 * Product ID column
333
-	 *
334
-	 * @param WPInv_Subscription $item
335
-	 * @since       1.0.0
336
-	 * @return      string
337
-	 */
338
-	public function column_item( $item ) {
339
-		$_item = get_post( $item->get_product_id() );
340
-
341
-		if ( ! empty( $_item ) ) {
342
-			$link = get_edit_post_link( $_item );
343
-			$link = esc_url( $link );
344
-			$name = esc_html( get_the_title( $_item ) );
345
-			return "<a href='$link'>$name</a>";
346
-		} else {
347
-			return sprintf( __( 'Item #%s', 'invoicing' ), $item->get_product_id() );
348
-		}
349
-
350
-	}
351
-
352
-	/**
353
-	 * Retrieve the current page number
354
-	 *
355
-	 * @return      int
356
-	 */
357
-	public function get_paged() {
358
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
359
-	}
360
-
361
-	/**
362
-	 * Setup the final data for the table
363
-	 *
364
-	 */
365
-	public function prepare_items() {
366
-
367
-		$columns  = $this->get_columns();
368
-		$hidden   = array();
369
-		$sortable = $this->get_sortable_columns();
370
-
371
-		$this->_column_headers = array( $columns, $hidden, $sortable );
372
-
373
-		$this->set_pagination_args(
374
-			array(
375
-			'total_items' => $this->current_total_count,
376
-			'per_page'    => $this->per_page,
377
-			'total_pages' => ceil( $this->current_total_count / $this->per_page )
378
-			)
379
-		);
380
-	}
381
-
382
-	/**
383
-	 * Table columns
384
-	 *
385
-	 * @return array
386
-	 */
387
-	public function get_columns(){
388
-		$columns = array(
389
-			'cb'                => '<input type="checkbox" />',
390
-			'subscription'      => __( 'Subscription', 'invoicing' ),
391
-			'start_date'        => __( 'Start Date', 'invoicing' ),
392
-			'renewal_date'      => __( 'Next Payment', 'invoicing' ),
393
-			'renewals'          => __( 'Renewals', 'invoicing' ),
394
-			'item'              => __( 'Item', 'invoicing' ),
395
-			'status'            => __( 'Status', 'invoicing' ),
396
-		);
397
-
398
-		return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
399
-	}
400
-
401
-	/**
402
-	 * Sortable table columns.
403
-	 *
404
-	 * @return array
405
-	 */
406
-	public function get_sortable_columns() {
407
-		$sortable = array(
408
-			'subscription' => array( 'id', true ),
409
-			'start_date'   => array( 'created', true ),
410
-			'renewal_date' => array( 'expiration', true ),
411
-			'renewals'     => array( 'bill_times', true ),
412
-			'item'         => array( 'product_id', true ),
413
-			'status'       => array( 'status', true ),
414
-		);
415
-
416
-		return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
417
-	}
418
-
419
-	/**
420
-	 * Whether the table has items to display or not
421
-	 *
422
-	 * @return bool
423
-	 */
424
-	public function has_items() {
425
-		return ! empty( $this->current_total_count );
426
-	}
427
-
428
-	/**
429
-	 * Processes bulk actions.
430
-	 *
431
-	 */
432
-	public function process_bulk_action() {
433
-
434
-	}
17
+    /**
18
+     * URL of this page
19
+     *
20
+     * @var   string
21
+     * @since 1.0.19
22
+     */
23
+    public $base_url;
24
+
25
+    /**
26
+     * Query
27
+     *
28
+     * @var   GetPaid_Subscriptions_Query
29
+     * @since 1.0.19
30
+     */
31
+    public $query;
32
+
33
+    /**
34
+     * Total subscriptions
35
+     *
36
+     * @var   string
37
+     * @since 1.0.0
38
+     */
39
+    public $total_count;
40
+
41
+    /**
42
+     * Current status subscriptions
43
+     *
44
+     * @var   string
45
+     * @since 1.0.0
46
+     */
47
+    public $current_total_count;
48
+
49
+    /**
50
+     * Status counts
51
+     *
52
+     * @var   array
53
+     * @since 1.0.19
54
+     */
55
+    public $status_counts;
56
+
57
+    /**
58
+     * Number of results to show per page
59
+     *
60
+     * @var   int
61
+     * @since 1.0.0
62
+     */
63
+    public $per_page = 10;
64
+
65
+    /**
66
+     *  Constructor function.
67
+     */
68
+    public function __construct() {
69
+
70
+        parent::__construct(
71
+            array(
72
+                'singular' => 'subscription',
73
+                'plural'   => 'subscriptions',
74
+            )
75
+        );
76
+
77
+        $this->process_bulk_action();
78
+
79
+        $this->prepare_query();
80
+
81
+        $this->base_url = remove_query_arg( 'status' );
82
+
83
+    }
84
+
85
+    /**
86
+     *  Prepares the display query
87
+     */
88
+    public function prepare_query() {
89
+
90
+        // Prepare query args.
91
+        $query = array(
92
+            'number'  => $this->per_page,
93
+            'paged'   => $this->get_paged(),
94
+            'status'  => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? $_GET['status'] : 'all',
95
+            'orderby' => ( isset( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id',
96
+            'order'   => ( isset( $_GET['order'] ) ) ? $_GET['order'] : 'DESC',
97
+        );
98
+
99
+        // Prepare class properties.
100
+        $this->query               = new GetPaid_Subscriptions_Query( $query );
101
+        $this->total_count         = $this->query->get_total();
102
+        $this->current_total_count = $this->query->get_total();
103
+        $this->items               = $this->query->get_results();
104
+        $this->status_counts       = getpaid_get_subscription_status_counts( $query );
105
+
106
+        if ( 'all' != $query['status'] ) {
107
+            unset( $query['status'] );
108
+            $this->total_count   = getpaid_get_subscriptions( $query, 'count' );
109
+        }
110
+
111
+    }
112
+
113
+    /**
114
+     * Gets the list of views available on this table.
115
+     *
116
+     * The format is an associative array:
117
+     * - `'id' => 'link'`
118
+     *
119
+     * @since 1.0.0
120
+     *
121
+     * @return array
122
+     */
123
+    protected function get_views() {
124
+
125
+        $current  = isset( $_GET['status'] ) ? $_GET['status'] : 'all';
126
+        $views    = array(
127
+
128
+            'all' => sprintf(
129
+                '<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
130
+                esc_url( add_query_arg( 'status', false, $this->base_url ) ),
131
+                $current === 'all' ? ' class="current"' : '',
132
+                __('All','invoicing' ),
133
+                $this->total_count
134
+            )
135
+
136
+        );
137
+
138
+        foreach ( array_filter( $this->status_counts ) as $status => $count ) {
139
+
140
+            $views[ $status ] = sprintf(
141
+                '<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
142
+                esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
143
+                $current === $status ? ' class="current"' : '',
144
+                sanitize_text_field( getpaid_get_subscription_status_label( $status ) ),
145
+                $count
146
+            );
147
+
148
+        }
149
+
150
+        return $views;
151
+
152
+    }
153
+
154
+    /**
155
+     * Render most columns
156
+     *
157
+     * @access      private
158
+     * @since       1.0.0
159
+     * @return      string
160
+     */
161
+    public function column_default( $item, $column_name ) {
162
+        return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
163
+    }
164
+
165
+    /**
166
+     * This is how checkbox column renders.
167
+     *
168
+     * @param WPInv_Subscription $item
169
+     * @return string
170
+     */
171
+    public function column_cb( $item ) {
172
+        return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
173
+    }
174
+
175
+    /**
176
+     * Status column
177
+     *
178
+     * @param WPInv_Subscription $item
179
+     * @since       1.0.0
180
+     * @return      string
181
+     */
182
+    public function column_status( $item ) {
183
+        return $item->get_status_label_html();
184
+    }
185
+
186
+    /**
187
+     * Subscription column
188
+     *
189
+     * @param WPInv_Subscription $item
190
+     * @since       1.0.0
191
+     * @return      string
192
+     */
193
+    public function column_subscription( $item ) {
194
+
195
+        $username = __( '(Missing User)', 'invoicing' );
196
+
197
+        $user = get_userdata( $item->get_customer_id() );
198
+        if ( $user ) {
199
+
200
+            $username = sprintf(
201
+                '<a href="user-edit.php?user_id=%s">%s</a>',
202
+                absint( $user->ID ),
203
+                ! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email )
204
+            );
205
+
206
+        }
207
+
208
+        // translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
209
+        $column_content = sprintf(
210
+            _x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
211
+            '<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
212
+            '<strong>' . esc_attr( $item->get_id() ) . '</strong>', '</a>',
213
+            $username
214
+        );
215
+
216
+        $row_actions = array();
217
+
218
+        // View subscription.
219
+        $view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ));
220
+        $row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
221
+
222
+        // View invoice.
223
+        $invoice = get_post( $item->get_parent_invoice_id() );
224
+
225
+        if ( ! empty( $invoice ) ) {
226
+            $view_url    = get_edit_post_link( $invoice );
227
+            $row_actions['invoice'] = '<a href="' . $view_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
228
+        }
229
+
230
+        $row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
231
+
232
+        return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
233
+    }
234
+
235
+    /**
236
+     * Renewal date column
237
+     *
238
+     * @param WPInv_Subscription $item
239
+     * @since       1.0.0
240
+     * @return      string
241
+     */
242
+    public function column_renewal_date( $item ) {
243
+
244
+        $expiration = $item->get_expiration();
245
+        if ( ! $item->is_active() || empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
246
+            return "&mdash;";
247
+        }
248
+
249
+        return date_i18n( /** @scrutinizer ignore-type */get_option( 'date_format' ), strtotime( $expiration ) );
250
+
251
+    }
252
+
253
+    /**
254
+     * Start date column
255
+     *
256
+     * @param WPInv_Subscription $item
257
+     * @since       1.0.0
258
+     * @return      string
259
+     */
260
+    public function column_start_date( $item ) {
261
+
262
+        $created = $item->get_date_created();
263
+        if ( empty( $created ) || '0000-00-00 00:00:00' == $created ) {
264
+            return "&mdash;";
265
+        }
266
+
267
+        return date_i18n( /** @scrutinizer ignore-type */get_option( 'date_format' ), strtotime( $created ) );
268
+
269
+    }
270
+
271
+    /**
272
+     * Amount column
273
+     *
274
+     * @param WPInv_Subscription $item
275
+     * @since       1.0.19
276
+     * @return      string
277
+     */
278
+    public function column_amount( $item ) {
279
+
280
+        $initial   = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_initial_amount() ) ), $item->get_parent_payment()->get_currency() );
281
+        $recurring = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_recurring_amount() ) ), $item->get_parent_payment()->get_currency() );
282
+        $period    = 1 == $item->get_frequency() ? getpaid_get_subscription_period_label( $item->get_period() ) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->get_period(),$item->get_frequency() );
283
+
284
+        if ( $item->has_trial_period() ) {
285
+
286
+            // translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
287
+            $amount = sprintf(
288
+                _x( '%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
289
+                $initial,
290
+                sanitize_text_field( $item->get_trial_period() ),
291
+                $recurring,
292
+                sanitize_text_field( strtolower( $period ) )
293
+            );
294
+
295
+        } else if ( $initial != $recurring ) {
296
+
297
+            // translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring perio
298
+            $amount = sprintf(
299
+                _x( 'Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing' ),
300
+                $initial,
301
+                $recurring,
302
+                sanitize_text_field( strtolower( $period ) )
303
+            );
304
+
305
+        } else {
306
+
307
+            // translators: $1: is the recurring amount, $2: is the recurring period
308
+            $amount = sprintf(
309
+                _x( '%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing' ),
310
+                $initial,
311
+                sanitize_text_field( strtolower( $period ) )
312
+            );
313
+
314
+        }
315
+
316
+        return "<span class='text-muted form-text mt-2 mb-2'>$amount</span>";
317
+    }
318
+
319
+    /**
320
+     * Billing Times column
321
+     *
322
+     * @param WPInv_Subscription $item
323
+     * @since       1.0.0
324
+     * @return      string
325
+     */
326
+    public function column_renewals( $item ) {
327
+        $max_bills = $item->get_bill_times();
328
+        return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
329
+    }
330
+
331
+    /**
332
+     * Product ID column
333
+     *
334
+     * @param WPInv_Subscription $item
335
+     * @since       1.0.0
336
+     * @return      string
337
+     */
338
+    public function column_item( $item ) {
339
+        $_item = get_post( $item->get_product_id() );
340
+
341
+        if ( ! empty( $_item ) ) {
342
+            $link = get_edit_post_link( $_item );
343
+            $link = esc_url( $link );
344
+            $name = esc_html( get_the_title( $_item ) );
345
+            return "<a href='$link'>$name</a>";
346
+        } else {
347
+            return sprintf( __( 'Item #%s', 'invoicing' ), $item->get_product_id() );
348
+        }
349
+
350
+    }
351
+
352
+    /**
353
+     * Retrieve the current page number
354
+     *
355
+     * @return      int
356
+     */
357
+    public function get_paged() {
358
+        return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
359
+    }
360
+
361
+    /**
362
+     * Setup the final data for the table
363
+     *
364
+     */
365
+    public function prepare_items() {
366
+
367
+        $columns  = $this->get_columns();
368
+        $hidden   = array();
369
+        $sortable = $this->get_sortable_columns();
370
+
371
+        $this->_column_headers = array( $columns, $hidden, $sortable );
372
+
373
+        $this->set_pagination_args(
374
+            array(
375
+            'total_items' => $this->current_total_count,
376
+            'per_page'    => $this->per_page,
377
+            'total_pages' => ceil( $this->current_total_count / $this->per_page )
378
+            )
379
+        );
380
+    }
381
+
382
+    /**
383
+     * Table columns
384
+     *
385
+     * @return array
386
+     */
387
+    public function get_columns(){
388
+        $columns = array(
389
+            'cb'                => '<input type="checkbox" />',
390
+            'subscription'      => __( 'Subscription', 'invoicing' ),
391
+            'start_date'        => __( 'Start Date', 'invoicing' ),
392
+            'renewal_date'      => __( 'Next Payment', 'invoicing' ),
393
+            'renewals'          => __( 'Renewals', 'invoicing' ),
394
+            'item'              => __( 'Item', 'invoicing' ),
395
+            'status'            => __( 'Status', 'invoicing' ),
396
+        );
397
+
398
+        return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
399
+    }
400
+
401
+    /**
402
+     * Sortable table columns.
403
+     *
404
+     * @return array
405
+     */
406
+    public function get_sortable_columns() {
407
+        $sortable = array(
408
+            'subscription' => array( 'id', true ),
409
+            'start_date'   => array( 'created', true ),
410
+            'renewal_date' => array( 'expiration', true ),
411
+            'renewals'     => array( 'bill_times', true ),
412
+            'item'         => array( 'product_id', true ),
413
+            'status'       => array( 'status', true ),
414
+        );
415
+
416
+        return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
417
+    }
418
+
419
+    /**
420
+     * Whether the table has items to display or not
421
+     *
422
+     * @return bool
423
+     */
424
+    public function has_items() {
425
+        return ! empty( $this->current_total_count );
426
+    }
427
+
428
+    /**
429
+     * Processes bulk actions.
430
+     *
431
+     */
432
+    public function process_bulk_action() {
433
+
434
+    }
435 435
 
436 436
 }
Please login to merge, or discard this patch.
Spacing   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -3,9 +3,9 @@  discard block
 block discarded – undo
3 3
  * Displays a list of all subscriptions rules
4 4
  */
5 5
 
6
-if ( ! defined( 'ABSPATH' ) ) exit;
6
+if (!defined('ABSPATH')) exit;
7 7
 
8
-if ( ! class_exists( 'WP_List_Table' ) ) {
8
+if (!class_exists('WP_List_Table')) {
9 9
 	include_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
10 10
 }
11 11
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 
79 79
 		$this->prepare_query();
80 80
 
81
-		$this->base_url = remove_query_arg( 'status' );
81
+		$this->base_url = remove_query_arg('status');
82 82
 
83 83
 	}
84 84
 
@@ -91,21 +91,21 @@  discard block
 block discarded – undo
91 91
 		$query = array(
92 92
 			'number'  => $this->per_page,
93 93
 			'paged'   => $this->get_paged(),
94
-			'status'  => ( isset( $_GET['status'] ) && array_key_exists( $_GET['status'], getpaid_get_subscription_statuses() ) ) ? $_GET['status'] : 'all',
95
-			'orderby' => ( isset( $_GET['orderby'] ) ) ? $_GET['orderby'] : 'id',
96
-			'order'   => ( isset( $_GET['order'] ) ) ? $_GET['order'] : 'DESC',
94
+			'status'  => (isset($_GET['status']) && array_key_exists($_GET['status'], getpaid_get_subscription_statuses())) ? $_GET['status'] : 'all',
95
+			'orderby' => (isset($_GET['orderby'])) ? $_GET['orderby'] : 'id',
96
+			'order'   => (isset($_GET['order'])) ? $_GET['order'] : 'DESC',
97 97
 		);
98 98
 
99 99
 		// Prepare class properties.
100
-		$this->query               = new GetPaid_Subscriptions_Query( $query );
100
+		$this->query               = new GetPaid_Subscriptions_Query($query);
101 101
 		$this->total_count         = $this->query->get_total();
102 102
 		$this->current_total_count = $this->query->get_total();
103 103
 		$this->items               = $this->query->get_results();
104
-		$this->status_counts       = getpaid_get_subscription_status_counts( $query );
104
+		$this->status_counts       = getpaid_get_subscription_status_counts($query);
105 105
 
106
-		if ( 'all' != $query['status'] ) {
107
-			unset( $query['status'] );
108
-			$this->total_count   = getpaid_get_subscriptions( $query, 'count' );
106
+		if ('all' != $query['status']) {
107
+			unset($query['status']);
108
+			$this->total_count = getpaid_get_subscriptions($query, 'count');
109 109
 		}
110 110
 
111 111
 	}
@@ -122,26 +122,26 @@  discard block
 block discarded – undo
122 122
 	 */
123 123
 	protected function get_views() {
124 124
 
125
-		$current  = isset( $_GET['status'] ) ? $_GET['status'] : 'all';
125
+		$current  = isset($_GET['status']) ? $_GET['status'] : 'all';
126 126
 		$views    = array(
127 127
 
128 128
 			'all' => sprintf(
129 129
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
130
-				esc_url( add_query_arg( 'status', false, $this->base_url ) ),
130
+				esc_url(add_query_arg('status', false, $this->base_url)),
131 131
 				$current === 'all' ? ' class="current"' : '',
132
-				__('All','invoicing' ),
132
+				__('All', 'invoicing'),
133 133
 				$this->total_count
134 134
 			)
135 135
 
136 136
 		);
137 137
 
138
-		foreach ( array_filter( $this->status_counts ) as $status => $count ) {
138
+		foreach (array_filter($this->status_counts) as $status => $count) {
139 139
 
140
-			$views[ $status ] = sprintf(
140
+			$views[$status] = sprintf(
141 141
 				'<a href="%s" %s>%s&nbsp;<span class="count">(%d)</span></a>',
142
-				esc_url( add_query_arg( 'status', urlencode( $status ), $this->base_url ) ),
142
+				esc_url(add_query_arg('status', urlencode($status), $this->base_url)),
143 143
 				$current === $status ? ' class="current"' : '',
144
-				sanitize_text_field( getpaid_get_subscription_status_label( $status ) ),
144
+				sanitize_text_field(getpaid_get_subscription_status_label($status)),
145 145
 				$count
146 146
 			);
147 147
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @since       1.0.0
159 159
 	 * @return      string
160 160
 	 */
161
-	public function column_default( $item, $column_name ) {
162
-		return apply_filters( "getpaid_subscriptions_table_column_$column_name", $item->$column_name );
161
+	public function column_default($item, $column_name) {
162
+		return apply_filters("getpaid_subscriptions_table_column_$column_name", $item->$column_name);
163 163
 	}
164 164
 
165 165
 	/**
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 	 * @param WPInv_Subscription $item
169 169
 	 * @return string
170 170
 	 */
171
-	public function column_cb( $item ) {
172
-		return sprintf( '<input type="checkbox" name="id[]" value="%s" />', esc_html( $item->get_id() ) );
171
+	public function column_cb($item) {
172
+		return sprintf('<input type="checkbox" name="id[]" value="%s" />', esc_html($item->get_id()));
173 173
 	}
174 174
 
175 175
 	/**
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 	 * @since       1.0.0
180 180
 	 * @return      string
181 181
 	 */
182
-	public function column_status( $item ) {
182
+	public function column_status($item) {
183 183
 		return $item->get_status_label_html();
184 184
 	}
185 185
 
@@ -190,46 +190,46 @@  discard block
 block discarded – undo
190 190
 	 * @since       1.0.0
191 191
 	 * @return      string
192 192
 	 */
193
-	public function column_subscription( $item ) {
193
+	public function column_subscription($item) {
194 194
 
195
-		$username = __( '(Missing User)', 'invoicing' );
195
+		$username = __('(Missing User)', 'invoicing');
196 196
 
197
-		$user = get_userdata( $item->get_customer_id() );
198
-		if ( $user ) {
197
+		$user = get_userdata($item->get_customer_id());
198
+		if ($user) {
199 199
 
200 200
 			$username = sprintf(
201 201
 				'<a href="user-edit.php?user_id=%s">%s</a>',
202
-				absint( $user->ID ),
203
-				! empty( $user->display_name ) ? sanitize_text_field( $user->display_name ) : sanitize_email( $user->user_email )
202
+				absint($user->ID),
203
+				!empty($user->display_name) ? sanitize_text_field($user->display_name) : sanitize_email($user->user_email)
204 204
 			);
205 205
 
206 206
 		}
207 207
 
208 208
 		// translators: $1: is opening link, $2: is subscription id number, $3: is closing link tag, $4: is user's name
209 209
 		$column_content = sprintf(
210
-			_x( '%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing' ),
211
-			'<a href="' . esc_url( admin_url( 'admin.php?page=wpinv-subscriptions&id=' . absint( $item->get_id() ) ) ) . '">',
212
-			'<strong>' . esc_attr( $item->get_id() ) . '</strong>', '</a>',
210
+			_x('%1$s#%2$s%3$s for %4$s', 'Subscription title on admin table. (e.g.: #211 for John Doe)', 'invoicing'),
211
+			'<a href="' . esc_url(admin_url('admin.php?page=wpinv-subscriptions&id=' . absint($item->get_id()))) . '">',
212
+			'<strong>' . esc_attr($item->get_id()) . '</strong>', '</a>',
213 213
 			$username
214 214
 		);
215 215
 
216 216
 		$row_actions = array();
217 217
 
218 218
 		// View subscription.
219
-		$view_url    = esc_url( add_query_arg( 'id', $item->get_id(), admin_url( 'admin.php?page=wpinv-subscriptions' ) ));
220
-		$row_actions['view'] = '<a href="' . $view_url . '">' . __( 'View Subscription', 'invoicing' ) . '</a>';
219
+		$view_url    = esc_url(add_query_arg('id', $item->get_id(), admin_url('admin.php?page=wpinv-subscriptions')));
220
+		$row_actions['view'] = '<a href="' . $view_url . '">' . __('View Subscription', 'invoicing') . '</a>';
221 221
 
222 222
 		// View invoice.
223
-		$invoice = get_post( $item->get_parent_invoice_id() );
223
+		$invoice = get_post($item->get_parent_invoice_id());
224 224
 
225
-		if ( ! empty( $invoice ) ) {
226
-			$view_url    = get_edit_post_link( $invoice );
227
-			$row_actions['invoice'] = '<a href="' . $view_url . '">' . __( 'View Invoice', 'invoicing' ) . '</a>';
225
+		if (!empty($invoice)) {
226
+			$view_url = get_edit_post_link($invoice);
227
+			$row_actions['invoice'] = '<a href="' . $view_url . '">' . __('View Invoice', 'invoicing') . '</a>';
228 228
 		}
229 229
 
230
-		$row_actions = $this->row_actions( apply_filters( 'getpaid_subscription_table_row_actions', $row_actions, $item ) );
230
+		$row_actions = $this->row_actions(apply_filters('getpaid_subscription_table_row_actions', $row_actions, $item));
231 231
 
232
-		return "<strong>$column_content</strong>" . $this->column_amount( $item ) . $row_actions;
232
+		return "<strong>$column_content</strong>" . $this->column_amount($item) . $row_actions;
233 233
 	}
234 234
 
235 235
 	/**
@@ -239,14 +239,14 @@  discard block
 block discarded – undo
239 239
 	 * @since       1.0.0
240 240
 	 * @return      string
241 241
 	 */
242
-	public function column_renewal_date( $item ) {
242
+	public function column_renewal_date($item) {
243 243
 
244 244
 		$expiration = $item->get_expiration();
245
-		if ( ! $item->is_active() || empty( $expiration ) || '0000-00-00 00:00:00' == $expiration ) {
245
+		if (!$item->is_active() || empty($expiration) || '0000-00-00 00:00:00' == $expiration) {
246 246
 			return "&mdash;";
247 247
 		}
248 248
 
249
-		return date_i18n( /** @scrutinizer ignore-type */get_option( 'date_format' ), strtotime( $expiration ) );
249
+		return date_i18n(/** @scrutinizer ignore-type */get_option('date_format'), strtotime($expiration));
250 250
 
251 251
 	}
252 252
 
@@ -257,14 +257,14 @@  discard block
 block discarded – undo
257 257
 	 * @since       1.0.0
258 258
 	 * @return      string
259 259
 	 */
260
-	public function column_start_date( $item ) {
260
+	public function column_start_date($item) {
261 261
 
262 262
 		$created = $item->get_date_created();
263
-		if ( empty( $created ) || '0000-00-00 00:00:00' == $created ) {
263
+		if (empty($created) || '0000-00-00 00:00:00' == $created) {
264 264
 			return "&mdash;";
265 265
 		}
266 266
 
267
-		return date_i18n( /** @scrutinizer ignore-type */get_option( 'date_format' ), strtotime( $created ) );
267
+		return date_i18n(/** @scrutinizer ignore-type */get_option('date_format'), strtotime($created));
268 268
 
269 269
 	}
270 270
 
@@ -275,40 +275,40 @@  discard block
 block discarded – undo
275 275
 	 * @since       1.0.19
276 276
 	 * @return      string
277 277
 	 */
278
-	public function column_amount( $item ) {
278
+	public function column_amount($item) {
279 279
 
280
-		$initial   = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_initial_amount() ) ), $item->get_parent_payment()->get_currency() );
281
-		$recurring = wpinv_price( wpinv_format_amount( wpinv_sanitize_amount( $item->get_recurring_amount() ) ), $item->get_parent_payment()->get_currency() );
282
-		$period    = 1 == $item->get_frequency() ? getpaid_get_subscription_period_label( $item->get_period() ) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency( $item->get_period(),$item->get_frequency() );
280
+		$initial   = wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($item->get_initial_amount())), $item->get_parent_payment()->get_currency());
281
+		$recurring = wpinv_price(wpinv_format_amount(wpinv_sanitize_amount($item->get_recurring_amount())), $item->get_parent_payment()->get_currency());
282
+		$period    = 1 == $item->get_frequency() ? getpaid_get_subscription_period_label($item->get_period()) : WPInv_Subscriptions::wpinv_get_pretty_subscription_frequency($item->get_period(), $item->get_frequency());
283 283
 
284
-		if ( $item->has_trial_period() ) {
284
+		if ($item->has_trial_period()) {
285 285
 
286 286
 			// translators: $1: is the initial amount, $2: is the trial period, $3: is the recurring amount, $4: is the recurring period
287 287
 			$amount = sprintf(
288
-				_x( '%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing' ),
288
+				_x('%1$s trial for %2$s(s) then %3$s / %4$s', 'Subscription amount on admin table. (e.g.: $10 trial for 1 month then $120 / year)', 'invoicing'),
289 289
 				$initial,
290
-				sanitize_text_field( $item->get_trial_period() ),
290
+				sanitize_text_field($item->get_trial_period()),
291 291
 				$recurring,
292
-				sanitize_text_field( strtolower( $period ) )
292
+				sanitize_text_field(strtolower($period))
293 293
 			);
294 294
 
295
-		} else if ( $initial != $recurring ) {
295
+		} else if ($initial != $recurring) {
296 296
 
297 297
 			// translators: $1: is the initial amount, $2: is the recurring amount, $3: is the recurring perio
298 298
 			$amount = sprintf(
299
-				_x( 'Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing' ),
299
+				_x('Initial payment of %1$s then %2$s / %3$s', 'Subscription amount on admin table. (e.g.:Initial payment of $100 then $120 / year)', 'invoicing'),
300 300
 				$initial,
301 301
 				$recurring,
302
-				sanitize_text_field( strtolower( $period ) )
302
+				sanitize_text_field(strtolower($period))
303 303
 			);
304 304
 
305 305
 		} else {
306 306
 
307 307
 			// translators: $1: is the recurring amount, $2: is the recurring period
308 308
 			$amount = sprintf(
309
-				_x( '%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing' ),
309
+				_x('%1$s / %2$s', 'Subscription amount on admin table. (e.g.: $120 / year)', 'invoicing'),
310 310
 				$initial,
311
-				sanitize_text_field( strtolower( $period ) )
311
+				sanitize_text_field(strtolower($period))
312 312
 			);
313 313
 
314 314
 		}
@@ -323,9 +323,9 @@  discard block
 block discarded – undo
323 323
 	 * @since       1.0.0
324 324
 	 * @return      string
325 325
 	 */
326
-	public function column_renewals( $item ) {
326
+	public function column_renewals($item) {
327 327
 		$max_bills = $item->get_bill_times();
328
-		return $item->get_times_billed() . ' / ' . ( empty( $max_bills ) ? "&infin;" : $max_bills );
328
+		return $item->get_times_billed() . ' / ' . (empty($max_bills) ? "&infin;" : $max_bills);
329 329
 	}
330 330
 
331 331
 	/**
@@ -335,16 +335,16 @@  discard block
 block discarded – undo
335 335
 	 * @since       1.0.0
336 336
 	 * @return      string
337 337
 	 */
338
-	public function column_item( $item ) {
339
-		$_item = get_post( $item->get_product_id() );
338
+	public function column_item($item) {
339
+		$_item = get_post($item->get_product_id());
340 340
 
341
-		if ( ! empty( $_item ) ) {
342
-			$link = get_edit_post_link( $_item );
343
-			$link = esc_url( $link );
344
-			$name = esc_html( get_the_title( $_item ) );
341
+		if (!empty($_item)) {
342
+			$link = get_edit_post_link($_item);
343
+			$link = esc_url($link);
344
+			$name = esc_html(get_the_title($_item));
345 345
 			return "<a href='$link'>$name</a>";
346 346
 		} else {
347
-			return sprintf( __( 'Item #%s', 'invoicing' ), $item->get_product_id() );
347
+			return sprintf(__('Item #%s', 'invoicing'), $item->get_product_id());
348 348
 		}
349 349
 
350 350
 	}
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	 * @return      int
356 356
 	 */
357 357
 	public function get_paged() {
358
-		return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
358
+		return isset($_GET['paged']) ? absint($_GET['paged']) : 1;
359 359
 	}
360 360
 
361 361
 	/**
@@ -368,13 +368,13 @@  discard block
 block discarded – undo
368 368
 		$hidden   = array();
369 369
 		$sortable = $this->get_sortable_columns();
370 370
 
371
-		$this->_column_headers = array( $columns, $hidden, $sortable );
371
+		$this->_column_headers = array($columns, $hidden, $sortable);
372 372
 
373 373
 		$this->set_pagination_args(
374 374
 			array(
375 375
 			'total_items' => $this->current_total_count,
376 376
 			'per_page'    => $this->per_page,
377
-			'total_pages' => ceil( $this->current_total_count / $this->per_page )
377
+			'total_pages' => ceil($this->current_total_count / $this->per_page)
378 378
 			)
379 379
 		);
380 380
 	}
@@ -384,18 +384,18 @@  discard block
 block discarded – undo
384 384
 	 *
385 385
 	 * @return array
386 386
 	 */
387
-	public function get_columns(){
387
+	public function get_columns() {
388 388
 		$columns = array(
389 389
 			'cb'                => '<input type="checkbox" />',
390
-			'subscription'      => __( 'Subscription', 'invoicing' ),
391
-			'start_date'        => __( 'Start Date', 'invoicing' ),
392
-			'renewal_date'      => __( 'Next Payment', 'invoicing' ),
393
-			'renewals'          => __( 'Renewals', 'invoicing' ),
394
-			'item'              => __( 'Item', 'invoicing' ),
395
-			'status'            => __( 'Status', 'invoicing' ),
390
+			'subscription'      => __('Subscription', 'invoicing'),
391
+			'start_date'        => __('Start Date', 'invoicing'),
392
+			'renewal_date'      => __('Next Payment', 'invoicing'),
393
+			'renewals'          => __('Renewals', 'invoicing'),
394
+			'item'              => __('Item', 'invoicing'),
395
+			'status'            => __('Status', 'invoicing'),
396 396
 		);
397 397
 
398
-		return apply_filters( 'manage_getpaid_subscriptions_table_columns', $columns );
398
+		return apply_filters('manage_getpaid_subscriptions_table_columns', $columns);
399 399
 	}
400 400
 
401 401
 	/**
@@ -405,15 +405,15 @@  discard block
 block discarded – undo
405 405
 	 */
406 406
 	public function get_sortable_columns() {
407 407
 		$sortable = array(
408
-			'subscription' => array( 'id', true ),
409
-			'start_date'   => array( 'created', true ),
410
-			'renewal_date' => array( 'expiration', true ),
411
-			'renewals'     => array( 'bill_times', true ),
412
-			'item'         => array( 'product_id', true ),
413
-			'status'       => array( 'status', true ),
408
+			'subscription' => array('id', true),
409
+			'start_date'   => array('created', true),
410
+			'renewal_date' => array('expiration', true),
411
+			'renewals'     => array('bill_times', true),
412
+			'item'         => array('product_id', true),
413
+			'status'       => array('status', true),
414 414
 		);
415 415
 
416
-		return apply_filters( 'manage_getpaid_subscriptions_sortable_table_columns', $sortable );
416
+		return apply_filters('manage_getpaid_subscriptions_sortable_table_columns', $sortable);
417 417
 	}
418 418
 
419 419
 	/**
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 * @return bool
423 423
 	 */
424 424
 	public function has_items() {
425
-		return ! empty( $this->current_total_count );
425
+		return !empty($this->current_total_count);
426 426
 	}
427 427
 
428 428
 	/**
Please login to merge, or discard this patch.
includes/class-wpinv-subscriptions.php 1 patch
Spacing   +87 added lines, -87 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
  * Main Subscriptions class.
10 10
  *
@@ -14,22 +14,22 @@  discard block
 block discarded – undo
14 14
     /**
15 15
 	 * Class constructor.
16 16
 	 */
17
-    public function __construct(){
17
+    public function __construct() {
18 18
 
19 19
         // Fire gateway specific hooks when a subscription changes.
20
-        add_action( 'getpaid_subscription_status_changed', array( $this, 'process_subscription_status_change' ), 10, 3 );
20
+        add_action('getpaid_subscription_status_changed', array($this, 'process_subscription_status_change'), 10, 3);
21 21
 
22 22
         // Handles subscription cancelations.
23
-        add_action( 'getpaid_authenticated_action_subscription_cancel', array( $this, 'user_cancel_single_subscription' ) );
23
+        add_action('getpaid_authenticated_action_subscription_cancel', array($this, 'user_cancel_single_subscription'));
24 24
 
25 25
         // Create a subscription whenever an invoice is created, (and update it when it is updated).
26
-        add_action( 'getpaid_new_invoice', array( $this, 'maybe_create_invoice_subscription' ) );
27
-        add_action( 'getpaid_update_invoice', array( $this, 'maybe_update_invoice_subscription' ) );
26
+        add_action('getpaid_new_invoice', array($this, 'maybe_create_invoice_subscription'));
27
+        add_action('getpaid_update_invoice', array($this, 'maybe_update_invoice_subscription'));
28 28
 
29 29
         // Handles admin subscription update actions.
30
-        add_action( 'getpaid_authenticated_admin_action_update_single_subscription', array( $this, 'admin_update_single_subscription' ) );
31
-        add_action( 'getpaid_authenticated_admin_action_subscription_manual_renew', array( $this, 'admin_renew_single_subscription' ) );
32
-        add_action( 'getpaid_authenticated_admin_action_subscription_manual_delete', array( $this, 'admin_delete_single_subscription' ) );
30
+        add_action('getpaid_authenticated_admin_action_update_single_subscription', array($this, 'admin_update_single_subscription'));
31
+        add_action('getpaid_authenticated_admin_action_subscription_manual_renew', array($this, 'admin_renew_single_subscription'));
32
+        add_action('getpaid_authenticated_admin_action_subscription_manual_delete', array($this, 'admin_delete_single_subscription'));
33 33
     }
34 34
 
35 35
     /**
@@ -39,15 +39,15 @@  discard block
 block discarded – undo
39 39
      * @param string $from
40 40
      * @param string $to
41 41
 	 */
42
-    public function process_subscription_status_change( $subscription, $from, $to ) {
42
+    public function process_subscription_status_change($subscription, $from, $to) {
43 43
 
44 44
         $gateway = $subscription->get_gateway();
45 45
 
46
-        if ( ! empty( $gateway ) ) {
47
-            $gateway = sanitize_key( $gateway );
48
-            $from    = sanitize_key( $from );
49
-            $to      = sanitize_key( $to );
50
-            do_action( "getpaid_{$gateway}subscription_$to", $subscription, $from );
46
+        if (!empty($gateway)) {
47
+            $gateway = sanitize_key($gateway);
48
+            $from    = sanitize_key($from);
49
+            $to      = sanitize_key($to);
50
+            do_action("getpaid_{$gateway}subscription_$to", $subscription, $from);
51 51
         }
52 52
 
53 53
     }
@@ -59,29 +59,29 @@  discard block
 block discarded – undo
59 59
      * @param int $frequency_count The frequency of the period.
60 60
      * @return mixed|string|void
61 61
      */
62
-    public static function wpinv_get_pretty_subscription_frequency( $period, $frequency_count = 1) {
62
+    public static function wpinv_get_pretty_subscription_frequency($period, $frequency_count = 1) {
63 63
 
64 64
         $frequency = '';
65 65
         //Format period details
66
-        switch ( strtolower( $period ) ) {
66
+        switch (strtolower($period)) {
67 67
             case 'day' :
68 68
             case 'd' :
69
-                $frequency = sprintf( _n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count);
69
+                $frequency = sprintf(_n('%d Day', '%d Days', $frequency_count, 'invoicing'), $frequency_count);
70 70
                 break;
71 71
             case 'week' :
72 72
             case 'w' :
73
-                $frequency = sprintf( _n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count);
73
+                $frequency = sprintf(_n('%d Week', '%d Weeks', $frequency_count, 'invoicing'), $frequency_count);
74 74
                 break;
75 75
             case 'month' :
76 76
             case 'm' :
77
-                $frequency = sprintf( _n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count);
77
+                $frequency = sprintf(_n('%d Month', '%d Months', $frequency_count, 'invoicing'), $frequency_count);
78 78
                 break;
79 79
             case 'year' :
80 80
             case 'y' :
81
-                $frequency = sprintf( _n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count);
81
+                $frequency = sprintf(_n('%d Year', '%d Years', $frequency_count, 'invoicing'), $frequency_count);
82 82
                 break;
83 83
             default :
84
-                $frequency = apply_filters( 'wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count );
84
+                $frequency = apply_filters('wpinv_recurring_subscription_frequency', $frequency, $period, $frequency_count);
85 85
                 break;
86 86
         }
87 87
 
@@ -96,29 +96,29 @@  discard block
 block discarded – undo
96 96
      * @since       1.0.0
97 97
      * @return      void
98 98
      */
99
-    public function user_cancel_single_subscription( $data ) {
99
+    public function user_cancel_single_subscription($data) {
100 100
 
101 101
         // Ensure there is a subscription to cancel.
102
-        if ( empty( $data['sub_id'] ) ) {
102
+        if (empty($data['sub_id'])) {
103 103
             return;
104 104
         }
105 105
 
106
-        $subscription = new WPInv_Subscription( (int) $data['sub_id'] );
106
+        $subscription = new WPInv_Subscription((int) $data['sub_id']);
107 107
 
108 108
         // Ensure that it exists and that it belongs to the current user.
109
-        if ( ! $subscription->get_id() || $subscription->get_customer_id() != get_current_user_id() ) {
110
-            wpinv_set_error( 'invalid_subscription', __( 'You do not have permission to cancel this subscription', 'invoicing' ) );
109
+        if (!$subscription->get_id() || $subscription->get_customer_id() != get_current_user_id()) {
110
+            wpinv_set_error('invalid_subscription', __('You do not have permission to cancel this subscription', 'invoicing'));
111 111
 
112 112
         // Can it be cancelled.
113
-        } else if ( ! $subscription->can_cancel() ) {
114
-            wpinv_set_error( 'cannot_cancel', __( 'This subscription cannot be cancelled as it is not active.', 'invoicing' ) );
113
+        } else if (!$subscription->can_cancel()) {
114
+            wpinv_set_error('cannot_cancel', __('This subscription cannot be cancelled as it is not active.', 'invoicing'));
115 115
             
116 116
 
117 117
         // Cancel it.
118 118
         } else {
119 119
 
120 120
             $subscription->cancel();
121
-            wpinv_set_error( 'cancelled', __( 'This subscription is now cancelled.', 'invoicing' ), 'info' );
121
+            wpinv_set_error('cancelled', __('This subscription is now cancelled.', 'invoicing'), 'info');
122 122
         }
123 123
 
124 124
 
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
             )
131 131
         );
132 132
 
133
-        wp_safe_redirect( esc_url( $redirect ) );
133
+        wp_safe_redirect(esc_url($redirect));
134 134
         exit;
135 135
 
136 136
     }
@@ -142,15 +142,15 @@  discard block
 block discarded – undo
142 142
      * @param       WPInv_Invoice $invoice
143 143
      * @since       1.0.0
144 144
      */
145
-    public function maybe_create_invoice_subscription( $invoice ) {
145
+    public function maybe_create_invoice_subscription($invoice) {
146 146
 
147 147
         // Abort if it is not recurring.
148
-        if ( $invoice->is_free() || ! $invoice->is_recurring() || $invoice->is_renewal() ) {
148
+        if ($invoice->is_free() || !$invoice->is_recurring() || $invoice->is_renewal()) {
149 149
             return;
150 150
         }
151 151
 
152 152
         $subscription = new WPInv_Subscription();
153
-        return $this->update_invoice_subscription( $subscription, $invoice );
153
+        return $this->update_invoice_subscription($subscription, $invoice);
154 154
 
155 155
     }
156 156
 
@@ -161,33 +161,33 @@  discard block
 block discarded – undo
161 161
      * @param       WPInv_Invoice $invoice
162 162
      * @since       1.0.19
163 163
      */
164
-    public function maybe_update_invoice_subscription( $invoice ) {
164
+    public function maybe_update_invoice_subscription($invoice) {
165 165
 
166 166
         // Do not process renewals.
167
-        if ( $invoice->is_renewal() ) {
167
+        if ($invoice->is_renewal()) {
168 168
             return;
169 169
         }
170 170
 
171 171
         // (Maybe) create a new subscription.
172
-        if ( ! $invoice->get_subscription_id() ) {
173
-            return $this->maybe_create_invoice_subscription( $invoice );
172
+        if (!$invoice->get_subscription_id()) {
173
+            return $this->maybe_create_invoice_subscription($invoice);
174 174
         }
175 175
 
176
-        $subscription = new WPInv_Subscription( $invoice->get_subscription_id() );
176
+        $subscription = new WPInv_Subscription($invoice->get_subscription_id());
177 177
 
178 178
         // In case the subscription was deleted...
179
-        if ( ! $subscription->get_id() ) {
179
+        if (!$subscription->get_id()) {
180 180
             $invoice->set_subscription_id(0);
181 181
             $invoice->save();
182
-            return $this->maybe_create_invoice_subscription( $invoice );
182
+            return $this->maybe_create_invoice_subscription($invoice);
183 183
         }
184 184
 
185 185
         // Abort if an invoice is paid and already has a subscription.
186
-        if ( $invoice->is_paid() || $invoice->is_refunded() ) {
186
+        if ($invoice->is_paid() || $invoice->is_refunded()) {
187 187
             return;
188 188
         }
189 189
 
190
-        return $this->update_invoice_subscription( $subscription, $invoice );
190
+        return $this->update_invoice_subscription($subscription, $invoice);
191 191
 
192 192
     }
193 193
 
@@ -199,53 +199,53 @@  discard block
 block discarded – undo
199 199
      * @param       WPInv_Invoice $invoice
200 200
      * @since       1.0.19
201 201
      */
202
-    public function update_invoice_subscription( $subscription, $invoice ) {
202
+    public function update_invoice_subscription($subscription, $invoice) {
203 203
 
204 204
         // Delete the subscription if an invoice is free.
205
-        if ( $invoice->is_free() || ! $invoice->is_recurring() ) {
205
+        if ($invoice->is_free() || !$invoice->is_recurring()) {
206 206
             return $subscription->delete();
207 207
         }
208 208
 
209
-        $subscription->set_customer_id( $invoice->get_customer_id() );
210
-        $subscription->set_parent_invoice_id( $invoice->get_id() );
211
-        $subscription->set_initial_amount( $invoice->get_initial_total() );
212
-        $subscription->set_recurring_amount( $invoice->get_recurring_total() );
213
-        $subscription->set_date_created( current_time( 'mysql' ) );
214
-        $subscription->set_status( $invoice->is_paid() ? 'active' : 'pending' );
209
+        $subscription->set_customer_id($invoice->get_customer_id());
210
+        $subscription->set_parent_invoice_id($invoice->get_id());
211
+        $subscription->set_initial_amount($invoice->get_initial_total());
212
+        $subscription->set_recurring_amount($invoice->get_recurring_total());
213
+        $subscription->set_date_created(current_time('mysql'));
214
+        $subscription->set_status($invoice->is_paid() ? 'active' : 'pending');
215 215
 
216 216
         // Get the recurring item and abort if it does not exist.
217
-        $subscription_item = $invoice->get_recurring( true );
218
-        if ( ! $subscription_item->get_id() ) {
217
+        $subscription_item = $invoice->get_recurring(true);
218
+        if (!$subscription_item->get_id()) {
219 219
             return $subscription->delete();
220 220
         }
221 221
 
222
-        $subscription->set_product_id( $subscription_item->get_id() );
223
-        $subscription->set_period( $subscription_item->get_recurring_period( true ) );
224
-        $subscription->set_frequency( $subscription_item->get_recurring_interval() );
225
-        $subscription->set_bill_times( $subscription_item->get_recurring_limit() );
222
+        $subscription->set_product_id($subscription_item->get_id());
223
+        $subscription->set_period($subscription_item->get_recurring_period(true));
224
+        $subscription->set_frequency($subscription_item->get_recurring_interval());
225
+        $subscription->set_bill_times($subscription_item->get_recurring_limit());
226 226
 
227 227
         // Calculate the next renewal date.
228
-        $period       = $subscription_item->get_recurring_period( true );
228
+        $period       = $subscription_item->get_recurring_period(true);
229 229
         $interval     = $subscription_item->get_recurring_interval();
230 230
 
231 231
         // If the subscription item has a trial period...
232
-        if ( $subscription_item->has_free_trial() ) {
233
-            $period   = $subscription_item->get_trial_period( true );
232
+        if ($subscription_item->has_free_trial()) {
233
+            $period   = $subscription_item->get_trial_period(true);
234 234
             $interval = $subscription_item->get_trial_interval();
235
-            $subscription->set_trial_period( $interval . ' ' . $period );
236
-            $subscription->set_status( 'trialling' );
235
+            $subscription->set_trial_period($interval . ' ' . $period);
236
+            $subscription->set_status('trialling');
237 237
         }
238 238
 
239 239
         // If initial amount is free, treat it as a free trial even if the subscription item does not have a free trial.
240
-        if ( $invoice->has_free_trial() ) {
241
-            $subscription->set_trial_period( $interval . ' ' . $period );
242
-            $subscription->set_status( 'trialling' );
240
+        if ($invoice->has_free_trial()) {
241
+            $subscription->set_trial_period($interval . ' ' . $period);
242
+            $subscription->set_status('trialling');
243 243
         }
244 244
 
245 245
         // Calculate the next renewal date.
246
-        $expiration = date( 'Y-m-d H:i:s', strtotime( "+ $interval $period", strtotime( $subscription->get_date_created() ) ) );
246
+        $expiration = date('Y-m-d H:i:s', strtotime("+ $interval $period", strtotime($subscription->get_date_created())));
247 247
 
248
-        $subscription->set_next_renewal_date( $expiration );
248
+        $subscription->set_next_renewal_date($expiration);
249 249
         return $subscription->save();
250 250
 
251 251
     }
@@ -256,21 +256,21 @@  discard block
 block discarded – undo
256 256
      * @param       array $data
257 257
      * @since       1.0.19
258 258
      */
259
-    public function admin_update_single_subscription( $args ) {
259
+    public function admin_update_single_subscription($args) {
260 260
 
261 261
         // Ensure the subscription exists and that a status has been given.
262
-        if ( empty( $args['subscription_id'] ) || empty( $args['subscription_status'] ) ) {
262
+        if (empty($args['subscription_id']) || empty($args['subscription_status'])) {
263 263
             return;
264 264
         }
265 265
 
266 266
         // Retrieve the subscriptions.
267
-        $subscription = new WPInv_Subscription( $args['subscription_id'] );
267
+        $subscription = new WPInv_Subscription($args['subscription_id']);
268 268
 
269
-        if ( $subscription->get_id() ) {
269
+        if ($subscription->get_id()) {
270 270
 
271
-            $subscription->set_status( $args['subscription_status'] );
271
+            $subscription->set_status($args['subscription_status']);
272 272
             $subscription->save();
273
-            getpaid_admin()->show_info( __( 'Your changes have been saved', 'invoicing' ) );
273
+            getpaid_admin()->show_info(__('Your changes have been saved', 'invoicing'));
274 274
 
275 275
         }
276 276
 
@@ -282,25 +282,25 @@  discard block
 block discarded – undo
282 282
      * @param       array $data
283 283
      * @since       1.0.19
284 284
      */
285
-    public function admin_renew_single_subscription( $args ) {
285
+    public function admin_renew_single_subscription($args) {
286 286
 
287 287
         // Ensure the subscription exists and that a status has been given.
288
-        if ( empty( $args['id'] ) ) {
288
+        if (empty($args['id'])) {
289 289
             return;
290 290
         }
291 291
 
292 292
         // Retrieve the subscriptions.
293
-        $subscription = new WPInv_Subscription( $args['id'] );
293
+        $subscription = new WPInv_Subscription($args['id']);
294 294
 
295
-        if ( $subscription->get_id() ) {
295
+        if ($subscription->get_id()) {
296 296
 
297
-            $args = array( 'transaction_id', $subscription->get_parent_invoice()->generate_key( 'renewal_' ) );
297
+            $args = array('transaction_id', $subscription->get_parent_invoice()->generate_key('renewal_'));
298 298
 
299
-            if ( $subscription->add_payment( $args ) ) {
299
+            if ($subscription->add_payment($args)) {
300 300
                 $subscription->renew();
301
-                getpaid_admin()->show_info( __( 'This subscription has been renewed and extended.', 'invoicing' ) );
301
+                getpaid_admin()->show_info(__('This subscription has been renewed and extended.', 'invoicing'));
302 302
             } else {
303
-                getpaid_admin()->show_error( __( 'We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing' ) );
303
+                getpaid_admin()->show_error(__('We are unable to renew this subscription as the parent invoice does not exist.', 'invoicing'));
304 304
             }
305 305
     
306 306
             wp_safe_redirect(
@@ -323,20 +323,20 @@  discard block
 block discarded – undo
323 323
      * @param       array $data
324 324
      * @since       1.0.19
325 325
      */
326
-    public function admin_delete_single_subscription( $args ) {
326
+    public function admin_delete_single_subscription($args) {
327 327
 
328 328
         // Ensure the subscription exists and that a status has been given.
329
-        if ( empty( $args['id'] ) ) {
329
+        if (empty($args['id'])) {
330 330
             return;
331 331
         }
332 332
 
333 333
         // Retrieve the subscriptions.
334
-        $subscription = new WPInv_Subscription( $args['id'] );
334
+        $subscription = new WPInv_Subscription($args['id']);
335 335
 
336
-        if ( $subscription->delete() ) {
337
-            getpaid_admin()->show_info( __( 'This subscription has been deleted.', 'invoicing' ) );
336
+        if ($subscription->delete()) {
337
+            getpaid_admin()->show_info(__('This subscription has been deleted.', 'invoicing'));
338 338
         } else {
339
-            getpaid_admin()->show_error( __( 'We are unable to delete this subscription. Please try again.', 'invoicing' ) );
339
+            getpaid_admin()->show_error(__('We are unable to delete this subscription. Please try again.', 'invoicing'));
340 340
         }
341 341
     
342 342
         wp_safe_redirect(
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 2 patches
Indentation   +2286 added lines, -2286 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'            => 0,
38
-		'status'               => 'wpi-pending',
39
-		'version'              => '',
40
-		'date_created'         => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'            => 0,
38
+        'status'               => 'wpi-pending',
39
+        'version'              => '',
40
+        'date_created'         => null,
41 41
         'date_modified'        => null,
42 42
         'due_date'             => null,
43 43
         'completed_date'       => null,
@@ -79,21 +79,21 @@  discard block
 block discarded – undo
79 79
         'transaction_id'       => '',
80 80
         'currency'             => '',
81 81
         'disable_taxes'        => false,
82
-		'subscription_id'      => null,
83
-		'remote_subscription_id' => null,
84
-		'is_viewed'            => false,
85
-		'email_cc'             => '',
86
-		'template'             => 'quantity', // hours, amount only
82
+        'subscription_id'      => null,
83
+        'remote_subscription_id' => null,
84
+        'is_viewed'            => false,
85
+        'email_cc'             => '',
86
+        'template'             => 'quantity', // hours, amount only
87 87
     );
88 88
 
89 89
     /**
90
-	 * Stores meta in cache for future reads.
91
-	 *
92
-	 * A group must be set to to enable caching.
93
-	 *
94
-	 * @var string
95
-	 */
96
-	protected $cache_group = 'getpaid_invoices';
90
+     * Stores meta in cache for future reads.
91
+     *
92
+     * A group must be set to to enable caching.
93
+     *
94
+     * @var string
95
+     */
96
+    protected $cache_group = 'getpaid_invoices';
97 97
 
98 98
     /**
99 99
      * Stores a reference to the original WP_Post object
@@ -107,104 +107,104 @@  discard block
 block discarded – undo
107 107
      *
108 108
      * @var int
109 109
      */
110
-	protected $recurring_item = null;
110
+    protected $recurring_item = null;
111 111
 
112
-	/**
112
+    /**
113 113
      * Stores an array of item totals.
114
-	 *
115
-	 * e.g $totals['discount'] = array(
116
-	 * 		'initial'   => 10,
117
-	 * 		'recurring' => 10,
118
-	 * )
114
+     *
115
+     * e.g $totals['discount'] = array(
116
+     * 		'initial'   => 10,
117
+     * 		'recurring' => 10,
118
+     * )
119 119
      *
120 120
      * @var array
121 121
      */
122
-	protected $totals = array();
122
+    protected $totals = array();
123 123
 
124
-	/**
125
-	 * Stores the status transition information.
126
-	 *
127
-	 * @since 1.0.19
128
-	 * @var bool
129
-	 */
130
-	protected $status_transition = false;
124
+    /**
125
+     * Stores the status transition information.
126
+     *
127
+     * @since 1.0.19
128
+     * @var bool
129
+     */
130
+    protected $status_transition = false;
131 131
 
132 132
     /**
133
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
134
-	 *
135
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
136
-	 */
133
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
134
+     *
135
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
136
+     */
137 137
     public function __construct( $invoice = false ) {
138 138
 
139 139
         parent::__construct( $invoice );
140 140
 
141
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
142
-			$this->set_id( $invoice );
143
-		} elseif ( $invoice instanceof self ) {
144
-			$this->set_id( $invoice->get_id() );
145
-		} elseif ( ! empty( $invoice->ID ) ) {
146
-			$this->set_id( $invoice->ID );
147
-		} elseif ( is_array( $invoice ) ) {
148
-			$this->set_props( $invoice );
149
-
150
-			if ( isset( $invoice['ID'] ) ) {
151
-				$this->set_id( $invoice['ID'] );
152
-			}
153
-
154
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
155
-			$this->set_id( $invoice_id );
156
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
157
-			$this->set_id( $invoice_id );
158
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
159
-			$this->set_id( $invoice_id );
160
-		}else {
161
-			$this->set_object_read( true );
162
-		}
141
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
142
+            $this->set_id( $invoice );
143
+        } elseif ( $invoice instanceof self ) {
144
+            $this->set_id( $invoice->get_id() );
145
+        } elseif ( ! empty( $invoice->ID ) ) {
146
+            $this->set_id( $invoice->ID );
147
+        } elseif ( is_array( $invoice ) ) {
148
+            $this->set_props( $invoice );
149
+
150
+            if ( isset( $invoice['ID'] ) ) {
151
+                $this->set_id( $invoice['ID'] );
152
+            }
153
+
154
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
155
+            $this->set_id( $invoice_id );
156
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
157
+            $this->set_id( $invoice_id );
158
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
159
+            $this->set_id( $invoice_id );
160
+        }else {
161
+            $this->set_object_read( true );
162
+        }
163 163
 
164 164
         // Load the datastore.
165
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
165
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
166 166
 
167
-		if ( $this->get_id() > 0 ) {
167
+        if ( $this->get_id() > 0 ) {
168 168
             $this->post = get_post( $this->get_id() );
169 169
             $this->ID   = $this->get_id();
170
-			$this->data_store->read( $this );
170
+            $this->data_store->read( $this );
171 171
         }
172 172
 
173 173
     }
174 174
 
175 175
     /**
176
-	 * Given an invoice key/number, it returns its id.
177
-	 *
178
-	 *
179
-	 * @static
180
-	 * @param string $value The invoice key or number
181
-	 * @param string $field Either key, transaction_id or number.
182
-	 * @since 1.0.15
183
-	 * @return int
184
-	 */
185
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
176
+     * Given an invoice key/number, it returns its id.
177
+     *
178
+     *
179
+     * @static
180
+     * @param string $value The invoice key or number
181
+     * @param string $field Either key, transaction_id or number.
182
+     * @since 1.0.15
183
+     * @return int
184
+     */
185
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
186 186
         global $wpdb;
187 187
 
188
-		// Trim the value.
189
-		$value = trim( $value );
188
+        // Trim the value.
189
+        $value = trim( $value );
190 190
 
191
-		if ( empty( $value ) ) {
192
-			return 0;
193
-		}
191
+        if ( empty( $value ) ) {
192
+            return 0;
193
+        }
194 194
 
195 195
         // Valid fields.
196 196
         $fields = array( 'key', 'number', 'transaction_id' );
197 197
 
198
-		// Ensure a field has been passed.
199
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
200
-			return 0;
201
-		}
198
+        // Ensure a field has been passed.
199
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
200
+            return 0;
201
+        }
202 202
 
203
-		// Maybe retrieve from the cache.
204
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
205
-		if ( false !== $invoice_id ) {
206
-			return $invoice_id;
207
-		}
203
+        // Maybe retrieve from the cache.
204
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
205
+        if ( false !== $invoice_id ) {
206
+            return $invoice_id;
207
+        }
208 208
 
209 209
         // Fetch from the db.
210 210
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
213 213
         );
214 214
 
215
-		// Update the cache with our data
216
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
215
+        // Update the cache with our data
216
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
217 217
 
218
-		return $invoice_id;
218
+        return $invoice_id;
219 219
     }
220 220
 
221 221
     /**
@@ -241,80 +241,80 @@  discard block
 block discarded – undo
241 241
     */
242 242
 
243 243
     /**
244
-	 * Get parent invoice ID.
245
-	 *
246
-	 * @since 1.0.19
247
-	 * @param  string $context View or edit context.
248
-	 * @return int
249
-	 */
250
-	public function get_parent_id( $context = 'view' ) {
251
-		return (int) $this->get_prop( 'parent_id', $context );
244
+     * Get parent invoice ID.
245
+     *
246
+     * @since 1.0.19
247
+     * @param  string $context View or edit context.
248
+     * @return int
249
+     */
250
+    public function get_parent_id( $context = 'view' ) {
251
+        return (int) $this->get_prop( 'parent_id', $context );
252 252
     }
253 253
 
254 254
     /**
255
-	 * Get parent invoice.
256
-	 *
257
-	 * @since 1.0.19
258
-	 * @return WPInv_Invoice
259
-	 */
255
+     * Get parent invoice.
256
+     *
257
+     * @since 1.0.19
258
+     * @return WPInv_Invoice
259
+     */
260 260
     public function get_parent_payment() {
261 261
         return new WPInv_Invoice( $this->get_parent_id() );
262 262
     }
263 263
 
264 264
     /**
265
-	 * Alias for self::get_parent_payment().
266
-	 *
267
-	 * @since 1.0.19
268
-	 * @return WPInv_Invoice
269
-	 */
265
+     * Alias for self::get_parent_payment().
266
+     *
267
+     * @since 1.0.19
268
+     * @return WPInv_Invoice
269
+     */
270 270
     public function get_parent() {
271 271
         return $this->get_parent_payment();
272 272
     }
273 273
 
274 274
     /**
275
-	 * Get invoice status.
276
-	 *
277
-	 * @since 1.0.19
278
-	 * @param  string $context View or edit context.
279
-	 * @return string
280
-	 */
281
-	public function get_status( $context = 'view' ) {
282
-		return $this->get_prop( 'status', $context );
283
-	}
275
+     * Get invoice status.
276
+     *
277
+     * @since 1.0.19
278
+     * @param  string $context View or edit context.
279
+     * @return string
280
+     */
281
+    public function get_status( $context = 'view' ) {
282
+        return $this->get_prop( 'status', $context );
283
+    }
284 284
 	
285
-	/**
286
-	 * Retrieves an array of possible invoice statuses.
287
-	 *
288
-	 * @since 1.0.19
289
-	 * @return array
290
-	 */
291
-	public function get_all_statuses() {
292
-
293
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
294
-
295
-		// For backwards compatibility.
296
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
285
+    /**
286
+     * Retrieves an array of possible invoice statuses.
287
+     *
288
+     * @since 1.0.19
289
+     * @return array
290
+     */
291
+    public function get_all_statuses() {
292
+
293
+        $statuses = wpinv_get_invoice_statuses( true, true, $this );
294
+
295
+        // For backwards compatibility.
296
+        if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
297 297
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
298
-		}
298
+        }
299 299
 
300
-		return $statuses;
300
+        return $statuses;
301 301
     }
302 302
 
303 303
     /**
304
-	 * Get invoice status nice name.
305
-	 *
306
-	 * @since 1.0.19
307
-	 * @return string
308
-	 */
304
+     * Get invoice status nice name.
305
+     *
306
+     * @since 1.0.19
307
+     * @return string
308
+     */
309 309
     public function get_status_nicename() {
310
-		$statuses = $this->get_all_statuses();
310
+        $statuses = $this->get_all_statuses();
311 311
 
312 312
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
313 313
 
314 314
         return apply_filters( 'wpinv_get_invoice_status_nicename', $status, $this );
315 315
     }
316 316
 
317
-	/**
317
+    /**
318 318
      * Retrieves the invoice status label html
319 319
      *
320 320
      * @since  1.0.0
@@ -322,27 +322,27 @@  discard block
 block discarded – undo
322 322
      */
323 323
     public function get_status_label_html() {
324 324
 
325
-		$status_label = sanitize_text_field( $this->get_status_nicename() );
326
-		$status       = sanitize_html_class( $this->get_status() );
325
+        $status_label = sanitize_text_field( $this->get_status_nicename() );
326
+        $status       = sanitize_html_class( $this->get_status() );
327 327
 
328
-		return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
329
-	}
328
+        return "<span class='bsui'><span class='d-inline-block py-2 px-3 rounded getpaid-invoice-status-$status'>$status_label</span></span>";
329
+    }
330 330
 
331 331
     /**
332
-	 * Get plugin version when the invoice was created.
333
-	 *
334
-	 * @since 1.0.19
335
-	 * @param  string $context View or edit context.
336
-	 * @return string
337
-	 */
338
-	public function get_version( $context = 'view' ) {
339
-		return $this->get_prop( 'version', $context );
340
-	}
332
+     * Get plugin version when the invoice was created.
333
+     *
334
+     * @since 1.0.19
335
+     * @param  string $context View or edit context.
336
+     * @return string
337
+     */
338
+    public function get_version( $context = 'view' ) {
339
+        return $this->get_prop( 'version', $context );
340
+    }
341 341
 
342
-	/**
343
-	 * @deprecated
344
-	 */
345
-	public function get_invoice_date( $formatted = true ) {
342
+    /**
343
+     * @deprecated
344
+     */
345
+    public function get_invoice_date( $formatted = true ) {
346 346
         $date_completed = $this->get_date_completed();
347 347
         $invoice_date   = $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
348 348
 
@@ -359,228 +359,228 @@  discard block
 block discarded – undo
359 359
     }
360 360
 
361 361
     /**
362
-	 * Get date when the invoice was created.
363
-	 *
364
-	 * @since 1.0.19
365
-	 * @param  string $context View or edit context.
366
-	 * @return string
367
-	 */
368
-	public function get_date_created( $context = 'view' ) {
369
-		return $this->get_prop( 'date_created', $context );
370
-	}
362
+     * Get date when the invoice was created.
363
+     *
364
+     * @since 1.0.19
365
+     * @param  string $context View or edit context.
366
+     * @return string
367
+     */
368
+    public function get_date_created( $context = 'view' ) {
369
+        return $this->get_prop( 'date_created', $context );
370
+    }
371 371
 	
372
-	/**
373
-	 * Alias for self::get_date_created().
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_created_date( $context = 'view' ) {
380
-		return $this->get_date_created( $context );
381
-    }
382
-
383
-    /**
384
-	 * Get GMT date when the invoice was created.
385
-	 *
386
-	 * @since 1.0.19
387
-	 * @param  string $context View or edit context.
388
-	 * @return string
389
-	 */
390
-	public function get_date_created_gmt( $context = 'view' ) {
372
+    /**
373
+     * Alias for self::get_date_created().
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_created_date( $context = 'view' ) {
380
+        return $this->get_date_created( $context );
381
+    }
382
+
383
+    /**
384
+     * Get GMT date when the invoice was created.
385
+     *
386
+     * @since 1.0.19
387
+     * @param  string $context View or edit context.
388
+     * @return string
389
+     */
390
+    public function get_date_created_gmt( $context = 'view' ) {
391 391
         $date = $this->get_date_created( $context );
392 392
 
393 393
         if ( $date ) {
394 394
             $date = get_gmt_from_date( $date );
395 395
         }
396
-		return $date;
396
+        return $date;
397 397
     }
398 398
 
399 399
     /**
400
-	 * Get date when the invoice was last modified.
401
-	 *
402
-	 * @since 1.0.19
403
-	 * @param  string $context View or edit context.
404
-	 * @return string
405
-	 */
406
-	public function get_date_modified( $context = 'view' ) {
407
-		return $this->get_prop( 'date_modified', $context );
408
-	}
400
+     * Get date when the invoice was last modified.
401
+     *
402
+     * @since 1.0.19
403
+     * @param  string $context View or edit context.
404
+     * @return string
405
+     */
406
+    public function get_date_modified( $context = 'view' ) {
407
+        return $this->get_prop( 'date_modified', $context );
408
+    }
409 409
 
410
-	/**
411
-	 * Alias for self::get_date_modified().
412
-	 *
413
-	 * @since 1.0.19
414
-	 * @param  string $context View or edit context.
415
-	 * @return string
416
-	 */
417
-	public function get_modified_date( $context = 'view' ) {
418
-		return $this->get_date_modified( $context );
410
+    /**
411
+     * Alias for self::get_date_modified().
412
+     *
413
+     * @since 1.0.19
414
+     * @param  string $context View or edit context.
415
+     * @return string
416
+     */
417
+    public function get_modified_date( $context = 'view' ) {
418
+        return $this->get_date_modified( $context );
419 419
     }
420 420
 
421 421
     /**
422
-	 * Get GMT date when the invoice was last modified.
423
-	 *
424
-	 * @since 1.0.19
425
-	 * @param  string $context View or edit context.
426
-	 * @return string
427
-	 */
428
-	public function get_date_modified_gmt( $context = 'view' ) {
422
+     * Get GMT date when the invoice was last modified.
423
+     *
424
+     * @since 1.0.19
425
+     * @param  string $context View or edit context.
426
+     * @return string
427
+     */
428
+    public function get_date_modified_gmt( $context = 'view' ) {
429 429
         $date = $this->get_date_modified( $context );
430 430
 
431 431
         if ( $date ) {
432 432
             $date = get_gmt_from_date( $date );
433 433
         }
434
-		return $date;
434
+        return $date;
435 435
     }
436 436
 
437 437
     /**
438
-	 * Get the invoice due date.
439
-	 *
440
-	 * @since 1.0.19
441
-	 * @param  string $context View or edit context.
442
-	 * @return string
443
-	 */
444
-	public function get_due_date( $context = 'view' ) {
445
-		return $this->get_prop( 'due_date', $context );
438
+     * Get the invoice due date.
439
+     *
440
+     * @since 1.0.19
441
+     * @param  string $context View or edit context.
442
+     * @return string
443
+     */
444
+    public function get_due_date( $context = 'view' ) {
445
+        return $this->get_prop( 'due_date', $context );
446 446
     }
447 447
 
448 448
     /**
449
-	 * Alias for self::get_due_date().
450
-	 *
451
-	 * @since 1.0.19
452
-	 * @param  string $context View or edit context.
453
-	 * @return string
454
-	 */
455
-	public function get_date_due( $context = 'view' ) {
456
-		return $this->get_due_date( $context );
449
+     * Alias for self::get_due_date().
450
+     *
451
+     * @since 1.0.19
452
+     * @param  string $context View or edit context.
453
+     * @return string
454
+     */
455
+    public function get_date_due( $context = 'view' ) {
456
+        return $this->get_due_date( $context );
457 457
     }
458 458
 
459 459
     /**
460
-	 * Get the invoice GMT due date.
461
-	 *
462
-	 * @since 1.0.19
463
-	 * @param  string $context View or edit context.
464
-	 * @return string
465
-	 */
466
-	public function get_due_date_gmt( $context = 'view' ) {
460
+     * Get the invoice GMT due date.
461
+     *
462
+     * @since 1.0.19
463
+     * @param  string $context View or edit context.
464
+     * @return string
465
+     */
466
+    public function get_due_date_gmt( $context = 'view' ) {
467 467
         $date = $this->get_due_date( $context );
468 468
 
469 469
         if ( $date ) {
470 470
             $date = get_gmt_from_date( $date );
471 471
         }
472
-		return $date;
472
+        return $date;
473 473
     }
474 474
 
475 475
     /**
476
-	 * Alias for self::get_due_date_gmt().
477
-	 *
478
-	 * @since 1.0.19
479
-	 * @param  string $context View or edit context.
480
-	 * @return string
481
-	 */
482
-	public function get_gmt_date_due( $context = 'view' ) {
483
-		return $this->get_due_date_gmt( $context );
476
+     * Alias for self::get_due_date_gmt().
477
+     *
478
+     * @since 1.0.19
479
+     * @param  string $context View or edit context.
480
+     * @return string
481
+     */
482
+    public function get_gmt_date_due( $context = 'view' ) {
483
+        return $this->get_due_date_gmt( $context );
484 484
     }
485 485
 
486 486
     /**
487
-	 * Get date when the invoice was completed.
488
-	 *
489
-	 * @since 1.0.19
490
-	 * @param  string $context View or edit context.
491
-	 * @return string
492
-	 */
493
-	public function get_completed_date( $context = 'view' ) {
494
-		return $this->get_prop( 'completed_date', $context );
487
+     * Get date when the invoice was completed.
488
+     *
489
+     * @since 1.0.19
490
+     * @param  string $context View or edit context.
491
+     * @return string
492
+     */
493
+    public function get_completed_date( $context = 'view' ) {
494
+        return $this->get_prop( 'completed_date', $context );
495 495
     }
496 496
 
497 497
     /**
498
-	 * Alias for self::get_completed_date().
499
-	 *
500
-	 * @since 1.0.19
501
-	 * @param  string $context View or edit context.
502
-	 * @return string
503
-	 */
504
-	public function get_date_completed( $context = 'view' ) {
505
-		return $this->get_completed_date( $context );
498
+     * Alias for self::get_completed_date().
499
+     *
500
+     * @since 1.0.19
501
+     * @param  string $context View or edit context.
502
+     * @return string
503
+     */
504
+    public function get_date_completed( $context = 'view' ) {
505
+        return $this->get_completed_date( $context );
506 506
     }
507 507
 
508 508
     /**
509
-	 * Get GMT date when the invoice was was completed.
510
-	 *
511
-	 * @since 1.0.19
512
-	 * @param  string $context View or edit context.
513
-	 * @return string
514
-	 */
515
-	public function get_completed_date_gmt( $context = 'view' ) {
509
+     * Get GMT date when the invoice was was completed.
510
+     *
511
+     * @since 1.0.19
512
+     * @param  string $context View or edit context.
513
+     * @return string
514
+     */
515
+    public function get_completed_date_gmt( $context = 'view' ) {
516 516
         $date = $this->get_completed_date( $context );
517 517
 
518 518
         if ( $date ) {
519 519
             $date = get_gmt_from_date( $date );
520 520
         }
521
-		return $date;
521
+        return $date;
522 522
     }
523 523
 
524 524
     /**
525
-	 * Alias for self::get_completed_date_gmt().
526
-	 *
527
-	 * @since 1.0.19
528
-	 * @param  string $context View or edit context.
529
-	 * @return string
530
-	 */
531
-	public function get_gmt_completed_date( $context = 'view' ) {
532
-		return $this->get_completed_date_gmt( $context );
525
+     * Alias for self::get_completed_date_gmt().
526
+     *
527
+     * @since 1.0.19
528
+     * @param  string $context View or edit context.
529
+     * @return string
530
+     */
531
+    public function get_gmt_completed_date( $context = 'view' ) {
532
+        return $this->get_completed_date_gmt( $context );
533 533
     }
534 534
 
535 535
     /**
536
-	 * Get the invoice number.
537
-	 *
538
-	 * @since 1.0.19
539
-	 * @param  string $context View or edit context.
540
-	 * @return string
541
-	 */
542
-	public function get_number( $context = 'view' ) {
543
-		$number = $this->get_prop( 'number', $context );
536
+     * Get the invoice number.
537
+     *
538
+     * @since 1.0.19
539
+     * @param  string $context View or edit context.
540
+     * @return string
541
+     */
542
+    public function get_number( $context = 'view' ) {
543
+        $number = $this->get_prop( 'number', $context );
544 544
 
545
-		if ( empty( $number ) ) {
546
-			$number = $this->generate_number();
547
-			$this->set_number( $this->generate_number() );
548
-		}
545
+        if ( empty( $number ) ) {
546
+            $number = $this->generate_number();
547
+            $this->set_number( $this->generate_number() );
548
+        }
549 549
 
550
-		return $number;
550
+        return $number;
551 551
     }
552 552
 
553
-	/**
554
-	 * Set the invoice number.
555
-	 *
556
-	 * @since 1.0.19
557
-	 */
558
-	public function maybe_set_number() {
553
+    /**
554
+     * Set the invoice number.
555
+     *
556
+     * @since 1.0.19
557
+     */
558
+    public function maybe_set_number() {
559 559
         $number = $this->get_number();
560 560
 
561 561
         if ( empty( $number ) || $this->get_id() == $number ) {
562
-			$this->set_number( $this->generate_number() );
562
+            $this->set_number( $this->generate_number() );
563 563
         }
564 564
 
565
-	}
565
+    }
566 566
 
567 567
     /**
568
-	 * Get the invoice key.
569
-	 *
570
-	 * @since 1.0.19
571
-	 * @param  string $context View or edit context.
572
-	 * @return string
573
-	 */
574
-	public function get_key( $context = 'view' ) {
568
+     * Get the invoice key.
569
+     *
570
+     * @since 1.0.19
571
+     * @param  string $context View or edit context.
572
+     * @return string
573
+     */
574
+    public function get_key( $context = 'view' ) {
575 575
         return $this->get_prop( 'key', $context );
576
-	}
577
-
578
-	/**
579
-	 * Set the invoice key.
580
-	 *
581
-	 * @since 1.0.19
582
-	 */
583
-	public function maybe_set_key() {
576
+    }
577
+
578
+    /**
579
+     * Set the invoice key.
580
+     *
581
+     * @since 1.0.19
582
+     */
583
+    public function maybe_set_key() {
584 584
         $key = $this->get_key();
585 585
 
586 586
         if ( empty( $key ) ) {
@@ -591,126 +591,126 @@  discard block
 block discarded – undo
591 591
     }
592 592
 
593 593
     /**
594
-	 * Get the invoice type.
595
-	 *
596
-	 * @since 1.0.19
597
-	 * @param  string $context View or edit context.
598
-	 * @return string
599
-	 */
600
-	public function get_type( $context = 'view' ) {
594
+     * Get the invoice type.
595
+     *
596
+     * @since 1.0.19
597
+     * @param  string $context View or edit context.
598
+     * @return string
599
+     */
600
+    public function get_type( $context = 'view' ) {
601 601
         return $this->get_prop( 'type', $context );
602
-	}
602
+    }
603 603
 
604
-	/**
605
-	 * @deprecated
606
-	 */
607
-	public function get_invoice_quote_type() {
604
+    /**
605
+     * @deprecated
606
+     */
607
+    public function get_invoice_quote_type() {
608 608
         ucfirst( $this->get_type() );
609 609
     }
610 610
 
611 611
     /**
612
-	 * Get the invoice post type.
613
-	 *
614
-	 * @since 1.0.19
615
-	 * @param  string $context View or edit context.
616
-	 * @return string
617
-	 */
618
-	public function get_post_type( $context = 'view' ) {
612
+     * Get the invoice post type.
613
+     *
614
+     * @since 1.0.19
615
+     * @param  string $context View or edit context.
616
+     * @return string
617
+     */
618
+    public function get_post_type( $context = 'view' ) {
619 619
         return $this->get_prop( 'post_type', $context );
620 620
     }
621 621
 
622 622
     /**
623
-	 * Get the invoice mode.
624
-	 *
625
-	 * @since 1.0.19
626
-	 * @param  string $context View or edit context.
627
-	 * @return string
628
-	 */
629
-	public function get_mode( $context = 'view' ) {
623
+     * Get the invoice mode.
624
+     *
625
+     * @since 1.0.19
626
+     * @param  string $context View or edit context.
627
+     * @return string
628
+     */
629
+    public function get_mode( $context = 'view' ) {
630 630
         return $this->get_prop( 'mode', $context );
631 631
     }
632 632
 
633 633
     /**
634
-	 * Get the invoice path.
635
-	 *
636
-	 * @since 1.0.19
637
-	 * @param  string $context View or edit context.
638
-	 * @return string
639
-	 */
640
-	public function get_path( $context = 'view' ) {
634
+     * Get the invoice path.
635
+     *
636
+     * @since 1.0.19
637
+     * @param  string $context View or edit context.
638
+     * @return string
639
+     */
640
+    public function get_path( $context = 'view' ) {
641 641
         $path   = $this->get_prop( 'path', $context );
642
-		$prefix = wpinv_post_name_prefix( $this->get_post_type() );
642
+        $prefix = wpinv_post_name_prefix( $this->get_post_type() );
643 643
 
644
-		if ( 0 !== strpos( $path, $prefix ) ) {
645
-			$path = sanitize_title(  $prefix . $this->get_id()  );
646
-			$this->set_path( $path );
647
-		}
644
+        if ( 0 !== strpos( $path, $prefix ) ) {
645
+            $path = sanitize_title(  $prefix . $this->get_id()  );
646
+            $this->set_path( $path );
647
+        }
648 648
 
649
-		return $path;
649
+        return $path;
650 650
     }
651 651
 
652 652
     /**
653
-	 * Get the invoice name/title.
654
-	 *
655
-	 * @since 1.0.19
656
-	 * @param  string $context View or edit context.
657
-	 * @return string
658
-	 */
659
-	public function get_name( $context = 'view' ) {
653
+     * Get the invoice name/title.
654
+     *
655
+     * @since 1.0.19
656
+     * @param  string $context View or edit context.
657
+     * @return string
658
+     */
659
+    public function get_name( $context = 'view' ) {
660 660
         return $this->get_prop( 'title', $context );
661 661
     }
662 662
 
663 663
     /**
664
-	 * Alias of self::get_name().
665
-	 *
666
-	 * @since 1.0.19
667
-	 * @param  string $context View or edit context.
668
-	 * @return string
669
-	 */
670
-	public function get_title( $context = 'view' ) {
671
-		return $this->get_name( $context );
664
+     * Alias of self::get_name().
665
+     *
666
+     * @since 1.0.19
667
+     * @param  string $context View or edit context.
668
+     * @return string
669
+     */
670
+    public function get_title( $context = 'view' ) {
671
+        return $this->get_name( $context );
672 672
     }
673 673
 
674 674
     /**
675
-	 * Get the invoice description.
676
-	 *
677
-	 * @since 1.0.19
678
-	 * @param  string $context View or edit context.
679
-	 * @return string
680
-	 */
681
-	public function get_description( $context = 'view' ) {
682
-		return $this->get_prop( 'description', $context );
675
+     * Get the invoice description.
676
+     *
677
+     * @since 1.0.19
678
+     * @param  string $context View or edit context.
679
+     * @return string
680
+     */
681
+    public function get_description( $context = 'view' ) {
682
+        return $this->get_prop( 'description', $context );
683 683
     }
684 684
 
685 685
     /**
686
-	 * Alias of self::get_description().
687
-	 *
688
-	 * @since 1.0.19
689
-	 * @param  string $context View or edit context.
690
-	 * @return string
691
-	 */
692
-	public function get_excerpt( $context = 'view' ) {
693
-		return $this->get_description( $context );
686
+     * Alias of self::get_description().
687
+     *
688
+     * @since 1.0.19
689
+     * @param  string $context View or edit context.
690
+     * @return string
691
+     */
692
+    public function get_excerpt( $context = 'view' ) {
693
+        return $this->get_description( $context );
694 694
     }
695 695
 
696 696
     /**
697
-	 * Alias of self::get_description().
698
-	 *
699
-	 * @since 1.0.19
700
-	 * @param  string $context View or edit context.
701
-	 * @return string
702
-	 */
703
-	public function get_summary( $context = 'view' ) {
704
-		return $this->get_description( $context );
697
+     * Alias of self::get_description().
698
+     *
699
+     * @since 1.0.19
700
+     * @param  string $context View or edit context.
701
+     * @return string
702
+     */
703
+    public function get_summary( $context = 'view' ) {
704
+        return $this->get_description( $context );
705 705
     }
706 706
 
707 707
     /**
708
-	 * Returns the user info.
709
-	 *
710
-	 * @since 1.0.19
708
+     * Returns the user info.
709
+     *
710
+     * @since 1.0.19
711 711
      * @param  string $context View or edit context.
712
-	 * @return array
713
-	 */
712
+     * @return array
713
+     */
714 714
     public function get_user_info( $context = 'view' ) {
715 715
 
716 716
         $user_info = array(
@@ -727,605 +727,605 @@  discard block
 block discarded – undo
727 727
             'company'    => $this->get_company( $context ),
728 728
             'vat_number' => $this->get_vat_number( $context ),
729 729
             'discount'   => $this->get_discount_code( $context ),
730
-		);
730
+        );
731 731
 
732
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
732
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
733 733
 
734 734
     }
735 735
 
736 736
     /**
737
-	 * Get the customer id.
738
-	 *
739
-	 * @since 1.0.19
740
-	 * @param  string $context View or edit context.
741
-	 * @return int
742
-	 */
743
-	public function get_author( $context = 'view' ) {
744
-		return (int) $this->get_prop( 'author', $context );
737
+     * Get the customer id.
738
+     *
739
+     * @since 1.0.19
740
+     * @param  string $context View or edit context.
741
+     * @return int
742
+     */
743
+    public function get_author( $context = 'view' ) {
744
+        return (int) $this->get_prop( 'author', $context );
745 745
     }
746 746
 
747 747
     /**
748
-	 * Alias of self::get_author().
749
-	 *
750
-	 * @since 1.0.19
751
-	 * @param  string $context View or edit context.
752
-	 * @return int
753
-	 */
754
-	public function get_user_id( $context = 'view' ) {
755
-		return $this->get_author( $context );
748
+     * Alias of self::get_author().
749
+     *
750
+     * @since 1.0.19
751
+     * @param  string $context View or edit context.
752
+     * @return int
753
+     */
754
+    public function get_user_id( $context = 'view' ) {
755
+        return $this->get_author( $context );
756 756
     }
757 757
 
758
-     /**
759
-	 * Alias of self::get_author().
760
-	 *
761
-	 * @since 1.0.19
762
-	 * @param  string $context View or edit context.
763
-	 * @return int
764
-	 */
765
-	public function get_customer_id( $context = 'view' ) {
766
-		return $this->get_author( $context );
758
+        /**
759
+         * Alias of self::get_author().
760
+         *
761
+         * @since 1.0.19
762
+         * @param  string $context View or edit context.
763
+         * @return int
764
+         */
765
+    public function get_customer_id( $context = 'view' ) {
766
+        return $this->get_author( $context );
767 767
     }
768 768
 
769 769
     /**
770
-	 * Get the customer's ip.
771
-	 *
772
-	 * @since 1.0.19
773
-	 * @param  string $context View or edit context.
774
-	 * @return string
775
-	 */
776
-	public function get_ip( $context = 'view' ) {
777
-		return $this->get_prop( 'user_ip', $context );
770
+     * Get the customer's ip.
771
+     *
772
+     * @since 1.0.19
773
+     * @param  string $context View or edit context.
774
+     * @return string
775
+     */
776
+    public function get_ip( $context = 'view' ) {
777
+        return $this->get_prop( 'user_ip', $context );
778 778
     }
779 779
 
780 780
     /**
781
-	 * Alias of self::get_ip().
782
-	 *
783
-	 * @since 1.0.19
784
-	 * @param  string $context View or edit context.
785
-	 * @return string
786
-	 */
787
-	public function get_user_ip( $context = 'view' ) {
788
-		return $this->get_ip( $context );
781
+     * Alias of self::get_ip().
782
+     *
783
+     * @since 1.0.19
784
+     * @param  string $context View or edit context.
785
+     * @return string
786
+     */
787
+    public function get_user_ip( $context = 'view' ) {
788
+        return $this->get_ip( $context );
789
+    }
790
+
791
+        /**
792
+         * Alias of self::get_ip().
793
+         *
794
+         * @since 1.0.19
795
+         * @param  string $context View or edit context.
796
+         * @return string
797
+         */
798
+    public function get_customer_ip( $context = 'view' ) {
799
+        return $this->get_ip( $context );
800
+    }
801
+
802
+    /**
803
+     * Get the customer's first name.
804
+     *
805
+     * @since 1.0.19
806
+     * @param  string $context View or edit context.
807
+     * @return string
808
+     */
809
+    public function get_first_name( $context = 'view' ) {
810
+        return $this->get_prop( 'first_name', $context );
811
+    }
812
+
813
+    /**
814
+     * Alias of self::get_first_name().
815
+     *
816
+     * @since 1.0.19
817
+     * @param  string $context View or edit context.
818
+     * @return int
819
+     */
820
+    public function get_user_first_name( $context = 'view' ) {
821
+        return $this->get_first_name( $context );
822
+    }
823
+
824
+        /**
825
+         * Alias of self::get_first_name().
826
+         *
827
+         * @since 1.0.19
828
+         * @param  string $context View or edit context.
829
+         * @return int
830
+         */
831
+    public function get_customer_first_name( $context = 'view' ) {
832
+        return $this->get_first_name( $context );
833
+    }
834
+
835
+    /**
836
+     * Get the customer's last name.
837
+     *
838
+     * @since 1.0.19
839
+     * @param  string $context View or edit context.
840
+     * @return string
841
+     */
842
+    public function get_last_name( $context = 'view' ) {
843
+        return $this->get_prop( 'last_name', $context );
844
+    }
845
+
846
+    /**
847
+     * Alias of self::get_last_name().
848
+     *
849
+     * @since 1.0.19
850
+     * @param  string $context View or edit context.
851
+     * @return int
852
+     */
853
+    public function get_user_last_name( $context = 'view' ) {
854
+        return $this->get_last_name( $context );
855
+    }
856
+
857
+    /**
858
+     * Alias of self::get_last_name().
859
+     *
860
+     * @since 1.0.19
861
+     * @param  string $context View or edit context.
862
+     * @return int
863
+     */
864
+    public function get_customer_last_name( $context = 'view' ) {
865
+        return $this->get_last_name( $context );
866
+    }
867
+
868
+    /**
869
+     * Get the customer's full name.
870
+     *
871
+     * @since 1.0.19
872
+     * @param  string $context View or edit context.
873
+     * @return string
874
+     */
875
+    public function get_full_name( $context = 'view' ) {
876
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
877
+    }
878
+
879
+    /**
880
+     * Alias of self::get_full_name().
881
+     *
882
+     * @since 1.0.19
883
+     * @param  string $context View or edit context.
884
+     * @return int
885
+     */
886
+    public function get_user_full_name( $context = 'view' ) {
887
+        return $this->get_full_name( $context );
789 888
     }
790 889
 
791
-     /**
792
-	 * Alias of self::get_ip().
793
-	 *
794
-	 * @since 1.0.19
795
-	 * @param  string $context View or edit context.
796
-	 * @return string
797
-	 */
798
-	public function get_customer_ip( $context = 'view' ) {
799
-		return $this->get_ip( $context );
890
+    /**
891
+     * Alias of self::get_full_name().
892
+     *
893
+     * @since 1.0.19
894
+     * @param  string $context View or edit context.
895
+     * @return int
896
+     */
897
+    public function get_customer_full_name( $context = 'view' ) {
898
+        return $this->get_full_name( $context );
800 899
     }
801 900
 
802 901
     /**
803
-	 * Get the customer's first name.
804
-	 *
805
-	 * @since 1.0.19
806
-	 * @param  string $context View or edit context.
807
-	 * @return string
808
-	 */
809
-	public function get_first_name( $context = 'view' ) {
810
-		return $this->get_prop( 'first_name', $context );
902
+     * Get the customer's phone number.
903
+     *
904
+     * @since 1.0.19
905
+     * @param  string $context View or edit context.
906
+     * @return string
907
+     */
908
+    public function get_phone( $context = 'view' ) {
909
+        return $this->get_prop( 'phone', $context );
811 910
     }
812 911
 
813 912
     /**
814
-	 * Alias of self::get_first_name().
815
-	 *
816
-	 * @since 1.0.19
817
-	 * @param  string $context View or edit context.
818
-	 * @return int
819
-	 */
820
-	public function get_user_first_name( $context = 'view' ) {
821
-		return $this->get_first_name( $context );
913
+     * Alias of self::get_phone().
914
+     *
915
+     * @since 1.0.19
916
+     * @param  string $context View or edit context.
917
+     * @return int
918
+     */
919
+    public function get_phone_number( $context = 'view' ) {
920
+        return $this->get_phone( $context );
822 921
     }
823 922
 
824
-     /**
825
-	 * Alias of self::get_first_name().
826
-	 *
827
-	 * @since 1.0.19
828
-	 * @param  string $context View or edit context.
829
-	 * @return int
830
-	 */
831
-	public function get_customer_first_name( $context = 'view' ) {
832
-		return $this->get_first_name( $context );
923
+    /**
924
+     * Alias of self::get_phone().
925
+     *
926
+     * @since 1.0.19
927
+     * @param  string $context View or edit context.
928
+     * @return int
929
+     */
930
+    public function get_user_phone( $context = 'view' ) {
931
+        return $this->get_phone( $context );
833 932
     }
834 933
 
835 934
     /**
836
-	 * Get the customer's last name.
837
-	 *
838
-	 * @since 1.0.19
839
-	 * @param  string $context View or edit context.
840
-	 * @return string
841
-	 */
842
-	public function get_last_name( $context = 'view' ) {
843
-		return $this->get_prop( 'last_name', $context );
935
+     * Alias of self::get_phone().
936
+     *
937
+     * @since 1.0.19
938
+     * @param  string $context View or edit context.
939
+     * @return int
940
+     */
941
+    public function get_customer_phone( $context = 'view' ) {
942
+        return $this->get_phone( $context );
844 943
     }
845 944
 
846 945
     /**
847
-	 * Alias of self::get_last_name().
848
-	 *
849
-	 * @since 1.0.19
850
-	 * @param  string $context View or edit context.
851
-	 * @return int
852
-	 */
853
-	public function get_user_last_name( $context = 'view' ) {
854
-		return $this->get_last_name( $context );
946
+     * Get the customer's email address.
947
+     *
948
+     * @since 1.0.19
949
+     * @param  string $context View or edit context.
950
+     * @return string
951
+     */
952
+    public function get_email( $context = 'view' ) {
953
+        return $this->get_prop( 'email', $context );
855 954
     }
856 955
 
857 956
     /**
858
-	 * Alias of self::get_last_name().
859
-	 *
860
-	 * @since 1.0.19
861
-	 * @param  string $context View or edit context.
862
-	 * @return int
863
-	 */
864
-	public function get_customer_last_name( $context = 'view' ) {
865
-		return $this->get_last_name( $context );
957
+     * Alias of self::get_email().
958
+     *
959
+     * @since 1.0.19
960
+     * @param  string $context View or edit context.
961
+     * @return string
962
+     */
963
+    public function get_email_address( $context = 'view' ) {
964
+        return $this->get_email( $context );
866 965
     }
867 966
 
868 967
     /**
869
-	 * Get the customer's full name.
870
-	 *
871
-	 * @since 1.0.19
872
-	 * @param  string $context View or edit context.
873
-	 * @return string
874
-	 */
875
-	public function get_full_name( $context = 'view' ) {
876
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
968
+     * Alias of self::get_email().
969
+     *
970
+     * @since 1.0.19
971
+     * @param  string $context View or edit context.
972
+     * @return int
973
+     */
974
+    public function get_user_email( $context = 'view' ) {
975
+        return $this->get_email( $context );
877 976
     }
878 977
 
879 978
     /**
880
-	 * Alias of self::get_full_name().
881
-	 *
882
-	 * @since 1.0.19
883
-	 * @param  string $context View or edit context.
884
-	 * @return int
885
-	 */
886
-	public function get_user_full_name( $context = 'view' ) {
887
-		return $this->get_full_name( $context );
979
+     * Alias of self::get_email().
980
+     *
981
+     * @since 1.0.19
982
+     * @param  string $context View or edit context.
983
+     * @return int
984
+     */
985
+    public function get_customer_email( $context = 'view' ) {
986
+        return $this->get_email( $context );
888 987
     }
889 988
 
890 989
     /**
891
-	 * Alias of self::get_full_name().
892
-	 *
893
-	 * @since 1.0.19
894
-	 * @param  string $context View or edit context.
895
-	 * @return int
896
-	 */
897
-	public function get_customer_full_name( $context = 'view' ) {
898
-		return $this->get_full_name( $context );
990
+     * Get the customer's country.
991
+     *
992
+     * @since 1.0.19
993
+     * @param  string $context View or edit context.
994
+     * @return string
995
+     */
996
+    public function get_country( $context = 'view' ) {
997
+        $country = $this->get_prop( 'country', $context );
998
+        return empty( $country ) ? wpinv_get_default_country() : $country;
899 999
     }
900 1000
 
901 1001
     /**
902
-	 * Get the customer's phone number.
903
-	 *
904
-	 * @since 1.0.19
905
-	 * @param  string $context View or edit context.
906
-	 * @return string
907
-	 */
908
-	public function get_phone( $context = 'view' ) {
909
-		return $this->get_prop( 'phone', $context );
1002
+     * Alias of self::get_country().
1003
+     *
1004
+     * @since 1.0.19
1005
+     * @param  string $context View or edit context.
1006
+     * @return int
1007
+     */
1008
+    public function get_user_country( $context = 'view' ) {
1009
+        return $this->get_country( $context );
910 1010
     }
911 1011
 
912 1012
     /**
913
-	 * Alias of self::get_phone().
914
-	 *
915
-	 * @since 1.0.19
916
-	 * @param  string $context View or edit context.
917
-	 * @return int
918
-	 */
919
-	public function get_phone_number( $context = 'view' ) {
920
-		return $this->get_phone( $context );
1013
+     * Alias of self::get_country().
1014
+     *
1015
+     * @since 1.0.19
1016
+     * @param  string $context View or edit context.
1017
+     * @return int
1018
+     */
1019
+    public function get_customer_country( $context = 'view' ) {
1020
+        return $this->get_country( $context );
921 1021
     }
922 1022
 
923 1023
     /**
924
-	 * Alias of self::get_phone().
925
-	 *
926
-	 * @since 1.0.19
927
-	 * @param  string $context View or edit context.
928
-	 * @return int
929
-	 */
930
-	public function get_user_phone( $context = 'view' ) {
931
-		return $this->get_phone( $context );
1024
+     * Get the customer's state.
1025
+     *
1026
+     * @since 1.0.19
1027
+     * @param  string $context View or edit context.
1028
+     * @return string
1029
+     */
1030
+    public function get_state( $context = 'view' ) {
1031
+        $state = $this->get_prop( 'state', $context );
1032
+        return empty( $state ) ? wpinv_get_default_state() : $state;
932 1033
     }
933 1034
 
934 1035
     /**
935
-	 * Alias of self::get_phone().
936
-	 *
937
-	 * @since 1.0.19
938
-	 * @param  string $context View or edit context.
939
-	 * @return int
940
-	 */
941
-	public function get_customer_phone( $context = 'view' ) {
942
-		return $this->get_phone( $context );
1036
+     * Alias of self::get_state().
1037
+     *
1038
+     * @since 1.0.19
1039
+     * @param  string $context View or edit context.
1040
+     * @return int
1041
+     */
1042
+    public function get_user_state( $context = 'view' ) {
1043
+        return $this->get_state( $context );
943 1044
     }
944 1045
 
945 1046
     /**
946
-	 * Get the customer's email address.
947
-	 *
948
-	 * @since 1.0.19
949
-	 * @param  string $context View or edit context.
950
-	 * @return string
951
-	 */
952
-	public function get_email( $context = 'view' ) {
953
-		return $this->get_prop( 'email', $context );
1047
+     * Alias of self::get_state().
1048
+     *
1049
+     * @since 1.0.19
1050
+     * @param  string $context View or edit context.
1051
+     * @return int
1052
+     */
1053
+    public function get_customer_state( $context = 'view' ) {
1054
+        return $this->get_state( $context );
954 1055
     }
955 1056
 
956 1057
     /**
957
-	 * Alias of self::get_email().
958
-	 *
959
-	 * @since 1.0.19
960
-	 * @param  string $context View or edit context.
961
-	 * @return string
962
-	 */
963
-	public function get_email_address( $context = 'view' ) {
964
-		return $this->get_email( $context );
1058
+     * Get the customer's city.
1059
+     *
1060
+     * @since 1.0.19
1061
+     * @param  string $context View or edit context.
1062
+     * @return string
1063
+     */
1064
+    public function get_city( $context = 'view' ) {
1065
+        return $this->get_prop( 'city', $context );
965 1066
     }
966 1067
 
967 1068
     /**
968
-	 * Alias of self::get_email().
969
-	 *
970
-	 * @since 1.0.19
971
-	 * @param  string $context View or edit context.
972
-	 * @return int
973
-	 */
974
-	public function get_user_email( $context = 'view' ) {
975
-		return $this->get_email( $context );
1069
+     * Alias of self::get_city().
1070
+     *
1071
+     * @since 1.0.19
1072
+     * @param  string $context View or edit context.
1073
+     * @return string
1074
+     */
1075
+    public function get_user_city( $context = 'view' ) {
1076
+        return $this->get_city( $context );
976 1077
     }
977 1078
 
978 1079
     /**
979
-	 * Alias of self::get_email().
980
-	 *
981
-	 * @since 1.0.19
982
-	 * @param  string $context View or edit context.
983
-	 * @return int
984
-	 */
985
-	public function get_customer_email( $context = 'view' ) {
986
-		return $this->get_email( $context );
1080
+     * Alias of self::get_city().
1081
+     *
1082
+     * @since 1.0.19
1083
+     * @param  string $context View or edit context.
1084
+     * @return string
1085
+     */
1086
+    public function get_customer_city( $context = 'view' ) {
1087
+        return $this->get_city( $context );
987 1088
     }
988 1089
 
989 1090
     /**
990
-	 * Get the customer's country.
991
-	 *
992
-	 * @since 1.0.19
993
-	 * @param  string $context View or edit context.
994
-	 * @return string
995
-	 */
996
-	public function get_country( $context = 'view' ) {
997
-		$country = $this->get_prop( 'country', $context );
998
-		return empty( $country ) ? wpinv_get_default_country() : $country;
1091
+     * Get the customer's zip.
1092
+     *
1093
+     * @since 1.0.19
1094
+     * @param  string $context View or edit context.
1095
+     * @return string
1096
+     */
1097
+    public function get_zip( $context = 'view' ) {
1098
+        return $this->get_prop( 'zip', $context );
999 1099
     }
1000 1100
 
1001 1101
     /**
1002
-	 * Alias of self::get_country().
1003
-	 *
1004
-	 * @since 1.0.19
1005
-	 * @param  string $context View or edit context.
1006
-	 * @return int
1007
-	 */
1008
-	public function get_user_country( $context = 'view' ) {
1009
-		return $this->get_country( $context );
1102
+     * Alias of self::get_zip().
1103
+     *
1104
+     * @since 1.0.19
1105
+     * @param  string $context View or edit context.
1106
+     * @return string
1107
+     */
1108
+    public function get_user_zip( $context = 'view' ) {
1109
+        return $this->get_zip( $context );
1010 1110
     }
1011 1111
 
1012 1112
     /**
1013
-	 * Alias of self::get_country().
1014
-	 *
1015
-	 * @since 1.0.19
1016
-	 * @param  string $context View or edit context.
1017
-	 * @return int
1018
-	 */
1019
-	public function get_customer_country( $context = 'view' ) {
1020
-		return $this->get_country( $context );
1113
+     * Alias of self::get_zip().
1114
+     *
1115
+     * @since 1.0.19
1116
+     * @param  string $context View or edit context.
1117
+     * @return string
1118
+     */
1119
+    public function get_customer_zip( $context = 'view' ) {
1120
+        return $this->get_zip( $context );
1021 1121
     }
1022 1122
 
1023 1123
     /**
1024
-	 * Get the customer's state.
1025
-	 *
1026
-	 * @since 1.0.19
1027
-	 * @param  string $context View or edit context.
1028
-	 * @return string
1029
-	 */
1030
-	public function get_state( $context = 'view' ) {
1031
-		$state = $this->get_prop( 'state', $context );
1032
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1124
+     * Get the customer's company.
1125
+     *
1126
+     * @since 1.0.19
1127
+     * @param  string $context View or edit context.
1128
+     * @return string
1129
+     */
1130
+    public function get_company( $context = 'view' ) {
1131
+        return $this->get_prop( 'company', $context );
1033 1132
     }
1034 1133
 
1035 1134
     /**
1036
-	 * Alias of self::get_state().
1037
-	 *
1038
-	 * @since 1.0.19
1039
-	 * @param  string $context View or edit context.
1040
-	 * @return int
1041
-	 */
1042
-	public function get_user_state( $context = 'view' ) {
1043
-		return $this->get_state( $context );
1135
+     * Alias of self::get_company().
1136
+     *
1137
+     * @since 1.0.19
1138
+     * @param  string $context View or edit context.
1139
+     * @return string
1140
+     */
1141
+    public function get_user_company( $context = 'view' ) {
1142
+        return $this->get_company( $context );
1044 1143
     }
1045 1144
 
1046 1145
     /**
1047
-	 * Alias of self::get_state().
1048
-	 *
1049
-	 * @since 1.0.19
1050
-	 * @param  string $context View or edit context.
1051
-	 * @return int
1052
-	 */
1053
-	public function get_customer_state( $context = 'view' ) {
1054
-		return $this->get_state( $context );
1146
+     * Alias of self::get_company().
1147
+     *
1148
+     * @since 1.0.19
1149
+     * @param  string $context View or edit context.
1150
+     * @return string
1151
+     */
1152
+    public function get_customer_company( $context = 'view' ) {
1153
+        return $this->get_company( $context );
1055 1154
     }
1056 1155
 
1057 1156
     /**
1058
-	 * Get the customer's city.
1059
-	 *
1060
-	 * @since 1.0.19
1061
-	 * @param  string $context View or edit context.
1062
-	 * @return string
1063
-	 */
1064
-	public function get_city( $context = 'view' ) {
1065
-		return $this->get_prop( 'city', $context );
1157
+     * Get the customer's vat number.
1158
+     *
1159
+     * @since 1.0.19
1160
+     * @param  string $context View or edit context.
1161
+     * @return string
1162
+     */
1163
+    public function get_vat_number( $context = 'view' ) {
1164
+        return $this->get_prop( 'vat_number', $context );
1066 1165
     }
1067 1166
 
1068 1167
     /**
1069
-	 * Alias of self::get_city().
1070
-	 *
1071
-	 * @since 1.0.19
1072
-	 * @param  string $context View or edit context.
1073
-	 * @return string
1074
-	 */
1075
-	public function get_user_city( $context = 'view' ) {
1076
-		return $this->get_city( $context );
1168
+     * Alias of self::get_vat_number().
1169
+     *
1170
+     * @since 1.0.19
1171
+     * @param  string $context View or edit context.
1172
+     * @return string
1173
+     */
1174
+    public function get_user_vat_number( $context = 'view' ) {
1175
+        return $this->get_vat_number( $context );
1077 1176
     }
1078 1177
 
1079 1178
     /**
1080
-	 * Alias of self::get_city().
1081
-	 *
1082
-	 * @since 1.0.19
1083
-	 * @param  string $context View or edit context.
1084
-	 * @return string
1085
-	 */
1086
-	public function get_customer_city( $context = 'view' ) {
1087
-		return $this->get_city( $context );
1179
+     * Alias of self::get_vat_number().
1180
+     *
1181
+     * @since 1.0.19
1182
+     * @param  string $context View or edit context.
1183
+     * @return string
1184
+     */
1185
+    public function get_customer_vat_number( $context = 'view' ) {
1186
+        return $this->get_vat_number( $context );
1088 1187
     }
1089 1188
 
1090 1189
     /**
1091
-	 * Get the customer's zip.
1092
-	 *
1093
-	 * @since 1.0.19
1094
-	 * @param  string $context View or edit context.
1095
-	 * @return string
1096
-	 */
1097
-	public function get_zip( $context = 'view' ) {
1098
-		return $this->get_prop( 'zip', $context );
1190
+     * Get the customer's vat rate.
1191
+     *
1192
+     * @since 1.0.19
1193
+     * @param  string $context View or edit context.
1194
+     * @return string
1195
+     */
1196
+    public function get_vat_rate( $context = 'view' ) {
1197
+        return $this->get_prop( 'vat_rate', $context );
1099 1198
     }
1100 1199
 
1101 1200
     /**
1102
-	 * Alias of self::get_zip().
1103
-	 *
1104
-	 * @since 1.0.19
1105
-	 * @param  string $context View or edit context.
1106
-	 * @return string
1107
-	 */
1108
-	public function get_user_zip( $context = 'view' ) {
1109
-		return $this->get_zip( $context );
1201
+     * Alias of self::get_vat_rate().
1202
+     *
1203
+     * @since 1.0.19
1204
+     * @param  string $context View or edit context.
1205
+     * @return string
1206
+     */
1207
+    public function get_user_vat_rate( $context = 'view' ) {
1208
+        return $this->get_vat_rate( $context );
1110 1209
     }
1111 1210
 
1112 1211
     /**
1113
-	 * Alias of self::get_zip().
1114
-	 *
1115
-	 * @since 1.0.19
1116
-	 * @param  string $context View or edit context.
1117
-	 * @return string
1118
-	 */
1119
-	public function get_customer_zip( $context = 'view' ) {
1120
-		return $this->get_zip( $context );
1212
+     * Alias of self::get_vat_rate().
1213
+     *
1214
+     * @since 1.0.19
1215
+     * @param  string $context View or edit context.
1216
+     * @return string
1217
+     */
1218
+    public function get_customer_vat_rate( $context = 'view' ) {
1219
+        return $this->get_vat_rate( $context );
1121 1220
     }
1122 1221
 
1123 1222
     /**
1124
-	 * Get the customer's company.
1125
-	 *
1126
-	 * @since 1.0.19
1127
-	 * @param  string $context View or edit context.
1128
-	 * @return string
1129
-	 */
1130
-	public function get_company( $context = 'view' ) {
1131
-		return $this->get_prop( 'company', $context );
1223
+     * Get the customer's address.
1224
+     *
1225
+     * @since 1.0.19
1226
+     * @param  string $context View or edit context.
1227
+     * @return string
1228
+     */
1229
+    public function get_address( $context = 'view' ) {
1230
+        return $this->get_prop( 'address', $context );
1132 1231
     }
1133 1232
 
1134 1233
     /**
1135
-	 * Alias of self::get_company().
1136
-	 *
1137
-	 * @since 1.0.19
1138
-	 * @param  string $context View or edit context.
1139
-	 * @return string
1140
-	 */
1141
-	public function get_user_company( $context = 'view' ) {
1142
-		return $this->get_company( $context );
1234
+     * Alias of self::get_address().
1235
+     *
1236
+     * @since 1.0.19
1237
+     * @param  string $context View or edit context.
1238
+     * @return string
1239
+     */
1240
+    public function get_user_address( $context = 'view' ) {
1241
+        return $this->get_address( $context );
1143 1242
     }
1144 1243
 
1145 1244
     /**
1146
-	 * Alias of self::get_company().
1147
-	 *
1148
-	 * @since 1.0.19
1149
-	 * @param  string $context View or edit context.
1150
-	 * @return string
1151
-	 */
1152
-	public function get_customer_company( $context = 'view' ) {
1153
-		return $this->get_company( $context );
1245
+     * Alias of self::get_address().
1246
+     *
1247
+     * @since 1.0.19
1248
+     * @param  string $context View or edit context.
1249
+     * @return string
1250
+     */
1251
+    public function get_customer_address( $context = 'view' ) {
1252
+        return $this->get_address( $context );
1154 1253
     }
1155 1254
 
1156 1255
     /**
1157
-	 * Get the customer's vat number.
1158
-	 *
1159
-	 * @since 1.0.19
1160
-	 * @param  string $context View or edit context.
1161
-	 * @return string
1162
-	 */
1163
-	public function get_vat_number( $context = 'view' ) {
1164
-		return $this->get_prop( 'vat_number', $context );
1256
+     * Get whether the customer has viewed the invoice or not.
1257
+     *
1258
+     * @since 1.0.19
1259
+     * @param  string $context View or edit context.
1260
+     * @return bool
1261
+     */
1262
+    public function get_is_viewed( $context = 'view' ) {
1263
+        return (bool) $this->get_prop( 'is_viewed', $context );
1165 1264
     }
1166 1265
 
1167 1266
     /**
1168
-	 * Alias of self::get_vat_number().
1169
-	 *
1170
-	 * @since 1.0.19
1171
-	 * @param  string $context View or edit context.
1172
-	 * @return string
1173
-	 */
1174
-	public function get_user_vat_number( $context = 'view' ) {
1175
-		return $this->get_vat_number( $context );
1267
+     * Get other recipients for invoice communications.
1268
+     *
1269
+     * @since 1.0.19
1270
+     * @param  string $context View or edit context.
1271
+     * @return bool
1272
+     */
1273
+    public function get_email_cc( $context = 'view' ) {
1274
+        return $this->get_prop( 'email_cc', $context );
1176 1275
     }
1177 1276
 
1178 1277
     /**
1179
-	 * Alias of self::get_vat_number().
1180
-	 *
1181
-	 * @since 1.0.19
1182
-	 * @param  string $context View or edit context.
1183
-	 * @return string
1184
-	 */
1185
-	public function get_customer_vat_number( $context = 'view' ) {
1186
-		return $this->get_vat_number( $context );
1278
+     * Get invoice template.
1279
+     *
1280
+     * @since 1.0.19
1281
+     * @param  string $context View or edit context.
1282
+     * @return bool
1283
+     */
1284
+    public function get_template( $context = 'view' ) {
1285
+        return $this->get_prop( 'template', $context );
1187 1286
     }
1188 1287
 
1189 1288
     /**
1190
-	 * Get the customer's vat rate.
1191
-	 *
1192
-	 * @since 1.0.19
1193
-	 * @param  string $context View or edit context.
1194
-	 * @return string
1195
-	 */
1196
-	public function get_vat_rate( $context = 'view' ) {
1197
-		return $this->get_prop( 'vat_rate', $context );
1289
+     * Get whether the customer has confirmed their address.
1290
+     *
1291
+     * @since 1.0.19
1292
+     * @param  string $context View or edit context.
1293
+     * @return bool
1294
+     */
1295
+    public function get_address_confirmed( $context = 'view' ) {
1296
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1198 1297
     }
1199 1298
 
1200 1299
     /**
1201
-	 * Alias of self::get_vat_rate().
1202
-	 *
1203
-	 * @since 1.0.19
1204
-	 * @param  string $context View or edit context.
1205
-	 * @return string
1206
-	 */
1207
-	public function get_user_vat_rate( $context = 'view' ) {
1208
-		return $this->get_vat_rate( $context );
1300
+     * Alias of self::get_address_confirmed().
1301
+     *
1302
+     * @since 1.0.19
1303
+     * @param  string $context View or edit context.
1304
+     * @return bool
1305
+     */
1306
+    public function get_user_address_confirmed( $context = 'view' ) {
1307
+        return $this->get_address_confirmed( $context );
1209 1308
     }
1210 1309
 
1211 1310
     /**
1212
-	 * Alias of self::get_vat_rate().
1213
-	 *
1214
-	 * @since 1.0.19
1215
-	 * @param  string $context View or edit context.
1216
-	 * @return string
1217
-	 */
1218
-	public function get_customer_vat_rate( $context = 'view' ) {
1219
-		return $this->get_vat_rate( $context );
1311
+     * Alias of self::get_address().
1312
+     *
1313
+     * @since 1.0.19
1314
+     * @param  string $context View or edit context.
1315
+     * @return bool
1316
+     */
1317
+    public function get_customer_address_confirmed( $context = 'view' ) {
1318
+        return $this->get_address_confirmed( $context );
1220 1319
     }
1221 1320
 
1222 1321
     /**
1223
-	 * Get the customer's address.
1224
-	 *
1225
-	 * @since 1.0.19
1226
-	 * @param  string $context View or edit context.
1227
-	 * @return string
1228
-	 */
1229
-	public function get_address( $context = 'view' ) {
1230
-		return $this->get_prop( 'address', $context );
1231
-    }
1232
-
1233
-    /**
1234
-	 * Alias of self::get_address().
1235
-	 *
1236
-	 * @since 1.0.19
1237
-	 * @param  string $context View or edit context.
1238
-	 * @return string
1239
-	 */
1240
-	public function get_user_address( $context = 'view' ) {
1241
-		return $this->get_address( $context );
1242
-    }
1243
-
1244
-    /**
1245
-	 * Alias of self::get_address().
1246
-	 *
1247
-	 * @since 1.0.19
1248
-	 * @param  string $context View or edit context.
1249
-	 * @return string
1250
-	 */
1251
-	public function get_customer_address( $context = 'view' ) {
1252
-		return $this->get_address( $context );
1253
-    }
1254
-
1255
-    /**
1256
-	 * Get whether the customer has viewed the invoice or not.
1257
-	 *
1258
-	 * @since 1.0.19
1259
-	 * @param  string $context View or edit context.
1260
-	 * @return bool
1261
-	 */
1262
-	public function get_is_viewed( $context = 'view' ) {
1263
-		return (bool) $this->get_prop( 'is_viewed', $context );
1264
-	}
1265
-
1266
-	/**
1267
-	 * Get other recipients for invoice communications.
1268
-	 *
1269
-	 * @since 1.0.19
1270
-	 * @param  string $context View or edit context.
1271
-	 * @return bool
1272
-	 */
1273
-	public function get_email_cc( $context = 'view' ) {
1274
-		return $this->get_prop( 'email_cc', $context );
1275
-	}
1276
-
1277
-	/**
1278
-	 * Get invoice template.
1279
-	 *
1280
-	 * @since 1.0.19
1281
-	 * @param  string $context View or edit context.
1282
-	 * @return bool
1283
-	 */
1284
-	public function get_template( $context = 'view' ) {
1285
-		return $this->get_prop( 'template', $context );
1286
-	}
1287
-
1288
-	/**
1289
-	 * Get whether the customer has confirmed their address.
1290
-	 *
1291
-	 * @since 1.0.19
1292
-	 * @param  string $context View or edit context.
1293
-	 * @return bool
1294
-	 */
1295
-	public function get_address_confirmed( $context = 'view' ) {
1296
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1297
-    }
1298
-
1299
-    /**
1300
-	 * Alias of self::get_address_confirmed().
1301
-	 *
1302
-	 * @since 1.0.19
1303
-	 * @param  string $context View or edit context.
1304
-	 * @return bool
1305
-	 */
1306
-	public function get_user_address_confirmed( $context = 'view' ) {
1307
-		return $this->get_address_confirmed( $context );
1308
-    }
1309
-
1310
-    /**
1311
-	 * Alias of self::get_address().
1312
-	 *
1313
-	 * @since 1.0.19
1314
-	 * @param  string $context View or edit context.
1315
-	 * @return bool
1316
-	 */
1317
-	public function get_customer_address_confirmed( $context = 'view' ) {
1318
-		return $this->get_address_confirmed( $context );
1319
-    }
1320
-
1321
-    /**
1322
-	 * Get the invoice subtotal.
1323
-	 *
1324
-	 * @since 1.0.19
1325
-	 * @param  string $context View or edit context.
1326
-	 * @return float
1327
-	 */
1328
-	public function get_subtotal( $context = 'view' ) {
1322
+     * Get the invoice subtotal.
1323
+     *
1324
+     * @since 1.0.19
1325
+     * @param  string $context View or edit context.
1326
+     * @return float
1327
+     */
1328
+    public function get_subtotal( $context = 'view' ) {
1329 1329
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1330 1330
 
1331 1331
         // Backwards compatibility.
@@ -1337,165 +1337,165 @@  discard block
 block discarded – undo
1337 1337
     }
1338 1338
 
1339 1339
     /**
1340
-	 * Get the invoice discount total.
1341
-	 *
1342
-	 * @since 1.0.19
1343
-	 * @param  string $context View or edit context.
1344
-	 * @return float
1345
-	 */
1346
-	public function get_total_discount( $context = 'view' ) {
1347
-		return (float) $this->get_prop( 'total_discount', $context );
1340
+     * Get the invoice discount total.
1341
+     *
1342
+     * @since 1.0.19
1343
+     * @param  string $context View or edit context.
1344
+     * @return float
1345
+     */
1346
+    public function get_total_discount( $context = 'view' ) {
1347
+        return (float) $this->get_prop( 'total_discount', $context );
1348 1348
     }
1349 1349
 
1350 1350
     /**
1351
-	 * Get the invoice tax total.
1352
-	 *
1353
-	 * @since 1.0.19
1354
-	 * @param  string $context View or edit context.
1355
-	 * @return float
1356
-	 */
1357
-	public function get_total_tax( $context = 'view' ) {
1358
-		return (float) $this->get_prop( 'total_tax', $context );
1359
-	}
1351
+     * Get the invoice tax total.
1352
+     *
1353
+     * @since 1.0.19
1354
+     * @param  string $context View or edit context.
1355
+     * @return float
1356
+     */
1357
+    public function get_total_tax( $context = 'view' ) {
1358
+        return (float) $this->get_prop( 'total_tax', $context );
1359
+    }
1360 1360
 
1361
-	/**
1362
-	 * @deprecated
1363
-	 */
1364
-	public function get_final_tax( $currency = false ) {
1365
-		$tax = $this->get_total_tax();
1361
+    /**
1362
+     * @deprecated
1363
+     */
1364
+    public function get_final_tax( $currency = false ) {
1365
+        $tax = $this->get_total_tax();
1366 1366
 
1367 1367
         if ( $currency ) {
1368
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1368
+            return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1369 1369
         }
1370 1370
 
1371 1371
         return $tax;
1372 1372
     }
1373 1373
 
1374 1374
     /**
1375
-	 * Get the invoice fees total.
1376
-	 *
1377
-	 * @since 1.0.19
1378
-	 * @param  string $context View or edit context.
1379
-	 * @return float
1380
-	 */
1381
-	public function get_total_fees( $context = 'view' ) {
1382
-		return (float) $this->get_prop( 'total_fees', $context );
1375
+     * Get the invoice fees total.
1376
+     *
1377
+     * @since 1.0.19
1378
+     * @param  string $context View or edit context.
1379
+     * @return float
1380
+     */
1381
+    public function get_total_fees( $context = 'view' ) {
1382
+        return (float) $this->get_prop( 'total_fees', $context );
1383 1383
     }
1384 1384
 
1385 1385
     /**
1386
-	 * Alias for self::get_total_fees().
1387
-	 *
1388
-	 * @since 1.0.19
1389
-	 * @param  string $context View or edit context.
1390
-	 * @return float
1391
-	 */
1392
-	public function get_fees_total( $context = 'view' ) {
1393
-		return $this->get_total_fees( $context );
1386
+     * Alias for self::get_total_fees().
1387
+     *
1388
+     * @since 1.0.19
1389
+     * @param  string $context View or edit context.
1390
+     * @return float
1391
+     */
1392
+    public function get_fees_total( $context = 'view' ) {
1393
+        return $this->get_total_fees( $context );
1394 1394
     }
1395 1395
 
1396 1396
     /**
1397
-	 * Get the invoice total.
1398
-	 *
1399
-	 * @since 1.0.19
1397
+     * Get the invoice total.
1398
+     *
1399
+     * @since 1.0.19
1400 1400
      * @return float
1401
-	 */
1402
-	public function get_total() {
1403
-		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1404
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1405
-	}
1401
+     */
1402
+    public function get_total() {
1403
+        $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1404
+        return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1405
+    }
1406 1406
 	
1407
-	/**
1408
-	 * Get the invoice totals.
1409
-	 *
1410
-	 * @since 1.0.19
1407
+    /**
1408
+     * Get the invoice totals.
1409
+     *
1410
+     * @since 1.0.19
1411 1411
      * @return float
1412
-	 */
1413
-	public function get_totals() {
1414
-		return $this->totals;
1412
+     */
1413
+    public function get_totals() {
1414
+        return $this->totals;
1415 1415
     }
1416 1416
 
1417 1417
     /**
1418
-	 * Get the initial invoice total.
1419
-	 *
1420
-	 * @since 1.0.19
1418
+     * Get the initial invoice total.
1419
+     *
1420
+     * @since 1.0.19
1421 1421
      * @param  string $context View or edit context.
1422 1422
      * @return float
1423
-	 */
1423
+     */
1424 1424
     public function get_initial_total() {
1425 1425
 
1426
-		if ( empty( $this->totals ) ) {
1427
-			$this->recalculate_total();
1428
-		}
1426
+        if ( empty( $this->totals ) ) {
1427
+            $this->recalculate_total();
1428
+        }
1429 1429
 
1430
-		$tax      = $this->totals['tax']['initial'];
1431
-		$fee      = $this->totals['fee']['initial'];
1432
-		$discount = $this->totals['discount']['initial'];
1433
-		$subtotal = $this->totals['subtotal']['initial'];
1434
-		$total    = $tax + $fee - $discount + $subtotal;
1430
+        $tax      = $this->totals['tax']['initial'];
1431
+        $fee      = $this->totals['fee']['initial'];
1432
+        $discount = $this->totals['discount']['initial'];
1433
+        $subtotal = $this->totals['subtotal']['initial'];
1434
+        $total    = $tax + $fee - $discount + $subtotal;
1435 1435
 
1436
-		if ( 0 > $total ) {
1437
-			$total = 0;
1438
-		}
1436
+        if ( 0 > $total ) {
1437
+            $total = 0;
1438
+        }
1439 1439
 
1440 1440
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1441
-	}
1441
+    }
1442 1442
 
1443
-	/**
1444
-	 * Get the recurring invoice total.
1445
-	 *
1446
-	 * @since 1.0.19
1443
+    /**
1444
+     * Get the recurring invoice total.
1445
+     *
1446
+     * @since 1.0.19
1447 1447
      * @param  string $context View or edit context.
1448 1448
      * @return float
1449
-	 */
1449
+     */
1450 1450
     public function get_recurring_total() {
1451 1451
 
1452
-		if ( empty( $this->totals ) ) {
1453
-			$this->recalculate_total();
1454
-		}
1452
+        if ( empty( $this->totals ) ) {
1453
+            $this->recalculate_total();
1454
+        }
1455 1455
 
1456
-		$tax      = $this->totals['tax']['recurring'];
1457
-		$fee      = $this->totals['fee']['recurring'];
1458
-		$discount = $this->totals['discount']['recurring'];
1459
-		$subtotal = $this->totals['subtotal']['recurring'];
1460
-		$total    = $tax + $fee - $discount + $subtotal;
1456
+        $tax      = $this->totals['tax']['recurring'];
1457
+        $fee      = $this->totals['fee']['recurring'];
1458
+        $discount = $this->totals['discount']['recurring'];
1459
+        $subtotal = $this->totals['subtotal']['recurring'];
1460
+        $total    = $tax + $fee - $discount + $subtotal;
1461 1461
 
1462
-		if ( 0 > $total ) {
1463
-			$total = 0;
1464
-		}
1462
+        if ( 0 > $total ) {
1463
+            $total = 0;
1464
+        }
1465 1465
 
1466 1466
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1467
-	}
1467
+    }
1468 1468
 
1469
-	/**
1470
-	 * Returns recurring payment details.
1471
-	 *
1472
-	 * @since 1.0.19
1469
+    /**
1470
+     * Returns recurring payment details.
1471
+     *
1472
+     * @since 1.0.19
1473 1473
      * @param  string $field Optionally provide a field to return.
1474
-	 * @param string $currency Whether to include the currency.
1474
+     * @param string $currency Whether to include the currency.
1475 1475
      * @return float
1476
-	 */
1476
+     */
1477 1477
     public function get_recurring_details( $field = '', $currency = false ) {
1478 1478
 
1479
-		// Maybe recalculate totals.
1480
-		if ( empty( $this->totals ) ) {
1481
-			$this->recalculate_total();
1482
-		}
1479
+        // Maybe recalculate totals.
1480
+        if ( empty( $this->totals ) ) {
1481
+            $this->recalculate_total();
1482
+        }
1483 1483
 
1484
-		// Prepare recurring totals.
1484
+        // Prepare recurring totals.
1485 1485
         $data = apply_filters(
1486
-			'wpinv_get_invoice_recurring_details',
1487
-			array(
1488
-				'cart_details' => $this->get_cart_details(),
1489
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1490
-				'discount'     => $this->totals['discount']['recurring'],
1491
-				'tax'          => $this->totals['tax']['recurring'],
1492
-				'fee'          => $this->totals['fee']['recurring'],
1493
-				'total'        => $this->get_recurring_total(),
1494
-			),
1495
-			$this,
1496
-			$field,
1497
-			$currency
1498
-		);
1486
+            'wpinv_get_invoice_recurring_details',
1487
+            array(
1488
+                'cart_details' => $this->get_cart_details(),
1489
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1490
+                'discount'     => $this->totals['discount']['recurring'],
1491
+                'tax'          => $this->totals['tax']['recurring'],
1492
+                'fee'          => $this->totals['fee']['recurring'],
1493
+                'total'        => $this->get_recurring_total(),
1494
+            ),
1495
+            $this,
1496
+            $field,
1497
+            $currency
1498
+        );
1499 1499
 
1500 1500
         if ( isset( $data[$field] ) ) {
1501 1501
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1505,156 +1505,156 @@  discard block
 block discarded – undo
1505 1505
     }
1506 1506
 
1507 1507
     /**
1508
-	 * Get the invoice fees.
1509
-	 *
1510
-	 * @since 1.0.19
1511
-	 * @param  string $context View or edit context.
1512
-	 * @return array
1513
-	 */
1514
-	public function get_fees( $context = 'view' ) {
1515
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1508
+     * Get the invoice fees.
1509
+     *
1510
+     * @since 1.0.19
1511
+     * @param  string $context View or edit context.
1512
+     * @return array
1513
+     */
1514
+    public function get_fees( $context = 'view' ) {
1515
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1516 1516
     }
1517 1517
 
1518 1518
     /**
1519
-	 * Get the invoice discounts.
1520
-	 *
1521
-	 * @since 1.0.19
1522
-	 * @param  string $context View or edit context.
1523
-	 * @return array
1524
-	 */
1525
-	public function get_discounts( $context = 'view' ) {
1526
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1519
+     * Get the invoice discounts.
1520
+     *
1521
+     * @since 1.0.19
1522
+     * @param  string $context View or edit context.
1523
+     * @return array
1524
+     */
1525
+    public function get_discounts( $context = 'view' ) {
1526
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1527 1527
     }
1528 1528
 
1529 1529
     /**
1530
-	 * Get the invoice taxes.
1531
-	 *
1532
-	 * @since 1.0.19
1533
-	 * @param  string $context View or edit context.
1534
-	 * @return array
1535
-	 */
1536
-	public function get_taxes( $context = 'view' ) {
1537
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1530
+     * Get the invoice taxes.
1531
+     *
1532
+     * @since 1.0.19
1533
+     * @param  string $context View or edit context.
1534
+     * @return array
1535
+     */
1536
+    public function get_taxes( $context = 'view' ) {
1537
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1538 1538
     }
1539 1539
 
1540 1540
     /**
1541
-	 * Get the invoice items.
1542
-	 *
1543
-	 * @since 1.0.19
1544
-	 * @param  string $context View or edit context.
1545
-	 * @return GetPaid_Form_Item[]
1546
-	 */
1547
-	public function get_items( $context = 'view' ) {
1541
+     * Get the invoice items.
1542
+     *
1543
+     * @since 1.0.19
1544
+     * @param  string $context View or edit context.
1545
+     * @return GetPaid_Form_Item[]
1546
+     */
1547
+    public function get_items( $context = 'view' ) {
1548 1548
         return $this->get_prop( 'items', $context );
1549 1549
     }
1550 1550
 
1551 1551
     /**
1552
-	 * Get the invoice's payment form.
1553
-	 *
1554
-	 * @since 1.0.19
1555
-	 * @param  string $context View or edit context.
1556
-	 * @return int
1557
-	 */
1558
-	public function get_payment_form( $context = 'view' ) {
1559
-		return intval( $this->get_prop( 'payment_form', $context ) );
1552
+     * Get the invoice's payment form.
1553
+     *
1554
+     * @since 1.0.19
1555
+     * @param  string $context View or edit context.
1556
+     * @return int
1557
+     */
1558
+    public function get_payment_form( $context = 'view' ) {
1559
+        return intval( $this->get_prop( 'payment_form', $context ) );
1560 1560
     }
1561 1561
 
1562 1562
     /**
1563
-	 * Get the invoice's submission id.
1564
-	 *
1565
-	 * @since 1.0.19
1566
-	 * @param  string $context View or edit context.
1567
-	 * @return string
1568
-	 */
1569
-	public function get_submission_id( $context = 'view' ) {
1570
-		return $this->get_prop( 'submission_id', $context );
1563
+     * Get the invoice's submission id.
1564
+     *
1565
+     * @since 1.0.19
1566
+     * @param  string $context View or edit context.
1567
+     * @return string
1568
+     */
1569
+    public function get_submission_id( $context = 'view' ) {
1570
+        return $this->get_prop( 'submission_id', $context );
1571 1571
     }
1572 1572
 
1573 1573
     /**
1574
-	 * Get the invoice's discount code.
1575
-	 *
1576
-	 * @since 1.0.19
1577
-	 * @param  string $context View or edit context.
1578
-	 * @return string
1579
-	 */
1580
-	public function get_discount_code( $context = 'view' ) {
1581
-		return $this->get_prop( 'discount_code', $context );
1574
+     * Get the invoice's discount code.
1575
+     *
1576
+     * @since 1.0.19
1577
+     * @param  string $context View or edit context.
1578
+     * @return string
1579
+     */
1580
+    public function get_discount_code( $context = 'view' ) {
1581
+        return $this->get_prop( 'discount_code', $context );
1582 1582
     }
1583 1583
 
1584 1584
     /**
1585
-	 * Get the invoice's gateway.
1586
-	 *
1587
-	 * @since 1.0.19
1588
-	 * @param  string $context View or edit context.
1589
-	 * @return string
1590
-	 */
1591
-	public function get_gateway( $context = 'view' ) {
1592
-		return $this->get_prop( 'gateway', $context );
1585
+     * Get the invoice's gateway.
1586
+     *
1587
+     * @since 1.0.19
1588
+     * @param  string $context View or edit context.
1589
+     * @return string
1590
+     */
1591
+    public function get_gateway( $context = 'view' ) {
1592
+        return $this->get_prop( 'gateway', $context );
1593 1593
     }
1594 1594
 
1595 1595
     /**
1596
-	 * Get the invoice's gateway display title.
1597
-	 *
1598
-	 * @since 1.0.19
1599
-	 * @return string
1600
-	 */
1596
+     * Get the invoice's gateway display title.
1597
+     *
1598
+     * @since 1.0.19
1599
+     * @return string
1600
+     */
1601 1601
     public function get_gateway_title() {
1602 1602
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1603 1603
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1604 1604
     }
1605 1605
 
1606 1606
     /**
1607
-	 * Get the invoice's transaction id.
1608
-	 *
1609
-	 * @since 1.0.19
1610
-	 * @param  string $context View or edit context.
1611
-	 * @return string
1612
-	 */
1613
-	public function get_transaction_id( $context = 'view' ) {
1614
-		return $this->get_prop( 'transaction_id', $context );
1607
+     * Get the invoice's transaction id.
1608
+     *
1609
+     * @since 1.0.19
1610
+     * @param  string $context View or edit context.
1611
+     * @return string
1612
+     */
1613
+    public function get_transaction_id( $context = 'view' ) {
1614
+        return $this->get_prop( 'transaction_id', $context );
1615 1615
     }
1616 1616
 
1617 1617
     /**
1618
-	 * Get the invoice's currency.
1619
-	 *
1620
-	 * @since 1.0.19
1621
-	 * @param  string $context View or edit context.
1622
-	 * @return string
1623
-	 */
1624
-	public function get_currency( $context = 'view' ) {
1618
+     * Get the invoice's currency.
1619
+     *
1620
+     * @since 1.0.19
1621
+     * @param  string $context View or edit context.
1622
+     * @return string
1623
+     */
1624
+    public function get_currency( $context = 'view' ) {
1625 1625
         $currency = $this->get_prop( 'currency', $context );
1626 1626
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1627 1627
     }
1628 1628
 
1629 1629
     /**
1630
-	 * Checks if we are charging taxes for this invoice.
1631
-	 *
1632
-	 * @since 1.0.19
1633
-	 * @param  string $context View or edit context.
1634
-	 * @return bool
1635
-	 */
1636
-	public function get_disable_taxes( $context = 'view' ) {
1630
+     * Checks if we are charging taxes for this invoice.
1631
+     *
1632
+     * @since 1.0.19
1633
+     * @param  string $context View or edit context.
1634
+     * @return bool
1635
+     */
1636
+    public function get_disable_taxes( $context = 'view' ) {
1637 1637
         return (bool) $this->get_prop( 'disable_taxes', $context );
1638 1638
     }
1639 1639
 
1640 1640
     /**
1641
-	 * Retrieves the subscription id for an invoice.
1642
-	 *
1643
-	 * @since 1.0.19
1644
-	 * @param  string $context View or edit context.
1645
-	 * @return int
1646
-	 */
1641
+     * Retrieves the subscription id for an invoice.
1642
+     *
1643
+     * @since 1.0.19
1644
+     * @param  string $context View or edit context.
1645
+     * @return int
1646
+     */
1647 1647
     public function get_subscription_id( $context = 'view' ) {
1648
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1649
-	}
1650
-
1651
-	/**
1652
-	 * Retrieves the remote subscription id for an invoice.
1653
-	 *
1654
-	 * @since 1.0.19
1655
-	 * @param  string $context View or edit context.
1656
-	 * @return int
1657
-	 */
1648
+        return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1649
+    }
1650
+
1651
+    /**
1652
+     * Retrieves the remote subscription id for an invoice.
1653
+     *
1654
+     * @since 1.0.19
1655
+     * @param  string $context View or edit context.
1656
+     * @return int
1657
+     */
1658 1658
     public function get_remote_subscription_id( $context = 'view' ) {
1659 1659
         $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1660 1660
 
@@ -1667,12 +1667,12 @@  discard block
 block discarded – undo
1667 1667
     }
1668 1668
 
1669 1669
     /**
1670
-	 * Retrieves the payment meta for an invoice.
1671
-	 *
1672
-	 * @since 1.0.19
1673
-	 * @param  string $context View or edit context.
1674
-	 * @return array
1675
-	 */
1670
+     * Retrieves the payment meta for an invoice.
1671
+     *
1672
+     * @since 1.0.19
1673
+     * @param  string $context View or edit context.
1674
+     * @return array
1675
+     */
1676 1676
     public function get_payment_meta( $context = 'view' ) {
1677 1677
 
1678 1678
         return array(
@@ -1692,31 +1692,31 @@  discard block
 block discarded – undo
1692 1692
     }
1693 1693
 
1694 1694
     /**
1695
-	 * Retrieves the cart details for an invoice.
1696
-	 *
1697
-	 * @since 1.0.19
1698
-	 * @return array
1699
-	 */
1695
+     * Retrieves the cart details for an invoice.
1696
+     *
1697
+     * @since 1.0.19
1698
+     * @return array
1699
+     */
1700 1700
     public function get_cart_details() {
1701 1701
         $items        = $this->get_items();
1702 1702
         $cart_details = array();
1703 1703
 
1704 1704
         foreach ( $items as $item_id => $item ) {
1705
-			$item->invoice_id = $this->get_id();
1705
+            $item->invoice_id = $this->get_id();
1706 1706
             $cart_details[]   = $item->prepare_data_for_saving();
1707 1707
         }
1708 1708
 
1709 1709
         return $cart_details;
1710
-	}
1710
+    }
1711 1711
 
1712
-	/**
1713
-	 * Retrieves the recurring item.
1714
-	 *
1715
-	 * @return null|GetPaid_Form_Item|int
1716
-	 */
1717
-	public function get_recurring( $object = false ) {
1712
+    /**
1713
+     * Retrieves the recurring item.
1714
+     *
1715
+     * @return null|GetPaid_Form_Item|int
1716
+     */
1717
+    public function get_recurring( $object = false ) {
1718 1718
 
1719
-		// Are we returning an object?
1719
+        // Are we returning an object?
1720 1720
         if ( $object ) {
1721 1721
             return $this->get_item( $this->recurring_item );
1722 1722
         }
@@ -1724,100 +1724,100 @@  discard block
 block discarded – undo
1724 1724
         return $this->recurring_item;
1725 1725
     }
1726 1726
 
1727
-	/**
1728
-	 * Retrieves the subscription name.
1729
-	 *
1730
-	 * @since 1.0.19
1731
-	 * @return string
1732
-	 */
1733
-	public function get_subscription_name() {
1727
+    /**
1728
+     * Retrieves the subscription name.
1729
+     *
1730
+     * @since 1.0.19
1731
+     * @return string
1732
+     */
1733
+    public function get_subscription_name() {
1734 1734
 
1735
-		// Retrieve the recurring name
1735
+        // Retrieve the recurring name
1736 1736
         $item = $this->get_recurring( true );
1737 1737
 
1738
-		// Abort if it does not exist.
1738
+        // Abort if it does not exist.
1739 1739
         if ( empty( $item ) ) {
1740 1740
             return '';
1741 1741
         }
1742 1742
 
1743
-		// Return the item name.
1743
+        // Return the item name.
1744 1744
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1745
-	}
1746
-
1747
-	/**
1748
-	 * Retrieves the view url.
1749
-	 *
1750
-	 * @since 1.0.19
1751
-	 * @return string
1752
-	 */
1753
-	public function get_view_url() {
1745
+    }
1746
+
1747
+    /**
1748
+     * Retrieves the view url.
1749
+     *
1750
+     * @since 1.0.19
1751
+     * @return string
1752
+     */
1753
+    public function get_view_url() {
1754 1754
         $invoice_url = get_permalink( $this->get_id() );
1755
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1755
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1756 1756
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1757
-	}
1757
+    }
1758 1758
 
1759
-	/**
1760
-	 * Retrieves the payment url.
1761
-	 *
1762
-	 * @since 1.0.19
1763
-	 * @return string
1764
-	 */
1765
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1759
+    /**
1760
+     * Retrieves the payment url.
1761
+     *
1762
+     * @since 1.0.19
1763
+     * @return string
1764
+     */
1765
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1766 1766
 
1767
-		// Retrieve the checkout url.
1767
+        // Retrieve the checkout url.
1768 1768
         $pay_url = wpinv_get_checkout_uri();
1769 1769
 
1770
-		// Maybe force ssl.
1770
+        // Maybe force ssl.
1771 1771
         if ( is_ssl() ) {
1772 1772
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1773 1773
         }
1774 1774
 
1775
-		// Add the invoice key.
1776
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1775
+        // Add the invoice key.
1776
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1777 1777
 
1778
-		// (Maybe?) add a secret
1778
+        // (Maybe?) add a secret
1779 1779
         if ( $secret ) {
1780 1780
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1781 1781
         }
1782 1782
 
1783 1783
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1784
-	}
1784
+    }
1785 1785
 	
1786
-	/**
1787
-	 * Retrieves the receipt url.
1788
-	 *
1789
-	 * @since 1.0.19
1790
-	 * @return string
1791
-	 */
1792
-	public function get_receipt_url() {
1793
-
1794
-		// Retrieve the checkout url.
1786
+    /**
1787
+     * Retrieves the receipt url.
1788
+     *
1789
+     * @since 1.0.19
1790
+     * @return string
1791
+     */
1792
+    public function get_receipt_url() {
1793
+
1794
+        // Retrieve the checkout url.
1795 1795
         $receipt_url = wpinv_get_success_page_uri();
1796 1796
 
1797
-		// Maybe force ssl.
1797
+        // Maybe force ssl.
1798 1798
         if ( is_ssl() ) {
1799 1799
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1800 1800
         }
1801 1801
 
1802
-		// Add the invoice key.
1803
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1802
+        // Add the invoice key.
1803
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1804 1804
 
1805 1805
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1806 1806
     }
1807 1807
 
1808 1808
     /**
1809
-	 * Magic method for accessing invoice properties.
1810
-	 *
1811
-	 * @since 1.0.15
1812
-	 * @access public
1813
-	 *
1814
-	 * @param string $key Discount data to retrieve
1815
-	 * @param  string $context View or edit context.
1816
-	 * @return mixed Value of the given invoice property (if set).
1817
-	 */
1818
-	public function get( $key, $context = 'view' ) {
1809
+     * Magic method for accessing invoice properties.
1810
+     *
1811
+     * @since 1.0.15
1812
+     * @access public
1813
+     *
1814
+     * @param string $key Discount data to retrieve
1815
+     * @param  string $context View or edit context.
1816
+     * @return mixed Value of the given invoice property (if set).
1817
+     */
1818
+    public function get( $key, $context = 'view' ) {
1819 1819
         return $this->get_prop( $key, $context );
1820
-	}
1820
+    }
1821 1821
 
1822 1822
     /*
1823 1823
 	|--------------------------------------------------------------------------
@@ -1830,130 +1830,130 @@  discard block
 block discarded – undo
1830 1830
     */
1831 1831
 
1832 1832
     /**
1833
-	 * Magic method for setting invoice properties.
1834
-	 *
1835
-	 * @since 1.0.19
1836
-	 * @access public
1837
-	 *
1838
-	 * @param string $key Discount data to retrieve
1839
-	 * @param  mixed $value new value.
1840
-	 * @return mixed Value of the given invoice property (if set).
1841
-	 */
1842
-	public function set( $key, $value ) {
1833
+     * Magic method for setting invoice properties.
1834
+     *
1835
+     * @since 1.0.19
1836
+     * @access public
1837
+     *
1838
+     * @param string $key Discount data to retrieve
1839
+     * @param  mixed $value new value.
1840
+     * @return mixed Value of the given invoice property (if set).
1841
+     */
1842
+    public function set( $key, $value ) {
1843 1843
 
1844 1844
         $setter = "set_$key";
1845 1845
         if ( is_callable( array( $this, $setter ) ) ) {
1846 1846
             $this->{$setter}( $value );
1847 1847
         }
1848 1848
 
1849
-	}
1849
+    }
1850 1850
 
1851
-	/**
1852
-	 * Sets item status.
1853
-	 *
1854
-	 * @since 1.0.19
1855
-	 * @param string $new_status    New status.
1856
-	 * @param string $note          Optional note to add.
1857
-	 * @param bool   $manual_update Is this a manual status change?.
1858
-	 * @return array details of change.
1859
-	 */
1860
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1861
-		$old_status = $this->get_status();
1851
+    /**
1852
+     * Sets item status.
1853
+     *
1854
+     * @since 1.0.19
1855
+     * @param string $new_status    New status.
1856
+     * @param string $note          Optional note to add.
1857
+     * @param bool   $manual_update Is this a manual status change?.
1858
+     * @return array details of change.
1859
+     */
1860
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1861
+        $old_status = $this->get_status();
1862 1862
 
1863
-		$statuses = $this->get_all_statuses();
1863
+        $statuses = $this->get_all_statuses();
1864 1864
 
1865
-		if ( isset( $statuses[ 'draft' ] ) ) {
1866
-			unset( $statuses[ 'draft' ] );
1867
-		}
1865
+        if ( isset( $statuses[ 'draft' ] ) ) {
1866
+            unset( $statuses[ 'draft' ] );
1867
+        }
1868 1868
 
1869
-		$this->set_prop( 'status', $new_status );
1869
+        $this->set_prop( 'status', $new_status );
1870 1870
 
1871
-		// If setting the status, ensure it's set to a valid status.
1872
-		if ( true === $this->object_read ) {
1871
+        // If setting the status, ensure it's set to a valid status.
1872
+        if ( true === $this->object_read ) {
1873 1873
 
1874
-			// Only allow valid new status.
1875
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1876
-				$new_status = 'wpi-pending';
1877
-			}
1874
+            // Only allow valid new status.
1875
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1876
+                $new_status = 'wpi-pending';
1877
+            }
1878 1878
 
1879
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1880
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1881
-				$old_status = 'wpi-pending';
1882
-			}
1879
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1880
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1881
+                $old_status = 'wpi-pending';
1882
+            }
1883 1883
 
1884
-			// Paid - Renewal (i.e when duplicating a parent invoice )
1885
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1886
-				$old_status = 'wpi-pending';
1887
-			}
1884
+            // Paid - Renewal (i.e when duplicating a parent invoice )
1885
+            if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1886
+                $old_status = 'wpi-pending';
1887
+            }
1888 1888
 
1889
-		}
1889
+        }
1890 1890
 
1891
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1892
-			$this->status_transition = array(
1893
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1894
-				'to'     => $new_status,
1895
-				'note'   => $note,
1896
-				'manual' => (bool) $manual_update,
1897
-			);
1891
+        if ( true === $this->object_read && $old_status !== $new_status ) {
1892
+            $this->status_transition = array(
1893
+                'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1894
+                'to'     => $new_status,
1895
+                'note'   => $note,
1896
+                'manual' => (bool) $manual_update,
1897
+            );
1898 1898
 
1899
-			if ( $manual_update ) {
1900
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1901
-			}
1899
+            if ( $manual_update ) {
1900
+                do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1901
+            }
1902 1902
 
1903
-			$this->maybe_set_date_paid();
1903
+            $this->maybe_set_date_paid();
1904 1904
 
1905
-		}
1905
+        }
1906 1906
 
1907
-		return array(
1908
-			'from' => $old_status,
1909
-			'to'   => $new_status,
1910
-		);
1911
-	}
1907
+        return array(
1908
+            'from' => $old_status,
1909
+            'to'   => $new_status,
1910
+        );
1911
+    }
1912 1912
 
1913
-	/**
1914
-	 * Maybe set date paid.
1915
-	 *
1916
-	 * Sets the date paid variable when transitioning to the payment complete
1917
-	 * order status.
1918
-	 *
1919
-	 * @since 1.0.19
1920
-	 */
1921
-	public function maybe_set_date_paid() {
1913
+    /**
1914
+     * Maybe set date paid.
1915
+     *
1916
+     * Sets the date paid variable when transitioning to the payment complete
1917
+     * order status.
1918
+     *
1919
+     * @since 1.0.19
1920
+     */
1921
+    public function maybe_set_date_paid() {
1922 1922
 
1923
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1924
-			$this->set_date_completed( current_time( 'mysql' ) );
1925
-		}
1926
-	}
1923
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1924
+            $this->set_date_completed( current_time( 'mysql' ) );
1925
+        }
1926
+    }
1927 1927
 
1928 1928
     /**
1929
-	 * Set parent invoice ID.
1930
-	 *
1931
-	 * @since 1.0.19
1932
-	 */
1933
-	public function set_parent_id( $value ) {
1934
-		if ( $value && ( $value === $this->get_id() ) ) {
1935
-			return;
1936
-		}
1937
-		$this->set_prop( 'parent_id', absint( $value ) );
1929
+     * Set parent invoice ID.
1930
+     *
1931
+     * @since 1.0.19
1932
+     */
1933
+    public function set_parent_id( $value ) {
1934
+        if ( $value && ( $value === $this->get_id() ) ) {
1935
+            return;
1936
+        }
1937
+        $this->set_prop( 'parent_id', absint( $value ) );
1938 1938
     }
1939 1939
 
1940 1940
     /**
1941
-	 * Set plugin version when the invoice was created.
1942
-	 *
1943
-	 * @since 1.0.19
1944
-	 */
1945
-	public function set_version( $value ) {
1946
-		$this->set_prop( 'version', $value );
1941
+     * Set plugin version when the invoice was created.
1942
+     *
1943
+     * @since 1.0.19
1944
+     */
1945
+    public function set_version( $value ) {
1946
+        $this->set_prop( 'version', $value );
1947 1947
     }
1948
-
1949
-    /**
1950
-	 * Set date when the invoice was created.
1951
-	 *
1952
-	 * @since 1.0.19
1953
-	 * @param string $value Value to set.
1948
+
1949
+    /**
1950
+     * Set date when the invoice was created.
1951
+     *
1952
+     * @since 1.0.19
1953
+     * @param string $value Value to set.
1954 1954
      * @return bool Whether or not the date was set.
1955
-	 */
1956
-	public function set_date_created( $value ) {
1955
+     */
1956
+    public function set_date_created( $value ) {
1957 1957
         $date = strtotime( $value );
1958 1958
 
1959 1959
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1966,13 +1966,13 @@  discard block
 block discarded – undo
1966 1966
     }
1967 1967
 
1968 1968
     /**
1969
-	 * Set date invoice due date.
1970
-	 *
1971
-	 * @since 1.0.19
1972
-	 * @param string $value Value to set.
1969
+     * Set date invoice due date.
1970
+     *
1971
+     * @since 1.0.19
1972
+     * @param string $value Value to set.
1973 1973
      * @return bool Whether or not the date was set.
1974
-	 */
1975
-	public function set_due_date( $value ) {
1974
+     */
1975
+    public function set_due_date( $value ) {
1976 1976
         $date = strtotime( $value );
1977 1977
 
1978 1978
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1980,29 +1980,29 @@  discard block
 block discarded – undo
1980 1980
             return true;
1981 1981
         }
1982 1982
 
1983
-		$this->set_prop( 'due_date', '' );
1983
+        $this->set_prop( 'due_date', '' );
1984 1984
         return false;
1985 1985
 
1986 1986
     }
1987 1987
 
1988 1988
     /**
1989
-	 * Alias of self::set_due_date().
1990
-	 *
1991
-	 * @since 1.0.19
1992
-	 * @param  string $value New name.
1993
-	 */
1994
-	public function set_date_due( $value ) {
1995
-		$this->set_due_date( $value );
1989
+     * Alias of self::set_due_date().
1990
+     *
1991
+     * @since 1.0.19
1992
+     * @param  string $value New name.
1993
+     */
1994
+    public function set_date_due( $value ) {
1995
+        $this->set_due_date( $value );
1996 1996
     }
1997 1997
 
1998 1998
     /**
1999
-	 * Set date invoice was completed.
2000
-	 *
2001
-	 * @since 1.0.19
2002
-	 * @param string $value Value to set.
1999
+     * Set date invoice was completed.
2000
+     *
2001
+     * @since 1.0.19
2002
+     * @param string $value Value to set.
2003 2003
      * @return bool Whether or not the date was set.
2004
-	 */
2005
-	public function set_completed_date( $value ) {
2004
+     */
2005
+    public function set_completed_date( $value ) {
2006 2006
         $date = strtotime( $value );
2007 2007
 
2008 2008
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -2010,29 +2010,29 @@  discard block
 block discarded – undo
2010 2010
             return true;
2011 2011
         }
2012 2012
 
2013
-		$this->set_prop( 'completed_date', '' );
2013
+        $this->set_prop( 'completed_date', '' );
2014 2014
         return false;
2015 2015
 
2016 2016
     }
2017 2017
 
2018 2018
     /**
2019
-	 * Alias of self::set_completed_date().
2020
-	 *
2021
-	 * @since 1.0.19
2022
-	 * @param  string $value New name.
2023
-	 */
2024
-	public function set_date_completed( $value ) {
2025
-		$this->set_completed_date( $value );
2019
+     * Alias of self::set_completed_date().
2020
+     *
2021
+     * @since 1.0.19
2022
+     * @param  string $value New name.
2023
+     */
2024
+    public function set_date_completed( $value ) {
2025
+        $this->set_completed_date( $value );
2026 2026
     }
2027 2027
 
2028 2028
     /**
2029
-	 * Set date when the invoice was last modified.
2030
-	 *
2031
-	 * @since 1.0.19
2032
-	 * @param string $value Value to set.
2029
+     * Set date when the invoice was last modified.
2030
+     *
2031
+     * @since 1.0.19
2032
+     * @param string $value Value to set.
2033 2033
      * @return bool Whether or not the date was set.
2034
-	 */
2035
-	public function set_date_modified( $value ) {
2034
+     */
2035
+    public function set_date_modified( $value ) {
2036 2036
         $date = strtotime( $value );
2037 2037
 
2038 2038
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -2040,706 +2040,706 @@  discard block
 block discarded – undo
2040 2040
             return true;
2041 2041
         }
2042 2042
 
2043
-		$this->set_prop( 'date_modified', '' );
2043
+        $this->set_prop( 'date_modified', '' );
2044 2044
         return false;
2045 2045
 
2046 2046
     }
2047 2047
 
2048 2048
     /**
2049
-	 * Set the invoice number.
2050
-	 *
2051
-	 * @since 1.0.19
2052
-	 * @param  string $value New number.
2053
-	 */
2054
-	public function set_number( $value ) {
2049
+     * Set the invoice number.
2050
+     *
2051
+     * @since 1.0.19
2052
+     * @param  string $value New number.
2053
+     */
2054
+    public function set_number( $value ) {
2055 2055
         $number = sanitize_text_field( $value );
2056
-		$this->set_prop( 'number', $number );
2056
+        $this->set_prop( 'number', $number );
2057 2057
     }
2058 2058
 
2059 2059
     /**
2060
-	 * Set the invoice type.
2061
-	 *
2062
-	 * @since 1.0.19
2063
-	 * @param  string $value Type.
2064
-	 */
2065
-	public function set_type( $value ) {
2060
+     * Set the invoice type.
2061
+     *
2062
+     * @since 1.0.19
2063
+     * @param  string $value Type.
2064
+     */
2065
+    public function set_type( $value ) {
2066 2066
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2067
-		$this->set_prop( 'type', $type );
2068
-	}
2067
+        $this->set_prop( 'type', $type );
2068
+    }
2069 2069
 
2070 2070
     /**
2071
-	 * Set the invoice post type.
2072
-	 *
2073
-	 * @since 1.0.19
2074
-	 * @param  string $value Post type.
2075
-	 */
2076
-	public function set_post_type( $value ) {
2071
+     * Set the invoice post type.
2072
+     *
2073
+     * @since 1.0.19
2074
+     * @param  string $value Post type.
2075
+     */
2076
+    public function set_post_type( $value ) {
2077 2077
         if ( getpaid_is_invoice_post_type( $value ) ) {
2078
-			$this->set_type( $value );
2078
+            $this->set_type( $value );
2079 2079
             $this->set_prop( 'post_type', $value );
2080 2080
         }
2081 2081
     }
2082 2082
 
2083 2083
     /**
2084
-	 * Set the invoice key.
2085
-	 *
2086
-	 * @since 1.0.19
2087
-	 * @param  string $value New key.
2088
-	 */
2089
-	public function set_key( $value ) {
2084
+     * Set the invoice key.
2085
+     *
2086
+     * @since 1.0.19
2087
+     * @param  string $value New key.
2088
+     */
2089
+    public function set_key( $value ) {
2090 2090
         $key = sanitize_text_field( $value );
2091
-		$this->set_prop( 'key', $key );
2091
+        $this->set_prop( 'key', $key );
2092 2092
     }
2093 2093
 
2094 2094
     /**
2095
-	 * Set the invoice mode.
2096
-	 *
2097
-	 * @since 1.0.19
2098
-	 * @param  string $value mode.
2099
-	 */
2100
-	public function set_mode( $value ) {
2095
+     * Set the invoice mode.
2096
+     *
2097
+     * @since 1.0.19
2098
+     * @param  string $value mode.
2099
+     */
2100
+    public function set_mode( $value ) {
2101 2101
         if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2102 2102
             $this->set_prop( 'value', $value );
2103 2103
         }
2104 2104
     }
2105 2105
 
2106 2106
     /**
2107
-	 * Set the invoice path.
2108
-	 *
2109
-	 * @since 1.0.19
2110
-	 * @param  string $value path.
2111
-	 */
2112
-	public function set_path( $value ) {
2107
+     * Set the invoice path.
2108
+     *
2109
+     * @since 1.0.19
2110
+     * @param  string $value path.
2111
+     */
2112
+    public function set_path( $value ) {
2113 2113
         $this->set_prop( 'path', $value );
2114 2114
     }
2115 2115
 
2116 2116
     /**
2117
-	 * Set the invoice name.
2118
-	 *
2119
-	 * @since 1.0.19
2120
-	 * @param  string $value New name.
2121
-	 */
2122
-	public function set_name( $value ) {
2117
+     * Set the invoice name.
2118
+     *
2119
+     * @since 1.0.19
2120
+     * @param  string $value New name.
2121
+     */
2122
+    public function set_name( $value ) {
2123 2123
         $name = sanitize_text_field( $value );
2124
-		$this->set_prop( 'name', $name );
2124
+        $this->set_prop( 'name', $name );
2125 2125
     }
2126 2126
 
2127 2127
     /**
2128
-	 * Alias of self::set_name().
2129
-	 *
2130
-	 * @since 1.0.19
2131
-	 * @param  string $value New name.
2132
-	 */
2133
-	public function set_title( $value ) {
2134
-		$this->set_name( $value );
2128
+     * Alias of self::set_name().
2129
+     *
2130
+     * @since 1.0.19
2131
+     * @param  string $value New name.
2132
+     */
2133
+    public function set_title( $value ) {
2134
+        $this->set_name( $value );
2135 2135
     }
2136 2136
 
2137 2137
     /**
2138
-	 * Set the invoice description.
2139
-	 *
2140
-	 * @since 1.0.19
2141
-	 * @param  string $value New description.
2142
-	 */
2143
-	public function set_description( $value ) {
2138
+     * Set the invoice description.
2139
+     *
2140
+     * @since 1.0.19
2141
+     * @param  string $value New description.
2142
+     */
2143
+    public function set_description( $value ) {
2144 2144
         $description = wp_kses_post( $value );
2145
-		return $this->set_prop( 'description', $description );
2145
+        return $this->set_prop( 'description', $description );
2146 2146
     }
2147 2147
 
2148 2148
     /**
2149
-	 * Alias of self::set_description().
2150
-	 *
2151
-	 * @since 1.0.19
2152
-	 * @param  string $value New description.
2153
-	 */
2154
-	public function set_excerpt( $value ) {
2155
-		$this->set_description( $value );
2149
+     * Alias of self::set_description().
2150
+     *
2151
+     * @since 1.0.19
2152
+     * @param  string $value New description.
2153
+     */
2154
+    public function set_excerpt( $value ) {
2155
+        $this->set_description( $value );
2156 2156
     }
2157 2157
 
2158 2158
     /**
2159
-	 * Alias of self::set_description().
2160
-	 *
2161
-	 * @since 1.0.19
2162
-	 * @param  string $value New description.
2163
-	 */
2164
-	public function set_summary( $value ) {
2165
-		$this->set_description( $value );
2159
+     * Alias of self::set_description().
2160
+     *
2161
+     * @since 1.0.19
2162
+     * @param  string $value New description.
2163
+     */
2164
+    public function set_summary( $value ) {
2165
+        $this->set_description( $value );
2166 2166
     }
2167 2167
 
2168 2168
     /**
2169
-	 * Set the receiver of the invoice.
2170
-	 *
2171
-	 * @since 1.0.19
2172
-	 * @param  int $value New author.
2173
-	 */
2174
-	public function set_author( $value ) {
2175
-		$user = get_user_by( 'id', (int) $value );
2169
+     * Set the receiver of the invoice.
2170
+     *
2171
+     * @since 1.0.19
2172
+     * @param  int $value New author.
2173
+     */
2174
+    public function set_author( $value ) {
2175
+        $user = get_user_by( 'id', (int) $value );
2176 2176
 
2177
-		if ( $user && $user->ID ) {
2178
-			$this->set_prop( 'author', $user->ID );
2179
-			$this->set_prop( 'email', $user->user_email );
2180
-		}
2177
+        if ( $user && $user->ID ) {
2178
+            $this->set_prop( 'author', $user->ID );
2179
+            $this->set_prop( 'email', $user->user_email );
2180
+        }
2181 2181
 		
2182 2182
     }
2183 2183
 
2184 2184
     /**
2185
-	 * Alias of self::set_author().
2186
-	 *
2187
-	 * @since 1.0.19
2188
-	 * @param  int $value New user id.
2189
-	 */
2190
-	public function set_user_id( $value ) {
2191
-		$this->set_author( $value );
2185
+     * Alias of self::set_author().
2186
+     *
2187
+     * @since 1.0.19
2188
+     * @param  int $value New user id.
2189
+     */
2190
+    public function set_user_id( $value ) {
2191
+        $this->set_author( $value );
2192
+    }
2193
+
2194
+    /**
2195
+     * Alias of self::set_author().
2196
+     *
2197
+     * @since 1.0.19
2198
+     * @param  int $value New user id.
2199
+     */
2200
+    public function set_customer_id( $value ) {
2201
+        $this->set_author( $value );
2202
+    }
2203
+
2204
+    /**
2205
+     * Set the customer's ip.
2206
+     *
2207
+     * @since 1.0.19
2208
+     * @param  string $value ip address.
2209
+     */
2210
+    public function set_ip( $value ) {
2211
+        $this->set_prop( 'ip', $value );
2212
+    }
2213
+
2214
+    /**
2215
+     * Alias of self::set_ip().
2216
+     *
2217
+     * @since 1.0.19
2218
+     * @param  string $value ip address.
2219
+     */
2220
+    public function set_user_ip( $value ) {
2221
+        $this->set_ip( $value );
2192 2222
     }
2193 2223
 
2194 2224
     /**
2195
-	 * Alias of self::set_author().
2196
-	 *
2197
-	 * @since 1.0.19
2198
-	 * @param  int $value New user id.
2199
-	 */
2200
-	public function set_customer_id( $value ) {
2201
-		$this->set_author( $value );
2225
+     * Set the customer's first name.
2226
+     *
2227
+     * @since 1.0.19
2228
+     * @param  string $value first name.
2229
+     */
2230
+    public function set_first_name( $value ) {
2231
+        $this->set_prop( 'first_name', $value );
2202 2232
     }
2203 2233
 
2204 2234
     /**
2205
-	 * Set the customer's ip.
2206
-	 *
2207
-	 * @since 1.0.19
2208
-	 * @param  string $value ip address.
2209
-	 */
2210
-	public function set_ip( $value ) {
2211
-		$this->set_prop( 'ip', $value );
2235
+     * Alias of self::set_first_name().
2236
+     *
2237
+     * @since 1.0.19
2238
+     * @param  string $value first name.
2239
+     */
2240
+    public function set_user_first_name( $value ) {
2241
+        $this->set_first_name( $value );
2212 2242
     }
2213 2243
 
2214 2244
     /**
2215
-	 * Alias of self::set_ip().
2216
-	 *
2217
-	 * @since 1.0.19
2218
-	 * @param  string $value ip address.
2219
-	 */
2220
-	public function set_user_ip( $value ) {
2221
-		$this->set_ip( $value );
2245
+     * Alias of self::set_first_name().
2246
+     *
2247
+     * @since 1.0.19
2248
+     * @param  string $value first name.
2249
+     */
2250
+    public function set_customer_first_name( $value ) {
2251
+        $this->set_first_name( $value );
2222 2252
     }
2223 2253
 
2224 2254
     /**
2225
-	 * Set the customer's first name.
2226
-	 *
2227
-	 * @since 1.0.19
2228
-	 * @param  string $value first name.
2229
-	 */
2230
-	public function set_first_name( $value ) {
2231
-		$this->set_prop( 'first_name', $value );
2255
+     * Set the customer's last name.
2256
+     *
2257
+     * @since 1.0.19
2258
+     * @param  string $value last name.
2259
+     */
2260
+    public function set_last_name( $value ) {
2261
+        $this->set_prop( 'last_name', $value );
2232 2262
     }
2233 2263
 
2234 2264
     /**
2235
-	 * Alias of self::set_first_name().
2236
-	 *
2237
-	 * @since 1.0.19
2238
-	 * @param  string $value first name.
2239
-	 */
2240
-	public function set_user_first_name( $value ) {
2241
-		$this->set_first_name( $value );
2265
+     * Alias of self::set_last_name().
2266
+     *
2267
+     * @since 1.0.19
2268
+     * @param  string $value last name.
2269
+     */
2270
+    public function set_user_last_name( $value ) {
2271
+        $this->set_last_name( $value );
2242 2272
     }
2243 2273
 
2244 2274
     /**
2245
-	 * Alias of self::set_first_name().
2246
-	 *
2247
-	 * @since 1.0.19
2248
-	 * @param  string $value first name.
2249
-	 */
2250
-	public function set_customer_first_name( $value ) {
2251
-		$this->set_first_name( $value );
2275
+     * Alias of self::set_last_name().
2276
+     *
2277
+     * @since 1.0.19
2278
+     * @param  string $value last name.
2279
+     */
2280
+    public function set_customer_last_name( $value ) {
2281
+        $this->set_last_name( $value );
2252 2282
     }
2253 2283
 
2254 2284
     /**
2255
-	 * Set the customer's last name.
2256
-	 *
2257
-	 * @since 1.0.19
2258
-	 * @param  string $value last name.
2259
-	 */
2260
-	public function set_last_name( $value ) {
2261
-		$this->set_prop( 'last_name', $value );
2285
+     * Set the customer's phone number.
2286
+     *
2287
+     * @since 1.0.19
2288
+     * @param  string $value phone.
2289
+     */
2290
+    public function set_phone( $value ) {
2291
+        $this->set_prop( 'phone', $value );
2262 2292
     }
2263 2293
 
2264 2294
     /**
2265
-	 * Alias of self::set_last_name().
2266
-	 *
2267
-	 * @since 1.0.19
2268
-	 * @param  string $value last name.
2269
-	 */
2270
-	public function set_user_last_name( $value ) {
2271
-		$this->set_last_name( $value );
2295
+     * Alias of self::set_phone().
2296
+     *
2297
+     * @since 1.0.19
2298
+     * @param  string $value phone.
2299
+     */
2300
+    public function set_user_phone( $value ) {
2301
+        $this->set_phone( $value );
2272 2302
     }
2273 2303
 
2274 2304
     /**
2275
-	 * Alias of self::set_last_name().
2276
-	 *
2277
-	 * @since 1.0.19
2278
-	 * @param  string $value last name.
2279
-	 */
2280
-	public function set_customer_last_name( $value ) {
2281
-		$this->set_last_name( $value );
2305
+     * Alias of self::set_phone().
2306
+     *
2307
+     * @since 1.0.19
2308
+     * @param  string $value phone.
2309
+     */
2310
+    public function set_customer_phone( $value ) {
2311
+        $this->set_phone( $value );
2282 2312
     }
2283 2313
 
2284 2314
     /**
2285
-	 * Set the customer's phone number.
2286
-	 *
2287
-	 * @since 1.0.19
2288
-	 * @param  string $value phone.
2289
-	 */
2290
-	public function set_phone( $value ) {
2291
-		$this->set_prop( 'phone', $value );
2315
+     * Alias of self::set_phone().
2316
+     *
2317
+     * @since 1.0.19
2318
+     * @param  string $value phone.
2319
+     */
2320
+    public function set_phone_number( $value ) {
2321
+        $this->set_phone( $value );
2292 2322
     }
2293 2323
 
2294 2324
     /**
2295
-	 * Alias of self::set_phone().
2296
-	 *
2297
-	 * @since 1.0.19
2298
-	 * @param  string $value phone.
2299
-	 */
2300
-	public function set_user_phone( $value ) {
2301
-		$this->set_phone( $value );
2325
+     * Set the customer's email address.
2326
+     *
2327
+     * @since 1.0.19
2328
+     * @param  string $value email address.
2329
+     */
2330
+    public function set_email( $value ) {
2331
+        $this->set_prop( 'email', $value );
2302 2332
     }
2303 2333
 
2304 2334
     /**
2305
-	 * Alias of self::set_phone().
2306
-	 *
2307
-	 * @since 1.0.19
2308
-	 * @param  string $value phone.
2309
-	 */
2310
-	public function set_customer_phone( $value ) {
2311
-		$this->set_phone( $value );
2335
+     * Alias of self::set_email().
2336
+     *
2337
+     * @since 1.0.19
2338
+     * @param  string $value email address.
2339
+     */
2340
+    public function set_user_email( $value ) {
2341
+        $this->set_email( $value );
2312 2342
     }
2313 2343
 
2314 2344
     /**
2315
-	 * Alias of self::set_phone().
2316
-	 *
2317
-	 * @since 1.0.19
2318
-	 * @param  string $value phone.
2319
-	 */
2320
-	public function set_phone_number( $value ) {
2321
-		$this->set_phone( $value );
2345
+     * Alias of self::set_email().
2346
+     *
2347
+     * @since 1.0.19
2348
+     * @param  string $value email address.
2349
+     */
2350
+    public function set_email_address( $value ) {
2351
+        $this->set_email( $value );
2322 2352
     }
2323 2353
 
2324 2354
     /**
2325
-	 * Set the customer's email address.
2326
-	 *
2327
-	 * @since 1.0.19
2328
-	 * @param  string $value email address.
2329
-	 */
2330
-	public function set_email( $value ) {
2331
-		$this->set_prop( 'email', $value );
2355
+     * Alias of self::set_email().
2356
+     *
2357
+     * @since 1.0.19
2358
+     * @param  string $value email address.
2359
+     */
2360
+    public function set_customer_email( $value ) {
2361
+        $this->set_email( $value );
2332 2362
     }
2333 2363
 
2334 2364
     /**
2335
-	 * Alias of self::set_email().
2336
-	 *
2337
-	 * @since 1.0.19
2338
-	 * @param  string $value email address.
2339
-	 */
2340
-	public function set_user_email( $value ) {
2341
-		$this->set_email( $value );
2365
+     * Set the customer's country.
2366
+     *
2367
+     * @since 1.0.19
2368
+     * @param  string $value country.
2369
+     */
2370
+    public function set_country( $value ) {
2371
+        $this->set_prop( 'country', $value );
2342 2372
     }
2343 2373
 
2344 2374
     /**
2345
-	 * Alias of self::set_email().
2346
-	 *
2347
-	 * @since 1.0.19
2348
-	 * @param  string $value email address.
2349
-	 */
2350
-	public function set_email_address( $value ) {
2351
-		$this->set_email( $value );
2375
+     * Alias of self::set_country().
2376
+     *
2377
+     * @since 1.0.19
2378
+     * @param  string $value country.
2379
+     */
2380
+    public function set_user_country( $value ) {
2381
+        $this->set_country( $value );
2352 2382
     }
2353 2383
 
2354 2384
     /**
2355
-	 * Alias of self::set_email().
2356
-	 *
2357
-	 * @since 1.0.19
2358
-	 * @param  string $value email address.
2359
-	 */
2360
-	public function set_customer_email( $value ) {
2361
-		$this->set_email( $value );
2385
+     * Alias of self::set_country().
2386
+     *
2387
+     * @since 1.0.19
2388
+     * @param  string $value country.
2389
+     */
2390
+    public function set_customer_country( $value ) {
2391
+        $this->set_country( $value );
2362 2392
     }
2363 2393
 
2364 2394
     /**
2365
-	 * Set the customer's country.
2366
-	 *
2367
-	 * @since 1.0.19
2368
-	 * @param  string $value country.
2369
-	 */
2370
-	public function set_country( $value ) {
2371
-		$this->set_prop( 'country', $value );
2395
+     * Set the customer's state.
2396
+     *
2397
+     * @since 1.0.19
2398
+     * @param  string $value state.
2399
+     */
2400
+    public function set_state( $value ) {
2401
+        $this->set_prop( 'state', $value );
2372 2402
     }
2373 2403
 
2374 2404
     /**
2375
-	 * Alias of self::set_country().
2376
-	 *
2377
-	 * @since 1.0.19
2378
-	 * @param  string $value country.
2379
-	 */
2380
-	public function set_user_country( $value ) {
2381
-		$this->set_country( $value );
2405
+     * Alias of self::set_state().
2406
+     *
2407
+     * @since 1.0.19
2408
+     * @param  string $value state.
2409
+     */
2410
+    public function set_user_state( $value ) {
2411
+        $this->set_state( $value );
2382 2412
     }
2383 2413
 
2384 2414
     /**
2385
-	 * Alias of self::set_country().
2386
-	 *
2387
-	 * @since 1.0.19
2388
-	 * @param  string $value country.
2389
-	 */
2390
-	public function set_customer_country( $value ) {
2391
-		$this->set_country( $value );
2415
+     * Alias of self::set_state().
2416
+     *
2417
+     * @since 1.0.19
2418
+     * @param  string $value state.
2419
+     */
2420
+    public function set_customer_state( $value ) {
2421
+        $this->set_state( $value );
2392 2422
     }
2393 2423
 
2394 2424
     /**
2395
-	 * Set the customer's state.
2396
-	 *
2397
-	 * @since 1.0.19
2398
-	 * @param  string $value state.
2399
-	 */
2400
-	public function set_state( $value ) {
2401
-		$this->set_prop( 'state', $value );
2425
+     * Set the customer's city.
2426
+     *
2427
+     * @since 1.0.19
2428
+     * @param  string $value city.
2429
+     */
2430
+    public function set_city( $value ) {
2431
+        $this->set_prop( 'city', $value );
2402 2432
     }
2403 2433
 
2404 2434
     /**
2405
-	 * Alias of self::set_state().
2406
-	 *
2407
-	 * @since 1.0.19
2408
-	 * @param  string $value state.
2409
-	 */
2410
-	public function set_user_state( $value ) {
2411
-		$this->set_state( $value );
2435
+     * Alias of self::set_city().
2436
+     *
2437
+     * @since 1.0.19
2438
+     * @param  string $value city.
2439
+     */
2440
+    public function set_user_city( $value ) {
2441
+        $this->set_city( $value );
2412 2442
     }
2413 2443
 
2414 2444
     /**
2415
-	 * Alias of self::set_state().
2416
-	 *
2417
-	 * @since 1.0.19
2418
-	 * @param  string $value state.
2419
-	 */
2420
-	public function set_customer_state( $value ) {
2421
-		$this->set_state( $value );
2445
+     * Alias of self::set_city().
2446
+     *
2447
+     * @since 1.0.19
2448
+     * @param  string $value city.
2449
+     */
2450
+    public function set_customer_city( $value ) {
2451
+        $this->set_city( $value );
2422 2452
     }
2423 2453
 
2424 2454
     /**
2425
-	 * Set the customer's city.
2426
-	 *
2427
-	 * @since 1.0.19
2428
-	 * @param  string $value city.
2429
-	 */
2430
-	public function set_city( $value ) {
2431
-		$this->set_prop( 'city', $value );
2455
+     * Set the customer's zip code.
2456
+     *
2457
+     * @since 1.0.19
2458
+     * @param  string $value zip.
2459
+     */
2460
+    public function set_zip( $value ) {
2461
+        $this->set_prop( 'zip', $value );
2432 2462
     }
2433 2463
 
2434 2464
     /**
2435
-	 * Alias of self::set_city().
2436
-	 *
2437
-	 * @since 1.0.19
2438
-	 * @param  string $value city.
2439
-	 */
2440
-	public function set_user_city( $value ) {
2441
-		$this->set_city( $value );
2465
+     * Alias of self::set_zip().
2466
+     *
2467
+     * @since 1.0.19
2468
+     * @param  string $value zip.
2469
+     */
2470
+    public function set_user_zip( $value ) {
2471
+        $this->set_zip( $value );
2442 2472
     }
2443 2473
 
2444 2474
     /**
2445
-	 * Alias of self::set_city().
2446
-	 *
2447
-	 * @since 1.0.19
2448
-	 * @param  string $value city.
2449
-	 */
2450
-	public function set_customer_city( $value ) {
2451
-		$this->set_city( $value );
2475
+     * Alias of self::set_zip().
2476
+     *
2477
+     * @since 1.0.19
2478
+     * @param  string $value zip.
2479
+     */
2480
+    public function set_customer_zip( $value ) {
2481
+        $this->set_zip( $value );
2452 2482
     }
2453 2483
 
2454 2484
     /**
2455
-	 * Set the customer's zip code.
2456
-	 *
2457
-	 * @since 1.0.19
2458
-	 * @param  string $value zip.
2459
-	 */
2460
-	public function set_zip( $value ) {
2461
-		$this->set_prop( 'zip', $value );
2485
+     * Set the customer's company.
2486
+     *
2487
+     * @since 1.0.19
2488
+     * @param  string $value company.
2489
+     */
2490
+    public function set_company( $value ) {
2491
+        $this->set_prop( 'company', $value );
2462 2492
     }
2463 2493
 
2464 2494
     /**
2465
-	 * Alias of self::set_zip().
2466
-	 *
2467
-	 * @since 1.0.19
2468
-	 * @param  string $value zip.
2469
-	 */
2470
-	public function set_user_zip( $value ) {
2471
-		$this->set_zip( $value );
2495
+     * Alias of self::set_company().
2496
+     *
2497
+     * @since 1.0.19
2498
+     * @param  string $value company.
2499
+     */
2500
+    public function set_user_company( $value ) {
2501
+        $this->set_company( $value );
2472 2502
     }
2473 2503
 
2474 2504
     /**
2475
-	 * Alias of self::set_zip().
2476
-	 *
2477
-	 * @since 1.0.19
2478
-	 * @param  string $value zip.
2479
-	 */
2480
-	public function set_customer_zip( $value ) {
2481
-		$this->set_zip( $value );
2505
+     * Alias of self::set_company().
2506
+     *
2507
+     * @since 1.0.19
2508
+     * @param  string $value company.
2509
+     */
2510
+    public function set_customer_company( $value ) {
2511
+        $this->set_company( $value );
2482 2512
     }
2483 2513
 
2484 2514
     /**
2485
-	 * Set the customer's company.
2486
-	 *
2487
-	 * @since 1.0.19
2488
-	 * @param  string $value company.
2489
-	 */
2490
-	public function set_company( $value ) {
2491
-		$this->set_prop( 'company', $value );
2515
+     * Set the customer's var number.
2516
+     *
2517
+     * @since 1.0.19
2518
+     * @param  string $value var number.
2519
+     */
2520
+    public function set_vat_number( $value ) {
2521
+        $this->set_prop( 'vat_number', $value );
2492 2522
     }
2493 2523
 
2494 2524
     /**
2495
-	 * Alias of self::set_company().
2496
-	 *
2497
-	 * @since 1.0.19
2498
-	 * @param  string $value company.
2499
-	 */
2500
-	public function set_user_company( $value ) {
2501
-		$this->set_company( $value );
2525
+     * Alias of self::set_vat_number().
2526
+     *
2527
+     * @since 1.0.19
2528
+     * @param  string $value var number.
2529
+     */
2530
+    public function set_user_vat_number( $value ) {
2531
+        $this->set_vat_number( $value );
2502 2532
     }
2503 2533
 
2504 2534
     /**
2505
-	 * Alias of self::set_company().
2506
-	 *
2507
-	 * @since 1.0.19
2508
-	 * @param  string $value company.
2509
-	 */
2510
-	public function set_customer_company( $value ) {
2511
-		$this->set_company( $value );
2535
+     * Alias of self::set_vat_number().
2536
+     *
2537
+     * @since 1.0.19
2538
+     * @param  string $value var number.
2539
+     */
2540
+    public function set_customer_vat_number( $value ) {
2541
+        $this->set_vat_number( $value );
2512 2542
     }
2513 2543
 
2514 2544
     /**
2515
-	 * Set the customer's var number.
2516
-	 *
2517
-	 * @since 1.0.19
2518
-	 * @param  string $value var number.
2519
-	 */
2520
-	public function set_vat_number( $value ) {
2521
-		$this->set_prop( 'vat_number', $value );
2545
+     * Set the customer's vat rate.
2546
+     *
2547
+     * @since 1.0.19
2548
+     * @param  string $value var rate.
2549
+     */
2550
+    public function set_vat_rate( $value ) {
2551
+        $this->set_prop( 'vat_rate', $value );
2522 2552
     }
2523 2553
 
2524 2554
     /**
2525
-	 * Alias of self::set_vat_number().
2526
-	 *
2527
-	 * @since 1.0.19
2528
-	 * @param  string $value var number.
2529
-	 */
2530
-	public function set_user_vat_number( $value ) {
2531
-		$this->set_vat_number( $value );
2555
+     * Alias of self::set_vat_rate().
2556
+     *
2557
+     * @since 1.0.19
2558
+     * @param  string $value var number.
2559
+     */
2560
+    public function set_user_vat_rate( $value ) {
2561
+        $this->set_vat_rate( $value );
2532 2562
     }
2533 2563
 
2534 2564
     /**
2535
-	 * Alias of self::set_vat_number().
2536
-	 *
2537
-	 * @since 1.0.19
2538
-	 * @param  string $value var number.
2539
-	 */
2540
-	public function set_customer_vat_number( $value ) {
2541
-		$this->set_vat_number( $value );
2565
+     * Alias of self::set_vat_rate().
2566
+     *
2567
+     * @since 1.0.19
2568
+     * @param  string $value var number.
2569
+     */
2570
+    public function set_customer_vat_rate( $value ) {
2571
+        $this->set_vat_rate( $value );
2542 2572
     }
2543 2573
 
2544 2574
     /**
2545
-	 * Set the customer's vat rate.
2546
-	 *
2547
-	 * @since 1.0.19
2548
-	 * @param  string $value var rate.
2549
-	 */
2550
-	public function set_vat_rate( $value ) {
2551
-		$this->set_prop( 'vat_rate', $value );
2575
+     * Set the customer's address.
2576
+     *
2577
+     * @since 1.0.19
2578
+     * @param  string $value address.
2579
+     */
2580
+    public function set_address( $value ) {
2581
+        $this->set_prop( 'address', $value );
2552 2582
     }
2553 2583
 
2554 2584
     /**
2555
-	 * Alias of self::set_vat_rate().
2556
-	 *
2557
-	 * @since 1.0.19
2558
-	 * @param  string $value var number.
2559
-	 */
2560
-	public function set_user_vat_rate( $value ) {
2561
-		$this->set_vat_rate( $value );
2585
+     * Alias of self::set_address().
2586
+     *
2587
+     * @since 1.0.19
2588
+     * @param  string $value address.
2589
+     */
2590
+    public function set_user_address( $value ) {
2591
+        $this->set_address( $value );
2562 2592
     }
2563 2593
 
2564 2594
     /**
2565
-	 * Alias of self::set_vat_rate().
2566
-	 *
2567
-	 * @since 1.0.19
2568
-	 * @param  string $value var number.
2569
-	 */
2570
-	public function set_customer_vat_rate( $value ) {
2571
-		$this->set_vat_rate( $value );
2595
+     * Alias of self::set_address().
2596
+     *
2597
+     * @since 1.0.19
2598
+     * @param  string $value address.
2599
+     */
2600
+    public function set_customer_address( $value ) {
2601
+        $this->set_address( $value );
2572 2602
     }
2573 2603
 
2574 2604
     /**
2575
-	 * Set the customer's address.
2576
-	 *
2577
-	 * @since 1.0.19
2578
-	 * @param  string $value address.
2579
-	 */
2580
-	public function set_address( $value ) {
2581
-		$this->set_prop( 'address', $value );
2605
+     * Set whether the customer has viewed the invoice or not.
2606
+     *
2607
+     * @since 1.0.19
2608
+     * @param  int|bool $value confirmed.
2609
+     */
2610
+    public function set_is_viewed( $value ) {
2611
+        $this->set_prop( 'is_viewed', $value );
2582 2612
     }
2583 2613
 
2584 2614
     /**
2585
-	 * Alias of self::set_address().
2586
-	 *
2587
-	 * @since 1.0.19
2588
-	 * @param  string $value address.
2589
-	 */
2590
-	public function set_user_address( $value ) {
2591
-		$this->set_address( $value );
2615
+     * Set extra email recipients.
2616
+     *
2617
+     * @since 1.0.19
2618
+     * @param  string $value email recipients.
2619
+     */
2620
+    public function set_email_cc( $value ) {
2621
+        $this->set_prop( 'email_cc', $value );
2592 2622
     }
2593 2623
 
2594 2624
     /**
2595
-	 * Alias of self::set_address().
2596
-	 *
2597
-	 * @since 1.0.19
2598
-	 * @param  string $value address.
2599
-	 */
2600
-	public function set_customer_address( $value ) {
2601
-		$this->set_address( $value );
2625
+     * Set the invoice template.
2626
+     *
2627
+     * @since 1.0.19
2628
+     * @param  string $value email recipients.
2629
+     */
2630
+    public function set_template( $value ) {
2631
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2632
+            $this->set_prop( 'template', $value );
2633
+        }
2602 2634
     }
2603 2635
 
2604 2636
     /**
2605
-	 * Set whether the customer has viewed the invoice or not.
2606
-	 *
2607
-	 * @since 1.0.19
2608
-	 * @param  int|bool $value confirmed.
2609
-	 */
2610
-	public function set_is_viewed( $value ) {
2611
-		$this->set_prop( 'is_viewed', $value );
2612
-	}
2613
-
2614
-	/**
2615
-	 * Set extra email recipients.
2616
-	 *
2617
-	 * @since 1.0.19
2618
-	 * @param  string $value email recipients.
2619
-	 */
2620
-	public function set_email_cc( $value ) {
2621
-		$this->set_prop( 'email_cc', $value );
2622
-	}
2623
-
2624
-	/**
2625
-	 * Set the invoice template.
2626
-	 *
2627
-	 * @since 1.0.19
2628
-	 * @param  string $value email recipients.
2629
-	 */
2630
-	public function set_template( $value ) {
2631
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2632
-			$this->set_prop( 'template', $value );
2633
-		}
2634
-	}
2635
-
2636
-	/**
2637
-	 * Set the customer's address confirmed status.
2638
-	 *
2639
-	 * @since 1.0.19
2640
-	 * @param  int|bool $value confirmed.
2641
-	 */
2642
-	public function set_address_confirmed( $value ) {
2643
-		$this->set_prop( 'address_confirmed', $value );
2637
+     * Set the customer's address confirmed status.
2638
+     *
2639
+     * @since 1.0.19
2640
+     * @param  int|bool $value confirmed.
2641
+     */
2642
+    public function set_address_confirmed( $value ) {
2643
+        $this->set_prop( 'address_confirmed', $value );
2644 2644
     }
2645 2645
 
2646 2646
     /**
2647
-	 * Alias of self::set_address_confirmed().
2648
-	 *
2649
-	 * @since 1.0.19
2650
-	 * @param  int|bool $value confirmed.
2651
-	 */
2652
-	public function set_user_address_confirmed( $value ) {
2653
-		$this->set_address_confirmed( $value );
2647
+     * Alias of self::set_address_confirmed().
2648
+     *
2649
+     * @since 1.0.19
2650
+     * @param  int|bool $value confirmed.
2651
+     */
2652
+    public function set_user_address_confirmed( $value ) {
2653
+        $this->set_address_confirmed( $value );
2654 2654
     }
2655 2655
 
2656 2656
     /**
2657
-	 * Alias of self::set_address_confirmed().
2658
-	 *
2659
-	 * @since 1.0.19
2660
-	 * @param  int|bool $value confirmed.
2661
-	 */
2662
-	public function set_customer_address_confirmed( $value ) {
2663
-		$this->set_address_confirmed( $value );
2657
+     * Alias of self::set_address_confirmed().
2658
+     *
2659
+     * @since 1.0.19
2660
+     * @param  int|bool $value confirmed.
2661
+     */
2662
+    public function set_customer_address_confirmed( $value ) {
2663
+        $this->set_address_confirmed( $value );
2664 2664
     }
2665 2665
 
2666 2666
     /**
2667
-	 * Set the invoice sub total.
2668
-	 *
2669
-	 * @since 1.0.19
2670
-	 * @param  float $value sub total.
2671
-	 */
2672
-	public function set_subtotal( $value ) {
2673
-		$this->set_prop( 'subtotal', $value );
2667
+     * Set the invoice sub total.
2668
+     *
2669
+     * @since 1.0.19
2670
+     * @param  float $value sub total.
2671
+     */
2672
+    public function set_subtotal( $value ) {
2673
+        $this->set_prop( 'subtotal', $value );
2674 2674
     }
2675 2675
 
2676 2676
     /**
2677
-	 * Set the invoice discount amount.
2678
-	 *
2679
-	 * @since 1.0.19
2680
-	 * @param  float $value discount total.
2681
-	 */
2682
-	public function set_total_discount( $value ) {
2683
-		$this->set_prop( 'total_discount', $value );
2677
+     * Set the invoice discount amount.
2678
+     *
2679
+     * @since 1.0.19
2680
+     * @param  float $value discount total.
2681
+     */
2682
+    public function set_total_discount( $value ) {
2683
+        $this->set_prop( 'total_discount', $value );
2684 2684
     }
2685 2685
 
2686 2686
     /**
2687
-	 * Alias of self::set_total_discount().
2688
-	 *
2689
-	 * @since 1.0.19
2690
-	 * @param  float $value discount total.
2691
-	 */
2692
-	public function set_discount( $value ) {
2693
-		$this->set_total_discount( $value );
2687
+     * Alias of self::set_total_discount().
2688
+     *
2689
+     * @since 1.0.19
2690
+     * @param  float $value discount total.
2691
+     */
2692
+    public function set_discount( $value ) {
2693
+        $this->set_total_discount( $value );
2694 2694
     }
2695 2695
 
2696 2696
     /**
2697
-	 * Set the invoice tax amount.
2698
-	 *
2699
-	 * @since 1.0.19
2700
-	 * @param  float $value tax total.
2701
-	 */
2702
-	public function set_total_tax( $value ) {
2703
-		$this->set_prop( 'total_tax', $value );
2697
+     * Set the invoice tax amount.
2698
+     *
2699
+     * @since 1.0.19
2700
+     * @param  float $value tax total.
2701
+     */
2702
+    public function set_total_tax( $value ) {
2703
+        $this->set_prop( 'total_tax', $value );
2704 2704
     }
2705 2705
 
2706 2706
     /**
2707
-	 * Alias of self::set_total_tax().
2708
-	 *
2709
-	 * @since 1.0.19
2710
-	 * @param  float $value tax total.
2711
-	 */
2712
-	public function set_tax_total( $value ) {
2713
-		$this->set_total_tax( $value );
2707
+     * Alias of self::set_total_tax().
2708
+     *
2709
+     * @since 1.0.19
2710
+     * @param  float $value tax total.
2711
+     */
2712
+    public function set_tax_total( $value ) {
2713
+        $this->set_total_tax( $value );
2714 2714
     }
2715 2715
 
2716 2716
     /**
2717
-	 * Set the invoice fees amount.
2718
-	 *
2719
-	 * @since 1.0.19
2720
-	 * @param  float $value fees total.
2721
-	 */
2722
-	public function set_total_fees( $value ) {
2723
-		$this->set_prop( 'total_fees', $value );
2717
+     * Set the invoice fees amount.
2718
+     *
2719
+     * @since 1.0.19
2720
+     * @param  float $value fees total.
2721
+     */
2722
+    public function set_total_fees( $value ) {
2723
+        $this->set_prop( 'total_fees', $value );
2724 2724
     }
2725 2725
 
2726 2726
     /**
2727
-	 * Alias of self::set_total_fees().
2728
-	 *
2729
-	 * @since 1.0.19
2730
-	 * @param  float $value fees total.
2731
-	 */
2732
-	public function set_fees_total( $value ) {
2733
-		$this->set_total_fees( $value );
2727
+     * Alias of self::set_total_fees().
2728
+     *
2729
+     * @since 1.0.19
2730
+     * @param  float $value fees total.
2731
+     */
2732
+    public function set_fees_total( $value ) {
2733
+        $this->set_total_fees( $value );
2734 2734
     }
2735 2735
 
2736 2736
     /**
2737
-	 * Set the invoice fees.
2738
-	 *
2739
-	 * @since 1.0.19
2740
-	 * @param  array $value fees.
2741
-	 */
2742
-	public function set_fees( $value ) {
2737
+     * Set the invoice fees.
2738
+     *
2739
+     * @since 1.0.19
2740
+     * @param  array $value fees.
2741
+     */
2742
+    public function set_fees( $value ) {
2743 2743
 
2744 2744
         $this->set_prop( 'fees', array() );
2745 2745
 
@@ -2757,23 +2757,23 @@  discard block
 block discarded – undo
2757 2757
     }
2758 2758
 
2759 2759
     /**
2760
-	 * Set the invoice taxes.
2761
-	 *
2762
-	 * @since 1.0.19
2763
-	 * @param  array $value taxes.
2764
-	 */
2765
-	public function set_taxes( $value ) {
2766
-		$this->set_prop( 'taxes', $value );
2760
+     * Set the invoice taxes.
2761
+     *
2762
+     * @since 1.0.19
2763
+     * @param  array $value taxes.
2764
+     */
2765
+    public function set_taxes( $value ) {
2766
+        $this->set_prop( 'taxes', $value );
2767 2767
     }
2768 2768
 
2769 2769
     /**
2770
-	 * Set the invoice discounts.
2771
-	 *
2772
-	 * @since 1.0.19
2773
-	 * @param  array $value discounts.
2774
-	 */
2775
-	public function set_discounts( $value ) {
2776
-		$this->set_prop( 'discounts', array() );
2770
+     * Set the invoice discounts.
2771
+     *
2772
+     * @since 1.0.19
2773
+     * @param  array $value discounts.
2774
+     */
2775
+    public function set_discounts( $value ) {
2776
+        $this->set_prop( 'discounts', array() );
2777 2777
 
2778 2778
         // Ensure that we have an array.
2779 2779
         if ( ! is_array( $value ) ) {
@@ -2788,12 +2788,12 @@  discard block
 block discarded – undo
2788 2788
     }
2789 2789
 
2790 2790
     /**
2791
-	 * Set the invoice items.
2792
-	 *
2793
-	 * @since 1.0.19
2794
-	 * @param  GetPaid_Form_Item[] $value items.
2795
-	 */
2796
-	public function set_items( $value ) {
2791
+     * Set the invoice items.
2792
+     *
2793
+     * @since 1.0.19
2794
+     * @param  GetPaid_Form_Item[] $value items.
2795
+     */
2796
+    public function set_items( $value ) {
2797 2797
 
2798 2798
         // Remove existing items.
2799 2799
         $this->set_prop( 'items', array() );
@@ -2810,95 +2810,95 @@  discard block
 block discarded – undo
2810 2810
     }
2811 2811
 
2812 2812
     /**
2813
-	 * Set the payment form.
2814
-	 *
2815
-	 * @since 1.0.19
2816
-	 * @param  int $value payment form.
2817
-	 */
2818
-	public function set_payment_form( $value ) {
2819
-		$this->set_prop( 'payment_form', $value );
2813
+     * Set the payment form.
2814
+     *
2815
+     * @since 1.0.19
2816
+     * @param  int $value payment form.
2817
+     */
2818
+    public function set_payment_form( $value ) {
2819
+        $this->set_prop( 'payment_form', $value );
2820 2820
     }
2821 2821
 
2822 2822
     /**
2823
-	 * Set the submission id.
2824
-	 *
2825
-	 * @since 1.0.19
2826
-	 * @param  string $value submission id.
2827
-	 */
2828
-	public function set_submission_id( $value ) {
2829
-		$this->set_prop( 'submission_id', $value );
2823
+     * Set the submission id.
2824
+     *
2825
+     * @since 1.0.19
2826
+     * @param  string $value submission id.
2827
+     */
2828
+    public function set_submission_id( $value ) {
2829
+        $this->set_prop( 'submission_id', $value );
2830 2830
     }
2831 2831
 
2832 2832
     /**
2833
-	 * Set the discount code.
2834
-	 *
2835
-	 * @since 1.0.19
2836
-	 * @param  string $value discount code.
2837
-	 */
2838
-	public function set_discount_code( $value ) {
2839
-		$this->set_prop( 'discount_code', $value );
2833
+     * Set the discount code.
2834
+     *
2835
+     * @since 1.0.19
2836
+     * @param  string $value discount code.
2837
+     */
2838
+    public function set_discount_code( $value ) {
2839
+        $this->set_prop( 'discount_code', $value );
2840 2840
     }
2841 2841
 
2842 2842
     /**
2843
-	 * Set the gateway.
2844
-	 *
2845
-	 * @since 1.0.19
2846
-	 * @param  string $value gateway.
2847
-	 */
2848
-	public function set_gateway( $value ) {
2849
-		$this->set_prop( 'gateway', $value );
2843
+     * Set the gateway.
2844
+     *
2845
+     * @since 1.0.19
2846
+     * @param  string $value gateway.
2847
+     */
2848
+    public function set_gateway( $value ) {
2849
+        $this->set_prop( 'gateway', $value );
2850 2850
     }
2851 2851
 
2852 2852
     /**
2853
-	 * Set the transaction id.
2854
-	 *
2855
-	 * @since 1.0.19
2856
-	 * @param  string $value transaction id.
2857
-	 */
2858
-	public function set_transaction_id( $value ) {
2859
-		if ( ! empty( $value ) ) {
2860
-			$this->set_prop( 'transaction_id', $value );
2861
-		}
2853
+     * Set the transaction id.
2854
+     *
2855
+     * @since 1.0.19
2856
+     * @param  string $value transaction id.
2857
+     */
2858
+    public function set_transaction_id( $value ) {
2859
+        if ( ! empty( $value ) ) {
2860
+            $this->set_prop( 'transaction_id', $value );
2861
+        }
2862 2862
     }
2863 2863
 
2864 2864
     /**
2865
-	 * Set the currency id.
2866
-	 *
2867
-	 * @since 1.0.19
2868
-	 * @param  string $value currency id.
2869
-	 */
2870
-	public function set_currency( $value ) {
2871
-		$this->set_prop( 'currency', $value );
2865
+     * Set the currency id.
2866
+     *
2867
+     * @since 1.0.19
2868
+     * @param  string $value currency id.
2869
+     */
2870
+    public function set_currency( $value ) {
2871
+        $this->set_prop( 'currency', $value );
2872 2872
     }
2873 2873
 
2874
-	/**
2875
-	 * Set whether to disable taxes.
2876
-	 *
2877
-	 * @since 1.0.19
2878
-	 * @param  bool $value value.
2879
-	 */
2880
-	public function set_disable_taxes( $value ) {
2881
-		$this->set_prop( 'disable_taxes', (bool) $value );
2882
-	}
2874
+    /**
2875
+     * Set whether to disable taxes.
2876
+     *
2877
+     * @since 1.0.19
2878
+     * @param  bool $value value.
2879
+     */
2880
+    public function set_disable_taxes( $value ) {
2881
+        $this->set_prop( 'disable_taxes', (bool) $value );
2882
+    }
2883 2883
 
2884 2884
     /**
2885
-	 * Set the subscription id.
2886
-	 *
2887
-	 * @since 1.0.19
2888
-	 * @param  string $value subscription id.
2889
-	 */
2890
-	public function set_subscription_id( $value ) {
2891
-		$this->set_prop( 'subscription_id', $value );
2892
-	}
2885
+     * Set the subscription id.
2886
+     *
2887
+     * @since 1.0.19
2888
+     * @param  string $value subscription id.
2889
+     */
2890
+    public function set_subscription_id( $value ) {
2891
+        $this->set_prop( 'subscription_id', $value );
2892
+    }
2893 2893
 	
2894
-	/**
2895
-	 * Set the remote subscription id.
2896
-	 *
2897
-	 * @since 1.0.19
2898
-	 * @param  string $value subscription id.
2899
-	 */
2900
-	public function set_remote_subscription_id( $value ) {
2901
-		$this->set_prop( 'remote_subscription_id', $value );
2894
+    /**
2895
+     * Set the remote subscription id.
2896
+     *
2897
+     * @since 1.0.19
2898
+     * @param  string $value subscription id.
2899
+     */
2900
+    public function set_remote_subscription_id( $value ) {
2901
+        $this->set_prop( 'remote_subscription_id', $value );
2902 2902
     }
2903 2903
 
2904 2904
     /*
@@ -2937,12 +2937,12 @@  discard block
 block discarded – undo
2937 2937
      */
2938 2938
     public function is_taxable() {
2939 2939
         return ! $this->get_disable_taxes();
2940
-	}
2940
+    }
2941 2941
 
2942
-	/**
2943
-	 * @deprecated
2944
-	 */
2945
-	public function has_vat() {
2942
+    /**
2943
+     * @deprecated
2944
+     */
2945
+    public function has_vat() {
2946 2946
         global $wpinv_euvat, $wpi_country;
2947 2947
 
2948 2948
         $requires_vat = false;
@@ -2953,17 +2953,17 @@  discard block
 block discarded – undo
2953 2953
         }
2954 2954
 
2955 2955
         return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2956
-	}
2956
+    }
2957 2957
 
2958
-	/**
2959
-	 * Checks to see if the invoice requires payment.
2960
-	 */
2961
-	public function is_free() {
2958
+    /**
2959
+     * Checks to see if the invoice requires payment.
2960
+     */
2961
+    public function is_free() {
2962 2962
         $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2963 2963
 
2964
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2965
-			$is_free = false;
2966
-		}
2964
+        if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2965
+            $is_free = false;
2966
+        }
2967 2967
 
2968 2968
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2969 2969
     }
@@ -2974,46 +2974,46 @@  discard block
 block discarded – undo
2974 2974
     public function is_paid() {
2975 2975
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2976 2976
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2977
-	}
2977
+    }
2978 2978
 
2979
-	/**
2979
+    /**
2980 2980
      * Checks if the invoice needs payment.
2981 2981
      */
2982
-	public function needs_payment() {
2983
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2982
+    public function needs_payment() {
2983
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2984 2984
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2985 2985
     }
2986 2986
 
2987
-	/**
2987
+    /**
2988 2988
      * Checks if the invoice is refunded.
2989 2989
      */
2990
-	public function is_refunded() {
2990
+    public function is_refunded() {
2991 2991
         $is_refunded = $this->has_status( 'wpi-refunded' );
2992 2992
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2993
-	}
2993
+    }
2994 2994
 
2995
-	/**
2995
+    /**
2996 2996
      * Checks if the invoice is held.
2997 2997
      */
2998
-	public function is_held() {
2998
+    public function is_held() {
2999 2999
         $is_held = $this->has_status( 'wpi-onhold' );
3000 3000
         return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
3001
-	}
3001
+    }
3002 3002
 
3003
-	/**
3003
+    /**
3004 3004
      * Checks if the invoice is due.
3005 3005
      */
3006
-	public function is_due() {
3007
-		$due_date = $this->get_due_date();
3008
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3009
-	}
3006
+    public function is_due() {
3007
+        $due_date = $this->get_due_date();
3008
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3009
+    }
3010 3010
 
3011
-	/**
3011
+    /**
3012 3012
      * Checks if the invoice is draft.
3013 3013
      */
3014
-	public function is_draft() {
3014
+    public function is_draft() {
3015 3015
         return $this->has_status( 'draft, auto-draft' );
3016
-	}
3016
+    }
3017 3017
 
3018 3018
     /**
3019 3019
      * Checks if the invoice has a given status.
@@ -3021,9 +3021,9 @@  discard block
 block discarded – undo
3021 3021
     public function has_status( $status ) {
3022 3022
         $status = wpinv_parse_list( $status );
3023 3023
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3024
-	}
3024
+    }
3025 3025
 
3026
-	/**
3026
+    /**
3027 3027
      * Checks if the invoice is of a given type.
3028 3028
      */
3029 3029
     public function is_type( $type ) {
@@ -3046,25 +3046,25 @@  discard block
 block discarded – undo
3046 3046
      */
3047 3047
     public function has_free_trial() {
3048 3048
         return $this->is_recurring() && 0 == $this->get_initial_total();
3049
-	}
3049
+    }
3050 3050
 
3051
-	/**
3051
+    /**
3052 3052
      * @deprecated
3053 3053
      */
3054 3054
     public function is_free_trial() {
3055 3055
         $this->has_free_trial();
3056 3056
     }
3057 3057
 
3058
-	/**
3058
+    /**
3059 3059
      * Check if the initial payment if 0.
3060 3060
      *
3061 3061
      */
3062
-	public function is_initial_free() {
3062
+    public function is_initial_free() {
3063 3063
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3064 3064
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3065 3065
     }
3066 3066
 	
3067
-	/**
3067
+    /**
3068 3068
      * Check if the recurring item has a free trial.
3069 3069
      *
3070 3070
      */
@@ -3077,21 +3077,21 @@  discard block
 block discarded – undo
3077 3077
 
3078 3078
         $item = $this->get_recurring( true );
3079 3079
         return $item->has_free_trial();
3080
-	}
3080
+    }
3081 3081
 
3082
-	/**
3082
+    /**
3083 3083
      * Check if the free trial is a result of a discount.
3084 3084
      */
3085 3085
     public function is_free_trial_from_discount() {
3086
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3087
-	}
3086
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3087
+    }
3088 3088
 	
3089
-	/**
3089
+    /**
3090 3090
      * @deprecated
3091 3091
      */
3092 3092
     public function discount_first_payment_only() {
3093 3093
 
3094
-		$discount_code = $this->get_discount_code();
3094
+        $discount_code = $this->get_discount_code();
3095 3095
         if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3096 3096
             return true;
3097 3097
         }
@@ -3122,28 +3122,28 @@  discard block
 block discarded – undo
3122 3122
      */
3123 3123
     public function add_item( $item ) {
3124 3124
 
3125
-		if ( is_array( $item ) ) {
3126
-			$item = $this->process_array_item( $item );
3127
-		}
3125
+        if ( is_array( $item ) ) {
3126
+            $item = $this->process_array_item( $item );
3127
+        }
3128 3128
 
3129
-		if ( is_numeric( $item ) ) {
3130
-			$item = new GetPaid_Form_Item( $item );
3131
-		}
3129
+        if ( is_numeric( $item ) ) {
3130
+            $item = new GetPaid_Form_Item( $item );
3131
+        }
3132 3132
 
3133 3133
         // Make sure that it is available for purchase.
3134
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3135
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3134
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3135
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3136 3136
         }
3137 3137
 
3138 3138
         // Do we have a recurring item?
3139
-		if ( $item->is_recurring() ) {
3139
+        if ( $item->is_recurring() ) {
3140 3140
 
3141
-			// An invoice can only contain one recurring item.
3142
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3143
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3144
-			}
3141
+            // An invoice can only contain one recurring item.
3142
+            if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3143
+                return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3144
+            }
3145 3145
 
3146
-			$this->recurring_item = $item->get_id();
3146
+            $this->recurring_item = $item->get_id();
3147 3147
         }
3148 3148
 
3149 3149
         // Invoice id.
@@ -3154,60 +3154,60 @@  discard block
 block discarded – undo
3154 3154
         $items[ (int) $item->get_id() ] = $item;
3155 3155
 
3156 3156
         $this->set_prop( 'items', $items );
3157
-		return true;
3158
-	}
3157
+        return true;
3158
+    }
3159 3159
 	
3160
-	/**
3161
-	 * Converts an array to an item.
3162
-	 *
3163
-	 * @since 1.0.19
3164
-	 * @return GetPaid_Form_Item
3165
-	 */
3166
-	protected function process_array_item( $array ) {
3167
-
3168
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3169
-		$item    = new GetPaid_Form_Item( $item_id );
3170
-
3171
-		// Set item data.
3172
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3173
-			if ( isset( $array[ "item_$key" ] ) ) {
3174
-				$method = "set_$key";
3175
-				$item->$method( $array[ "item_$key" ] );
3176
-			}
3177
-		}
3178
-
3179
-		if ( isset( $array['quantity'] ) ) {
3180
-			$item->set_quantity( $array['quantity'] );
3181
-		}
3182
-
3183
-		// Set item meta.
3184
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3185
-			$item->set_item_meta( $array['meta'] );
3186
-		}
3187
-
3188
-		return $item;
3189
-
3190
-	}
3191
-
3192
-    /**
3193
-	 * Retrieves a specific item.
3194
-	 *
3195
-	 * @since 1.0.19
3196
-	 */
3197
-	public function get_item( $item_id ) {
3198
-		$items   = $this->get_items();
3199
-		$item_id = (int) $item_id;
3200
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3201
-    }
3202
-
3203
-    /**
3204
-	 * Removes a specific item.
3205
-	 *
3206
-	 * @since 1.0.19
3207
-	 */
3208
-	public function remove_item( $item_id ) {
3209
-		$items   = $this->get_items();
3210
-		$item_id = (int) $item_id;
3160
+    /**
3161
+     * Converts an array to an item.
3162
+     *
3163
+     * @since 1.0.19
3164
+     * @return GetPaid_Form_Item
3165
+     */
3166
+    protected function process_array_item( $array ) {
3167
+
3168
+        $item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3169
+        $item    = new GetPaid_Form_Item( $item_id );
3170
+
3171
+        // Set item data.
3172
+        foreach( array( 'name', 'price', 'description' ) as $key ) {
3173
+            if ( isset( $array[ "item_$key" ] ) ) {
3174
+                $method = "set_$key";
3175
+                $item->$method( $array[ "item_$key" ] );
3176
+            }
3177
+        }
3178
+
3179
+        if ( isset( $array['quantity'] ) ) {
3180
+            $item->set_quantity( $array['quantity'] );
3181
+        }
3182
+
3183
+        // Set item meta.
3184
+        if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3185
+            $item->set_item_meta( $array['meta'] );
3186
+        }
3187
+
3188
+        return $item;
3189
+
3190
+    }
3191
+
3192
+    /**
3193
+     * Retrieves a specific item.
3194
+     *
3195
+     * @since 1.0.19
3196
+     */
3197
+    public function get_item( $item_id ) {
3198
+        $items   = $this->get_items();
3199
+        $item_id = (int) $item_id;
3200
+        return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3201
+    }
3202
+
3203
+    /**
3204
+     * Removes a specific item.
3205
+     *
3206
+     * @since 1.0.19
3207
+     */
3208
+    public function remove_item( $item_id ) {
3209
+        $items   = $this->get_items();
3210
+        $item_id = (int) $item_id;
3211 3211
 
3212 3212
         if ( $item_id == $this->recurring_item ) {
3213 3213
             $this->recurring_item = null;
@@ -3234,38 +3234,38 @@  discard block
 block discarded – undo
3234 3234
         if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3235 3235
 
3236 3236
             $amount = $fees[ $fee ]['amount'] += $amount;
3237
-			$fees[ $fee ] = array(
3238
-				'amount'    => $amount,
3237
+            $fees[ $fee ] = array(
3238
+                'amount'    => $amount,
3239 3239
                 'recurring' => (bool) $recurring,
3240 3240
             );
3241 3241
 
3242
-		} else {
3243
-			$fees[ $fee ] = array(
3242
+        } else {
3243
+            $fees[ $fee ] = array(
3244 3244
                 'amount'    => $amount,
3245 3245
                 'recurring' => (bool) $recurring,
3246 3246
             );
3247
-		}
3247
+        }
3248 3248
 
3249 3249
         $this->set_prop( 'fees', $fee );
3250 3250
 
3251 3251
     }
3252 3252
 
3253 3253
     /**
3254
-	 * Retrieves a specific fee.
3255
-	 *
3256
-	 * @since 1.0.19
3257
-	 */
3258
-	public function get_fee( $fee ) {
3254
+     * Retrieves a specific fee.
3255
+     *
3256
+     * @since 1.0.19
3257
+     */
3258
+    public function get_fee( $fee ) {
3259 3259
         $fees = $this->get_fees();
3260
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3260
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3261 3261
     }
3262 3262
 
3263 3263
     /**
3264
-	 * Removes a specific fee.
3265
-	 *
3266
-	 * @since 1.0.19
3267
-	 */
3268
-	public function remove_fee( $fee ) {
3264
+     * Removes a specific fee.
3265
+     *
3266
+     * @since 1.0.19
3267
+     */
3268
+    public function remove_fee( $fee ) {
3269 3269
         $fees = $this->get_fees();
3270 3270
         if ( isset( $fees[ $fee ] ) ) {
3271 3271
             unset( $fees[ $fee ] );
@@ -3288,44 +3288,44 @@  discard block
 block discarded – undo
3288 3288
         if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3289 3289
 
3290 3290
             $amount = $discounts[ $discount ]['amount'] += $amount;
3291
-			$discounts[ $discount ] = array(
3291
+            $discounts[ $discount ] = array(
3292 3292
                 'amount'    => $amount,
3293 3293
                 'recurring' => (bool) $recurring,
3294 3294
             );
3295 3295
 
3296
-		} else {
3297
-			$discounts[ $discount ] = array(
3296
+        } else {
3297
+            $discounts[ $discount ] = array(
3298 3298
                 'amount'    => $amount,
3299 3299
                 'recurring' => (bool) $recurring,
3300 3300
             );
3301
-		}
3301
+        }
3302 3302
 
3303 3303
         $this->set_prop( 'discounts', $discount );
3304 3304
 
3305 3305
     }
3306 3306
 
3307 3307
     /**
3308
-	 * Retrieves a specific discount.
3309
-	 *
3310
-	 * @since 1.0.19
3311
-	 */
3312
-	public function get_discount( $discount = false ) {
3308
+     * Retrieves a specific discount.
3309
+     *
3310
+     * @since 1.0.19
3311
+     */
3312
+    public function get_discount( $discount = false ) {
3313 3313
 
3314
-		// Backwards compatibilty.
3315
-		if ( empty( $discount ) ) {
3316
-			return $this->get_total_discount();
3317
-		}
3314
+        // Backwards compatibilty.
3315
+        if ( empty( $discount ) ) {
3316
+            return $this->get_total_discount();
3317
+        }
3318 3318
 
3319 3319
         $discounts = $this->get_discounts();
3320
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3320
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3321 3321
     }
3322 3322
 
3323 3323
     /**
3324
-	 * Removes a specific discount.
3325
-	 *
3326
-	 * @since 1.0.19
3327
-	 */
3328
-	public function remove_discount( $discount ) {
3324
+     * Removes a specific discount.
3325
+     *
3326
+     * @since 1.0.19
3327
+     */
3328
+    public function remove_discount( $discount ) {
3329 3329
         $discounts = $this->get_discounts();
3330 3330
         if ( isset( $discounts[ $discount ] ) ) {
3331 3331
             unset( $discounts[ $discount ] );
@@ -3351,44 +3351,44 @@  discard block
 block discarded – undo
3351 3351
         if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3352 3352
 
3353 3353
             $amount = $taxes[ $tax ]['amount'] += $amount;
3354
-			$taxes[ $tax ] = array(
3354
+            $taxes[ $tax ] = array(
3355 3355
                 'amount'    => $amount,
3356 3356
                 'recurring' => (bool) $recurring,
3357 3357
             );
3358 3358
 
3359
-		} else {
3360
-			$taxes[ $tax ] = array(
3359
+        } else {
3360
+            $taxes[ $tax ] = array(
3361 3361
                 'amount'    => $amount,
3362 3362
                 'recurring' => (bool) $recurring,
3363 3363
             );
3364
-		}
3364
+        }
3365 3365
 
3366 3366
         $this->set_prop( 'taxes', $tax );
3367 3367
 
3368 3368
     }
3369 3369
 
3370 3370
     /**
3371
-	 * Retrieves a specific tax.
3372
-	 *
3373
-	 * @since 1.0.19
3374
-	 */
3375
-	public function get_tax( $tax = null ) {
3371
+     * Retrieves a specific tax.
3372
+     *
3373
+     * @since 1.0.19
3374
+     */
3375
+    public function get_tax( $tax = null ) {
3376 3376
 
3377
-		// Backwards compatility.
3378
-		if ( empty( $tax ) ) {
3379
-			return $this->get_total_tax();
3380
-		}
3377
+        // Backwards compatility.
3378
+        if ( empty( $tax ) ) {
3379
+            return $this->get_total_tax();
3380
+        }
3381 3381
 
3382 3382
         $taxes = $this->get_taxes();
3383
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3383
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3384 3384
     }
3385 3385
 
3386 3386
     /**
3387
-	 * Removes a specific tax.
3388
-	 *
3389
-	 * @since 1.0.19
3390
-	 */
3391
-	public function remove_tax( $tax ) {
3387
+     * Removes a specific tax.
3388
+     *
3389
+     * @since 1.0.19
3390
+     */
3391
+    public function remove_tax( $tax ) {
3392 3392
         $taxes = $this->get_discounts();
3393 3393
         if ( isset( $taxes[ $tax ] ) ) {
3394 3394
             unset( $taxes[ $tax ] );
@@ -3397,160 +3397,160 @@  discard block
 block discarded – undo
3397 3397
     }
3398 3398
 
3399 3399
     /**
3400
-	 * Recalculates the invoice subtotal.
3401
-	 *
3402
-	 * @since 1.0.19
3403
-	 * @return float The recalculated subtotal
3404
-	 */
3405
-	public function recalculate_subtotal() {
3400
+     * Recalculates the invoice subtotal.
3401
+     *
3402
+     * @since 1.0.19
3403
+     * @return float The recalculated subtotal
3404
+     */
3405
+    public function recalculate_subtotal() {
3406 3406
         $items     = $this->get_items();
3407
-		$subtotal  = 0;
3408
-		$recurring = 0;
3407
+        $subtotal  = 0;
3408
+        $recurring = 0;
3409 3409
 
3410 3410
         foreach ( $items as $item ) {
3411
-			$subtotal  += $item->get_sub_total();
3412
-			$recurring += $item->get_recurring_sub_total();
3411
+            $subtotal  += $item->get_sub_total();
3412
+            $recurring += $item->get_recurring_sub_total();
3413 3413
         }
3414 3414
 
3415
-		if ( $this->is_renewal() ) {
3416
-			$this->set_subtotal( $recurring );
3417
-		} else {
3418
-			$this->set_subtotal( $subtotal );
3419
-		}
3415
+        if ( $this->is_renewal() ) {
3416
+            $this->set_subtotal( $recurring );
3417
+        } else {
3418
+            $this->set_subtotal( $subtotal );
3419
+        }
3420 3420
 
3421
-		$this->totals['subtotal'] = array(
3422
-			'initial'   => $subtotal,
3423
-			'recurring' => $recurring,
3424
-		);
3421
+        $this->totals['subtotal'] = array(
3422
+            'initial'   => $subtotal,
3423
+            'recurring' => $recurring,
3424
+        );
3425 3425
 
3426 3426
         return $this->is_renewal() ? $recurring : $subtotal;
3427 3427
     }
3428 3428
 
3429 3429
     /**
3430
-	 * Recalculates the invoice discount total.
3431
-	 *
3432
-	 * @since 1.0.19
3433
-	 * @return float The recalculated discount
3434
-	 */
3435
-	public function recalculate_total_discount() {
3430
+     * Recalculates the invoice discount total.
3431
+     *
3432
+     * @since 1.0.19
3433
+     * @return float The recalculated discount
3434
+     */
3435
+    public function recalculate_total_discount() {
3436 3436
         $discounts = $this->get_discounts();
3437
-		$discount  = 0;
3438
-		$recurring = 0;
3437
+        $discount  = 0;
3438
+        $recurring = 0;
3439 3439
 
3440 3440
         foreach ( $discounts as $data ) {
3441 3441
 
3442
-			if ( $data['recurring'] ) {
3443
-				$recurring += $data['amount'];
3444
-			} else {
3445
-				$discount += $data['amount'];
3446
-			}
3442
+            if ( $data['recurring'] ) {
3443
+                $recurring += $data['amount'];
3444
+            } else {
3445
+                $discount += $data['amount'];
3446
+            }
3447 3447
 
3448
-		}
3448
+        }
3449 3449
 
3450
-		if ( $this->is_renewal() ) {
3451
-			$this->set_total_discount( $recurring );
3452
-		} else {
3453
-			$this->set_total_discount( $discount );
3454
-		}
3450
+        if ( $this->is_renewal() ) {
3451
+            $this->set_total_discount( $recurring );
3452
+        } else {
3453
+            $this->set_total_discount( $discount );
3454
+        }
3455 3455
 
3456
-		$this->totals['discount'] = array(
3457
-			'initial'   => $discount,
3458
-			'recurring' => $recurring,
3459
-		);
3456
+        $this->totals['discount'] = array(
3457
+            'initial'   => $discount,
3458
+            'recurring' => $recurring,
3459
+        );
3460 3460
 
3461
-		return $this->is_renewal() ? $recurring : $discount;
3461
+        return $this->is_renewal() ? $recurring : $discount;
3462 3462
 
3463 3463
     }
3464 3464
 
3465 3465
     /**
3466
-	 * Recalculates the invoice tax total.
3467
-	 *
3468
-	 * @since 1.0.19
3469
-	 * @return float The recalculated tax
3470
-	 */
3471
-	public function recalculate_total_tax() {
3466
+     * Recalculates the invoice tax total.
3467
+     *
3468
+     * @since 1.0.19
3469
+     * @return float The recalculated tax
3470
+     */
3471
+    public function recalculate_total_tax() {
3472 3472
         $taxes     = $this->get_taxes();
3473
-		$tax       = 0;
3474
-		$recurring = 0;
3473
+        $tax       = 0;
3474
+        $recurring = 0;
3475 3475
 
3476 3476
         foreach ( $taxes as $data ) {
3477 3477
 
3478
-			if ( $data['recurring'] ) {
3479
-				$recurring += $data['amount'];
3480
-			} else {
3481
-				$tax += $data['amount'];
3482
-			}
3478
+            if ( $data['recurring'] ) {
3479
+                $recurring += $data['amount'];
3480
+            } else {
3481
+                $tax += $data['amount'];
3482
+            }
3483 3483
 
3484
-		}
3484
+        }
3485 3485
 
3486
-		if ( $this->is_renewal() ) {
3487
-			$this->set_total_tax( $recurring );
3488
-		} else {
3489
-			$this->set_total_tax( $tax );
3490
-		}
3486
+        if ( $this->is_renewal() ) {
3487
+            $this->set_total_tax( $recurring );
3488
+        } else {
3489
+            $this->set_total_tax( $tax );
3490
+        }
3491 3491
 
3492
-		$this->totals['tax'] = array(
3493
-			'initial'   => $tax,
3494
-			'recurring' => $recurring,
3495
-		);
3492
+        $this->totals['tax'] = array(
3493
+            'initial'   => $tax,
3494
+            'recurring' => $recurring,
3495
+        );
3496 3496
 
3497
-		return $this->is_renewal() ? $recurring : $tax;
3497
+        return $this->is_renewal() ? $recurring : $tax;
3498 3498
 
3499 3499
     }
3500 3500
 
3501 3501
     /**
3502
-	 * Recalculates the invoice fees total.
3503
-	 *
3504
-	 * @since 1.0.19
3505
-	 * @return float The recalculated fee
3506
-	 */
3507
-	public function recalculate_total_fees() {
3508
-		$fees      = $this->get_fees();
3509
-		$fee       = 0;
3510
-		$recurring = 0;
3502
+     * Recalculates the invoice fees total.
3503
+     *
3504
+     * @since 1.0.19
3505
+     * @return float The recalculated fee
3506
+     */
3507
+    public function recalculate_total_fees() {
3508
+        $fees      = $this->get_fees();
3509
+        $fee       = 0;
3510
+        $recurring = 0;
3511 3511
 
3512 3512
         foreach ( $fees as $data ) {
3513 3513
 
3514
-			if ( $data['recurring'] ) {
3515
-				$recurring += $data['amount'];
3516
-			} else {
3517
-				$fee += $data['amount'];
3518
-			}
3514
+            if ( $data['recurring'] ) {
3515
+                $recurring += $data['amount'];
3516
+            } else {
3517
+                $fee += $data['amount'];
3518
+            }
3519 3519
 
3520
-		}
3520
+        }
3521 3521
 
3522 3522
         if ( $this->is_renewal() ) {
3523
-			$this->set_total_fees( $recurring );
3524
-		} else {
3525
-			$this->set_total_fees( $fee );
3526
-		}
3523
+            $this->set_total_fees( $recurring );
3524
+        } else {
3525
+            $this->set_total_fees( $fee );
3526
+        }
3527 3527
 
3528
-		$this->totals['fee'] = array(
3529
-			'initial'   => $fee,
3530
-			'recurring' => $recurring,
3531
-		);
3528
+        $this->totals['fee'] = array(
3529
+            'initial'   => $fee,
3530
+            'recurring' => $recurring,
3531
+        );
3532 3532
 
3533 3533
         $this->set_total_fees( $fee );
3534 3534
         return $this->is_renewal() ? $recurring : $fee;
3535 3535
     }
3536 3536
 
3537 3537
     /**
3538
-	 * Recalculates the invoice total.
3539
-	 *
3540
-	 * @since 1.0.19
3538
+     * Recalculates the invoice total.
3539
+     *
3540
+     * @since 1.0.19
3541 3541
      * @return float The invoice total
3542
-	 */
3543
-	public function recalculate_total() {
3542
+     */
3543
+    public function recalculate_total() {
3544 3544
         $this->recalculate_subtotal();
3545 3545
         $this->recalculate_total_fees();
3546 3546
         $this->recalculate_total_discount();
3547 3547
         $this->recalculate_total_tax();
3548
-		return $this->get_total();
3549
-	}
3548
+        return $this->get_total();
3549
+    }
3550 3550
 
3551
-	/**
3552
-	 * @deprecated
3553
-	 */
3551
+    /**
3552
+     * @deprecated
3553
+     */
3554 3554
     public function recalculate_totals( $temp = false ) {
3555 3555
         $this->update_items( $temp );
3556 3556
         $this->save( true );
@@ -3568,7 +3568,7 @@  discard block
 block discarded – undo
3568 3568
      * Adds a note to an invoice.
3569 3569
      *
3570 3570
      * @param string $note The note being added.
3571
-	 * @return int|false The new note's ID on success, false on failure.
3571
+     * @return int|false The new note's ID on success, false on failure.
3572 3572
      *
3573 3573
      */
3574 3574
     public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
@@ -3578,21 +3578,21 @@  discard block
 block discarded – undo
3578 3578
             return false;
3579 3579
         }
3580 3580
 
3581
-		$author       = 'System';
3582
-		$author_email = '[email protected]';
3581
+        $author       = 'System';
3582
+        $author_email = '[email protected]';
3583 3583
 
3584
-		// If this is an admin comment or it has been added by the user.
3585
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3586
-			$user         = get_user_by( 'id', get_current_user_id() );
3584
+        // If this is an admin comment or it has been added by the user.
3585
+        if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3586
+            $user         = get_user_by( 'id', get_current_user_id() );
3587 3587
             $author       = $user->display_name;
3588 3588
             $author_email = $user->user_email;
3589
-		}
3589
+        }
3590 3590
 
3591
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3591
+        return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3592 3592
 
3593
-	}
3593
+    }
3594 3594
 
3595
-	/**
3595
+    /**
3596 3596
      * Generates a unique key for the invoice.
3597 3597
      */
3598 3598
     public function generate_key( $string = '' ) {
@@ -3612,105 +3612,105 @@  discard block
 block discarded – undo
3612 3612
             $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3613 3613
         }
3614 3614
 
3615
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3615
+        return wpinv_format_invoice_number( $number, $this->get_post_type() );
3616 3616
 
3617
-	}
3617
+    }
3618 3618
 
3619
-	/**
3620
-	 * Handle the status transition.
3621
-	 */
3622
-	protected function status_transition() {
3623
-		$status_transition = $this->status_transition;
3619
+    /**
3620
+     * Handle the status transition.
3621
+     */
3622
+    protected function status_transition() {
3623
+        $status_transition = $this->status_transition;
3624 3624
 
3625
-		// Reset status transition variable.
3626
-		$this->status_transition = false;
3625
+        // Reset status transition variable.
3626
+        $this->status_transition = false;
3627 3627
 
3628
-		if ( $status_transition ) {
3629
-			try {
3628
+        if ( $status_transition ) {
3629
+            try {
3630 3630
 
3631
-				// Fire a hook for the status change.
3632
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3631
+                // Fire a hook for the status change.
3632
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3633 3633
 
3634
-				// @deprecated this is deprecated and will be removed in the future.
3635
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3634
+                // @deprecated this is deprecated and will be removed in the future.
3635
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3636 3636
 
3637
-				if ( ! empty( $status_transition['from'] ) ) {
3637
+                if ( ! empty( $status_transition['from'] ) ) {
3638 3638
 
3639
-					/* translators: 1: old invoice status 2: new invoice status */
3640
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3639
+                    /* translators: 1: old invoice status 2: new invoice status */
3640
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3641 3641
 
3642
-					// Fire another hook.
3643
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3644
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3642
+                    // Fire another hook.
3643
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3644
+                    do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3645 3645
 
3646
-					// @deprecated this is deprecated and will be removed in the future.
3647
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3646
+                    // @deprecated this is deprecated and will be removed in the future.
3647
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3648 3648
 
3649
-					// Note the transition occurred.
3650
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3649
+                    // Note the transition occurred.
3650
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3651 3651
 
3652
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3653
-					if (
3654
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3655
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3656
-					) {
3657
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3658
-					}
3659
-				} else {
3660
-					/* translators: %s: new invoice status */
3661
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3652
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3653
+                    if (
3654
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3655
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3656
+                    ) {
3657
+                        do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3658
+                    }
3659
+                } else {
3660
+                    /* translators: %s: new invoice status */
3661
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3662 3662
 
3663
-					// Note the transition occurred.
3664
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3663
+                    // Note the transition occurred.
3664
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3665 3665
 
3666
-				}
3667
-			} catch ( Exception $e ) {
3668
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3669
-			}
3670
-		}
3671
-	}
3666
+                }
3667
+            } catch ( Exception $e ) {
3668
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3669
+            }
3670
+        }
3671
+    }
3672 3672
 
3673
-	/**
3674
-	 * Updates an invoice status.
3675
-	 */
3676
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3673
+    /**
3674
+     * Updates an invoice status.
3675
+     */
3676
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3677 3677
 
3678
-		// Fires before updating a status.
3679
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3678
+        // Fires before updating a status.
3679
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3680 3680
 
3681
-		// Update the status.
3682
-		$this->set_status( $new_status, $note, $manual );
3681
+        // Update the status.
3682
+        $this->set_status( $new_status, $note, $manual );
3683 3683
 
3684
-		// Save the order.
3685
-		return $this->save();
3684
+        // Save the order.
3685
+        return $this->save();
3686 3686
 
3687
-	}
3687
+    }
3688 3688
 
3689
-	/**
3690
-	 * @deprecated
3691
-	 */
3692
-	public function refresh_item_ids() {
3689
+    /**
3690
+     * @deprecated
3691
+     */
3692
+    public function refresh_item_ids() {
3693 3693
         $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3694 3694
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3695
-	}
3695
+    }
3696 3696
 
3697
-	/**
3698
-	 * @deprecated
3699
-	 */
3700
-	public function update_items( $temp = false ) {
3697
+    /**
3698
+     * @deprecated
3699
+     */
3700
+    public function update_items( $temp = false ) {
3701 3701
 
3702
-		$this->set_items( $this->get_items() );
3702
+        $this->set_items( $this->get_items() );
3703 3703
 
3704
-		if ( ! $temp ) {
3705
-			$this->save();
3706
-		}
3704
+        if ( ! $temp ) {
3705
+            $this->save();
3706
+        }
3707 3707
 
3708 3708
         return $this;
3709
-	}
3709
+    }
3710 3710
 
3711
-	/**
3712
-	 * @deprecated
3713
-	 */
3711
+    /**
3712
+     * @deprecated
3713
+     */
3714 3714
     public function validate_discount() {
3715 3715
 
3716 3716
         $discount_code = $this->get_discount_code();
@@ -3726,97 +3726,97 @@  discard block
 block discarded – undo
3726 3726
 
3727 3727
     }
3728 3728
 
3729
-	/**
3730
-	 * Refunds an invoice.
3731
-	 */
3729
+    /**
3730
+     * Refunds an invoice.
3731
+     */
3732 3732
     public function refund() {
3733
-		$this->set_status( 'wpi-refunded' );
3733
+        $this->set_status( 'wpi-refunded' );
3734 3734
         $this->save();
3735
-	}
3735
+    }
3736 3736
 
3737
-	/**
3738
-	 * Marks an invoice as paid.
3739
-	 * 
3740
-	 * @param string $transaction_id
3741
-	 */
3737
+    /**
3738
+     * Marks an invoice as paid.
3739
+     * 
3740
+     * @param string $transaction_id
3741
+     */
3742 3742
     public function mark_paid( $transaction_id = null, $note = '' ) {
3743 3743
 
3744
-		// Set the transaction id.
3745
-		if ( empty( $transaction_id ) ) {
3746
-			$transaction_id = $this->generate_key('trans_');
3747
-		}
3744
+        // Set the transaction id.
3745
+        if ( empty( $transaction_id ) ) {
3746
+            $transaction_id = $this->generate_key('trans_');
3747
+        }
3748 3748
 
3749
-		if ( ! $this->get_transaction_id() ) {
3750
-			$this->set_transaction_id( $transaction_id );
3751
-		}
3749
+        if ( ! $this->get_transaction_id() ) {
3750
+            $this->set_transaction_id( $transaction_id );
3751
+        }
3752 3752
 
3753
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3754
-			return $this->save();
3755
-		}
3753
+        if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3754
+            return $this->save();
3755
+        }
3756 3756
 
3757
-		// Set the completed date.
3758
-		$this->set_date_completed( current_time( 'mysql' ) );
3757
+        // Set the completed date.
3758
+        $this->set_date_completed( current_time( 'mysql' ) );
3759 3759
 
3760
-		// Set the new status.
3761
-		if ( $this->is_renewal() ) {
3760
+        // Set the new status.
3761
+        if ( $this->is_renewal() ) {
3762 3762
 
3763
-			$_note = sprintf(
3764
-				__( 'Renewed via %s', 'invoicing' ),
3765
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3766
-			);
3763
+            $_note = sprintf(
3764
+                __( 'Renewed via %s', 'invoicing' ),
3765
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3766
+            );
3767 3767
 
3768
-			if ( 'none' == $this->get_gateway() ) {
3769
-				$_note = $note;
3770
-			}
3768
+            if ( 'none' == $this->get_gateway() ) {
3769
+                $_note = $note;
3770
+            }
3771 3771
 
3772
-			$this->set_status( 'wpi-renewal', $_note );
3772
+            $this->set_status( 'wpi-renewal', $_note );
3773 3773
 
3774
-		} else {
3774
+        } else {
3775 3775
 
3776
-			$_note = sprintf(
3777
-				__( 'Paid via %s', 'invoicing' ),
3778
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3779
-			);
3776
+            $_note = sprintf(
3777
+                __( 'Paid via %s', 'invoicing' ),
3778
+                $this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3779
+            );
3780 3780
 
3781
-			if ( 'none' == $this->get_gateway() ) {
3782
-				$_note = $note;
3783
-			}
3781
+            if ( 'none' == $this->get_gateway() ) {
3782
+                $_note = $note;
3783
+            }
3784 3784
 
3785
-			$this->set_status( 'publish',$_note );
3785
+            $this->set_status( 'publish',$_note );
3786 3786
 
3787
-		}
3787
+        }
3788 3788
 
3789
-		// Set checkout mode.
3790
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3791
-		$this->set_mode( $mode );
3789
+        // Set checkout mode.
3790
+        $mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3791
+        $this->set_mode( $mode );
3792 3792
 
3793
-		// Save the invoice.
3793
+        // Save the invoice.
3794 3794
         $this->save();
3795
-	}
3796
-
3797
-
3798
-	/**
3799
-	 * Save data to the database.
3800
-	 *
3801
-	 * @since 1.0.19
3802
-	 * @return int invoice ID
3803
-	 */
3804
-	public function save() {
3805
-		$this->maybe_set_date_paid();
3806
-		$this->maybe_set_key();
3807
-		parent::save();
3808
-		$this->clear_cache();
3809
-		$this->status_transition();
3810
-		return $this->get_id();
3811
-	}
3812
-
3813
-	/**
3795
+    }
3796
+
3797
+
3798
+    /**
3799
+     * Save data to the database.
3800
+     *
3801
+     * @since 1.0.19
3802
+     * @return int invoice ID
3803
+     */
3804
+    public function save() {
3805
+        $this->maybe_set_date_paid();
3806
+        $this->maybe_set_key();
3807
+        parent::save();
3808
+        $this->clear_cache();
3809
+        $this->status_transition();
3810
+        return $this->get_id();
3811
+    }
3812
+
3813
+    /**
3814 3814
      * Clears the subscription's cache.
3815 3815
      */
3816 3816
     public function clear_cache() {
3817
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3818
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3819
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3820
-	}
3817
+        wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3818
+        wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3819
+        wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3820
+    }
3821 3821
 
3822 3822
 }
Please login to merge, or discard this patch.
Spacing   +758 added lines, -758 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,27 +335,27 @@  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( $formatted = true ) {
345
+	public function get_invoice_date($formatted = true) {
346 346
         $date_completed = $this->get_date_completed();
347 347
         $invoice_date   = $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
348 348
 
349
-        if ( $invoice_date == '' ) {
349
+        if ($invoice_date == '') {
350 350
             $date_created   = $this->get_date_created();
351 351
             $invoice_date   = $date_created != '0000-00-00 00:00:00' ? $date_created : '';
352 352
         }
353 353
 
354
-        if ( $formatted && $invoice_date ) {
355
-            $invoice_date   = date_i18n( get_option( 'date_format' ), strtotime( $invoice_date ) );
354
+        if ($formatted && $invoice_date) {
355
+            $invoice_date = date_i18n(get_option('date_format'), strtotime($invoice_date));
356 356
         }
357 357
 
358
-        return apply_filters( 'wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this );
358
+        return apply_filters('wpinv_get_invoice_date', $invoice_date, $formatted, $this->get_id(), $this);
359 359
     }
360 360
 
361 361
     /**
@@ -365,8 +365,8 @@  discard block
 block discarded – undo
365 365
 	 * @param  string $context View or edit context.
366 366
 	 * @return string
367 367
 	 */
368
-	public function get_date_created( $context = 'view' ) {
369
-		return $this->get_prop( 'date_created', $context );
368
+	public function get_date_created($context = 'view') {
369
+		return $this->get_prop('date_created', $context);
370 370
 	}
371 371
 	
372 372
 	/**
@@ -376,8 +376,8 @@  discard block
 block discarded – undo
376 376
 	 * @param  string $context View or edit context.
377 377
 	 * @return string
378 378
 	 */
379
-	public function get_created_date( $context = 'view' ) {
380
-		return $this->get_date_created( $context );
379
+	public function get_created_date($context = 'view') {
380
+		return $this->get_date_created($context);
381 381
     }
382 382
 
383 383
     /**
@@ -387,11 +387,11 @@  discard block
 block discarded – undo
387 387
 	 * @param  string $context View or edit context.
388 388
 	 * @return string
389 389
 	 */
390
-	public function get_date_created_gmt( $context = 'view' ) {
391
-        $date = $this->get_date_created( $context );
390
+	public function get_date_created_gmt($context = 'view') {
391
+        $date = $this->get_date_created($context);
392 392
 
393
-        if ( $date ) {
394
-            $date = get_gmt_from_date( $date );
393
+        if ($date) {
394
+            $date = get_gmt_from_date($date);
395 395
         }
396 396
 		return $date;
397 397
     }
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 	 * @param  string $context View or edit context.
404 404
 	 * @return string
405 405
 	 */
406
-	public function get_date_modified( $context = 'view' ) {
407
-		return $this->get_prop( 'date_modified', $context );
406
+	public function get_date_modified($context = 'view') {
407
+		return $this->get_prop('date_modified', $context);
408 408
 	}
409 409
 
410 410
 	/**
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
 	 * @param  string $context View or edit context.
415 415
 	 * @return string
416 416
 	 */
417
-	public function get_modified_date( $context = 'view' ) {
418
-		return $this->get_date_modified( $context );
417
+	public function get_modified_date($context = 'view') {
418
+		return $this->get_date_modified($context);
419 419
     }
420 420
 
421 421
     /**
@@ -425,11 +425,11 @@  discard block
 block discarded – undo
425 425
 	 * @param  string $context View or edit context.
426 426
 	 * @return string
427 427
 	 */
428
-	public function get_date_modified_gmt( $context = 'view' ) {
429
-        $date = $this->get_date_modified( $context );
428
+	public function get_date_modified_gmt($context = 'view') {
429
+        $date = $this->get_date_modified($context);
430 430
 
431
-        if ( $date ) {
432
-            $date = get_gmt_from_date( $date );
431
+        if ($date) {
432
+            $date = get_gmt_from_date($date);
433 433
         }
434 434
 		return $date;
435 435
     }
@@ -441,8 +441,8 @@  discard block
 block discarded – undo
441 441
 	 * @param  string $context View or edit context.
442 442
 	 * @return string
443 443
 	 */
444
-	public function get_due_date( $context = 'view' ) {
445
-		return $this->get_prop( 'due_date', $context );
444
+	public function get_due_date($context = 'view') {
445
+		return $this->get_prop('due_date', $context);
446 446
     }
447 447
 
448 448
     /**
@@ -452,8 +452,8 @@  discard block
 block discarded – undo
452 452
 	 * @param  string $context View or edit context.
453 453
 	 * @return string
454 454
 	 */
455
-	public function get_date_due( $context = 'view' ) {
456
-		return $this->get_due_date( $context );
455
+	public function get_date_due($context = 'view') {
456
+		return $this->get_due_date($context);
457 457
     }
458 458
 
459 459
     /**
@@ -463,11 +463,11 @@  discard block
 block discarded – undo
463 463
 	 * @param  string $context View or edit context.
464 464
 	 * @return string
465 465
 	 */
466
-	public function get_due_date_gmt( $context = 'view' ) {
467
-        $date = $this->get_due_date( $context );
466
+	public function get_due_date_gmt($context = 'view') {
467
+        $date = $this->get_due_date($context);
468 468
 
469
-        if ( $date ) {
470
-            $date = get_gmt_from_date( $date );
469
+        if ($date) {
470
+            $date = get_gmt_from_date($date);
471 471
         }
472 472
 		return $date;
473 473
     }
@@ -479,8 +479,8 @@  discard block
 block discarded – undo
479 479
 	 * @param  string $context View or edit context.
480 480
 	 * @return string
481 481
 	 */
482
-	public function get_gmt_date_due( $context = 'view' ) {
483
-		return $this->get_due_date_gmt( $context );
482
+	public function get_gmt_date_due($context = 'view') {
483
+		return $this->get_due_date_gmt($context);
484 484
     }
485 485
 
486 486
     /**
@@ -490,8 +490,8 @@  discard block
 block discarded – undo
490 490
 	 * @param  string $context View or edit context.
491 491
 	 * @return string
492 492
 	 */
493
-	public function get_completed_date( $context = 'view' ) {
494
-		return $this->get_prop( 'completed_date', $context );
493
+	public function get_completed_date($context = 'view') {
494
+		return $this->get_prop('completed_date', $context);
495 495
     }
496 496
 
497 497
     /**
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 	 * @param  string $context View or edit context.
502 502
 	 * @return string
503 503
 	 */
504
-	public function get_date_completed( $context = 'view' ) {
505
-		return $this->get_completed_date( $context );
504
+	public function get_date_completed($context = 'view') {
505
+		return $this->get_completed_date($context);
506 506
     }
507 507
 
508 508
     /**
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
 	 * @param  string $context View or edit context.
513 513
 	 * @return string
514 514
 	 */
515
-	public function get_completed_date_gmt( $context = 'view' ) {
516
-        $date = $this->get_completed_date( $context );
515
+	public function get_completed_date_gmt($context = 'view') {
516
+        $date = $this->get_completed_date($context);
517 517
 
518
-        if ( $date ) {
519
-            $date = get_gmt_from_date( $date );
518
+        if ($date) {
519
+            $date = get_gmt_from_date($date);
520 520
         }
521 521
 		return $date;
522 522
     }
@@ -528,8 +528,8 @@  discard block
 block discarded – undo
528 528
 	 * @param  string $context View or edit context.
529 529
 	 * @return string
530 530
 	 */
531
-	public function get_gmt_completed_date( $context = 'view' ) {
532
-		return $this->get_completed_date_gmt( $context );
531
+	public function get_gmt_completed_date($context = 'view') {
532
+		return $this->get_completed_date_gmt($context);
533 533
     }
534 534
 
535 535
     /**
@@ -539,12 +539,12 @@  discard block
 block discarded – undo
539 539
 	 * @param  string $context View or edit context.
540 540
 	 * @return string
541 541
 	 */
542
-	public function get_number( $context = 'view' ) {
543
-		$number = $this->get_prop( 'number', $context );
542
+	public function get_number($context = 'view') {
543
+		$number = $this->get_prop('number', $context);
544 544
 
545
-		if ( empty( $number ) ) {
545
+		if (empty($number)) {
546 546
 			$number = $this->generate_number();
547
-			$this->set_number( $this->generate_number() );
547
+			$this->set_number($this->generate_number());
548 548
 		}
549 549
 
550 550
 		return $number;
@@ -558,8 +558,8 @@  discard block
 block discarded – undo
558 558
 	public function maybe_set_number() {
559 559
         $number = $this->get_number();
560 560
 
561
-        if ( empty( $number ) || $this->get_id() == $number ) {
562
-			$this->set_number( $this->generate_number() );
561
+        if (empty($number) || $this->get_id() == $number) {
562
+			$this->set_number($this->generate_number());
563 563
         }
564 564
 
565 565
 	}
@@ -571,8 +571,8 @@  discard block
 block discarded – undo
571 571
 	 * @param  string $context View or edit context.
572 572
 	 * @return string
573 573
 	 */
574
-	public function get_key( $context = 'view' ) {
575
-        return $this->get_prop( 'key', $context );
574
+	public function get_key($context = 'view') {
575
+        return $this->get_prop('key', $context);
576 576
 	}
577 577
 
578 578
 	/**
@@ -583,9 +583,9 @@  discard block
 block discarded – undo
583 583
 	public function maybe_set_key() {
584 584
         $key = $this->get_key();
585 585
 
586
-        if ( empty( $key ) ) {
587
-            $key = $this->generate_key( $this->get_type() . '_' );
588
-            $this->set_key( $key );
586
+        if (empty($key)) {
587
+            $key = $this->generate_key($this->get_type() . '_');
588
+            $this->set_key($key);
589 589
         }
590 590
 
591 591
     }
@@ -597,15 +597,15 @@  discard block
 block discarded – undo
597 597
 	 * @param  string $context View or edit context.
598 598
 	 * @return string
599 599
 	 */
600
-	public function get_type( $context = 'view' ) {
601
-        return $this->get_prop( 'type', $context );
600
+	public function get_type($context = 'view') {
601
+        return $this->get_prop('type', $context);
602 602
 	}
603 603
 
604 604
 	/**
605 605
 	 * @deprecated
606 606
 	 */
607 607
 	public function get_invoice_quote_type() {
608
-        ucfirst( $this->get_type() );
608
+        ucfirst($this->get_type());
609 609
     }
610 610
 
611 611
     /**
@@ -615,8 +615,8 @@  discard block
 block discarded – undo
615 615
 	 * @param  string $context View or edit context.
616 616
 	 * @return string
617 617
 	 */
618
-	public function get_post_type( $context = 'view' ) {
619
-        return $this->get_prop( 'post_type', $context );
618
+	public function get_post_type($context = 'view') {
619
+        return $this->get_prop('post_type', $context);
620 620
     }
621 621
 
622 622
     /**
@@ -626,8 +626,8 @@  discard block
 block discarded – undo
626 626
 	 * @param  string $context View or edit context.
627 627
 	 * @return string
628 628
 	 */
629
-	public function get_mode( $context = 'view' ) {
630
-        return $this->get_prop( 'mode', $context );
629
+	public function get_mode($context = 'view') {
630
+        return $this->get_prop('mode', $context);
631 631
     }
632 632
 
633 633
     /**
@@ -637,13 +637,13 @@  discard block
 block discarded – undo
637 637
 	 * @param  string $context View or edit context.
638 638
 	 * @return string
639 639
 	 */
640
-	public function get_path( $context = 'view' ) {
641
-        $path   = $this->get_prop( 'path', $context );
642
-		$prefix = wpinv_post_name_prefix( $this->get_post_type() );
640
+	public function get_path($context = 'view') {
641
+        $path = $this->get_prop('path', $context);
642
+		$prefix = wpinv_post_name_prefix($this->get_post_type());
643 643
 
644
-		if ( 0 !== strpos( $path, $prefix ) ) {
645
-			$path = sanitize_title(  $prefix . $this->get_id()  );
646
-			$this->set_path( $path );
644
+		if (0 !== strpos($path, $prefix)) {
645
+			$path = sanitize_title($prefix . $this->get_id());
646
+			$this->set_path($path);
647 647
 		}
648 648
 
649 649
 		return $path;
@@ -656,8 +656,8 @@  discard block
 block discarded – undo
656 656
 	 * @param  string $context View or edit context.
657 657
 	 * @return string
658 658
 	 */
659
-	public function get_name( $context = 'view' ) {
660
-        return $this->get_prop( 'title', $context );
659
+	public function get_name($context = 'view') {
660
+        return $this->get_prop('title', $context);
661 661
     }
662 662
 
663 663
     /**
@@ -667,8 +667,8 @@  discard block
 block discarded – undo
667 667
 	 * @param  string $context View or edit context.
668 668
 	 * @return string
669 669
 	 */
670
-	public function get_title( $context = 'view' ) {
671
-		return $this->get_name( $context );
670
+	public function get_title($context = 'view') {
671
+		return $this->get_name($context);
672 672
     }
673 673
 
674 674
     /**
@@ -678,8 +678,8 @@  discard block
 block discarded – undo
678 678
 	 * @param  string $context View or edit context.
679 679
 	 * @return string
680 680
 	 */
681
-	public function get_description( $context = 'view' ) {
682
-		return $this->get_prop( 'description', $context );
681
+	public function get_description($context = 'view') {
682
+		return $this->get_prop('description', $context);
683 683
     }
684 684
 
685 685
     /**
@@ -689,8 +689,8 @@  discard block
 block discarded – undo
689 689
 	 * @param  string $context View or edit context.
690 690
 	 * @return string
691 691
 	 */
692
-	public function get_excerpt( $context = 'view' ) {
693
-		return $this->get_description( $context );
692
+	public function get_excerpt($context = 'view') {
693
+		return $this->get_description($context);
694 694
     }
695 695
 
696 696
     /**
@@ -700,8 +700,8 @@  discard block
 block discarded – undo
700 700
 	 * @param  string $context View or edit context.
701 701
 	 * @return string
702 702
 	 */
703
-	public function get_summary( $context = 'view' ) {
704
-		return $this->get_description( $context );
703
+	public function get_summary($context = 'view') {
704
+		return $this->get_description($context);
705 705
     }
706 706
 
707 707
     /**
@@ -711,25 +711,25 @@  discard block
 block discarded – undo
711 711
      * @param  string $context View or edit context.
712 712
 	 * @return array
713 713
 	 */
714
-    public function get_user_info( $context = 'view' ) {
714
+    public function get_user_info($context = 'view') {
715 715
 
716 716
         $user_info = array(
717
-            'user_id'    => $this->get_user_id( $context ),
718
-            'email'      => $this->get_email( $context ),
719
-            'first_name' => $this->get_first_name( $context ),
720
-            'last_name'  => $this->get_last_name( $context ),
721
-            'address'    => $this->get_address( $context ),
722
-            'phone'      => $this->get_phone( $context ),
723
-            'city'       => $this->get_city( $context ),
724
-            'country'    => $this->get_country( $context ),
725
-            'state'      => $this->get_state( $context ),
726
-            'zip'        => $this->get_zip( $context ),
727
-            'company'    => $this->get_company( $context ),
728
-            'vat_number' => $this->get_vat_number( $context ),
729
-            'discount'   => $this->get_discount_code( $context ),
717
+            'user_id'    => $this->get_user_id($context),
718
+            'email'      => $this->get_email($context),
719
+            'first_name' => $this->get_first_name($context),
720
+            'last_name'  => $this->get_last_name($context),
721
+            'address'    => $this->get_address($context),
722
+            'phone'      => $this->get_phone($context),
723
+            'city'       => $this->get_city($context),
724
+            'country'    => $this->get_country($context),
725
+            'state'      => $this->get_state($context),
726
+            'zip'        => $this->get_zip($context),
727
+            'company'    => $this->get_company($context),
728
+            'vat_number' => $this->get_vat_number($context),
729
+            'discount'   => $this->get_discount_code($context),
730 730
 		);
731 731
 
732
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
732
+		return apply_filters('wpinv_user_info', $user_info, $this->get_id(), $this);
733 733
 
734 734
     }
735 735
 
@@ -740,8 +740,8 @@  discard block
 block discarded – undo
740 740
 	 * @param  string $context View or edit context.
741 741
 	 * @return int
742 742
 	 */
743
-	public function get_author( $context = 'view' ) {
744
-		return (int) $this->get_prop( 'author', $context );
743
+	public function get_author($context = 'view') {
744
+		return (int) $this->get_prop('author', $context);
745 745
     }
746 746
 
747 747
     /**
@@ -751,8 +751,8 @@  discard block
 block discarded – undo
751 751
 	 * @param  string $context View or edit context.
752 752
 	 * @return int
753 753
 	 */
754
-	public function get_user_id( $context = 'view' ) {
755
-		return $this->get_author( $context );
754
+	public function get_user_id($context = 'view') {
755
+		return $this->get_author($context);
756 756
     }
757 757
 
758 758
      /**
@@ -762,8 +762,8 @@  discard block
 block discarded – undo
762 762
 	 * @param  string $context View or edit context.
763 763
 	 * @return int
764 764
 	 */
765
-	public function get_customer_id( $context = 'view' ) {
766
-		return $this->get_author( $context );
765
+	public function get_customer_id($context = 'view') {
766
+		return $this->get_author($context);
767 767
     }
768 768
 
769 769
     /**
@@ -773,8 +773,8 @@  discard block
 block discarded – undo
773 773
 	 * @param  string $context View or edit context.
774 774
 	 * @return string
775 775
 	 */
776
-	public function get_ip( $context = 'view' ) {
777
-		return $this->get_prop( 'user_ip', $context );
776
+	public function get_ip($context = 'view') {
777
+		return $this->get_prop('user_ip', $context);
778 778
     }
779 779
 
780 780
     /**
@@ -784,8 +784,8 @@  discard block
 block discarded – undo
784 784
 	 * @param  string $context View or edit context.
785 785
 	 * @return string
786 786
 	 */
787
-	public function get_user_ip( $context = 'view' ) {
788
-		return $this->get_ip( $context );
787
+	public function get_user_ip($context = 'view') {
788
+		return $this->get_ip($context);
789 789
     }
790 790
 
791 791
      /**
@@ -795,8 +795,8 @@  discard block
 block discarded – undo
795 795
 	 * @param  string $context View or edit context.
796 796
 	 * @return string
797 797
 	 */
798
-	public function get_customer_ip( $context = 'view' ) {
799
-		return $this->get_ip( $context );
798
+	public function get_customer_ip($context = 'view') {
799
+		return $this->get_ip($context);
800 800
     }
801 801
 
802 802
     /**
@@ -806,8 +806,8 @@  discard block
 block discarded – undo
806 806
 	 * @param  string $context View or edit context.
807 807
 	 * @return string
808 808
 	 */
809
-	public function get_first_name( $context = 'view' ) {
810
-		return $this->get_prop( 'first_name', $context );
809
+	public function get_first_name($context = 'view') {
810
+		return $this->get_prop('first_name', $context);
811 811
     }
812 812
 
813 813
     /**
@@ -817,8 +817,8 @@  discard block
 block discarded – undo
817 817
 	 * @param  string $context View or edit context.
818 818
 	 * @return int
819 819
 	 */
820
-	public function get_user_first_name( $context = 'view' ) {
821
-		return $this->get_first_name( $context );
820
+	public function get_user_first_name($context = 'view') {
821
+		return $this->get_first_name($context);
822 822
     }
823 823
 
824 824
      /**
@@ -828,8 +828,8 @@  discard block
 block discarded – undo
828 828
 	 * @param  string $context View or edit context.
829 829
 	 * @return int
830 830
 	 */
831
-	public function get_customer_first_name( $context = 'view' ) {
832
-		return $this->get_first_name( $context );
831
+	public function get_customer_first_name($context = 'view') {
832
+		return $this->get_first_name($context);
833 833
     }
834 834
 
835 835
     /**
@@ -839,8 +839,8 @@  discard block
 block discarded – undo
839 839
 	 * @param  string $context View or edit context.
840 840
 	 * @return string
841 841
 	 */
842
-	public function get_last_name( $context = 'view' ) {
843
-		return $this->get_prop( 'last_name', $context );
842
+	public function get_last_name($context = 'view') {
843
+		return $this->get_prop('last_name', $context);
844 844
     }
845 845
 
846 846
     /**
@@ -850,8 +850,8 @@  discard block
 block discarded – undo
850 850
 	 * @param  string $context View or edit context.
851 851
 	 * @return int
852 852
 	 */
853
-	public function get_user_last_name( $context = 'view' ) {
854
-		return $this->get_last_name( $context );
853
+	public function get_user_last_name($context = 'view') {
854
+		return $this->get_last_name($context);
855 855
     }
856 856
 
857 857
     /**
@@ -861,8 +861,8 @@  discard block
 block discarded – undo
861 861
 	 * @param  string $context View or edit context.
862 862
 	 * @return int
863 863
 	 */
864
-	public function get_customer_last_name( $context = 'view' ) {
865
-		return $this->get_last_name( $context );
864
+	public function get_customer_last_name($context = 'view') {
865
+		return $this->get_last_name($context);
866 866
     }
867 867
 
868 868
     /**
@@ -872,8 +872,8 @@  discard block
 block discarded – undo
872 872
 	 * @param  string $context View or edit context.
873 873
 	 * @return string
874 874
 	 */
875
-	public function get_full_name( $context = 'view' ) {
876
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
875
+	public function get_full_name($context = 'view') {
876
+		return trim($this->get_first_name($context) . ' ' . $this->get_last_name($context));
877 877
     }
878 878
 
879 879
     /**
@@ -883,8 +883,8 @@  discard block
 block discarded – undo
883 883
 	 * @param  string $context View or edit context.
884 884
 	 * @return int
885 885
 	 */
886
-	public function get_user_full_name( $context = 'view' ) {
887
-		return $this->get_full_name( $context );
886
+	public function get_user_full_name($context = 'view') {
887
+		return $this->get_full_name($context);
888 888
     }
889 889
 
890 890
     /**
@@ -894,8 +894,8 @@  discard block
 block discarded – undo
894 894
 	 * @param  string $context View or edit context.
895 895
 	 * @return int
896 896
 	 */
897
-	public function get_customer_full_name( $context = 'view' ) {
898
-		return $this->get_full_name( $context );
897
+	public function get_customer_full_name($context = 'view') {
898
+		return $this->get_full_name($context);
899 899
     }
900 900
 
901 901
     /**
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
 	 * @param  string $context View or edit context.
906 906
 	 * @return string
907 907
 	 */
908
-	public function get_phone( $context = 'view' ) {
909
-		return $this->get_prop( 'phone', $context );
908
+	public function get_phone($context = 'view') {
909
+		return $this->get_prop('phone', $context);
910 910
     }
911 911
 
912 912
     /**
@@ -916,8 +916,8 @@  discard block
 block discarded – undo
916 916
 	 * @param  string $context View or edit context.
917 917
 	 * @return int
918 918
 	 */
919
-	public function get_phone_number( $context = 'view' ) {
920
-		return $this->get_phone( $context );
919
+	public function get_phone_number($context = 'view') {
920
+		return $this->get_phone($context);
921 921
     }
922 922
 
923 923
     /**
@@ -927,8 +927,8 @@  discard block
 block discarded – undo
927 927
 	 * @param  string $context View or edit context.
928 928
 	 * @return int
929 929
 	 */
930
-	public function get_user_phone( $context = 'view' ) {
931
-		return $this->get_phone( $context );
930
+	public function get_user_phone($context = 'view') {
931
+		return $this->get_phone($context);
932 932
     }
933 933
 
934 934
     /**
@@ -938,8 +938,8 @@  discard block
 block discarded – undo
938 938
 	 * @param  string $context View or edit context.
939 939
 	 * @return int
940 940
 	 */
941
-	public function get_customer_phone( $context = 'view' ) {
942
-		return $this->get_phone( $context );
941
+	public function get_customer_phone($context = 'view') {
942
+		return $this->get_phone($context);
943 943
     }
944 944
 
945 945
     /**
@@ -949,8 +949,8 @@  discard block
 block discarded – undo
949 949
 	 * @param  string $context View or edit context.
950 950
 	 * @return string
951 951
 	 */
952
-	public function get_email( $context = 'view' ) {
953
-		return $this->get_prop( 'email', $context );
952
+	public function get_email($context = 'view') {
953
+		return $this->get_prop('email', $context);
954 954
     }
955 955
 
956 956
     /**
@@ -960,8 +960,8 @@  discard block
 block discarded – undo
960 960
 	 * @param  string $context View or edit context.
961 961
 	 * @return string
962 962
 	 */
963
-	public function get_email_address( $context = 'view' ) {
964
-		return $this->get_email( $context );
963
+	public function get_email_address($context = 'view') {
964
+		return $this->get_email($context);
965 965
     }
966 966
 
967 967
     /**
@@ -971,8 +971,8 @@  discard block
 block discarded – undo
971 971
 	 * @param  string $context View or edit context.
972 972
 	 * @return int
973 973
 	 */
974
-	public function get_user_email( $context = 'view' ) {
975
-		return $this->get_email( $context );
974
+	public function get_user_email($context = 'view') {
975
+		return $this->get_email($context);
976 976
     }
977 977
 
978 978
     /**
@@ -982,8 +982,8 @@  discard block
 block discarded – undo
982 982
 	 * @param  string $context View or edit context.
983 983
 	 * @return int
984 984
 	 */
985
-	public function get_customer_email( $context = 'view' ) {
986
-		return $this->get_email( $context );
985
+	public function get_customer_email($context = 'view') {
986
+		return $this->get_email($context);
987 987
     }
988 988
 
989 989
     /**
@@ -993,9 +993,9 @@  discard block
 block discarded – undo
993 993
 	 * @param  string $context View or edit context.
994 994
 	 * @return string
995 995
 	 */
996
-	public function get_country( $context = 'view' ) {
997
-		$country = $this->get_prop( 'country', $context );
998
-		return empty( $country ) ? wpinv_get_default_country() : $country;
996
+	public function get_country($context = 'view') {
997
+		$country = $this->get_prop('country', $context);
998
+		return empty($country) ? wpinv_get_default_country() : $country;
999 999
     }
1000 1000
 
1001 1001
     /**
@@ -1005,8 +1005,8 @@  discard block
 block discarded – undo
1005 1005
 	 * @param  string $context View or edit context.
1006 1006
 	 * @return int
1007 1007
 	 */
1008
-	public function get_user_country( $context = 'view' ) {
1009
-		return $this->get_country( $context );
1008
+	public function get_user_country($context = 'view') {
1009
+		return $this->get_country($context);
1010 1010
     }
1011 1011
 
1012 1012
     /**
@@ -1016,8 +1016,8 @@  discard block
 block discarded – undo
1016 1016
 	 * @param  string $context View or edit context.
1017 1017
 	 * @return int
1018 1018
 	 */
1019
-	public function get_customer_country( $context = 'view' ) {
1020
-		return $this->get_country( $context );
1019
+	public function get_customer_country($context = 'view') {
1020
+		return $this->get_country($context);
1021 1021
     }
1022 1022
 
1023 1023
     /**
@@ -1027,9 +1027,9 @@  discard block
 block discarded – undo
1027 1027
 	 * @param  string $context View or edit context.
1028 1028
 	 * @return string
1029 1029
 	 */
1030
-	public function get_state( $context = 'view' ) {
1031
-		$state = $this->get_prop( 'state', $context );
1032
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1030
+	public function get_state($context = 'view') {
1031
+		$state = $this->get_prop('state', $context);
1032
+		return empty($state) ? wpinv_get_default_state() : $state;
1033 1033
     }
1034 1034
 
1035 1035
     /**
@@ -1039,8 +1039,8 @@  discard block
 block discarded – undo
1039 1039
 	 * @param  string $context View or edit context.
1040 1040
 	 * @return int
1041 1041
 	 */
1042
-	public function get_user_state( $context = 'view' ) {
1043
-		return $this->get_state( $context );
1042
+	public function get_user_state($context = 'view') {
1043
+		return $this->get_state($context);
1044 1044
     }
1045 1045
 
1046 1046
     /**
@@ -1050,8 +1050,8 @@  discard block
 block discarded – undo
1050 1050
 	 * @param  string $context View or edit context.
1051 1051
 	 * @return int
1052 1052
 	 */
1053
-	public function get_customer_state( $context = 'view' ) {
1054
-		return $this->get_state( $context );
1053
+	public function get_customer_state($context = 'view') {
1054
+		return $this->get_state($context);
1055 1055
     }
1056 1056
 
1057 1057
     /**
@@ -1061,8 +1061,8 @@  discard block
 block discarded – undo
1061 1061
 	 * @param  string $context View or edit context.
1062 1062
 	 * @return string
1063 1063
 	 */
1064
-	public function get_city( $context = 'view' ) {
1065
-		return $this->get_prop( 'city', $context );
1064
+	public function get_city($context = 'view') {
1065
+		return $this->get_prop('city', $context);
1066 1066
     }
1067 1067
 
1068 1068
     /**
@@ -1072,8 +1072,8 @@  discard block
 block discarded – undo
1072 1072
 	 * @param  string $context View or edit context.
1073 1073
 	 * @return string
1074 1074
 	 */
1075
-	public function get_user_city( $context = 'view' ) {
1076
-		return $this->get_city( $context );
1075
+	public function get_user_city($context = 'view') {
1076
+		return $this->get_city($context);
1077 1077
     }
1078 1078
 
1079 1079
     /**
@@ -1083,8 +1083,8 @@  discard block
 block discarded – undo
1083 1083
 	 * @param  string $context View or edit context.
1084 1084
 	 * @return string
1085 1085
 	 */
1086
-	public function get_customer_city( $context = 'view' ) {
1087
-		return $this->get_city( $context );
1086
+	public function get_customer_city($context = 'view') {
1087
+		return $this->get_city($context);
1088 1088
     }
1089 1089
 
1090 1090
     /**
@@ -1094,8 +1094,8 @@  discard block
 block discarded – undo
1094 1094
 	 * @param  string $context View or edit context.
1095 1095
 	 * @return string
1096 1096
 	 */
1097
-	public function get_zip( $context = 'view' ) {
1098
-		return $this->get_prop( 'zip', $context );
1097
+	public function get_zip($context = 'view') {
1098
+		return $this->get_prop('zip', $context);
1099 1099
     }
1100 1100
 
1101 1101
     /**
@@ -1105,8 +1105,8 @@  discard block
 block discarded – undo
1105 1105
 	 * @param  string $context View or edit context.
1106 1106
 	 * @return string
1107 1107
 	 */
1108
-	public function get_user_zip( $context = 'view' ) {
1109
-		return $this->get_zip( $context );
1108
+	public function get_user_zip($context = 'view') {
1109
+		return $this->get_zip($context);
1110 1110
     }
1111 1111
 
1112 1112
     /**
@@ -1116,8 +1116,8 @@  discard block
 block discarded – undo
1116 1116
 	 * @param  string $context View or edit context.
1117 1117
 	 * @return string
1118 1118
 	 */
1119
-	public function get_customer_zip( $context = 'view' ) {
1120
-		return $this->get_zip( $context );
1119
+	public function get_customer_zip($context = 'view') {
1120
+		return $this->get_zip($context);
1121 1121
     }
1122 1122
 
1123 1123
     /**
@@ -1127,8 +1127,8 @@  discard block
 block discarded – undo
1127 1127
 	 * @param  string $context View or edit context.
1128 1128
 	 * @return string
1129 1129
 	 */
1130
-	public function get_company( $context = 'view' ) {
1131
-		return $this->get_prop( 'company', $context );
1130
+	public function get_company($context = 'view') {
1131
+		return $this->get_prop('company', $context);
1132 1132
     }
1133 1133
 
1134 1134
     /**
@@ -1138,8 +1138,8 @@  discard block
 block discarded – undo
1138 1138
 	 * @param  string $context View or edit context.
1139 1139
 	 * @return string
1140 1140
 	 */
1141
-	public function get_user_company( $context = 'view' ) {
1142
-		return $this->get_company( $context );
1141
+	public function get_user_company($context = 'view') {
1142
+		return $this->get_company($context);
1143 1143
     }
1144 1144
 
1145 1145
     /**
@@ -1149,8 +1149,8 @@  discard block
 block discarded – undo
1149 1149
 	 * @param  string $context View or edit context.
1150 1150
 	 * @return string
1151 1151
 	 */
1152
-	public function get_customer_company( $context = 'view' ) {
1153
-		return $this->get_company( $context );
1152
+	public function get_customer_company($context = 'view') {
1153
+		return $this->get_company($context);
1154 1154
     }
1155 1155
 
1156 1156
     /**
@@ -1160,8 +1160,8 @@  discard block
 block discarded – undo
1160 1160
 	 * @param  string $context View or edit context.
1161 1161
 	 * @return string
1162 1162
 	 */
1163
-	public function get_vat_number( $context = 'view' ) {
1164
-		return $this->get_prop( 'vat_number', $context );
1163
+	public function get_vat_number($context = 'view') {
1164
+		return $this->get_prop('vat_number', $context);
1165 1165
     }
1166 1166
 
1167 1167
     /**
@@ -1171,8 +1171,8 @@  discard block
 block discarded – undo
1171 1171
 	 * @param  string $context View or edit context.
1172 1172
 	 * @return string
1173 1173
 	 */
1174
-	public function get_user_vat_number( $context = 'view' ) {
1175
-		return $this->get_vat_number( $context );
1174
+	public function get_user_vat_number($context = 'view') {
1175
+		return $this->get_vat_number($context);
1176 1176
     }
1177 1177
 
1178 1178
     /**
@@ -1182,8 +1182,8 @@  discard block
 block discarded – undo
1182 1182
 	 * @param  string $context View or edit context.
1183 1183
 	 * @return string
1184 1184
 	 */
1185
-	public function get_customer_vat_number( $context = 'view' ) {
1186
-		return $this->get_vat_number( $context );
1185
+	public function get_customer_vat_number($context = 'view') {
1186
+		return $this->get_vat_number($context);
1187 1187
     }
1188 1188
 
1189 1189
     /**
@@ -1193,8 +1193,8 @@  discard block
 block discarded – undo
1193 1193
 	 * @param  string $context View or edit context.
1194 1194
 	 * @return string
1195 1195
 	 */
1196
-	public function get_vat_rate( $context = 'view' ) {
1197
-		return $this->get_prop( 'vat_rate', $context );
1196
+	public function get_vat_rate($context = 'view') {
1197
+		return $this->get_prop('vat_rate', $context);
1198 1198
     }
1199 1199
 
1200 1200
     /**
@@ -1204,8 +1204,8 @@  discard block
 block discarded – undo
1204 1204
 	 * @param  string $context View or edit context.
1205 1205
 	 * @return string
1206 1206
 	 */
1207
-	public function get_user_vat_rate( $context = 'view' ) {
1208
-		return $this->get_vat_rate( $context );
1207
+	public function get_user_vat_rate($context = 'view') {
1208
+		return $this->get_vat_rate($context);
1209 1209
     }
1210 1210
 
1211 1211
     /**
@@ -1215,8 +1215,8 @@  discard block
 block discarded – undo
1215 1215
 	 * @param  string $context View or edit context.
1216 1216
 	 * @return string
1217 1217
 	 */
1218
-	public function get_customer_vat_rate( $context = 'view' ) {
1219
-		return $this->get_vat_rate( $context );
1218
+	public function get_customer_vat_rate($context = 'view') {
1219
+		return $this->get_vat_rate($context);
1220 1220
     }
1221 1221
 
1222 1222
     /**
@@ -1226,8 +1226,8 @@  discard block
 block discarded – undo
1226 1226
 	 * @param  string $context View or edit context.
1227 1227
 	 * @return string
1228 1228
 	 */
1229
-	public function get_address( $context = 'view' ) {
1230
-		return $this->get_prop( 'address', $context );
1229
+	public function get_address($context = 'view') {
1230
+		return $this->get_prop('address', $context);
1231 1231
     }
1232 1232
 
1233 1233
     /**
@@ -1237,8 +1237,8 @@  discard block
 block discarded – undo
1237 1237
 	 * @param  string $context View or edit context.
1238 1238
 	 * @return string
1239 1239
 	 */
1240
-	public function get_user_address( $context = 'view' ) {
1241
-		return $this->get_address( $context );
1240
+	public function get_user_address($context = 'view') {
1241
+		return $this->get_address($context);
1242 1242
     }
1243 1243
 
1244 1244
     /**
@@ -1248,8 +1248,8 @@  discard block
 block discarded – undo
1248 1248
 	 * @param  string $context View or edit context.
1249 1249
 	 * @return string
1250 1250
 	 */
1251
-	public function get_customer_address( $context = 'view' ) {
1252
-		return $this->get_address( $context );
1251
+	public function get_customer_address($context = 'view') {
1252
+		return $this->get_address($context);
1253 1253
     }
1254 1254
 
1255 1255
     /**
@@ -1259,8 +1259,8 @@  discard block
 block discarded – undo
1259 1259
 	 * @param  string $context View or edit context.
1260 1260
 	 * @return bool
1261 1261
 	 */
1262
-	public function get_is_viewed( $context = 'view' ) {
1263
-		return (bool) $this->get_prop( 'is_viewed', $context );
1262
+	public function get_is_viewed($context = 'view') {
1263
+		return (bool) $this->get_prop('is_viewed', $context);
1264 1264
 	}
1265 1265
 
1266 1266
 	/**
@@ -1270,8 +1270,8 @@  discard block
 block discarded – undo
1270 1270
 	 * @param  string $context View or edit context.
1271 1271
 	 * @return bool
1272 1272
 	 */
1273
-	public function get_email_cc( $context = 'view' ) {
1274
-		return $this->get_prop( 'email_cc', $context );
1273
+	public function get_email_cc($context = 'view') {
1274
+		return $this->get_prop('email_cc', $context);
1275 1275
 	}
1276 1276
 
1277 1277
 	/**
@@ -1281,8 +1281,8 @@  discard block
 block discarded – undo
1281 1281
 	 * @param  string $context View or edit context.
1282 1282
 	 * @return bool
1283 1283
 	 */
1284
-	public function get_template( $context = 'view' ) {
1285
-		return $this->get_prop( 'template', $context );
1284
+	public function get_template($context = 'view') {
1285
+		return $this->get_prop('template', $context);
1286 1286
 	}
1287 1287
 
1288 1288
 	/**
@@ -1292,8 +1292,8 @@  discard block
 block discarded – undo
1292 1292
 	 * @param  string $context View or edit context.
1293 1293
 	 * @return bool
1294 1294
 	 */
1295
-	public function get_address_confirmed( $context = 'view' ) {
1296
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1295
+	public function get_address_confirmed($context = 'view') {
1296
+		return (bool) $this->get_prop('address_confirmed', $context);
1297 1297
     }
1298 1298
 
1299 1299
     /**
@@ -1303,8 +1303,8 @@  discard block
 block discarded – undo
1303 1303
 	 * @param  string $context View or edit context.
1304 1304
 	 * @return bool
1305 1305
 	 */
1306
-	public function get_user_address_confirmed( $context = 'view' ) {
1307
-		return $this->get_address_confirmed( $context );
1306
+	public function get_user_address_confirmed($context = 'view') {
1307
+		return $this->get_address_confirmed($context);
1308 1308
     }
1309 1309
 
1310 1310
     /**
@@ -1314,8 +1314,8 @@  discard block
 block discarded – undo
1314 1314
 	 * @param  string $context View or edit context.
1315 1315
 	 * @return bool
1316 1316
 	 */
1317
-	public function get_customer_address_confirmed( $context = 'view' ) {
1318
-		return $this->get_address_confirmed( $context );
1317
+	public function get_customer_address_confirmed($context = 'view') {
1318
+		return $this->get_address_confirmed($context);
1319 1319
     }
1320 1320
 
1321 1321
     /**
@@ -1325,12 +1325,12 @@  discard block
 block discarded – undo
1325 1325
 	 * @param  string $context View or edit context.
1326 1326
 	 * @return float
1327 1327
 	 */
1328
-	public function get_subtotal( $context = 'view' ) {
1329
-        $subtotal = (float) $this->get_prop( 'subtotal', $context );
1328
+	public function get_subtotal($context = 'view') {
1329
+        $subtotal = (float) $this->get_prop('subtotal', $context);
1330 1330
 
1331 1331
         // Backwards compatibility.
1332
-        if ( is_bool( $context ) && $context ) {
1333
-            return wpinv_price( wpinv_format_amount( $subtotal ), $this->get_currency() );
1332
+        if (is_bool($context) && $context) {
1333
+            return wpinv_price(wpinv_format_amount($subtotal), $this->get_currency());
1334 1334
         }
1335 1335
 
1336 1336
         return $subtotal;
@@ -1343,8 +1343,8 @@  discard block
 block discarded – undo
1343 1343
 	 * @param  string $context View or edit context.
1344 1344
 	 * @return float
1345 1345
 	 */
1346
-	public function get_total_discount( $context = 'view' ) {
1347
-		return (float) $this->get_prop( 'total_discount', $context );
1346
+	public function get_total_discount($context = 'view') {
1347
+		return (float) $this->get_prop('total_discount', $context);
1348 1348
     }
1349 1349
 
1350 1350
     /**
@@ -1354,18 +1354,18 @@  discard block
 block discarded – undo
1354 1354
 	 * @param  string $context View or edit context.
1355 1355
 	 * @return float
1356 1356
 	 */
1357
-	public function get_total_tax( $context = 'view' ) {
1358
-		return (float) $this->get_prop( 'total_tax', $context );
1357
+	public function get_total_tax($context = 'view') {
1358
+		return (float) $this->get_prop('total_tax', $context);
1359 1359
 	}
1360 1360
 
1361 1361
 	/**
1362 1362
 	 * @deprecated
1363 1363
 	 */
1364
-	public function get_final_tax( $currency = false ) {
1364
+	public function get_final_tax($currency = false) {
1365 1365
 		$tax = $this->get_total_tax();
1366 1366
 
1367
-        if ( $currency ) {
1368
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1367
+        if ($currency) {
1368
+			return wpinv_price(wpinv_format_amount($tax, NULL, false), $this->get_currency());
1369 1369
         }
1370 1370
 
1371 1371
         return $tax;
@@ -1378,8 +1378,8 @@  discard block
 block discarded – undo
1378 1378
 	 * @param  string $context View or edit context.
1379 1379
 	 * @return float
1380 1380
 	 */
1381
-	public function get_total_fees( $context = 'view' ) {
1382
-		return (float) $this->get_prop( 'total_fees', $context );
1381
+	public function get_total_fees($context = 'view') {
1382
+		return (float) $this->get_prop('total_fees', $context);
1383 1383
     }
1384 1384
 
1385 1385
     /**
@@ -1389,8 +1389,8 @@  discard block
 block discarded – undo
1389 1389
 	 * @param  string $context View or edit context.
1390 1390
 	 * @return float
1391 1391
 	 */
1392
-	public function get_fees_total( $context = 'view' ) {
1393
-		return $this->get_total_fees( $context );
1392
+	public function get_fees_total($context = 'view') {
1393
+		return $this->get_total_fees($context);
1394 1394
     }
1395 1395
 
1396 1396
     /**
@@ -1401,7 +1401,7 @@  discard block
 block discarded – undo
1401 1401
 	 */
1402 1402
 	public function get_total() {
1403 1403
 		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1404
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1404
+		return apply_filters('getpaid_get_invoice_total_amount', $total, $this);
1405 1405
 	}
1406 1406
 	
1407 1407
 	/**
@@ -1423,7 +1423,7 @@  discard block
 block discarded – undo
1423 1423
 	 */
1424 1424
     public function get_initial_total() {
1425 1425
 
1426
-		if ( empty( $this->totals ) ) {
1426
+		if (empty($this->totals)) {
1427 1427
 			$this->recalculate_total();
1428 1428
 		}
1429 1429
 
@@ -1433,11 +1433,11 @@  discard block
 block discarded – undo
1433 1433
 		$subtotal = $this->totals['subtotal']['initial'];
1434 1434
 		$total    = $tax + $fee - $discount + $subtotal;
1435 1435
 
1436
-		if ( 0 > $total ) {
1436
+		if (0 > $total) {
1437 1437
 			$total = 0;
1438 1438
 		}
1439 1439
 
1440
-        return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1440
+        return apply_filters('wpinv_get_initial_invoice_total', $total, $this);
1441 1441
 	}
1442 1442
 
1443 1443
 	/**
@@ -1449,7 +1449,7 @@  discard block
 block discarded – undo
1449 1449
 	 */
1450 1450
     public function get_recurring_total() {
1451 1451
 
1452
-		if ( empty( $this->totals ) ) {
1452
+		if (empty($this->totals)) {
1453 1453
 			$this->recalculate_total();
1454 1454
 		}
1455 1455
 
@@ -1459,11 +1459,11 @@  discard block
 block discarded – undo
1459 1459
 		$subtotal = $this->totals['subtotal']['recurring'];
1460 1460
 		$total    = $tax + $fee - $discount + $subtotal;
1461 1461
 
1462
-		if ( 0 > $total ) {
1462
+		if (0 > $total) {
1463 1463
 			$total = 0;
1464 1464
 		}
1465 1465
 
1466
-        return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1466
+        return apply_filters('wpinv_get_recurring_invoice_total', $total, $this);
1467 1467
 	}
1468 1468
 
1469 1469
 	/**
@@ -1474,10 +1474,10 @@  discard block
 block discarded – undo
1474 1474
 	 * @param string $currency Whether to include the currency.
1475 1475
      * @return float
1476 1476
 	 */
1477
-    public function get_recurring_details( $field = '', $currency = false ) {
1477
+    public function get_recurring_details($field = '', $currency = false) {
1478 1478
 
1479 1479
 		// Maybe recalculate totals.
1480
-		if ( empty( $this->totals ) ) {
1480
+		if (empty($this->totals)) {
1481 1481
 			$this->recalculate_total();
1482 1482
 		}
1483 1483
 
@@ -1497,8 +1497,8 @@  discard block
 block discarded – undo
1497 1497
 			$currency
1498 1498
 		);
1499 1499
 
1500
-        if ( isset( $data[$field] ) ) {
1501
-            return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
1500
+        if (isset($data[$field])) {
1501
+            return ($currency ? wpinv_price($data[$field], $this->get_currency()) : $data[$field]);
1502 1502
         }
1503 1503
 
1504 1504
         return $data;
@@ -1511,8 +1511,8 @@  discard block
 block discarded – undo
1511 1511
 	 * @param  string $context View or edit context.
1512 1512
 	 * @return array
1513 1513
 	 */
1514
-	public function get_fees( $context = 'view' ) {
1515
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1514
+	public function get_fees($context = 'view') {
1515
+		return wpinv_parse_list($this->get_prop('fees', $context));
1516 1516
     }
1517 1517
 
1518 1518
     /**
@@ -1522,8 +1522,8 @@  discard block
 block discarded – undo
1522 1522
 	 * @param  string $context View or edit context.
1523 1523
 	 * @return array
1524 1524
 	 */
1525
-	public function get_discounts( $context = 'view' ) {
1526
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1525
+	public function get_discounts($context = 'view') {
1526
+		return wpinv_parse_list($this->get_prop('discounts', $context));
1527 1527
     }
1528 1528
 
1529 1529
     /**
@@ -1533,8 +1533,8 @@  discard block
 block discarded – undo
1533 1533
 	 * @param  string $context View or edit context.
1534 1534
 	 * @return array
1535 1535
 	 */
1536
-	public function get_taxes( $context = 'view' ) {
1537
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1536
+	public function get_taxes($context = 'view') {
1537
+		return wpinv_parse_list($this->get_prop('taxes', $context));
1538 1538
     }
1539 1539
 
1540 1540
     /**
@@ -1544,8 +1544,8 @@  discard block
 block discarded – undo
1544 1544
 	 * @param  string $context View or edit context.
1545 1545
 	 * @return GetPaid_Form_Item[]
1546 1546
 	 */
1547
-	public function get_items( $context = 'view' ) {
1548
-        return $this->get_prop( 'items', $context );
1547
+	public function get_items($context = 'view') {
1548
+        return $this->get_prop('items', $context);
1549 1549
     }
1550 1550
 
1551 1551
     /**
@@ -1555,8 +1555,8 @@  discard block
 block discarded – undo
1555 1555
 	 * @param  string $context View or edit context.
1556 1556
 	 * @return int
1557 1557
 	 */
1558
-	public function get_payment_form( $context = 'view' ) {
1559
-		return intval( $this->get_prop( 'payment_form', $context ) );
1558
+	public function get_payment_form($context = 'view') {
1559
+		return intval($this->get_prop('payment_form', $context));
1560 1560
     }
1561 1561
 
1562 1562
     /**
@@ -1566,8 +1566,8 @@  discard block
 block discarded – undo
1566 1566
 	 * @param  string $context View or edit context.
1567 1567
 	 * @return string
1568 1568
 	 */
1569
-	public function get_submission_id( $context = 'view' ) {
1570
-		return $this->get_prop( 'submission_id', $context );
1569
+	public function get_submission_id($context = 'view') {
1570
+		return $this->get_prop('submission_id', $context);
1571 1571
     }
1572 1572
 
1573 1573
     /**
@@ -1577,8 +1577,8 @@  discard block
 block discarded – undo
1577 1577
 	 * @param  string $context View or edit context.
1578 1578
 	 * @return string
1579 1579
 	 */
1580
-	public function get_discount_code( $context = 'view' ) {
1581
-		return $this->get_prop( 'discount_code', $context );
1580
+	public function get_discount_code($context = 'view') {
1581
+		return $this->get_prop('discount_code', $context);
1582 1582
     }
1583 1583
 
1584 1584
     /**
@@ -1588,8 +1588,8 @@  discard block
 block discarded – undo
1588 1588
 	 * @param  string $context View or edit context.
1589 1589
 	 * @return string
1590 1590
 	 */
1591
-	public function get_gateway( $context = 'view' ) {
1592
-		return $this->get_prop( 'gateway', $context );
1591
+	public function get_gateway($context = 'view') {
1592
+		return $this->get_prop('gateway', $context);
1593 1593
     }
1594 1594
 
1595 1595
     /**
@@ -1599,8 +1599,8 @@  discard block
 block discarded – undo
1599 1599
 	 * @return string
1600 1600
 	 */
1601 1601
     public function get_gateway_title() {
1602
-        $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1603
-        return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1602
+        $title = wpinv_get_gateway_checkout_label($this->get_gateway());
1603
+        return apply_filters('wpinv_gateway_title', $title, $this->get_id(), $this);
1604 1604
     }
1605 1605
 
1606 1606
     /**
@@ -1610,8 +1610,8 @@  discard block
 block discarded – undo
1610 1610
 	 * @param  string $context View or edit context.
1611 1611
 	 * @return string
1612 1612
 	 */
1613
-	public function get_transaction_id( $context = 'view' ) {
1614
-		return $this->get_prop( 'transaction_id', $context );
1613
+	public function get_transaction_id($context = 'view') {
1614
+		return $this->get_prop('transaction_id', $context);
1615 1615
     }
1616 1616
 
1617 1617
     /**
@@ -1621,9 +1621,9 @@  discard block
 block discarded – undo
1621 1621
 	 * @param  string $context View or edit context.
1622 1622
 	 * @return string
1623 1623
 	 */
1624
-	public function get_currency( $context = 'view' ) {
1625
-        $currency = $this->get_prop( 'currency', $context );
1626
-        return empty( $currency ) ? wpinv_get_currency() : $currency;
1624
+	public function get_currency($context = 'view') {
1625
+        $currency = $this->get_prop('currency', $context);
1626
+        return empty($currency) ? wpinv_get_currency() : $currency;
1627 1627
     }
1628 1628
 
1629 1629
     /**
@@ -1633,8 +1633,8 @@  discard block
 block discarded – undo
1633 1633
 	 * @param  string $context View or edit context.
1634 1634
 	 * @return bool
1635 1635
 	 */
1636
-	public function get_disable_taxes( $context = 'view' ) {
1637
-        return (bool) $this->get_prop( 'disable_taxes', $context );
1636
+	public function get_disable_taxes($context = 'view') {
1637
+        return (bool) $this->get_prop('disable_taxes', $context);
1638 1638
     }
1639 1639
 
1640 1640
     /**
@@ -1644,8 +1644,8 @@  discard block
 block discarded – undo
1644 1644
 	 * @param  string $context View or edit context.
1645 1645
 	 * @return int
1646 1646
 	 */
1647
-    public function get_subscription_id( $context = 'view' ) {
1648
-		return $this->is_renewal() ? $this->get_parent()->get_subscription_id( $context ) : $this->get_prop( 'subscription_id', $context );
1647
+    public function get_subscription_id($context = 'view') {
1648
+		return $this->is_renewal() ? $this->get_parent()->get_subscription_id($context) : $this->get_prop('subscription_id', $context);
1649 1649
 	}
1650 1650
 
1651 1651
 	/**
@@ -1655,12 +1655,12 @@  discard block
 block discarded – undo
1655 1655
 	 * @param  string $context View or edit context.
1656 1656
 	 * @return int
1657 1657
 	 */
1658
-    public function get_remote_subscription_id( $context = 'view' ) {
1659
-        $subscription_id = $this->get_prop( 'remote_subscription_id', $context );
1658
+    public function get_remote_subscription_id($context = 'view') {
1659
+        $subscription_id = $this->get_prop('remote_subscription_id', $context);
1660 1660
 
1661
-        if ( empty( $subscription_id ) && $this->is_renewal() ) {
1661
+        if (empty($subscription_id) && $this->is_renewal()) {
1662 1662
             $parent = $this->get_parent();
1663
-            return $parent->get_subscription_id( $context );
1663
+            return $parent->get_subscription_id($context);
1664 1664
         }
1665 1665
 
1666 1666
         return $subscription_id;
@@ -1673,20 +1673,20 @@  discard block
 block discarded – undo
1673 1673
 	 * @param  string $context View or edit context.
1674 1674
 	 * @return array
1675 1675
 	 */
1676
-    public function get_payment_meta( $context = 'view' ) {
1676
+    public function get_payment_meta($context = 'view') {
1677 1677
 
1678 1678
         return array(
1679
-            'price'        => $this->get_total( $context ),
1680
-            'date'         => $this->get_date_created( $context ),
1681
-            'user_email'   => $this->get_email( $context ),
1682
-            'invoice_key'  => $this->get_key( $context ),
1683
-            'currency'     => $this->get_currency( $context ),
1684
-            'items'        => $this->get_items( $context ),
1685
-            'user_info'    => $this->get_user_info( $context ),
1679
+            'price'        => $this->get_total($context),
1680
+            'date'         => $this->get_date_created($context),
1681
+            'user_email'   => $this->get_email($context),
1682
+            'invoice_key'  => $this->get_key($context),
1683
+            'currency'     => $this->get_currency($context),
1684
+            'items'        => $this->get_items($context),
1685
+            'user_info'    => $this->get_user_info($context),
1686 1686
             'cart_details' => $this->get_cart_details(),
1687
-            'status'       => $this->get_status( $context ),
1688
-            'fees'         => $this->get_fees( $context ),
1689
-            'taxes'        => $this->get_taxes( $context ),
1687
+            'status'       => $this->get_status($context),
1688
+            'fees'         => $this->get_fees($context),
1689
+            'taxes'        => $this->get_taxes($context),
1690 1690
         );
1691 1691
 
1692 1692
     }
@@ -1701,9 +1701,9 @@  discard block
 block discarded – undo
1701 1701
         $items        = $this->get_items();
1702 1702
         $cart_details = array();
1703 1703
 
1704
-        foreach ( $items as $item_id => $item ) {
1704
+        foreach ($items as $item_id => $item) {
1705 1705
 			$item->invoice_id = $this->get_id();
1706
-            $cart_details[]   = $item->prepare_data_for_saving();
1706
+            $cart_details[] = $item->prepare_data_for_saving();
1707 1707
         }
1708 1708
 
1709 1709
         return $cart_details;
@@ -1714,11 +1714,11 @@  discard block
 block discarded – undo
1714 1714
 	 *
1715 1715
 	 * @return null|GetPaid_Form_Item|int
1716 1716
 	 */
1717
-	public function get_recurring( $object = false ) {
1717
+	public function get_recurring($object = false) {
1718 1718
 
1719 1719
 		// Are we returning an object?
1720
-        if ( $object ) {
1721
-            return $this->get_item( $this->recurring_item );
1720
+        if ($object) {
1721
+            return $this->get_item($this->recurring_item);
1722 1722
         }
1723 1723
 
1724 1724
         return $this->recurring_item;
@@ -1733,15 +1733,15 @@  discard block
 block discarded – undo
1733 1733
 	public function get_subscription_name() {
1734 1734
 
1735 1735
 		// Retrieve the recurring name
1736
-        $item = $this->get_recurring( true );
1736
+        $item = $this->get_recurring(true);
1737 1737
 
1738 1738
 		// Abort if it does not exist.
1739
-        if ( empty( $item ) ) {
1739
+        if (empty($item)) {
1740 1740
             return '';
1741 1741
         }
1742 1742
 
1743 1743
 		// Return the item name.
1744
-        return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1744
+        return apply_filters('wpinv_invoice_get_subscription_name', $item->get_name(), $this);
1745 1745
 	}
1746 1746
 
1747 1747
 	/**
@@ -1751,9 +1751,9 @@  discard block
 block discarded – undo
1751 1751
 	 * @return string
1752 1752
 	 */
1753 1753
 	public function get_view_url() {
1754
-        $invoice_url = get_permalink( $this->get_id() );
1755
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1756
-        return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1754
+        $invoice_url = get_permalink($this->get_id());
1755
+		$invoice_url = add_query_arg('invoice_key', $this->get_key(), $invoice_url);
1756
+        return apply_filters('wpinv_get_view_url', $invoice_url, $this);
1757 1757
 	}
1758 1758
 
1759 1759
 	/**
@@ -1762,25 +1762,25 @@  discard block
 block discarded – undo
1762 1762
 	 * @since 1.0.19
1763 1763
 	 * @return string
1764 1764
 	 */
1765
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1765
+	public function get_checkout_payment_url($deprecated = false, $secret = false) {
1766 1766
 
1767 1767
 		// Retrieve the checkout url.
1768 1768
         $pay_url = wpinv_get_checkout_uri();
1769 1769
 
1770 1770
 		// Maybe force ssl.
1771
-        if ( is_ssl() ) {
1772
-            $pay_url = str_replace( 'http:', 'https:', $pay_url );
1771
+        if (is_ssl()) {
1772
+            $pay_url = str_replace('http:', 'https:', $pay_url);
1773 1773
         }
1774 1774
 
1775 1775
 		// Add the invoice key.
1776
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1776
+		$pay_url = add_query_arg('invoice_key', $this->get_key(), $pay_url);
1777 1777
 
1778 1778
 		// (Maybe?) add a secret
1779
-        if ( $secret ) {
1780
-            $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1779
+        if ($secret) {
1780
+            $pay_url = add_query_arg(array('_wpipay' => md5($this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key())), $pay_url);
1781 1781
         }
1782 1782
 
1783
-        return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1783
+        return apply_filters('wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret);
1784 1784
 	}
1785 1785
 	
1786 1786
 	/**
@@ -1795,14 +1795,14 @@  discard block
 block discarded – undo
1795 1795
         $receipt_url = wpinv_get_success_page_uri();
1796 1796
 
1797 1797
 		// Maybe force ssl.
1798
-        if ( is_ssl() ) {
1799
-            $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1798
+        if (is_ssl()) {
1799
+            $receipt_url = str_replace('http:', 'https:', $receipt_url);
1800 1800
         }
1801 1801
 
1802 1802
 		// Add the invoice key.
1803
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1803
+		$receipt_url = add_query_arg('invoice_key', $this->get_key(), $receipt_url);
1804 1804
 
1805
-        return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1805
+        return apply_filters('getpaid_get_invoice_receipt_url', $receipt_url, $this);
1806 1806
     }
1807 1807
 
1808 1808
     /**
@@ -1815,8 +1815,8 @@  discard block
 block discarded – undo
1815 1815
 	 * @param  string $context View or edit context.
1816 1816
 	 * @return mixed Value of the given invoice property (if set).
1817 1817
 	 */
1818
-	public function get( $key, $context = 'view' ) {
1819
-        return $this->get_prop( $key, $context );
1818
+	public function get($key, $context = 'view') {
1819
+        return $this->get_prop($key, $context);
1820 1820
 	}
1821 1821
 
1822 1822
     /*
@@ -1839,11 +1839,11 @@  discard block
 block discarded – undo
1839 1839
 	 * @param  mixed $value new value.
1840 1840
 	 * @return mixed Value of the given invoice property (if set).
1841 1841
 	 */
1842
-	public function set( $key, $value ) {
1842
+	public function set($key, $value) {
1843 1843
 
1844 1844
         $setter = "set_$key";
1845
-        if ( is_callable( array( $this, $setter ) ) ) {
1846
-            $this->{$setter}( $value );
1845
+        if (is_callable(array($this, $setter))) {
1846
+            $this->{$setter}($value);
1847 1847
         }
1848 1848
 
1849 1849
 	}
@@ -1857,47 +1857,47 @@  discard block
 block discarded – undo
1857 1857
 	 * @param bool   $manual_update Is this a manual status change?.
1858 1858
 	 * @return array details of change.
1859 1859
 	 */
1860
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1860
+	public function set_status($new_status, $note = '', $manual_update = false) {
1861 1861
 		$old_status = $this->get_status();
1862 1862
 
1863 1863
 		$statuses = $this->get_all_statuses();
1864 1864
 
1865
-		if ( isset( $statuses[ 'draft' ] ) ) {
1866
-			unset( $statuses[ 'draft' ] );
1865
+		if (isset($statuses['draft'])) {
1866
+			unset($statuses['draft']);
1867 1867
 		}
1868 1868
 
1869
-		$this->set_prop( 'status', $new_status );
1869
+		$this->set_prop('status', $new_status);
1870 1870
 
1871 1871
 		// If setting the status, ensure it's set to a valid status.
1872
-		if ( true === $this->object_read ) {
1872
+		if (true === $this->object_read) {
1873 1873
 
1874 1874
 			// Only allow valid new status.
1875
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1875
+			if (!array_key_exists($new_status, $statuses)) {
1876 1876
 				$new_status = 'wpi-pending';
1877 1877
 			}
1878 1878
 
1879 1879
 			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1880
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1880
+			if ($old_status && !array_key_exists($new_status, $statuses)) {
1881 1881
 				$old_status = 'wpi-pending';
1882 1882
 			}
1883 1883
 
1884 1884
 			// Paid - Renewal (i.e when duplicating a parent invoice )
1885
-			if ( $new_status == 'wpi-pending' && $old_status == 'publish' && ! $this->get_id() ) {
1885
+			if ($new_status == 'wpi-pending' && $old_status == 'publish' && !$this->get_id()) {
1886 1886
 				$old_status = 'wpi-pending';
1887 1887
 			}
1888 1888
 
1889 1889
 		}
1890 1890
 
1891
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1891
+		if (true === $this->object_read && $old_status !== $new_status) {
1892 1892
 			$this->status_transition = array(
1893
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1893
+				'from'   => !empty($this->status_transition['from']) ? $this->status_transition['from'] : $old_status,
1894 1894
 				'to'     => $new_status,
1895 1895
 				'note'   => $note,
1896 1896
 				'manual' => (bool) $manual_update,
1897 1897
 			);
1898 1898
 
1899
-			if ( $manual_update ) {
1900
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1899
+			if ($manual_update) {
1900
+				do_action('getpaid_' . $this->object_type . '_edit_status', $this->get_id(), $new_status);
1901 1901
 			}
1902 1902
 
1903 1903
 			$this->maybe_set_date_paid();
@@ -1920,8 +1920,8 @@  discard block
 block discarded – undo
1920 1920
 	 */
1921 1921
 	public function maybe_set_date_paid() {
1922 1922
 
1923
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1924
-			$this->set_date_completed( current_time( 'mysql' ) );
1923
+		if (!$this->get_date_completed('edit') && $this->is_paid()) {
1924
+			$this->set_date_completed(current_time('mysql'));
1925 1925
 		}
1926 1926
 	}
1927 1927
 
@@ -1930,11 +1930,11 @@  discard block
 block discarded – undo
1930 1930
 	 *
1931 1931
 	 * @since 1.0.19
1932 1932
 	 */
1933
-	public function set_parent_id( $value ) {
1934
-		if ( $value && ( $value === $this->get_id() ) ) {
1933
+	public function set_parent_id($value) {
1934
+		if ($value && ($value === $this->get_id())) {
1935 1935
 			return;
1936 1936
 		}
1937
-		$this->set_prop( 'parent_id', absint( $value ) );
1937
+		$this->set_prop('parent_id', absint($value));
1938 1938
     }
1939 1939
 
1940 1940
     /**
@@ -1942,8 +1942,8 @@  discard block
 block discarded – undo
1942 1942
 	 *
1943 1943
 	 * @since 1.0.19
1944 1944
 	 */
1945
-	public function set_version( $value ) {
1946
-		$this->set_prop( 'version', $value );
1945
+	public function set_version($value) {
1946
+		$this->set_prop('version', $value);
1947 1947
     }
1948 1948
 
1949 1949
     /**
@@ -1953,15 +1953,15 @@  discard block
 block discarded – undo
1953 1953
 	 * @param string $value Value to set.
1954 1954
      * @return bool Whether or not the date was set.
1955 1955
 	 */
1956
-	public function set_date_created( $value ) {
1957
-        $date = strtotime( $value );
1956
+	public function set_date_created($value) {
1957
+        $date = strtotime($value);
1958 1958
 
1959
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1960
-            $this->set_prop( 'date_created', date( 'Y-m-d H:i:s', $date ) );
1959
+        if ($date && $value !== '0000-00-00 00:00:00') {
1960
+            $this->set_prop('date_created', date('Y-m-d H:i:s', $date));
1961 1961
             return true;
1962 1962
         }
1963 1963
 
1964
-        return $this->set_prop( 'date_created', '' );
1964
+        return $this->set_prop('date_created', '');
1965 1965
 
1966 1966
     }
1967 1967
 
@@ -1972,15 +1972,15 @@  discard block
 block discarded – undo
1972 1972
 	 * @param string $value Value to set.
1973 1973
      * @return bool Whether or not the date was set.
1974 1974
 	 */
1975
-	public function set_due_date( $value ) {
1976
-        $date = strtotime( $value );
1975
+	public function set_due_date($value) {
1976
+        $date = strtotime($value);
1977 1977
 
1978
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
1979
-            $this->set_prop( 'due_date', date( 'Y-m-d H:i:s', $date ) );
1978
+        if ($date && $value !== '0000-00-00 00:00:00') {
1979
+            $this->set_prop('due_date', date('Y-m-d H:i:s', $date));
1980 1980
             return true;
1981 1981
         }
1982 1982
 
1983
-		$this->set_prop( 'due_date', '' );
1983
+		$this->set_prop('due_date', '');
1984 1984
         return false;
1985 1985
 
1986 1986
     }
@@ -1991,8 +1991,8 @@  discard block
 block discarded – undo
1991 1991
 	 * @since 1.0.19
1992 1992
 	 * @param  string $value New name.
1993 1993
 	 */
1994
-	public function set_date_due( $value ) {
1995
-		$this->set_due_date( $value );
1994
+	public function set_date_due($value) {
1995
+		$this->set_due_date($value);
1996 1996
     }
1997 1997
 
1998 1998
     /**
@@ -2002,15 +2002,15 @@  discard block
 block discarded – undo
2002 2002
 	 * @param string $value Value to set.
2003 2003
      * @return bool Whether or not the date was set.
2004 2004
 	 */
2005
-	public function set_completed_date( $value ) {
2006
-        $date = strtotime( $value );
2005
+	public function set_completed_date($value) {
2006
+        $date = strtotime($value);
2007 2007
 
2008
-        if ( $date && $value !== '0000-00-00 00:00:00'  ) {
2009
-            $this->set_prop( 'completed_date', date( 'Y-m-d H:i:s', $date ) );
2008
+        if ($date && $value !== '0000-00-00 00:00:00') {
2009
+            $this->set_prop('completed_date', date('Y-m-d H:i:s', $date));
2010 2010
             return true;
2011 2011
         }
2012 2012
 
2013
-		$this->set_prop( 'completed_date', '' );
2013
+		$this->set_prop('completed_date', '');
2014 2014
         return false;
2015 2015
 
2016 2016
     }
@@ -2021,8 +2021,8 @@  discard block
 block discarded – undo
2021 2021
 	 * @since 1.0.19
2022 2022
 	 * @param  string $value New name.
2023 2023
 	 */
2024
-	public function set_date_completed( $value ) {
2025
-		$this->set_completed_date( $value );
2024
+	public function set_date_completed($value) {
2025
+		$this->set_completed_date($value);
2026 2026
     }
2027 2027
 
2028 2028
     /**
@@ -2032,15 +2032,15 @@  discard block
 block discarded – undo
2032 2032
 	 * @param string $value Value to set.
2033 2033
      * @return bool Whether or not the date was set.
2034 2034
 	 */
2035
-	public function set_date_modified( $value ) {
2036
-        $date = strtotime( $value );
2035
+	public function set_date_modified($value) {
2036
+        $date = strtotime($value);
2037 2037
 
2038
-        if ( $date && $value !== '0000-00-00 00:00:00' ) {
2039
-            $this->set_prop( 'date_modified', date( 'Y-m-d H:i:s', $date ) );
2038
+        if ($date && $value !== '0000-00-00 00:00:00') {
2039
+            $this->set_prop('date_modified', date('Y-m-d H:i:s', $date));
2040 2040
             return true;
2041 2041
         }
2042 2042
 
2043
-		$this->set_prop( 'date_modified', '' );
2043
+		$this->set_prop('date_modified', '');
2044 2044
         return false;
2045 2045
 
2046 2046
     }
@@ -2051,9 +2051,9 @@  discard block
 block discarded – undo
2051 2051
 	 * @since 1.0.19
2052 2052
 	 * @param  string $value New number.
2053 2053
 	 */
2054
-	public function set_number( $value ) {
2055
-        $number = sanitize_text_field( $value );
2056
-		$this->set_prop( 'number', $number );
2054
+	public function set_number($value) {
2055
+        $number = sanitize_text_field($value);
2056
+		$this->set_prop('number', $number);
2057 2057
     }
2058 2058
 
2059 2059
     /**
@@ -2062,9 +2062,9 @@  discard block
 block discarded – undo
2062 2062
 	 * @since 1.0.19
2063 2063
 	 * @param  string $value Type.
2064 2064
 	 */
2065
-	public function set_type( $value ) {
2066
-        $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2067
-		$this->set_prop( 'type', $type );
2065
+	public function set_type($value) {
2066
+        $type = sanitize_text_field(str_replace('wpi_', '', $value));
2067
+		$this->set_prop('type', $type);
2068 2068
 	}
2069 2069
 
2070 2070
     /**
@@ -2073,10 +2073,10 @@  discard block
 block discarded – undo
2073 2073
 	 * @since 1.0.19
2074 2074
 	 * @param  string $value Post type.
2075 2075
 	 */
2076
-	public function set_post_type( $value ) {
2077
-        if ( getpaid_is_invoice_post_type( $value ) ) {
2078
-			$this->set_type( $value );
2079
-            $this->set_prop( 'post_type', $value );
2076
+	public function set_post_type($value) {
2077
+        if (getpaid_is_invoice_post_type($value)) {
2078
+			$this->set_type($value);
2079
+            $this->set_prop('post_type', $value);
2080 2080
         }
2081 2081
     }
2082 2082
 
@@ -2086,9 +2086,9 @@  discard block
 block discarded – undo
2086 2086
 	 * @since 1.0.19
2087 2087
 	 * @param  string $value New key.
2088 2088
 	 */
2089
-	public function set_key( $value ) {
2090
-        $key = sanitize_text_field( $value );
2091
-		$this->set_prop( 'key', $key );
2089
+	public function set_key($value) {
2090
+        $key = sanitize_text_field($value);
2091
+		$this->set_prop('key', $key);
2092 2092
     }
2093 2093
 
2094 2094
     /**
@@ -2097,9 +2097,9 @@  discard block
 block discarded – undo
2097 2097
 	 * @since 1.0.19
2098 2098
 	 * @param  string $value mode.
2099 2099
 	 */
2100
-	public function set_mode( $value ) {
2101
-        if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2102
-            $this->set_prop( 'value', $value );
2100
+	public function set_mode($value) {
2101
+        if (!in_array($value, array('live', 'test'))) {
2102
+            $this->set_prop('value', $value);
2103 2103
         }
2104 2104
     }
2105 2105
 
@@ -2109,8 +2109,8 @@  discard block
 block discarded – undo
2109 2109
 	 * @since 1.0.19
2110 2110
 	 * @param  string $value path.
2111 2111
 	 */
2112
-	public function set_path( $value ) {
2113
-        $this->set_prop( 'path', $value );
2112
+	public function set_path($value) {
2113
+        $this->set_prop('path', $value);
2114 2114
     }
2115 2115
 
2116 2116
     /**
@@ -2119,9 +2119,9 @@  discard block
 block discarded – undo
2119 2119
 	 * @since 1.0.19
2120 2120
 	 * @param  string $value New name.
2121 2121
 	 */
2122
-	public function set_name( $value ) {
2123
-        $name = sanitize_text_field( $value );
2124
-		$this->set_prop( 'name', $name );
2122
+	public function set_name($value) {
2123
+        $name = sanitize_text_field($value);
2124
+		$this->set_prop('name', $name);
2125 2125
     }
2126 2126
 
2127 2127
     /**
@@ -2130,8 +2130,8 @@  discard block
 block discarded – undo
2130 2130
 	 * @since 1.0.19
2131 2131
 	 * @param  string $value New name.
2132 2132
 	 */
2133
-	public function set_title( $value ) {
2134
-		$this->set_name( $value );
2133
+	public function set_title($value) {
2134
+		$this->set_name($value);
2135 2135
     }
2136 2136
 
2137 2137
     /**
@@ -2140,9 +2140,9 @@  discard block
 block discarded – undo
2140 2140
 	 * @since 1.0.19
2141 2141
 	 * @param  string $value New description.
2142 2142
 	 */
2143
-	public function set_description( $value ) {
2144
-        $description = wp_kses_post( $value );
2145
-		return $this->set_prop( 'description', $description );
2143
+	public function set_description($value) {
2144
+        $description = wp_kses_post($value);
2145
+		return $this->set_prop('description', $description);
2146 2146
     }
2147 2147
 
2148 2148
     /**
@@ -2151,8 +2151,8 @@  discard block
 block discarded – undo
2151 2151
 	 * @since 1.0.19
2152 2152
 	 * @param  string $value New description.
2153 2153
 	 */
2154
-	public function set_excerpt( $value ) {
2155
-		$this->set_description( $value );
2154
+	public function set_excerpt($value) {
2155
+		$this->set_description($value);
2156 2156
     }
2157 2157
 
2158 2158
     /**
@@ -2161,8 +2161,8 @@  discard block
 block discarded – undo
2161 2161
 	 * @since 1.0.19
2162 2162
 	 * @param  string $value New description.
2163 2163
 	 */
2164
-	public function set_summary( $value ) {
2165
-		$this->set_description( $value );
2164
+	public function set_summary($value) {
2165
+		$this->set_description($value);
2166 2166
     }
2167 2167
 
2168 2168
     /**
@@ -2171,12 +2171,12 @@  discard block
 block discarded – undo
2171 2171
 	 * @since 1.0.19
2172 2172
 	 * @param  int $value New author.
2173 2173
 	 */
2174
-	public function set_author( $value ) {
2175
-		$user = get_user_by( 'id', (int) $value );
2174
+	public function set_author($value) {
2175
+		$user = get_user_by('id', (int) $value);
2176 2176
 
2177
-		if ( $user && $user->ID ) {
2178
-			$this->set_prop( 'author', $user->ID );
2179
-			$this->set_prop( 'email', $user->user_email );
2177
+		if ($user && $user->ID) {
2178
+			$this->set_prop('author', $user->ID);
2179
+			$this->set_prop('email', $user->user_email);
2180 2180
 		}
2181 2181
 		
2182 2182
     }
@@ -2187,8 +2187,8 @@  discard block
 block discarded – undo
2187 2187
 	 * @since 1.0.19
2188 2188
 	 * @param  int $value New user id.
2189 2189
 	 */
2190
-	public function set_user_id( $value ) {
2191
-		$this->set_author( $value );
2190
+	public function set_user_id($value) {
2191
+		$this->set_author($value);
2192 2192
     }
2193 2193
 
2194 2194
     /**
@@ -2197,8 +2197,8 @@  discard block
 block discarded – undo
2197 2197
 	 * @since 1.0.19
2198 2198
 	 * @param  int $value New user id.
2199 2199
 	 */
2200
-	public function set_customer_id( $value ) {
2201
-		$this->set_author( $value );
2200
+	public function set_customer_id($value) {
2201
+		$this->set_author($value);
2202 2202
     }
2203 2203
 
2204 2204
     /**
@@ -2207,8 +2207,8 @@  discard block
 block discarded – undo
2207 2207
 	 * @since 1.0.19
2208 2208
 	 * @param  string $value ip address.
2209 2209
 	 */
2210
-	public function set_ip( $value ) {
2211
-		$this->set_prop( 'ip', $value );
2210
+	public function set_ip($value) {
2211
+		$this->set_prop('ip', $value);
2212 2212
     }
2213 2213
 
2214 2214
     /**
@@ -2217,8 +2217,8 @@  discard block
 block discarded – undo
2217 2217
 	 * @since 1.0.19
2218 2218
 	 * @param  string $value ip address.
2219 2219
 	 */
2220
-	public function set_user_ip( $value ) {
2221
-		$this->set_ip( $value );
2220
+	public function set_user_ip($value) {
2221
+		$this->set_ip($value);
2222 2222
     }
2223 2223
 
2224 2224
     /**
@@ -2227,8 +2227,8 @@  discard block
 block discarded – undo
2227 2227
 	 * @since 1.0.19
2228 2228
 	 * @param  string $value first name.
2229 2229
 	 */
2230
-	public function set_first_name( $value ) {
2231
-		$this->set_prop( 'first_name', $value );
2230
+	public function set_first_name($value) {
2231
+		$this->set_prop('first_name', $value);
2232 2232
     }
2233 2233
 
2234 2234
     /**
@@ -2237,8 +2237,8 @@  discard block
 block discarded – undo
2237 2237
 	 * @since 1.0.19
2238 2238
 	 * @param  string $value first name.
2239 2239
 	 */
2240
-	public function set_user_first_name( $value ) {
2241
-		$this->set_first_name( $value );
2240
+	public function set_user_first_name($value) {
2241
+		$this->set_first_name($value);
2242 2242
     }
2243 2243
 
2244 2244
     /**
@@ -2247,8 +2247,8 @@  discard block
 block discarded – undo
2247 2247
 	 * @since 1.0.19
2248 2248
 	 * @param  string $value first name.
2249 2249
 	 */
2250
-	public function set_customer_first_name( $value ) {
2251
-		$this->set_first_name( $value );
2250
+	public function set_customer_first_name($value) {
2251
+		$this->set_first_name($value);
2252 2252
     }
2253 2253
 
2254 2254
     /**
@@ -2257,8 +2257,8 @@  discard block
 block discarded – undo
2257 2257
 	 * @since 1.0.19
2258 2258
 	 * @param  string $value last name.
2259 2259
 	 */
2260
-	public function set_last_name( $value ) {
2261
-		$this->set_prop( 'last_name', $value );
2260
+	public function set_last_name($value) {
2261
+		$this->set_prop('last_name', $value);
2262 2262
     }
2263 2263
 
2264 2264
     /**
@@ -2267,8 +2267,8 @@  discard block
 block discarded – undo
2267 2267
 	 * @since 1.0.19
2268 2268
 	 * @param  string $value last name.
2269 2269
 	 */
2270
-	public function set_user_last_name( $value ) {
2271
-		$this->set_last_name( $value );
2270
+	public function set_user_last_name($value) {
2271
+		$this->set_last_name($value);
2272 2272
     }
2273 2273
 
2274 2274
     /**
@@ -2277,8 +2277,8 @@  discard block
 block discarded – undo
2277 2277
 	 * @since 1.0.19
2278 2278
 	 * @param  string $value last name.
2279 2279
 	 */
2280
-	public function set_customer_last_name( $value ) {
2281
-		$this->set_last_name( $value );
2280
+	public function set_customer_last_name($value) {
2281
+		$this->set_last_name($value);
2282 2282
     }
2283 2283
 
2284 2284
     /**
@@ -2287,8 +2287,8 @@  discard block
 block discarded – undo
2287 2287
 	 * @since 1.0.19
2288 2288
 	 * @param  string $value phone.
2289 2289
 	 */
2290
-	public function set_phone( $value ) {
2291
-		$this->set_prop( 'phone', $value );
2290
+	public function set_phone($value) {
2291
+		$this->set_prop('phone', $value);
2292 2292
     }
2293 2293
 
2294 2294
     /**
@@ -2297,8 +2297,8 @@  discard block
 block discarded – undo
2297 2297
 	 * @since 1.0.19
2298 2298
 	 * @param  string $value phone.
2299 2299
 	 */
2300
-	public function set_user_phone( $value ) {
2301
-		$this->set_phone( $value );
2300
+	public function set_user_phone($value) {
2301
+		$this->set_phone($value);
2302 2302
     }
2303 2303
 
2304 2304
     /**
@@ -2307,8 +2307,8 @@  discard block
 block discarded – undo
2307 2307
 	 * @since 1.0.19
2308 2308
 	 * @param  string $value phone.
2309 2309
 	 */
2310
-	public function set_customer_phone( $value ) {
2311
-		$this->set_phone( $value );
2310
+	public function set_customer_phone($value) {
2311
+		$this->set_phone($value);
2312 2312
     }
2313 2313
 
2314 2314
     /**
@@ -2317,8 +2317,8 @@  discard block
 block discarded – undo
2317 2317
 	 * @since 1.0.19
2318 2318
 	 * @param  string $value phone.
2319 2319
 	 */
2320
-	public function set_phone_number( $value ) {
2321
-		$this->set_phone( $value );
2320
+	public function set_phone_number($value) {
2321
+		$this->set_phone($value);
2322 2322
     }
2323 2323
 
2324 2324
     /**
@@ -2327,8 +2327,8 @@  discard block
 block discarded – undo
2327 2327
 	 * @since 1.0.19
2328 2328
 	 * @param  string $value email address.
2329 2329
 	 */
2330
-	public function set_email( $value ) {
2331
-		$this->set_prop( 'email', $value );
2330
+	public function set_email($value) {
2331
+		$this->set_prop('email', $value);
2332 2332
     }
2333 2333
 
2334 2334
     /**
@@ -2337,8 +2337,8 @@  discard block
 block discarded – undo
2337 2337
 	 * @since 1.0.19
2338 2338
 	 * @param  string $value email address.
2339 2339
 	 */
2340
-	public function set_user_email( $value ) {
2341
-		$this->set_email( $value );
2340
+	public function set_user_email($value) {
2341
+		$this->set_email($value);
2342 2342
     }
2343 2343
 
2344 2344
     /**
@@ -2347,8 +2347,8 @@  discard block
 block discarded – undo
2347 2347
 	 * @since 1.0.19
2348 2348
 	 * @param  string $value email address.
2349 2349
 	 */
2350
-	public function set_email_address( $value ) {
2351
-		$this->set_email( $value );
2350
+	public function set_email_address($value) {
2351
+		$this->set_email($value);
2352 2352
     }
2353 2353
 
2354 2354
     /**
@@ -2357,8 +2357,8 @@  discard block
 block discarded – undo
2357 2357
 	 * @since 1.0.19
2358 2358
 	 * @param  string $value email address.
2359 2359
 	 */
2360
-	public function set_customer_email( $value ) {
2361
-		$this->set_email( $value );
2360
+	public function set_customer_email($value) {
2361
+		$this->set_email($value);
2362 2362
     }
2363 2363
 
2364 2364
     /**
@@ -2367,8 +2367,8 @@  discard block
 block discarded – undo
2367 2367
 	 * @since 1.0.19
2368 2368
 	 * @param  string $value country.
2369 2369
 	 */
2370
-	public function set_country( $value ) {
2371
-		$this->set_prop( 'country', $value );
2370
+	public function set_country($value) {
2371
+		$this->set_prop('country', $value);
2372 2372
     }
2373 2373
 
2374 2374
     /**
@@ -2377,8 +2377,8 @@  discard block
 block discarded – undo
2377 2377
 	 * @since 1.0.19
2378 2378
 	 * @param  string $value country.
2379 2379
 	 */
2380
-	public function set_user_country( $value ) {
2381
-		$this->set_country( $value );
2380
+	public function set_user_country($value) {
2381
+		$this->set_country($value);
2382 2382
     }
2383 2383
 
2384 2384
     /**
@@ -2387,8 +2387,8 @@  discard block
 block discarded – undo
2387 2387
 	 * @since 1.0.19
2388 2388
 	 * @param  string $value country.
2389 2389
 	 */
2390
-	public function set_customer_country( $value ) {
2391
-		$this->set_country( $value );
2390
+	public function set_customer_country($value) {
2391
+		$this->set_country($value);
2392 2392
     }
2393 2393
 
2394 2394
     /**
@@ -2397,8 +2397,8 @@  discard block
 block discarded – undo
2397 2397
 	 * @since 1.0.19
2398 2398
 	 * @param  string $value state.
2399 2399
 	 */
2400
-	public function set_state( $value ) {
2401
-		$this->set_prop( 'state', $value );
2400
+	public function set_state($value) {
2401
+		$this->set_prop('state', $value);
2402 2402
     }
2403 2403
 
2404 2404
     /**
@@ -2407,8 +2407,8 @@  discard block
 block discarded – undo
2407 2407
 	 * @since 1.0.19
2408 2408
 	 * @param  string $value state.
2409 2409
 	 */
2410
-	public function set_user_state( $value ) {
2411
-		$this->set_state( $value );
2410
+	public function set_user_state($value) {
2411
+		$this->set_state($value);
2412 2412
     }
2413 2413
 
2414 2414
     /**
@@ -2417,8 +2417,8 @@  discard block
 block discarded – undo
2417 2417
 	 * @since 1.0.19
2418 2418
 	 * @param  string $value state.
2419 2419
 	 */
2420
-	public function set_customer_state( $value ) {
2421
-		$this->set_state( $value );
2420
+	public function set_customer_state($value) {
2421
+		$this->set_state($value);
2422 2422
     }
2423 2423
 
2424 2424
     /**
@@ -2427,8 +2427,8 @@  discard block
 block discarded – undo
2427 2427
 	 * @since 1.0.19
2428 2428
 	 * @param  string $value city.
2429 2429
 	 */
2430
-	public function set_city( $value ) {
2431
-		$this->set_prop( 'city', $value );
2430
+	public function set_city($value) {
2431
+		$this->set_prop('city', $value);
2432 2432
     }
2433 2433
 
2434 2434
     /**
@@ -2437,8 +2437,8 @@  discard block
 block discarded – undo
2437 2437
 	 * @since 1.0.19
2438 2438
 	 * @param  string $value city.
2439 2439
 	 */
2440
-	public function set_user_city( $value ) {
2441
-		$this->set_city( $value );
2440
+	public function set_user_city($value) {
2441
+		$this->set_city($value);
2442 2442
     }
2443 2443
 
2444 2444
     /**
@@ -2447,8 +2447,8 @@  discard block
 block discarded – undo
2447 2447
 	 * @since 1.0.19
2448 2448
 	 * @param  string $value city.
2449 2449
 	 */
2450
-	public function set_customer_city( $value ) {
2451
-		$this->set_city( $value );
2450
+	public function set_customer_city($value) {
2451
+		$this->set_city($value);
2452 2452
     }
2453 2453
 
2454 2454
     /**
@@ -2457,8 +2457,8 @@  discard block
 block discarded – undo
2457 2457
 	 * @since 1.0.19
2458 2458
 	 * @param  string $value zip.
2459 2459
 	 */
2460
-	public function set_zip( $value ) {
2461
-		$this->set_prop( 'zip', $value );
2460
+	public function set_zip($value) {
2461
+		$this->set_prop('zip', $value);
2462 2462
     }
2463 2463
 
2464 2464
     /**
@@ -2467,8 +2467,8 @@  discard block
 block discarded – undo
2467 2467
 	 * @since 1.0.19
2468 2468
 	 * @param  string $value zip.
2469 2469
 	 */
2470
-	public function set_user_zip( $value ) {
2471
-		$this->set_zip( $value );
2470
+	public function set_user_zip($value) {
2471
+		$this->set_zip($value);
2472 2472
     }
2473 2473
 
2474 2474
     /**
@@ -2477,8 +2477,8 @@  discard block
 block discarded – undo
2477 2477
 	 * @since 1.0.19
2478 2478
 	 * @param  string $value zip.
2479 2479
 	 */
2480
-	public function set_customer_zip( $value ) {
2481
-		$this->set_zip( $value );
2480
+	public function set_customer_zip($value) {
2481
+		$this->set_zip($value);
2482 2482
     }
2483 2483
 
2484 2484
     /**
@@ -2487,8 +2487,8 @@  discard block
 block discarded – undo
2487 2487
 	 * @since 1.0.19
2488 2488
 	 * @param  string $value company.
2489 2489
 	 */
2490
-	public function set_company( $value ) {
2491
-		$this->set_prop( 'company', $value );
2490
+	public function set_company($value) {
2491
+		$this->set_prop('company', $value);
2492 2492
     }
2493 2493
 
2494 2494
     /**
@@ -2497,8 +2497,8 @@  discard block
 block discarded – undo
2497 2497
 	 * @since 1.0.19
2498 2498
 	 * @param  string $value company.
2499 2499
 	 */
2500
-	public function set_user_company( $value ) {
2501
-		$this->set_company( $value );
2500
+	public function set_user_company($value) {
2501
+		$this->set_company($value);
2502 2502
     }
2503 2503
 
2504 2504
     /**
@@ -2507,8 +2507,8 @@  discard block
 block discarded – undo
2507 2507
 	 * @since 1.0.19
2508 2508
 	 * @param  string $value company.
2509 2509
 	 */
2510
-	public function set_customer_company( $value ) {
2511
-		$this->set_company( $value );
2510
+	public function set_customer_company($value) {
2511
+		$this->set_company($value);
2512 2512
     }
2513 2513
 
2514 2514
     /**
@@ -2517,8 +2517,8 @@  discard block
 block discarded – undo
2517 2517
 	 * @since 1.0.19
2518 2518
 	 * @param  string $value var number.
2519 2519
 	 */
2520
-	public function set_vat_number( $value ) {
2521
-		$this->set_prop( 'vat_number', $value );
2520
+	public function set_vat_number($value) {
2521
+		$this->set_prop('vat_number', $value);
2522 2522
     }
2523 2523
 
2524 2524
     /**
@@ -2527,8 +2527,8 @@  discard block
 block discarded – undo
2527 2527
 	 * @since 1.0.19
2528 2528
 	 * @param  string $value var number.
2529 2529
 	 */
2530
-	public function set_user_vat_number( $value ) {
2531
-		$this->set_vat_number( $value );
2530
+	public function set_user_vat_number($value) {
2531
+		$this->set_vat_number($value);
2532 2532
     }
2533 2533
 
2534 2534
     /**
@@ -2537,8 +2537,8 @@  discard block
 block discarded – undo
2537 2537
 	 * @since 1.0.19
2538 2538
 	 * @param  string $value var number.
2539 2539
 	 */
2540
-	public function set_customer_vat_number( $value ) {
2541
-		$this->set_vat_number( $value );
2540
+	public function set_customer_vat_number($value) {
2541
+		$this->set_vat_number($value);
2542 2542
     }
2543 2543
 
2544 2544
     /**
@@ -2547,8 +2547,8 @@  discard block
 block discarded – undo
2547 2547
 	 * @since 1.0.19
2548 2548
 	 * @param  string $value var rate.
2549 2549
 	 */
2550
-	public function set_vat_rate( $value ) {
2551
-		$this->set_prop( 'vat_rate', $value );
2550
+	public function set_vat_rate($value) {
2551
+		$this->set_prop('vat_rate', $value);
2552 2552
     }
2553 2553
 
2554 2554
     /**
@@ -2557,8 +2557,8 @@  discard block
 block discarded – undo
2557 2557
 	 * @since 1.0.19
2558 2558
 	 * @param  string $value var number.
2559 2559
 	 */
2560
-	public function set_user_vat_rate( $value ) {
2561
-		$this->set_vat_rate( $value );
2560
+	public function set_user_vat_rate($value) {
2561
+		$this->set_vat_rate($value);
2562 2562
     }
2563 2563
 
2564 2564
     /**
@@ -2567,8 +2567,8 @@  discard block
 block discarded – undo
2567 2567
 	 * @since 1.0.19
2568 2568
 	 * @param  string $value var number.
2569 2569
 	 */
2570
-	public function set_customer_vat_rate( $value ) {
2571
-		$this->set_vat_rate( $value );
2570
+	public function set_customer_vat_rate($value) {
2571
+		$this->set_vat_rate($value);
2572 2572
     }
2573 2573
 
2574 2574
     /**
@@ -2577,8 +2577,8 @@  discard block
 block discarded – undo
2577 2577
 	 * @since 1.0.19
2578 2578
 	 * @param  string $value address.
2579 2579
 	 */
2580
-	public function set_address( $value ) {
2581
-		$this->set_prop( 'address', $value );
2580
+	public function set_address($value) {
2581
+		$this->set_prop('address', $value);
2582 2582
     }
2583 2583
 
2584 2584
     /**
@@ -2587,8 +2587,8 @@  discard block
 block discarded – undo
2587 2587
 	 * @since 1.0.19
2588 2588
 	 * @param  string $value address.
2589 2589
 	 */
2590
-	public function set_user_address( $value ) {
2591
-		$this->set_address( $value );
2590
+	public function set_user_address($value) {
2591
+		$this->set_address($value);
2592 2592
     }
2593 2593
 
2594 2594
     /**
@@ -2597,8 +2597,8 @@  discard block
 block discarded – undo
2597 2597
 	 * @since 1.0.19
2598 2598
 	 * @param  string $value address.
2599 2599
 	 */
2600
-	public function set_customer_address( $value ) {
2601
-		$this->set_address( $value );
2600
+	public function set_customer_address($value) {
2601
+		$this->set_address($value);
2602 2602
     }
2603 2603
 
2604 2604
     /**
@@ -2607,8 +2607,8 @@  discard block
 block discarded – undo
2607 2607
 	 * @since 1.0.19
2608 2608
 	 * @param  int|bool $value confirmed.
2609 2609
 	 */
2610
-	public function set_is_viewed( $value ) {
2611
-		$this->set_prop( 'is_viewed', $value );
2610
+	public function set_is_viewed($value) {
2611
+		$this->set_prop('is_viewed', $value);
2612 2612
 	}
2613 2613
 
2614 2614
 	/**
@@ -2617,8 +2617,8 @@  discard block
 block discarded – undo
2617 2617
 	 * @since 1.0.19
2618 2618
 	 * @param  string $value email recipients.
2619 2619
 	 */
2620
-	public function set_email_cc( $value ) {
2621
-		$this->set_prop( 'email_cc', $value );
2620
+	public function set_email_cc($value) {
2621
+		$this->set_prop('email_cc', $value);
2622 2622
 	}
2623 2623
 
2624 2624
 	/**
@@ -2627,9 +2627,9 @@  discard block
 block discarded – undo
2627 2627
 	 * @since 1.0.19
2628 2628
 	 * @param  string $value email recipients.
2629 2629
 	 */
2630
-	public function set_template( $value ) {
2631
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2632
-			$this->set_prop( 'template', $value );
2630
+	public function set_template($value) {
2631
+		if (in_array($value, array('quantity', 'hours', 'amount'))) {
2632
+			$this->set_prop('template', $value);
2633 2633
 		}
2634 2634
 	}
2635 2635
 
@@ -2639,8 +2639,8 @@  discard block
 block discarded – undo
2639 2639
 	 * @since 1.0.19
2640 2640
 	 * @param  int|bool $value confirmed.
2641 2641
 	 */
2642
-	public function set_address_confirmed( $value ) {
2643
-		$this->set_prop( 'address_confirmed', $value );
2642
+	public function set_address_confirmed($value) {
2643
+		$this->set_prop('address_confirmed', $value);
2644 2644
     }
2645 2645
 
2646 2646
     /**
@@ -2649,8 +2649,8 @@  discard block
 block discarded – undo
2649 2649
 	 * @since 1.0.19
2650 2650
 	 * @param  int|bool $value confirmed.
2651 2651
 	 */
2652
-	public function set_user_address_confirmed( $value ) {
2653
-		$this->set_address_confirmed( $value );
2652
+	public function set_user_address_confirmed($value) {
2653
+		$this->set_address_confirmed($value);
2654 2654
     }
2655 2655
 
2656 2656
     /**
@@ -2659,8 +2659,8 @@  discard block
 block discarded – undo
2659 2659
 	 * @since 1.0.19
2660 2660
 	 * @param  int|bool $value confirmed.
2661 2661
 	 */
2662
-	public function set_customer_address_confirmed( $value ) {
2663
-		$this->set_address_confirmed( $value );
2662
+	public function set_customer_address_confirmed($value) {
2663
+		$this->set_address_confirmed($value);
2664 2664
     }
2665 2665
 
2666 2666
     /**
@@ -2669,8 +2669,8 @@  discard block
 block discarded – undo
2669 2669
 	 * @since 1.0.19
2670 2670
 	 * @param  float $value sub total.
2671 2671
 	 */
2672
-	public function set_subtotal( $value ) {
2673
-		$this->set_prop( 'subtotal', $value );
2672
+	public function set_subtotal($value) {
2673
+		$this->set_prop('subtotal', $value);
2674 2674
     }
2675 2675
 
2676 2676
     /**
@@ -2679,8 +2679,8 @@  discard block
 block discarded – undo
2679 2679
 	 * @since 1.0.19
2680 2680
 	 * @param  float $value discount total.
2681 2681
 	 */
2682
-	public function set_total_discount( $value ) {
2683
-		$this->set_prop( 'total_discount', $value );
2682
+	public function set_total_discount($value) {
2683
+		$this->set_prop('total_discount', $value);
2684 2684
     }
2685 2685
 
2686 2686
     /**
@@ -2689,8 +2689,8 @@  discard block
 block discarded – undo
2689 2689
 	 * @since 1.0.19
2690 2690
 	 * @param  float $value discount total.
2691 2691
 	 */
2692
-	public function set_discount( $value ) {
2693
-		$this->set_total_discount( $value );
2692
+	public function set_discount($value) {
2693
+		$this->set_total_discount($value);
2694 2694
     }
2695 2695
 
2696 2696
     /**
@@ -2699,8 +2699,8 @@  discard block
 block discarded – undo
2699 2699
 	 * @since 1.0.19
2700 2700
 	 * @param  float $value tax total.
2701 2701
 	 */
2702
-	public function set_total_tax( $value ) {
2703
-		$this->set_prop( 'total_tax', $value );
2702
+	public function set_total_tax($value) {
2703
+		$this->set_prop('total_tax', $value);
2704 2704
     }
2705 2705
 
2706 2706
     /**
@@ -2709,8 +2709,8 @@  discard block
 block discarded – undo
2709 2709
 	 * @since 1.0.19
2710 2710
 	 * @param  float $value tax total.
2711 2711
 	 */
2712
-	public function set_tax_total( $value ) {
2713
-		$this->set_total_tax( $value );
2712
+	public function set_tax_total($value) {
2713
+		$this->set_total_tax($value);
2714 2714
     }
2715 2715
 
2716 2716
     /**
@@ -2719,8 +2719,8 @@  discard block
 block discarded – undo
2719 2719
 	 * @since 1.0.19
2720 2720
 	 * @param  float $value fees total.
2721 2721
 	 */
2722
-	public function set_total_fees( $value ) {
2723
-		$this->set_prop( 'total_fees', $value );
2722
+	public function set_total_fees($value) {
2723
+		$this->set_prop('total_fees', $value);
2724 2724
     }
2725 2725
 
2726 2726
     /**
@@ -2729,8 +2729,8 @@  discard block
 block discarded – undo
2729 2729
 	 * @since 1.0.19
2730 2730
 	 * @param  float $value fees total.
2731 2731
 	 */
2732
-	public function set_fees_total( $value ) {
2733
-		$this->set_total_fees( $value );
2732
+	public function set_fees_total($value) {
2733
+		$this->set_total_fees($value);
2734 2734
     }
2735 2735
 
2736 2736
     /**
@@ -2739,18 +2739,18 @@  discard block
 block discarded – undo
2739 2739
 	 * @since 1.0.19
2740 2740
 	 * @param  array $value fees.
2741 2741
 	 */
2742
-	public function set_fees( $value ) {
2742
+	public function set_fees($value) {
2743 2743
 
2744
-        $this->set_prop( 'fees', array() );
2744
+        $this->set_prop('fees', array());
2745 2745
 
2746 2746
         // Ensure that we have an array.
2747
-        if ( ! is_array( $value ) ) {
2747
+        if (!is_array($value)) {
2748 2748
             return;
2749 2749
         }
2750 2750
 
2751
-        foreach ( $value as $name => $data ) {
2752
-            if ( isset( $data['amount'] ) ) {
2753
-                $this->add_fee( $name, $data['amount'], $data['recurring'] );
2751
+        foreach ($value as $name => $data) {
2752
+            if (isset($data['amount'])) {
2753
+                $this->add_fee($name, $data['amount'], $data['recurring']);
2754 2754
             }
2755 2755
         }
2756 2756
 
@@ -2762,8 +2762,8 @@  discard block
 block discarded – undo
2762 2762
 	 * @since 1.0.19
2763 2763
 	 * @param  array $value taxes.
2764 2764
 	 */
2765
-	public function set_taxes( $value ) {
2766
-		$this->set_prop( 'taxes', $value );
2765
+	public function set_taxes($value) {
2766
+		$this->set_prop('taxes', $value);
2767 2767
     }
2768 2768
 
2769 2769
     /**
@@ -2772,17 +2772,17 @@  discard block
 block discarded – undo
2772 2772
 	 * @since 1.0.19
2773 2773
 	 * @param  array $value discounts.
2774 2774
 	 */
2775
-	public function set_discounts( $value ) {
2776
-		$this->set_prop( 'discounts', array() );
2775
+	public function set_discounts($value) {
2776
+		$this->set_prop('discounts', array());
2777 2777
 
2778 2778
         // Ensure that we have an array.
2779
-        if ( ! is_array( $value ) ) {
2779
+        if (!is_array($value)) {
2780 2780
             return;
2781 2781
         }
2782 2782
 
2783
-        foreach ( $value as $name => $data ) {
2784
-            if ( isset( $data['amount'] ) ) {
2785
-                $this->add_discount( $name, $data['amount'], $data['recurring'] );
2783
+        foreach ($value as $name => $data) {
2784
+            if (isset($data['amount'])) {
2785
+                $this->add_discount($name, $data['amount'], $data['recurring']);
2786 2786
             }
2787 2787
         }
2788 2788
     }
@@ -2793,18 +2793,18 @@  discard block
 block discarded – undo
2793 2793
 	 * @since 1.0.19
2794 2794
 	 * @param  GetPaid_Form_Item[] $value items.
2795 2795
 	 */
2796
-	public function set_items( $value ) {
2796
+	public function set_items($value) {
2797 2797
 
2798 2798
         // Remove existing items.
2799
-        $this->set_prop( 'items', array() );
2799
+        $this->set_prop('items', array());
2800 2800
 
2801 2801
         // Ensure that we have an array.
2802
-        if ( ! is_array( $value ) ) {
2802
+        if (!is_array($value)) {
2803 2803
             return;
2804 2804
         }
2805 2805
 
2806
-        foreach ( $value as $item ) {
2807
-            $this->add_item( $item );
2806
+        foreach ($value as $item) {
2807
+            $this->add_item($item);
2808 2808
         }
2809 2809
 
2810 2810
     }
@@ -2815,8 +2815,8 @@  discard block
 block discarded – undo
2815 2815
 	 * @since 1.0.19
2816 2816
 	 * @param  int $value payment form.
2817 2817
 	 */
2818
-	public function set_payment_form( $value ) {
2819
-		$this->set_prop( 'payment_form', $value );
2818
+	public function set_payment_form($value) {
2819
+		$this->set_prop('payment_form', $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 submission id.
2827 2827
 	 */
2828
-	public function set_submission_id( $value ) {
2829
-		$this->set_prop( 'submission_id', $value );
2828
+	public function set_submission_id($value) {
2829
+		$this->set_prop('submission_id', $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 discount code.
2837 2837
 	 */
2838
-	public function set_discount_code( $value ) {
2839
-		$this->set_prop( 'discount_code', $value );
2838
+	public function set_discount_code($value) {
2839
+		$this->set_prop('discount_code', $value);
2840 2840
     }
2841 2841
 
2842 2842
     /**
@@ -2845,8 +2845,8 @@  discard block
 block discarded – undo
2845 2845
 	 * @since 1.0.19
2846 2846
 	 * @param  string $value gateway.
2847 2847
 	 */
2848
-	public function set_gateway( $value ) {
2849
-		$this->set_prop( 'gateway', $value );
2848
+	public function set_gateway($value) {
2849
+		$this->set_prop('gateway', $value);
2850 2850
     }
2851 2851
 
2852 2852
     /**
@@ -2855,9 +2855,9 @@  discard block
 block discarded – undo
2855 2855
 	 * @since 1.0.19
2856 2856
 	 * @param  string $value transaction id.
2857 2857
 	 */
2858
-	public function set_transaction_id( $value ) {
2859
-		if ( ! empty( $value ) ) {
2860
-			$this->set_prop( 'transaction_id', $value );
2858
+	public function set_transaction_id($value) {
2859
+		if (!empty($value)) {
2860
+			$this->set_prop('transaction_id', $value);
2861 2861
 		}
2862 2862
     }
2863 2863
 
@@ -2867,8 +2867,8 @@  discard block
 block discarded – undo
2867 2867
 	 * @since 1.0.19
2868 2868
 	 * @param  string $value currency id.
2869 2869
 	 */
2870
-	public function set_currency( $value ) {
2871
-		$this->set_prop( 'currency', $value );
2870
+	public function set_currency($value) {
2871
+		$this->set_prop('currency', $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  bool $value value.
2879 2879
 	 */
2880
-	public function set_disable_taxes( $value ) {
2881
-		$this->set_prop( 'disable_taxes', (bool) $value );
2880
+	public function set_disable_taxes($value) {
2881
+		$this->set_prop('disable_taxes', (bool) $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_subscription_id( $value ) {
2891
-		$this->set_prop( 'subscription_id', $value );
2890
+	public function set_subscription_id($value) {
2891
+		$this->set_prop('subscription_id', $value);
2892 2892
 	}
2893 2893
 	
2894 2894
 	/**
@@ -2897,8 +2897,8 @@  discard block
 block discarded – undo
2897 2897
 	 * @since 1.0.19
2898 2898
 	 * @param  string $value subscription id.
2899 2899
 	 */
2900
-	public function set_remote_subscription_id( $value ) {
2901
-		$this->set_prop( 'remote_subscription_id', $value );
2900
+	public function set_remote_subscription_id($value) {
2901
+		$this->set_prop('remote_subscription_id', $value);
2902 2902
     }
2903 2903
 
2904 2904
     /*
@@ -2915,28 +2915,28 @@  discard block
 block discarded – undo
2915 2915
      */
2916 2916
     public function is_parent() {
2917 2917
         $parent = $this->get_parent_id();
2918
-        return apply_filters( 'wpinv_invoice_is_parent', empty( $parent ), $this );
2918
+        return apply_filters('wpinv_invoice_is_parent', empty($parent), $this);
2919 2919
     }
2920 2920
 
2921 2921
     /**
2922 2922
      * Checks if this is a renewal invoice.
2923 2923
      */
2924 2924
     public function is_renewal() {
2925
-        return ! $this->is_parent();
2925
+        return !$this->is_parent();
2926 2926
     }
2927 2927
 
2928 2928
     /**
2929 2929
      * Checks if this is a recurring invoice.
2930 2930
      */
2931 2931
     public function is_recurring() {
2932
-        return $this->is_renewal() || ! empty( $this->recurring_item );
2932
+        return $this->is_renewal() || !empty($this->recurring_item);
2933 2933
     }
2934 2934
 
2935 2935
     /**
2936 2936
      * Checks if this is a taxable invoice.
2937 2937
      */
2938 2938
     public function is_taxable() {
2939
-        return ! $this->get_disable_taxes();
2939
+        return !$this->get_disable_taxes();
2940 2940
 	}
2941 2941
 
2942 2942
 	/**
@@ -2947,57 +2947,57 @@  discard block
 block discarded – undo
2947 2947
 
2948 2948
         $requires_vat = false;
2949 2949
 
2950
-        if ( $this->country ) {
2950
+        if ($this->country) {
2951 2951
             $wpi_country        = $this->country;
2952
-            $requires_vat       = $wpinv_euvat->requires_vat( $requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule( $this ) );
2952
+            $requires_vat       = $wpinv_euvat->requires_vat($requires_vat, $this->get_user_id(), $wpinv_euvat->invoice_has_digital_rule($this));
2953 2953
         }
2954 2954
 
2955
-        return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2955
+        return apply_filters('wpinv_invoice_has_vat', $requires_vat, $this);
2956 2956
 	}
2957 2957
 
2958 2958
 	/**
2959 2959
 	 * Checks to see if the invoice requires payment.
2960 2960
 	 */
2961 2961
 	public function is_free() {
2962
-        $is_free = ( (float) wpinv_round_amount( $this->get_initial_total() ) == 0 );
2962
+        $is_free = ((float) wpinv_round_amount($this->get_initial_total()) == 0);
2963 2963
 
2964
-		if ( $this->is_recurring() && $this->get_recurring_total() > 0 ) {
2964
+		if ($this->is_recurring() && $this->get_recurring_total() > 0) {
2965 2965
 			$is_free = false;
2966 2966
 		}
2967 2967
 
2968
-        return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2968
+        return apply_filters('wpinv_invoice_is_free', $is_free, $this);
2969 2969
     }
2970 2970
 
2971 2971
     /**
2972 2972
      * Checks if the invoice is paid.
2973 2973
      */
2974 2974
     public function is_paid() {
2975
-        $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2976
-        return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2975
+        $is_paid = $this->has_status(array('publish', 'wpi-processing', 'wpi-renewal'));
2976
+        return apply_filters('wpinv_invoice_is_paid', $is_paid, $this);
2977 2977
 	}
2978 2978
 
2979 2979
 	/**
2980 2980
      * Checks if the invoice needs payment.
2981 2981
      */
2982 2982
 	public function needs_payment() {
2983
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2984
-        return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2983
+		$needs_payment = !$this->is_paid() && !$this->is_refunded() && !$this->is_free();
2984
+        return apply_filters('wpinv_needs_payment', $needs_payment, $this);
2985 2985
     }
2986 2986
 
2987 2987
 	/**
2988 2988
      * Checks if the invoice is refunded.
2989 2989
      */
2990 2990
 	public function is_refunded() {
2991
-        $is_refunded = $this->has_status( 'wpi-refunded' );
2992
-        return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2991
+        $is_refunded = $this->has_status('wpi-refunded');
2992
+        return apply_filters('wpinv_invoice_is_refunded', $is_refunded, $this);
2993 2993
 	}
2994 2994
 
2995 2995
 	/**
2996 2996
      * Checks if the invoice is held.
2997 2997
      */
2998 2998
 	public function is_held() {
2999
-        $is_held = $this->has_status( 'wpi-onhold' );
3000
-        return apply_filters( 'wpinv_invoice_is_held', $is_held, $this );
2999
+        $is_held = $this->has_status('wpi-onhold');
3000
+        return apply_filters('wpinv_invoice_is_held', $is_held, $this);
3001 3001
 	}
3002 3002
 
3003 3003
 	/**
@@ -3005,30 +3005,30 @@  discard block
 block discarded – undo
3005 3005
      */
3006 3006
 	public function is_due() {
3007 3007
 		$due_date = $this->get_due_date();
3008
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
3008
+		return empty($due_date) ? false : current_time('timestamp') > strtotime($due_date);
3009 3009
 	}
3010 3010
 
3011 3011
 	/**
3012 3012
      * Checks if the invoice is draft.
3013 3013
      */
3014 3014
 	public function is_draft() {
3015
-        return $this->has_status( 'draft, auto-draft' );
3015
+        return $this->has_status('draft, auto-draft');
3016 3016
 	}
3017 3017
 
3018 3018
     /**
3019 3019
      * Checks if the invoice has a given status.
3020 3020
      */
3021
-    public function has_status( $status ) {
3022
-        $status = wpinv_parse_list( $status );
3023
-        return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
3021
+    public function has_status($status) {
3022
+        $status = wpinv_parse_list($status);
3023
+        return apply_filters('wpinv_has_status', in_array($this->get_status(), $status), $status);
3024 3024
 	}
3025 3025
 
3026 3026
 	/**
3027 3027
      * Checks if the invoice is of a given type.
3028 3028
      */
3029
-    public function is_type( $type ) {
3030
-        $type = wpinv_parse_list( $type );
3031
-        return in_array( $this->get_type(), $type );
3029
+    public function is_type($type) {
3030
+        $type = wpinv_parse_list($type);
3031
+        return in_array($this->get_type(), $type);
3032 3032
     }
3033 3033
 
3034 3034
     /**
@@ -3060,8 +3060,8 @@  discard block
 block discarded – undo
3060 3060
      *
3061 3061
      */
3062 3062
 	public function is_initial_free() {
3063
-        $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
3064
-        return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
3063
+        $is_initial_free = !((float) wpinv_round_amount($this->get_initial_total()) > 0);
3064
+        return apply_filters('wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this);
3065 3065
     }
3066 3066
 	
3067 3067
 	/**
@@ -3071,11 +3071,11 @@  discard block
 block discarded – undo
3071 3071
     public function item_has_free_trial() {
3072 3072
 
3073 3073
         // Ensure we have a recurring item.
3074
-        if ( ! $this->is_recurring() ) {
3074
+        if (!$this->is_recurring()) {
3075 3075
             return false;
3076 3076
         }
3077 3077
 
3078
-        $item = $this->get_recurring( true );
3078
+        $item = $this->get_recurring(true);
3079 3079
         return $item->has_free_trial();
3080 3080
 	}
3081 3081
 
@@ -3083,7 +3083,7 @@  discard block
 block discarded – undo
3083 3083
      * Check if the free trial is a result of a discount.
3084 3084
      */
3085 3085
     public function is_free_trial_from_discount() {
3086
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3086
+		return $this->has_free_trial() && !$this->item_has_free_trial();
3087 3087
 	}
3088 3088
 	
3089 3089
 	/**
@@ -3092,17 +3092,17 @@  discard block
 block discarded – undo
3092 3092
     public function discount_first_payment_only() {
3093 3093
 
3094 3094
 		$discount_code = $this->get_discount_code();
3095
-        if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3095
+        if (empty($this->discount_code) || !$this->is_recurring()) {
3096 3096
             return true;
3097 3097
         }
3098 3098
 
3099
-        $discount = wpinv_get_discount_obj( $discount_code );
3099
+        $discount = wpinv_get_discount_obj($discount_code);
3100 3100
 
3101
-        if ( ! $discount || ! $discount->exists() ) {
3101
+        if (!$discount || !$discount->exists()) {
3102 3102
             return true;
3103 3103
         }
3104 3104
 
3105
-        return ! $discount->get_is_recurring();
3105
+        return !$discount->get_is_recurring();
3106 3106
     }
3107 3107
 
3108 3108
     /*
@@ -3120,27 +3120,27 @@  discard block
 block discarded – undo
3120 3120
      * @param GetPaid_Form_Item|array $item
3121 3121
      * @return WP_Error|Bool
3122 3122
      */
3123
-    public function add_item( $item ) {
3123
+    public function add_item($item) {
3124 3124
 
3125
-		if ( is_array( $item ) ) {
3126
-			$item = $this->process_array_item( $item );
3125
+		if (is_array($item)) {
3126
+			$item = $this->process_array_item($item);
3127 3127
 		}
3128 3128
 
3129
-		if ( is_numeric( $item ) ) {
3130
-			$item = new GetPaid_Form_Item( $item );
3129
+		if (is_numeric($item)) {
3130
+			$item = new GetPaid_Form_Item($item);
3131 3131
 		}
3132 3132
 
3133 3133
         // Make sure that it is available for purchase.
3134
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3135
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3134
+		if ($item->get_id() > 0 && !$item->can_purchase()) {
3135
+			return new WP_Error('invalid_item', __('This item is not available for purchase', 'invoicing'));
3136 3136
         }
3137 3137
 
3138 3138
         // Do we have a recurring item?
3139
-		if ( $item->is_recurring() ) {
3139
+		if ($item->is_recurring()) {
3140 3140
 
3141 3141
 			// An invoice can only contain one recurring item.
3142
-			if ( ! empty( $this->recurring_item  && $this->recurring_item != (int) $item->get_id() ) ) {
3143
-				return new WP_Error( 'recurring_item', __( 'An invoice can only contain one recurring item', 'invoicing' ) );
3142
+			if (!empty($this->recurring_item && $this->recurring_item != (int) $item->get_id())) {
3143
+				return new WP_Error('recurring_item', __('An invoice can only contain one recurring item', 'invoicing'));
3144 3144
 			}
3145 3145
 
3146 3146
 			$this->recurring_item = $item->get_id();
@@ -3151,9 +3151,9 @@  discard block
 block discarded – undo
3151 3151
 
3152 3152
         // Retrieve all items.
3153 3153
         $items = $this->get_items();
3154
-        $items[ (int) $item->get_id() ] = $item;
3154
+        $items[(int) $item->get_id()] = $item;
3155 3155
 
3156
-        $this->set_prop( 'items', $items );
3156
+        $this->set_prop('items', $items);
3157 3157
 		return true;
3158 3158
 	}
3159 3159
 	
@@ -3163,26 +3163,26 @@  discard block
 block discarded – undo
3163 3163
 	 * @since 1.0.19
3164 3164
 	 * @return GetPaid_Form_Item
3165 3165
 	 */
3166
-	protected function process_array_item( $array ) {
3166
+	protected function process_array_item($array) {
3167 3167
 
3168
-		$item_id = isset( $array['item_id'] ) ? $array['item_id'] : 0;
3169
-		$item    = new GetPaid_Form_Item( $item_id );
3168
+		$item_id = isset($array['item_id']) ? $array['item_id'] : 0;
3169
+		$item    = new GetPaid_Form_Item($item_id);
3170 3170
 
3171 3171
 		// Set item data.
3172
-		foreach( array( 'name', 'price', 'description' ) as $key ) {
3173
-			if ( isset( $array[ "item_$key" ] ) ) {
3172
+		foreach (array('name', 'price', 'description') as $key) {
3173
+			if (isset($array["item_$key"])) {
3174 3174
 				$method = "set_$key";
3175
-				$item->$method( $array[ "item_$key" ] );
3175
+				$item->$method($array["item_$key"]);
3176 3176
 			}
3177 3177
 		}
3178 3178
 
3179
-		if ( isset( $array['quantity'] ) ) {
3180
-			$item->set_quantity( $array['quantity'] );
3179
+		if (isset($array['quantity'])) {
3180
+			$item->set_quantity($array['quantity']);
3181 3181
 		}
3182 3182
 
3183 3183
 		// Set item meta.
3184
-		if ( isset( $array['meta'] ) && is_array( $array['meta'] ) ) {
3185
-			$item->set_item_meta( $array['meta'] );
3184
+		if (isset($array['meta']) && is_array($array['meta'])) {
3185
+			$item->set_item_meta($array['meta']);
3186 3186
 		}
3187 3187
 
3188 3188
 		return $item;
@@ -3194,10 +3194,10 @@  discard block
 block discarded – undo
3194 3194
 	 *
3195 3195
 	 * @since 1.0.19
3196 3196
 	 */
3197
-	public function get_item( $item_id ) {
3197
+	public function get_item($item_id) {
3198 3198
 		$items   = $this->get_items();
3199 3199
 		$item_id = (int) $item_id;
3200
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3200
+		return (!empty($item_id) && isset($items[$item_id])) ? $items[$item_id] : null;
3201 3201
     }
3202 3202
 
3203 3203
     /**
@@ -3205,17 +3205,17 @@  discard block
 block discarded – undo
3205 3205
 	 *
3206 3206
 	 * @since 1.0.19
3207 3207
 	 */
3208
-	public function remove_item( $item_id ) {
3208
+	public function remove_item($item_id) {
3209 3209
 		$items   = $this->get_items();
3210 3210
 		$item_id = (int) $item_id;
3211 3211
 
3212
-        if ( $item_id == $this->recurring_item ) {
3212
+        if ($item_id == $this->recurring_item) {
3213 3213
             $this->recurring_item = null;
3214 3214
         }
3215 3215
 
3216
-        if ( isset( $items[ $item_id ] ) ) {
3217
-            unset( $items[ $item_id ] );
3218
-            $this->set_prop( 'items', $items );
3216
+        if (isset($items[$item_id])) {
3217
+            unset($items[$item_id]);
3218
+            $this->set_prop('items', $items);
3219 3219
         }
3220 3220
     }
3221 3221
 
@@ -3226,27 +3226,27 @@  discard block
 block discarded – undo
3226 3226
      * @param float $value
3227 3227
      * @return WP_Error|Bool
3228 3228
      */
3229
-    public function add_fee( $fee, $value, $recurring = false ) {
3229
+    public function add_fee($fee, $value, $recurring = false) {
3230 3230
 
3231
-        $amount = wpinv_sanitize_amount( $value );
3231
+        $amount = wpinv_sanitize_amount($value);
3232 3232
         $fees   = $this->get_fees();
3233 3233
 
3234
-        if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3234
+        if (isset($fees[$fee]) && isset($fees[$fee]['amount'])) {
3235 3235
 
3236
-            $amount = $fees[ $fee ]['amount'] += $amount;
3237
-			$fees[ $fee ] = array(
3236
+            $amount = $fees[$fee]['amount'] += $amount;
3237
+			$fees[$fee] = array(
3238 3238
 				'amount'    => $amount,
3239 3239
                 'recurring' => (bool) $recurring,
3240 3240
             );
3241 3241
 
3242 3242
 		} else {
3243
-			$fees[ $fee ] = array(
3243
+			$fees[$fee] = array(
3244 3244
                 'amount'    => $amount,
3245 3245
                 'recurring' => (bool) $recurring,
3246 3246
             );
3247 3247
 		}
3248 3248
 
3249
-        $this->set_prop( 'fees', $fee );
3249
+        $this->set_prop('fees', $fee);
3250 3250
 
3251 3251
     }
3252 3252
 
@@ -3255,9 +3255,9 @@  discard block
 block discarded – undo
3255 3255
 	 *
3256 3256
 	 * @since 1.0.19
3257 3257
 	 */
3258
-	public function get_fee( $fee ) {
3258
+	public function get_fee($fee) {
3259 3259
         $fees = $this->get_fees();
3260
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3260
+		return isset($fees[$fee]) ? $fees[$fee] : null;
3261 3261
     }
3262 3262
 
3263 3263
     /**
@@ -3265,11 +3265,11 @@  discard block
 block discarded – undo
3265 3265
 	 *
3266 3266
 	 * @since 1.0.19
3267 3267
 	 */
3268
-	public function remove_fee( $fee ) {
3268
+	public function remove_fee($fee) {
3269 3269
         $fees = $this->get_fees();
3270
-        if ( isset( $fees[ $fee ] ) ) {
3271
-            unset( $fees[ $fee ] );
3272
-            $this->set_prop( 'fees', $fees );
3270
+        if (isset($fees[$fee])) {
3271
+            unset($fees[$fee]);
3272
+            $this->set_prop('fees', $fees);
3273 3273
         }
3274 3274
     }
3275 3275
 
@@ -3280,27 +3280,27 @@  discard block
 block discarded – undo
3280 3280
      * @param float $value
3281 3281
      * @return WP_Error|Bool
3282 3282
      */
3283
-    public function add_discount( $discount, $value, $recurring = false ) {
3283
+    public function add_discount($discount, $value, $recurring = false) {
3284 3284
 
3285
-        $amount    = wpinv_sanitize_amount( $value );
3285
+        $amount    = wpinv_sanitize_amount($value);
3286 3286
         $discounts = $this->get_discounts();
3287 3287
 
3288
-        if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3288
+        if (isset($discounts[$discount]) && isset($discounts[$discount]['amount'])) {
3289 3289
 
3290
-            $amount = $discounts[ $discount ]['amount'] += $amount;
3291
-			$discounts[ $discount ] = array(
3290
+            $amount = $discounts[$discount]['amount'] += $amount;
3291
+			$discounts[$discount] = array(
3292 3292
                 'amount'    => $amount,
3293 3293
                 'recurring' => (bool) $recurring,
3294 3294
             );
3295 3295
 
3296 3296
 		} else {
3297
-			$discounts[ $discount ] = array(
3297
+			$discounts[$discount] = array(
3298 3298
                 'amount'    => $amount,
3299 3299
                 'recurring' => (bool) $recurring,
3300 3300
             );
3301 3301
 		}
3302 3302
 
3303
-        $this->set_prop( 'discounts', $discount );
3303
+        $this->set_prop('discounts', $discount);
3304 3304
 
3305 3305
     }
3306 3306
 
@@ -3309,15 +3309,15 @@  discard block
 block discarded – undo
3309 3309
 	 *
3310 3310
 	 * @since 1.0.19
3311 3311
 	 */
3312
-	public function get_discount( $discount = false ) {
3312
+	public function get_discount($discount = false) {
3313 3313
 
3314 3314
 		// Backwards compatibilty.
3315
-		if ( empty( $discount ) ) {
3315
+		if (empty($discount)) {
3316 3316
 			return $this->get_total_discount();
3317 3317
 		}
3318 3318
 
3319 3319
         $discounts = $this->get_discounts();
3320
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3320
+		return isset($discounts[$discount]) ? $discounts[$discount] : null;
3321 3321
     }
3322 3322
 
3323 3323
     /**
@@ -3325,11 +3325,11 @@  discard block
 block discarded – undo
3325 3325
 	 *
3326 3326
 	 * @since 1.0.19
3327 3327
 	 */
3328
-	public function remove_discount( $discount ) {
3328
+	public function remove_discount($discount) {
3329 3329
         $discounts = $this->get_discounts();
3330
-        if ( isset( $discounts[ $discount ] ) ) {
3331
-            unset( $discounts[ $discount ] );
3332
-            $this->set_prop( 'discounts', $discounts );
3330
+        if (isset($discounts[$discount])) {
3331
+            unset($discounts[$discount]);
3332
+            $this->set_prop('discounts', $discounts);
3333 3333
         }
3334 3334
     }
3335 3335
 
@@ -3339,31 +3339,31 @@  discard block
 block discarded – undo
3339 3339
      * @param string $tax
3340 3340
      * @param float $value
3341 3341
      */
3342
-    public function add_tax( $tax, $value, $recurring = true ) {
3342
+    public function add_tax($tax, $value, $recurring = true) {
3343 3343
 
3344
-        if ( ! $this->is_taxable() ) {
3344
+        if (!$this->is_taxable()) {
3345 3345
             return;
3346 3346
         }
3347 3347
 
3348
-        $amount    = wpinv_sanitize_amount( $value );
3348
+        $amount    = wpinv_sanitize_amount($value);
3349 3349
         $taxes     = $this->get_taxes();
3350 3350
 
3351
-        if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3351
+        if (isset($taxes[$tax]) && isset($taxes[$tax]['amount'])) {
3352 3352
 
3353
-            $amount = $taxes[ $tax ]['amount'] += $amount;
3354
-			$taxes[ $tax ] = array(
3353
+            $amount = $taxes[$tax]['amount'] += $amount;
3354
+			$taxes[$tax] = array(
3355 3355
                 'amount'    => $amount,
3356 3356
                 'recurring' => (bool) $recurring,
3357 3357
             );
3358 3358
 
3359 3359
 		} else {
3360
-			$taxes[ $tax ] = array(
3360
+			$taxes[$tax] = array(
3361 3361
                 'amount'    => $amount,
3362 3362
                 'recurring' => (bool) $recurring,
3363 3363
             );
3364 3364
 		}
3365 3365
 
3366
-        $this->set_prop( 'taxes', $tax );
3366
+        $this->set_prop('taxes', $tax);
3367 3367
 
3368 3368
     }
3369 3369
 
@@ -3372,15 +3372,15 @@  discard block
 block discarded – undo
3372 3372
 	 *
3373 3373
 	 * @since 1.0.19
3374 3374
 	 */
3375
-	public function get_tax( $tax = null ) {
3375
+	public function get_tax($tax = null) {
3376 3376
 
3377 3377
 		// Backwards compatility.
3378
-		if ( empty( $tax ) ) {
3378
+		if (empty($tax)) {
3379 3379
 			return $this->get_total_tax();
3380 3380
 		}
3381 3381
 
3382 3382
         $taxes = $this->get_taxes();
3383
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3383
+		return isset($taxes[$tax]) ? $taxes[$tax] : null;
3384 3384
     }
3385 3385
 
3386 3386
     /**
@@ -3388,11 +3388,11 @@  discard block
 block discarded – undo
3388 3388
 	 *
3389 3389
 	 * @since 1.0.19
3390 3390
 	 */
3391
-	public function remove_tax( $tax ) {
3391
+	public function remove_tax($tax) {
3392 3392
         $taxes = $this->get_discounts();
3393
-        if ( isset( $taxes[ $tax ] ) ) {
3394
-            unset( $taxes[ $tax ] );
3395
-            $this->set_prop( 'taxes', $taxes );
3393
+        if (isset($taxes[$tax])) {
3394
+            unset($taxes[$tax]);
3395
+            $this->set_prop('taxes', $taxes);
3396 3396
         }
3397 3397
     }
3398 3398
 
@@ -3403,19 +3403,19 @@  discard block
 block discarded – undo
3403 3403
 	 * @return float The recalculated subtotal
3404 3404
 	 */
3405 3405
 	public function recalculate_subtotal() {
3406
-        $items     = $this->get_items();
3406
+        $items = $this->get_items();
3407 3407
 		$subtotal  = 0;
3408 3408
 		$recurring = 0;
3409 3409
 
3410
-        foreach ( $items as $item ) {
3410
+        foreach ($items as $item) {
3411 3411
 			$subtotal  += $item->get_sub_total();
3412 3412
 			$recurring += $item->get_recurring_sub_total();
3413 3413
         }
3414 3414
 
3415
-		if ( $this->is_renewal() ) {
3416
-			$this->set_subtotal( $recurring );
3415
+		if ($this->is_renewal()) {
3416
+			$this->set_subtotal($recurring);
3417 3417
 		} else {
3418
-			$this->set_subtotal( $subtotal );
3418
+			$this->set_subtotal($subtotal);
3419 3419
 		}
3420 3420
 
3421 3421
 		$this->totals['subtotal'] = array(
@@ -3437,9 +3437,9 @@  discard block
 block discarded – undo
3437 3437
 		$discount  = 0;
3438 3438
 		$recurring = 0;
3439 3439
 
3440
-        foreach ( $discounts as $data ) {
3440
+        foreach ($discounts as $data) {
3441 3441
 
3442
-			if ( $data['recurring'] ) {
3442
+			if ($data['recurring']) {
3443 3443
 				$recurring += $data['amount'];
3444 3444
 			} else {
3445 3445
 				$discount += $data['amount'];
@@ -3447,10 +3447,10 @@  discard block
 block discarded – undo
3447 3447
 
3448 3448
 		}
3449 3449
 
3450
-		if ( $this->is_renewal() ) {
3451
-			$this->set_total_discount( $recurring );
3450
+		if ($this->is_renewal()) {
3451
+			$this->set_total_discount($recurring);
3452 3452
 		} else {
3453
-			$this->set_total_discount( $discount );
3453
+			$this->set_total_discount($discount);
3454 3454
 		}
3455 3455
 
3456 3456
 		$this->totals['discount'] = array(
@@ -3469,13 +3469,13 @@  discard block
 block discarded – undo
3469 3469
 	 * @return float The recalculated tax
3470 3470
 	 */
3471 3471
 	public function recalculate_total_tax() {
3472
-        $taxes     = $this->get_taxes();
3472
+        $taxes = $this->get_taxes();
3473 3473
 		$tax       = 0;
3474 3474
 		$recurring = 0;
3475 3475
 
3476
-        foreach ( $taxes as $data ) {
3476
+        foreach ($taxes as $data) {
3477 3477
 
3478
-			if ( $data['recurring'] ) {
3478
+			if ($data['recurring']) {
3479 3479
 				$recurring += $data['amount'];
3480 3480
 			} else {
3481 3481
 				$tax += $data['amount'];
@@ -3483,10 +3483,10 @@  discard block
 block discarded – undo
3483 3483
 
3484 3484
 		}
3485 3485
 
3486
-		if ( $this->is_renewal() ) {
3487
-			$this->set_total_tax( $recurring );
3486
+		if ($this->is_renewal()) {
3487
+			$this->set_total_tax($recurring);
3488 3488
 		} else {
3489
-			$this->set_total_tax( $tax );
3489
+			$this->set_total_tax($tax);
3490 3490
 		}
3491 3491
 
3492 3492
 		$this->totals['tax'] = array(
@@ -3509,9 +3509,9 @@  discard block
 block discarded – undo
3509 3509
 		$fee       = 0;
3510 3510
 		$recurring = 0;
3511 3511
 
3512
-        foreach ( $fees as $data ) {
3512
+        foreach ($fees as $data) {
3513 3513
 
3514
-			if ( $data['recurring'] ) {
3514
+			if ($data['recurring']) {
3515 3515
 				$recurring += $data['amount'];
3516 3516
 			} else {
3517 3517
 				$fee += $data['amount'];
@@ -3519,10 +3519,10 @@  discard block
 block discarded – undo
3519 3519
 
3520 3520
 		}
3521 3521
 
3522
-        if ( $this->is_renewal() ) {
3523
-			$this->set_total_fees( $recurring );
3522
+        if ($this->is_renewal()) {
3523
+			$this->set_total_fees($recurring);
3524 3524
 		} else {
3525
-			$this->set_total_fees( $fee );
3525
+			$this->set_total_fees($fee);
3526 3526
 		}
3527 3527
 
3528 3528
 		$this->totals['fee'] = array(
@@ -3530,7 +3530,7 @@  discard block
 block discarded – undo
3530 3530
 			'recurring' => $recurring,
3531 3531
 		);
3532 3532
 
3533
-        $this->set_total_fees( $fee );
3533
+        $this->set_total_fees($fee);
3534 3534
         return $this->is_renewal() ? $recurring : $fee;
3535 3535
     }
3536 3536
 
@@ -3551,9 +3551,9 @@  discard block
 block discarded – undo
3551 3551
 	/**
3552 3552
 	 * @deprecated
3553 3553
 	 */
3554
-    public function recalculate_totals( $temp = false ) {
3555
-        $this->update_items( $temp );
3556
-        $this->save( true );
3554
+    public function recalculate_totals($temp = false) {
3555
+        $this->update_items($temp);
3556
+        $this->save(true);
3557 3557
         return $this;
3558 3558
     }
3559 3559
 
@@ -3571,10 +3571,10 @@  discard block
 block discarded – undo
3571 3571
 	 * @return int|false The new note's ID on success, false on failure.
3572 3572
      *
3573 3573
      */
3574
-    public function add_note( $note = '', $customer_type = false, $added_by_user = false, $system = false ) {
3574
+    public function add_note($note = '', $customer_type = false, $added_by_user = false, $system = false) {
3575 3575
 
3576 3576
         // Bail if no note specified or this invoice is not yet saved.
3577
-        if ( ! $note || $this->get_id() == 0 || ( ! is_user_logged_in() && ! $system ) ) {
3577
+        if (!$note || $this->get_id() == 0 || (!is_user_logged_in() && !$system)) {
3578 3578
             return false;
3579 3579
         }
3580 3580
 
@@ -3582,23 +3582,23 @@  discard block
 block discarded – undo
3582 3582
 		$author_email = '[email protected]';
3583 3583
 
3584 3584
 		// If this is an admin comment or it has been added by the user.
3585
-		if ( is_user_logged_in() && ( ! $system || $added_by_user ) ) {
3586
-			$user         = get_user_by( 'id', get_current_user_id() );
3585
+		if (is_user_logged_in() && (!$system || $added_by_user)) {
3586
+			$user = get_user_by('id', get_current_user_id());
3587 3587
             $author       = $user->display_name;
3588 3588
             $author_email = $user->user_email;
3589 3589
 		}
3590 3590
 
3591
-		return getpaid_notes()->add_invoice_note( $this, $note, $author, $author_email, $customer_type );
3591
+		return getpaid_notes()->add_invoice_note($this, $note, $author, $author_email, $customer_type);
3592 3592
 
3593 3593
 	}
3594 3594
 
3595 3595
 	/**
3596 3596
      * Generates a unique key for the invoice.
3597 3597
      */
3598
-    public function generate_key( $string = '' ) {
3599
-        $auth_key  = defined( 'AUTH_KEY' ) ? AUTH_KEY : '';
3598
+    public function generate_key($string = '') {
3599
+        $auth_key = defined('AUTH_KEY') ? AUTH_KEY : '';
3600 3600
         return strtolower(
3601
-            $string . md5( $this->get_id() . date( 'Y-m-d H:i:s' ) . $auth_key . uniqid( 'wpinv', true ) )
3601
+            $string . md5($this->get_id() . date('Y-m-d H:i:s') . $auth_key . uniqid('wpinv', true))
3602 3602
         );
3603 3603
     }
3604 3604
 
@@ -3608,11 +3608,11 @@  discard block
 block discarded – undo
3608 3608
     public function generate_number() {
3609 3609
         $number = $this->get_id();
3610 3610
 
3611
-        if ( wpinv_sequential_number_active( $this->get_post_type() ) ) {
3612
-            $number = wpinv_get_next_invoice_number( $this->get_post_type() );
3611
+        if (wpinv_sequential_number_active($this->get_post_type())) {
3612
+            $number = wpinv_get_next_invoice_number($this->get_post_type());
3613 3613
         }
3614 3614
 
3615
-		return wpinv_format_invoice_number( $number, $this->get_post_type() );
3615
+		return wpinv_format_invoice_number($number, $this->get_post_type());
3616 3616
 
3617 3617
 	}
3618 3618
 
@@ -3625,47 +3625,47 @@  discard block
 block discarded – undo
3625 3625
 		// Reset status transition variable.
3626 3626
 		$this->status_transition = false;
3627 3627
 
3628
-		if ( $status_transition ) {
3628
+		if ($status_transition) {
3629 3629
 			try {
3630 3630
 
3631 3631
 				// Fire a hook for the status change.
3632
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition );
3632
+				do_action('getpaid_invoice_status_' . $status_transition['to'], $this, $status_transition);
3633 3633
 
3634 3634
 				// @deprecated this is deprecated and will be removed in the future.
3635
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3635
+				do_action('wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3636 3636
 
3637
-				if ( ! empty( $status_transition['from'] ) ) {
3637
+				if (!empty($status_transition['from'])) {
3638 3638
 
3639 3639
 					/* translators: 1: old invoice status 2: new invoice status */
3640
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3640
+					$transition_note = sprintf(__('Status changed from %1$s to %2$s.', 'invoicing'), wpinv_status_nicename($status_transition['from']), wpinv_status_nicename($status_transition['to']));
3641 3641
 
3642 3642
 					// Fire another hook.
3643
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this );
3644
-					do_action( 'getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to'] );
3643
+					do_action('getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this);
3644
+					do_action('getpaid_invoice_status_changed', $this, $status_transition['from'], $status_transition['to']);
3645 3645
 
3646 3646
 					// @deprecated this is deprecated and will be removed in the future.
3647
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3647
+					do_action('wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from']);
3648 3648
 
3649 3649
 					// Note the transition occurred.
3650
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3650
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3651 3651
 
3652 3652
 					// Work out if this was for a payment, and trigger a payment_status hook instead.
3653 3653
 					if (
3654
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3655
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3654
+						in_array($status_transition['from'], array('wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded'), true)
3655
+						&& in_array($status_transition['to'], array('publish', 'wpi-processing', 'wpi-renewal'), true)
3656 3656
 					) {
3657
-						do_action( 'getpaid_invoice_payment_status_changed', $this, $status_transition );
3657
+						do_action('getpaid_invoice_payment_status_changed', $this, $status_transition);
3658 3658
 					}
3659 3659
 				} else {
3660 3660
 					/* translators: %s: new invoice status */
3661
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3661
+					$transition_note = sprintf(__('Status set to %s.', 'invoicing'), wpinv_status_nicename($status_transition['to']));
3662 3662
 
3663 3663
 					// Note the transition occurred.
3664
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3664
+					$this->add_note(trim($status_transition['note'] . ' ' . $transition_note), 0, $status_transition['manual']);
3665 3665
 
3666 3666
 				}
3667
-			} catch ( Exception $e ) {
3668
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3667
+			} catch (Exception $e) {
3668
+				$this->add_note(__('Error during status transition.', 'invoicing') . ' ' . $e->getMessage());
3669 3669
 			}
3670 3670
 		}
3671 3671
 	}
@@ -3673,13 +3673,13 @@  discard block
 block discarded – undo
3673 3673
 	/**
3674 3674
 	 * Updates an invoice status.
3675 3675
 	 */
3676
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3676
+	public function update_status($new_status = false, $note = '', $manual = false) {
3677 3677
 
3678 3678
 		// Fires before updating a status.
3679
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3679
+		do_action('wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status('edit'));
3680 3680
 
3681 3681
 		// Update the status.
3682
-		$this->set_status( $new_status, $note, $manual );
3682
+		$this->set_status($new_status, $note, $manual);
3683 3683
 
3684 3684
 		// Save the order.
3685 3685
 		return $this->save();
@@ -3690,18 +3690,18 @@  discard block
 block discarded – undo
3690 3690
 	 * @deprecated
3691 3691
 	 */
3692 3692
 	public function refresh_item_ids() {
3693
-        $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3694
-        update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3693
+        $item_ids = implode(',', array_unique(array_keys($this->get_items())));
3694
+        update_post_meta($this->get_id(), '_wpinv_item_ids', $item_ids);
3695 3695
 	}
3696 3696
 
3697 3697
 	/**
3698 3698
 	 * @deprecated
3699 3699
 	 */
3700
-	public function update_items( $temp = false ) {
3700
+	public function update_items($temp = false) {
3701 3701
 
3702
-		$this->set_items( $this->get_items() );
3702
+		$this->set_items($this->get_items());
3703 3703
 
3704
-		if ( ! $temp ) {
3704
+		if (!$temp) {
3705 3705
 			$this->save();
3706 3706
 		}
3707 3707
 
@@ -3715,11 +3715,11 @@  discard block
 block discarded – undo
3715 3715
 
3716 3716
         $discount_code = $this->get_discount_code();
3717 3717
 
3718
-        if ( empty( $discount_code ) ) {
3718
+        if (empty($discount_code)) {
3719 3719
             return false;
3720 3720
         }
3721 3721
 
3722
-        $discount = wpinv_get_discount_obj( $discount_code );
3722
+        $discount = wpinv_get_discount_obj($discount_code);
3723 3723
 
3724 3724
         // Ensure it is active.
3725 3725
         return $discount->exists();
@@ -3730,7 +3730,7 @@  discard block
 block discarded – undo
3730 3730
 	 * Refunds an invoice.
3731 3731
 	 */
3732 3732
     public function refund() {
3733
-		$this->set_status( 'wpi-refunded' );
3733
+		$this->set_status('wpi-refunded');
3734 3734
         $this->save();
3735 3735
 	}
3736 3736
 
@@ -3739,56 +3739,56 @@  discard block
 block discarded – undo
3739 3739
 	 * 
3740 3740
 	 * @param string $transaction_id
3741 3741
 	 */
3742
-    public function mark_paid( $transaction_id = null, $note = '' ) {
3742
+    public function mark_paid($transaction_id = null, $note = '') {
3743 3743
 
3744 3744
 		// Set the transaction id.
3745
-		if ( empty( $transaction_id ) ) {
3745
+		if (empty($transaction_id)) {
3746 3746
 			$transaction_id = $this->generate_key('trans_');
3747 3747
 		}
3748 3748
 
3749
-		if ( ! $this->get_transaction_id() ) {
3750
-			$this->set_transaction_id( $transaction_id );
3749
+		if (!$this->get_transaction_id()) {
3750
+			$this->set_transaction_id($transaction_id);
3751 3751
 		}
3752 3752
 
3753
-		if ( $this->is_paid() && 'wpi-processing' != $this->get_status() ) {
3753
+		if ($this->is_paid() && 'wpi-processing' != $this->get_status()) {
3754 3754
 			return $this->save();
3755 3755
 		}
3756 3756
 
3757 3757
 		// Set the completed date.
3758
-		$this->set_date_completed( current_time( 'mysql' ) );
3758
+		$this->set_date_completed(current_time('mysql'));
3759 3759
 
3760 3760
 		// Set the new status.
3761
-		if ( $this->is_renewal() ) {
3761
+		if ($this->is_renewal()) {
3762 3762
 
3763 3763
 			$_note = sprintf(
3764
-				__( 'Renewed via %s', 'invoicing' ),
3765
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3764
+				__('Renewed via %s', 'invoicing'),
3765
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3766 3766
 			);
3767 3767
 
3768
-			if ( 'none' == $this->get_gateway() ) {
3768
+			if ('none' == $this->get_gateway()) {
3769 3769
 				$_note = $note;
3770 3770
 			}
3771 3771
 
3772
-			$this->set_status( 'wpi-renewal', $_note );
3772
+			$this->set_status('wpi-renewal', $_note);
3773 3773
 
3774 3774
 		} else {
3775 3775
 
3776 3776
 			$_note = sprintf(
3777
-				__( 'Paid via %s', 'invoicing' ),
3778
-				$this->get_gateway_title() . empty( $note ) ? '' : " ($note)"
3777
+				__('Paid via %s', 'invoicing'),
3778
+				$this->get_gateway_title() . empty($note) ? '' : " ($note)"
3779 3779
 			);
3780 3780
 
3781
-			if ( 'none' == $this->get_gateway() ) {
3781
+			if ('none' == $this->get_gateway()) {
3782 3782
 				$_note = $note;
3783 3783
 			}
3784 3784
 
3785
-			$this->set_status( 'publish',$_note );
3785
+			$this->set_status('publish', $_note);
3786 3786
 
3787 3787
 		}
3788 3788
 
3789 3789
 		// Set checkout mode.
3790
-		$mode = wpinv_is_test_mode( $this->get_gateway() ) ? 'test' : 'live';
3791
-		$this->set_mode( $mode );
3790
+		$mode = wpinv_is_test_mode($this->get_gateway()) ? 'test' : 'live';
3791
+		$this->set_mode($mode);
3792 3792
 
3793 3793
 		// Save the invoice.
3794 3794
         $this->save();
@@ -3814,9 +3814,9 @@  discard block
 block discarded – undo
3814 3814
      * Clears the subscription's cache.
3815 3815
      */
3816 3816
     public function clear_cache() {
3817
-		wp_cache_delete( $this->get_key(), 'getpaid_invoice_keys_to_invoice_ids' );
3818
-		wp_cache_delete( $this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids' );
3819
-		wp_cache_delete( $this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids' );
3817
+		wp_cache_delete($this->get_key(), 'getpaid_invoice_keys_to_invoice_ids');
3818
+		wp_cache_delete($this->get_number(), 'getpaid_invoice_numbers_to_invoice_ids');
3819
+		wp_cache_delete($this->get_transaction_id(), 'getpaid_invoice_transaction_ids_to_invoice_ids');
3820 3820
 	}
3821 3821
 
3822 3822
 }
Please login to merge, or discard this patch.