Passed
Push — master ( cb75a2...6929e7 )
by Brian
05:54 queued 11s
created
templates/invoice-history.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -40,86 +40,86 @@  discard block
 block discarded – undo
40 40
 				<tr class="wpinv-item wpinv-item-<?php echo $invoice_status = $invoice->get_status(); ?>">
41 41
 					<?php
42 42
 
43
-						foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) :
43
+                        foreach ( wpinv_get_user_invoices_columns() as $column_id => $column_name ) :
44 44
 
45
-							$column_id = sanitize_html_class( $column_id );
46
-							$class     = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] );
45
+                            $column_id = sanitize_html_class( $column_id );
46
+                            $class     = empty( $column_name['class'] ) ? '' : sanitize_html_class( $column_name['class'] );
47 47
 
48
-							echo "<td class='$column_id $class'>";
49
-							switch ( $column_id ) {
48
+                            echo "<td class='$column_id $class'>";
49
+                            switch ( $column_id ) {
50 50
 
51
-								case 'invoice-number':
52
-									echo wpinv_invoice_link( $invoice );
53
-									break;
51
+                                case 'invoice-number':
52
+                                    echo wpinv_invoice_link( $invoice );
53
+                                    break;
54 54
 
55
-								case 'created-date':
56
-									echo date_i18n( get_option( 'date_format' ), strtotime( $invoice->get_date_created() ) );
57
-									break;
55
+                                case 'created-date':
56
+                                    echo date_i18n( get_option( 'date_format' ), strtotime( $invoice->get_date_created() ) );
57
+                                    break;
58 58
 
59
-								case 'payment-date':
59
+                                case 'payment-date':
60 60
 
61
-									if ( $invoice->needs_payment() ) {
62
-										echo "&mdash;";
63
-									} else {
64
-										echo date_i18n( get_option( 'date_format' ), strtotime( $invoice->get_date_completed() ) );
65
-									}
61
+                                    if ( $invoice->needs_payment() ) {
62
+                                        echo "&mdash;";
63
+                                    } else {
64
+                                        echo date_i18n( get_option( 'date_format' ), strtotime( $invoice->get_date_completed() ) );
65
+                                    }
66 66
 									
67
-									break;
67
+                                    break;
68 68
 
69
-								case 'invoice-status':
70
-									echo wpinv_invoice_status_label( $invoice->get_status(), $invoice->get_status_nicename() );
69
+                                case 'invoice-status':
70
+                                    echo wpinv_invoice_status_label( $invoice->get_status(), $invoice->get_status_nicename() );
71 71
 									
72
-									break;
72
+                                    break;
73 73
 
74
-								case 'invoice-total':
75
-									echo wpinv_price( wpinv_format_amount( $invoice->get_total() ) );
74
+                                case 'invoice-total':
75
+                                    echo wpinv_price( wpinv_format_amount( $invoice->get_total() ) );
76 76
 									
77
-									break;
77
+                                    break;
78 78
 
79
-								case 'invoice-actions':
79
+                                case 'invoice-actions':
80 80
 
81
-									$actions = array(
81
+                                    $actions = array(
82 82
 
83
-										'pay'       => array(
84
-											'url'   => $invoice->get_checkout_payment_url(),
85
-											'name'  => __( 'Pay Now', 'invoicing' ),
83
+                                        'pay'       => array(
84
+                                            'url'   => $invoice->get_checkout_payment_url(),
85
+                                            'name'  => __( 'Pay Now', 'invoicing' ),
86 86
                                             'class' => 'btn-success'
87
-										),
87
+                                        ),
88 88
 
89 89
                                         'print'     => array(
90
-											'url'   => $invoice->get_view_url(),
91
-											'name'  => __( 'View Invoice', 'invoicing' ),
90
+                                            'url'   => $invoice->get_view_url(),
91
+                                            'name'  => __( 'View Invoice', 'invoicing' ),
92 92
                                             'class' => 'btn-secondary',
93 93
                                             'attrs' => 'target="_blank"'
94
-										)
95
-									);
94
+                                        )
95
+                                    );
96 96
 
97
-									if ( ! $invoice->needs_payment() ) {
98
-										unset( $actions['pay'] );
99
-									}
97
+                                    if ( ! $invoice->needs_payment() ) {
98
+                                        unset( $actions['pay'] );
99
+                                    }
100 100
 
101
-									$actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice );
101
+                                    $actions = apply_filters( 'wpinv_user_invoices_actions', $actions, $invoice );
102 102
 
103
-									foreach ( $actions as $key => $action ) {
104
-										$class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
105
-										echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
106
-									}
103
+                                    foreach ( $actions as $key => $action ) {
104
+                                        $class = !empty($action['class']) ? sanitize_html_class($action['class']) : '';
105
+                                        echo '<a href="' . esc_url( $action['url'] ) . '" class="btn btn-sm btn-block ' . $class . ' ' . sanitize_html_class( $key ) . '" ' . ( !empty($action['attrs']) ? $action['attrs'] : '' ) . '>' . $action['name'] . '</a>';
106
+                                    }
107 107
 									
108
-									break;
108
+                                    break;
109 109
 
110
-								default:
111
-									do_action( "wpinv_user_invoices_column_$column_id", $invoice );
112
-									break;
110
+                                default:
111
+                                    do_action( "wpinv_user_invoices_column_$column_id", $invoice );
112
+                                    break;
113 113
 
114 114
 								
115
-							}
115
+                            }
116 116
 
117
-							do_action( "wpinv_user_invoices_column_after_$column_id", $invoice );
117
+                            do_action( "wpinv_user_invoices_column_after_$column_id", $invoice );
118 118
 						
119
-							echo '</td>';
119
+                            echo '</td>';
120 120
 
121
-						endforeach;
122
-					?>
121
+                        endforeach;
122
+                    ?>
123 123
 				</tr>
124 124
 
125 125
 			<?php endforeach; ?>
@@ -132,14 +132,14 @@  discard block
 block discarded – undo
132 132
 	<?php if ( 1 < $invoices->max_num_pages ) : ?>
133 133
 		<div class="invoicing-Pagination">
134 134
 			<?php
135
-			$big = 999999;
136
-
137
-			echo paginate_links( array(
138
-				'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
139
-				'format'  => '?paged=%#%',
140
-				'total'   => $invoices->max_num_pages,
141
-			) );
142
-			?>
135
+            $big = 999999;
136
+
137
+            echo paginate_links( array(
138
+                'base'    => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
139
+                'format'  => '?paged=%#%',
140
+                'total'   => $invoices->max_num_pages,
141
+            ) );
142
+            ?>
143 143
 		</div>
144 144
 	<?php endif; ?>
145 145
 
Please login to merge, or discard this patch.
includes/deprecated-functions.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
  * @deprecated
247 247
  */
248 248
 function wpinv_get_payment_key( $invoice = 0 ) {
249
-	$invoice = new WPInv_Invoice( $invoice );
249
+    $invoice = new WPInv_Invoice( $invoice );
250 250
     return $invoice->get_key();
251 251
 }
252 252
 
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
  * @deprecated
425 425
  */
426 426
 function wpinv_get_checkout_session() {
427
-	return false;
427
+    return false;
428 428
 }
429 429
 
430 430
 /**
Please login to merge, or discard this patch.
includes/data-stores/class-getpaid-data.php 1 patch
Indentation   +857 added lines, -857 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 ) {
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 ) {
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,509 +391,509 @@  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
-		$this->meta_data = array();
615
-		$cache_loaded    = false;
616
-
617
-		if ( ! $this->get_id() ) {
618
-			return;
619
-		}
620
-
621
-		if ( ! $this->data_store ) {
622
-			return;
623
-		}
624
-
625
-		if ( ! 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
-		}
628
-
629
-		if ( ! $force_read ) {
630
-			if ( ! empty( $this->cache_group ) ) {
631
-				$cached_meta  = wp_cache_get( $cache_key, $this->cache_group );
632
-				$cache_loaded = ! empty( $cached_meta );
633
-			}
634
-		}
635
-
636
-		$raw_meta_data = $cache_loaded ? $cached_meta : $this->data_store->read_meta( $this );
637
-		if ( $raw_meta_data ) {
638
-			foreach ( $raw_meta_data as $meta ) {
639
-				$this->meta_data[] = new GetPaid_Meta_Data(
640
-					array(
641
-						'id'    => (int) $meta->meta_id,
642
-						'key'   => $meta->meta_key,
643
-						'value' => maybe_unserialize( $meta->meta_value ),
644
-					)
645
-				);
646
-			}
647
-
648
-			if ( ! $cache_loaded && ! empty( $this->cache_group ) ) {
649
-				wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group );
650
-			}
651
-		}
652
-	}
653
-
654
-	/**
655
-	 * Update Meta Data in the database.
656
-	 *
657
-	 * @since 1.0.19
658
-	 */
659
-	public function save_meta_data() {
660
-		if ( ! $this->data_store || is_null( $this->meta_data ) ) {
661
-			return;
662
-		}
663
-		foreach ( $this->meta_data as $array_key => $meta ) {
664
-			if ( is_null( $meta->value ) ) {
665
-				if ( ! empty( $meta->id ) ) {
666
-					$this->data_store->delete_meta( $this, $meta );
667
-					unset( $this->meta_data[ $array_key ] );
668
-				}
669
-			} elseif ( empty( $meta->id ) ) {
670
-				$meta->id = $this->data_store->add_meta( $this, $meta );
671
-				$meta->apply_changes();
672
-			} else {
673
-				if ( $meta->get_changes() ) {
674
-					$this->data_store->update_meta( $this, $meta );
675
-					$meta->apply_changes();
676
-				}
677
-			}
678
-		}
679
-		if ( ! empty( $this->cache_group ) ) {
680
-			$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();
681
-			wp_cache_delete( $cache_key, $this->cache_group );
682
-		}
683
-	}
684
-
685
-	/**
686
-	 * Set ID.
687
-	 *
688
-	 * @since 1.0.19
689
-	 * @param int $id ID.
690
-	 */
691
-	public function set_id( $id ) {
692
-		$this->id = absint( $id );
693
-	}
694
-
695
-	/**
696
-	 * Sets item status.
697
-	 *
698
-	 * @since 1.0.19
699
-	 * @param string $status New status.
700
-	 * @return array details of change.
701
-	 */
702
-	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
+        $this->meta_data = array();
615
+        $cache_loaded    = false;
616
+
617
+        if ( ! $this->get_id() ) {
618
+            return;
619
+        }
620
+
621
+        if ( ! $this->data_store ) {
622
+            return;
623
+        }
624
+
625
+        if ( ! 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
+        }
628
+
629
+        if ( ! $force_read ) {
630
+            if ( ! empty( $this->cache_group ) ) {
631
+                $cached_meta  = wp_cache_get( $cache_key, $this->cache_group );
632
+                $cache_loaded = ! empty( $cached_meta );
633
+            }
634
+        }
635
+
636
+        $raw_meta_data = $cache_loaded ? $cached_meta : $this->data_store->read_meta( $this );
637
+        if ( $raw_meta_data ) {
638
+            foreach ( $raw_meta_data as $meta ) {
639
+                $this->meta_data[] = new GetPaid_Meta_Data(
640
+                    array(
641
+                        'id'    => (int) $meta->meta_id,
642
+                        'key'   => $meta->meta_key,
643
+                        'value' => maybe_unserialize( $meta->meta_value ),
644
+                    )
645
+                );
646
+            }
647
+
648
+            if ( ! $cache_loaded && ! empty( $this->cache_group ) ) {
649
+                wp_cache_set( $cache_key, $raw_meta_data, $this->cache_group );
650
+            }
651
+        }
652
+    }
653
+
654
+    /**
655
+     * Update Meta Data in the database.
656
+     *
657
+     * @since 1.0.19
658
+     */
659
+    public function save_meta_data() {
660
+        if ( ! $this->data_store || is_null( $this->meta_data ) ) {
661
+            return;
662
+        }
663
+        foreach ( $this->meta_data as $array_key => $meta ) {
664
+            if ( is_null( $meta->value ) ) {
665
+                if ( ! empty( $meta->id ) ) {
666
+                    $this->data_store->delete_meta( $this, $meta );
667
+                    unset( $this->meta_data[ $array_key ] );
668
+                }
669
+            } elseif ( empty( $meta->id ) ) {
670
+                $meta->id = $this->data_store->add_meta( $this, $meta );
671
+                $meta->apply_changes();
672
+            } else {
673
+                if ( $meta->get_changes() ) {
674
+                    $this->data_store->update_meta( $this, $meta );
675
+                    $meta->apply_changes();
676
+                }
677
+            }
678
+        }
679
+        if ( ! empty( $this->cache_group ) ) {
680
+            $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();
681
+            wp_cache_delete( $cache_key, $this->cache_group );
682
+        }
683
+    }
684
+
685
+    /**
686
+     * Set ID.
687
+     *
688
+     * @since 1.0.19
689
+     * @param int $id ID.
690
+     */
691
+    public function set_id( $id ) {
692
+        $this->id = absint( $id );
693
+    }
694
+
695
+    /**
696
+     * Sets item status.
697
+     *
698
+     * @since 1.0.19
699
+     * @param string $status New status.
700
+     * @return array details of change.
701
+     */
702
+    public function set_status( $status ) {
703 703
         $old_status = $this->get_status();
704 704
 
705
-		$this->set_prop( 'status', $status );
706
-
707
-		return array(
708
-			'from' => $old_status,
709
-			'to'   => $status,
710
-		);
711
-    }
712
-
713
-	/**
714
-	 * Set all props to default values.
715
-	 *
716
-	 * @since 1.0.19
717
-	 */
718
-	public function set_defaults() {
719
-		$this->data    = $this->default_data;
720
-		$this->changes = array();
721
-		$this->set_object_read( false );
722
-	}
723
-
724
-	/**
725
-	 * Set object read property.
726
-	 *
727
-	 * @since 1.0.19
728
-	 * @param boolean $read Should read?.
729
-	 */
730
-	public function set_object_read( $read = true ) {
731
-		$this->object_read = (bool) $read;
732
-	}
733
-
734
-	/**
735
-	 * Get object read property.
736
-	 *
737
-	 * @since  1.0.19
738
-	 * @return boolean
739
-	 */
740
-	public function get_object_read() {
741
-		return (bool) $this->object_read;
742
-	}
743
-
744
-	/**
745
-	 * Set a collection of props in one go, collect any errors, and return the result.
746
-	 * Only sets using public methods.
747
-	 *
748
-	 * @since  1.0.19
749
-	 *
750
-	 * @param array  $props Key value pairs to set. Key is the prop and should map to a setter function name.
751
-	 * @param string $context In what context to run this.
752
-	 *
753
-	 * @return bool|WP_Error
754
-	 */
755
-	public function set_props( $props, $context = 'set' ) {
756
-		$errors = false;
757
-
758
-		foreach ( $props as $prop => $value ) {
759
-			try {
760
-				/**
761
-				 * Checks if the prop being set is allowed, and the value is not null.
762
-				 */
763
-				if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
764
-					continue;
765
-				}
766
-				$setter = "set_$prop";
767
-
768
-				if ( is_callable( array( $this, $setter ) ) ) {
769
-					$this->{$setter}( $value );
770
-				}
771
-			} catch ( Exception $e ) {
772
-				if ( ! $errors ) {
773
-					$errors = new WP_Error();
774
-				}
775
-				$errors->add( $e->getCode(), $e->getMessage() );
776
-				$this->last_error = $e->getMessage();
777
-			}
778
-		}
779
-
780
-		return $errors && count( $errors->get_error_codes() ) ? $errors : true;
781
-	}
782
-
783
-	/**
784
-	 * Sets a prop for a setter method.
785
-	 *
786
-	 * This stores changes in a special array so we can track what needs saving
787
-	 * the the DB later.
788
-	 *
789
-	 * @since 1.0.19
790
-	 * @param string $prop Name of prop to set.
791
-	 * @param mixed  $value Value of the prop.
792
-	 */
793
-	protected function set_prop( $prop, $value ) {
794
-		if ( array_key_exists( $prop, $this->data ) ) {
795
-			if ( true === $this->object_read ) {
796
-				if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
797
-					$this->changes[ $prop ] = maybe_unserialize( $value );
798
-				}
799
-			} else {
800
-				$this->data[ $prop ] = maybe_unserialize( $value );
801
-			}
802
-		}
803
-	}
804
-
805
-	/**
806
-	 * Return data changes only.
807
-	 *
808
-	 * @since 1.0.19
809
-	 * @return array
810
-	 */
811
-	public function get_changes() {
812
-		return $this->changes;
813
-	}
814
-
815
-	/**
816
-	 * Merge changes with data and clear.
817
-	 *
818
-	 * @since 1.0.19
819
-	 */
820
-	public function apply_changes() {
821
-		$this->data    = array_replace_recursive( $this->data, $this->changes );
822
-		$this->changes = array();
823
-	}
824
-
825
-	/**
826
-	 * Prefix for action and filter hooks on data.
827
-	 *
828
-	 * @since  1.0.19
829
-	 * @return string
830
-	 */
831
-	protected function get_hook_prefix() {
832
-		return 'wpinv_get_' . $this->object_type . '_';
833
-	}
834
-
835
-	/**
836
-	 * Gets a prop for a getter method.
837
-	 *
838
-	 * Gets the value from either current pending changes, or the data itself.
839
-	 * Context controls what happens to the value before it's returned.
840
-	 *
841
-	 * @since  1.0.19
842
-	 * @param  string $prop Name of prop to get.
843
-	 * @param  string $context What the value is for. Valid values are view and edit.
844
-	 * @return mixed
845
-	 */
846
-	protected function get_prop( $prop, $context = 'view' ) {
847
-		$value = null;
848
-
849
-		if ( array_key_exists( $prop, $this->data ) ) {
850
-			$value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ];
851
-
852
-			if ( 'view' === $context ) {
853
-				$value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
854
-			}
855
-		}
856
-
857
-		return $value;
858
-	}
859
-
860
-	/**
861
-	 * Sets a date prop whilst handling formatting and datetime objects.
862
-	 *
863
-	 * @since 1.0.19
864
-	 * @param string         $prop Name of prop to set.
865
-	 * @param string|integer $value Value of the prop.
866
-	 */
867
-	protected function set_date_prop( $prop, $value ) {
868
-
869
-		if ( empty( $value ) ) {
870
-			$this->set_prop( $prop, null );
871
-			return;
872
-		}
873
-		$this->set_prop( $prop, $value );
874
-
875
-	}
876
-
877
-	/**
878
-	 * When invalid data is found, throw an exception unless reading from the DB.
879
-	 *
880
-	 * @since 1.0.19
881
-	 * @param string $code             Error code.
882
-	 * @param string $message          Error message.
883
-	 */
884
-	protected function error( $code, $message ) {
885
-		$this->last_error = $message;
886
-	}
887
-
888
-	/**
889
-	 * Checks if the object is saved in the database
890
-	 *
891
-	 * @since 1.0.19
892
-	 * @return bool
893
-	 */
894
-	public function exists() {
895
-		$id = $this->get_id();
896
-		return ! empty( $id );
897
-	}
705
+        $this->set_prop( 'status', $status );
706
+
707
+        return array(
708
+            'from' => $old_status,
709
+            'to'   => $status,
710
+        );
711
+    }
712
+
713
+    /**
714
+     * Set all props to default values.
715
+     *
716
+     * @since 1.0.19
717
+     */
718
+    public function set_defaults() {
719
+        $this->data    = $this->default_data;
720
+        $this->changes = array();
721
+        $this->set_object_read( false );
722
+    }
723
+
724
+    /**
725
+     * Set object read property.
726
+     *
727
+     * @since 1.0.19
728
+     * @param boolean $read Should read?.
729
+     */
730
+    public function set_object_read( $read = true ) {
731
+        $this->object_read = (bool) $read;
732
+    }
733
+
734
+    /**
735
+     * Get object read property.
736
+     *
737
+     * @since  1.0.19
738
+     * @return boolean
739
+     */
740
+    public function get_object_read() {
741
+        return (bool) $this->object_read;
742
+    }
743
+
744
+    /**
745
+     * Set a collection of props in one go, collect any errors, and return the result.
746
+     * Only sets using public methods.
747
+     *
748
+     * @since  1.0.19
749
+     *
750
+     * @param array  $props Key value pairs to set. Key is the prop and should map to a setter function name.
751
+     * @param string $context In what context to run this.
752
+     *
753
+     * @return bool|WP_Error
754
+     */
755
+    public function set_props( $props, $context = 'set' ) {
756
+        $errors = false;
757
+
758
+        foreach ( $props as $prop => $value ) {
759
+            try {
760
+                /**
761
+                 * Checks if the prop being set is allowed, and the value is not null.
762
+                 */
763
+                if ( is_null( $value ) || in_array( $prop, array( 'prop', 'date_prop', 'meta_data' ), true ) ) {
764
+                    continue;
765
+                }
766
+                $setter = "set_$prop";
767
+
768
+                if ( is_callable( array( $this, $setter ) ) ) {
769
+                    $this->{$setter}( $value );
770
+                }
771
+            } catch ( Exception $e ) {
772
+                if ( ! $errors ) {
773
+                    $errors = new WP_Error();
774
+                }
775
+                $errors->add( $e->getCode(), $e->getMessage() );
776
+                $this->last_error = $e->getMessage();
777
+            }
778
+        }
779
+
780
+        return $errors && count( $errors->get_error_codes() ) ? $errors : true;
781
+    }
782
+
783
+    /**
784
+     * Sets a prop for a setter method.
785
+     *
786
+     * This stores changes in a special array so we can track what needs saving
787
+     * the the DB later.
788
+     *
789
+     * @since 1.0.19
790
+     * @param string $prop Name of prop to set.
791
+     * @param mixed  $value Value of the prop.
792
+     */
793
+    protected function set_prop( $prop, $value ) {
794
+        if ( array_key_exists( $prop, $this->data ) ) {
795
+            if ( true === $this->object_read ) {
796
+                if ( $value !== $this->data[ $prop ] || array_key_exists( $prop, $this->changes ) ) {
797
+                    $this->changes[ $prop ] = maybe_unserialize( $value );
798
+                }
799
+            } else {
800
+                $this->data[ $prop ] = maybe_unserialize( $value );
801
+            }
802
+        }
803
+    }
804
+
805
+    /**
806
+     * Return data changes only.
807
+     *
808
+     * @since 1.0.19
809
+     * @return array
810
+     */
811
+    public function get_changes() {
812
+        return $this->changes;
813
+    }
814
+
815
+    /**
816
+     * Merge changes with data and clear.
817
+     *
818
+     * @since 1.0.19
819
+     */
820
+    public function apply_changes() {
821
+        $this->data    = array_replace_recursive( $this->data, $this->changes );
822
+        $this->changes = array();
823
+    }
824
+
825
+    /**
826
+     * Prefix for action and filter hooks on data.
827
+     *
828
+     * @since  1.0.19
829
+     * @return string
830
+     */
831
+    protected function get_hook_prefix() {
832
+        return 'wpinv_get_' . $this->object_type . '_';
833
+    }
834
+
835
+    /**
836
+     * Gets a prop for a getter method.
837
+     *
838
+     * Gets the value from either current pending changes, or the data itself.
839
+     * Context controls what happens to the value before it's returned.
840
+     *
841
+     * @since  1.0.19
842
+     * @param  string $prop Name of prop to get.
843
+     * @param  string $context What the value is for. Valid values are view and edit.
844
+     * @return mixed
845
+     */
846
+    protected function get_prop( $prop, $context = 'view' ) {
847
+        $value = null;
848
+
849
+        if ( array_key_exists( $prop, $this->data ) ) {
850
+            $value = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : $this->data[ $prop ];
851
+
852
+            if ( 'view' === $context ) {
853
+                $value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this );
854
+            }
855
+        }
856
+
857
+        return $value;
858
+    }
859
+
860
+    /**
861
+     * Sets a date prop whilst handling formatting and datetime objects.
862
+     *
863
+     * @since 1.0.19
864
+     * @param string         $prop Name of prop to set.
865
+     * @param string|integer $value Value of the prop.
866
+     */
867
+    protected function set_date_prop( $prop, $value ) {
868
+
869
+        if ( empty( $value ) ) {
870
+            $this->set_prop( $prop, null );
871
+            return;
872
+        }
873
+        $this->set_prop( $prop, $value );
874
+
875
+    }
876
+
877
+    /**
878
+     * When invalid data is found, throw an exception unless reading from the DB.
879
+     *
880
+     * @since 1.0.19
881
+     * @param string $code             Error code.
882
+     * @param string $message          Error message.
883
+     */
884
+    protected function error( $code, $message ) {
885
+        $this->last_error = $message;
886
+    }
887
+
888
+    /**
889
+     * Checks if the object is saved in the database
890
+     *
891
+     * @since 1.0.19
892
+     * @return bool
893
+     */
894
+    public function exists() {
895
+        $id = $this->get_id();
896
+        return ! empty( $id );
897
+    }
898 898
 
899 899
 }
Please login to merge, or discard this patch.
includes/invoice-functions.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@
 block discarded – undo
67 67
  * Checks if the current user cna view an invoice receipt.
68 68
  */
69 69
 function wpinv_can_view_receipt( $invoice ) {
70
-	return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice );
70
+    return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice );
71 71
 }
72 72
 
73 73
 /**
Please login to merge, or discard this patch.
includes/class-getpaid-form-item.php 1 patch
Indentation   +340 added lines, -340 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined( 'ABSPATH' ) ) {
3
-	exit;
3
+    exit;
4 4
 }
5 5
 
6 6
 /**
@@ -10,60 +10,60 @@  discard block
 block discarded – undo
10 10
 class GetPaid_Form_Item  extends WPInv_Item {
11 11
 
12 12
     /**
13
-	 * Stores a custom description for the item.
14
-	 *
15
-	 * @var string
16
-	 */
17
-	protected $custom_description = null;
18
-
19
-	/**
20
-	 * Stores the item quantity.
21
-	 *
22
-	 * @var int
23
-	 */
24
-	protected $quantity = 1;
25
-
26
-	/**
27
-	 * Stores the item meta.
28
-	 *
29
-	 * @var array
30
-	 */
31
-	protected $meta = array();
32
-
33
-	/**
34
-	 * Is this item required?
35
-	 *
36
-	 * @var int
37
-	 */
38
-	protected $is_required = true;
39
-
40
-	/**
41
-	 * Are quantities allowed?
42
-	 *
43
-	 * @var int
44
-	 */
45
-	protected $allow_quantities = false;
46
-
47
-	/**
48
-	 * Associated invoice.
49
-	 *
50
-	 * @var int
51
-	 */
52
-	public $invoice_id = 0;
53
-
54
-	/**
55
-	 * Item discount.
56
-	 *
57
-	 * @var float
58
-	 */
59
-	public $item_discount = 0;
60
-
61
-	/**
62
-	 * Item tax.
63
-	 *
64
-	 * @var float
65
-	 */
66
-	public $item_tax = 0;
13
+     * Stores a custom description for the item.
14
+     *
15
+     * @var string
16
+     */
17
+    protected $custom_description = null;
18
+
19
+    /**
20
+     * Stores the item quantity.
21
+     *
22
+     * @var int
23
+     */
24
+    protected $quantity = 1;
25
+
26
+    /**
27
+     * Stores the item meta.
28
+     *
29
+     * @var array
30
+     */
31
+    protected $meta = array();
32
+
33
+    /**
34
+     * Is this item required?
35
+     *
36
+     * @var int
37
+     */
38
+    protected $is_required = true;
39
+
40
+    /**
41
+     * Are quantities allowed?
42
+     *
43
+     * @var int
44
+     */
45
+    protected $allow_quantities = false;
46
+
47
+    /**
48
+     * Associated invoice.
49
+     *
50
+     * @var int
51
+     */
52
+    public $invoice_id = 0;
53
+
54
+    /**
55
+     * Item discount.
56
+     *
57
+     * @var float
58
+     */
59
+    public $item_discount = 0;
60
+
61
+    /**
62
+     * Item tax.
63
+     *
64
+     * @var float
65
+     */
66
+    public $item_tax = 0;
67 67
 
68 68
     /*
69 69
 	|--------------------------------------------------------------------------
@@ -81,219 +81,219 @@  discard block
 block discarded – undo
81 81
     */
82 82
 
83 83
     /**
84
-	 * Get the item name.
85
-	 *
86
-	 * @since 1.0.19
87
-	 * @param  string $context View or edit context.
88
-	 * @return string
89
-	 */
90
-	public function get_name( $context = 'view' ) {
91
-		$name = parent::get_name( $context );
92
-		return $name . wpinv_get_item_suffix( $this );
93
-	}
94
-
95
-	/**
96
-	 * Get the item name without a suffix.
97
-	 *
98
-	 * @since 1.0.19
99
-	 * @param  string $context View or edit context.
100
-	 * @return string
101
-	 */
102
-	public function get_raw_name( $context = 'view' ) {
103
-		return parent::get_name( $context );
104
-	}
105
-
106
-	/**
107
-	 * Get the item description.
108
-	 *
109
-	 * @since 1.0.19
110
-	 * @param  string $context View or edit context.
111
-	 * @return string
112
-	 */
113
-	public function get_description( $context = 'view' ) {
114
-
115
-		if ( isset( $this->custom_description ) ) {
116
-			return $this->custom_description;
117
-		}
118
-
119
-		return parent::get_description( $context );
120
-	}
121
-
122
-	/**
123
-	 * Returns the sub total.
124
-	 *
125
-	 * @since 1.0.19
126
-	 * @param  string $context View or edit context.
127
-	 * @return int
128
-	 */
129
-	public function get_sub_total( $context = 'view' ) {
130
-		return $this->get_quantity( $context ) * $this->get_initial_price( $context );
131
-	}
132
-
133
-	/**
134
-	 * Returns the recurring sub total.
135
-	 *
136
-	 * @since 1.0.19
137
-	 * @param  string $context View or edit context.
138
-	 * @return int
139
-	 */
140
-	public function get_recurring_sub_total( $context = 'view' ) {
141
-		return $this->get_quantity( $context ) * $this->get_price( $context );
142
-	}
143
-
144
-	/**
145
-	 * @deprecated
146
-	 */
147
-	public function get_qantity( $context = 'view' ) {
148
-		return $this->get_quantity( $context );
149
-	}
150
-
151
-	/**
152
-	 * Get the item quantity.
153
-	 *
154
-	 * @since 1.0.19
155
-	 * @param  string $context View or edit context.
156
-	 * @return int
157
-	 */
158
-	public function get_quantity( $context = 'view' ) {
159
-		$quantity = (int) $this->quantity;
160
-
161
-		if ( empty( $quantity ) || 1 > $quantity ) {
162
-			$quantity = 1;
163
-		}
164
-
165
-		if ( 'view' == $context ) {
166
-			return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this );
167
-		}
168
-
169
-		return $quantity;
170
-
171
-	}
172
-
173
-	/**
174
-	 * Get the item meta data.
175
-	 *
176
-	 * @since 1.0.19
177
-	 * @param  string $context View or edit context.
178
-	 * @return meta
179
-	 */
180
-	public function get_item_meta( $context = 'view' ) {
181
-		$meta = $this->meta;
182
-
183
-		if ( 'view' == $context ) {
184
-			return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this );
185
-		}
186
-
187
-		return $meta;
188
-
189
-	}
190
-
191
-	/**
192
-	 * Returns whether or not customers can update the item quantity.
193
-	 *
194
-	 * @since 1.0.19
195
-	 * @param  string $context View or edit context.
196
-	 * @return bool
197
-	 */
198
-	public function get_allow_quantities( $context = 'view' ) {
199
-		$allow_quantities = (bool) $this->allow_quantities;
200
-
201
-		if ( 'view' == $context ) {
202
-			return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this );
203
-		}
204
-
205
-		return $allow_quantities;
206
-
207
-	}
208
-
209
-	/**
210
-	 * Returns whether or not the item is required.
211
-	 *
212
-	 * @since 1.0.19
213
-	 * @param  string $context View or edit context.
214
-	 * @return bool
215
-	 */
216
-	public function get_is_required( $context = 'view' ) {
217
-		$is_required = (bool) $this->is_required;
218
-
219
-		if ( 'view' == $context ) {
220
-			return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this );
221
-		}
222
-
223
-		return $is_required;
224
-
225
-	}
226
-
227
-	/**
228
-	 * Prepares form data for use.
229
-	 *
230
-	 * @since 1.0.19
231
-	 * @return array
232
-	 */
233
-	public function prepare_data_for_use() {
234
-
235
-		return array(
236
-			'title'            => sanitize_text_field( $this->get_name() ),
237
-			'id'               => $this->get_id(),
238
-			'price'            => $this->get_price(),
239
-			'recurring'        => $this->is_recurring(),
240
-			'description'      => $this->get_description(),
241
-			'allow_quantities' => $this->allows_quantities(),
242
-			'required'         => $this->is_required(),
243
-		);
244
-
245
-	}
246
-
247
-	/**
248
-	 * Prepares form data for ajax use.
249
-	 *
250
-	 * @since 1.0.19
251
-	 * @return array
252
-	 */
253
-	public function prepare_data_for_invoice_edit_ajax() {
254
-
255
-		return array(
256
-			'id'     => $this->get_id(),
257
-			'texts'  => array(
258
-				'item-name'        => sanitize_text_field( $this->get_name() ),
259
-				'item-description' => wp_kses_post( $this->get_description() ),
260
-				'item-quantity'    => absint( $this->get_quantity() ),
261
-				'item-price'       => wpinv_price( wpinv_format_amount ( $this->get_price() ) ),
262
-				'item-total'       => wpinv_price( wpinv_format_amount( $this->get_sub_total() ) ),
263
-			),
264
-			'inputs' => array(
265
-				'item-id'          => $this->get_id(),
266
-				'item-name'        => sanitize_text_field( $this->get_name() ),
267
-				'item-description' => wp_kses_post( $this->get_description() ),
268
-				'item-quantity'    => absint( $this->get_quantity() ),
269
-				'item-price'       => $this->get_price(),
270
-			)
271
-		);
272
-
273
-	}
274
-
275
-	/**
276
-	 * Prepares form data for saving (cart_details).
277
-	 *
278
-	 * @since 1.0.19
279
-	 * @return array
280
-	 */
281
-	public function prepare_data_for_saving() {
282
-
283
-		return array(
284
-			'post_id'           => $this->invoice_id,
285
-			'item_id'           => $this->get_id(),
286
-			'item_name'         => sanitize_text_field( $this->get_name() ),
287
-			'item_description'  => $this->get_description(),
288
-			'tax'               => $this->item_tax,
289
-			'item_price'        => $this->get_price(),
290
-			'quantity'          => (int) $this->get_quantity(),
291
-			'discount'          => $this->item_discount,
292
-			'subtotal'          => $this->get_sub_total(),
293
-			'price'             => $this->get_sub_total() + $this->item_tax + $this->item_discount,
294
-			'meta'              => $this->get_item_meta(),
84
+     * Get the item name.
85
+     *
86
+     * @since 1.0.19
87
+     * @param  string $context View or edit context.
88
+     * @return string
89
+     */
90
+    public function get_name( $context = 'view' ) {
91
+        $name = parent::get_name( $context );
92
+        return $name . wpinv_get_item_suffix( $this );
93
+    }
94
+
95
+    /**
96
+     * Get the item name without a suffix.
97
+     *
98
+     * @since 1.0.19
99
+     * @param  string $context View or edit context.
100
+     * @return string
101
+     */
102
+    public function get_raw_name( $context = 'view' ) {
103
+        return parent::get_name( $context );
104
+    }
105
+
106
+    /**
107
+     * Get the item description.
108
+     *
109
+     * @since 1.0.19
110
+     * @param  string $context View or edit context.
111
+     * @return string
112
+     */
113
+    public function get_description( $context = 'view' ) {
114
+
115
+        if ( isset( $this->custom_description ) ) {
116
+            return $this->custom_description;
117
+        }
118
+
119
+        return parent::get_description( $context );
120
+    }
121
+
122
+    /**
123
+     * Returns the sub total.
124
+     *
125
+     * @since 1.0.19
126
+     * @param  string $context View or edit context.
127
+     * @return int
128
+     */
129
+    public function get_sub_total( $context = 'view' ) {
130
+        return $this->get_quantity( $context ) * $this->get_initial_price( $context );
131
+    }
132
+
133
+    /**
134
+     * Returns the recurring sub total.
135
+     *
136
+     * @since 1.0.19
137
+     * @param  string $context View or edit context.
138
+     * @return int
139
+     */
140
+    public function get_recurring_sub_total( $context = 'view' ) {
141
+        return $this->get_quantity( $context ) * $this->get_price( $context );
142
+    }
143
+
144
+    /**
145
+     * @deprecated
146
+     */
147
+    public function get_qantity( $context = 'view' ) {
148
+        return $this->get_quantity( $context );
149
+    }
150
+
151
+    /**
152
+     * Get the item quantity.
153
+     *
154
+     * @since 1.0.19
155
+     * @param  string $context View or edit context.
156
+     * @return int
157
+     */
158
+    public function get_quantity( $context = 'view' ) {
159
+        $quantity = (int) $this->quantity;
160
+
161
+        if ( empty( $quantity ) || 1 > $quantity ) {
162
+            $quantity = 1;
163
+        }
164
+
165
+        if ( 'view' == $context ) {
166
+            return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this );
167
+        }
168
+
169
+        return $quantity;
170
+
171
+    }
172
+
173
+    /**
174
+     * Get the item meta data.
175
+     *
176
+     * @since 1.0.19
177
+     * @param  string $context View or edit context.
178
+     * @return meta
179
+     */
180
+    public function get_item_meta( $context = 'view' ) {
181
+        $meta = $this->meta;
182
+
183
+        if ( 'view' == $context ) {
184
+            return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this );
185
+        }
186
+
187
+        return $meta;
188
+
189
+    }
190
+
191
+    /**
192
+     * Returns whether or not customers can update the item quantity.
193
+     *
194
+     * @since 1.0.19
195
+     * @param  string $context View or edit context.
196
+     * @return bool
197
+     */
198
+    public function get_allow_quantities( $context = 'view' ) {
199
+        $allow_quantities = (bool) $this->allow_quantities;
200
+
201
+        if ( 'view' == $context ) {
202
+            return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this );
203
+        }
204
+
205
+        return $allow_quantities;
206
+
207
+    }
208
+
209
+    /**
210
+     * Returns whether or not the item is required.
211
+     *
212
+     * @since 1.0.19
213
+     * @param  string $context View or edit context.
214
+     * @return bool
215
+     */
216
+    public function get_is_required( $context = 'view' ) {
217
+        $is_required = (bool) $this->is_required;
218
+
219
+        if ( 'view' == $context ) {
220
+            return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this );
221
+        }
222
+
223
+        return $is_required;
224
+
225
+    }
226
+
227
+    /**
228
+     * Prepares form data for use.
229
+     *
230
+     * @since 1.0.19
231
+     * @return array
232
+     */
233
+    public function prepare_data_for_use() {
234
+
235
+        return array(
236
+            'title'            => sanitize_text_field( $this->get_name() ),
237
+            'id'               => $this->get_id(),
238
+            'price'            => $this->get_price(),
239
+            'recurring'        => $this->is_recurring(),
240
+            'description'      => $this->get_description(),
241
+            'allow_quantities' => $this->allows_quantities(),
242
+            'required'         => $this->is_required(),
243
+        );
244
+
245
+    }
246
+
247
+    /**
248
+     * Prepares form data for ajax use.
249
+     *
250
+     * @since 1.0.19
251
+     * @return array
252
+     */
253
+    public function prepare_data_for_invoice_edit_ajax() {
254
+
255
+        return array(
256
+            'id'     => $this->get_id(),
257
+            'texts'  => array(
258
+                'item-name'        => sanitize_text_field( $this->get_name() ),
259
+                'item-description' => wp_kses_post( $this->get_description() ),
260
+                'item-quantity'    => absint( $this->get_quantity() ),
261
+                'item-price'       => wpinv_price( wpinv_format_amount ( $this->get_price() ) ),
262
+                'item-total'       => wpinv_price( wpinv_format_amount( $this->get_sub_total() ) ),
263
+            ),
264
+            'inputs' => array(
265
+                'item-id'          => $this->get_id(),
266
+                'item-name'        => sanitize_text_field( $this->get_name() ),
267
+                'item-description' => wp_kses_post( $this->get_description() ),
268
+                'item-quantity'    => absint( $this->get_quantity() ),
269
+                'item-price'       => $this->get_price(),
270
+            )
295 271
         );
296
-	}
272
+
273
+    }
274
+
275
+    /**
276
+     * Prepares form data for saving (cart_details).
277
+     *
278
+     * @since 1.0.19
279
+     * @return array
280
+     */
281
+    public function prepare_data_for_saving() {
282
+
283
+        return array(
284
+            'post_id'           => $this->invoice_id,
285
+            'item_id'           => $this->get_id(),
286
+            'item_name'         => sanitize_text_field( $this->get_name() ),
287
+            'item_description'  => $this->get_description(),
288
+            'tax'               => $this->item_tax,
289
+            'item_price'        => $this->get_price(),
290
+            'quantity'          => (int) $this->get_quantity(),
291
+            'discount'          => $this->item_discount,
292
+            'subtotal'          => $this->get_sub_total(),
293
+            'price'             => $this->get_sub_total() + $this->item_tax + $this->item_discount,
294
+            'meta'              => $this->get_item_meta(),
295
+        );
296
+    }
297 297
 
298 298
     /*
299 299
 	|--------------------------------------------------------------------------
@@ -305,70 +305,70 @@  discard block
 block discarded – undo
305 305
 	| object.
306 306
     */
307 307
 
308
-	/**
309
-	 * Set the item qantity.
310
-	 *
311
-	 * @since 1.0.19
312
-	 * @param  int $quantity The item quantity.
313
-	 */
314
-	public function set_quantity( $quantity ) {
315
-
316
-		if ( empty( $quantity ) || ! is_numeric( $quantity ) ) {
317
-			$quantity = 1;
318
-		}
319
-
320
-		$this->quantity = (int) $quantity;
321
-
322
-	}
323
-
324
-	/**
325
-	 * Set the item meta data.
326
-	 *
327
-	 * @since 1.0.19
328
-	 * @param  array $meta The item meta data.
329
-	 */
330
-	public function set_item_meta( $meta ) {
331
-		$this->meta = maybe_unserialize( $meta );
332
-	}
333
-
334
-	/**
335
-	 * Set whether or not the quantities are allowed.
336
-	 *
337
-	 * @since 1.0.19
338
-	 * @param  bool $allow_quantities
339
-	 */
340
-	public function set_allow_quantities( $allow_quantities ) {
341
-		$this->allow_quantities = (bool) $allow_quantities;
342
-	}
343
-
344
-	/**
345
-	 * Set whether or not the item is required.
346
-	 *
347
-	 * @since 1.0.19
348
-	 * @param  bool $is_required
349
-	 */
350
-	public function set_is_required( $is_required ) {
351
-		$this->is_required = (bool) $is_required;
352
-	}
353
-
354
-	/**
355
-	 * Sets the custom item description.
356
-	 *
357
-	 * @since 1.0.19
358
-	 * @param  string $description
359
-	 */
360
-	public function set_custom_description( $description ) {
361
-		$this->custom_description = $description;
362
-	}
308
+    /**
309
+     * Set the item qantity.
310
+     *
311
+     * @since 1.0.19
312
+     * @param  int $quantity The item quantity.
313
+     */
314
+    public function set_quantity( $quantity ) {
315
+
316
+        if ( empty( $quantity ) || ! is_numeric( $quantity ) ) {
317
+            $quantity = 1;
318
+        }
319
+
320
+        $this->quantity = (int) $quantity;
321
+
322
+    }
323
+
324
+    /**
325
+     * Set the item meta data.
326
+     *
327
+     * @since 1.0.19
328
+     * @param  array $meta The item meta data.
329
+     */
330
+    public function set_item_meta( $meta ) {
331
+        $this->meta = maybe_unserialize( $meta );
332
+    }
333
+
334
+    /**
335
+     * Set whether or not the quantities are allowed.
336
+     *
337
+     * @since 1.0.19
338
+     * @param  bool $allow_quantities
339
+     */
340
+    public function set_allow_quantities( $allow_quantities ) {
341
+        $this->allow_quantities = (bool) $allow_quantities;
342
+    }
343
+
344
+    /**
345
+     * Set whether or not the item is required.
346
+     *
347
+     * @since 1.0.19
348
+     * @param  bool $is_required
349
+     */
350
+    public function set_is_required( $is_required ) {
351
+        $this->is_required = (bool) $is_required;
352
+    }
353
+
354
+    /**
355
+     * Sets the custom item description.
356
+     *
357
+     * @since 1.0.19
358
+     * @param  string $description
359
+     */
360
+    public function set_custom_description( $description ) {
361
+        $this->custom_description = $description;
362
+    }
363 363
 
364 364
     /**
365 365
      * We do not want to save items to the database.
366 366
      * 
367
-	 * @return int item id
367
+     * @return int item id
368 368
      */
369 369
     public function save( $data = array() ) {
370 370
         return $this->get_id();
371
-	}
371
+    }
372 372
 
373 373
     /*
374 374
 	|--------------------------------------------------------------------------
@@ -380,23 +380,23 @@  discard block
 block discarded – undo
380 380
 	*/
381 381
 
382 382
     /**
383
-	 * Checks whether the item has enabled dynamic pricing.
384
-	 *
385
-	 * @since 1.0.19
386
-	 * @return bool
387
-	 */
388
-	public function is_required() {
383
+     * Checks whether the item has enabled dynamic pricing.
384
+     *
385
+     * @since 1.0.19
386
+     * @return bool
387
+     */
388
+    public function is_required() {
389 389
         return (bool) $this->get_is_required();
390
-	}
391
-
392
-	/**
393
-	 * Checks whether users can edit the quantities.
394
-	 *
395
-	 * @since 1.0.19
396
-	 * @return bool
397
-	 */
398
-	public function allows_quantities() {
390
+    }
391
+
392
+    /**
393
+     * Checks whether users can edit the quantities.
394
+     *
395
+     * @since 1.0.19
396
+     * @return bool
397
+     */
398
+    public function allows_quantities() {
399 399
         return (bool) $this->get_allow_quantities();
400
-	}
400
+    }
401 401
 
402 402
 }
Please login to merge, or discard this patch.
includes/class-wpinv-invoice.php 1 patch
Indentation   +2108 added lines, -2108 removed lines patch added patch discarded remove patch
@@ -14,30 +14,30 @@  discard block
 block discarded – undo
14 14
 class WPInv_Invoice extends GetPaid_Data {
15 15
 
16 16
     /**
17
-	 * Which data store to load.
18
-	 *
19
-	 * @var string
20
-	 */
17
+     * Which data store to load.
18
+     *
19
+     * @var string
20
+     */
21 21
     protected $data_store_name = 'invoice';
22 22
 
23 23
     /**
24
-	 * This is the name of this object type.
25
-	 *
26
-	 * @var string
27
-	 */
24
+     * This is the name of this object type.
25
+     *
26
+     * @var string
27
+     */
28 28
     protected $object_type = 'invoice';
29 29
 
30 30
     /**
31
-	 * Item Data array. This is the core item data exposed in APIs.
32
-	 *
33
-	 * @since 1.0.19
34
-	 * @var array
35
-	 */
36
-	protected $data = array(
37
-		'parent_id'            => 0,
38
-		'status'               => 'wpi-pending',
39
-		'version'              => '',
40
-		'date_created'         => null,
31
+     * Item Data array. This is the core item data exposed in APIs.
32
+     *
33
+     * @since 1.0.19
34
+     * @var array
35
+     */
36
+    protected $data = array(
37
+        'parent_id'            => 0,
38
+        'status'               => 'wpi-pending',
39
+        'version'              => '',
40
+        'date_created'         => null,
41 41
         'date_modified'        => null,
42 42
         'due_date'             => null,
43 43
         'completed_date'       => null,
@@ -79,20 +79,20 @@  discard block
 block discarded – undo
79 79
         'transaction_id'       => '',
80 80
         'currency'             => '',
81 81
         'disable_taxes'        => false,
82
-		'subscription_id'      => null,
83
-		'is_viewed'            => false,
84
-		'email_cc'             => '',
85
-		'template'             => 'quantity', // hours, amount only
82
+        'subscription_id'      => null,
83
+        'is_viewed'            => false,
84
+        'email_cc'             => '',
85
+        'template'             => 'quantity', // hours, amount only
86 86
     );
87 87
 
88 88
     /**
89
-	 * Stores meta in cache for future reads.
90
-	 *
91
-	 * A group must be set to to enable caching.
92
-	 *
93
-	 * @var string
94
-	 */
95
-	protected $cache_group = 'getpaid_invoices';
89
+     * Stores meta in cache for future reads.
90
+     *
91
+     * A group must be set to to enable caching.
92
+     *
93
+     * @var string
94
+     */
95
+    protected $cache_group = 'getpaid_invoices';
96 96
 
97 97
     /**
98 98
      * Stores a reference to the original WP_Post object
@@ -106,104 +106,104 @@  discard block
 block discarded – undo
106 106
      *
107 107
      * @var int
108 108
      */
109
-	protected $recurring_item = null;
109
+    protected $recurring_item = null;
110 110
 
111
-	/**
111
+    /**
112 112
      * Stores an array of item totals.
113
-	 *
114
-	 * e.g $totals['discount'] = array(
115
-	 * 		'initial'   => 10,
116
-	 * 		'recurring' => 10,
117
-	 * )
113
+     *
114
+     * e.g $totals['discount'] = array(
115
+     * 		'initial'   => 10,
116
+     * 		'recurring' => 10,
117
+     * )
118 118
      *
119 119
      * @var array
120 120
      */
121
-	protected $totals = array();
121
+    protected $totals = array();
122 122
 
123
-	/**
124
-	 * Stores the status transition information.
125
-	 *
126
-	 * @since 1.0.19
127
-	 * @var bool
128
-	 */
129
-	protected $status_transition = false;
123
+    /**
124
+     * Stores the status transition information.
125
+     *
126
+     * @since 1.0.19
127
+     * @var bool
128
+     */
129
+    protected $status_transition = false;
130 130
 
131 131
     /**
132
-	 * Get the invoice if ID is passed, otherwise the invoice is new and empty.
133
-	 *
134
-	 * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
135
-	 */
132
+     * Get the invoice if ID is passed, otherwise the invoice is new and empty.
133
+     *
134
+     * @param  int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object to read.
135
+     */
136 136
     public function __construct( $invoice = false ) {
137 137
 
138 138
         parent::__construct( $invoice );
139 139
 
140
-		if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
141
-			$this->set_id( $invoice );
142
-		} elseif ( $invoice instanceof self ) {
143
-			$this->set_id( $invoice->get_id() );
144
-		} elseif ( ! empty( $invoice->ID ) ) {
145
-			$this->set_id( $invoice->ID );
146
-		} elseif ( is_array( $invoice ) ) {
147
-			$this->set_props( $invoice );
148
-
149
-			if ( isset( $invoice['ID'] ) ) {
150
-				$this->set_id( $invoice['ID'] );
151
-			}
152
-
153
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
154
-			$this->set_id( $invoice_id );
155
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
156
-			$this->set_id( $invoice_id );
157
-		} elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
158
-			$this->set_id( $invoice_id );
159
-		}else {
160
-			$this->set_object_read( true );
161
-		}
140
+        if ( ! empty( $invoice ) && is_numeric( $invoice ) && getpaid_is_invoice_post_type( get_post_type( $invoice ) ) ) {
141
+            $this->set_id( $invoice );
142
+        } elseif ( $invoice instanceof self ) {
143
+            $this->set_id( $invoice->get_id() );
144
+        } elseif ( ! empty( $invoice->ID ) ) {
145
+            $this->set_id( $invoice->ID );
146
+        } elseif ( is_array( $invoice ) ) {
147
+            $this->set_props( $invoice );
148
+
149
+            if ( isset( $invoice['ID'] ) ) {
150
+                $this->set_id( $invoice['ID'] );
151
+            }
152
+
153
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'key' ) ) {
154
+            $this->set_id( $invoice_id );
155
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'number' ) ) {
156
+            $this->set_id( $invoice_id );
157
+        } elseif ( is_scalar( $invoice ) && $invoice_id = self::get_invoice_id_by_field( $invoice, 'transaction_id' ) ) {
158
+            $this->set_id( $invoice_id );
159
+        }else {
160
+            $this->set_object_read( true );
161
+        }
162 162
 
163 163
         // Load the datastore.
164
-		$this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
164
+        $this->data_store = GetPaid_Data_Store::load( $this->data_store_name );
165 165
 
166
-		if ( $this->get_id() > 0 ) {
166
+        if ( $this->get_id() > 0 ) {
167 167
             $this->post = get_post( $this->get_id() );
168 168
             $this->ID   = $this->get_id();
169
-			$this->data_store->read( $this );
169
+            $this->data_store->read( $this );
170 170
         }
171 171
 
172 172
     }
173 173
 
174 174
     /**
175
-	 * Given an invoice key/number, it returns its id.
176
-	 *
177
-	 *
178
-	 * @static
179
-	 * @param string $value The invoice key or number
180
-	 * @param string $field Either key, transaction_id or number.
181
-	 * @since 1.0.15
182
-	 * @return int
183
-	 */
184
-	public static function get_invoice_id_by_field( $value, $field = 'key' ) {
175
+     * Given an invoice key/number, it returns its id.
176
+     *
177
+     *
178
+     * @static
179
+     * @param string $value The invoice key or number
180
+     * @param string $field Either key, transaction_id or number.
181
+     * @since 1.0.15
182
+     * @return int
183
+     */
184
+    public static function get_invoice_id_by_field( $value, $field = 'key' ) {
185 185
         global $wpdb;
186 186
 
187
-		// Trim the value.
188
-		$value = trim( $value );
187
+        // Trim the value.
188
+        $value = trim( $value );
189 189
 
190
-		if ( empty( $value ) ) {
191
-			return 0;
192
-		}
190
+        if ( empty( $value ) ) {
191
+            return 0;
192
+        }
193 193
 
194 194
         // Valid fields.
195 195
         $fields = array( 'key', 'number', 'transaction_id' );
196 196
 
197
-		// Ensure a field has been passed.
198
-		if ( empty( $field ) || ! in_array( $field, $fields ) ) {
199
-			return 0;
200
-		}
197
+        // Ensure a field has been passed.
198
+        if ( empty( $field ) || ! in_array( $field, $fields ) ) {
199
+            return 0;
200
+        }
201 201
 
202
-		// Maybe retrieve from the cache.
203
-		$invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
204
-		if ( ! empty( $invoice_id ) ) {
205
-			return $invoice_id;
206
-		}
202
+        // Maybe retrieve from the cache.
203
+        $invoice_id   = wp_cache_get( $value, "getpaid_invoice_{$field}s_to_invoice_ids" );
204
+        if ( ! empty( $invoice_id ) ) {
205
+            return $invoice_id;
206
+        }
207 207
 
208 208
         // Fetch from the db.
209 209
         $table       = $wpdb->prefix . 'getpaid_invoices';
@@ -211,14 +211,14 @@  discard block
 block discarded – undo
211 211
             $wpdb->prepare( "SELECT `post_id` FROM $table WHERE `$field`=%s LIMIT 1", $value )
212 212
         );
213 213
 
214
-		if ( empty( $invoice_id ) ) {
215
-			return 0;
216
-		}
214
+        if ( empty( $invoice_id ) ) {
215
+            return 0;
216
+        }
217 217
 
218
-		// Update the cache with our data
219
-		wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
218
+        // Update the cache with our data
219
+        wp_cache_set( $value, $invoice_id, "getpaid_invoice_{$field}s_to_invoice_ids" );
220 220
 
221
-		return $invoice_id;
221
+        return $invoice_id;
222 222
     }
223 223
 
224 224
     /**
@@ -244,73 +244,73 @@  discard block
 block discarded – undo
244 244
     */
245 245
 
246 246
     /**
247
-	 * Get parent invoice ID.
248
-	 *
249
-	 * @since 1.0.19
250
-	 * @param  string $context View or edit context.
251
-	 * @return int
252
-	 */
253
-	public function get_parent_id( $context = 'view' ) {
254
-		return (int) $this->get_prop( 'parent_id', $context );
247
+     * Get parent invoice ID.
248
+     *
249
+     * @since 1.0.19
250
+     * @param  string $context View or edit context.
251
+     * @return int
252
+     */
253
+    public function get_parent_id( $context = 'view' ) {
254
+        return (int) $this->get_prop( 'parent_id', $context );
255 255
     }
256 256
 
257 257
     /**
258
-	 * Get parent invoice.
259
-	 *
260
-	 * @since 1.0.19
261
-	 * @return WPInv_Invoice
262
-	 */
258
+     * Get parent invoice.
259
+     *
260
+     * @since 1.0.19
261
+     * @return WPInv_Invoice
262
+     */
263 263
     public function get_parent_payment() {
264 264
         return new WPInv_Invoice( $this->get_parent_id() );
265 265
     }
266 266
 
267 267
     /**
268
-	 * Alias for self::get_parent_payment().
269
-	 *
270
-	 * @since 1.0.19
271
-	 * @return WPInv_Invoice
272
-	 */
268
+     * Alias for self::get_parent_payment().
269
+     *
270
+     * @since 1.0.19
271
+     * @return WPInv_Invoice
272
+     */
273 273
     public function get_parent() {
274 274
         return $this->get_parent_payment();
275 275
     }
276 276
 
277 277
     /**
278
-	 * Get invoice status.
279
-	 *
280
-	 * @since 1.0.19
281
-	 * @param  string $context View or edit context.
282
-	 * @return string
283
-	 */
284
-	public function get_status( $context = 'view' ) {
285
-		return $this->get_prop( 'status', $context );
286
-	}
278
+     * Get invoice status.
279
+     *
280
+     * @since 1.0.19
281
+     * @param  string $context View or edit context.
282
+     * @return string
283
+     */
284
+    public function get_status( $context = 'view' ) {
285
+        return $this->get_prop( 'status', $context );
286
+    }
287 287
 	
288
-	/**
289
-	 * Retrieves an array of possible invoice statuses.
290
-	 *
291
-	 * @since 1.0.19
292
-	 * @return array
293
-	 */
294
-	public function get_all_statuses() {
288
+    /**
289
+     * Retrieves an array of possible invoice statuses.
290
+     *
291
+     * @since 1.0.19
292
+     * @return array
293
+     */
294
+    public function get_all_statuses() {
295 295
 		
296
-		$statuses = wpinv_get_invoice_statuses( true, true, $this );
296
+        $statuses = wpinv_get_invoice_statuses( true, true, $this );
297 297
 
298
-		// For backwards compatibility.
299
-		if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
298
+        // For backwards compatibility.
299
+        if ( $this->is_quote() && class_exists( 'Wpinv_Quotes_Shared' ) ) {
300 300
             $statuses = Wpinv_Quotes_Shared::wpinv_get_quote_statuses();
301
-		}
301
+        }
302 302
 
303
-		return $statuses;
303
+        return $statuses;
304 304
     }
305 305
 
306 306
     /**
307
-	 * Get invoice status nice name.
308
-	 *
309
-	 * @since 1.0.19
310
-	 * @return string
311
-	 */
307
+     * Get invoice status nice name.
308
+     *
309
+     * @since 1.0.19
310
+     * @return string
311
+     */
312 312
     public function get_status_nicename() {
313
-		$statuses = $this->get_all_statuses();
313
+        $statuses = $this->get_all_statuses();
314 314
 
315 315
         $status = isset( $statuses[ $this->get_status() ] ) ? $statuses[ $this->get_status() ] : $this->get_status();
316 316
 
@@ -318,20 +318,20 @@  discard block
 block discarded – undo
318 318
     }
319 319
 
320 320
     /**
321
-	 * Get plugin version when the invoice was created.
322
-	 *
323
-	 * @since 1.0.19
324
-	 * @param  string $context View or edit context.
325
-	 * @return string
326
-	 */
327
-	public function get_version( $context = 'view' ) {
328
-		return $this->get_prop( 'version', $context );
329
-	}
321
+     * Get plugin version when the invoice was created.
322
+     *
323
+     * @since 1.0.19
324
+     * @param  string $context View or edit context.
325
+     * @return string
326
+     */
327
+    public function get_version( $context = 'view' ) {
328
+        return $this->get_prop( 'version', $context );
329
+    }
330 330
 
331
-	/**
332
-	 * @deprecated
333
-	 */
334
-	public function get_invoice_date( $formatted = true ) {
331
+    /**
332
+     * @deprecated
333
+     */
334
+    public function get_invoice_date( $formatted = true ) {
335 335
         $date_completed = $this->get_date_completed();
336 336
         $invoice_date   = $date_completed != '0000-00-00 00:00:00' ? $date_completed : '';
337 337
 
@@ -348,187 +348,187 @@  discard block
 block discarded – undo
348 348
     }
349 349
 
350 350
     /**
351
-	 * Get date when the invoice was created.
352
-	 *
353
-	 * @since 1.0.19
354
-	 * @param  string $context View or edit context.
355
-	 * @return string
356
-	 */
357
-	public function get_date_created( $context = 'view' ) {
358
-		return $this->get_prop( 'date_created', $context );
359
-	}
351
+     * Get date when the invoice was created.
352
+     *
353
+     * @since 1.0.19
354
+     * @param  string $context View or edit context.
355
+     * @return string
356
+     */
357
+    public function get_date_created( $context = 'view' ) {
358
+        return $this->get_prop( 'date_created', $context );
359
+    }
360 360
 	
361
-	/**
362
-	 * Alias for self::get_date_created().
363
-	 *
364
-	 * @since 1.0.19
365
-	 * @param  string $context View or edit context.
366
-	 * @return string
367
-	 */
368
-	public function get_created_date( $context = 'view' ) {
369
-		return $this->get_date_created( $context );
370
-    }
371
-
372
-    /**
373
-	 * Get GMT date when the invoice was created.
374
-	 *
375
-	 * @since 1.0.19
376
-	 * @param  string $context View or edit context.
377
-	 * @return string
378
-	 */
379
-	public function get_date_created_gmt( $context = 'view' ) {
361
+    /**
362
+     * Alias for self::get_date_created().
363
+     *
364
+     * @since 1.0.19
365
+     * @param  string $context View or edit context.
366
+     * @return string
367
+     */
368
+    public function get_created_date( $context = 'view' ) {
369
+        return $this->get_date_created( $context );
370
+    }
371
+
372
+    /**
373
+     * Get GMT date when the invoice was created.
374
+     *
375
+     * @since 1.0.19
376
+     * @param  string $context View or edit context.
377
+     * @return string
378
+     */
379
+    public function get_date_created_gmt( $context = 'view' ) {
380 380
         $date = $this->get_date_created( $context );
381 381
 
382 382
         if ( $date ) {
383 383
             $date = get_gmt_from_date( $date );
384 384
         }
385
-		return $date;
385
+        return $date;
386 386
     }
387 387
 
388 388
     /**
389
-	 * Get date when the invoice was last modified.
390
-	 *
391
-	 * @since 1.0.19
392
-	 * @param  string $context View or edit context.
393
-	 * @return string
394
-	 */
395
-	public function get_date_modified( $context = 'view' ) {
396
-		return $this->get_prop( 'date_modified', $context );
397
-	}
389
+     * Get date when the invoice was last modified.
390
+     *
391
+     * @since 1.0.19
392
+     * @param  string $context View or edit context.
393
+     * @return string
394
+     */
395
+    public function get_date_modified( $context = 'view' ) {
396
+        return $this->get_prop( 'date_modified', $context );
397
+    }
398 398
 
399
-	/**
400
-	 * Alias for self::get_date_modified().
401
-	 *
402
-	 * @since 1.0.19
403
-	 * @param  string $context View or edit context.
404
-	 * @return string
405
-	 */
406
-	public function get_modified_date( $context = 'view' ) {
407
-		return $this->get_date_modified( $context );
399
+    /**
400
+     * Alias for self::get_date_modified().
401
+     *
402
+     * @since 1.0.19
403
+     * @param  string $context View or edit context.
404
+     * @return string
405
+     */
406
+    public function get_modified_date( $context = 'view' ) {
407
+        return $this->get_date_modified( $context );
408 408
     }
409 409
 
410 410
     /**
411
-	 * Get GMT date when the invoice was last modified.
412
-	 *
413
-	 * @since 1.0.19
414
-	 * @param  string $context View or edit context.
415
-	 * @return string
416
-	 */
417
-	public function get_date_modified_gmt( $context = 'view' ) {
411
+     * Get GMT date when the invoice was last modified.
412
+     *
413
+     * @since 1.0.19
414
+     * @param  string $context View or edit context.
415
+     * @return string
416
+     */
417
+    public function get_date_modified_gmt( $context = 'view' ) {
418 418
         $date = $this->get_date_modified( $context );
419 419
 
420 420
         if ( $date ) {
421 421
             $date = get_gmt_from_date( $date );
422 422
         }
423
-		return $date;
423
+        return $date;
424 424
     }
425 425
 
426 426
     /**
427
-	 * Get the invoice due date.
428
-	 *
429
-	 * @since 1.0.19
430
-	 * @param  string $context View or edit context.
431
-	 * @return string
432
-	 */
433
-	public function get_due_date( $context = 'view' ) {
434
-		return $this->get_prop( 'due_date', $context );
427
+     * Get the invoice due date.
428
+     *
429
+     * @since 1.0.19
430
+     * @param  string $context View or edit context.
431
+     * @return string
432
+     */
433
+    public function get_due_date( $context = 'view' ) {
434
+        return $this->get_prop( 'due_date', $context );
435 435
     }
436 436
 
437 437
     /**
438
-	 * Alias for self::get_due_date().
439
-	 *
440
-	 * @since 1.0.19
441
-	 * @param  string $context View or edit context.
442
-	 * @return string
443
-	 */
444
-	public function get_date_due( $context = 'view' ) {
445
-		return $this->get_due_date( $context );
438
+     * Alias for self::get_due_date().
439
+     *
440
+     * @since 1.0.19
441
+     * @param  string $context View or edit context.
442
+     * @return string
443
+     */
444
+    public function get_date_due( $context = 'view' ) {
445
+        return $this->get_due_date( $context );
446 446
     }
447 447
 
448 448
     /**
449
-	 * Get the invoice GMT due date.
450
-	 *
451
-	 * @since 1.0.19
452
-	 * @param  string $context View or edit context.
453
-	 * @return string
454
-	 */
455
-	public function get_due_date_gmt( $context = 'view' ) {
449
+     * Get the invoice GMT due date.
450
+     *
451
+     * @since 1.0.19
452
+     * @param  string $context View or edit context.
453
+     * @return string
454
+     */
455
+    public function get_due_date_gmt( $context = 'view' ) {
456 456
         $date = $this->get_due_date( $context );
457 457
 
458 458
         if ( $date ) {
459 459
             $date = get_gmt_from_date( $date );
460 460
         }
461
-		return $date;
461
+        return $date;
462 462
     }
463 463
 
464 464
     /**
465
-	 * Alias for self::get_due_date_gmt().
466
-	 *
467
-	 * @since 1.0.19
468
-	 * @param  string $context View or edit context.
469
-	 * @return string
470
-	 */
471
-	public function get_gmt_date_due( $context = 'view' ) {
472
-		return $this->get_due_date_gmt( $context );
465
+     * Alias for self::get_due_date_gmt().
466
+     *
467
+     * @since 1.0.19
468
+     * @param  string $context View or edit context.
469
+     * @return string
470
+     */
471
+    public function get_gmt_date_due( $context = 'view' ) {
472
+        return $this->get_due_date_gmt( $context );
473 473
     }
474 474
 
475 475
     /**
476
-	 * Get date when the invoice was completed.
477
-	 *
478
-	 * @since 1.0.19
479
-	 * @param  string $context View or edit context.
480
-	 * @return string
481
-	 */
482
-	public function get_completed_date( $context = 'view' ) {
483
-		return $this->get_prop( 'completed_date', $context );
476
+     * Get date when the invoice was completed.
477
+     *
478
+     * @since 1.0.19
479
+     * @param  string $context View or edit context.
480
+     * @return string
481
+     */
482
+    public function get_completed_date( $context = 'view' ) {
483
+        return $this->get_prop( 'completed_date', $context );
484 484
     }
485 485
 
486 486
     /**
487
-	 * Alias for self::get_completed_date().
488
-	 *
489
-	 * @since 1.0.19
490
-	 * @param  string $context View or edit context.
491
-	 * @return string
492
-	 */
493
-	public function get_date_completed( $context = 'view' ) {
494
-		return $this->get_completed_date( $context );
487
+     * Alias for self::get_completed_date().
488
+     *
489
+     * @since 1.0.19
490
+     * @param  string $context View or edit context.
491
+     * @return string
492
+     */
493
+    public function get_date_completed( $context = 'view' ) {
494
+        return $this->get_completed_date( $context );
495 495
     }
496 496
 
497 497
     /**
498
-	 * Get GMT date when the invoice was was completed.
499
-	 *
500
-	 * @since 1.0.19
501
-	 * @param  string $context View or edit context.
502
-	 * @return string
503
-	 */
504
-	public function get_completed_date_gmt( $context = 'view' ) {
498
+     * Get GMT date when the invoice was was completed.
499
+     *
500
+     * @since 1.0.19
501
+     * @param  string $context View or edit context.
502
+     * @return string
503
+     */
504
+    public function get_completed_date_gmt( $context = 'view' ) {
505 505
         $date = $this->get_completed_date( $context );
506 506
 
507 507
         if ( $date ) {
508 508
             $date = get_gmt_from_date( $date );
509 509
         }
510
-		return $date;
510
+        return $date;
511 511
     }
512 512
 
513 513
     /**
514
-	 * Alias for self::get_completed_date_gmt().
515
-	 *
516
-	 * @since 1.0.19
517
-	 * @param  string $context View or edit context.
518
-	 * @return string
519
-	 */
520
-	public function get_gmt_completed_date( $context = 'view' ) {
521
-		return $this->get_completed_date_gmt( $context );
514
+     * Alias for self::get_completed_date_gmt().
515
+     *
516
+     * @since 1.0.19
517
+     * @param  string $context View or edit context.
518
+     * @return string
519
+     */
520
+    public function get_gmt_completed_date( $context = 'view' ) {
521
+        return $this->get_completed_date_gmt( $context );
522 522
     }
523 523
 
524 524
     /**
525
-	 * Get the invoice number.
526
-	 *
527
-	 * @since 1.0.19
528
-	 * @param  string $context View or edit context.
529
-	 * @return string
530
-	 */
531
-	public function get_number( $context = 'view' ) {
525
+     * Get the invoice number.
526
+     *
527
+     * @since 1.0.19
528
+     * @param  string $context View or edit context.
529
+     * @return string
530
+     */
531
+    public function get_number( $context = 'view' ) {
532 532
         $number = $this->get_prop( 'number', $context );
533 533
 
534 534
         if ( empty( $number ) ) {
@@ -536,17 +536,17 @@  discard block
 block discarded – undo
536 536
             $this->set_number( $number );
537 537
         }
538 538
 
539
-		return $number;
539
+        return $number;
540 540
     }
541 541
 
542 542
     /**
543
-	 * Get the invoice key.
544
-	 *
545
-	 * @since 1.0.19
546
-	 * @param  string $context View or edit context.
547
-	 * @return string
548
-	 */
549
-	public function get_key( $context = 'view' ) {
543
+     * Get the invoice key.
544
+     *
545
+     * @since 1.0.19
546
+     * @param  string $context View or edit context.
547
+     * @return string
548
+     */
549
+    public function get_key( $context = 'view' ) {
550 550
         $key = $this->get_prop( 'key', $context );
551 551
 
552 552
         if ( empty( $key ) ) {
@@ -554,24 +554,24 @@  discard block
 block discarded – undo
554 554
             $this->set_key( $key );
555 555
         }
556 556
 
557
-		return $key;
557
+        return $key;
558 558
     }
559 559
 
560 560
     /**
561
-	 * Get the invoice type.
562
-	 *
563
-	 * @since 1.0.19
564
-	 * @param  string $context View or edit context.
565
-	 * @return string
566
-	 */
567
-	public function get_type( $context = 'view' ) {
561
+     * Get the invoice type.
562
+     *
563
+     * @since 1.0.19
564
+     * @param  string $context View or edit context.
565
+     * @return string
566
+     */
567
+    public function get_type( $context = 'view' ) {
568 568
         return $this->get_prop( 'type', $context );
569
-	}
569
+    }
570 570
 
571
-	/**
572
-	 * @deprecated
573
-	 */
574
-	public function get_invoice_quote_type( $post_id ) {
571
+    /**
572
+     * @deprecated
573
+     */
574
+    public function get_invoice_quote_type( $post_id ) {
575 575
         if ( empty( $post_id ) ) {
576 576
             return '';
577 577
         }
@@ -588,35 +588,35 @@  discard block
 block discarded – undo
588 588
     }
589 589
 
590 590
     /**
591
-	 * Get the invoice post type.
592
-	 *
593
-	 * @since 1.0.19
594
-	 * @param  string $context View or edit context.
595
-	 * @return string
596
-	 */
597
-	public function get_post_type( $context = 'view' ) {
591
+     * Get the invoice post type.
592
+     *
593
+     * @since 1.0.19
594
+     * @param  string $context View or edit context.
595
+     * @return string
596
+     */
597
+    public function get_post_type( $context = 'view' ) {
598 598
         return $this->get_prop( 'post_type', $context );
599 599
     }
600 600
 
601 601
     /**
602
-	 * Get the invoice mode.
603
-	 *
604
-	 * @since 1.0.19
605
-	 * @param  string $context View or edit context.
606
-	 * @return string
607
-	 */
608
-	public function get_mode( $context = 'view' ) {
602
+     * Get the invoice mode.
603
+     *
604
+     * @since 1.0.19
605
+     * @param  string $context View or edit context.
606
+     * @return string
607
+     */
608
+    public function get_mode( $context = 'view' ) {
609 609
         return $this->get_prop( 'mode', $context );
610 610
     }
611 611
 
612 612
     /**
613
-	 * Get the invoice path.
614
-	 *
615
-	 * @since 1.0.19
616
-	 * @param  string $context View or edit context.
617
-	 * @return string
618
-	 */
619
-	public function get_path( $context = 'view' ) {
613
+     * Get the invoice path.
614
+     *
615
+     * @since 1.0.19
616
+     * @param  string $context View or edit context.
617
+     * @return string
618
+     */
619
+    public function get_path( $context = 'view' ) {
620 620
         $path = $this->get_prop( 'path', $context );
621 621
 
622 622
         if ( empty( $path ) ) {
@@ -624,73 +624,73 @@  discard block
 block discarded – undo
624 624
             $path   = sanitize_title( $prefix . $this->get_id() );
625 625
         }
626 626
 
627
-		return $path;
627
+        return $path;
628 628
     }
629 629
 
630 630
     /**
631
-	 * Get the invoice name/title.
632
-	 *
633
-	 * @since 1.0.19
634
-	 * @param  string $context View or edit context.
635
-	 * @return string
636
-	 */
637
-	public function get_name( $context = 'view' ) {
631
+     * Get the invoice name/title.
632
+     *
633
+     * @since 1.0.19
634
+     * @param  string $context View or edit context.
635
+     * @return string
636
+     */
637
+    public function get_name( $context = 'view' ) {
638 638
         $name = $this->get_prop( 'title', $context );
639 639
 
640
-		return empty( $name ) ? $this->get_number( $context ) : $name;
640
+        return empty( $name ) ? $this->get_number( $context ) : $name;
641 641
     }
642 642
 
643 643
     /**
644
-	 * Alias of self::get_name().
645
-	 *
646
-	 * @since 1.0.19
647
-	 * @param  string $context View or edit context.
648
-	 * @return string
649
-	 */
650
-	public function get_title( $context = 'view' ) {
651
-		return $this->get_name( $context );
644
+     * Alias of self::get_name().
645
+     *
646
+     * @since 1.0.19
647
+     * @param  string $context View or edit context.
648
+     * @return string
649
+     */
650
+    public function get_title( $context = 'view' ) {
651
+        return $this->get_name( $context );
652 652
     }
653 653
 
654 654
     /**
655
-	 * Get the invoice description.
656
-	 *
657
-	 * @since 1.0.19
658
-	 * @param  string $context View or edit context.
659
-	 * @return string
660
-	 */
661
-	public function get_description( $context = 'view' ) {
662
-		return $this->get_prop( 'description', $context );
655
+     * Get the invoice description.
656
+     *
657
+     * @since 1.0.19
658
+     * @param  string $context View or edit context.
659
+     * @return string
660
+     */
661
+    public function get_description( $context = 'view' ) {
662
+        return $this->get_prop( 'description', $context );
663 663
     }
664 664
 
665 665
     /**
666
-	 * Alias of self::get_description().
667
-	 *
668
-	 * @since 1.0.19
669
-	 * @param  string $context View or edit context.
670
-	 * @return string
671
-	 */
672
-	public function get_excerpt( $context = 'view' ) {
673
-		return $this->get_description( $context );
666
+     * Alias of self::get_description().
667
+     *
668
+     * @since 1.0.19
669
+     * @param  string $context View or edit context.
670
+     * @return string
671
+     */
672
+    public function get_excerpt( $context = 'view' ) {
673
+        return $this->get_description( $context );
674 674
     }
675 675
 
676 676
     /**
677
-	 * Alias of self::get_description().
678
-	 *
679
-	 * @since 1.0.19
680
-	 * @param  string $context View or edit context.
681
-	 * @return string
682
-	 */
683
-	public function get_summary( $context = 'view' ) {
684
-		return $this->get_description( $context );
677
+     * Alias of self::get_description().
678
+     *
679
+     * @since 1.0.19
680
+     * @param  string $context View or edit context.
681
+     * @return string
682
+     */
683
+    public function get_summary( $context = 'view' ) {
684
+        return $this->get_description( $context );
685 685
     }
686 686
 
687 687
     /**
688
-	 * Returns the user info.
689
-	 *
690
-	 * @since 1.0.19
688
+     * Returns the user info.
689
+     *
690
+     * @since 1.0.19
691 691
      * @param  string $context View or edit context.
692
-	 * @return array
693
-	 */
692
+     * @return array
693
+     */
694 694
     public function get_user_info( $context = 'view' ) {
695 695
 
696 696
         $user_info = array(
@@ -707,605 +707,605 @@  discard block
 block discarded – undo
707 707
             'company'    => $this->get_company( $context ),
708 708
             'vat_number' => $this->get_vat_number( $context ),
709 709
             'discount'   => $this->get_discount_code( $context ),
710
-		);
710
+        );
711 711
 
712
-		return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
712
+        return apply_filters( 'wpinv_user_info', $user_info, $this->get_id(), $this );
713 713
 
714 714
     }
715 715
 
716 716
     /**
717
-	 * Get the customer id.
718
-	 *
719
-	 * @since 1.0.19
720
-	 * @param  string $context View or edit context.
721
-	 * @return int
722
-	 */
723
-	public function get_author( $context = 'view' ) {
724
-		return (int) $this->get_prop( 'author', $context );
717
+     * Get the customer id.
718
+     *
719
+     * @since 1.0.19
720
+     * @param  string $context View or edit context.
721
+     * @return int
722
+     */
723
+    public function get_author( $context = 'view' ) {
724
+        return (int) $this->get_prop( 'author', $context );
725 725
     }
726 726
 
727 727
     /**
728
-	 * Alias of self::get_author().
729
-	 *
730
-	 * @since 1.0.19
731
-	 * @param  string $context View or edit context.
732
-	 * @return int
733
-	 */
734
-	public function get_user_id( $context = 'view' ) {
735
-		return $this->get_author( $context );
728
+     * Alias of self::get_author().
729
+     *
730
+     * @since 1.0.19
731
+     * @param  string $context View or edit context.
732
+     * @return int
733
+     */
734
+    public function get_user_id( $context = 'view' ) {
735
+        return $this->get_author( $context );
736 736
     }
737 737
 
738
-     /**
739
-	 * Alias of self::get_author().
740
-	 *
741
-	 * @since 1.0.19
742
-	 * @param  string $context View or edit context.
743
-	 * @return int
744
-	 */
745
-	public function get_customer_id( $context = 'view' ) {
746
-		return $this->get_author( $context );
738
+        /**
739
+         * Alias of self::get_author().
740
+         *
741
+         * @since 1.0.19
742
+         * @param  string $context View or edit context.
743
+         * @return int
744
+         */
745
+    public function get_customer_id( $context = 'view' ) {
746
+        return $this->get_author( $context );
747 747
     }
748 748
 
749 749
     /**
750
-	 * Get the customer's ip.
751
-	 *
752
-	 * @since 1.0.19
753
-	 * @param  string $context View or edit context.
754
-	 * @return string
755
-	 */
756
-	public function get_ip( $context = 'view' ) {
757
-		return $this->get_prop( 'user_ip', $context );
750
+     * Get the customer's ip.
751
+     *
752
+     * @since 1.0.19
753
+     * @param  string $context View or edit context.
754
+     * @return string
755
+     */
756
+    public function get_ip( $context = 'view' ) {
757
+        return $this->get_prop( 'user_ip', $context );
758 758
     }
759 759
 
760 760
     /**
761
-	 * Alias of self::get_ip().
762
-	 *
763
-	 * @since 1.0.19
764
-	 * @param  string $context View or edit context.
765
-	 * @return string
766
-	 */
767
-	public function get_user_ip( $context = 'view' ) {
768
-		return $this->get_ip( $context );
761
+     * Alias of self::get_ip().
762
+     *
763
+     * @since 1.0.19
764
+     * @param  string $context View or edit context.
765
+     * @return string
766
+     */
767
+    public function get_user_ip( $context = 'view' ) {
768
+        return $this->get_ip( $context );
769 769
     }
770 770
 
771
-     /**
772
-	 * Alias of self::get_ip().
773
-	 *
774
-	 * @since 1.0.19
775
-	 * @param  string $context View or edit context.
776
-	 * @return string
777
-	 */
778
-	public function get_customer_ip( $context = 'view' ) {
779
-		return $this->get_ip( $context );
771
+        /**
772
+         * Alias of self::get_ip().
773
+         *
774
+         * @since 1.0.19
775
+         * @param  string $context View or edit context.
776
+         * @return string
777
+         */
778
+    public function get_customer_ip( $context = 'view' ) {
779
+        return $this->get_ip( $context );
780 780
     }
781 781
 
782 782
     /**
783
-	 * Get the customer's first name.
784
-	 *
785
-	 * @since 1.0.19
786
-	 * @param  string $context View or edit context.
787
-	 * @return string
788
-	 */
789
-	public function get_first_name( $context = 'view' ) {
790
-		return $this->get_prop( 'first_name', $context );
783
+     * Get the customer's first name.
784
+     *
785
+     * @since 1.0.19
786
+     * @param  string $context View or edit context.
787
+     * @return string
788
+     */
789
+    public function get_first_name( $context = 'view' ) {
790
+        return $this->get_prop( 'first_name', $context );
791 791
     }
792 792
 
793 793
     /**
794
-	 * Alias of self::get_first_name().
795
-	 *
796
-	 * @since 1.0.19
797
-	 * @param  string $context View or edit context.
798
-	 * @return int
799
-	 */
800
-	public function get_user_first_name( $context = 'view' ) {
801
-		return $this->get_first_name( $context );
794
+     * Alias of self::get_first_name().
795
+     *
796
+     * @since 1.0.19
797
+     * @param  string $context View or edit context.
798
+     * @return int
799
+     */
800
+    public function get_user_first_name( $context = 'view' ) {
801
+        return $this->get_first_name( $context );
802 802
     }
803 803
 
804
-     /**
805
-	 * Alias of self::get_first_name().
806
-	 *
807
-	 * @since 1.0.19
808
-	 * @param  string $context View or edit context.
809
-	 * @return int
810
-	 */
811
-	public function get_customer_first_name( $context = 'view' ) {
812
-		return $this->get_first_name( $context );
804
+        /**
805
+         * Alias of self::get_first_name().
806
+         *
807
+         * @since 1.0.19
808
+         * @param  string $context View or edit context.
809
+         * @return int
810
+         */
811
+    public function get_customer_first_name( $context = 'view' ) {
812
+        return $this->get_first_name( $context );
813 813
     }
814 814
 
815 815
     /**
816
-	 * Get the customer's last name.
817
-	 *
818
-	 * @since 1.0.19
819
-	 * @param  string $context View or edit context.
820
-	 * @return string
821
-	 */
822
-	public function get_last_name( $context = 'view' ) {
823
-		return $this->get_prop( 'last_name', $context );
816
+     * Get the customer's last name.
817
+     *
818
+     * @since 1.0.19
819
+     * @param  string $context View or edit context.
820
+     * @return string
821
+     */
822
+    public function get_last_name( $context = 'view' ) {
823
+        return $this->get_prop( 'last_name', $context );
824 824
     }
825 825
 
826 826
     /**
827
-	 * Alias of self::get_last_name().
828
-	 *
829
-	 * @since 1.0.19
830
-	 * @param  string $context View or edit context.
831
-	 * @return int
832
-	 */
833
-	public function get_user_last_name( $context = 'view' ) {
834
-		return $this->get_last_name( $context );
827
+     * Alias of self::get_last_name().
828
+     *
829
+     * @since 1.0.19
830
+     * @param  string $context View or edit context.
831
+     * @return int
832
+     */
833
+    public function get_user_last_name( $context = 'view' ) {
834
+        return $this->get_last_name( $context );
835 835
     }
836 836
 
837 837
     /**
838
-	 * Alias of self::get_last_name().
839
-	 *
840
-	 * @since 1.0.19
841
-	 * @param  string $context View or edit context.
842
-	 * @return int
843
-	 */
844
-	public function get_customer_last_name( $context = 'view' ) {
845
-		return $this->get_last_name( $context );
838
+     * Alias of self::get_last_name().
839
+     *
840
+     * @since 1.0.19
841
+     * @param  string $context View or edit context.
842
+     * @return int
843
+     */
844
+    public function get_customer_last_name( $context = 'view' ) {
845
+        return $this->get_last_name( $context );
846 846
     }
847 847
 
848 848
     /**
849
-	 * Get the customer's full name.
850
-	 *
851
-	 * @since 1.0.19
852
-	 * @param  string $context View or edit context.
853
-	 * @return string
854
-	 */
855
-	public function get_full_name( $context = 'view' ) {
856
-		return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
849
+     * Get the customer's full name.
850
+     *
851
+     * @since 1.0.19
852
+     * @param  string $context View or edit context.
853
+     * @return string
854
+     */
855
+    public function get_full_name( $context = 'view' ) {
856
+        return trim( $this->get_first_name( $context ) . ' ' . $this->get_last_name( $context ) );
857 857
     }
858 858
 
859 859
     /**
860
-	 * Alias of self::get_full_name().
861
-	 *
862
-	 * @since 1.0.19
863
-	 * @param  string $context View or edit context.
864
-	 * @return int
865
-	 */
866
-	public function get_user_full_name( $context = 'view' ) {
867
-		return $this->get_full_name( $context );
860
+     * Alias of self::get_full_name().
861
+     *
862
+     * @since 1.0.19
863
+     * @param  string $context View or edit context.
864
+     * @return int
865
+     */
866
+    public function get_user_full_name( $context = 'view' ) {
867
+        return $this->get_full_name( $context );
868 868
     }
869 869
 
870 870
     /**
871
-	 * Alias of self::get_full_name().
872
-	 *
873
-	 * @since 1.0.19
874
-	 * @param  string $context View or edit context.
875
-	 * @return int
876
-	 */
877
-	public function get_customer_full_name( $context = 'view' ) {
878
-		return $this->get_full_name( $context );
871
+     * Alias of self::get_full_name().
872
+     *
873
+     * @since 1.0.19
874
+     * @param  string $context View or edit context.
875
+     * @return int
876
+     */
877
+    public function get_customer_full_name( $context = 'view' ) {
878
+        return $this->get_full_name( $context );
879 879
     }
880 880
 
881 881
     /**
882
-	 * Get the customer's phone number.
883
-	 *
884
-	 * @since 1.0.19
885
-	 * @param  string $context View or edit context.
886
-	 * @return string
887
-	 */
888
-	public function get_phone( $context = 'view' ) {
889
-		return $this->get_prop( 'phone', $context );
882
+     * Get the customer's phone number.
883
+     *
884
+     * @since 1.0.19
885
+     * @param  string $context View or edit context.
886
+     * @return string
887
+     */
888
+    public function get_phone( $context = 'view' ) {
889
+        return $this->get_prop( 'phone', $context );
890 890
     }
891 891
 
892 892
     /**
893
-	 * Alias of self::get_phone().
894
-	 *
895
-	 * @since 1.0.19
896
-	 * @param  string $context View or edit context.
897
-	 * @return int
898
-	 */
899
-	public function get_phone_number( $context = 'view' ) {
900
-		return $this->get_phone( $context );
893
+     * Alias of self::get_phone().
894
+     *
895
+     * @since 1.0.19
896
+     * @param  string $context View or edit context.
897
+     * @return int
898
+     */
899
+    public function get_phone_number( $context = 'view' ) {
900
+        return $this->get_phone( $context );
901 901
     }
902 902
 
903 903
     /**
904
-	 * Alias of self::get_phone().
905
-	 *
906
-	 * @since 1.0.19
907
-	 * @param  string $context View or edit context.
908
-	 * @return int
909
-	 */
910
-	public function get_user_phone( $context = 'view' ) {
911
-		return $this->get_phone( $context );
904
+     * Alias of self::get_phone().
905
+     *
906
+     * @since 1.0.19
907
+     * @param  string $context View or edit context.
908
+     * @return int
909
+     */
910
+    public function get_user_phone( $context = 'view' ) {
911
+        return $this->get_phone( $context );
912 912
     }
913 913
 
914 914
     /**
915
-	 * Alias of self::get_phone().
916
-	 *
917
-	 * @since 1.0.19
918
-	 * @param  string $context View or edit context.
919
-	 * @return int
920
-	 */
921
-	public function get_customer_phone( $context = 'view' ) {
922
-		return $this->get_phone( $context );
915
+     * Alias of self::get_phone().
916
+     *
917
+     * @since 1.0.19
918
+     * @param  string $context View or edit context.
919
+     * @return int
920
+     */
921
+    public function get_customer_phone( $context = 'view' ) {
922
+        return $this->get_phone( $context );
923 923
     }
924 924
 
925 925
     /**
926
-	 * Get the customer's email address.
927
-	 *
928
-	 * @since 1.0.19
929
-	 * @param  string $context View or edit context.
930
-	 * @return string
931
-	 */
932
-	public function get_email( $context = 'view' ) {
933
-		return $this->get_prop( 'email', $context );
926
+     * Get the customer's email address.
927
+     *
928
+     * @since 1.0.19
929
+     * @param  string $context View or edit context.
930
+     * @return string
931
+     */
932
+    public function get_email( $context = 'view' ) {
933
+        return $this->get_prop( 'email', $context );
934 934
     }
935 935
 
936 936
     /**
937
-	 * Alias of self::get_email().
938
-	 *
939
-	 * @since 1.0.19
940
-	 * @param  string $context View or edit context.
941
-	 * @return string
942
-	 */
943
-	public function get_email_address( $context = 'view' ) {
944
-		return $this->get_email( $context );
937
+     * Alias of self::get_email().
938
+     *
939
+     * @since 1.0.19
940
+     * @param  string $context View or edit context.
941
+     * @return string
942
+     */
943
+    public function get_email_address( $context = 'view' ) {
944
+        return $this->get_email( $context );
945 945
     }
946 946
 
947 947
     /**
948
-	 * Alias of self::get_email().
949
-	 *
950
-	 * @since 1.0.19
951
-	 * @param  string $context View or edit context.
952
-	 * @return int
953
-	 */
954
-	public function get_user_email( $context = 'view' ) {
955
-		return $this->get_email( $context );
948
+     * Alias of self::get_email().
949
+     *
950
+     * @since 1.0.19
951
+     * @param  string $context View or edit context.
952
+     * @return int
953
+     */
954
+    public function get_user_email( $context = 'view' ) {
955
+        return $this->get_email( $context );
956 956
     }
957 957
 
958 958
     /**
959
-	 * Alias of self::get_email().
960
-	 *
961
-	 * @since 1.0.19
962
-	 * @param  string $context View or edit context.
963
-	 * @return int
964
-	 */
965
-	public function get_customer_email( $context = 'view' ) {
966
-		return $this->get_email( $context );
959
+     * Alias of self::get_email().
960
+     *
961
+     * @since 1.0.19
962
+     * @param  string $context View or edit context.
963
+     * @return int
964
+     */
965
+    public function get_customer_email( $context = 'view' ) {
966
+        return $this->get_email( $context );
967 967
     }
968 968
 
969 969
     /**
970
-	 * Get the customer's country.
971
-	 *
972
-	 * @since 1.0.19
973
-	 * @param  string $context View or edit context.
974
-	 * @return string
975
-	 */
976
-	public function get_country( $context = 'view' ) {
977
-		$country = $this->get_prop( 'country', $context );
978
-		return empty( $country ) ? wpinv_get_default_country() : $country;
970
+     * Get the customer's country.
971
+     *
972
+     * @since 1.0.19
973
+     * @param  string $context View or edit context.
974
+     * @return string
975
+     */
976
+    public function get_country( $context = 'view' ) {
977
+        $country = $this->get_prop( 'country', $context );
978
+        return empty( $country ) ? wpinv_get_default_country() : $country;
979 979
     }
980 980
 
981 981
     /**
982
-	 * Alias of self::get_country().
983
-	 *
984
-	 * @since 1.0.19
985
-	 * @param  string $context View or edit context.
986
-	 * @return int
987
-	 */
988
-	public function get_user_country( $context = 'view' ) {
989
-		return $this->get_country( $context );
982
+     * Alias of self::get_country().
983
+     *
984
+     * @since 1.0.19
985
+     * @param  string $context View or edit context.
986
+     * @return int
987
+     */
988
+    public function get_user_country( $context = 'view' ) {
989
+        return $this->get_country( $context );
990 990
     }
991 991
 
992 992
     /**
993
-	 * Alias of self::get_country().
994
-	 *
995
-	 * @since 1.0.19
996
-	 * @param  string $context View or edit context.
997
-	 * @return int
998
-	 */
999
-	public function get_customer_country( $context = 'view' ) {
1000
-		return $this->get_country( $context );
993
+     * Alias of self::get_country().
994
+     *
995
+     * @since 1.0.19
996
+     * @param  string $context View or edit context.
997
+     * @return int
998
+     */
999
+    public function get_customer_country( $context = 'view' ) {
1000
+        return $this->get_country( $context );
1001 1001
     }
1002 1002
 
1003 1003
     /**
1004
-	 * Get the customer's state.
1005
-	 *
1006
-	 * @since 1.0.19
1007
-	 * @param  string $context View or edit context.
1008
-	 * @return string
1009
-	 */
1010
-	public function get_state( $context = 'view' ) {
1011
-		$state = $this->get_prop( 'state', $context );
1012
-		return empty( $state ) ? wpinv_get_default_state() : $state;
1004
+     * Get the customer's state.
1005
+     *
1006
+     * @since 1.0.19
1007
+     * @param  string $context View or edit context.
1008
+     * @return string
1009
+     */
1010
+    public function get_state( $context = 'view' ) {
1011
+        $state = $this->get_prop( 'state', $context );
1012
+        return empty( $state ) ? wpinv_get_default_state() : $state;
1013 1013
     }
1014 1014
 
1015 1015
     /**
1016
-	 * Alias of self::get_state().
1017
-	 *
1018
-	 * @since 1.0.19
1019
-	 * @param  string $context View or edit context.
1020
-	 * @return int
1021
-	 */
1022
-	public function get_user_state( $context = 'view' ) {
1023
-		return $this->get_state( $context );
1016
+     * Alias of self::get_state().
1017
+     *
1018
+     * @since 1.0.19
1019
+     * @param  string $context View or edit context.
1020
+     * @return int
1021
+     */
1022
+    public function get_user_state( $context = 'view' ) {
1023
+        return $this->get_state( $context );
1024 1024
     }
1025 1025
 
1026 1026
     /**
1027
-	 * Alias of self::get_state().
1028
-	 *
1029
-	 * @since 1.0.19
1030
-	 * @param  string $context View or edit context.
1031
-	 * @return int
1032
-	 */
1033
-	public function get_customer_state( $context = 'view' ) {
1034
-		return $this->get_state( $context );
1027
+     * Alias of self::get_state().
1028
+     *
1029
+     * @since 1.0.19
1030
+     * @param  string $context View or edit context.
1031
+     * @return int
1032
+     */
1033
+    public function get_customer_state( $context = 'view' ) {
1034
+        return $this->get_state( $context );
1035 1035
     }
1036 1036
 
1037 1037
     /**
1038
-	 * Get the customer's city.
1039
-	 *
1040
-	 * @since 1.0.19
1041
-	 * @param  string $context View or edit context.
1042
-	 * @return string
1043
-	 */
1044
-	public function get_city( $context = 'view' ) {
1045
-		return $this->get_prop( 'city', $context );
1038
+     * Get the customer's city.
1039
+     *
1040
+     * @since 1.0.19
1041
+     * @param  string $context View or edit context.
1042
+     * @return string
1043
+     */
1044
+    public function get_city( $context = 'view' ) {
1045
+        return $this->get_prop( 'city', $context );
1046 1046
     }
1047 1047
 
1048 1048
     /**
1049
-	 * Alias of self::get_city().
1050
-	 *
1051
-	 * @since 1.0.19
1052
-	 * @param  string $context View or edit context.
1053
-	 * @return string
1054
-	 */
1055
-	public function get_user_city( $context = 'view' ) {
1056
-		return $this->get_city( $context );
1049
+     * Alias of self::get_city().
1050
+     *
1051
+     * @since 1.0.19
1052
+     * @param  string $context View or edit context.
1053
+     * @return string
1054
+     */
1055
+    public function get_user_city( $context = 'view' ) {
1056
+        return $this->get_city( $context );
1057 1057
     }
1058 1058
 
1059 1059
     /**
1060
-	 * Alias of self::get_city().
1061
-	 *
1062
-	 * @since 1.0.19
1063
-	 * @param  string $context View or edit context.
1064
-	 * @return string
1065
-	 */
1066
-	public function get_customer_city( $context = 'view' ) {
1067
-		return $this->get_city( $context );
1060
+     * Alias of self::get_city().
1061
+     *
1062
+     * @since 1.0.19
1063
+     * @param  string $context View or edit context.
1064
+     * @return string
1065
+     */
1066
+    public function get_customer_city( $context = 'view' ) {
1067
+        return $this->get_city( $context );
1068 1068
     }
1069 1069
 
1070 1070
     /**
1071
-	 * Get the customer's zip.
1072
-	 *
1073
-	 * @since 1.0.19
1074
-	 * @param  string $context View or edit context.
1075
-	 * @return string
1076
-	 */
1077
-	public function get_zip( $context = 'view' ) {
1078
-		return $this->get_prop( 'zip', $context );
1071
+     * Get the customer's zip.
1072
+     *
1073
+     * @since 1.0.19
1074
+     * @param  string $context View or edit context.
1075
+     * @return string
1076
+     */
1077
+    public function get_zip( $context = 'view' ) {
1078
+        return $this->get_prop( 'zip', $context );
1079 1079
     }
1080 1080
 
1081 1081
     /**
1082
-	 * Alias of self::get_zip().
1083
-	 *
1084
-	 * @since 1.0.19
1085
-	 * @param  string $context View or edit context.
1086
-	 * @return string
1087
-	 */
1088
-	public function get_user_zip( $context = 'view' ) {
1089
-		return $this->get_zip( $context );
1082
+     * Alias of self::get_zip().
1083
+     *
1084
+     * @since 1.0.19
1085
+     * @param  string $context View or edit context.
1086
+     * @return string
1087
+     */
1088
+    public function get_user_zip( $context = 'view' ) {
1089
+        return $this->get_zip( $context );
1090 1090
     }
1091 1091
 
1092 1092
     /**
1093
-	 * Alias of self::get_zip().
1094
-	 *
1095
-	 * @since 1.0.19
1096
-	 * @param  string $context View or edit context.
1097
-	 * @return string
1098
-	 */
1099
-	public function get_customer_zip( $context = 'view' ) {
1100
-		return $this->get_zip( $context );
1093
+     * Alias of self::get_zip().
1094
+     *
1095
+     * @since 1.0.19
1096
+     * @param  string $context View or edit context.
1097
+     * @return string
1098
+     */
1099
+    public function get_customer_zip( $context = 'view' ) {
1100
+        return $this->get_zip( $context );
1101 1101
     }
1102 1102
 
1103 1103
     /**
1104
-	 * Get the customer's company.
1105
-	 *
1106
-	 * @since 1.0.19
1107
-	 * @param  string $context View or edit context.
1108
-	 * @return string
1109
-	 */
1110
-	public function get_company( $context = 'view' ) {
1111
-		return $this->get_prop( 'company', $context );
1104
+     * Get the customer's company.
1105
+     *
1106
+     * @since 1.0.19
1107
+     * @param  string $context View or edit context.
1108
+     * @return string
1109
+     */
1110
+    public function get_company( $context = 'view' ) {
1111
+        return $this->get_prop( 'company', $context );
1112 1112
     }
1113 1113
 
1114 1114
     /**
1115
-	 * Alias of self::get_company().
1116
-	 *
1117
-	 * @since 1.0.19
1118
-	 * @param  string $context View or edit context.
1119
-	 * @return string
1120
-	 */
1121
-	public function get_user_company( $context = 'view' ) {
1122
-		return $this->get_company( $context );
1115
+     * Alias of self::get_company().
1116
+     *
1117
+     * @since 1.0.19
1118
+     * @param  string $context View or edit context.
1119
+     * @return string
1120
+     */
1121
+    public function get_user_company( $context = 'view' ) {
1122
+        return $this->get_company( $context );
1123 1123
     }
1124 1124
 
1125 1125
     /**
1126
-	 * Alias of self::get_company().
1127
-	 *
1128
-	 * @since 1.0.19
1129
-	 * @param  string $context View or edit context.
1130
-	 * @return string
1131
-	 */
1132
-	public function get_customer_company( $context = 'view' ) {
1133
-		return $this->get_company( $context );
1126
+     * Alias of self::get_company().
1127
+     *
1128
+     * @since 1.0.19
1129
+     * @param  string $context View or edit context.
1130
+     * @return string
1131
+     */
1132
+    public function get_customer_company( $context = 'view' ) {
1133
+        return $this->get_company( $context );
1134 1134
     }
1135 1135
 
1136 1136
     /**
1137
-	 * Get the customer's vat number.
1138
-	 *
1139
-	 * @since 1.0.19
1140
-	 * @param  string $context View or edit context.
1141
-	 * @return string
1142
-	 */
1143
-	public function get_vat_number( $context = 'view' ) {
1144
-		return $this->get_prop( 'vat_number', $context );
1137
+     * Get the customer's vat number.
1138
+     *
1139
+     * @since 1.0.19
1140
+     * @param  string $context View or edit context.
1141
+     * @return string
1142
+     */
1143
+    public function get_vat_number( $context = 'view' ) {
1144
+        return $this->get_prop( 'vat_number', $context );
1145 1145
     }
1146 1146
 
1147 1147
     /**
1148
-	 * Alias of self::get_vat_number().
1149
-	 *
1150
-	 * @since 1.0.19
1151
-	 * @param  string $context View or edit context.
1152
-	 * @return string
1153
-	 */
1154
-	public function get_user_vat_number( $context = 'view' ) {
1155
-		return $this->get_vat_number( $context );
1148
+     * Alias of self::get_vat_number().
1149
+     *
1150
+     * @since 1.0.19
1151
+     * @param  string $context View or edit context.
1152
+     * @return string
1153
+     */
1154
+    public function get_user_vat_number( $context = 'view' ) {
1155
+        return $this->get_vat_number( $context );
1156 1156
     }
1157 1157
 
1158 1158
     /**
1159
-	 * Alias of self::get_vat_number().
1160
-	 *
1161
-	 * @since 1.0.19
1162
-	 * @param  string $context View or edit context.
1163
-	 * @return string
1164
-	 */
1165
-	public function get_customer_vat_number( $context = 'view' ) {
1166
-		return $this->get_vat_number( $context );
1159
+     * Alias of self::get_vat_number().
1160
+     *
1161
+     * @since 1.0.19
1162
+     * @param  string $context View or edit context.
1163
+     * @return string
1164
+     */
1165
+    public function get_customer_vat_number( $context = 'view' ) {
1166
+        return $this->get_vat_number( $context );
1167 1167
     }
1168 1168
 
1169 1169
     /**
1170
-	 * Get the customer's vat rate.
1171
-	 *
1172
-	 * @since 1.0.19
1173
-	 * @param  string $context View or edit context.
1174
-	 * @return string
1175
-	 */
1176
-	public function get_vat_rate( $context = 'view' ) {
1177
-		return $this->get_prop( 'vat_rate', $context );
1170
+     * Get the customer's vat rate.
1171
+     *
1172
+     * @since 1.0.19
1173
+     * @param  string $context View or edit context.
1174
+     * @return string
1175
+     */
1176
+    public function get_vat_rate( $context = 'view' ) {
1177
+        return $this->get_prop( 'vat_rate', $context );
1178
+    }
1179
+
1180
+    /**
1181
+     * Alias of self::get_vat_rate().
1182
+     *
1183
+     * @since 1.0.19
1184
+     * @param  string $context View or edit context.
1185
+     * @return string
1186
+     */
1187
+    public function get_user_vat_rate( $context = 'view' ) {
1188
+        return $this->get_vat_rate( $context );
1189
+    }
1190
+
1191
+    /**
1192
+     * Alias of self::get_vat_rate().
1193
+     *
1194
+     * @since 1.0.19
1195
+     * @param  string $context View or edit context.
1196
+     * @return string
1197
+     */
1198
+    public function get_customer_vat_rate( $context = 'view' ) {
1199
+        return $this->get_vat_rate( $context );
1200
+    }
1201
+
1202
+    /**
1203
+     * Get the customer's address.
1204
+     *
1205
+     * @since 1.0.19
1206
+     * @param  string $context View or edit context.
1207
+     * @return string
1208
+     */
1209
+    public function get_address( $context = 'view' ) {
1210
+        return $this->get_prop( 'address', $context );
1211
+    }
1212
+
1213
+    /**
1214
+     * Alias of self::get_address().
1215
+     *
1216
+     * @since 1.0.19
1217
+     * @param  string $context View or edit context.
1218
+     * @return string
1219
+     */
1220
+    public function get_user_address( $context = 'view' ) {
1221
+        return $this->get_address( $context );
1222
+    }
1223
+
1224
+    /**
1225
+     * Alias of self::get_address().
1226
+     *
1227
+     * @since 1.0.19
1228
+     * @param  string $context View or edit context.
1229
+     * @return string
1230
+     */
1231
+    public function get_customer_address( $context = 'view' ) {
1232
+        return $this->get_address( $context );
1233
+    }
1234
+
1235
+    /**
1236
+     * Get whether the customer has viewed the invoice or not.
1237
+     *
1238
+     * @since 1.0.19
1239
+     * @param  string $context View or edit context.
1240
+     * @return bool
1241
+     */
1242
+    public function get_is_viewed( $context = 'view' ) {
1243
+        return (bool) $this->get_prop( 'is_viewed', $context );
1244
+    }
1245
+
1246
+    /**
1247
+     * Get other recipients for invoice communications.
1248
+     *
1249
+     * @since 1.0.19
1250
+     * @param  string $context View or edit context.
1251
+     * @return bool
1252
+     */
1253
+    public function get_email_cc( $context = 'view' ) {
1254
+        return $this->get_prop( 'email_cc', $context );
1255
+    }
1256
+
1257
+    /**
1258
+     * Get invoice template.
1259
+     *
1260
+     * @since 1.0.19
1261
+     * @param  string $context View or edit context.
1262
+     * @return bool
1263
+     */
1264
+    public function get_template( $context = 'view' ) {
1265
+        return $this->get_prop( 'template', $context );
1266
+    }
1267
+
1268
+    /**
1269
+     * Get whether the customer has confirmed their address.
1270
+     *
1271
+     * @since 1.0.19
1272
+     * @param  string $context View or edit context.
1273
+     * @return bool
1274
+     */
1275
+    public function get_address_confirmed( $context = 'view' ) {
1276
+        return (bool) $this->get_prop( 'address_confirmed', $context );
1178 1277
     }
1179 1278
 
1180 1279
     /**
1181
-	 * Alias of self::get_vat_rate().
1182
-	 *
1183
-	 * @since 1.0.19
1184
-	 * @param  string $context View or edit context.
1185
-	 * @return string
1186
-	 */
1187
-	public function get_user_vat_rate( $context = 'view' ) {
1188
-		return $this->get_vat_rate( $context );
1280
+     * Alias of self::get_address_confirmed().
1281
+     *
1282
+     * @since 1.0.19
1283
+     * @param  string $context View or edit context.
1284
+     * @return bool
1285
+     */
1286
+    public function get_user_address_confirmed( $context = 'view' ) {
1287
+        return $this->get_address_confirmed( $context );
1189 1288
     }
1190 1289
 
1191 1290
     /**
1192
-	 * Alias of self::get_vat_rate().
1193
-	 *
1194
-	 * @since 1.0.19
1195
-	 * @param  string $context View or edit context.
1196
-	 * @return string
1197
-	 */
1198
-	public function get_customer_vat_rate( $context = 'view' ) {
1199
-		return $this->get_vat_rate( $context );
1291
+     * Alias of self::get_address().
1292
+     *
1293
+     * @since 1.0.19
1294
+     * @param  string $context View or edit context.
1295
+     * @return bool
1296
+     */
1297
+    public function get_customer_address_confirmed( $context = 'view' ) {
1298
+        return $this->get_address_confirmed( $context );
1200 1299
     }
1201 1300
 
1202 1301
     /**
1203
-	 * Get the customer's address.
1204
-	 *
1205
-	 * @since 1.0.19
1206
-	 * @param  string $context View or edit context.
1207
-	 * @return string
1208
-	 */
1209
-	public function get_address( $context = 'view' ) {
1210
-		return $this->get_prop( 'address', $context );
1211
-    }
1212
-
1213
-    /**
1214
-	 * Alias of self::get_address().
1215
-	 *
1216
-	 * @since 1.0.19
1217
-	 * @param  string $context View or edit context.
1218
-	 * @return string
1219
-	 */
1220
-	public function get_user_address( $context = 'view' ) {
1221
-		return $this->get_address( $context );
1222
-    }
1223
-
1224
-    /**
1225
-	 * Alias of self::get_address().
1226
-	 *
1227
-	 * @since 1.0.19
1228
-	 * @param  string $context View or edit context.
1229
-	 * @return string
1230
-	 */
1231
-	public function get_customer_address( $context = 'view' ) {
1232
-		return $this->get_address( $context );
1233
-    }
1234
-
1235
-    /**
1236
-	 * Get whether the customer has viewed the invoice or not.
1237
-	 *
1238
-	 * @since 1.0.19
1239
-	 * @param  string $context View or edit context.
1240
-	 * @return bool
1241
-	 */
1242
-	public function get_is_viewed( $context = 'view' ) {
1243
-		return (bool) $this->get_prop( 'is_viewed', $context );
1244
-	}
1245
-
1246
-	/**
1247
-	 * Get other recipients for invoice communications.
1248
-	 *
1249
-	 * @since 1.0.19
1250
-	 * @param  string $context View or edit context.
1251
-	 * @return bool
1252
-	 */
1253
-	public function get_email_cc( $context = 'view' ) {
1254
-		return $this->get_prop( 'email_cc', $context );
1255
-	}
1256
-
1257
-	/**
1258
-	 * Get invoice template.
1259
-	 *
1260
-	 * @since 1.0.19
1261
-	 * @param  string $context View or edit context.
1262
-	 * @return bool
1263
-	 */
1264
-	public function get_template( $context = 'view' ) {
1265
-		return $this->get_prop( 'template', $context );
1266
-	}
1267
-
1268
-	/**
1269
-	 * Get whether the customer has confirmed their address.
1270
-	 *
1271
-	 * @since 1.0.19
1272
-	 * @param  string $context View or edit context.
1273
-	 * @return bool
1274
-	 */
1275
-	public function get_address_confirmed( $context = 'view' ) {
1276
-		return (bool) $this->get_prop( 'address_confirmed', $context );
1277
-    }
1278
-
1279
-    /**
1280
-	 * Alias of self::get_address_confirmed().
1281
-	 *
1282
-	 * @since 1.0.19
1283
-	 * @param  string $context View or edit context.
1284
-	 * @return bool
1285
-	 */
1286
-	public function get_user_address_confirmed( $context = 'view' ) {
1287
-		return $this->get_address_confirmed( $context );
1288
-    }
1289
-
1290
-    /**
1291
-	 * Alias of self::get_address().
1292
-	 *
1293
-	 * @since 1.0.19
1294
-	 * @param  string $context View or edit context.
1295
-	 * @return bool
1296
-	 */
1297
-	public function get_customer_address_confirmed( $context = 'view' ) {
1298
-		return $this->get_address_confirmed( $context );
1299
-    }
1300
-
1301
-    /**
1302
-	 * Get the invoice subtotal.
1303
-	 *
1304
-	 * @since 1.0.19
1305
-	 * @param  string $context View or edit context.
1306
-	 * @return float
1307
-	 */
1308
-	public function get_subtotal( $context = 'view' ) {
1302
+     * Get the invoice subtotal.
1303
+     *
1304
+     * @since 1.0.19
1305
+     * @param  string $context View or edit context.
1306
+     * @return float
1307
+     */
1308
+    public function get_subtotal( $context = 'view' ) {
1309 1309
         $subtotal = (float) $this->get_prop( 'subtotal', $context );
1310 1310
 
1311 1311
         // Backwards compatibility.
@@ -1317,155 +1317,155 @@  discard block
 block discarded – undo
1317 1317
     }
1318 1318
 
1319 1319
     /**
1320
-	 * Get the invoice discount total.
1321
-	 *
1322
-	 * @since 1.0.19
1323
-	 * @param  string $context View or edit context.
1324
-	 * @return float
1325
-	 */
1326
-	public function get_total_discount( $context = 'view' ) {
1327
-		return (float) $this->get_prop( 'total_discount', $context );
1320
+     * Get the invoice discount total.
1321
+     *
1322
+     * @since 1.0.19
1323
+     * @param  string $context View or edit context.
1324
+     * @return float
1325
+     */
1326
+    public function get_total_discount( $context = 'view' ) {
1327
+        return (float) $this->get_prop( 'total_discount', $context );
1328 1328
     }
1329 1329
 
1330 1330
     /**
1331
-	 * Get the invoice tax total.
1332
-	 *
1333
-	 * @since 1.0.19
1334
-	 * @param  string $context View or edit context.
1335
-	 * @return float
1336
-	 */
1337
-	public function get_total_tax( $context = 'view' ) {
1338
-		return (float) $this->get_prop( 'total_tax', $context );
1339
-	}
1331
+     * Get the invoice tax total.
1332
+     *
1333
+     * @since 1.0.19
1334
+     * @param  string $context View or edit context.
1335
+     * @return float
1336
+     */
1337
+    public function get_total_tax( $context = 'view' ) {
1338
+        return (float) $this->get_prop( 'total_tax', $context );
1339
+    }
1340 1340
 
1341
-	/**
1342
-	 * @deprecated
1343
-	 */
1344
-	public function get_final_tax( $currency = false ) {
1345
-		$tax = $this->get_total_tax();
1341
+    /**
1342
+     * @deprecated
1343
+     */
1344
+    public function get_final_tax( $currency = false ) {
1345
+        $tax = $this->get_total_tax();
1346 1346
 
1347 1347
         if ( $currency ) {
1348
-			return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1348
+            return wpinv_price( wpinv_format_amount( $tax, NULL, false ), $this->get_currency() );
1349 1349
         }
1350 1350
 
1351 1351
         return $tax;
1352 1352
     }
1353 1353
 
1354 1354
     /**
1355
-	 * Get the invoice fees total.
1356
-	 *
1357
-	 * @since 1.0.19
1358
-	 * @param  string $context View or edit context.
1359
-	 * @return float
1360
-	 */
1361
-	public function get_total_fees( $context = 'view' ) {
1362
-		return (float) $this->get_prop( 'total_fees', $context );
1355
+     * Get the invoice fees total.
1356
+     *
1357
+     * @since 1.0.19
1358
+     * @param  string $context View or edit context.
1359
+     * @return float
1360
+     */
1361
+    public function get_total_fees( $context = 'view' ) {
1362
+        return (float) $this->get_prop( 'total_fees', $context );
1363 1363
     }
1364 1364
 
1365 1365
     /**
1366
-	 * Alias for self::get_total_fees().
1367
-	 *
1368
-	 * @since 1.0.19
1369
-	 * @param  string $context View or edit context.
1370
-	 * @return float
1371
-	 */
1372
-	public function get_fees_total( $context = 'view' ) {
1373
-		return $this->get_total_fees( $context );
1366
+     * Alias for self::get_total_fees().
1367
+     *
1368
+     * @since 1.0.19
1369
+     * @param  string $context View or edit context.
1370
+     * @return float
1371
+     */
1372
+    public function get_fees_total( $context = 'view' ) {
1373
+        return $this->get_total_fees( $context );
1374 1374
     }
1375 1375
 
1376 1376
     /**
1377
-	 * Get the invoice total.
1378
-	 *
1379
-	 * @since 1.0.19
1377
+     * Get the invoice total.
1378
+     *
1379
+     * @since 1.0.19
1380 1380
      * @return float
1381
-	 */
1382
-	public function get_total() {
1383
-		$total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1384
-		return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1381
+     */
1382
+    public function get_total() {
1383
+        $total = $this->is_renewal() ? $this->get_recurring_total() : $this->get_initial_total();
1384
+        return apply_filters( 'getpaid_get_invoice_total_amount', $total, $this  );
1385 1385
     }
1386 1386
 
1387 1387
     /**
1388
-	 * Get the initial invoice total.
1389
-	 *
1390
-	 * @since 1.0.19
1388
+     * Get the initial invoice total.
1389
+     *
1390
+     * @since 1.0.19
1391 1391
      * @param  string $context View or edit context.
1392 1392
      * @return float
1393
-	 */
1393
+     */
1394 1394
     public function get_initial_total() {
1395 1395
 
1396
-		if ( empty( $this->totals ) ) {
1397
-			$this->recalculate_total();
1398
-		}
1396
+        if ( empty( $this->totals ) ) {
1397
+            $this->recalculate_total();
1398
+        }
1399 1399
 
1400
-		$tax      = $this->totals['tax']['initial'];
1401
-		$fee      = $this->totals['fee']['initial'];
1402
-		$discount = $this->totals['discount']['initial'];
1403
-		$subtotal = $this->totals['subtotal']['initial'];
1404
-		$total    = $tax + $fee - $discount + $subtotal;
1400
+        $tax      = $this->totals['tax']['initial'];
1401
+        $fee      = $this->totals['fee']['initial'];
1402
+        $discount = $this->totals['discount']['initial'];
1403
+        $subtotal = $this->totals['subtotal']['initial'];
1404
+        $total    = $tax + $fee - $discount + $subtotal;
1405 1405
 
1406
-		if ( 0 > $total ) {
1407
-			$total = 0;
1408
-		}
1406
+        if ( 0 > $total ) {
1407
+            $total = 0;
1408
+        }
1409 1409
 
1410 1410
         return apply_filters( 'wpinv_get_initial_invoice_total', $total, $this );
1411
-	}
1411
+    }
1412 1412
 
1413
-	/**
1414
-	 * Get the recurring invoice total.
1415
-	 *
1416
-	 * @since 1.0.19
1413
+    /**
1414
+     * Get the recurring invoice total.
1415
+     *
1416
+     * @since 1.0.19
1417 1417
      * @param  string $context View or edit context.
1418 1418
      * @return float
1419
-	 */
1419
+     */
1420 1420
     public function get_recurring_total() {
1421 1421
 
1422
-		if ( empty( $this->totals ) ) {
1423
-			$this->recalculate_total();
1424
-		}
1422
+        if ( empty( $this->totals ) ) {
1423
+            $this->recalculate_total();
1424
+        }
1425 1425
 
1426
-		$tax      = $this->totals['tax']['recurring'];
1427
-		$fee      = $this->totals['fee']['recurring'];
1428
-		$discount = $this->totals['discount']['recurring'];
1429
-		$subtotal = $this->totals['subtotal']['recurring'];
1430
-		$total    = $tax + $fee - $discount + $subtotal;
1426
+        $tax      = $this->totals['tax']['recurring'];
1427
+        $fee      = $this->totals['fee']['recurring'];
1428
+        $discount = $this->totals['discount']['recurring'];
1429
+        $subtotal = $this->totals['subtotal']['recurring'];
1430
+        $total    = $tax + $fee - $discount + $subtotal;
1431 1431
 
1432
-		if ( 0 > $total ) {
1433
-			$total = 0;
1434
-		}
1432
+        if ( 0 > $total ) {
1433
+            $total = 0;
1434
+        }
1435 1435
 
1436 1436
         return apply_filters( 'wpinv_get_recurring_invoice_total', $total, $this );
1437
-	}
1437
+    }
1438 1438
 
1439
-	/**
1440
-	 * Returns recurring payment details.
1441
-	 *
1442
-	 * @since 1.0.19
1439
+    /**
1440
+     * Returns recurring payment details.
1441
+     *
1442
+     * @since 1.0.19
1443 1443
      * @param  string $field Optionally provide a field to return.
1444
-	 * @param string $currency Whether to include the currency.
1444
+     * @param string $currency Whether to include the currency.
1445 1445
      * @return float
1446
-	 */
1446
+     */
1447 1447
     public function get_recurring_details( $field = '', $currency = false ) {
1448 1448
 
1449
-		// Maybe recalculate totals.
1450
-		if ( empty( $this->totals ) ) {
1451
-			$this->recalculate_total();
1452
-		}
1449
+        // Maybe recalculate totals.
1450
+        if ( empty( $this->totals ) ) {
1451
+            $this->recalculate_total();
1452
+        }
1453 1453
 
1454
-		// Prepare recurring totals.
1454
+        // Prepare recurring totals.
1455 1455
         $data = apply_filters(
1456
-			'wpinv_get_invoice_recurring_details',
1457
-			array(
1458
-				'cart_details' => $this->get_cart_details(),
1459
-				'subtotal'     => $this->totals['subtotal']['recurring'],
1460
-				'discount'     => $this->totals['discount']['recurring'],
1461
-				'tax'          => $this->totals['tax']['recurring'],
1462
-				'fee'          => $this->totals['fee']['recurring'],
1463
-				'total'        => $this->get_recurring_total(),
1464
-			),
1465
-			$this,
1466
-			$field,
1467
-			$currency
1468
-		);
1456
+            'wpinv_get_invoice_recurring_details',
1457
+            array(
1458
+                'cart_details' => $this->get_cart_details(),
1459
+                'subtotal'     => $this->totals['subtotal']['recurring'],
1460
+                'discount'     => $this->totals['discount']['recurring'],
1461
+                'tax'          => $this->totals['tax']['recurring'],
1462
+                'fee'          => $this->totals['fee']['recurring'],
1463
+                'total'        => $this->get_recurring_total(),
1464
+            ),
1465
+            $this,
1466
+            $field,
1467
+            $currency
1468
+        );
1469 1469
 
1470 1470
         if ( isset( $data[$field] ) ) {
1471 1471
             return ( $currency ? wpinv_price( $data[$field], $this->get_currency() ) : $data[$field] );
@@ -1475,145 +1475,145 @@  discard block
 block discarded – undo
1475 1475
     }
1476 1476
 
1477 1477
     /**
1478
-	 * Get the invoice fees.
1479
-	 *
1480
-	 * @since 1.0.19
1481
-	 * @param  string $context View or edit context.
1482
-	 * @return array
1483
-	 */
1484
-	public function get_fees( $context = 'view' ) {
1485
-		return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1478
+     * Get the invoice fees.
1479
+     *
1480
+     * @since 1.0.19
1481
+     * @param  string $context View or edit context.
1482
+     * @return array
1483
+     */
1484
+    public function get_fees( $context = 'view' ) {
1485
+        return wpinv_parse_list( $this->get_prop( 'fees', $context ) );
1486 1486
     }
1487 1487
 
1488 1488
     /**
1489
-	 * Get the invoice discounts.
1490
-	 *
1491
-	 * @since 1.0.19
1492
-	 * @param  string $context View or edit context.
1493
-	 * @return array
1494
-	 */
1495
-	public function get_discounts( $context = 'view' ) {
1496
-		return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1489
+     * Get the invoice discounts.
1490
+     *
1491
+     * @since 1.0.19
1492
+     * @param  string $context View or edit context.
1493
+     * @return array
1494
+     */
1495
+    public function get_discounts( $context = 'view' ) {
1496
+        return wpinv_parse_list( $this->get_prop( 'discounts', $context ) );
1497 1497
     }
1498 1498
 
1499 1499
     /**
1500
-	 * Get the invoice taxes.
1501
-	 *
1502
-	 * @since 1.0.19
1503
-	 * @param  string $context View or edit context.
1504
-	 * @return array
1505
-	 */
1506
-	public function get_taxes( $context = 'view' ) {
1507
-		return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1500
+     * Get the invoice taxes.
1501
+     *
1502
+     * @since 1.0.19
1503
+     * @param  string $context View or edit context.
1504
+     * @return array
1505
+     */
1506
+    public function get_taxes( $context = 'view' ) {
1507
+        return wpinv_parse_list( $this->get_prop( 'taxes', $context ) );
1508 1508
     }
1509 1509
 
1510 1510
     /**
1511
-	 * Get the invoice items.
1512
-	 *
1513
-	 * @since 1.0.19
1514
-	 * @param  string $context View or edit context.
1515
-	 * @return GetPaid_Form_Item[]
1516
-	 */
1517
-	public function get_items( $context = 'view' ) {
1511
+     * Get the invoice items.
1512
+     *
1513
+     * @since 1.0.19
1514
+     * @param  string $context View or edit context.
1515
+     * @return GetPaid_Form_Item[]
1516
+     */
1517
+    public function get_items( $context = 'view' ) {
1518 1518
         return $this->get_prop( 'items', $context );
1519 1519
     }
1520 1520
 
1521 1521
     /**
1522
-	 * Get the invoice's payment form.
1523
-	 *
1524
-	 * @since 1.0.19
1525
-	 * @param  string $context View or edit context.
1526
-	 * @return int
1527
-	 */
1528
-	public function get_payment_form( $context = 'view' ) {
1529
-		return intval( $this->get_prop( 'payment_form', $context ) );
1522
+     * Get the invoice's payment form.
1523
+     *
1524
+     * @since 1.0.19
1525
+     * @param  string $context View or edit context.
1526
+     * @return int
1527
+     */
1528
+    public function get_payment_form( $context = 'view' ) {
1529
+        return intval( $this->get_prop( 'payment_form', $context ) );
1530 1530
     }
1531 1531
 
1532 1532
     /**
1533
-	 * Get the invoice's submission id.
1534
-	 *
1535
-	 * @since 1.0.19
1536
-	 * @param  string $context View or edit context.
1537
-	 * @return string
1538
-	 */
1539
-	public function get_submission_id( $context = 'view' ) {
1540
-		return $this->get_prop( 'submission_id', $context );
1533
+     * Get the invoice's submission id.
1534
+     *
1535
+     * @since 1.0.19
1536
+     * @param  string $context View or edit context.
1537
+     * @return string
1538
+     */
1539
+    public function get_submission_id( $context = 'view' ) {
1540
+        return $this->get_prop( 'submission_id', $context );
1541 1541
     }
1542 1542
 
1543 1543
     /**
1544
-	 * Get the invoice's discount code.
1545
-	 *
1546
-	 * @since 1.0.19
1547
-	 * @param  string $context View or edit context.
1548
-	 * @return string
1549
-	 */
1550
-	public function get_discount_code( $context = 'view' ) {
1551
-		return $this->get_prop( 'discount_code', $context );
1544
+     * Get the invoice's discount code.
1545
+     *
1546
+     * @since 1.0.19
1547
+     * @param  string $context View or edit context.
1548
+     * @return string
1549
+     */
1550
+    public function get_discount_code( $context = 'view' ) {
1551
+        return $this->get_prop( 'discount_code', $context );
1552 1552
     }
1553 1553
 
1554 1554
     /**
1555
-	 * Get the invoice's gateway.
1556
-	 *
1557
-	 * @since 1.0.19
1558
-	 * @param  string $context View or edit context.
1559
-	 * @return string
1560
-	 */
1561
-	public function get_gateway( $context = 'view' ) {
1562
-		return $this->get_prop( 'gateway', $context );
1555
+     * Get the invoice's gateway.
1556
+     *
1557
+     * @since 1.0.19
1558
+     * @param  string $context View or edit context.
1559
+     * @return string
1560
+     */
1561
+    public function get_gateway( $context = 'view' ) {
1562
+        return $this->get_prop( 'gateway', $context );
1563 1563
     }
1564 1564
 
1565 1565
     /**
1566
-	 * Get the invoice's gateway display title.
1567
-	 *
1568
-	 * @since 1.0.19
1569
-	 * @return string
1570
-	 */
1566
+     * Get the invoice's gateway display title.
1567
+     *
1568
+     * @since 1.0.19
1569
+     * @return string
1570
+     */
1571 1571
     public function get_gateway_title() {
1572 1572
         $title =  wpinv_get_gateway_checkout_label( $this->get_gateway() );
1573 1573
         return apply_filters( 'wpinv_gateway_title', $title, $this->get_id(), $this );
1574 1574
     }
1575 1575
 
1576 1576
     /**
1577
-	 * Get the invoice's transaction id.
1578
-	 *
1579
-	 * @since 1.0.19
1580
-	 * @param  string $context View or edit context.
1581
-	 * @return string
1582
-	 */
1583
-	public function get_transaction_id( $context = 'view' ) {
1584
-		return $this->get_prop( 'transaction_id', $context );
1577
+     * Get the invoice's transaction id.
1578
+     *
1579
+     * @since 1.0.19
1580
+     * @param  string $context View or edit context.
1581
+     * @return string
1582
+     */
1583
+    public function get_transaction_id( $context = 'view' ) {
1584
+        return $this->get_prop( 'transaction_id', $context );
1585 1585
     }
1586 1586
 
1587 1587
     /**
1588
-	 * Get the invoice's currency.
1589
-	 *
1590
-	 * @since 1.0.19
1591
-	 * @param  string $context View or edit context.
1592
-	 * @return string
1593
-	 */
1594
-	public function get_currency( $context = 'view' ) {
1588
+     * Get the invoice's currency.
1589
+     *
1590
+     * @since 1.0.19
1591
+     * @param  string $context View or edit context.
1592
+     * @return string
1593
+     */
1594
+    public function get_currency( $context = 'view' ) {
1595 1595
         $currency = $this->get_prop( 'currency', $context );
1596 1596
         return empty( $currency ) ? wpinv_get_currency() : $currency;
1597 1597
     }
1598 1598
 
1599 1599
     /**
1600
-	 * Checks if we are charging taxes for this invoice.
1601
-	 *
1602
-	 * @since 1.0.19
1603
-	 * @param  string $context View or edit context.
1604
-	 * @return bool
1605
-	 */
1606
-	public function get_disable_taxes( $context = 'view' ) {
1600
+     * Checks if we are charging taxes for this invoice.
1601
+     *
1602
+     * @since 1.0.19
1603
+     * @param  string $context View or edit context.
1604
+     * @return bool
1605
+     */
1606
+    public function get_disable_taxes( $context = 'view' ) {
1607 1607
         return (bool) $this->get_prop( 'disable_taxes', $context );
1608 1608
     }
1609 1609
 
1610 1610
     /**
1611
-	 * Retrieves the subscription id for an invoice.
1612
-	 *
1613
-	 * @since 1.0.19
1614
-	 * @param  string $context View or edit context.
1615
-	 * @return int
1616
-	 */
1611
+     * Retrieves the subscription id for an invoice.
1612
+     *
1613
+     * @since 1.0.19
1614
+     * @param  string $context View or edit context.
1615
+     * @return int
1616
+     */
1617 1617
     public function get_subscription_id( $context = 'view' ) {
1618 1618
         $subscription_id = $this->get_prop( 'subscription_id', $context );
1619 1619
 
@@ -1626,12 +1626,12 @@  discard block
 block discarded – undo
1626 1626
     }
1627 1627
 
1628 1628
     /**
1629
-	 * Retrieves the payment meta for an invoice.
1630
-	 *
1631
-	 * @since 1.0.19
1632
-	 * @param  string $context View or edit context.
1633
-	 * @return array
1634
-	 */
1629
+     * Retrieves the payment meta for an invoice.
1630
+     *
1631
+     * @since 1.0.19
1632
+     * @param  string $context View or edit context.
1633
+     * @return array
1634
+     */
1635 1635
     public function get_payment_meta( $context = 'view' ) {
1636 1636
 
1637 1637
         return array(
@@ -1651,11 +1651,11 @@  discard block
 block discarded – undo
1651 1651
     }
1652 1652
 
1653 1653
     /**
1654
-	 * Retrieves the cart details for an invoice.
1655
-	 *
1656
-	 * @since 1.0.19
1657
-	 * @return array
1658
-	 */
1654
+     * Retrieves the cart details for an invoice.
1655
+     *
1656
+     * @since 1.0.19
1657
+     * @return array
1658
+     */
1659 1659
     public function get_cart_details() {
1660 1660
         $items        = $this->get_items();
1661 1661
         $cart_details = array();
@@ -1665,16 +1665,16 @@  discard block
 block discarded – undo
1665 1665
         }
1666 1666
 
1667 1667
         return $cart_details;
1668
-	}
1668
+    }
1669 1669
 
1670
-	/**
1671
-	 * Retrieves the recurring item.
1672
-	 *
1673
-	 * @return null|GetPaid_Form_Item
1674
-	 */
1675
-	public function get_recurring( $object = false ) {
1670
+    /**
1671
+     * Retrieves the recurring item.
1672
+     *
1673
+     * @return null|GetPaid_Form_Item
1674
+     */
1675
+    public function get_recurring( $object = false ) {
1676 1676
 
1677
-		// Are we returning an object?
1677
+        // Are we returning an object?
1678 1678
         if ( $object ) {
1679 1679
             return $this->get_item( $this->recurring_item );
1680 1680
         }
@@ -1682,100 +1682,100 @@  discard block
 block discarded – undo
1682 1682
         return $this->recurring_item;
1683 1683
     }
1684 1684
 
1685
-	/**
1686
-	 * Retrieves the subscription name.
1687
-	 *
1688
-	 * @since 1.0.19
1689
-	 * @return string
1690
-	 */
1691
-	public function get_subscription_name() {
1685
+    /**
1686
+     * Retrieves the subscription name.
1687
+     *
1688
+     * @since 1.0.19
1689
+     * @return string
1690
+     */
1691
+    public function get_subscription_name() {
1692 1692
 
1693
-		// Retrieve the recurring name
1693
+        // Retrieve the recurring name
1694 1694
         $item = $this->get_recurring( true );
1695 1695
 
1696
-		// Abort if it does not exist.
1696
+        // Abort if it does not exist.
1697 1697
         if ( empty( $item ) ) {
1698 1698
             return '';
1699 1699
         }
1700 1700
 
1701
-		// Return the item name.
1701
+        // Return the item name.
1702 1702
         return apply_filters( 'wpinv_invoice_get_subscription_name', $item->get_name(), $this );
1703
-	}
1704
-
1705
-	/**
1706
-	 * Retrieves the view url.
1707
-	 *
1708
-	 * @since 1.0.19
1709
-	 * @return string
1710
-	 */
1711
-	public function get_view_url() {
1703
+    }
1704
+
1705
+    /**
1706
+     * Retrieves the view url.
1707
+     *
1708
+     * @since 1.0.19
1709
+     * @return string
1710
+     */
1711
+    public function get_view_url() {
1712 1712
         $invoice_url = get_permalink( $this->get_id() );
1713
-		$invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1713
+        $invoice_url = add_query_arg( 'invoice_key', $this->get_key(), $invoice_url );
1714 1714
         return apply_filters( 'wpinv_get_view_url', $invoice_url, $this );
1715
-	}
1715
+    }
1716 1716
 
1717
-	/**
1718
-	 * Retrieves the payment url.
1719
-	 *
1720
-	 * @since 1.0.19
1721
-	 * @return string
1722
-	 */
1723
-	public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1717
+    /**
1718
+     * Retrieves the payment url.
1719
+     *
1720
+     * @since 1.0.19
1721
+     * @return string
1722
+     */
1723
+    public function get_checkout_payment_url( $deprecated = false, $secret = false ) {
1724 1724
 
1725
-		// Retrieve the checkout url.
1725
+        // Retrieve the checkout url.
1726 1726
         $pay_url = wpinv_get_checkout_uri();
1727 1727
 
1728
-		// Maybe force ssl.
1728
+        // Maybe force ssl.
1729 1729
         if ( is_ssl() ) {
1730 1730
             $pay_url = str_replace( 'http:', 'https:', $pay_url );
1731 1731
         }
1732 1732
 
1733
-		// Add the invoice key.
1734
-		$pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1733
+        // Add the invoice key.
1734
+        $pay_url = add_query_arg( 'invoice_key', $this->get_key(), $pay_url );
1735 1735
 
1736
-		// (Maybe?) add a secret
1736
+        // (Maybe?) add a secret
1737 1737
         if ( $secret ) {
1738 1738
             $pay_url = add_query_arg( array( '_wpipay' => md5( $this->get_user_id() . '::' . $this->get_email() . '::' . $this->get_key() ) ), $pay_url );
1739 1739
         }
1740 1740
 
1741 1741
         return apply_filters( 'wpinv_get_checkout_payment_url', $pay_url, $this, $deprecated, $secret );
1742
-	}
1742
+    }
1743 1743
 	
1744
-	/**
1745
-	 * Retrieves the receipt url.
1746
-	 *
1747
-	 * @since 1.0.19
1748
-	 * @return string
1749
-	 */
1750
-	public function get_receipt_url() {
1751
-
1752
-		// Retrieve the checkout url.
1744
+    /**
1745
+     * Retrieves the receipt url.
1746
+     *
1747
+     * @since 1.0.19
1748
+     * @return string
1749
+     */
1750
+    public function get_receipt_url() {
1751
+
1752
+        // Retrieve the checkout url.
1753 1753
         $receipt_url = wpinv_get_success_page_uri();
1754 1754
 
1755
-		// Maybe force ssl.
1755
+        // Maybe force ssl.
1756 1756
         if ( is_ssl() ) {
1757 1757
             $receipt_url = str_replace( 'http:', 'https:', $receipt_url );
1758 1758
         }
1759 1759
 
1760
-		// Add the invoice key.
1761
-		$receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1760
+        // Add the invoice key.
1761
+        $receipt_url = add_query_arg( 'invoice_key', $this->get_key(), $receipt_url );
1762 1762
 
1763 1763
         return apply_filters( 'getpaid_get_invoice_receipt_url', $receipt_url, $this );
1764 1764
     }
1765 1765
 
1766 1766
     /**
1767
-	 * Magic method for accessing invoice properties.
1768
-	 *
1769
-	 * @since 1.0.15
1770
-	 * @access public
1771
-	 *
1772
-	 * @param string $key Discount data to retrieve
1773
-	 * @param  string $context View or edit context.
1774
-	 * @return mixed Value of the given invoice property (if set).
1775
-	 */
1776
-	public function get( $key, $context = 'view' ) {
1767
+     * Magic method for accessing invoice properties.
1768
+     *
1769
+     * @since 1.0.15
1770
+     * @access public
1771
+     *
1772
+     * @param string $key Discount data to retrieve
1773
+     * @param  string $context View or edit context.
1774
+     * @return mixed Value of the given invoice property (if set).
1775
+     */
1776
+    public function get( $key, $context = 'view' ) {
1777 1777
         return $this->get_prop( $key, $context );
1778
-	}
1778
+    }
1779 1779
 
1780 1780
     /*
1781 1781
 	|--------------------------------------------------------------------------
@@ -1788,126 +1788,126 @@  discard block
 block discarded – undo
1788 1788
     */
1789 1789
 
1790 1790
     /**
1791
-	 * Magic method for setting invoice properties.
1792
-	 *
1793
-	 * @since 1.0.19
1794
-	 * @access public
1795
-	 *
1796
-	 * @param string $key Discount data to retrieve
1797
-	 * @param  mixed $value new value.
1798
-	 * @return mixed Value of the given invoice property (if set).
1799
-	 */
1800
-	public function set( $key, $value ) {
1791
+     * Magic method for setting invoice properties.
1792
+     *
1793
+     * @since 1.0.19
1794
+     * @access public
1795
+     *
1796
+     * @param string $key Discount data to retrieve
1797
+     * @param  mixed $value new value.
1798
+     * @return mixed Value of the given invoice property (if set).
1799
+     */
1800
+    public function set( $key, $value ) {
1801 1801
 
1802 1802
         $setter = "set_$key";
1803 1803
         if ( is_callable( array( $this, $setter ) ) ) {
1804 1804
             $this->{$setter}( $value );
1805 1805
         }
1806 1806
 
1807
-	}
1807
+    }
1808 1808
 
1809
-	/**
1810
-	 * Sets item status.
1811
-	 *
1812
-	 * @since 1.0.19
1813
-	 * @param string $new_status    New status.
1814
-	 * @param string $note          Optional note to add.
1815
-	 * @param bool   $manual_update Is this a manual status change?.
1816
-	 * @return array details of change.
1817
-	 */
1818
-	public function set_status( $new_status, $note = '', $manual_update = false ) {
1819
-		$old_status = $this->get_status();
1809
+    /**
1810
+     * Sets item status.
1811
+     *
1812
+     * @since 1.0.19
1813
+     * @param string $new_status    New status.
1814
+     * @param string $note          Optional note to add.
1815
+     * @param bool   $manual_update Is this a manual status change?.
1816
+     * @return array details of change.
1817
+     */
1818
+    public function set_status( $new_status, $note = '', $manual_update = false ) {
1819
+        $old_status = $this->get_status();
1820 1820
 
1821
-		$statuses = $this->get_all_statuses();
1821
+        $statuses = $this->get_all_statuses();
1822 1822
 
1823
-		if ( isset( $statuses[ 'draft' ] ) ) {
1824
-			unset( $statuses[ 'draft' ] );
1825
-		}
1823
+        if ( isset( $statuses[ 'draft' ] ) ) {
1824
+            unset( $statuses[ 'draft' ] );
1825
+        }
1826 1826
 
1827 1827
 
1828
-		$this->set_prop( 'status', $new_status );
1828
+        $this->set_prop( 'status', $new_status );
1829 1829
 
1830
-		// If setting the status, ensure it's set to a valid status.
1831
-		if ( true === $this->object_read ) {
1830
+        // If setting the status, ensure it's set to a valid status.
1831
+        if ( true === $this->object_read ) {
1832 1832
 
1833
-			// Only allow valid new status.
1834
-			if ( ! array_key_exists( $new_status, $statuses ) ) {
1835
-				$new_status = 'wpi-pending';
1836
-			}
1833
+            // Only allow valid new status.
1834
+            if ( ! array_key_exists( $new_status, $statuses ) ) {
1835
+                $new_status = 'wpi-pending';
1836
+            }
1837 1837
 
1838
-			// If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1839
-			if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1840
-				$old_status = 'wpi-pending';
1841
-			}
1838
+            // If the old status is set but unknown (e.g. draft) assume its pending for action usage.
1839
+            if ( $old_status && ! array_key_exists( $new_status, $statuses ) ) {
1840
+                $old_status = 'wpi-pending';
1841
+            }
1842 1842
 
1843
-		}
1843
+        }
1844 1844
 
1845
-		if ( true === $this->object_read && $old_status !== $new_status ) {
1846
-			$this->status_transition = array(
1847
-				'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1848
-				'to'     => $new_status,
1849
-				'note'   => $note,
1850
-				'manual' => (bool) $manual_update,
1851
-			);
1845
+        if ( true === $this->object_read && $old_status !== $new_status ) {
1846
+            $this->status_transition = array(
1847
+                'from'   => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $old_status,
1848
+                'to'     => $new_status,
1849
+                'note'   => $note,
1850
+                'manual' => (bool) $manual_update,
1851
+            );
1852 1852
 
1853
-			if ( $manual_update ) {
1854
-				do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1855
-			}
1853
+            if ( $manual_update ) {
1854
+                do_action( 'getpaid_' . $this->object_type .'_edit_status', $this->get_id(), $new_status );
1855
+            }
1856 1856
 
1857
-			$this->maybe_set_date_paid();
1857
+            $this->maybe_set_date_paid();
1858 1858
 
1859
-		}
1859
+        }
1860 1860
 
1861
-		return array(
1862
-			'from' => $old_status,
1863
-			'to'   => $new_status,
1864
-		);
1865
-	}
1861
+        return array(
1862
+            'from' => $old_status,
1863
+            'to'   => $new_status,
1864
+        );
1865
+    }
1866 1866
 
1867
-	/**
1868
-	 * Maybe set date paid.
1869
-	 *
1870
-	 * Sets the date paid variable when transitioning to the payment complete
1871
-	 * order status.
1872
-	 *
1873
-	 * @since 1.0.19
1874
-	 */
1875
-	public function maybe_set_date_paid() {
1867
+    /**
1868
+     * Maybe set date paid.
1869
+     *
1870
+     * Sets the date paid variable when transitioning to the payment complete
1871
+     * order status.
1872
+     *
1873
+     * @since 1.0.19
1874
+     */
1875
+    public function maybe_set_date_paid() {
1876 1876
 
1877
-		if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1878
-			$this->set_date_completed( current_time( 'mysql' ) );
1879
-		}
1880
-	}
1877
+        if ( ! $this->get_date_completed( 'edit' ) && $this->is_paid() ) {
1878
+            $this->set_date_completed( current_time( 'mysql' ) );
1879
+        }
1880
+    }
1881 1881
 
1882 1882
     /**
1883
-	 * Set parent invoice ID.
1884
-	 *
1885
-	 * @since 1.0.19
1886
-	 */
1887
-	public function set_parent_id( $value ) {
1888
-		if ( $value && ( $value === $this->get_id() ) ) {
1889
-			return;
1890
-		}
1891
-		$this->set_prop( 'parent_id', absint( $value ) );
1883
+     * Set parent invoice ID.
1884
+     *
1885
+     * @since 1.0.19
1886
+     */
1887
+    public function set_parent_id( $value ) {
1888
+        if ( $value && ( $value === $this->get_id() ) ) {
1889
+            return;
1890
+        }
1891
+        $this->set_prop( 'parent_id', absint( $value ) );
1892 1892
     }
1893 1893
 
1894 1894
     /**
1895
-	 * Set plugin version when the invoice was created.
1896
-	 *
1897
-	 * @since 1.0.19
1898
-	 */
1899
-	public function set_version( $value ) {
1900
-		$this->set_prop( 'version', $value );
1895
+     * Set plugin version when the invoice was created.
1896
+     *
1897
+     * @since 1.0.19
1898
+     */
1899
+    public function set_version( $value ) {
1900
+        $this->set_prop( 'version', $value );
1901 1901
     }
1902 1902
 
1903 1903
     /**
1904
-	 * Set date when the invoice was created.
1905
-	 *
1906
-	 * @since 1.0.19
1907
-	 * @param string $value Value to set.
1904
+     * Set date when the invoice was created.
1905
+     *
1906
+     * @since 1.0.19
1907
+     * @param string $value Value to set.
1908 1908
      * @return bool Whether or not the date was set.
1909
-	 */
1910
-	public function set_date_created( $value ) {
1909
+     */
1910
+    public function set_date_created( $value ) {
1911 1911
         $date = strtotime( $value );
1912 1912
 
1913 1913
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1920,13 +1920,13 @@  discard block
 block discarded – undo
1920 1920
     }
1921 1921
 
1922 1922
     /**
1923
-	 * Set date invoice due date.
1924
-	 *
1925
-	 * @since 1.0.19
1926
-	 * @param string $value Value to set.
1923
+     * Set date invoice due date.
1924
+     *
1925
+     * @since 1.0.19
1926
+     * @param string $value Value to set.
1927 1927
      * @return bool Whether or not the date was set.
1928
-	 */
1929
-	public function set_due_date( $value ) {
1928
+     */
1929
+    public function set_due_date( $value ) {
1930 1930
         $date = strtotime( $value );
1931 1931
 
1932 1932
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1934,29 +1934,29 @@  discard block
 block discarded – undo
1934 1934
             return true;
1935 1935
         }
1936 1936
 
1937
-		$this->set_prop( 'due_date', '' );
1937
+        $this->set_prop( 'due_date', '' );
1938 1938
         return false;
1939 1939
 
1940 1940
     }
1941 1941
 
1942 1942
     /**
1943
-	 * Alias of self::set_due_date().
1944
-	 *
1945
-	 * @since 1.0.19
1946
-	 * @param  string $value New name.
1947
-	 */
1948
-	public function set_date_due( $value ) {
1949
-		$this->set_due_date( $value );
1943
+     * Alias of self::set_due_date().
1944
+     *
1945
+     * @since 1.0.19
1946
+     * @param  string $value New name.
1947
+     */
1948
+    public function set_date_due( $value ) {
1949
+        $this->set_due_date( $value );
1950 1950
     }
1951 1951
 
1952 1952
     /**
1953
-	 * Set date invoice was completed.
1954
-	 *
1955
-	 * @since 1.0.19
1956
-	 * @param string $value Value to set.
1953
+     * Set date invoice was completed.
1954
+     *
1955
+     * @since 1.0.19
1956
+     * @param string $value Value to set.
1957 1957
      * @return bool Whether or not the date was set.
1958
-	 */
1959
-	public function set_completed_date( $value ) {
1958
+     */
1959
+    public function set_completed_date( $value ) {
1960 1960
         $date = strtotime( $value );
1961 1961
 
1962 1962
         if ( $date && $value !== '0000-00-00 00:00:00'  ) {
@@ -1964,29 +1964,29 @@  discard block
 block discarded – undo
1964 1964
             return true;
1965 1965
         }
1966 1966
 
1967
-		$this->set_prop( 'completed_date', '' );
1967
+        $this->set_prop( 'completed_date', '' );
1968 1968
         return false;
1969 1969
 
1970 1970
     }
1971 1971
 
1972 1972
     /**
1973
-	 * Alias of self::set_completed_date().
1974
-	 *
1975
-	 * @since 1.0.19
1976
-	 * @param  string $value New name.
1977
-	 */
1978
-	public function set_date_completed( $value ) {
1979
-		$this->set_completed_date( $value );
1973
+     * Alias of self::set_completed_date().
1974
+     *
1975
+     * @since 1.0.19
1976
+     * @param  string $value New name.
1977
+     */
1978
+    public function set_date_completed( $value ) {
1979
+        $this->set_completed_date( $value );
1980 1980
     }
1981 1981
 
1982 1982
     /**
1983
-	 * Set date when the invoice was last modified.
1984
-	 *
1985
-	 * @since 1.0.19
1986
-	 * @param string $value Value to set.
1983
+     * Set date when the invoice was last modified.
1984
+     *
1985
+     * @since 1.0.19
1986
+     * @param string $value Value to set.
1987 1987
      * @return bool Whether or not the date was set.
1988
-	 */
1989
-	public function set_date_modified( $value ) {
1988
+     */
1989
+    public function set_date_modified( $value ) {
1990 1990
         $date = strtotime( $value );
1991 1991
 
1992 1992
         if ( $date && $value !== '0000-00-00 00:00:00' ) {
@@ -1994,706 +1994,706 @@  discard block
 block discarded – undo
1994 1994
             return true;
1995 1995
         }
1996 1996
 
1997
-		$this->set_prop( 'date_modified', '' );
1997
+        $this->set_prop( 'date_modified', '' );
1998 1998
         return false;
1999 1999
 
2000 2000
     }
2001 2001
 
2002 2002
     /**
2003
-	 * Set the invoice number.
2004
-	 *
2005
-	 * @since 1.0.19
2006
-	 * @param  string $value New number.
2007
-	 */
2008
-	public function set_number( $value ) {
2003
+     * Set the invoice number.
2004
+     *
2005
+     * @since 1.0.19
2006
+     * @param  string $value New number.
2007
+     */
2008
+    public function set_number( $value ) {
2009 2009
         $number = sanitize_text_field( $value );
2010
-		$this->set_prop( 'number', $number );
2010
+        $this->set_prop( 'number', $number );
2011 2011
     }
2012 2012
 
2013 2013
     /**
2014
-	 * Set the invoice type.
2015
-	 *
2016
-	 * @since 1.0.19
2017
-	 * @param  string $value Type.
2018
-	 */
2019
-	public function set_type( $value ) {
2014
+     * Set the invoice type.
2015
+     *
2016
+     * @since 1.0.19
2017
+     * @param  string $value Type.
2018
+     */
2019
+    public function set_type( $value ) {
2020 2020
         $type = sanitize_text_field( str_replace( 'wpi_', '', $value ) );
2021
-		$this->set_prop( 'type', $type );
2022
-	}
2021
+        $this->set_prop( 'type', $type );
2022
+    }
2023 2023
 
2024 2024
     /**
2025
-	 * Set the invoice post type.
2026
-	 *
2027
-	 * @since 1.0.19
2028
-	 * @param  string $value Post type.
2029
-	 */
2030
-	public function set_post_type( $value ) {
2025
+     * Set the invoice post type.
2026
+     *
2027
+     * @since 1.0.19
2028
+     * @param  string $value Post type.
2029
+     */
2030
+    public function set_post_type( $value ) {
2031 2031
         if ( getpaid_is_invoice_post_type( $value ) ) {
2032
-			$this->set_type( $value );
2032
+            $this->set_type( $value );
2033 2033
             $this->set_prop( 'post_type', $value );
2034 2034
         }
2035 2035
     }
2036 2036
 
2037 2037
     /**
2038
-	 * Set the invoice key.
2039
-	 *
2040
-	 * @since 1.0.19
2041
-	 * @param  string $value New key.
2042
-	 */
2043
-	public function set_key( $value ) {
2038
+     * Set the invoice key.
2039
+     *
2040
+     * @since 1.0.19
2041
+     * @param  string $value New key.
2042
+     */
2043
+    public function set_key( $value ) {
2044 2044
         $key = sanitize_text_field( $value );
2045
-		$this->set_prop( 'key', $key );
2045
+        $this->set_prop( 'key', $key );
2046 2046
     }
2047 2047
 
2048 2048
     /**
2049
-	 * Set the invoice mode.
2050
-	 *
2051
-	 * @since 1.0.19
2052
-	 * @param  string $value mode.
2053
-	 */
2054
-	public function set_mode( $value ) {
2049
+     * Set the invoice mode.
2050
+     *
2051
+     * @since 1.0.19
2052
+     * @param  string $value mode.
2053
+     */
2054
+    public function set_mode( $value ) {
2055 2055
         if ( ! in_array( $value, array( 'live', 'test' ) ) ) {
2056 2056
             $this->set_prop( 'value', $value );
2057 2057
         }
2058 2058
     }
2059 2059
 
2060 2060
     /**
2061
-	 * Set the invoice path.
2062
-	 *
2063
-	 * @since 1.0.19
2064
-	 * @param  string $value path.
2065
-	 */
2066
-	public function set_path( $value ) {
2061
+     * Set the invoice path.
2062
+     *
2063
+     * @since 1.0.19
2064
+     * @param  string $value path.
2065
+     */
2066
+    public function set_path( $value ) {
2067 2067
         $this->set_prop( 'path', $value );
2068 2068
     }
2069 2069
 
2070 2070
     /**
2071
-	 * Set the invoice name.
2072
-	 *
2073
-	 * @since 1.0.19
2074
-	 * @param  string $value New name.
2075
-	 */
2076
-	public function set_name( $value ) {
2071
+     * Set the invoice name.
2072
+     *
2073
+     * @since 1.0.19
2074
+     * @param  string $value New name.
2075
+     */
2076
+    public function set_name( $value ) {
2077 2077
         $name = sanitize_text_field( $value );
2078
-		$this->set_prop( 'name', $name );
2078
+        $this->set_prop( 'name', $name );
2079 2079
     }
2080 2080
 
2081 2081
     /**
2082
-	 * Alias of self::set_name().
2083
-	 *
2084
-	 * @since 1.0.19
2085
-	 * @param  string $value New name.
2086
-	 */
2087
-	public function set_title( $value ) {
2088
-		$this->set_name( $value );
2082
+     * Alias of self::set_name().
2083
+     *
2084
+     * @since 1.0.19
2085
+     * @param  string $value New name.
2086
+     */
2087
+    public function set_title( $value ) {
2088
+        $this->set_name( $value );
2089 2089
     }
2090 2090
 
2091 2091
     /**
2092
-	 * Set the invoice description.
2093
-	 *
2094
-	 * @since 1.0.19
2095
-	 * @param  string $value New description.
2096
-	 */
2097
-	public function set_description( $value ) {
2092
+     * Set the invoice description.
2093
+     *
2094
+     * @since 1.0.19
2095
+     * @param  string $value New description.
2096
+     */
2097
+    public function set_description( $value ) {
2098 2098
         $description = wp_kses_post( $value );
2099
-		return $this->set_prop( 'description', $description );
2099
+        return $this->set_prop( 'description', $description );
2100 2100
     }
2101 2101
 
2102 2102
     /**
2103
-	 * Alias of self::set_description().
2104
-	 *
2105
-	 * @since 1.0.19
2106
-	 * @param  string $value New description.
2107
-	 */
2108
-	public function set_excerpt( $value ) {
2109
-		$this->set_description( $value );
2103
+     * Alias of self::set_description().
2104
+     *
2105
+     * @since 1.0.19
2106
+     * @param  string $value New description.
2107
+     */
2108
+    public function set_excerpt( $value ) {
2109
+        $this->set_description( $value );
2110
+    }
2111
+
2112
+    /**
2113
+     * Alias of self::set_description().
2114
+     *
2115
+     * @since 1.0.19
2116
+     * @param  string $value New description.
2117
+     */
2118
+    public function set_summary( $value ) {
2119
+        $this->set_description( $value );
2120
+    }
2121
+
2122
+    /**
2123
+     * Set the receiver of the invoice.
2124
+     *
2125
+     * @since 1.0.19
2126
+     * @param  int $value New author.
2127
+     */
2128
+    public function set_author( $value ) {
2129
+        $user = get_user_by( 'id', (int) $value );
2130
+
2131
+        if ( $user && $user->ID ) {
2132
+            $this->set_prop( 'author', $user->ID );
2133
+            $this->set_prop( 'email', $user->user_email );
2134
+        }
2135
+		
2136
+    }
2137
+
2138
+    /**
2139
+     * Alias of self::set_author().
2140
+     *
2141
+     * @since 1.0.19
2142
+     * @param  int $value New user id.
2143
+     */
2144
+    public function set_user_id( $value ) {
2145
+        $this->set_author( $value );
2110 2146
     }
2111 2147
 
2112 2148
     /**
2113
-	 * Alias of self::set_description().
2114
-	 *
2115
-	 * @since 1.0.19
2116
-	 * @param  string $value New description.
2117
-	 */
2118
-	public function set_summary( $value ) {
2119
-		$this->set_description( $value );
2149
+     * Alias of self::set_author().
2150
+     *
2151
+     * @since 1.0.19
2152
+     * @param  int $value New user id.
2153
+     */
2154
+    public function set_customer_id( $value ) {
2155
+        $this->set_author( $value );
2120 2156
     }
2121 2157
 
2122 2158
     /**
2123
-	 * Set the receiver of the invoice.
2124
-	 *
2125
-	 * @since 1.0.19
2126
-	 * @param  int $value New author.
2127
-	 */
2128
-	public function set_author( $value ) {
2129
-		$user = get_user_by( 'id', (int) $value );
2130
-
2131
-		if ( $user && $user->ID ) {
2132
-			$this->set_prop( 'author', $user->ID );
2133
-			$this->set_prop( 'email', $user->user_email );
2134
-		}
2135
-		
2159
+     * Set the customer's ip.
2160
+     *
2161
+     * @since 1.0.19
2162
+     * @param  string $value ip address.
2163
+     */
2164
+    public function set_ip( $value ) {
2165
+        $this->set_prop( 'ip', $value );
2136 2166
     }
2137 2167
 
2138 2168
     /**
2139
-	 * Alias of self::set_author().
2140
-	 *
2141
-	 * @since 1.0.19
2142
-	 * @param  int $value New user id.
2143
-	 */
2144
-	public function set_user_id( $value ) {
2145
-		$this->set_author( $value );
2169
+     * Alias of self::set_ip().
2170
+     *
2171
+     * @since 1.0.19
2172
+     * @param  string $value ip address.
2173
+     */
2174
+    public function set_user_ip( $value ) {
2175
+        $this->set_ip( $value );
2146 2176
     }
2147 2177
 
2148 2178
     /**
2149
-	 * Alias of self::set_author().
2150
-	 *
2151
-	 * @since 1.0.19
2152
-	 * @param  int $value New user id.
2153
-	 */
2154
-	public function set_customer_id( $value ) {
2155
-		$this->set_author( $value );
2179
+     * Set the customer's first name.
2180
+     *
2181
+     * @since 1.0.19
2182
+     * @param  string $value first name.
2183
+     */
2184
+    public function set_first_name( $value ) {
2185
+        $this->set_prop( 'first_name', $value );
2156 2186
     }
2157 2187
 
2158 2188
     /**
2159
-	 * Set the customer's ip.
2160
-	 *
2161
-	 * @since 1.0.19
2162
-	 * @param  string $value ip address.
2163
-	 */
2164
-	public function set_ip( $value ) {
2165
-		$this->set_prop( 'ip', $value );
2189
+     * Alias of self::set_first_name().
2190
+     *
2191
+     * @since 1.0.19
2192
+     * @param  string $value first name.
2193
+     */
2194
+    public function set_user_first_name( $value ) {
2195
+        $this->set_first_name( $value );
2166 2196
     }
2167 2197
 
2168 2198
     /**
2169
-	 * Alias of self::set_ip().
2170
-	 *
2171
-	 * @since 1.0.19
2172
-	 * @param  string $value ip address.
2173
-	 */
2174
-	public function set_user_ip( $value ) {
2175
-		$this->set_ip( $value );
2199
+     * Alias of self::set_first_name().
2200
+     *
2201
+     * @since 1.0.19
2202
+     * @param  string $value first name.
2203
+     */
2204
+    public function set_customer_first_name( $value ) {
2205
+        $this->set_first_name( $value );
2176 2206
     }
2177 2207
 
2178 2208
     /**
2179
-	 * Set the customer's first name.
2180
-	 *
2181
-	 * @since 1.0.19
2182
-	 * @param  string $value first name.
2183
-	 */
2184
-	public function set_first_name( $value ) {
2185
-		$this->set_prop( 'first_name', $value );
2209
+     * Set the customer's last name.
2210
+     *
2211
+     * @since 1.0.19
2212
+     * @param  string $value last name.
2213
+     */
2214
+    public function set_last_name( $value ) {
2215
+        $this->set_prop( 'last_name', $value );
2186 2216
     }
2187 2217
 
2188 2218
     /**
2189
-	 * Alias of self::set_first_name().
2190
-	 *
2191
-	 * @since 1.0.19
2192
-	 * @param  string $value first name.
2193
-	 */
2194
-	public function set_user_first_name( $value ) {
2195
-		$this->set_first_name( $value );
2219
+     * Alias of self::set_last_name().
2220
+     *
2221
+     * @since 1.0.19
2222
+     * @param  string $value last name.
2223
+     */
2224
+    public function set_user_last_name( $value ) {
2225
+        $this->set_last_name( $value );
2196 2226
     }
2197 2227
 
2198 2228
     /**
2199
-	 * Alias of self::set_first_name().
2200
-	 *
2201
-	 * @since 1.0.19
2202
-	 * @param  string $value first name.
2203
-	 */
2204
-	public function set_customer_first_name( $value ) {
2205
-		$this->set_first_name( $value );
2229
+     * Alias of self::set_last_name().
2230
+     *
2231
+     * @since 1.0.19
2232
+     * @param  string $value last name.
2233
+     */
2234
+    public function set_customer_last_name( $value ) {
2235
+        $this->set_last_name( $value );
2206 2236
     }
2207 2237
 
2208 2238
     /**
2209
-	 * Set the customer's last name.
2210
-	 *
2211
-	 * @since 1.0.19
2212
-	 * @param  string $value last name.
2213
-	 */
2214
-	public function set_last_name( $value ) {
2215
-		$this->set_prop( 'last_name', $value );
2239
+     * Set the customer's phone number.
2240
+     *
2241
+     * @since 1.0.19
2242
+     * @param  string $value phone.
2243
+     */
2244
+    public function set_phone( $value ) {
2245
+        $this->set_prop( 'phone', $value );
2216 2246
     }
2217 2247
 
2218 2248
     /**
2219
-	 * Alias of self::set_last_name().
2220
-	 *
2221
-	 * @since 1.0.19
2222
-	 * @param  string $value last name.
2223
-	 */
2224
-	public function set_user_last_name( $value ) {
2225
-		$this->set_last_name( $value );
2249
+     * Alias of self::set_phone().
2250
+     *
2251
+     * @since 1.0.19
2252
+     * @param  string $value phone.
2253
+     */
2254
+    public function set_user_phone( $value ) {
2255
+        $this->set_phone( $value );
2226 2256
     }
2227 2257
 
2228 2258
     /**
2229
-	 * Alias of self::set_last_name().
2230
-	 *
2231
-	 * @since 1.0.19
2232
-	 * @param  string $value last name.
2233
-	 */
2234
-	public function set_customer_last_name( $value ) {
2235
-		$this->set_last_name( $value );
2259
+     * Alias of self::set_phone().
2260
+     *
2261
+     * @since 1.0.19
2262
+     * @param  string $value phone.
2263
+     */
2264
+    public function set_customer_phone( $value ) {
2265
+        $this->set_phone( $value );
2236 2266
     }
2237 2267
 
2238 2268
     /**
2239
-	 * Set the customer's phone number.
2240
-	 *
2241
-	 * @since 1.0.19
2242
-	 * @param  string $value phone.
2243
-	 */
2244
-	public function set_phone( $value ) {
2245
-		$this->set_prop( 'phone', $value );
2269
+     * Alias of self::set_phone().
2270
+     *
2271
+     * @since 1.0.19
2272
+     * @param  string $value phone.
2273
+     */
2274
+    public function set_phone_number( $value ) {
2275
+        $this->set_phone( $value );
2246 2276
     }
2247 2277
 
2248 2278
     /**
2249
-	 * Alias of self::set_phone().
2250
-	 *
2251
-	 * @since 1.0.19
2252
-	 * @param  string $value phone.
2253
-	 */
2254
-	public function set_user_phone( $value ) {
2255
-		$this->set_phone( $value );
2279
+     * Set the customer's email address.
2280
+     *
2281
+     * @since 1.0.19
2282
+     * @param  string $value email address.
2283
+     */
2284
+    public function set_email( $value ) {
2285
+        $this->set_prop( 'email', $value );
2256 2286
     }
2257 2287
 
2258 2288
     /**
2259
-	 * Alias of self::set_phone().
2260
-	 *
2261
-	 * @since 1.0.19
2262
-	 * @param  string $value phone.
2263
-	 */
2264
-	public function set_customer_phone( $value ) {
2265
-		$this->set_phone( $value );
2289
+     * Alias of self::set_email().
2290
+     *
2291
+     * @since 1.0.19
2292
+     * @param  string $value email address.
2293
+     */
2294
+    public function set_user_email( $value ) {
2295
+        $this->set_email( $value );
2266 2296
     }
2267 2297
 
2268 2298
     /**
2269
-	 * Alias of self::set_phone().
2270
-	 *
2271
-	 * @since 1.0.19
2272
-	 * @param  string $value phone.
2273
-	 */
2274
-	public function set_phone_number( $value ) {
2275
-		$this->set_phone( $value );
2299
+     * Alias of self::set_email().
2300
+     *
2301
+     * @since 1.0.19
2302
+     * @param  string $value email address.
2303
+     */
2304
+    public function set_email_address( $value ) {
2305
+        $this->set_email( $value );
2276 2306
     }
2277 2307
 
2278 2308
     /**
2279
-	 * Set the customer's email address.
2280
-	 *
2281
-	 * @since 1.0.19
2282
-	 * @param  string $value email address.
2283
-	 */
2284
-	public function set_email( $value ) {
2285
-		$this->set_prop( 'email', $value );
2309
+     * Alias of self::set_email().
2310
+     *
2311
+     * @since 1.0.19
2312
+     * @param  string $value email address.
2313
+     */
2314
+    public function set_customer_email( $value ) {
2315
+        $this->set_email( $value );
2286 2316
     }
2287 2317
 
2288 2318
     /**
2289
-	 * Alias of self::set_email().
2290
-	 *
2291
-	 * @since 1.0.19
2292
-	 * @param  string $value email address.
2293
-	 */
2294
-	public function set_user_email( $value ) {
2295
-		$this->set_email( $value );
2319
+     * Set the customer's country.
2320
+     *
2321
+     * @since 1.0.19
2322
+     * @param  string $value country.
2323
+     */
2324
+    public function set_country( $value ) {
2325
+        $this->set_prop( 'country', $value );
2296 2326
     }
2297 2327
 
2298 2328
     /**
2299
-	 * Alias of self::set_email().
2300
-	 *
2301
-	 * @since 1.0.19
2302
-	 * @param  string $value email address.
2303
-	 */
2304
-	public function set_email_address( $value ) {
2305
-		$this->set_email( $value );
2329
+     * Alias of self::set_country().
2330
+     *
2331
+     * @since 1.0.19
2332
+     * @param  string $value country.
2333
+     */
2334
+    public function set_user_country( $value ) {
2335
+        $this->set_country( $value );
2306 2336
     }
2307 2337
 
2308 2338
     /**
2309
-	 * Alias of self::set_email().
2310
-	 *
2311
-	 * @since 1.0.19
2312
-	 * @param  string $value email address.
2313
-	 */
2314
-	public function set_customer_email( $value ) {
2315
-		$this->set_email( $value );
2339
+     * Alias of self::set_country().
2340
+     *
2341
+     * @since 1.0.19
2342
+     * @param  string $value country.
2343
+     */
2344
+    public function set_customer_country( $value ) {
2345
+        $this->set_country( $value );
2316 2346
     }
2317 2347
 
2318 2348
     /**
2319
-	 * Set the customer's country.
2320
-	 *
2321
-	 * @since 1.0.19
2322
-	 * @param  string $value country.
2323
-	 */
2324
-	public function set_country( $value ) {
2325
-		$this->set_prop( 'country', $value );
2349
+     * Set the customer's state.
2350
+     *
2351
+     * @since 1.0.19
2352
+     * @param  string $value state.
2353
+     */
2354
+    public function set_state( $value ) {
2355
+        $this->set_prop( 'state', $value );
2326 2356
     }
2327 2357
 
2328 2358
     /**
2329
-	 * Alias of self::set_country().
2330
-	 *
2331
-	 * @since 1.0.19
2332
-	 * @param  string $value country.
2333
-	 */
2334
-	public function set_user_country( $value ) {
2335
-		$this->set_country( $value );
2359
+     * Alias of self::set_state().
2360
+     *
2361
+     * @since 1.0.19
2362
+     * @param  string $value state.
2363
+     */
2364
+    public function set_user_state( $value ) {
2365
+        $this->set_state( $value );
2336 2366
     }
2337 2367
 
2338 2368
     /**
2339
-	 * Alias of self::set_country().
2340
-	 *
2341
-	 * @since 1.0.19
2342
-	 * @param  string $value country.
2343
-	 */
2344
-	public function set_customer_country( $value ) {
2345
-		$this->set_country( $value );
2369
+     * Alias of self::set_state().
2370
+     *
2371
+     * @since 1.0.19
2372
+     * @param  string $value state.
2373
+     */
2374
+    public function set_customer_state( $value ) {
2375
+        $this->set_state( $value );
2346 2376
     }
2347 2377
 
2348 2378
     /**
2349
-	 * Set the customer's state.
2350
-	 *
2351
-	 * @since 1.0.19
2352
-	 * @param  string $value state.
2353
-	 */
2354
-	public function set_state( $value ) {
2355
-		$this->set_prop( 'state', $value );
2379
+     * Set the customer's city.
2380
+     *
2381
+     * @since 1.0.19
2382
+     * @param  string $value city.
2383
+     */
2384
+    public function set_city( $value ) {
2385
+        $this->set_prop( 'city', $value );
2356 2386
     }
2357 2387
 
2358 2388
     /**
2359
-	 * Alias of self::set_state().
2360
-	 *
2361
-	 * @since 1.0.19
2362
-	 * @param  string $value state.
2363
-	 */
2364
-	public function set_user_state( $value ) {
2365
-		$this->set_state( $value );
2389
+     * Alias of self::set_city().
2390
+     *
2391
+     * @since 1.0.19
2392
+     * @param  string $value city.
2393
+     */
2394
+    public function set_user_city( $value ) {
2395
+        $this->set_city( $value );
2366 2396
     }
2367 2397
 
2368 2398
     /**
2369
-	 * Alias of self::set_state().
2370
-	 *
2371
-	 * @since 1.0.19
2372
-	 * @param  string $value state.
2373
-	 */
2374
-	public function set_customer_state( $value ) {
2375
-		$this->set_state( $value );
2399
+     * Alias of self::set_city().
2400
+     *
2401
+     * @since 1.0.19
2402
+     * @param  string $value city.
2403
+     */
2404
+    public function set_customer_city( $value ) {
2405
+        $this->set_city( $value );
2376 2406
     }
2377 2407
 
2378 2408
     /**
2379
-	 * Set the customer's city.
2380
-	 *
2381
-	 * @since 1.0.19
2382
-	 * @param  string $value city.
2383
-	 */
2384
-	public function set_city( $value ) {
2385
-		$this->set_prop( 'city', $value );
2409
+     * Set the customer's zip code.
2410
+     *
2411
+     * @since 1.0.19
2412
+     * @param  string $value zip.
2413
+     */
2414
+    public function set_zip( $value ) {
2415
+        $this->set_prop( 'zip', $value );
2386 2416
     }
2387 2417
 
2388 2418
     /**
2389
-	 * Alias of self::set_city().
2390
-	 *
2391
-	 * @since 1.0.19
2392
-	 * @param  string $value city.
2393
-	 */
2394
-	public function set_user_city( $value ) {
2395
-		$this->set_city( $value );
2419
+     * Alias of self::set_zip().
2420
+     *
2421
+     * @since 1.0.19
2422
+     * @param  string $value zip.
2423
+     */
2424
+    public function set_user_zip( $value ) {
2425
+        $this->set_zip( $value );
2396 2426
     }
2397 2427
 
2398 2428
     /**
2399
-	 * Alias of self::set_city().
2400
-	 *
2401
-	 * @since 1.0.19
2402
-	 * @param  string $value city.
2403
-	 */
2404
-	public function set_customer_city( $value ) {
2405
-		$this->set_city( $value );
2429
+     * Alias of self::set_zip().
2430
+     *
2431
+     * @since 1.0.19
2432
+     * @param  string $value zip.
2433
+     */
2434
+    public function set_customer_zip( $value ) {
2435
+        $this->set_zip( $value );
2406 2436
     }
2407 2437
 
2408 2438
     /**
2409
-	 * Set the customer's zip code.
2410
-	 *
2411
-	 * @since 1.0.19
2412
-	 * @param  string $value zip.
2413
-	 */
2414
-	public function set_zip( $value ) {
2415
-		$this->set_prop( 'zip', $value );
2439
+     * Set the customer's company.
2440
+     *
2441
+     * @since 1.0.19
2442
+     * @param  string $value company.
2443
+     */
2444
+    public function set_company( $value ) {
2445
+        $this->set_prop( 'company', $value );
2416 2446
     }
2417 2447
 
2418 2448
     /**
2419
-	 * Alias of self::set_zip().
2420
-	 *
2421
-	 * @since 1.0.19
2422
-	 * @param  string $value zip.
2423
-	 */
2424
-	public function set_user_zip( $value ) {
2425
-		$this->set_zip( $value );
2449
+     * Alias of self::set_company().
2450
+     *
2451
+     * @since 1.0.19
2452
+     * @param  string $value company.
2453
+     */
2454
+    public function set_user_company( $value ) {
2455
+        $this->set_company( $value );
2426 2456
     }
2427 2457
 
2428 2458
     /**
2429
-	 * Alias of self::set_zip().
2430
-	 *
2431
-	 * @since 1.0.19
2432
-	 * @param  string $value zip.
2433
-	 */
2434
-	public function set_customer_zip( $value ) {
2435
-		$this->set_zip( $value );
2459
+     * Alias of self::set_company().
2460
+     *
2461
+     * @since 1.0.19
2462
+     * @param  string $value company.
2463
+     */
2464
+    public function set_customer_company( $value ) {
2465
+        $this->set_company( $value );
2436 2466
     }
2437 2467
 
2438 2468
     /**
2439
-	 * Set the customer's company.
2440
-	 *
2441
-	 * @since 1.0.19
2442
-	 * @param  string $value company.
2443
-	 */
2444
-	public function set_company( $value ) {
2445
-		$this->set_prop( 'company', $value );
2469
+     * Set the customer's var number.
2470
+     *
2471
+     * @since 1.0.19
2472
+     * @param  string $value var number.
2473
+     */
2474
+    public function set_vat_number( $value ) {
2475
+        $this->set_prop( 'vat_number', $value );
2446 2476
     }
2447 2477
 
2448 2478
     /**
2449
-	 * Alias of self::set_company().
2450
-	 *
2451
-	 * @since 1.0.19
2452
-	 * @param  string $value company.
2453
-	 */
2454
-	public function set_user_company( $value ) {
2455
-		$this->set_company( $value );
2479
+     * Alias of self::set_vat_number().
2480
+     *
2481
+     * @since 1.0.19
2482
+     * @param  string $value var number.
2483
+     */
2484
+    public function set_user_vat_number( $value ) {
2485
+        $this->set_vat_number( $value );
2456 2486
     }
2457 2487
 
2458 2488
     /**
2459
-	 * Alias of self::set_company().
2460
-	 *
2461
-	 * @since 1.0.19
2462
-	 * @param  string $value company.
2463
-	 */
2464
-	public function set_customer_company( $value ) {
2465
-		$this->set_company( $value );
2489
+     * Alias of self::set_vat_number().
2490
+     *
2491
+     * @since 1.0.19
2492
+     * @param  string $value var number.
2493
+     */
2494
+    public function set_customer_vat_number( $value ) {
2495
+        $this->set_vat_number( $value );
2466 2496
     }
2467 2497
 
2468 2498
     /**
2469
-	 * Set the customer's var number.
2470
-	 *
2471
-	 * @since 1.0.19
2472
-	 * @param  string $value var number.
2473
-	 */
2474
-	public function set_vat_number( $value ) {
2475
-		$this->set_prop( 'vat_number', $value );
2499
+     * Set the customer's vat rate.
2500
+     *
2501
+     * @since 1.0.19
2502
+     * @param  string $value var rate.
2503
+     */
2504
+    public function set_vat_rate( $value ) {
2505
+        $this->set_prop( 'vat_rate', $value );
2476 2506
     }
2477 2507
 
2478 2508
     /**
2479
-	 * Alias of self::set_vat_number().
2480
-	 *
2481
-	 * @since 1.0.19
2482
-	 * @param  string $value var number.
2483
-	 */
2484
-	public function set_user_vat_number( $value ) {
2485
-		$this->set_vat_number( $value );
2509
+     * Alias of self::set_vat_rate().
2510
+     *
2511
+     * @since 1.0.19
2512
+     * @param  string $value var number.
2513
+     */
2514
+    public function set_user_vat_rate( $value ) {
2515
+        $this->set_vat_rate( $value );
2486 2516
     }
2487 2517
 
2488 2518
     /**
2489
-	 * Alias of self::set_vat_number().
2490
-	 *
2491
-	 * @since 1.0.19
2492
-	 * @param  string $value var number.
2493
-	 */
2494
-	public function set_customer_vat_number( $value ) {
2495
-		$this->set_vat_number( $value );
2519
+     * Alias of self::set_vat_rate().
2520
+     *
2521
+     * @since 1.0.19
2522
+     * @param  string $value var number.
2523
+     */
2524
+    public function set_customer_vat_rate( $value ) {
2525
+        $this->set_vat_rate( $value );
2496 2526
     }
2497 2527
 
2498 2528
     /**
2499
-	 * Set the customer's vat rate.
2500
-	 *
2501
-	 * @since 1.0.19
2502
-	 * @param  string $value var rate.
2503
-	 */
2504
-	public function set_vat_rate( $value ) {
2505
-		$this->set_prop( 'vat_rate', $value );
2529
+     * Set the customer's address.
2530
+     *
2531
+     * @since 1.0.19
2532
+     * @param  string $value address.
2533
+     */
2534
+    public function set_address( $value ) {
2535
+        $this->set_prop( 'address', $value );
2506 2536
     }
2507 2537
 
2508 2538
     /**
2509
-	 * Alias of self::set_vat_rate().
2510
-	 *
2511
-	 * @since 1.0.19
2512
-	 * @param  string $value var number.
2513
-	 */
2514
-	public function set_user_vat_rate( $value ) {
2515
-		$this->set_vat_rate( $value );
2539
+     * Alias of self::set_address().
2540
+     *
2541
+     * @since 1.0.19
2542
+     * @param  string $value address.
2543
+     */
2544
+    public function set_user_address( $value ) {
2545
+        $this->set_address( $value );
2516 2546
     }
2517 2547
 
2518 2548
     /**
2519
-	 * Alias of self::set_vat_rate().
2520
-	 *
2521
-	 * @since 1.0.19
2522
-	 * @param  string $value var number.
2523
-	 */
2524
-	public function set_customer_vat_rate( $value ) {
2525
-		$this->set_vat_rate( $value );
2549
+     * Alias of self::set_address().
2550
+     *
2551
+     * @since 1.0.19
2552
+     * @param  string $value address.
2553
+     */
2554
+    public function set_customer_address( $value ) {
2555
+        $this->set_address( $value );
2526 2556
     }
2527 2557
 
2528 2558
     /**
2529
-	 * Set the customer's address.
2530
-	 *
2531
-	 * @since 1.0.19
2532
-	 * @param  string $value address.
2533
-	 */
2534
-	public function set_address( $value ) {
2535
-		$this->set_prop( 'address', $value );
2559
+     * Set whether the customer has viewed the invoice or not.
2560
+     *
2561
+     * @since 1.0.19
2562
+     * @param  int|bool $value confirmed.
2563
+     */
2564
+    public function set_is_viewed( $value ) {
2565
+        $this->set_prop( 'is_viewed', $value );
2536 2566
     }
2537 2567
 
2538 2568
     /**
2539
-	 * Alias of self::set_address().
2540
-	 *
2541
-	 * @since 1.0.19
2542
-	 * @param  string $value address.
2543
-	 */
2544
-	public function set_user_address( $value ) {
2545
-		$this->set_address( $value );
2569
+     * Set extra email recipients.
2570
+     *
2571
+     * @since 1.0.19
2572
+     * @param  string $value email recipients.
2573
+     */
2574
+    public function set_email_cc( $value ) {
2575
+        $this->set_prop( 'email_cc', $value );
2546 2576
     }
2547 2577
 
2548 2578
     /**
2549
-	 * Alias of self::set_address().
2550
-	 *
2551
-	 * @since 1.0.19
2552
-	 * @param  string $value address.
2553
-	 */
2554
-	public function set_customer_address( $value ) {
2555
-		$this->set_address( $value );
2579
+     * Set the invoice template.
2580
+     *
2581
+     * @since 1.0.19
2582
+     * @param  string $value email recipients.
2583
+     */
2584
+    public function set_template( $value ) {
2585
+        if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2586
+            $this->set_prop( 'template', $value );
2587
+        }
2556 2588
     }
2557 2589
 
2558 2590
     /**
2559
-	 * Set whether the customer has viewed the invoice or not.
2560
-	 *
2561
-	 * @since 1.0.19
2562
-	 * @param  int|bool $value confirmed.
2563
-	 */
2564
-	public function set_is_viewed( $value ) {
2565
-		$this->set_prop( 'is_viewed', $value );
2566
-	}
2567
-
2568
-	/**
2569
-	 * Set extra email recipients.
2570
-	 *
2571
-	 * @since 1.0.19
2572
-	 * @param  string $value email recipients.
2573
-	 */
2574
-	public function set_email_cc( $value ) {
2575
-		$this->set_prop( 'email_cc', $value );
2576
-	}
2577
-
2578
-	/**
2579
-	 * Set the invoice template.
2580
-	 *
2581
-	 * @since 1.0.19
2582
-	 * @param  string $value email recipients.
2583
-	 */
2584
-	public function set_template( $value ) {
2585
-		if ( in_array( $value, array( 'quantity', 'hours', 'amount' ) ) ) {
2586
-			$this->set_prop( 'template', $value );
2587
-		}
2588
-	}
2589
-
2590
-	/**
2591
-	 * Set the customer's address confirmed status.
2592
-	 *
2593
-	 * @since 1.0.19
2594
-	 * @param  int|bool $value confirmed.
2595
-	 */
2596
-	public function set_address_confirmed( $value ) {
2597
-		$this->set_prop( 'address_confirmed', $value );
2591
+     * Set the customer's address confirmed status.
2592
+     *
2593
+     * @since 1.0.19
2594
+     * @param  int|bool $value confirmed.
2595
+     */
2596
+    public function set_address_confirmed( $value ) {
2597
+        $this->set_prop( 'address_confirmed', $value );
2598 2598
     }
2599 2599
 
2600 2600
     /**
2601
-	 * Alias of self::set_address_confirmed().
2602
-	 *
2603
-	 * @since 1.0.19
2604
-	 * @param  int|bool $value confirmed.
2605
-	 */
2606
-	public function set_user_address_confirmed( $value ) {
2607
-		$this->set_address_confirmed( $value );
2601
+     * Alias of self::set_address_confirmed().
2602
+     *
2603
+     * @since 1.0.19
2604
+     * @param  int|bool $value confirmed.
2605
+     */
2606
+    public function set_user_address_confirmed( $value ) {
2607
+        $this->set_address_confirmed( $value );
2608 2608
     }
2609 2609
 
2610 2610
     /**
2611
-	 * Alias of self::set_address_confirmed().
2612
-	 *
2613
-	 * @since 1.0.19
2614
-	 * @param  int|bool $value confirmed.
2615
-	 */
2616
-	public function set_customer_address_confirmed( $value ) {
2617
-		$this->set_address_confirmed( $value );
2611
+     * Alias of self::set_address_confirmed().
2612
+     *
2613
+     * @since 1.0.19
2614
+     * @param  int|bool $value confirmed.
2615
+     */
2616
+    public function set_customer_address_confirmed( $value ) {
2617
+        $this->set_address_confirmed( $value );
2618 2618
     }
2619 2619
 
2620 2620
     /**
2621
-	 * Set the invoice sub total.
2622
-	 *
2623
-	 * @since 1.0.19
2624
-	 * @param  float $value sub total.
2625
-	 */
2626
-	public function set_subtotal( $value ) {
2627
-		$this->set_prop( 'subtotal', $value );
2621
+     * Set the invoice sub total.
2622
+     *
2623
+     * @since 1.0.19
2624
+     * @param  float $value sub total.
2625
+     */
2626
+    public function set_subtotal( $value ) {
2627
+        $this->set_prop( 'subtotal', $value );
2628 2628
     }
2629 2629
 
2630 2630
     /**
2631
-	 * Set the invoice discount amount.
2632
-	 *
2633
-	 * @since 1.0.19
2634
-	 * @param  float $value discount total.
2635
-	 */
2636
-	public function set_total_discount( $value ) {
2637
-		$this->set_prop( 'total_discount', $value );
2631
+     * Set the invoice discount amount.
2632
+     *
2633
+     * @since 1.0.19
2634
+     * @param  float $value discount total.
2635
+     */
2636
+    public function set_total_discount( $value ) {
2637
+        $this->set_prop( 'total_discount', $value );
2638 2638
     }
2639 2639
 
2640 2640
     /**
2641
-	 * Alias of self::set_total_discount().
2642
-	 *
2643
-	 * @since 1.0.19
2644
-	 * @param  float $value discount total.
2645
-	 */
2646
-	public function set_discount( $value ) {
2647
-		$this->set_total_discount( $value );
2641
+     * Alias of self::set_total_discount().
2642
+     *
2643
+     * @since 1.0.19
2644
+     * @param  float $value discount total.
2645
+     */
2646
+    public function set_discount( $value ) {
2647
+        $this->set_total_discount( $value );
2648 2648
     }
2649 2649
 
2650 2650
     /**
2651
-	 * Set the invoice tax amount.
2652
-	 *
2653
-	 * @since 1.0.19
2654
-	 * @param  float $value tax total.
2655
-	 */
2656
-	public function set_total_tax( $value ) {
2657
-		$this->set_prop( 'total_tax', $value );
2651
+     * Set the invoice tax amount.
2652
+     *
2653
+     * @since 1.0.19
2654
+     * @param  float $value tax total.
2655
+     */
2656
+    public function set_total_tax( $value ) {
2657
+        $this->set_prop( 'total_tax', $value );
2658 2658
     }
2659 2659
 
2660 2660
     /**
2661
-	 * Alias of self::set_total_tax().
2662
-	 *
2663
-	 * @since 1.0.19
2664
-	 * @param  float $value tax total.
2665
-	 */
2666
-	public function set_tax_total( $value ) {
2667
-		$this->set_total_tax( $value );
2661
+     * Alias of self::set_total_tax().
2662
+     *
2663
+     * @since 1.0.19
2664
+     * @param  float $value tax total.
2665
+     */
2666
+    public function set_tax_total( $value ) {
2667
+        $this->set_total_tax( $value );
2668 2668
     }
2669 2669
 
2670 2670
     /**
2671
-	 * Set the invoice fees amount.
2672
-	 *
2673
-	 * @since 1.0.19
2674
-	 * @param  float $value fees total.
2675
-	 */
2676
-	public function set_total_fees( $value ) {
2677
-		$this->set_prop( 'total_fees', $value );
2671
+     * Set the invoice fees amount.
2672
+     *
2673
+     * @since 1.0.19
2674
+     * @param  float $value fees total.
2675
+     */
2676
+    public function set_total_fees( $value ) {
2677
+        $this->set_prop( 'total_fees', $value );
2678 2678
     }
2679 2679
 
2680 2680
     /**
2681
-	 * Alias of self::set_total_fees().
2682
-	 *
2683
-	 * @since 1.0.19
2684
-	 * @param  float $value fees total.
2685
-	 */
2686
-	public function set_fees_total( $value ) {
2687
-		$this->set_total_fees( $value );
2681
+     * Alias of self::set_total_fees().
2682
+     *
2683
+     * @since 1.0.19
2684
+     * @param  float $value fees total.
2685
+     */
2686
+    public function set_fees_total( $value ) {
2687
+        $this->set_total_fees( $value );
2688 2688
     }
2689 2689
 
2690 2690
     /**
2691
-	 * Set the invoice fees.
2692
-	 *
2693
-	 * @since 1.0.19
2694
-	 * @param  array $value fees.
2695
-	 */
2696
-	public function set_fees( $value ) {
2691
+     * Set the invoice fees.
2692
+     *
2693
+     * @since 1.0.19
2694
+     * @param  array $value fees.
2695
+     */
2696
+    public function set_fees( $value ) {
2697 2697
 
2698 2698
         $this->set_prop( 'fees', array() );
2699 2699
 
@@ -2711,23 +2711,23 @@  discard block
 block discarded – undo
2711 2711
     }
2712 2712
 
2713 2713
     /**
2714
-	 * Set the invoice taxes.
2715
-	 *
2716
-	 * @since 1.0.19
2717
-	 * @param  array $value taxes.
2718
-	 */
2719
-	public function set_taxes( $value ) {
2720
-		$this->set_prop( 'taxes', $value );
2714
+     * Set the invoice taxes.
2715
+     *
2716
+     * @since 1.0.19
2717
+     * @param  array $value taxes.
2718
+     */
2719
+    public function set_taxes( $value ) {
2720
+        $this->set_prop( 'taxes', $value );
2721 2721
     }
2722 2722
 
2723 2723
     /**
2724
-	 * Set the invoice discounts.
2725
-	 *
2726
-	 * @since 1.0.19
2727
-	 * @param  array $value discounts.
2728
-	 */
2729
-	public function set_discounts( $value ) {
2730
-		$this->set_prop( 'discounts', array() );
2724
+     * Set the invoice discounts.
2725
+     *
2726
+     * @since 1.0.19
2727
+     * @param  array $value discounts.
2728
+     */
2729
+    public function set_discounts( $value ) {
2730
+        $this->set_prop( 'discounts', array() );
2731 2731
 
2732 2732
         // Ensure that we have an array.
2733 2733
         if ( ! is_array( $value ) ) {
@@ -2742,12 +2742,12 @@  discard block
 block discarded – undo
2742 2742
     }
2743 2743
 
2744 2744
     /**
2745
-	 * Set the invoice items.
2746
-	 *
2747
-	 * @since 1.0.19
2748
-	 * @param  GetPaid_Form_Item[] $value items.
2749
-	 */
2750
-	public function set_items( $value ) {
2745
+     * Set the invoice items.
2746
+     *
2747
+     * @since 1.0.19
2748
+     * @param  GetPaid_Form_Item[] $value items.
2749
+     */
2750
+    public function set_items( $value ) {
2751 2751
 
2752 2752
         // Remove existing items.
2753 2753
         $this->set_prop( 'items', array() );
@@ -2764,83 +2764,83 @@  discard block
 block discarded – undo
2764 2764
     }
2765 2765
 
2766 2766
     /**
2767
-	 * Set the payment form.
2768
-	 *
2769
-	 * @since 1.0.19
2770
-	 * @param  int $value payment form.
2771
-	 */
2772
-	public function set_payment_form( $value ) {
2773
-		$this->set_prop( 'payment_form', $value );
2767
+     * Set the payment form.
2768
+     *
2769
+     * @since 1.0.19
2770
+     * @param  int $value payment form.
2771
+     */
2772
+    public function set_payment_form( $value ) {
2773
+        $this->set_prop( 'payment_form', $value );
2774 2774
     }
2775 2775
 
2776 2776
     /**
2777
-	 * Set the submission id.
2778
-	 *
2779
-	 * @since 1.0.19
2780
-	 * @param  string $value submission id.
2781
-	 */
2782
-	public function set_submission_id( $value ) {
2783
-		$this->set_prop( 'submission_id', $value );
2777
+     * Set the submission id.
2778
+     *
2779
+     * @since 1.0.19
2780
+     * @param  string $value submission id.
2781
+     */
2782
+    public function set_submission_id( $value ) {
2783
+        $this->set_prop( 'submission_id', $value );
2784 2784
     }
2785 2785
 
2786 2786
     /**
2787
-	 * Set the discount code.
2788
-	 *
2789
-	 * @since 1.0.19
2790
-	 * @param  string $value discount code.
2791
-	 */
2792
-	public function set_discount_code( $value ) {
2793
-		$this->set_prop( 'discount_code', $value );
2787
+     * Set the discount code.
2788
+     *
2789
+     * @since 1.0.19
2790
+     * @param  string $value discount code.
2791
+     */
2792
+    public function set_discount_code( $value ) {
2793
+        $this->set_prop( 'discount_code', $value );
2794 2794
     }
2795 2795
 
2796 2796
     /**
2797
-	 * Set the gateway.
2798
-	 *
2799
-	 * @since 1.0.19
2800
-	 * @param  string $value gateway.
2801
-	 */
2802
-	public function set_gateway( $value ) {
2803
-		$this->set_prop( 'gateway', $value );
2797
+     * Set the gateway.
2798
+     *
2799
+     * @since 1.0.19
2800
+     * @param  string $value gateway.
2801
+     */
2802
+    public function set_gateway( $value ) {
2803
+        $this->set_prop( 'gateway', $value );
2804 2804
     }
2805 2805
 
2806 2806
     /**
2807
-	 * Set the transaction id.
2808
-	 *
2809
-	 * @since 1.0.19
2810
-	 * @param  string $value transaction id.
2811
-	 */
2812
-	public function set_transaction_id( $value ) {
2813
-		$this->set_prop( 'transaction_id', $value );
2807
+     * Set the transaction id.
2808
+     *
2809
+     * @since 1.0.19
2810
+     * @param  string $value transaction id.
2811
+     */
2812
+    public function set_transaction_id( $value ) {
2813
+        $this->set_prop( 'transaction_id', $value );
2814 2814
     }
2815 2815
 
2816 2816
     /**
2817
-	 * Set the currency id.
2818
-	 *
2819
-	 * @since 1.0.19
2820
-	 * @param  string $value currency id.
2821
-	 */
2822
-	public function set_currency( $value ) {
2823
-		$this->set_prop( 'currency', $value );
2817
+     * Set the currency id.
2818
+     *
2819
+     * @since 1.0.19
2820
+     * @param  string $value currency id.
2821
+     */
2822
+    public function set_currency( $value ) {
2823
+        $this->set_prop( 'currency', $value );
2824 2824
     }
2825 2825
 
2826
-	/**
2827
-	 * Set whether to disable taxes.
2828
-	 *
2829
-	 * @since 1.0.19
2830
-	 * @param  bool $value value.
2831
-	 */
2832
-	public function set_disable_taxes( $value ) {
2833
-		$this->set_prop( 'disable_taxes', (bool) $value );
2834
-	}
2826
+    /**
2827
+     * Set whether to disable taxes.
2828
+     *
2829
+     * @since 1.0.19
2830
+     * @param  bool $value value.
2831
+     */
2832
+    public function set_disable_taxes( $value ) {
2833
+        $this->set_prop( 'disable_taxes', (bool) $value );
2834
+    }
2835 2835
 
2836 2836
     /**
2837
-	 * Set the subscription id.
2838
-	 *
2839
-	 * @since 1.0.19
2840
-	 * @param  string $value subscription id.
2841
-	 */
2842
-	public function set_subscription_id( $value ) {
2843
-		$this->set_prop( 'subscription_id', $value );
2837
+     * Set the subscription id.
2838
+     *
2839
+     * @since 1.0.19
2840
+     * @param  string $value subscription id.
2841
+     */
2842
+    public function set_subscription_id( $value ) {
2843
+        $this->set_prop( 'subscription_id', $value );
2844 2844
     }
2845 2845
 
2846 2846
     /*
@@ -2879,12 +2879,12 @@  discard block
 block discarded – undo
2879 2879
      */
2880 2880
     public function is_taxable() {
2881 2881
         return $this->get_disable_taxes();
2882
-	}
2882
+    }
2883 2883
 
2884
-	/**
2885
-	 * @deprecated
2886
-	 */
2887
-	public function has_vat() {
2884
+    /**
2885
+     * @deprecated
2886
+     */
2887
+    public function has_vat() {
2888 2888
         global $wpinv_euvat, $wpi_country;
2889 2889
 
2890 2890
         $requires_vat = false;
@@ -2895,17 +2895,17 @@  discard block
 block discarded – undo
2895 2895
         }
2896 2896
 
2897 2897
         return apply_filters( 'wpinv_invoice_has_vat', $requires_vat, $this );
2898
-	}
2898
+    }
2899 2899
 
2900
-	/**
2901
-	 * Checks to see if the invoice requires payment.
2902
-	 */
2903
-	public function is_free() {
2900
+    /**
2901
+     * Checks to see if the invoice requires payment.
2902
+     */
2903
+    public function is_free() {
2904 2904
         $is_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
2905 2905
 
2906
-		if ( $is_free && $this->is_recurring() ) {
2907
-			$is_free = ! ( (float) wpinv_round_amount( $this->get_recurring_total() ) > 0 );
2908
-		}
2906
+        if ( $is_free && $this->is_recurring() ) {
2907
+            $is_free = ! ( (float) wpinv_round_amount( $this->get_recurring_total() ) > 0 );
2908
+        }
2909 2909
 
2910 2910
         return apply_filters( 'wpinv_invoice_is_free', $is_free, $this );
2911 2911
     }
@@ -2916,38 +2916,38 @@  discard block
 block discarded – undo
2916 2916
     public function is_paid() {
2917 2917
         $is_paid = $this->has_status( array( 'publish', 'wpi-processing', 'wpi-renewal' ) );
2918 2918
         return apply_filters( 'wpinv_invoice_is_paid', $is_paid, $this );
2919
-	}
2919
+    }
2920 2920
 
2921
-	/**
2921
+    /**
2922 2922
      * Checks if the invoice needs payment.
2923 2923
      */
2924
-	public function needs_payment() {
2925
-		$needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2924
+    public function needs_payment() {
2925
+        $needs_payment = ! $this->is_paid() && ! $this->is_refunded() && ! $this->is_free();
2926 2926
         return apply_filters( 'wpinv_needs_payment', $needs_payment, $this );
2927 2927
     }
2928 2928
 
2929
-	/**
2929
+    /**
2930 2930
      * Checks if the invoice is refunded.
2931 2931
      */
2932
-	public function is_refunded() {
2932
+    public function is_refunded() {
2933 2933
         $is_refunded = $this->has_status( 'wpi-refunded' );
2934 2934
         return apply_filters( 'wpinv_invoice_is_refunded', $is_refunded, $this );
2935
-	}
2935
+    }
2936 2936
 
2937
-	/**
2937
+    /**
2938 2938
      * Checks if the invoice is due.
2939 2939
      */
2940
-	public function is_due() {
2941
-		$due_date = $this->get_due_date();
2942
-		return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2943
-	}
2940
+    public function is_due() {
2941
+        $due_date = $this->get_due_date();
2942
+        return empty( $due_date ) ? false : current_time( 'timestamp' ) > strtotime( $due_date );
2943
+    }
2944 2944
 
2945
-	/**
2945
+    /**
2946 2946
      * Checks if the invoice is draft.
2947 2947
      */
2948
-	public function is_draft() {
2948
+    public function is_draft() {
2949 2949
         return $this->has_status( 'draft, auto-draft' );
2950
-	}
2950
+    }
2951 2951
 
2952 2952
     /**
2953 2953
      * Checks if the invoice has a given status.
@@ -2955,9 +2955,9 @@  discard block
 block discarded – undo
2955 2955
     public function has_status( $status ) {
2956 2956
         $status = wpinv_parse_list( $status );
2957 2957
         return apply_filters( 'wpinv_has_status', in_array( $this->get_status(), $status ), $status );
2958
-	}
2958
+    }
2959 2959
 
2960
-	/**
2960
+    /**
2961 2961
      * Checks if the invoice is of a given type.
2962 2962
      */
2963 2963
     public function is_type( $type ) {
@@ -2980,25 +2980,25 @@  discard block
 block discarded – undo
2980 2980
      */
2981 2981
     public function has_free_trial() {
2982 2982
         return $this->is_recurring() && 0 == $this->get_initial_total();
2983
-	}
2983
+    }
2984 2984
 
2985
-	/**
2985
+    /**
2986 2986
      * @deprecated
2987 2987
      */
2988 2988
     public function is_free_trial() {
2989 2989
         $this->has_free_trial();
2990 2990
     }
2991 2991
 
2992
-	/**
2992
+    /**
2993 2993
      * Check if the initial payment if 0.
2994 2994
      *
2995 2995
      */
2996
-	public function is_initial_free() {
2996
+    public function is_initial_free() {
2997 2997
         $is_initial_free = ! ( (float) wpinv_round_amount( $this->get_initial_total() ) > 0 );
2998 2998
         return apply_filters( 'wpinv_invoice_is_initial_free', $is_initial_free, $this->get_cart_details(), $this );
2999 2999
     }
3000 3000
 	
3001
-	/**
3001
+    /**
3002 3002
      * Check if the recurring item has a free trial.
3003 3003
      *
3004 3004
      */
@@ -3011,21 +3011,21 @@  discard block
 block discarded – undo
3011 3011
 
3012 3012
         $item = new WPInv_Item( $this->recurring_item );
3013 3013
         return $item->has_free_trial();
3014
-	}
3014
+    }
3015 3015
 
3016
-	/**
3016
+    /**
3017 3017
      * Check if the free trial is a result of a discount.
3018 3018
      */
3019 3019
     public function is_free_trial_from_discount() {
3020
-		return $this->has_free_trial() && ! $this->item_has_free_trial();
3021
-	}
3020
+        return $this->has_free_trial() && ! $this->item_has_free_trial();
3021
+    }
3022 3022
 	
3023
-	/**
3023
+    /**
3024 3024
      * @deprecated
3025 3025
      */
3026 3026
     public function discount_first_payment_only() {
3027 3027
 
3028
-		$discount_code = $this->get_discount_code();
3028
+        $discount_code = $this->get_discount_code();
3029 3029
         if ( empty( $this->discount_code ) || ! $this->is_recurring() ) {
3030 3030
             return true;
3031 3031
         }
@@ -3057,19 +3057,19 @@  discard block
 block discarded – undo
3057 3057
     public function add_item( $item ) {
3058 3058
 
3059 3059
         // Make sure that it is available for purchase.
3060
-		if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3061
-			return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3060
+        if ( $item->get_id() > 0 && ! $item->can_purchase() ) {
3061
+            return new WP_Error( 'invalid_item', __( 'This item is not available for purchase', 'invoicing' ) );
3062 3062
         }
3063 3063
 
3064 3064
         // Do we have a recurring item?
3065
-		if ( $item->is_recurring() ) {
3065
+        if ( $item->is_recurring() ) {
3066 3066
 
3067
-			// An invoice can only contain one recurring item.
3068
-			if ( ! empty( $this->recurring_item ) ) {
3069
-				return false;
3070
-			}
3067
+            // An invoice can only contain one recurring item.
3068
+            if ( ! empty( $this->recurring_item ) ) {
3069
+                return false;
3070
+            }
3071 3071
 
3072
-			$this->recurring_item = $item->get_id();
3072
+            $this->recurring_item = $item->get_id();
3073 3073
         }
3074 3074
 
3075 3075
         // Invoice id.
@@ -3080,25 +3080,25 @@  discard block
 block discarded – undo
3080 3080
         $items[ $item->get_id() ] = $item;
3081 3081
 
3082 3082
         $this->set_prop( 'items', $items );
3083
-		return true;
3083
+        return true;
3084 3084
     }
3085 3085
 
3086 3086
     /**
3087
-	 * Retrieves a specific item.
3088
-	 *
3089
-	 * @since 1.0.19
3090
-	 */
3091
-	public function get_item( $item_id ) {
3087
+     * Retrieves a specific item.
3088
+     *
3089
+     * @since 1.0.19
3090
+     */
3091
+    public function get_item( $item_id ) {
3092 3092
         $items = $this->get_items();
3093
-		return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3093
+        return ( ! empty( $item_id ) && isset( $items[ $item_id ] ) ) ? $items[ $item_id ] : null;
3094 3094
     }
3095 3095
 
3096 3096
     /**
3097
-	 * Removes a specific item.
3098
-	 *
3099
-	 * @since 1.0.19
3100
-	 */
3101
-	public function remove_item( $item_id ) {
3097
+     * Removes a specific item.
3098
+     *
3099
+     * @since 1.0.19
3100
+     */
3101
+    public function remove_item( $item_id ) {
3102 3102
         $items = $this->get_items();
3103 3103
 
3104 3104
         if ( $item_id == $this->recurring_item ) {
@@ -3126,38 +3126,38 @@  discard block
 block discarded – undo
3126 3126
         if ( isset( $fees[ $fee ] ) && isset( $fees[ $fee ]['amount'] ) ) {
3127 3127
 
3128 3128
             $amount = $fees[ $fee ]['amount'] += $amount;
3129
-			$fees[ $fee ] = array(
3129
+            $fees[ $fee ] = array(
3130 3130
                 'amount'    => $amount,
3131 3131
                 'recurring' => (bool) $recurring,
3132 3132
             );
3133 3133
 
3134
-		} else {
3135
-			$fees[ $fee ] = array(
3134
+        } else {
3135
+            $fees[ $fee ] = array(
3136 3136
                 'amount'    => $amount,
3137 3137
                 'recurring' => (bool) $recurring,
3138 3138
             );
3139
-		}
3139
+        }
3140 3140
 
3141 3141
         $this->set_prop( 'fees', $fee );
3142 3142
 
3143 3143
     }
3144 3144
 
3145 3145
     /**
3146
-	 * Retrieves a specific fee.
3147
-	 *
3148
-	 * @since 1.0.19
3149
-	 */
3150
-	public function get_fee( $fee ) {
3146
+     * Retrieves a specific fee.
3147
+     *
3148
+     * @since 1.0.19
3149
+     */
3150
+    public function get_fee( $fee ) {
3151 3151
         $fees = $this->get_fees();
3152
-		return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3152
+        return isset( $fees[ $fee ] ) ? $fees[ $fee ] : null;
3153 3153
     }
3154 3154
 
3155 3155
     /**
3156
-	 * Removes a specific fee.
3157
-	 *
3158
-	 * @since 1.0.19
3159
-	 */
3160
-	public function remove_fee( $fee ) {
3156
+     * Removes a specific fee.
3157
+     *
3158
+     * @since 1.0.19
3159
+     */
3160
+    public function remove_fee( $fee ) {
3161 3161
         $fees = $this->get_fees();
3162 3162
         if ( isset( $fees[ $fee ] ) ) {
3163 3163
             unset( $fees[ $fee ] );
@@ -3180,44 +3180,44 @@  discard block
 block discarded – undo
3180 3180
         if ( isset( $discounts[ $discount ] ) && isset( $discounts[ $discount ]['amount'] ) ) {
3181 3181
 
3182 3182
             $amount = $discounts[ $discount ]['amount'] += $amount;
3183
-			$discounts[ $discount ] = array(
3183
+            $discounts[ $discount ] = array(
3184 3184
                 'amount'    => $amount,
3185 3185
                 'recurring' => (bool) $recurring,
3186 3186
             );
3187 3187
 
3188
-		} else {
3189
-			$discounts[ $discount ] = array(
3188
+        } else {
3189
+            $discounts[ $discount ] = array(
3190 3190
                 'amount'    => $amount,
3191 3191
                 'recurring' => (bool) $recurring,
3192 3192
             );
3193
-		}
3193
+        }
3194 3194
 
3195 3195
         $this->set_prop( 'discounts', $discount );
3196 3196
 
3197 3197
     }
3198 3198
 
3199 3199
     /**
3200
-	 * Retrieves a specific discount.
3201
-	 *
3202
-	 * @since 1.0.19
3203
-	 */
3204
-	public function get_discount( $discount = false ) {
3200
+     * Retrieves a specific discount.
3201
+     *
3202
+     * @since 1.0.19
3203
+     */
3204
+    public function get_discount( $discount = false ) {
3205 3205
 
3206
-		// Backwards compatibilty.
3207
-		if ( empty( $discount ) ) {
3208
-			return $this->get_total_discount();
3209
-		}
3206
+        // Backwards compatibilty.
3207
+        if ( empty( $discount ) ) {
3208
+            return $this->get_total_discount();
3209
+        }
3210 3210
 
3211 3211
         $discounts = $this->get_discounts();
3212
-		return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3212
+        return isset( $discounts[ $discount ] ) ? $discounts[ $discount ] : null;
3213 3213
     }
3214 3214
 
3215 3215
     /**
3216
-	 * Removes a specific discount.
3217
-	 *
3218
-	 * @since 1.0.19
3219
-	 */
3220
-	public function remove_discount( $discount ) {
3216
+     * Removes a specific discount.
3217
+     *
3218
+     * @since 1.0.19
3219
+     */
3220
+    public function remove_discount( $discount ) {
3221 3221
         $discounts = $this->get_discounts();
3222 3222
         if ( isset( $discounts[ $discount ] ) ) {
3223 3223
             unset( $discounts[ $discount ] );
@@ -3243,38 +3243,38 @@  discard block
 block discarded – undo
3243 3243
         if ( isset( $taxes[ $tax ] ) && isset( $taxes[ $tax ]['amount'] ) ) {
3244 3244
 
3245 3245
             $amount = $taxes[ $tax ]['amount'] += $amount;
3246
-			$taxes[ $tax ] = array(
3246
+            $taxes[ $tax ] = array(
3247 3247
                 'amount'    => $amount,
3248 3248
                 'recurring' => (bool) $recurring,
3249 3249
             );
3250 3250
 
3251
-		} else {
3252
-			$taxes[ $tax ] = array(
3251
+        } else {
3252
+            $taxes[ $tax ] = array(
3253 3253
                 'amount'    => $amount,
3254 3254
                 'recurring' => (bool) $recurring,
3255 3255
             );
3256
-		}
3256
+        }
3257 3257
 
3258 3258
         $this->set_prop( 'taxes', $tax );
3259 3259
 
3260 3260
     }
3261 3261
 
3262 3262
     /**
3263
-	 * Retrieves a specific tax.
3264
-	 *
3265
-	 * @since 1.0.19
3266
-	 */
3267
-	public function get_tax( $tax ) {
3263
+     * Retrieves a specific tax.
3264
+     *
3265
+     * @since 1.0.19
3266
+     */
3267
+    public function get_tax( $tax ) {
3268 3268
         $taxes = $this->get_taxes();
3269
-		return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3269
+        return isset( $taxes[ $tax ] ) ? $taxes[ $tax ] : null;
3270 3270
     }
3271 3271
 
3272 3272
     /**
3273
-	 * Removes a specific tax.
3274
-	 *
3275
-	 * @since 1.0.19
3276
-	 */
3277
-	public function remove_tax( $tax ) {
3273
+     * Removes a specific tax.
3274
+     *
3275
+     * @since 1.0.19
3276
+     */
3277
+    public function remove_tax( $tax ) {
3278 3278
         $taxes = $this->get_discounts();
3279 3279
         if ( isset( $taxes[ $tax ] ) ) {
3280 3280
             unset( $taxes[ $tax ] );
@@ -3283,160 +3283,160 @@  discard block
 block discarded – undo
3283 3283
     }
3284 3284
 
3285 3285
     /**
3286
-	 * Recalculates the invoice subtotal.
3287
-	 *
3288
-	 * @since 1.0.19
3289
-	 * @return float The recalculated subtotal
3290
-	 */
3291
-	public function recalculate_subtotal() {
3286
+     * Recalculates the invoice subtotal.
3287
+     *
3288
+     * @since 1.0.19
3289
+     * @return float The recalculated subtotal
3290
+     */
3291
+    public function recalculate_subtotal() {
3292 3292
         $items     = $this->get_items();
3293
-		$subtotal  = 0;
3294
-		$recurring = 0;
3293
+        $subtotal  = 0;
3294
+        $recurring = 0;
3295 3295
 
3296 3296
         foreach ( $items as $item ) {
3297
-			$subtotal  += $item->get_sub_total();
3298
-			$recurring += $item->get_recurring_sub_total();
3297
+            $subtotal  += $item->get_sub_total();
3298
+            $recurring += $item->get_recurring_sub_total();
3299 3299
         }
3300 3300
 
3301
-		if ( $this->is_renewal() ) {
3302
-			$this->set_subtotal( $recurring );
3303
-		} else {
3304
-			$this->set_subtotal( $subtotal );
3305
-		}
3301
+        if ( $this->is_renewal() ) {
3302
+            $this->set_subtotal( $recurring );
3303
+        } else {
3304
+            $this->set_subtotal( $subtotal );
3305
+        }
3306 3306
 
3307
-		$this->totals['subtotal'] = array(
3308
-			'initial'   => $subtotal,
3309
-			'recurring' => $recurring,
3310
-		);
3307
+        $this->totals['subtotal'] = array(
3308
+            'initial'   => $subtotal,
3309
+            'recurring' => $recurring,
3310
+        );
3311 3311
 
3312 3312
         return $this->is_renewal() ? $recurring : $subtotal;
3313 3313
     }
3314 3314
 
3315 3315
     /**
3316
-	 * Recalculates the invoice discount total.
3317
-	 *
3318
-	 * @since 1.0.19
3319
-	 * @return float The recalculated discount
3320
-	 */
3321
-	public function recalculate_total_discount() {
3316
+     * Recalculates the invoice discount total.
3317
+     *
3318
+     * @since 1.0.19
3319
+     * @return float The recalculated discount
3320
+     */
3321
+    public function recalculate_total_discount() {
3322 3322
         $discounts = $this->get_discounts();
3323
-		$discount  = 0;
3324
-		$recurring = 0;
3323
+        $discount  = 0;
3324
+        $recurring = 0;
3325 3325
 
3326 3326
         foreach ( $discounts as $data ) {
3327 3327
 
3328
-			if ( $data['recurring'] ) {
3329
-				$recurring += $data['amount'];
3330
-			} else {
3331
-				$discount += $data['amount'];
3332
-			}
3328
+            if ( $data['recurring'] ) {
3329
+                $recurring += $data['amount'];
3330
+            } else {
3331
+                $discount += $data['amount'];
3332
+            }
3333 3333
 
3334
-		}
3334
+        }
3335 3335
 
3336
-		if ( $this->is_renewal() ) {
3337
-			$this->set_total_discount( $recurring );
3338
-		} else {
3339
-			$this->set_total_discount( $discount );
3340
-		}
3336
+        if ( $this->is_renewal() ) {
3337
+            $this->set_total_discount( $recurring );
3338
+        } else {
3339
+            $this->set_total_discount( $discount );
3340
+        }
3341 3341
 
3342
-		$this->totals['discount'] = array(
3343
-			'initial'   => $discount,
3344
-			'recurring' => $recurring,
3345
-		);
3342
+        $this->totals['discount'] = array(
3343
+            'initial'   => $discount,
3344
+            'recurring' => $recurring,
3345
+        );
3346 3346
 
3347
-		return $this->is_renewal() ? $recurring : $discount;
3347
+        return $this->is_renewal() ? $recurring : $discount;
3348 3348
 
3349 3349
     }
3350 3350
 
3351 3351
     /**
3352
-	 * Recalculates the invoice tax total.
3353
-	 *
3354
-	 * @since 1.0.19
3355
-	 * @return float The recalculated tax
3356
-	 */
3357
-	public function recalculate_total_tax() {
3352
+     * Recalculates the invoice tax total.
3353
+     *
3354
+     * @since 1.0.19
3355
+     * @return float The recalculated tax
3356
+     */
3357
+    public function recalculate_total_tax() {
3358 3358
         $taxes     = $this->get_taxes();
3359
-		$tax       = 0;
3360
-		$recurring = 0;
3359
+        $tax       = 0;
3360
+        $recurring = 0;
3361 3361
 
3362 3362
         foreach ( $taxes as $data ) {
3363 3363
 
3364
-			if ( $data['recurring'] ) {
3365
-				$recurring += $data['amount'];
3366
-			} else {
3367
-				$tax += $data['amount'];
3368
-			}
3364
+            if ( $data['recurring'] ) {
3365
+                $recurring += $data['amount'];
3366
+            } else {
3367
+                $tax += $data['amount'];
3368
+            }
3369 3369
 
3370
-		}
3370
+        }
3371 3371
 
3372
-		if ( $this->is_renewal() ) {
3373
-			$this->set_total_tax( $recurring );
3374
-		} else {
3375
-			$this->set_total_tax( $tax );
3376
-		}
3372
+        if ( $this->is_renewal() ) {
3373
+            $this->set_total_tax( $recurring );
3374
+        } else {
3375
+            $this->set_total_tax( $tax );
3376
+        }
3377 3377
 
3378
-		$this->totals['tax'] = array(
3379
-			'initial'   => $tax,
3380
-			'recurring' => $recurring,
3381
-		);
3378
+        $this->totals['tax'] = array(
3379
+            'initial'   => $tax,
3380
+            'recurring' => $recurring,
3381
+        );
3382 3382
 
3383
-		return $this->is_renewal() ? $recurring : $tax;
3383
+        return $this->is_renewal() ? $recurring : $tax;
3384 3384
 
3385 3385
     }
3386 3386
 
3387 3387
     /**
3388
-	 * Recalculates the invoice fees total.
3389
-	 *
3390
-	 * @since 1.0.19
3391
-	 * @return float The recalculated fee
3392
-	 */
3393
-	public function recalculate_total_fees() {
3394
-		$fees      = $this->get_fees();
3395
-		$fee       = 0;
3396
-		$recurring = 0;
3388
+     * Recalculates the invoice fees total.
3389
+     *
3390
+     * @since 1.0.19
3391
+     * @return float The recalculated fee
3392
+     */
3393
+    public function recalculate_total_fees() {
3394
+        $fees      = $this->get_fees();
3395
+        $fee       = 0;
3396
+        $recurring = 0;
3397 3397
 
3398 3398
         foreach ( $fees as $data ) {
3399 3399
 
3400
-			if ( $data['recurring'] ) {
3401
-				$recurring += $data['amount'];
3402
-			} else {
3403
-				$fee += $data['amount'];
3404
-			}
3400
+            if ( $data['recurring'] ) {
3401
+                $recurring += $data['amount'];
3402
+            } else {
3403
+                $fee += $data['amount'];
3404
+            }
3405 3405
 
3406
-		}
3406
+        }
3407 3407
 
3408 3408
         if ( $this->is_renewal() ) {
3409
-			$this->set_total_fees( $recurring );
3410
-		} else {
3411
-			$this->set_total_fees( $fee );
3412
-		}
3409
+            $this->set_total_fees( $recurring );
3410
+        } else {
3411
+            $this->set_total_fees( $fee );
3412
+        }
3413 3413
 
3414
-		$this->totals['fee'] = array(
3415
-			'initial'   => $fee,
3416
-			'recurring' => $recurring,
3417
-		);
3414
+        $this->totals['fee'] = array(
3415
+            'initial'   => $fee,
3416
+            'recurring' => $recurring,
3417
+        );
3418 3418
 
3419 3419
         $this->set_total_fees( $fee );
3420 3420
         return $this->is_renewal() ? $recurring : $fee;
3421 3421
     }
3422 3422
 
3423 3423
     /**
3424
-	 * Recalculates the invoice total.
3425
-	 *
3426
-	 * @since 1.0.19
3424
+     * Recalculates the invoice total.
3425
+     *
3426
+     * @since 1.0.19
3427 3427
      * @return float The invoice total
3428
-	 */
3429
-	public function recalculate_total() {
3428
+     */
3429
+    public function recalculate_total() {
3430 3430
         $this->recalculate_subtotal();
3431 3431
         $this->recalculate_total_fees();
3432 3432
         $this->recalculate_total_discount();
3433 3433
         $this->recalculate_total_tax();
3434
-		return $this->get_total();
3435
-	}
3434
+        return $this->get_total();
3435
+    }
3436 3436
 
3437
-	/**
3438
-	 * @deprecated
3439
-	 */
3437
+    /**
3438
+     * @deprecated
3439
+     */
3440 3440
     public function recalculate_totals( $temp = false ) {
3441 3441
         $this->update_items( $temp );
3442 3442
         $this->save( true );
@@ -3500,9 +3500,9 @@  discard block
 block discarded – undo
3500 3500
         }
3501 3501
 
3502 3502
         return $note_id;
3503
-	}
3503
+    }
3504 3504
 
3505
-	/**
3505
+    /**
3506 3506
      * Generates a unique key for the invoice.
3507 3507
      */
3508 3508
     public function generate_key( $string = '' ) {
@@ -3522,106 +3522,106 @@  discard block
 block discarded – undo
3522 3522
             $number = wpinv_get_next_invoice_number( $this->post_type );
3523 3523
         }
3524 3524
 
3525
-		$number = wpinv_format_invoice_number( $number, $this->post_type );
3525
+        $number = wpinv_format_invoice_number( $number, $this->post_type );
3526 3526
 
3527
-		return $number;
3528
-	}
3527
+        return $number;
3528
+    }
3529 3529
 
3530
-	/**
3531
-	 * Handle the status transition.
3532
-	 */
3533
-	protected function status_transition() {
3534
-		$status_transition = $this->status_transition;
3530
+    /**
3531
+     * Handle the status transition.
3532
+     */
3533
+    protected function status_transition() {
3534
+        $status_transition = $this->status_transition;
3535 3535
 
3536
-		// Reset status transition variable.
3537
-		$this->status_transition = false;
3536
+        // Reset status transition variable.
3537
+        $this->status_transition = false;
3538 3538
 
3539
-		if ( $status_transition ) {
3540
-			try {
3539
+        if ( $status_transition ) {
3540
+            try {
3541 3541
 
3542
-				// Fire a hook for the status change.
3543
-				do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
3542
+                // Fire a hook for the status change.
3543
+                do_action( 'getpaid_invoice_status_' . $status_transition['to'], $this->get_id(), $this, $status_transition );
3544 3544
 
3545
-				// @deprecated this is deprecated and will be removed in the future.
3546
-				do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3545
+                // @deprecated this is deprecated and will be removed in the future.
3546
+                do_action( 'wpinv_status_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3547 3547
 
3548
-				if ( ! empty( $status_transition['from'] ) ) {
3548
+                if ( ! empty( $status_transition['from'] ) ) {
3549 3549
 
3550
-					/* translators: 1: old invoice status 2: new invoice status */
3551
-					$transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3550
+                    /* translators: 1: old invoice status 2: new invoice status */
3551
+                    $transition_note = sprintf( __( 'Status changed from %1$s to %2$s.', 'invoicing' ), wpinv_status_nicename( $status_transition['from'] ), wpinv_status_nicename( $status_transition['to'] ) );
3552 3552
 
3553
-					// Fire another hook.
3554
-					do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
3555
-					do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
3553
+                    // Fire another hook.
3554
+                    do_action( 'getpaid_invoice_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $this );
3555
+                    do_action( 'getpaid_invoice_status_changed', $this->get_id(), $status_transition['from'], $status_transition['to'], $this );
3556 3556
 
3557
-					// @deprecated this is deprecated and will be removed in the future.
3558
-					do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3557
+                    // @deprecated this is deprecated and will be removed in the future.
3558
+                    do_action( 'wpinv_status_' . $status_transition['from'] . '_to_' . $status_transition['to'], $this->get_id(), $status_transition['from'] );
3559 3559
 
3560
-					// Note the transition occurred.
3561
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3560
+                    // Note the transition occurred.
3561
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3562 3562
 
3563
-					// Work out if this was for a payment, and trigger a payment_status hook instead.
3564
-					if (
3565
-						in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3566
-						&& in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3567
-					) {
3568
-						do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition );
3569
-					}
3570
-				} else {
3571
-					/* translators: %s: new invoice status */
3572
-					$transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3563
+                    // Work out if this was for a payment, and trigger a payment_status hook instead.
3564
+                    if (
3565
+                        in_array( $status_transition['from'], array( 'wpi-cancelled', 'wpi-pending', 'wpi-failed', 'wpi-refunded' ), true )
3566
+                        && in_array( $status_transition['to'], array( 'publish', 'wpi-processing', 'wpi-renewal' ), true )
3567
+                    ) {
3568
+                        do_action( 'getpaid_invoice_payment_status_changed', $this->get_id(), $this, $status_transition );
3569
+                    }
3570
+                } else {
3571
+                    /* translators: %s: new invoice status */
3572
+                    $transition_note = sprintf( __( 'Status set to %s.', 'invoicing' ), wpinv_status_nicename( $status_transition['to'] ) );
3573 3573
 
3574
-					// Note the transition occurred.
3575
-					$this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3574
+                    // Note the transition occurred.
3575
+                    $this->add_note( trim( $status_transition['note'] . ' ' . $transition_note ), 0, $status_transition['manual'] );
3576 3576
 
3577
-				}
3578
-			} catch ( Exception $e ) {
3579
-				$this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3580
-			}
3581
-		}
3582
-	}
3577
+                }
3578
+            } catch ( Exception $e ) {
3579
+                $this->add_note( __( 'Error during status transition.', 'invoicing' ) . ' ' . $e->getMessage() );
3580
+            }
3581
+        }
3582
+    }
3583 3583
 
3584
-	/**
3585
-	 * Updates an invoice status.
3586
-	 */
3587
-	public function update_status( $new_status = false, $note = '', $manual = false ) {
3584
+    /**
3585
+     * Updates an invoice status.
3586
+     */
3587
+    public function update_status( $new_status = false, $note = '', $manual = false ) {
3588 3588
 
3589
-		// Fires before updating a status.
3590
-		do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3589
+        // Fires before updating a status.
3590
+        do_action( 'wpinv_before_invoice_status_change', $this->get_id(), $new_status, $this->get_status( 'edit' ) );
3591 3591
 
3592
-		// Update the status.
3593
-		$this->set_status( $new_status, $note, $manual );
3592
+        // Update the status.
3593
+        $this->set_status( $new_status, $note, $manual );
3594 3594
 
3595
-		// Save the order.
3596
-		return $this->save();
3595
+        // Save the order.
3596
+        return $this->save();
3597 3597
 
3598
-	}
3598
+    }
3599 3599
 
3600
-	/**
3601
-	 * @deprecated
3602
-	 */
3603
-	public function refresh_item_ids() {
3600
+    /**
3601
+     * @deprecated
3602
+     */
3603
+    public function refresh_item_ids() {
3604 3604
         $item_ids = implode( ',', array_unique( array_keys( $this->get_items() ) ) );
3605 3605
         update_post_meta( $this->get_id(), '_wpinv_item_ids', $item_ids );
3606
-	}
3606
+    }
3607 3607
 
3608
-	/**
3609
-	 * @deprecated
3610
-	 */
3611
-	public function update_items( $temp = false ) {
3608
+    /**
3609
+     * @deprecated
3610
+     */
3611
+    public function update_items( $temp = false ) {
3612 3612
 
3613
-		$this->set_items( $this->get_items() );
3613
+        $this->set_items( $this->get_items() );
3614 3614
 
3615
-		if ( ! $temp ) {
3616
-			$this->save();
3617
-		}
3615
+        if ( ! $temp ) {
3616
+            $this->save();
3617
+        }
3618 3618
 
3619 3619
         return $this;
3620
-	}
3620
+    }
3621 3621
 
3622
-	/**
3623
-	 * @deprecated
3624
-	 */
3622
+    /**
3623
+     * @deprecated
3624
+     */
3625 3625
     public function validate_discount() {
3626 3626
 
3627 3627
         $discount_code = $this->get_discount_code();
@@ -3637,25 +3637,25 @@  discard block
 block discarded – undo
3637 3637
 
3638 3638
     }
3639 3639
 
3640
-	/**
3641
-	 * Refunds an invoice.
3642
-	 */
3640
+    /**
3641
+     * Refunds an invoice.
3642
+     */
3643 3643
     public function refund() {
3644
-		$this->set_status( 'wpi-refunded' );
3644
+        $this->set_status( 'wpi-refunded' );
3645 3645
         $this->save();
3646 3646
     }
3647 3647
 
3648
-	/**
3649
-	 * Save data to the database.
3650
-	 *
3651
-	 * @since 1.0.19
3652
-	 * @return int invoice ID
3653
-	 */
3654
-	public function save() {
3655
-		$this->maybe_set_date_paid();
3656
-		parent::save();
3657
-		$this->status_transition();
3658
-		return $this->get_id();
3659
-	}
3648
+    /**
3649
+     * Save data to the database.
3650
+     *
3651
+     * @since 1.0.19
3652
+     * @return int invoice ID
3653
+     */
3654
+    public function save() {
3655
+        $this->maybe_set_date_paid();
3656
+        parent::save();
3657
+        $this->status_transition();
3658
+        return $this->get_id();
3659
+    }
3660 3660
 
3661 3661
 }
Please login to merge, or discard this patch.
includes/wpinv-helper-functions.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -96,13 +96,13 @@  discard block
 block discarded – undo
96 96
  * @return array
97 97
  */
98 98
 function wpinv_get_invoice_statuses( $draft = false, $trashed = false, $invoice = false ) {
99
-	$invoice_statuses = array(
100
-		'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
99
+    $invoice_statuses = array(
100
+        'wpi-pending'    => _x( 'Pending payment', 'Invoice status', 'invoicing' ),
101 101
         'publish'        => _x( 'Paid', 'Invoice status', 'invoicing' ),
102 102
         'wpi-processing' => _x( 'Processing', 'Invoice status', 'invoicing' ),
103
-		'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
104
-		'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
105
-		'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
103
+        'wpi-onhold'     => _x( 'On hold', 'Invoice status', 'invoicing' ),
104
+        'wpi-cancelled'  => _x( 'Cancelled', 'Invoice status', 'invoicing' ),
105
+        'wpi-refunded'   => _x( 'Refunded', 'Invoice status', 'invoicing' ),
106 106
         'wpi-failed'     => _x( 'Failed', 'Invoice status', 'invoicing' ),
107 107
         'wpi-renewal'    => _x( 'Renewal Payment', 'Invoice status', 'invoicing' ),
108 108
     );
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
         $invoice_statuses['trash'] = __( 'Trash', 'invoicing' );
116 116
     }
117 117
 
118
-	return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
118
+    return apply_filters( 'wpinv_statuses', $invoice_statuses, $invoice );
119 119
 }
120 120
 
121 121
 function wpinv_status_nicename( $status ) {
@@ -712,13 +712,13 @@  discard block
 block discarded – undo
712 712
  * @param mixed  $value Value.
713 713
  */
714 714
 function getpaid_maybe_define_constant( $name, $value ) {
715
-	if ( ! defined( $name ) ) {
716
-		define( $name, $value );
717
-	}
715
+    if ( ! defined( $name ) ) {
716
+        define( $name, $value );
717
+    }
718 718
 }
719 719
 
720 720
 function wpinv_get_php_arg_separator_output() {
721
-	return ini_get( 'arg_separator.output' );
721
+    return ini_get( 'arg_separator.output' );
722 722
 }
723 723
 
724 724
 function wpinv_rgb_from_hex( $color ) {
@@ -1067,11 +1067,11 @@  discard block
 block discarded – undo
1067 1067
         $list = array();
1068 1068
     }
1069 1069
 
1070
-	if ( ! is_array( $list ) ) {
1071
-		return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
1072
-	}
1070
+    if ( ! is_array( $list ) ) {
1071
+        return preg_split( '/[\s,]+/', $list, -1, PREG_SPLIT_NO_EMPTY );
1072
+    }
1073 1073
 
1074
-	return $list;
1074
+    return $list;
1075 1075
 }
1076 1076
 
1077 1077
 /**
@@ -1091,9 +1091,9 @@  discard block
 block discarded – undo
1091 1091
     }
1092 1092
 
1093 1093
     $data = apply_filters( "wpinv_get_$key", include WPINV_PLUGIN_DIR . "includes/data/$key.php" );
1094
-	wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
1094
+    wp_cache_set( "wpinv-data-$key", $data, 'wpinv' );
1095 1095
 
1096
-	return $data;
1096
+    return $data;
1097 1097
 }
1098 1098
 
1099 1099
 /**
@@ -1122,17 +1122,17 @@  discard block
 block discarded – undo
1122 1122
  */
1123 1123
 function wpinv_clean( $var ) {
1124 1124
 
1125
-	if ( is_array( $var ) ) {
1126
-		return array_map( 'wpinv_clean', $var );
1125
+    if ( is_array( $var ) ) {
1126
+        return array_map( 'wpinv_clean', $var );
1127 1127
     }
1128 1128
 
1129 1129
     if ( is_object( $var ) ) {
1130
-		$object_vars = get_object_vars( $var );
1131
-		foreach ( $object_vars as $property_name => $property_value ) {
1132
-			$var->$property_name = wpinv_clean( $property_value );
1130
+        $object_vars = get_object_vars( $var );
1131
+        foreach ( $object_vars as $property_name => $property_value ) {
1132
+            $var->$property_name = wpinv_clean( $property_value );
1133 1133
         }
1134 1134
         return $var;
1135
-	}
1135
+    }
1136 1136
     
1137 1137
     return is_string( $var ) ? sanitize_text_field( $var ) : $var;
1138 1138
 }
@@ -1145,7 +1145,7 @@  discard block
 block discarded – undo
1145 1145
  */
1146 1146
 function getpaid_convert_price_string_to_options( $str ) {
1147 1147
 
1148
-	$raw_options = array_map( 'trim', explode( ',', $str ) );
1148
+    $raw_options = array_map( 'trim', explode( ',', $str ) );
1149 1149
     $options     = array();
1150 1150
 
1151 1151
     foreach ( $raw_options as $option ) {
Please login to merge, or discard this patch.
includes/wpinv-gateway-functions.php 1 patch
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -286,26 +286,26 @@  discard block
 block discarded – undo
286 286
 }
287 287
 
288 288
 function wpinv_get_chosen_gateway( $invoice_id = 0 ) {
289
-	$gateways = array_keys( wpinv_get_enabled_payment_gateways() );
289
+    $gateways = array_keys( wpinv_get_enabled_payment_gateways() );
290 290
 
291 291
     $chosen = false;
292 292
     if ( $invoice_id > 0 && $invoice = wpinv_get_invoice( $invoice_id ) ) {
293 293
         $chosen = $invoice->get_gateway();
294 294
     }
295 295
 
296
-	$chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
296
+    $chosen   = isset( $_REQUEST['payment-mode'] ) ? sanitize_text_field( $_REQUEST['payment-mode'] ) : $chosen;
297 297
 
298
-	if ( false !== $chosen ) {
299
-		$chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
300
-	}
298
+    if ( false !== $chosen ) {
299
+        $chosen = preg_replace('/[^a-zA-Z0-9-_]+/', '', $chosen );
300
+    }
301 301
 
302
-	if ( ! empty ( $chosen ) ) {
303
-		$enabled_gateway = urldecode( $chosen );
304
-	} else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
305
-		$enabled_gateway = 'manual';
306
-	} else {
307
-		$enabled_gateway = wpinv_get_default_gateway();
308
-	}
302
+    if ( ! empty ( $chosen ) ) {
303
+        $enabled_gateway = urldecode( $chosen );
304
+    } else if (  !empty( $invoice ) && (float)$invoice->get_subtotal() <= 0 ) {
305
+        $enabled_gateway = 'manual';
306
+    } else {
307
+        $enabled_gateway = wpinv_get_default_gateway();
308
+    }
309 309
     
310 310
     if ( !wpinv_is_gateway_active( $enabled_gateway ) && !empty( $gateways ) ) {
311 311
         if(wpinv_is_gateway_active( wpinv_get_default_gateway()) ){
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 
317 317
     }
318 318
 
319
-	return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
319
+    return apply_filters( 'wpinv_chosen_gateway', $enabled_gateway );
320 320
 }
321 321
 
322 322
 function wpinv_record_gateway_error( $title = '', $message = '', $parent = 0 ) {
@@ -324,21 +324,21 @@  discard block
 block discarded – undo
324 324
 }
325 325
 
326 326
 function wpinv_count_sales_by_gateway( $gateway_id = 'paypal', $status = 'publish' ) {
327
-	$ret  = 0;
328
-	$args = array(
329
-		'meta_key'    => '_wpinv_gateway',
330
-		'meta_value'  => $gateway_id,
331
-		'nopaging'    => true,
332
-		'post_type'   => 'wpi_invoice',
333
-		'post_status' => $status,
334
-		'fields'      => 'ids'
335
-	);
336
-
337
-	$payments = new WP_Query( $args );
338
-
339
-	if( $payments )
340
-		$ret = $payments->post_count;
341
-	return $ret;
327
+    $ret  = 0;
328
+    $args = array(
329
+        'meta_key'    => '_wpinv_gateway',
330
+        'meta_value'  => $gateway_id,
331
+        'nopaging'    => true,
332
+        'post_type'   => 'wpi_invoice',
333
+        'post_status' => $status,
334
+        'fields'      => 'ids'
335
+    );
336
+
337
+    $payments = new WP_Query( $args );
338
+
339
+    if( $payments )
340
+        $ret = $payments->post_count;
341
+    return $ret;
342 342
 }
343 343
 
344 344
 function wpinv_settings_update_gateways( $input ) {
@@ -900,20 +900,20 @@  discard block
 block discarded – undo
900 900
 }
901 901
 
902 902
 function wpinv_checkout_get_cc_info() {
903
-	$cc_info = array();
904
-	$cc_info['card_name']      = isset( $_POST['card_name'] )       ? sanitize_text_field( $_POST['card_name'] )       : '';
905
-	$cc_info['card_number']    = isset( $_POST['card_number'] )     ? sanitize_text_field( $_POST['card_number'] )     : '';
906
-	$cc_info['card_cvc']       = isset( $_POST['card_cvc'] )        ? sanitize_text_field( $_POST['card_cvc'] )        : '';
907
-	$cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] )  ? sanitize_text_field( $_POST['card_exp_month'] )  : '';
908
-	$cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] )   ? sanitize_text_field( $_POST['card_exp_year'] )   : '';
909
-	$cc_info['card_address']   = isset( $_POST['wpinv_address'] )  ? sanitize_text_field( $_POST['wpinv_address'] ) : '';
910
-	$cc_info['card_city']      = isset( $_POST['wpinv_city'] )     ? sanitize_text_field( $_POST['wpinv_city'] )    : '';
911
-	$cc_info['card_state']     = isset( $_POST['wpinv_state'] )    ? sanitize_text_field( $_POST['wpinv_state'] )   : '';
912
-	$cc_info['card_country']   = isset( $_POST['wpinv_country'] )  ? sanitize_text_field( $_POST['wpinv_country'] ) : '';
913
-	$cc_info['card_zip']       = isset( $_POST['wpinv_zip'] )      ? sanitize_text_field( $_POST['wpinv_zip'] )     : '';
914
-
915
-	// Return cc info
916
-	return $cc_info;
903
+    $cc_info = array();
904
+    $cc_info['card_name']      = isset( $_POST['card_name'] )       ? sanitize_text_field( $_POST['card_name'] )       : '';
905
+    $cc_info['card_number']    = isset( $_POST['card_number'] )     ? sanitize_text_field( $_POST['card_number'] )     : '';
906
+    $cc_info['card_cvc']       = isset( $_POST['card_cvc'] )        ? sanitize_text_field( $_POST['card_cvc'] )        : '';
907
+    $cc_info['card_exp_month'] = isset( $_POST['card_exp_month'] )  ? sanitize_text_field( $_POST['card_exp_month'] )  : '';
908
+    $cc_info['card_exp_year']  = isset( $_POST['card_exp_year'] )   ? sanitize_text_field( $_POST['card_exp_year'] )   : '';
909
+    $cc_info['card_address']   = isset( $_POST['wpinv_address'] )  ? sanitize_text_field( $_POST['wpinv_address'] ) : '';
910
+    $cc_info['card_city']      = isset( $_POST['wpinv_city'] )     ? sanitize_text_field( $_POST['wpinv_city'] )    : '';
911
+    $cc_info['card_state']     = isset( $_POST['wpinv_state'] )    ? sanitize_text_field( $_POST['wpinv_state'] )   : '';
912
+    $cc_info['card_country']   = isset( $_POST['wpinv_country'] )  ? sanitize_text_field( $_POST['wpinv_country'] ) : '';
913
+    $cc_info['card_zip']       = isset( $_POST['wpinv_zip'] )      ? sanitize_text_field( $_POST['wpinv_zip'] )     : '';
914
+
915
+    // Return cc info
916
+    return $cc_info;
917 917
 }
918 918
 
919 919
 /**
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
         $required_fields  = wpinv_checkout_required_fields();
970 970
 
971 971
         // Loop through required fields and show error messages
972
-         if ( !empty( $required_fields ) ) {
972
+            if ( !empty( $required_fields ) ) {
973 973
             foreach ( $required_fields as $field_name => $value ) {
974 974
                 if ( in_array( $value, $required_fields ) && empty( $_POST[ 'wpinv_' . $field_name ] ) ) {
975 975
                     wpinv_set_error( $value['error_id'], $value['error_message'] );
@@ -1129,7 +1129,7 @@  discard block
 block discarded – undo
1129 1129
         $response['data']['taxf']       = $invoice->get_tax( true );
1130 1130
         $response['data']['total']      = $invoice->get_total();
1131 1131
         $response['data']['totalf']     = $invoice->get_total( true );
1132
-	    $response['data']['free']       = $invoice->is_free() && ( ! ( (float) $response['data']['total'] > 0 ) || $invoice->has_free_trial() ) ? true : false;
1132
+        $response['data']['free']       = $invoice->is_free() && ( ! ( (float) $response['data']['total'] > 0 ) || $invoice->has_free_trial() ) ? true : false;
1133 1133
 
1134 1134
         wp_send_json( $response );
1135 1135
     }
@@ -1199,8 +1199,8 @@  discard block
 block discarded – undo
1199 1199
     // Allow themes and plugins to hook before the gateway
1200 1200
     do_action( 'wpinv_checkout_before_gateway', $_POST, $user_info, $valid_data );
1201 1201
 
1202
-     // If it is free, abort.
1203
-     if ( $invoice->is_free() && ( ! $invoice->is_recurring() || 0 ==  $invoice->get_recurring_details( 'total' ) ) ) {
1202
+        // If it is free, abort.
1203
+        if ( $invoice->is_free() && ( ! $invoice->is_recurring() || 0 ==  $invoice->get_recurring_details( 'total' ) ) ) {
1204 1204
         $invoice_data['gateway'] = 'manual';
1205 1205
         $_POST['wpi-gateway'] = 'manual';
1206 1206
     }
Please login to merge, or discard this patch.
includes/wpinv-general-functions.php 1 patch
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -31,36 +31,36 @@  discard block
 block discarded – undo
31 31
 }
32 32
 
33 33
 function wpinv_can_checkout() {
34
-	$can_checkout = true; // Always true for now
34
+    $can_checkout = true; // Always true for now
35 35
 
36
-	return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
36
+    return (bool) apply_filters( 'wpinv_can_checkout', $can_checkout );
37 37
 }
38 38
 
39 39
 function wpinv_get_success_page_uri() {
40
-	$page_id = wpinv_get_option( 'success_page', 0 );
41
-	$page_id = absint( $page_id );
40
+    $page_id = wpinv_get_option( 'success_page', 0 );
41
+    $page_id = absint( $page_id );
42 42
 
43
-	return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
43
+    return apply_filters( 'wpinv_get_success_page_uri', get_permalink( $page_id ) );
44 44
 }
45 45
 
46 46
 function wpinv_get_history_page_uri() {
47
-	$page_id = wpinv_get_option( 'invoice_history_page', 0 );
48
-	$page_id = absint( $page_id );
47
+    $page_id = wpinv_get_option( 'invoice_history_page', 0 );
48
+    $page_id = absint( $page_id );
49 49
 
50
-	return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
50
+    return apply_filters( 'wpinv_get_history_page_uri', get_permalink( $page_id ) );
51 51
 }
52 52
 
53 53
 function wpinv_is_success_page() {
54
-	$is_success_page = wpinv_get_option( 'success_page', false );
55
-	$is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false;
54
+    $is_success_page = wpinv_get_option( 'success_page', false );
55
+    $is_success_page = ! empty( $is_success_page ) ? is_page( $is_success_page ) : false;
56 56
 
57
-	return apply_filters( 'wpinv_is_success_page', $is_success_page );
57
+    return apply_filters( 'wpinv_is_success_page', $is_success_page );
58 58
 }
59 59
 
60 60
 function wpinv_is_invoice_history_page() {
61
-	$ret = wpinv_get_option( 'invoice_history_page', false );
62
-	$ret = $ret ? is_page( $ret ) : false;
63
-	return apply_filters( 'wpinv_is_invoice_history_page', $ret );
61
+    $ret = wpinv_get_option( 'invoice_history_page', false );
62
+    $ret = $ret ? is_page( $ret ) : false;
63
+    return apply_filters( 'wpinv_is_invoice_history_page', $ret );
64 64
 }
65 65
 
66 66
 function wpinv_is_subscriptions_history_page() {
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 }
71 71
 
72 72
 function wpinv_send_to_success_page( $args = null ) {
73
-	$redirect = wpinv_get_success_page_uri();
73
+    $redirect = wpinv_get_success_page_uri();
74 74
     
75 75
     if ( !empty( $args ) ) {
76 76
         // Check for backward compatibility
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 }
91 91
 
92 92
 function wpinv_send_to_failed_page( $args = null ) {
93
-	$redirect = wpinv_get_failed_transaction_uri();
93
+    $redirect = wpinv_get_failed_transaction_uri();
94 94
     
95 95
     if ( !empty( $args ) ) {
96 96
         // Check for backward compatibility
@@ -110,73 +110,73 @@  discard block
 block discarded – undo
110 110
 }
111 111
 
112 112
 function wpinv_get_checkout_uri( $args = array() ) {
113
-	$uri = wpinv_get_option( 'checkout_page', false );
114
-	$uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
113
+    $uri = wpinv_get_option( 'checkout_page', false );
114
+    $uri = isset( $uri ) ? get_permalink( $uri ) : NULL;
115 115
 
116
-	if ( !empty( $args ) ) {
117
-		// Check for backward compatibility
118
-		if ( is_string( $args ) )
119
-			$args = str_replace( '?', '', $args );
116
+    if ( !empty( $args ) ) {
117
+        // Check for backward compatibility
118
+        if ( is_string( $args ) )
119
+            $args = str_replace( '?', '', $args );
120 120
 
121
-		$args = wp_parse_args( $args );
121
+        $args = wp_parse_args( $args );
122 122
 
123
-		$uri = add_query_arg( $args, $uri );
124
-	}
123
+        $uri = add_query_arg( $args, $uri );
124
+    }
125 125
 
126
-	$scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
126
+    $scheme = defined( 'FORCE_SSL_ADMIN' ) && FORCE_SSL_ADMIN ? 'https' : 'admin';
127 127
 
128
-	$ajax_url = admin_url( 'admin-ajax.php', $scheme );
128
+    $ajax_url = admin_url( 'admin-ajax.php', $scheme );
129 129
 
130
-	if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
131
-		$uri = preg_replace( '/^http:/', 'https:', $uri );
132
-	}
130
+    if ( ( ! preg_match( '/^https/', $uri ) && preg_match( '/^https/', $ajax_url ) ) || wpinv_is_ssl_enforced() ) {
131
+        $uri = preg_replace( '/^http:/', 'https:', $uri );
132
+    }
133 133
 
134
-	return apply_filters( 'wpinv_get_checkout_uri', $uri );
134
+    return apply_filters( 'wpinv_get_checkout_uri', $uri );
135 135
 }
136 136
 
137 137
 function wpinv_send_back_to_checkout( $args = array() ) {
138
-	$redirect = wpinv_get_checkout_uri();
138
+    $redirect = wpinv_get_checkout_uri();
139 139
 
140
-	if ( ! empty( $args ) ) {
141
-		// Check for backward compatibility
142
-		if ( is_string( $args ) )
143
-			$args = str_replace( '?', '', $args );
140
+    if ( ! empty( $args ) ) {
141
+        // Check for backward compatibility
142
+        if ( is_string( $args ) )
143
+            $args = str_replace( '?', '', $args );
144 144
 
145
-		$args = wp_parse_args( $args );
145
+        $args = wp_parse_args( $args );
146 146
 
147
-		$redirect = add_query_arg( $args, $redirect );
148
-	}
147
+        $redirect = add_query_arg( $args, $redirect );
148
+    }
149 149
 
150 150
     do_action( 'wpinv_pre_send_back_to_checkout', $args );
151
-	wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
152
-	exit;
151
+    wp_redirect( apply_filters( 'wpinv_send_back_to_checkout', $redirect, $args ) );
152
+    exit;
153 153
 }
154 154
 
155 155
 function wpinv_get_success_page_url( $query_string = null ) {
156
-	$success_page = wpinv_get_option( 'success_page', 0 );
157
-	$success_page = get_permalink( $success_page );
156
+    $success_page = wpinv_get_option( 'success_page', 0 );
157
+    $success_page = get_permalink( $success_page );
158 158
 
159
-	if ( $query_string )
160
-		$success_page .= $query_string;
159
+    if ( $query_string )
160
+        $success_page .= $query_string;
161 161
 
162
-	return apply_filters( 'wpinv_success_page_url', $success_page );
162
+    return apply_filters( 'wpinv_success_page_url', $success_page );
163 163
 }
164 164
 
165 165
 function wpinv_get_failed_transaction_uri( $extras = false ) {
166
-	$uri = wpinv_get_option( 'failure_page', '' );
167
-	$uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
166
+    $uri = wpinv_get_option( 'failure_page', '' );
167
+    $uri = ! empty( $uri ) ? trailingslashit( get_permalink( $uri ) ) : home_url();
168 168
 
169
-	if ( $extras )
170
-		$uri .= $extras;
169
+    if ( $extras )
170
+        $uri .= $extras;
171 171
 
172
-	return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
172
+    return apply_filters( 'wpinv_get_failed_transaction_uri', $uri );
173 173
 }
174 174
 
175 175
 function wpinv_is_failed_transaction_page() {
176
-	$ret = wpinv_get_option( 'failure_page', false );
177
-	$ret = isset( $ret ) ? is_page( $ret ) : false;
176
+    $ret = wpinv_get_option( 'failure_page', false );
177
+    $ret = isset( $ret ) ? is_page( $ret ) : false;
178 178
 
179
-	return apply_filters( 'wpinv_is_failure_page', $ret );
179
+    return apply_filters( 'wpinv_is_failure_page', $ret );
180 180
 }
181 181
 
182 182
 function wpinv_transaction_query( $type = 'start' ) {
@@ -251,36 +251,36 @@  discard block
 block discarded – undo
251 251
     $require_billing_details = apply_filters( 'wpinv_checkout_required_billing_details', wpinv_use_taxes() );
252 252
     
253 253
     if ( $require_billing_details ) {
254
-		if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) {
255
-			$required_fields['first_name'] = array(
256
-				'error_id' => 'invalid_first_name',
257
-				'error_message' => __( 'Please enter your first name', 'invoicing' )
258
-			);
259
-		}
260
-		if ( (bool)wpinv_get_option( 'address_mandatory' ) ) {
261
-			$required_fields['address'] = array(
262
-				'error_id' => 'invalid_address',
263
-				'error_message' => __( 'Please enter your address', 'invoicing' )
264
-			);
265
-		}
266
-		if ( (bool)wpinv_get_option( 'city_mandatory' ) ) {
267
-			$required_fields['city'] = array(
268
-				'error_id' => 'invalid_city',
269
-				'error_message' => __( 'Please enter your billing city', 'invoicing' )
270
-			);
271
-		}
272
-		if ( (bool)wpinv_get_option( 'state_mandatory' ) ) {
273
-			$required_fields['state'] = array(
274
-				'error_id' => 'invalid_state',
275
-				'error_message' => __( 'Please enter billing state / province', 'invoicing' )
276
-			);
277
-		}
278
-		if ( (bool)wpinv_get_option( 'country_mandatory' ) ) {
279
-			$required_fields['country'] = array(
280
-				'error_id' => 'invalid_country',
281
-				'error_message' => __( 'Please select your billing country', 'invoicing' )
282
-			);
283
-		}
254
+        if ( (bool)wpinv_get_option( 'fname_mandatory' ) ) {
255
+            $required_fields['first_name'] = array(
256
+                'error_id' => 'invalid_first_name',
257
+                'error_message' => __( 'Please enter your first name', 'invoicing' )
258
+            );
259
+        }
260
+        if ( (bool)wpinv_get_option( 'address_mandatory' ) ) {
261
+            $required_fields['address'] = array(
262
+                'error_id' => 'invalid_address',
263
+                'error_message' => __( 'Please enter your address', 'invoicing' )
264
+            );
265
+        }
266
+        if ( (bool)wpinv_get_option( 'city_mandatory' ) ) {
267
+            $required_fields['city'] = array(
268
+                'error_id' => 'invalid_city',
269
+                'error_message' => __( 'Please enter your billing city', 'invoicing' )
270
+            );
271
+        }
272
+        if ( (bool)wpinv_get_option( 'state_mandatory' ) ) {
273
+            $required_fields['state'] = array(
274
+                'error_id' => 'invalid_state',
275
+                'error_message' => __( 'Please enter billing state / province', 'invoicing' )
276
+            );
277
+        }
278
+        if ( (bool)wpinv_get_option( 'country_mandatory' ) ) {
279
+            $required_fields['country'] = array(
280
+                'error_id' => 'invalid_country',
281
+                'error_message' => __( 'Please select your billing country', 'invoicing' )
282
+            );
283
+        }
284 284
     }
285 285
 
286 286
     return apply_filters( 'wpinv_checkout_required_fields', $required_fields );
Please login to merge, or discard this patch.