@@ -6,7 +6,7 @@ discard block |
||
6 | 6 | * @package Invoicing |
7 | 7 | */ |
8 | 8 | |
9 | -defined( 'ABSPATH' ) || exit; |
|
9 | +defined('ABSPATH') || exit; |
|
10 | 10 | |
11 | 11 | /** |
12 | 12 | * Retrieves the current invoice. |
@@ -14,15 +14,15 @@ discard block |
||
14 | 14 | function getpaid_get_current_invoice_id() { |
15 | 15 | |
16 | 16 | // Ensure that we have an invoice key. |
17 | - if ( empty( $_GET['invoice_key'] ) ) { |
|
17 | + if (empty($_GET['invoice_key'])) { |
|
18 | 18 | return 0; |
19 | 19 | } |
20 | 20 | |
21 | 21 | // Retrieve an invoice using the key. |
22 | - $invoice = new WPInv_Invoice( $_GET['invoice_key'] ); |
|
22 | + $invoice = new WPInv_Invoice($_GET['invoice_key']); |
|
23 | 23 | |
24 | 24 | // Compare the invoice key and the parsed key. |
25 | - if ( $invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key'] ) { |
|
25 | + if ($invoice->get_id() != 0 && $invoice->get_key() == $_GET['invoice_key']) { |
|
26 | 26 | return $invoice->get_id(); |
27 | 27 | } |
28 | 28 | |
@@ -32,42 +32,42 @@ discard block |
||
32 | 32 | /** |
33 | 33 | * Checks if the current user cna view an invoice. |
34 | 34 | */ |
35 | -function wpinv_user_can_view_invoice( $invoice ) { |
|
36 | - $invoice = new WPInv_Invoice( $invoice ); |
|
35 | +function wpinv_user_can_view_invoice($invoice) { |
|
36 | + $invoice = new WPInv_Invoice($invoice); |
|
37 | 37 | |
38 | 38 | // Abort if the invoice does not exist. |
39 | - if ( 0 == $invoice->get_id() ) { |
|
39 | + if (0 == $invoice->get_id()) { |
|
40 | 40 | return false; |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Don't allow trash, draft status |
44 | - if ( $invoice->is_draft() ) { |
|
44 | + if ($invoice->is_draft()) { |
|
45 | 45 | return false; |
46 | 46 | } |
47 | 47 | |
48 | 48 | // If users are not required to login to check out, compare the invoice keys. |
49 | - if ( ! wpinv_require_login_to_checkout() && isset( $_GET['invoice_key'] ) && trim( $_GET['invoice_key'] ) == $invoice->get_key() ) { |
|
49 | + if (!wpinv_require_login_to_checkout() && isset($_GET['invoice_key']) && trim($_GET['invoice_key']) == $invoice->get_key()) { |
|
50 | 50 | return true; |
51 | 51 | } |
52 | 52 | |
53 | 53 | // Always enable for admins.. |
54 | - if ( wpinv_current_user_can_manage_invoicing() || current_user_can( 'view_invoices', $invoice->get_id() ) ) { // Admin user |
|
54 | + if (wpinv_current_user_can_manage_invoicing() || current_user_can('view_invoices', $invoice->get_id())) { // Admin user |
|
55 | 55 | return true; |
56 | 56 | } |
57 | 57 | |
58 | 58 | // Else, ensure that this is their invoice. |
59 | - if ( is_user_logged_in() && $invoice->get_user_id() == get_current_user_id() ) { |
|
59 | + if (is_user_logged_in() && $invoice->get_user_id() == get_current_user_id()) { |
|
60 | 60 | return true; |
61 | 61 | } |
62 | 62 | |
63 | - return apply_filters( 'wpinv_current_user_can_view_invoice', false, $invoice ); |
|
63 | + return apply_filters('wpinv_current_user_can_view_invoice', false, $invoice); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | /** |
67 | 67 | * Checks if the current user cna view an invoice receipt. |
68 | 68 | */ |
69 | -function wpinv_can_view_receipt( $invoice ) { |
|
70 | - return (bool) apply_filters( 'wpinv_can_view_receipt', wpinv_user_can_view_invoice( $invoice ), $invoice ); |
|
69 | +function wpinv_can_view_receipt($invoice) { |
|
70 | + return (bool) apply_filters('wpinv_can_view_receipt', wpinv_user_can_view_invoice($invoice), $invoice); |
|
71 | 71 | } |
72 | 72 | |
73 | 73 | /** |
@@ -77,11 +77,11 @@ discard block |
||
77 | 77 | */ |
78 | 78 | function getpaid_get_invoice_post_types() { |
79 | 79 | $post_types = array( |
80 | - 'wpi_quote' => __( 'Quote', 'invoicing' ), |
|
81 | - 'wpi_invoice' => __( 'Invoice', 'invoicing' ), |
|
80 | + 'wpi_quote' => __('Quote', 'invoicing'), |
|
81 | + 'wpi_invoice' => __('Invoice', 'invoicing'), |
|
82 | 82 | ); |
83 | 83 | |
84 | - return apply_filters( 'getpaid_invoice_post_types', $post_types ); |
|
84 | + return apply_filters('getpaid_invoice_post_types', $post_types); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | /** |
@@ -90,8 +90,8 @@ discard block |
||
90 | 90 | * |
91 | 91 | * @param string $post_type The post type to check for. |
92 | 92 | */ |
93 | -function getpaid_is_invoice_post_type( $post_type ) { |
|
94 | - return ! empty( $post_type ) && array_key_exists( $post_type, getpaid_get_invoice_post_types() ); |
|
93 | +function getpaid_is_invoice_post_type($post_type) { |
|
94 | + return !empty($post_type) && array_key_exists($post_type, getpaid_get_invoice_post_types()); |
|
95 | 95 | } |
96 | 96 | |
97 | 97 | /** |
@@ -101,9 +101,9 @@ discard block |
||
101 | 101 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
102 | 102 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
103 | 103 | */ |
104 | -function wpinv_create_invoice( $data = array(), $deprecated = null, $wp_error = false ) { |
|
105 | - $data[ 'invoice_id' ] = 0; |
|
106 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
104 | +function wpinv_create_invoice($data = array(), $deprecated = null, $wp_error = false) { |
|
105 | + $data['invoice_id'] = 0; |
|
106 | + return wpinv_insert_invoice($data, $wp_error); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** |
@@ -113,36 +113,36 @@ discard block |
||
113 | 113 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
114 | 114 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
115 | 115 | */ |
116 | -function wpinv_update_invoice( $data = array(), $wp_error = false ) { |
|
116 | +function wpinv_update_invoice($data = array(), $wp_error = false) { |
|
117 | 117 | |
118 | 118 | // Backwards compatibility. |
119 | - if ( ! empty( $data['ID'] ) ) { |
|
119 | + if (!empty($data['ID'])) { |
|
120 | 120 | $data['invoice_id'] = $data['ID']; |
121 | 121 | } |
122 | 122 | |
123 | 123 | // Do we have an invoice id? |
124 | - if ( empty( $data['invoice_id'] ) ) { |
|
125 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', __( 'Invalid invoice ID.', 'invoicing' ) ) : 0; |
|
124 | + if (empty($data['invoice_id'])) { |
|
125 | + return $wp_error ? new WP_Error('invalid_invoice_id', __('Invalid invoice ID.', 'invoicing')) : 0; |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | // Retrieve the invoice. |
129 | - $invoice = wpinv_get_invoice( $data['invoice_id'] ); |
|
129 | + $invoice = wpinv_get_invoice($data['invoice_id']); |
|
130 | 130 | |
131 | 131 | // And abort if it does not exist. |
132 | - if ( empty( $invoice ) ) { |
|
133 | - return $wp_error ? new WP_Error( 'missing_invoice', __( 'Invoice not found.', 'invoicing' ) ) : 0; |
|
132 | + if (empty($invoice)) { |
|
133 | + return $wp_error ? new WP_Error('missing_invoice', __('Invoice not found.', 'invoicing')) : 0; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | // Do not update totals for paid / refunded invoices. |
137 | - if ( $invoice->is_paid() || $invoice->is_refunded() ) { |
|
137 | + if ($invoice->is_paid() || $invoice->is_refunded()) { |
|
138 | 138 | |
139 | - if ( ! empty( $data['items'] ) || ! empty( $data['cart_details'] ) ) { |
|
140 | - return $wp_error ? new WP_Error( 'paid_invoice', __( 'You can not update cart items for invoices that have already been paid for.', 'invoicing' ) ) : 0; |
|
139 | + if (!empty($data['items']) || !empty($data['cart_details'])) { |
|
140 | + return $wp_error ? new WP_Error('paid_invoice', __('You can not update cart items for invoices that have already been paid for.', 'invoicing')) : 0; |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | } |
144 | 144 | |
145 | - return wpinv_insert_invoice( $data, $wp_error ); |
|
145 | + return wpinv_insert_invoice($data, $wp_error); |
|
146 | 146 | |
147 | 147 | } |
148 | 148 | |
@@ -153,34 +153,34 @@ discard block |
||
153 | 153 | * @param bool $wp_error Whether to return false or WP_Error on failure. |
154 | 154 | * @return int|WP_Error|WPInv_Invoice The value 0 or WP_Error on failure. The WPInv_Invoice object on success. |
155 | 155 | */ |
156 | -function wpinv_insert_invoice( $data = array(), $wp_error = false ) { |
|
156 | +function wpinv_insert_invoice($data = array(), $wp_error = false) { |
|
157 | 157 | |
158 | 158 | // Ensure that we have invoice data. |
159 | - if ( empty( $data ) ) { |
|
159 | + if (empty($data)) { |
|
160 | 160 | return false; |
161 | 161 | } |
162 | 162 | |
163 | 163 | // The invoice id will be provided when updating an invoice. |
164 | - $data['invoice_id'] = ! empty( $data['invoice_id'] ) ? (int) $data['invoice_id'] : false; |
|
164 | + $data['invoice_id'] = !empty($data['invoice_id']) ? (int) $data['invoice_id'] : false; |
|
165 | 165 | |
166 | 166 | // Retrieve the invoice. |
167 | - $invoice = new WPInv_Invoice( $data['invoice_id'] ); |
|
167 | + $invoice = new WPInv_Invoice($data['invoice_id']); |
|
168 | 168 | |
169 | 169 | // Do we have an error? |
170 | - if ( ! empty( $invoice->last_error ) ) { |
|
171 | - return $wp_error ? new WP_Error( 'invalid_invoice_id', $invoice->last_error ) : 0; |
|
170 | + if (!empty($invoice->last_error)) { |
|
171 | + return $wp_error ? new WP_Error('invalid_invoice_id', $invoice->last_error) : 0; |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | // Backwards compatibility (billing address). |
175 | - if ( ! empty( $data['user_info'] ) ) { |
|
175 | + if (!empty($data['user_info'])) { |
|
176 | 176 | |
177 | - foreach ( $data['user_info'] as $key => $value ) { |
|
177 | + foreach ($data['user_info'] as $key => $value) { |
|
178 | 178 | |
179 | - if ( $key == 'discounts' ) { |
|
179 | + if ($key == 'discounts') { |
|
180 | 180 | $value = (array) $value; |
181 | - $data[ 'discount_code' ] = empty( $value ) ? null : $value[0]; |
|
181 | + $data['discount_code'] = empty($value) ? null : $value[0]; |
|
182 | 182 | } else { |
183 | - $data[ $key ] = $value; |
|
183 | + $data[$key] = $value; |
|
184 | 184 | } |
185 | 185 | |
186 | 186 | } |
@@ -188,30 +188,30 @@ discard block |
||
188 | 188 | } |
189 | 189 | |
190 | 190 | // Backwards compatibility. |
191 | - if ( ! empty( $data['payment_details'] ) ) { |
|
191 | + if (!empty($data['payment_details'])) { |
|
192 | 192 | |
193 | - foreach ( $data['payment_details'] as $key => $value ) { |
|
194 | - $data[ $key ] = $value; |
|
193 | + foreach ($data['payment_details'] as $key => $value) { |
|
194 | + $data[$key] = $value; |
|
195 | 195 | } |
196 | 196 | |
197 | 197 | } |
198 | 198 | |
199 | 199 | // Set up the owner of the invoice. |
200 | - $user_id = ! empty( $data['user_id'] ) ? wpinv_clean( $data['user_id'] ) : get_current_user_id(); |
|
200 | + $user_id = !empty($data['user_id']) ? wpinv_clean($data['user_id']) : get_current_user_id(); |
|
201 | 201 | |
202 | 202 | // Make sure the user exists. |
203 | - if ( ! get_userdata( $user_id ) ) { |
|
204 | - return $wp_error ? new WP_Error( 'wpinv_invalid_user', __( 'There is no user with that ID.', 'invoicing' ) ) : 0; |
|
203 | + if (!get_userdata($user_id)) { |
|
204 | + return $wp_error ? new WP_Error('wpinv_invalid_user', __('There is no user with that ID.', 'invoicing')) : 0; |
|
205 | 205 | } |
206 | 206 | |
207 | - $address = wpinv_get_user_address( $user_id ); |
|
207 | + $address = wpinv_get_user_address($user_id); |
|
208 | 208 | |
209 | - foreach ( $address as $key => $value ) { |
|
209 | + foreach ($address as $key => $value) { |
|
210 | 210 | |
211 | - if ( $value == '' ) { |
|
212 | - $address[ $key ] = null; |
|
211 | + if ($value == '') { |
|
212 | + $address[$key] = null; |
|
213 | 213 | } else { |
214 | - $address[ $key ] = wpinv_clean( $value ); |
|
214 | + $address[$key] = wpinv_clean($value); |
|
215 | 215 | } |
216 | 216 | |
217 | 217 | } |
@@ -222,103 +222,103 @@ discard block |
||
222 | 222 | array( |
223 | 223 | |
224 | 224 | // Basic info. |
225 | - 'template' => isset( $data['template'] ) ? wpinv_clean( $data['template'] ) : null, |
|
226 | - 'email_cc' => isset( $data['email_cc'] ) ? wpinv_clean( $data['email_cc'] ) : null, |
|
227 | - 'date_created' => isset( $data['created_date'] ) ? wpinv_clean( $data['created_date'] ) : null, |
|
228 | - 'due_date' => isset( $data['due_date'] ) ? wpinv_clean( $data['due_date'] ) : null, |
|
229 | - 'date_completed' => isset( $data['date_completed'] ) ? wpinv_clean( $data['date_completed'] ) : null, |
|
230 | - 'number' => isset( $data['number'] ) ? wpinv_clean( $data['number'] ) : null, |
|
231 | - 'key' => isset( $data['key'] ) ? wpinv_clean( $data['key'] ) : null, |
|
232 | - 'status' => isset( $data['status'] ) ? wpinv_clean( $data['status'] ) : null, |
|
233 | - 'post_type' => isset( $data['post_type'] ) ? wpinv_clean( $data['post_type'] ) : null, |
|
234 | - 'user_ip' => isset( $data['ip'] ) ? wpinv_clean( $data['ip'] ) : wpinv_get_ip(), |
|
235 | - 'parent_id' => isset( $data['parent'] ) ? intval( $data['parent'] ) : null, |
|
236 | - 'mode' => isset( $data['mode'] ) ? wpinv_clean( $data['mode'] ) : null, |
|
237 | - 'description' => isset( $data['description'] ) ? wp_kses_post( $data['description'] ) : null, |
|
225 | + 'template' => isset($data['template']) ? wpinv_clean($data['template']) : null, |
|
226 | + 'email_cc' => isset($data['email_cc']) ? wpinv_clean($data['email_cc']) : null, |
|
227 | + 'date_created' => isset($data['created_date']) ? wpinv_clean($data['created_date']) : null, |
|
228 | + 'due_date' => isset($data['due_date']) ? wpinv_clean($data['due_date']) : null, |
|
229 | + 'date_completed' => isset($data['date_completed']) ? wpinv_clean($data['date_completed']) : null, |
|
230 | + 'number' => isset($data['number']) ? wpinv_clean($data['number']) : null, |
|
231 | + 'key' => isset($data['key']) ? wpinv_clean($data['key']) : null, |
|
232 | + 'status' => isset($data['status']) ? wpinv_clean($data['status']) : null, |
|
233 | + 'post_type' => isset($data['post_type']) ? wpinv_clean($data['post_type']) : null, |
|
234 | + 'user_ip' => isset($data['ip']) ? wpinv_clean($data['ip']) : wpinv_get_ip(), |
|
235 | + 'parent_id' => isset($data['parent']) ? intval($data['parent']) : null, |
|
236 | + 'mode' => isset($data['mode']) ? wpinv_clean($data['mode']) : null, |
|
237 | + 'description' => isset($data['description']) ? wp_kses_post($data['description']) : null, |
|
238 | 238 | |
239 | 239 | // Payment info. |
240 | - 'disable_taxes' => ! empty( $data['disable_taxes'] ), |
|
241 | - 'currency' => isset( $data['currency'] ) ? wpinv_clean( $data['currency'] ) : wpinv_get_currency(), |
|
242 | - 'gateway' => isset( $data['gateway'] ) ? wpinv_clean( $data['gateway'] ) : null, |
|
243 | - 'transaction_id' => isset( $data['transaction_id'] ) ? wpinv_clean( $data['transaction_id'] ) : null, |
|
244 | - 'discount_code' => isset( $data['discount_code'] ) ? wpinv_clean( $data['discount_code'] ) : null, |
|
245 | - 'payment_form' => isset( $data['payment_form'] ) ? intval( $data['payment_form'] ) : null, |
|
246 | - 'submission_id' => isset( $data['submission_id'] ) ? wpinv_clean( $data['submission_id'] ) : null, |
|
247 | - 'subscription_id' => isset( $data['subscription_id'] ) ? wpinv_clean( $data['subscription_id'] ) : null, |
|
248 | - 'is_viewed' => isset( $data['is_viewed'] ) ? wpinv_clean( $data['is_viewed'] ) : null, |
|
249 | - 'fees' => isset( $data['fees'] ) ? wpinv_clean( $data['fees'] ) : null, |
|
250 | - 'discounts' => isset( $data['discounts'] ) ? wpinv_clean( $data['discounts'] ) : null, |
|
251 | - 'taxes' => isset( $data['taxes'] ) ? wpinv_clean( $data['taxes'] ) : null, |
|
240 | + 'disable_taxes' => !empty($data['disable_taxes']), |
|
241 | + 'currency' => isset($data['currency']) ? wpinv_clean($data['currency']) : wpinv_get_currency(), |
|
242 | + 'gateway' => isset($data['gateway']) ? wpinv_clean($data['gateway']) : null, |
|
243 | + 'transaction_id' => isset($data['transaction_id']) ? wpinv_clean($data['transaction_id']) : null, |
|
244 | + 'discount_code' => isset($data['discount_code']) ? wpinv_clean($data['discount_code']) : null, |
|
245 | + 'payment_form' => isset($data['payment_form']) ? intval($data['payment_form']) : null, |
|
246 | + 'submission_id' => isset($data['submission_id']) ? wpinv_clean($data['submission_id']) : null, |
|
247 | + 'subscription_id' => isset($data['subscription_id']) ? wpinv_clean($data['subscription_id']) : null, |
|
248 | + 'is_viewed' => isset($data['is_viewed']) ? wpinv_clean($data['is_viewed']) : null, |
|
249 | + 'fees' => isset($data['fees']) ? wpinv_clean($data['fees']) : null, |
|
250 | + 'discounts' => isset($data['discounts']) ? wpinv_clean($data['discounts']) : null, |
|
251 | + 'taxes' => isset($data['taxes']) ? wpinv_clean($data['taxes']) : null, |
|
252 | 252 | |
253 | 253 | |
254 | 254 | // Billing details. |
255 | 255 | 'user_id' => $data['user_id'], |
256 | - 'first_name' => isset( $data['first_name'] ) ? wpinv_clean( $data['first_name'] ) : $address['first_name'], |
|
257 | - 'last_name' => isset( $data['last_name'] ) ? wpinv_clean( $data['last_name'] ) : $address['last_name'], |
|
258 | - 'address' => isset( $data['address'] ) ? wpinv_clean( $data['address'] ) : $address['address'] , |
|
259 | - 'vat_number' => isset( $data['vat_number'] ) ? wpinv_clean( $data['vat_number'] ) : $address['vat_number'], |
|
260 | - 'company' => isset( $data['company'] ) ? wpinv_clean( $data['company'] ) : $address['company'], |
|
261 | - 'zip' => isset( $data['zip'] ) ? wpinv_clean( $data['zip'] ) : $address['zip'], |
|
262 | - 'state' => isset( $data['state'] ) ? wpinv_clean( $data['state'] ) : $address['state'], |
|
263 | - 'city' => isset( $data['city'] ) ? wpinv_clean( $data['city'] ) : $address['city'], |
|
264 | - 'country' => isset( $data['country'] ) ? wpinv_clean( $data['country'] ) : $address['country'], |
|
265 | - 'phone' => isset( $data['phone'] ) ? wpinv_clean( $data['phone'] ) : $address['phone'], |
|
266 | - 'address_confirmed' => ! empty( $data['address_confirmed'] ), |
|
256 | + 'first_name' => isset($data['first_name']) ? wpinv_clean($data['first_name']) : $address['first_name'], |
|
257 | + 'last_name' => isset($data['last_name']) ? wpinv_clean($data['last_name']) : $address['last_name'], |
|
258 | + 'address' => isset($data['address']) ? wpinv_clean($data['address']) : $address['address'], |
|
259 | + 'vat_number' => isset($data['vat_number']) ? wpinv_clean($data['vat_number']) : $address['vat_number'], |
|
260 | + 'company' => isset($data['company']) ? wpinv_clean($data['company']) : $address['company'], |
|
261 | + 'zip' => isset($data['zip']) ? wpinv_clean($data['zip']) : $address['zip'], |
|
262 | + 'state' => isset($data['state']) ? wpinv_clean($data['state']) : $address['state'], |
|
263 | + 'city' => isset($data['city']) ? wpinv_clean($data['city']) : $address['city'], |
|
264 | + 'country' => isset($data['country']) ? wpinv_clean($data['country']) : $address['country'], |
|
265 | + 'phone' => isset($data['phone']) ? wpinv_clean($data['phone']) : $address['phone'], |
|
266 | + 'address_confirmed' => !empty($data['address_confirmed']), |
|
267 | 267 | |
268 | 268 | ) |
269 | 269 | |
270 | 270 | ); |
271 | 271 | |
272 | 272 | // Backwards compatibililty. |
273 | - if ( ! empty( $data['cart_details'] ) && is_array( $data['cart_details'] ) ) { |
|
273 | + if (!empty($data['cart_details']) && is_array($data['cart_details'])) { |
|
274 | 274 | $data['items'] = array(); |
275 | 275 | |
276 | - foreach( $data['cart_details'] as $_item ) { |
|
276 | + foreach ($data['cart_details'] as $_item) { |
|
277 | 277 | |
278 | 278 | // Ensure that we have an item id. |
279 | - if ( empty( $_item['id'] ) ) { |
|
279 | + if (empty($_item['id'])) { |
|
280 | 280 | continue; |
281 | 281 | } |
282 | 282 | |
283 | 283 | // Retrieve the item. |
284 | - $item = new GetPaid_Form_Item( $_item['id'] ); |
|
284 | + $item = new GetPaid_Form_Item($_item['id']); |
|
285 | 285 | |
286 | 286 | // Ensure that it is purchasable. |
287 | - if ( ! $item->can_purchase() ) { |
|
287 | + if (!$item->can_purchase()) { |
|
288 | 288 | continue; |
289 | 289 | } |
290 | 290 | |
291 | 291 | // Set quantity. |
292 | - if ( ! empty( $_item['quantity'] ) && is_numeric( $_item['quantity'] ) ) { |
|
293 | - $item->set_quantity( $_item['quantity'] ); |
|
292 | + if (!empty($_item['quantity']) && is_numeric($_item['quantity'])) { |
|
293 | + $item->set_quantity($_item['quantity']); |
|
294 | 294 | } |
295 | 295 | |
296 | 296 | // Set price. |
297 | - if ( isset( $_item['item_price'] ) ) { |
|
298 | - $item->set_price( $_item['item_price'] ); |
|
297 | + if (isset($_item['item_price'])) { |
|
298 | + $item->set_price($_item['item_price']); |
|
299 | 299 | } |
300 | 300 | |
301 | - if ( isset( $_item['custom_price'] ) ) { |
|
302 | - $item->set_price( $_item['custom_price'] ); |
|
301 | + if (isset($_item['custom_price'])) { |
|
302 | + $item->set_price($_item['custom_price']); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | // Set name. |
306 | - if ( ! empty( $_item['name'] ) ) { |
|
307 | - $item->set_name( $_item['name'] ); |
|
306 | + if (!empty($_item['name'])) { |
|
307 | + $item->set_name($_item['name']); |
|
308 | 308 | } |
309 | 309 | |
310 | 310 | // Set description. |
311 | - if ( isset( $_item['description'] ) ) { |
|
312 | - $item->set_custom_description( $_item['description'] ); |
|
311 | + if (isset($_item['description'])) { |
|
312 | + $item->set_custom_description($_item['description']); |
|
313 | 313 | } |
314 | 314 | |
315 | 315 | // Set meta. |
316 | - if ( isset( $_item['meta'] ) && is_array( $_item['meta'] ) ) { |
|
316 | + if (isset($_item['meta']) && is_array($_item['meta'])) { |
|
317 | 317 | |
318 | - $item->set_item_meta( $_item['meta'] ); |
|
318 | + $item->set_item_meta($_item['meta']); |
|
319 | 319 | |
320 | - if ( isset( $_item['meta']['description'] ) ) { |
|
321 | - $item->set_custom_description( $_item['meta']['description'] ); |
|
320 | + if (isset($_item['meta']['description'])) { |
|
321 | + $item->set_custom_description($_item['meta']['description']); |
|
322 | 322 | } |
323 | 323 | |
324 | 324 | } |
@@ -329,14 +329,14 @@ discard block |
||
329 | 329 | } |
330 | 330 | |
331 | 331 | // Add invoice items. |
332 | - if ( ! empty( $data['items'] ) && is_array( $data['items'] ) ) { |
|
332 | + if (!empty($data['items']) && is_array($data['items'])) { |
|
333 | 333 | |
334 | - $invoice->set_items( array() ); |
|
334 | + $invoice->set_items(array()); |
|
335 | 335 | |
336 | - foreach ( $data['items'] as $item ) { |
|
336 | + foreach ($data['items'] as $item) { |
|
337 | 337 | |
338 | - if ( is_object( $item ) && is_a( $item, 'GetPaid_Form_Item' ) && $item->can_purchase() ) { |
|
339 | - $invoice->add_item( $item ); |
|
338 | + if (is_object($item) && is_a($item, 'GetPaid_Form_Item') && $item->can_purchase()) { |
|
339 | + $invoice->add_item($item); |
|
340 | 340 | } |
341 | 341 | |
342 | 342 | } |
@@ -346,30 +346,30 @@ discard block |
||
346 | 346 | // Save the invoice. |
347 | 347 | $invoice->save(); |
348 | 348 | |
349 | - if ( ! $invoice->get_id() ) { |
|
350 | - return $wp_error ? new WP_Error( 'wpinv_insert_invoice_error', __( 'An error occured when saving your invoice.', 'invoicing' ) ) : 0; |
|
349 | + if (!$invoice->get_id()) { |
|
350 | + return $wp_error ? new WP_Error('wpinv_insert_invoice_error', __('An error occured when saving your invoice.', 'invoicing')) : 0; |
|
351 | 351 | } |
352 | 352 | |
353 | 353 | // Add private note. |
354 | - if ( ! empty( $data['private_note'] ) ) { |
|
355 | - $invoice->add_note( $data['private_note'] ); |
|
354 | + if (!empty($data['private_note'])) { |
|
355 | + $invoice->add_note($data['private_note']); |
|
356 | 356 | } |
357 | 357 | |
358 | 358 | // User notes. |
359 | - if ( !empty( $data['user_note'] ) ) { |
|
360 | - $invoice->add_note( $data['user_note'], true ); |
|
359 | + if (!empty($data['user_note'])) { |
|
360 | + $invoice->add_note($data['user_note'], true); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 | // Created via. |
364 | - if ( isset( $data['created_via'] ) ) { |
|
365 | - update_post_meta( $invoice->get_id(), 'wpinv_created_via', $data['created_via'] ); |
|
364 | + if (isset($data['created_via'])) { |
|
365 | + update_post_meta($invoice->get_id(), 'wpinv_created_via', $data['created_via']); |
|
366 | 366 | } |
367 | 367 | |
368 | 368 | // Backwards compatiblity. |
369 | - if ( $invoice->is_quote() ) { |
|
369 | + if ($invoice->is_quote()) { |
|
370 | 370 | |
371 | - if ( isset( $data['valid_until'] ) ) { |
|
372 | - update_post_meta( $invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until'] ); |
|
371 | + if (isset($data['valid_until'])) { |
|
372 | + update_post_meta($invoice->get_id(), 'wpinv_quote_valid_until', $data['valid_until']); |
|
373 | 373 | } |
374 | 374 | return $invoice; |
375 | 375 | |
@@ -384,18 +384,18 @@ discard block |
||
384 | 384 | * @param $bool $deprecated |
385 | 385 | * @return WPInv_Invoice|null |
386 | 386 | */ |
387 | -function wpinv_get_invoice( $invoice = 0, $deprecated = false ) { |
|
387 | +function wpinv_get_invoice($invoice = 0, $deprecated = false) { |
|
388 | 388 | |
389 | 389 | // If we are retrieving the invoice from the cart... |
390 | - if ( $deprecated && empty( $invoice ) ) { |
|
390 | + if ($deprecated && empty($invoice)) { |
|
391 | 391 | $invoice = (int) getpaid_get_current_invoice_id(); |
392 | 392 | } |
393 | 393 | |
394 | 394 | // Retrieve the invoice. |
395 | - $invoice = new WPInv_Invoice( $invoice ); |
|
395 | + $invoice = new WPInv_Invoice($invoice); |
|
396 | 396 | |
397 | 397 | // Check if it exists. |
398 | - if ( $invoice->get_id() != 0 ) { |
|
398 | + if ($invoice->get_id() != 0) { |
|
399 | 399 | return $invoice; |
400 | 400 | } |
401 | 401 | |
@@ -408,15 +408,15 @@ discard block |
||
408 | 408 | * @param array $args Args to search for. |
409 | 409 | * @return WPInv_Invoice[]|int[]|object |
410 | 410 | */ |
411 | -function wpinv_get_invoices( $args ) { |
|
411 | +function wpinv_get_invoices($args) { |
|
412 | 412 | |
413 | 413 | // Prepare args. |
414 | 414 | $args = wp_parse_args( |
415 | 415 | $args, |
416 | 416 | array( |
417 | - 'status' => array_keys( wpinv_get_invoice_statuses() ), |
|
417 | + 'status' => array_keys(wpinv_get_invoice_statuses()), |
|
418 | 418 | 'type' => 'wpi_invoice', |
419 | - 'limit' => get_option( 'posts_per_page' ), |
|
419 | + 'limit' => get_option('posts_per_page'), |
|
420 | 420 | 'return' => 'objects', |
421 | 421 | ) |
422 | 422 | ); |
@@ -434,24 +434,24 @@ discard block |
||
434 | 434 | 'post__in' => 'include', |
435 | 435 | ); |
436 | 436 | |
437 | - foreach ( $map_legacy as $to => $from ) { |
|
438 | - if ( isset( $args[ $from ] ) ) { |
|
439 | - $args[ $to ] = $args[ $from ]; |
|
440 | - unset( $args[ $from ] ); |
|
437 | + foreach ($map_legacy as $to => $from) { |
|
438 | + if (isset($args[$from])) { |
|
439 | + $args[$to] = $args[$from]; |
|
440 | + unset($args[$from]); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | 444 | // Backwards compatibility. |
445 | - if ( ! empty( $args['email'] ) && empty( $args['user'] ) ) { |
|
445 | + if (!empty($args['email']) && empty($args['user'])) { |
|
446 | 446 | $args['user'] = $args['email']; |
447 | - unset( $args['email'] ); |
|
447 | + unset($args['email']); |
|
448 | 448 | } |
449 | 449 | |
450 | 450 | // Handle cases where the user is set as an email. |
451 | - if ( ! empty( $args['author'] ) && is_email( $args['author'] ) ) { |
|
452 | - $user = get_user_by( 'email', $args['user'] ); |
|
451 | + if (!empty($args['author']) && is_email($args['author'])) { |
|
452 | + $user = get_user_by('email', $args['user']); |
|
453 | 453 | |
454 | - if ( $user ) { |
|
454 | + if ($user) { |
|
455 | 455 | $args['author'] = $user->user_email; |
456 | 456 | } |
457 | 457 | |
@@ -462,31 +462,31 @@ discard block |
||
462 | 462 | |
463 | 463 | // Show all posts. |
464 | 464 | $paginate = true; |
465 | - if ( isset( $args['paginate'] ) ) { |
|
465 | + if (isset($args['paginate'])) { |
|
466 | 466 | |
467 | 467 | $paginate = $args['paginate']; |
468 | - $args['no_found_rows'] = empty( $args['paginate'] ); |
|
469 | - unset( $args['paginate'] ); |
|
468 | + $args['no_found_rows'] = empty($args['paginate']); |
|
469 | + unset($args['paginate']); |
|
470 | 470 | |
471 | 471 | } |
472 | 472 | |
473 | 473 | // Whether to return objects or fields. |
474 | 474 | $return = $args['return']; |
475 | - unset( $args['return'] ); |
|
475 | + unset($args['return']); |
|
476 | 476 | |
477 | 477 | // Get invoices. |
478 | - $invoices = new WP_Query( apply_filters( 'wpinv_get_invoices_args', $args ) ); |
|
478 | + $invoices = new WP_Query(apply_filters('wpinv_get_invoices_args', $args)); |
|
479 | 479 | |
480 | 480 | // Prepare the results. |
481 | - if ( 'objects' === $return ) { |
|
482 | - $results = array_map( 'wpinv_get_invoice', $invoices->posts ); |
|
483 | - } elseif ( 'self' === $return ) { |
|
481 | + if ('objects' === $return) { |
|
482 | + $results = array_map('wpinv_get_invoice', $invoices->posts); |
|
483 | + } elseif ('self' === $return) { |
|
484 | 484 | return $invoices; |
485 | 485 | } else { |
486 | 486 | $results = $invoices->posts; |
487 | 487 | } |
488 | 488 | |
489 | - if ( $paginate ) { |
|
489 | + if ($paginate) { |
|
490 | 490 | return (object) array( |
491 | 491 | 'invoices' => $results, |
492 | 492 | 'total' => $invoices->found_posts, |
@@ -504,8 +504,8 @@ discard block |
||
504 | 504 | * @param string $transaction_id The transaction id to check. |
505 | 505 | * @return int Invoice id on success or 0 on failure |
506 | 506 | */ |
507 | -function wpinv_get_id_by_transaction_id( $transaction_id ) { |
|
508 | - return WPInv_Invoice::get_invoice_id_by_field( $transaction_id, 'transaction_id' ); |
|
507 | +function wpinv_get_id_by_transaction_id($transaction_id) { |
|
508 | + return WPInv_Invoice::get_invoice_id_by_field($transaction_id, 'transaction_id'); |
|
509 | 509 | } |
510 | 510 | |
511 | 511 | /** |
@@ -514,8 +514,8 @@ discard block |
||
514 | 514 | * @param string $invoice_number The invoice number to check. |
515 | 515 | * @return int Invoice id on success or 0 on failure |
516 | 516 | */ |
517 | -function wpinv_get_id_by_invoice_number( $invoice_number ) { |
|
518 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_number, 'number' ); |
|
517 | +function wpinv_get_id_by_invoice_number($invoice_number) { |
|
518 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_number, 'number'); |
|
519 | 519 | } |
520 | 520 | |
521 | 521 | /** |
@@ -524,8 +524,8 @@ discard block |
||
524 | 524 | * @param string $invoice_key The invoice key to check. |
525 | 525 | * @return int Invoice id on success or 0 on failure |
526 | 526 | */ |
527 | -function wpinv_get_invoice_id_by_key( $invoice_key ) { |
|
528 | - return WPInv_Invoice::get_invoice_id_by_field( $invoice_key, 'key' ); |
|
527 | +function wpinv_get_invoice_id_by_key($invoice_key) { |
|
528 | + return WPInv_Invoice::get_invoice_id_by_field($invoice_key, 'key'); |
|
529 | 529 | } |
530 | 530 | |
531 | 531 | /** |
@@ -535,19 +535,19 @@ discard block |
||
535 | 535 | * @param string $type Optionally filter by type i.e customer|system |
536 | 536 | * @return array|null |
537 | 537 | */ |
538 | -function wpinv_get_invoice_notes( $invoice = 0, $type = '' ) { |
|
538 | +function wpinv_get_invoice_notes($invoice = 0, $type = '') { |
|
539 | 539 | |
540 | 540 | // Prepare the invoice. |
541 | - $invoice = wpinv_get_invoice( $invoice ); |
|
542 | - if ( empty( $invoice ) ) { |
|
541 | + $invoice = wpinv_get_invoice($invoice); |
|
542 | + if (empty($invoice)) { |
|
543 | 543 | return NULL; |
544 | 544 | } |
545 | 545 | |
546 | 546 | // Fetch notes. |
547 | - $notes = getpaid_notes()->get_invoice_notes( $invoice->get_id(), $type ); |
|
547 | + $notes = getpaid_notes()->get_invoice_notes($invoice->get_id(), $type); |
|
548 | 548 | |
549 | 549 | // Filter the notes. |
550 | - return apply_filters( 'wpinv_invoice_notes', $notes, $invoice->get_id(), $type ); |
|
550 | + return apply_filters('wpinv_invoice_notes', $notes, $invoice->get_id(), $type); |
|
551 | 551 | } |
552 | 552 | |
553 | 553 | /** |
@@ -557,27 +557,27 @@ discard block |
||
557 | 557 | $columns = array( |
558 | 558 | |
559 | 559 | 'invoice-number' => array( |
560 | - 'title' => __( 'Invoice', 'invoicing' ), |
|
560 | + 'title' => __('Invoice', 'invoicing'), |
|
561 | 561 | 'class' => 'text-left' |
562 | 562 | ), |
563 | 563 | |
564 | 564 | 'created-date' => array( |
565 | - 'title' => __( 'Created Date', 'invoicing' ), |
|
565 | + 'title' => __('Created Date', 'invoicing'), |
|
566 | 566 | 'class' => 'text-left' |
567 | 567 | ), |
568 | 568 | |
569 | 569 | 'payment-date' => array( |
570 | - 'title' => __( 'Payment Date', 'invoicing' ), |
|
570 | + 'title' => __('Payment Date', 'invoicing'), |
|
571 | 571 | 'class' => 'text-left' |
572 | 572 | ), |
573 | 573 | |
574 | 574 | 'invoice-status' => array( |
575 | - 'title' => __( 'Status', 'invoicing' ), |
|
575 | + 'title' => __('Status', 'invoicing'), |
|
576 | 576 | 'class' => 'text-center' |
577 | 577 | ), |
578 | 578 | |
579 | 579 | 'invoice-total' => array( |
580 | - 'title' => __( 'Total', 'invoicing' ), |
|
580 | + 'title' => __('Total', 'invoicing'), |
|
581 | 581 | 'class' => 'text-right' |
582 | 582 | ), |
583 | 583 | |
@@ -588,7 +588,7 @@ discard block |
||
588 | 588 | |
589 | 589 | ); |
590 | 590 | |
591 | - return apply_filters( 'wpinv_user_invoices_columns', $columns ); |
|
591 | + return apply_filters('wpinv_user_invoices_columns', $columns); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | /** |
@@ -598,54 +598,54 @@ discard block |
||
598 | 598 | |
599 | 599 | // Find the invoice. |
600 | 600 | $invoice_id = getpaid_get_current_invoice_id(); |
601 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
601 | + $invoice = new WPInv_Invoice($invoice_id); |
|
602 | 602 | |
603 | 603 | // Abort if non was found. |
604 | - if ( empty( $invoice_id ) || $invoice->is_draft() ) { |
|
604 | + if (empty($invoice_id) || $invoice->is_draft()) { |
|
605 | 605 | |
606 | 606 | return aui()->alert( |
607 | 607 | array( |
608 | 608 | 'type' => 'warning', |
609 | - 'content' => __( 'We could not find your invoice', 'invoicing' ), |
|
609 | + 'content' => __('We could not find your invoice', 'invoicing'), |
|
610 | 610 | ) |
611 | 611 | ); |
612 | 612 | |
613 | 613 | } |
614 | 614 | |
615 | 615 | // Can the user view this invoice? |
616 | - if ( ! wpinv_can_view_receipt( $invoice_id ) ) { |
|
616 | + if (!wpinv_can_view_receipt($invoice_id)) { |
|
617 | 617 | |
618 | 618 | return aui()->alert( |
619 | 619 | array( |
620 | 620 | 'type' => 'warning', |
621 | - 'content' => __( 'You are not allowed to view this receipt', 'invoicing' ), |
|
621 | + 'content' => __('You are not allowed to view this receipt', 'invoicing'), |
|
622 | 622 | ) |
623 | 623 | ); |
624 | 624 | |
625 | 625 | } |
626 | 626 | |
627 | 627 | // Load the template. |
628 | - return wpinv_get_template_html( 'invoice-receipt.php', compact( 'invoice' ) ); |
|
628 | + return wpinv_get_template_html('invoice-receipt.php', compact('invoice')); |
|
629 | 629 | |
630 | 630 | } |
631 | 631 | |
632 | 632 | /** |
633 | 633 | * Displays the invoice history. |
634 | 634 | */ |
635 | -function getpaid_invoice_history( $user_id = 0 ) { |
|
635 | +function getpaid_invoice_history($user_id = 0) { |
|
636 | 636 | |
637 | 637 | // Ensure that we have a user id. |
638 | - if ( empty( $user_id ) || ! is_numeric( $user_id ) ) { |
|
638 | + if (empty($user_id) || !is_numeric($user_id)) { |
|
639 | 639 | $user_id = get_current_user_id(); |
640 | 640 | } |
641 | 641 | |
642 | 642 | // View user id. |
643 | - if ( empty( $user_id ) ) { |
|
643 | + if (empty($user_id)) { |
|
644 | 644 | |
645 | 645 | return aui()->alert( |
646 | 646 | array( |
647 | 647 | 'type' => 'warning', |
648 | - 'content' => __( 'You must be logged in to view your invoice history.', 'invoicing' ), |
|
648 | + 'content' => __('You must be logged in to view your invoice history.', 'invoicing'), |
|
649 | 649 | ) |
650 | 650 | ); |
651 | 651 | |
@@ -655,55 +655,55 @@ discard block |
||
655 | 655 | $invoices = wpinv_get_invoices( |
656 | 656 | |
657 | 657 | array( |
658 | - 'page' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1, |
|
658 | + 'page' => (get_query_var('paged')) ? absint(get_query_var('paged')) : 1, |
|
659 | 659 | 'user' => $user_id, |
660 | 660 | 'paginate' => true, |
661 | 661 | ) |
662 | 662 | |
663 | 663 | ); |
664 | 664 | |
665 | - if ( empty( $invoices->total ) ) { |
|
665 | + if (empty($invoices->total)) { |
|
666 | 666 | |
667 | 667 | return aui()->alert( |
668 | 668 | array( |
669 | 669 | 'type' => 'info', |
670 | - 'content' => __( 'No invoices found.', 'invoicing' ), |
|
670 | + 'content' => __('No invoices found.', 'invoicing'), |
|
671 | 671 | ) |
672 | 672 | ); |
673 | 673 | |
674 | 674 | } |
675 | 675 | |
676 | 676 | // Load the template. |
677 | - return wpinv_get_template_html( 'invoice-history.php', compact( 'invoices' ) ); |
|
677 | + return wpinv_get_template_html('invoice-history.php', compact('invoices')); |
|
678 | 678 | |
679 | 679 | } |
680 | 680 | |
681 | 681 | /** |
682 | 682 | * Formats an invoice number given an invoice type. |
683 | 683 | */ |
684 | -function wpinv_format_invoice_number( $number, $type = '' ) { |
|
684 | +function wpinv_format_invoice_number($number, $type = '') { |
|
685 | 685 | |
686 | 686 | // Allow other plugins to overide this. |
687 | - $check = apply_filters( 'wpinv_pre_format_invoice_number', null, $number, $type ); |
|
688 | - if ( null !== $check ) { |
|
687 | + $check = apply_filters('wpinv_pre_format_invoice_number', null, $number, $type); |
|
688 | + if (null !== $check) { |
|
689 | 689 | return $check; |
690 | 690 | } |
691 | 691 | |
692 | 692 | // Ensure that we have a numeric number. |
693 | - if ( ! is_numeric( $number ) ) { |
|
693 | + if (!is_numeric($number)) { |
|
694 | 694 | return $number; |
695 | 695 | } |
696 | 696 | |
697 | 697 | // Format the number. |
698 | - $padd = absint( (int) wpinv_get_option( 'invoice_number_padd' ) ); |
|
699 | - $prefix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_prefix', 'INV-' ) ); |
|
700 | - $postfix = sanitize_text_field( (string) wpinv_get_option( 'invoice_number_postfix' ) ); |
|
701 | - $formatted_number = zeroise( absint( $number ), $padd ); |
|
698 | + $padd = absint((int) wpinv_get_option('invoice_number_padd')); |
|
699 | + $prefix = sanitize_text_field((string) wpinv_get_option('invoice_number_prefix', 'INV-')); |
|
700 | + $postfix = sanitize_text_field((string) wpinv_get_option('invoice_number_postfix')); |
|
701 | + $formatted_number = zeroise(absint($number), $padd); |
|
702 | 702 | |
703 | 703 | // Add the prefix and post fix. |
704 | 704 | $formatted_number = $prefix . $formatted_number . $postfix; |
705 | 705 | |
706 | - return apply_filters( 'wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd ); |
|
706 | + return apply_filters('wpinv_format_invoice_number', $formatted_number, $number, $prefix, $postfix, $padd); |
|
707 | 707 | } |
708 | 708 | |
709 | 709 | /** |
@@ -712,58 +712,58 @@ discard block |
||
712 | 712 | * @param string $type. |
713 | 713 | * @return int|null|bool |
714 | 714 | */ |
715 | -function wpinv_get_next_invoice_number( $type = '' ) { |
|
715 | +function wpinv_get_next_invoice_number($type = '') { |
|
716 | 716 | |
717 | 717 | // Allow plugins to overide this. |
718 | - $check = apply_filters( 'wpinv_get_pre_next_invoice_number', null, $type ); |
|
719 | - if ( null !== $check ) { |
|
718 | + $check = apply_filters('wpinv_get_pre_next_invoice_number', null, $type); |
|
719 | + if (null !== $check) { |
|
720 | 720 | return $check; |
721 | 721 | } |
722 | 722 | |
723 | 723 | // Ensure sequential invoice numbers is active. |
724 | - if ( ! wpinv_sequential_number_active() ) { |
|
724 | + if (!wpinv_sequential_number_active()) { |
|
725 | 725 | return false; |
726 | 726 | } |
727 | 727 | |
728 | 728 | // Retrieve the current number and the start number. |
729 | - $number = (int) get_option( 'wpinv_last_invoice_number', 0 ); |
|
730 | - $start = absint( (int) wpinv_get_option( 'invoice_sequence_start', 1 ) ); |
|
729 | + $number = (int) get_option('wpinv_last_invoice_number', 0); |
|
730 | + $start = absint((int) wpinv_get_option('invoice_sequence_start', 1)); |
|
731 | 731 | |
732 | 732 | // Ensure that we are starting at a positive integer. |
733 | - $start = max( $start, 1 ); |
|
733 | + $start = max($start, 1); |
|
734 | 734 | |
735 | 735 | // If this is the first invoice, use the start number. |
736 | - $number = max( $start, $number ); |
|
736 | + $number = max($start, $number); |
|
737 | 737 | |
738 | 738 | // Format the invoice number. |
739 | - $formatted_number = wpinv_format_invoice_number( $number, $type ); |
|
739 | + $formatted_number = wpinv_format_invoice_number($number, $type); |
|
740 | 740 | |
741 | 741 | // Ensure that this number is unique. |
742 | - $invoice_id = WPInv_Invoice::get_invoice_id_by_field( $formatted_number, 'number' ); |
|
742 | + $invoice_id = WPInv_Invoice::get_invoice_id_by_field($formatted_number, 'number'); |
|
743 | 743 | |
744 | 744 | // We found a match. Nice. |
745 | - if ( empty( $invoice_id ) ) { |
|
746 | - update_option( 'wpinv_last_invoice_number', $number ); |
|
747 | - return apply_filters( 'wpinv_get_next_invoice_number', $number ); |
|
745 | + if (empty($invoice_id)) { |
|
746 | + update_option('wpinv_last_invoice_number', $number); |
|
747 | + return apply_filters('wpinv_get_next_invoice_number', $number); |
|
748 | 748 | } |
749 | 749 | |
750 | - update_option( 'wpinv_last_invoice_number', $number + 1 ); |
|
751 | - return wpinv_get_next_invoice_number( $type ); |
|
750 | + update_option('wpinv_last_invoice_number', $number + 1); |
|
751 | + return wpinv_get_next_invoice_number($type); |
|
752 | 752 | |
753 | 753 | } |
754 | 754 | |
755 | 755 | /** |
756 | 756 | * The prefix used for invoice paths. |
757 | 757 | */ |
758 | -function wpinv_post_name_prefix( $post_type = 'wpi_invoice' ) { |
|
759 | - return apply_filters( 'wpinv_post_name_prefix', 'inv-', $post_type ); |
|
758 | +function wpinv_post_name_prefix($post_type = 'wpi_invoice') { |
|
759 | + return apply_filters('wpinv_post_name_prefix', 'inv-', $post_type); |
|
760 | 760 | } |
761 | 761 | |
762 | -function wpinv_generate_post_name( $post_ID ) { |
|
763 | - $prefix = wpinv_post_name_prefix( get_post_type( $post_ID ) ); |
|
764 | - $post_name = sanitize_title( $prefix . $post_ID ); |
|
762 | +function wpinv_generate_post_name($post_ID) { |
|
763 | + $prefix = wpinv_post_name_prefix(get_post_type($post_ID)); |
|
764 | + $post_name = sanitize_title($prefix . $post_ID); |
|
765 | 765 | |
766 | - return apply_filters( 'wpinv_generate_post_name', $post_name, $post_ID, $prefix ); |
|
766 | + return apply_filters('wpinv_generate_post_name', $post_name, $post_ID, $prefix); |
|
767 | 767 | } |
768 | 768 | |
769 | 769 | /** |
@@ -771,8 +771,8 @@ discard block |
||
771 | 771 | * |
772 | 772 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
773 | 773 | */ |
774 | -function wpinv_is_invoice_viewed( $invoice ) { |
|
775 | - $invoice = new WPInv_Invoice( $invoice ); |
|
774 | +function wpinv_is_invoice_viewed($invoice) { |
|
775 | + $invoice = new WPInv_Invoice($invoice); |
|
776 | 776 | return (bool) $invoice->get_is_viewed(); |
777 | 777 | } |
778 | 778 | |
@@ -781,17 +781,17 @@ discard block |
||
781 | 781 | * |
782 | 782 | * @param int|string|object|WPInv_Invoice|WPInv_Legacy_Invoice|WP_Post $invoice Invoice id, key, transaction id, number or object. |
783 | 783 | */ |
784 | -function getpaid_maybe_mark_invoice_as_viewed( $invoice ) { |
|
785 | - $invoice = new WPInv_Invoice( $invoice ); |
|
784 | +function getpaid_maybe_mark_invoice_as_viewed($invoice) { |
|
785 | + $invoice = new WPInv_Invoice($invoice); |
|
786 | 786 | |
787 | - if ( get_current_user_id() == $invoice->get_user_id() && ! $invoice->get_is_viewed() ) { |
|
788 | - $invoice->set_is_viewed( true ); |
|
787 | + if (get_current_user_id() == $invoice->get_user_id() && !$invoice->get_is_viewed()) { |
|
788 | + $invoice->set_is_viewed(true); |
|
789 | 789 | $invoice->save(); |
790 | 790 | } |
791 | 791 | |
792 | 792 | } |
793 | -add_action( 'wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
794 | -add_action( 'wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed' ); |
|
793 | +add_action('wpinv_invoice_print_before_display', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
794 | +add_action('wpinv_before_receipt', 'getpaid_maybe_mark_invoice_as_viewed'); |
|
795 | 795 | |
796 | 796 | /** |
797 | 797 | * Processes an invoice refund. |
@@ -801,27 +801,27 @@ discard block |
||
801 | 801 | * @param array $status_transition |
802 | 802 | * @todo: descrease customer/store earnings |
803 | 803 | */ |
804 | -function getpaid_maybe_process_refund( $invoice_id, $invoice, $status_transition ) { |
|
804 | +function getpaid_maybe_process_refund($invoice_id, $invoice, $status_transition) { |
|
805 | 805 | |
806 | - if ( empty( $status_transition['from'] ) || ! in_array( $status_transition['from'], array( 'publish', 'wpi-processing', 'wpi-renewal' ) ) ) { |
|
806 | + if (empty($status_transition['from']) || !in_array($status_transition['from'], array('publish', 'wpi-processing', 'wpi-renewal'))) { |
|
807 | 807 | return; |
808 | 808 | } |
809 | 809 | |
810 | 810 | $discount_code = $invoice->get_discount_code(); |
811 | - if ( ! empty( $discount_code ) ) { |
|
812 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
811 | + if (!empty($discount_code)) { |
|
812 | + $discount = wpinv_get_discount_obj($discount_code); |
|
813 | 813 | |
814 | - if ( $discount->exists() ) { |
|
814 | + if ($discount->exists()) { |
|
815 | 815 | $discount->increase_usage( -1 ); |
816 | 816 | } |
817 | 817 | |
818 | 818 | } |
819 | 819 | |
820 | - do_action( 'wpinv_pre_refund_invoice', $invoice, $invoice_id ); |
|
821 | - do_action( 'wpinv_refund_invoice', $invoice, $invoice_id ); |
|
822 | - do_action( 'wpinv_post_refund_invoice', $invoice, $invoice_id ); |
|
820 | + do_action('wpinv_pre_refund_invoice', $invoice, $invoice_id); |
|
821 | + do_action('wpinv_refund_invoice', $invoice, $invoice_id); |
|
822 | + do_action('wpinv_post_refund_invoice', $invoice, $invoice_id); |
|
823 | 823 | } |
824 | -add_action( 'getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 3 ); |
|
824 | +add_action('getpaid_invoice_status_wpi-refunded', 'getpaid_maybe_process_refund', 10, 3); |
|
825 | 825 | |
826 | 826 | |
827 | 827 | /** |
@@ -829,48 +829,48 @@ discard block |
||
829 | 829 | * |
830 | 830 | * @param int $invoice_id |
831 | 831 | */ |
832 | -function getpaid_process_invoice_payment( $invoice_id ) { |
|
832 | +function getpaid_process_invoice_payment($invoice_id) { |
|
833 | 833 | |
834 | 834 | // Fetch the invoice. |
835 | - $invoice = new WPInv_Invoice( $invoice_id ); |
|
835 | + $invoice = new WPInv_Invoice($invoice_id); |
|
836 | 836 | |
837 | 837 | // We only want to do this once. |
838 | - if ( 1 == get_post_meta( $invoice->get_id(), 'wpinv_processed_payment', true ) ) { |
|
838 | + if (1 == get_post_meta($invoice->get_id(), 'wpinv_processed_payment', true)) { |
|
839 | 839 | return; |
840 | 840 | } |
841 | 841 | |
842 | - update_post_meta( $invoice->get_id(), 'wpinv_processed_payment', 1 ); |
|
842 | + update_post_meta($invoice->get_id(), 'wpinv_processed_payment', 1); |
|
843 | 843 | |
844 | 844 | // Fires when processing a payment. |
845 | - do_action( 'getpaid_process_payment', $invoice ); |
|
845 | + do_action('getpaid_process_payment', $invoice); |
|
846 | 846 | |
847 | 847 | // Fire an action for each invoice item. |
848 | - foreach( $invoice->get_items() as $item ) { |
|
849 | - do_action( 'getpaid_process_item_payment', $item, $invoice ); |
|
848 | + foreach ($invoice->get_items() as $item) { |
|
849 | + do_action('getpaid_process_item_payment', $item, $invoice); |
|
850 | 850 | } |
851 | 851 | |
852 | 852 | // Increase discount usage. |
853 | 853 | $discount_code = $invoice->get_discount_code(); |
854 | - if ( ! empty( $discount_code ) && ! $invoice->is_renewal() ) { |
|
855 | - $discount = wpinv_get_discount_obj( $discount_code ); |
|
854 | + if (!empty($discount_code) && !$invoice->is_renewal()) { |
|
855 | + $discount = wpinv_get_discount_obj($discount_code); |
|
856 | 856 | |
857 | - if ( $discount->exists() ) { |
|
857 | + if ($discount->exists()) { |
|
858 | 858 | $discount->increase_usage(); |
859 | 859 | } |
860 | 860 | |
861 | 861 | } |
862 | 862 | |
863 | 863 | // Record reverse vat. |
864 | - if ( 'invoice' == $invoice->get_type() && wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
864 | + if ('invoice' == $invoice->get_type() && wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
865 | 865 | |
866 | - if ( WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country( $invoice->get_country() ) ) { |
|
867 | - $invoice->add_note( __( 'VAT was reverse charged', 'invoicing' ), false, false, true ); |
|
866 | + if (WPInv_EUVat::same_country_rule() == 'no' && wpinv_is_base_country($invoice->get_country())) { |
|
867 | + $invoice->add_note(__('VAT was reverse charged', 'invoicing'), false, false, true); |
|
868 | 868 | } |
869 | 869 | |
870 | 870 | } |
871 | 871 | |
872 | 872 | } |
873 | -add_action( 'getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment' ); |
|
873 | +add_action('getpaid_invoice_payment_status_changed', 'getpaid_process_invoice_payment'); |
|
874 | 874 | |
875 | 875 | /** |
876 | 876 | * Returns an array of invoice item columns |
@@ -878,13 +878,13 @@ discard block |
||
878 | 878 | * @param int|WPInv_Invoice $invoice |
879 | 879 | * @return array |
880 | 880 | */ |
881 | -function getpaid_invoice_item_columns( $invoice ) { |
|
881 | +function getpaid_invoice_item_columns($invoice) { |
|
882 | 882 | |
883 | 883 | // Prepare the invoice. |
884 | - $invoice = new WPInv_Invoice( $invoice ); |
|
884 | + $invoice = new WPInv_Invoice($invoice); |
|
885 | 885 | |
886 | 886 | // Abort if there is no invoice. |
887 | - if ( 0 == $invoice->get_id() ) { |
|
887 | + if (0 == $invoice->get_id()) { |
|
888 | 888 | return array(); |
889 | 889 | } |
890 | 890 | |
@@ -892,47 +892,47 @@ discard block |
||
892 | 892 | $columns = apply_filters( |
893 | 893 | 'getpaid_invoice_item_columns', |
894 | 894 | array( |
895 | - 'name' => __( 'Item', 'invoicing' ), |
|
896 | - 'price' => __( 'Price', 'invoicing' ), |
|
897 | - 'quantity' => __( 'Quantity', 'invoicing' ), |
|
898 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
895 | + 'name' => __('Item', 'invoicing'), |
|
896 | + 'price' => __('Price', 'invoicing'), |
|
897 | + 'quantity' => __('Quantity', 'invoicing'), |
|
898 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
899 | 899 | ), |
900 | 900 | $invoice |
901 | 901 | ); |
902 | 902 | |
903 | 903 | // Quantities. |
904 | - if ( isset( $columns[ 'quantity' ] ) ) { |
|
904 | + if (isset($columns['quantity'])) { |
|
905 | 905 | |
906 | - if ( 'hours' == $invoice->get_template() ) { |
|
907 | - $columns[ 'quantity' ] = __( 'Hours', 'invoicing' ); |
|
906 | + if ('hours' == $invoice->get_template()) { |
|
907 | + $columns['quantity'] = __('Hours', 'invoicing'); |
|
908 | 908 | } |
909 | 909 | |
910 | - if ( ! wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template() ) { |
|
911 | - unset( $columns[ 'quantity' ] ); |
|
910 | + if (!wpinv_item_quantities_enabled() || 'amount' == $invoice->get_template()) { |
|
911 | + unset($columns['quantity']); |
|
912 | 912 | } |
913 | 913 | |
914 | 914 | } |
915 | 915 | |
916 | 916 | |
917 | 917 | // Price. |
918 | - if ( isset( $columns[ 'price' ] ) ) { |
|
918 | + if (isset($columns['price'])) { |
|
919 | 919 | |
920 | - if ( 'amount' == $invoice->get_template() ) { |
|
921 | - $columns[ 'price' ] = __( 'Amount', 'invoicing' ); |
|
920 | + if ('amount' == $invoice->get_template()) { |
|
921 | + $columns['price'] = __('Amount', 'invoicing'); |
|
922 | 922 | } |
923 | 923 | |
924 | - if ( 'hours' == $invoice->get_template() ) { |
|
925 | - $columns[ 'price' ] = __( 'Rate', 'invoicing' ); |
|
924 | + if ('hours' == $invoice->get_template()) { |
|
925 | + $columns['price'] = __('Rate', 'invoicing'); |
|
926 | 926 | } |
927 | 927 | |
928 | 928 | } |
929 | 929 | |
930 | 930 | |
931 | 931 | // Sub total. |
932 | - if ( isset( $columns[ 'subtotal' ] ) ) { |
|
932 | + if (isset($columns['subtotal'])) { |
|
933 | 933 | |
934 | - if ( 'amount' == $invoice->get_template() ) { |
|
935 | - unset( $columns[ 'subtotal' ] ); |
|
934 | + if ('amount' == $invoice->get_template()) { |
|
935 | + unset($columns['subtotal']); |
|
936 | 936 | } |
937 | 937 | |
938 | 938 | } |
@@ -946,30 +946,30 @@ discard block |
||
946 | 946 | * @param int|WPInv_Invoice $invoice |
947 | 947 | * @return array |
948 | 948 | */ |
949 | -function getpaid_invoice_totals_rows( $invoice ) { |
|
949 | +function getpaid_invoice_totals_rows($invoice) { |
|
950 | 950 | |
951 | 951 | // Prepare the invoice. |
952 | - $invoice = new WPInv_Invoice( $invoice ); |
|
952 | + $invoice = new WPInv_Invoice($invoice); |
|
953 | 953 | |
954 | 954 | // Abort if there is no invoice. |
955 | - if ( 0 == $invoice->get_id() ) { |
|
955 | + if (0 == $invoice->get_id()) { |
|
956 | 956 | return array(); |
957 | 957 | } |
958 | 958 | |
959 | 959 | $totals = apply_filters( |
960 | 960 | 'getpaid_invoice_totals_rows', |
961 | 961 | array( |
962 | - 'subtotal' => __( 'Subtotal', 'invoicing' ), |
|
963 | - 'tax' => __( 'Tax', 'invoicing' ), |
|
964 | - 'fee' => __( 'Fee', 'invoicing' ), |
|
965 | - 'discount' => __( 'Discount', 'invoicing' ), |
|
966 | - 'total' => __( 'Total', 'invoicing' ), |
|
962 | + 'subtotal' => __('Subtotal', 'invoicing'), |
|
963 | + 'tax' => __('Tax', 'invoicing'), |
|
964 | + 'fee' => __('Fee', 'invoicing'), |
|
965 | + 'discount' => __('Discount', 'invoicing'), |
|
966 | + 'total' => __('Total', 'invoicing'), |
|
967 | 967 | ), |
968 | 968 | $invoice |
969 | 969 | ); |
970 | 970 | |
971 | - if ( ( $invoice->get_disable_taxes() || ! wpinv_use_taxes() ) && isset( $totals['tax'] ) ) { |
|
972 | - unset( $totals['tax'] ); |
|
971 | + if (($invoice->get_disable_taxes() || !wpinv_use_taxes()) && isset($totals['tax'])) { |
|
972 | + unset($totals['tax']); |
|
973 | 973 | } |
974 | 974 | |
975 | 975 | return $totals; |
@@ -980,46 +980,46 @@ discard block |
||
980 | 980 | * |
981 | 981 | * @param WPInv_Invoice $invoice |
982 | 982 | */ |
983 | -function getpaid_new_invoice( $invoice ) { |
|
983 | +function getpaid_new_invoice($invoice) { |
|
984 | 984 | |
985 | - if ( ! $invoice->get_status() ) { |
|
985 | + if (!$invoice->get_status()) { |
|
986 | 986 | return; |
987 | 987 | } |
988 | 988 | |
989 | 989 | // Add an invoice created note. |
990 | 990 | $invoice->add_note( |
991 | 991 | wp_sprintf( |
992 | - __( 'Invoice created with the status "%s".', 'invoicing' ), |
|
993 | - wpinv_status_nicename( $invoice->get_status() ) |
|
992 | + __('Invoice created with the status "%s".', 'invoicing'), |
|
993 | + wpinv_status_nicename($invoice->get_status()) |
|
994 | 994 | ) |
995 | 995 | ); |
996 | 996 | |
997 | 997 | } |
998 | -add_action( 'getpaid_new_invoice', 'getpaid_new_invoice' ); |
|
998 | +add_action('getpaid_new_invoice', 'getpaid_new_invoice'); |
|
999 | 999 | |
1000 | 1000 | /** |
1001 | 1001 | * This function updates invoice caches. |
1002 | 1002 | * |
1003 | 1003 | * @param WPInv_Invoice $invoice |
1004 | 1004 | */ |
1005 | -function getpaid_update_invoice_caches( $invoice ) { |
|
1005 | +function getpaid_update_invoice_caches($invoice) { |
|
1006 | 1006 | |
1007 | 1007 | // Cache invoice number. |
1008 | - wp_cache_set( $invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids" ); |
|
1008 | + wp_cache_set($invoice->get_number(), $invoice->get_id(), "getpaid_invoice_numbers_to_invoice_ids"); |
|
1009 | 1009 | |
1010 | 1010 | // Cache invoice key. |
1011 | - wp_cache_set( $invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids" ); |
|
1011 | + wp_cache_set($invoice->get_key(), $invoice->get_id(), "getpaid_invoice_keys_to_invoice_ids"); |
|
1012 | 1012 | |
1013 | 1013 | // (Maybe) cache transaction id. |
1014 | 1014 | $transaction_id = $invoice->get_transaction_id(); |
1015 | 1015 | |
1016 | - if ( ! empty( $transaction_id ) ) { |
|
1017 | - wp_cache_set( $transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids" ); |
|
1016 | + if (!empty($transaction_id)) { |
|
1017 | + wp_cache_set($transaction_id, $invoice->get_id(), "getpaid_invoice_transaction_ids_to_invoice_ids"); |
|
1018 | 1018 | } |
1019 | 1019 | |
1020 | 1020 | } |
1021 | -add_action( 'getpaid_new_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1022 | -add_action( 'getpaid_update_invoice', 'getpaid_update_invoice_caches', 5 ); |
|
1021 | +add_action('getpaid_new_invoice', 'getpaid_update_invoice_caches', 5); |
|
1022 | +add_action('getpaid_update_invoice', 'getpaid_update_invoice_caches', 5); |
|
1023 | 1023 | |
1024 | 1024 | /** |
1025 | 1025 | * Duplicates an invoice. |
@@ -1029,7 +1029,7 @@ discard block |
||
1029 | 1029 | * @param WPInv_Invoice $old_invoice The invoice to duplicate |
1030 | 1030 | * @return WPInv_Invoice The new invoice. |
1031 | 1031 | */ |
1032 | -function getpaid_duplicate_invoice( $old_invoice ) { |
|
1032 | +function getpaid_duplicate_invoice($old_invoice) { |
|
1033 | 1033 | |
1034 | 1034 | // Create the new invoice. |
1035 | 1035 | $invoice = new WPInv_Invoice(); |
@@ -4,7 +4,7 @@ discard block |
||
4 | 4 | * |
5 | 5 | */ |
6 | 6 | |
7 | -defined( 'ABSPATH' ) || exit; |
|
7 | +defined('ABSPATH') || exit; |
|
8 | 8 | |
9 | 9 | /** |
10 | 10 | * Authorize.net Payment Gateway class. |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | * |
25 | 25 | * @var array |
26 | 26 | */ |
27 | - protected $supports = array( 'subscription', 'sandbox', 'tokens' ); |
|
27 | + protected $supports = array('subscription', 'sandbox', 'tokens'); |
|
28 | 28 | |
29 | 29 | /** |
30 | 30 | * Payment method order. |
@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | * |
53 | 53 | * @var array |
54 | 54 | */ |
55 | - public $currencies = array( 'USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD' ); |
|
55 | + public $currencies = array('USD', 'CAD', 'GBP', 'DKK', 'NOK', 'PLN', 'SEK', 'AUD', 'EUR', 'NZD'); |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * URL to view a transaction. |
@@ -66,12 +66,12 @@ discard block |
||
66 | 66 | */ |
67 | 67 | public function __construct() { |
68 | 68 | |
69 | - $this->title = __( 'Credit Card / Debit Card', 'invoicing' ); |
|
70 | - $this->method_title = __( 'Authorize.Net', 'invoicing' ); |
|
71 | - $this->notify_url = wpinv_get_ipn_url( $this->id ); |
|
69 | + $this->title = __('Credit Card / Debit Card', 'invoicing'); |
|
70 | + $this->method_title = __('Authorize.Net', 'invoicing'); |
|
71 | + $this->notify_url = wpinv_get_ipn_url($this->id); |
|
72 | 72 | |
73 | - add_filter( 'getpaid_daily_maintenance_should_expire_subscription', array( $this, 'maybe_renew_subscription' ), 10, 2 ); |
|
74 | - add_filter( 'wpinv_gateway_description', array( $this, 'sandbox_notice' ), 10, 2 ); |
|
73 | + add_filter('getpaid_daily_maintenance_should_expire_subscription', array($this, 'maybe_renew_subscription'), 10, 2); |
|
74 | + add_filter('wpinv_gateway_description', array($this, 'sandbox_notice'), 10, 2); |
|
75 | 75 | parent::__construct(); |
76 | 76 | } |
77 | 77 | |
@@ -81,13 +81,13 @@ discard block |
||
81 | 81 | * @param int $invoice_id 0 or invoice id. |
82 | 82 | * @param GetPaid_Payment_Form $form Current payment form. |
83 | 83 | */ |
84 | - public function payment_fields( $invoice_id, $form ) { |
|
84 | + public function payment_fields($invoice_id, $form) { |
|
85 | 85 | |
86 | 86 | // Let the user select a payment method. |
87 | 87 | echo $this->saved_payment_methods(); |
88 | 88 | |
89 | 89 | // Show the credit card entry form. |
90 | - echo $this->new_payment_method_entry( $this->get_cc_form( true ) ); |
|
90 | + echo $this->new_payment_method_entry($this->get_cc_form(true)); |
|
91 | 91 | } |
92 | 92 | |
93 | 93 | /** |
@@ -100,64 +100,64 @@ discard block |
||
100 | 100 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
101 | 101 | * @return string|WP_Error Payment profile id. |
102 | 102 | */ |
103 | - public function create_customer_profile( $invoice, $submission_data, $save = true ) { |
|
103 | + public function create_customer_profile($invoice, $submission_data, $save = true) { |
|
104 | 104 | |
105 | 105 | // Remove non-digits from the number |
106 | - $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
106 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
107 | 107 | |
108 | 108 | // Generate args. |
109 | 109 | $args = array( |
110 | 110 | 'createCustomerProfileRequest' => array( |
111 | 111 | 'merchantAuthentication' => $this->get_auth_params(), |
112 | 112 | 'profile' => array( |
113 | - 'merchantCustomerId' => getpaid_limit_length( $invoice->get_user_id(), 20 ), |
|
114 | - 'description' => getpaid_limit_length( $invoice->get_full_name(), 255 ), |
|
115 | - 'email' => getpaid_limit_length( $invoice->get_email(), 255 ), |
|
113 | + 'merchantCustomerId' => getpaid_limit_length($invoice->get_user_id(), 20), |
|
114 | + 'description' => getpaid_limit_length($invoice->get_full_name(), 255), |
|
115 | + 'email' => getpaid_limit_length($invoice->get_email(), 255), |
|
116 | 116 | 'paymentProfiles' => array( |
117 | 117 | 'customerType' => 'individual', |
118 | 118 | |
119 | 119 | // Billing information. |
120 | 120 | 'billTo' => array( |
121 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
122 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
123 | - 'address' => getpaid_limit_length( $invoice->get_last_name(), 60 ), |
|
124 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
125 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
126 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
127 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
121 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
122 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
123 | + 'address' => getpaid_limit_length($invoice->get_last_name(), 60), |
|
124 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
125 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
126 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
127 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
128 | 128 | ), |
129 | 129 | |
130 | 130 | // Payment information. |
131 | - 'payment' => $this->get_payment_information( $submission_data['authorizenet'] ), |
|
131 | + 'payment' => $this->get_payment_information($submission_data['authorizenet']), |
|
132 | 132 | ) |
133 | 133 | ), |
134 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
134 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
135 | 135 | ) |
136 | 136 | ); |
137 | 137 | |
138 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_customer_profile_args', $args, $invoice ), $invoice ); |
|
138 | + $response = $this->post(apply_filters('getpaid_authorizenet_customer_profile_args', $args, $invoice), $invoice); |
|
139 | 139 | |
140 | - if ( is_wp_error( $response ) ) { |
|
140 | + if (is_wp_error($response)) { |
|
141 | 141 | return $response; |
142 | 142 | } |
143 | 143 | |
144 | - update_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), $response->customerProfileId ); |
|
144 | + update_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), $response->customerProfileId); |
|
145 | 145 | |
146 | 146 | // Save the payment token. |
147 | - if ( $save ) { |
|
147 | + if ($save) { |
|
148 | 148 | $this->save_token( |
149 | 149 | array( |
150 | 150 | 'id' => $response->customerPaymentProfileIdList[0], |
151 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . '····' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
151 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . '····' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
152 | 152 | 'default' => true, |
153 | - 'type' => $this->is_sandbox( $invoice ) ? 'sandbox' : 'live', |
|
153 | + 'type' => $this->is_sandbox($invoice) ? 'sandbox' : 'live', |
|
154 | 154 | ) |
155 | 155 | ); |
156 | 156 | } |
157 | 157 | |
158 | 158 | // Add a note about the validation response. |
159 | 159 | $invoice->add_note( |
160 | - sprintf( __( 'Created Authorize.NET customer profile: %s', 'invoicing' ), $response->validationDirectResponseList[0] ), |
|
160 | + sprintf(__('Created Authorize.NET customer profile: %s', 'invoicing'), $response->validationDirectResponseList[0]), |
|
161 | 161 | false, |
162 | 162 | false, |
163 | 163 | true |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | * @return string|WP_Error Profile id. |
175 | 175 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-profile |
176 | 176 | */ |
177 | - public function get_customer_profile( $profile_id ) { |
|
177 | + public function get_customer_profile($profile_id) { |
|
178 | 178 | |
179 | 179 | // Generate args. |
180 | 180 | $args = array( |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | ) |
185 | 185 | ); |
186 | 186 | |
187 | - return $this->post( $args, false ); |
|
187 | + return $this->post($args, false); |
|
188 | 188 | |
189 | 189 | } |
190 | 190 | |
@@ -199,10 +199,10 @@ discard block |
||
199 | 199 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-create-customer-profile |
200 | 200 | * @return string|WP_Error Profile id. |
201 | 201 | */ |
202 | - public function create_customer_payment_profile( $customer_profile, $invoice, $submission_data, $save ) { |
|
202 | + public function create_customer_payment_profile($customer_profile, $invoice, $submission_data, $save) { |
|
203 | 203 | |
204 | 204 | // Remove non-digits from the number |
205 | - $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number'] ); |
|
205 | + $submission_data['authorizenet']['cc_number'] = preg_replace('/\D/', '', $submission_data['authorizenet']['cc_number']); |
|
206 | 206 | |
207 | 207 | // Generate args. |
208 | 208 | $args = array( |
@@ -213,34 +213,34 @@ discard block |
||
213 | 213 | |
214 | 214 | // Billing information. |
215 | 215 | 'billTo' => array( |
216 | - 'firstName' => getpaid_limit_length( $invoice->get_first_name(), 50 ), |
|
217 | - 'lastName' => getpaid_limit_length( $invoice->get_last_name(), 50 ), |
|
218 | - 'address' => getpaid_limit_length( $invoice->get_last_name(), 60 ), |
|
219 | - 'city' => getpaid_limit_length( $invoice->get_city(), 40 ), |
|
220 | - 'state' => getpaid_limit_length( $invoice->get_state(), 40 ), |
|
221 | - 'zip' => getpaid_limit_length( $invoice->get_zip(), 20 ), |
|
222 | - 'country' => getpaid_limit_length( $invoice->get_country(), 60 ), |
|
216 | + 'firstName' => getpaid_limit_length($invoice->get_first_name(), 50), |
|
217 | + 'lastName' => getpaid_limit_length($invoice->get_last_name(), 50), |
|
218 | + 'address' => getpaid_limit_length($invoice->get_last_name(), 60), |
|
219 | + 'city' => getpaid_limit_length($invoice->get_city(), 40), |
|
220 | + 'state' => getpaid_limit_length($invoice->get_state(), 40), |
|
221 | + 'zip' => getpaid_limit_length($invoice->get_zip(), 20), |
|
222 | + 'country' => getpaid_limit_length($invoice->get_country(), 60), |
|
223 | 223 | ), |
224 | 224 | |
225 | 225 | // Payment information. |
226 | - 'payment' => $this->get_payment_information( $submission_data['authorizenet'] ) |
|
226 | + 'payment' => $this->get_payment_information($submission_data['authorizenet']) |
|
227 | 227 | ), |
228 | - 'validationMode' => $this->is_sandbox( $invoice ) ? 'testMode' : 'liveMode', |
|
228 | + 'validationMode' => $this->is_sandbox($invoice) ? 'testMode' : 'liveMode', |
|
229 | 229 | ) |
230 | 230 | ); |
231 | 231 | |
232 | - $response = $this->post( apply_filters( 'getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
232 | + $response = $this->post(apply_filters('getpaid_authorizenet_create_customer_payment_profile_args', $args, $invoice), $invoice); |
|
233 | 233 | |
234 | - if ( is_wp_error( $response ) ) { |
|
234 | + if (is_wp_error($response)) { |
|
235 | 235 | return $response; |
236 | 236 | } |
237 | 237 | |
238 | 238 | // Save the payment token. |
239 | - if ( $save ) { |
|
239 | + if ($save) { |
|
240 | 240 | $this->save_token( |
241 | 241 | array( |
242 | 242 | 'id' => $response->customerPaymentProfileId, |
243 | - 'name' => getpaid_get_card_name( $submission_data['authorizenet']['cc_number'] ) . ' ···· ' . substr( $submission_data['authorizenet']['cc_number'], -4 ), |
|
243 | + 'name' => getpaid_get_card_name($submission_data['authorizenet']['cc_number']) . ' ···· ' . substr($submission_data['authorizenet']['cc_number'], -4), |
|
244 | 244 | 'default' => true |
245 | 245 | ) |
246 | 246 | ); |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | |
249 | 249 | // Add a note about the validation response. |
250 | 250 | $invoice->add_note( |
251 | - sprintf( __( 'Saved Authorize.NET payment profile: %s', 'invoicing' ), $response->validationDirectResponse ), |
|
251 | + sprintf(__('Saved Authorize.NET payment profile: %s', 'invoicing'), $response->validationDirectResponse), |
|
252 | 252 | false, |
253 | 253 | false, |
254 | 254 | true |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | * @return string|WP_Error Profile id. |
268 | 268 | * @link https://developer.authorize.net/api/reference/index.html#customer-profiles-get-customer-payment-profile |
269 | 269 | */ |
270 | - public function get_customer_payment_profile( $customer_profile_id, $payment_profile_id ) { |
|
270 | + public function get_customer_payment_profile($customer_profile_id, $payment_profile_id) { |
|
271 | 271 | |
272 | 272 | // Generate args. |
273 | 273 | $args = array( |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | ) |
279 | 279 | ); |
280 | 280 | |
281 | - return $this->post( $args, false ); |
|
281 | + return $this->post($args, false); |
|
282 | 282 | |
283 | 283 | } |
284 | 284 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @link https://developer.authorize.net/api/reference/index.html#payment-transactions-charge-a-customer-profile |
292 | 292 | * @return WP_Error|object |
293 | 293 | */ |
294 | - public function charge_customer_payment_profile( $customer_profile_id, $payment_profile_id, $invoice ) { |
|
294 | + public function charge_customer_payment_profile($customer_profile_id, $payment_profile_id, $invoice) { |
|
295 | 295 | |
296 | 296 | // Generate args. |
297 | 297 | $args = array( |
@@ -311,28 +311,28 @@ discard block |
||
311 | 311 | ) |
312 | 312 | ), |
313 | 313 | 'order' => array( |
314 | - 'invoiceNumber' => getpaid_limit_length( $invoice->get_number(), 20 ), |
|
314 | + 'invoiceNumber' => getpaid_limit_length($invoice->get_number(), 20), |
|
315 | 315 | ), |
316 | - 'lineItems' => array( 'lineItem' => $this->get_line_items( $invoice ) ), |
|
316 | + 'lineItems' => array('lineItem' => $this->get_line_items($invoice)), |
|
317 | 317 | 'tax' => array( |
318 | 318 | 'amount' => $invoice->get_total_tax(), |
319 | 319 | 'name' => getpaid_tax()->get_vat_name(), |
320 | 320 | ), |
321 | - 'poNumber' => getpaid_limit_length( $invoice->get_number(), 25 ), |
|
321 | + 'poNumber' => getpaid_limit_length($invoice->get_number(), 25), |
|
322 | 322 | 'customer' => array( |
323 | - 'id' => getpaid_limit_length( $invoice->get_user_id(), 25 ), |
|
324 | - 'email' => getpaid_limit_length( $invoice->get_email(), 25 ), |
|
323 | + 'id' => getpaid_limit_length($invoice->get_user_id(), 25), |
|
324 | + 'email' => getpaid_limit_length($invoice->get_email(), 25), |
|
325 | 325 | ), |
326 | 326 | 'customerIP' => $invoice->get_ip(), |
327 | 327 | ) |
328 | 328 | ) |
329 | 329 | ); |
330 | 330 | |
331 | - if ( 0 == $invoice->get_total_tax() ) { |
|
332 | - unset( $args['createTransactionRequest']['transactionRequest']['tax'] ); |
|
331 | + if (0 == $invoice->get_total_tax()) { |
|
332 | + unset($args['createTransactionRequest']['transactionRequest']['tax']); |
|
333 | 333 | } |
334 | 334 | |
335 | - return $this->post( apply_filters( 'getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice ), $invoice ); |
|
335 | + return $this->post(apply_filters('getpaid_authorizenet_charge_customer_payment_profile_args', $args, $invoice), $invoice); |
|
336 | 336 | |
337 | 337 | } |
338 | 338 | |
@@ -342,29 +342,29 @@ discard block |
||
342 | 342 | * @param stdClass $result Api response. |
343 | 343 | * @param WPInv_Invoice $invoice Invoice. |
344 | 344 | */ |
345 | - public function process_charge_response( $result, $invoice ) { |
|
345 | + public function process_charge_response($result, $invoice) { |
|
346 | 346 | |
347 | 347 | wpinv_clear_errors(); |
348 | 348 | $response_code = (int) $result->transactionResponse->responseCode; |
349 | 349 | |
350 | 350 | // Succeeded. |
351 | - if ( 1 == $response_code || 4 == $response_code ) { |
|
351 | + if (1 == $response_code || 4 == $response_code) { |
|
352 | 352 | |
353 | 353 | // Maybe set a transaction id. |
354 | - if ( ! empty( $result->transactionResponse->transId ) ) { |
|
355 | - $invoice->set_transaction_id( $result->transactionResponse->transId ); |
|
354 | + if (!empty($result->transactionResponse->transId)) { |
|
355 | + $invoice->set_transaction_id($result->transactionResponse->transId); |
|
356 | 356 | } |
357 | 357 | |
358 | - $invoice->add_note( sprintf( __( 'Authentication code: %s (%s).', 'invoicing' ), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber ), false, false, true ); |
|
358 | + $invoice->add_note(sprintf(__('Authentication code: %s (%s).', 'invoicing'), $result->transactionResponse->authCode, $result->transactionResponse->accountNumber), false, false, true); |
|
359 | 359 | |
360 | - if ( 1 == $response_code ) { |
|
360 | + if (1 == $response_code) { |
|
361 | 361 | return $invoice->mark_paid(); |
362 | 362 | } |
363 | 363 | |
364 | - $invoice->set_status( 'wpi-onhold' ); |
|
364 | + $invoice->set_status('wpi-onhold'); |
|
365 | 365 | $invoice->add_note( |
366 | 366 | sprintf( |
367 | - __( 'Held for review: %s', 'invoicing' ), |
|
367 | + __('Held for review: %s', 'invoicing'), |
|
368 | 368 | $result->transactionResponse->messages->message[0]->description |
369 | 369 | ) |
370 | 370 | ); |
@@ -373,11 +373,11 @@ discard block |
||
373 | 373 | |
374 | 374 | } |
375 | 375 | |
376 | - wpinv_set_error( 'card_declined', __( 'Credit card declined.', 'invoicing' ) ); |
|
376 | + wpinv_set_error('card_declined', __('Credit card declined.', 'invoicing')); |
|
377 | 377 | |
378 | - if ( ! empty( $result->transactionResponse->errors ) ) { |
|
378 | + if (!empty($result->transactionResponse->errors)) { |
|
379 | 379 | $errors = (object) $result->transactionResponse->errors; |
380 | - wpinv_set_error( $errors->error[0]->errorCode, esc_html( $errors->error[0]->errorText ) ); |
|
380 | + wpinv_set_error($errors->error[0]->errorCode, esc_html($errors->error[0]->errorText)); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | } |
@@ -389,10 +389,10 @@ discard block |
||
389 | 389 | * @param array $card Card details. |
390 | 390 | * @return array |
391 | 391 | */ |
392 | - public function get_payment_information( $card ) { |
|
392 | + public function get_payment_information($card) { |
|
393 | 393 | return array( |
394 | 394 | |
395 | - 'creditCard' => array ( |
|
395 | + 'creditCard' => array( |
|
396 | 396 | 'cardNumber' => $card['cc_number'], |
397 | 397 | 'expirationDate' => $card['cc_expire_year'] . '-' . $card['cc_expire_month'], |
398 | 398 | 'cardCode' => $card['cc_cvv2'], |
@@ -408,8 +408,8 @@ discard block |
||
408 | 408 | * @param WPInv_Invoice $invoice Invoice. |
409 | 409 | * @return string |
410 | 410 | */ |
411 | - public function get_customer_profile_meta_name( $invoice ) { |
|
412 | - return $this->is_sandbox( $invoice ) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
411 | + public function get_customer_profile_meta_name($invoice) { |
|
412 | + return $this->is_sandbox($invoice) ? 'getpaid_authorizenet_sandbox_customer_profile_id' : 'getpaid_authorizenet_customer_profile_id'; |
|
413 | 413 | } |
414 | 414 | |
415 | 415 | /** |
@@ -420,34 +420,34 @@ discard block |
||
420 | 420 | * @param WPInv_Invoice $invoice |
421 | 421 | * @return WP_Error|string The payment profile id |
422 | 422 | */ |
423 | - public function validate_submission_data( $submission_data, $invoice ) { |
|
423 | + public function validate_submission_data($submission_data, $invoice) { |
|
424 | 424 | |
425 | 425 | // Validate authentication details. |
426 | 426 | $auth = $this->get_auth_params(); |
427 | 427 | |
428 | - if ( empty( $auth['name'] ) || empty( $auth['transactionKey'] ) ) { |
|
429 | - return new WP_Error( 'invalid_settings', __( 'Please set-up your login id and transaction key before using this gateway.', 'invoicing') ); |
|
428 | + if (empty($auth['name']) || empty($auth['transactionKey'])) { |
|
429 | + return new WP_Error('invalid_settings', __('Please set-up your login id and transaction key before using this gateway.', 'invoicing')); |
|
430 | 430 | } |
431 | 431 | |
432 | 432 | // Validate the payment method. |
433 | - if ( empty( $submission_data['getpaid-authorizenet-payment-method'] ) ) { |
|
434 | - return new WP_Error( 'invalid_payment_method', __( 'Please select a different payment method or add a new card.', 'invoicing') ); |
|
433 | + if (empty($submission_data['getpaid-authorizenet-payment-method'])) { |
|
434 | + return new WP_Error('invalid_payment_method', __('Please select a different payment method or add a new card.', 'invoicing')); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | // Are we adding a new payment method? |
438 | - if ( 'new' != $submission_data['getpaid-authorizenet-payment-method'] ) { |
|
438 | + if ('new' != $submission_data['getpaid-authorizenet-payment-method']) { |
|
439 | 439 | return $submission_data['getpaid-authorizenet-payment-method']; |
440 | 440 | } |
441 | 441 | |
442 | 442 | // Retrieve the customer profile id. |
443 | - $profile_id = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
443 | + $profile_id = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
444 | 444 | |
445 | 445 | // Create payment method. |
446 | - if ( empty( $profile_id ) ) { |
|
447 | - return $this->create_customer_profile( $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
446 | + if (empty($profile_id)) { |
|
447 | + return $this->create_customer_profile($invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
448 | 448 | } |
449 | 449 | |
450 | - return $this->create_customer_payment_profile( $profile_id, $invoice, $submission_data, ! empty( $submission_data['getpaid-authorizenet-new-payment-method'] ) ); |
|
450 | + return $this->create_customer_payment_profile($profile_id, $invoice, $submission_data, !empty($submission_data['getpaid-authorizenet-new-payment-method'])); |
|
451 | 451 | |
452 | 452 | } |
453 | 453 | |
@@ -458,16 +458,16 @@ discard block |
||
458 | 458 | * @param WPInv_Invoice $invoice Invoice. |
459 | 459 | * @return array |
460 | 460 | */ |
461 | - public function get_line_items( $invoice ) { |
|
461 | + public function get_line_items($invoice) { |
|
462 | 462 | $items = array(); |
463 | 463 | |
464 | - foreach ( $invoice->get_items() as $item ) { |
|
464 | + foreach ($invoice->get_items() as $item) { |
|
465 | 465 | |
466 | 466 | $amount = $invoice->is_renewal() ? $item->get_price() : $item->get_initial_price(); |
467 | 467 | $items[] = array( |
468 | - 'itemId' => getpaid_limit_length( $item->get_id(), 31 ), |
|
469 | - 'name' => getpaid_limit_length( $item->get_raw_name(), 31 ), |
|
470 | - 'description' => getpaid_limit_length( $item->get_description(), 255 ), |
|
468 | + 'itemId' => getpaid_limit_length($item->get_id(), 31), |
|
469 | + 'name' => getpaid_limit_length($item->get_raw_name(), 31), |
|
470 | + 'description' => getpaid_limit_length($item->get_description(), 255), |
|
471 | 471 | 'quantity' => (string) $invoice->get_template() == 'amount' ? 1 : $item->get_quantity(), |
472 | 472 | 'unitPrice' => (float) $amount, |
473 | 473 | 'taxable' => wpinv_use_taxes() && $invoice->is_taxable() && 'tax-exempt' != $item->get_vat_rule(), |
@@ -475,15 +475,15 @@ discard block |
||
475 | 475 | |
476 | 476 | } |
477 | 477 | |
478 | - foreach ( $invoice->get_fees() as $fee_name => $fee ) { |
|
478 | + foreach ($invoice->get_fees() as $fee_name => $fee) { |
|
479 | 479 | |
480 | - $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
480 | + $amount = $invoice->is_renewal() ? $fee['recurring_fee'] : $fee['initial_fee']; |
|
481 | 481 | |
482 | - if ( $amount > 0 ) { |
|
482 | + if ($amount > 0) { |
|
483 | 483 | $items[] = array( |
484 | - 'itemId' => getpaid_limit_length( $fee_name, 31 ), |
|
485 | - 'name' => getpaid_limit_length( $fee_name, 31 ), |
|
486 | - 'description' => getpaid_limit_length( $fee_name, 255 ), |
|
484 | + 'itemId' => getpaid_limit_length($fee_name, 31), |
|
485 | + 'name' => getpaid_limit_length($fee_name, 31), |
|
486 | + 'description' => getpaid_limit_length($fee_name, 255), |
|
487 | 487 | 'quantity' => '1', |
488 | 488 | 'unitPrice' => (float) $amount, |
489 | 489 | 'taxable' => false, |
@@ -504,36 +504,36 @@ discard block |
||
504 | 504 | * @param GetPaid_Payment_Form_Submission $submission Checkout submission. |
505 | 505 | * @return array |
506 | 506 | */ |
507 | - public function process_payment( $invoice, $submission_data, $submission ) { |
|
507 | + public function process_payment($invoice, $submission_data, $submission) { |
|
508 | 508 | |
509 | 509 | // Validate the submitted data. |
510 | - $payment_profile_id = $this->validate_submission_data( $submission_data, $invoice ); |
|
510 | + $payment_profile_id = $this->validate_submission_data($submission_data, $invoice); |
|
511 | 511 | |
512 | 512 | // Do we have an error? |
513 | - if ( is_wp_error( $payment_profile_id ) ) { |
|
514 | - wpinv_set_error( $payment_profile_id->get_error_code(), $payment_profile_id->get_error_message() ); |
|
513 | + if (is_wp_error($payment_profile_id)) { |
|
514 | + wpinv_set_error($payment_profile_id->get_error_code(), $payment_profile_id->get_error_message()); |
|
515 | 515 | wpinv_send_back_to_checkout(); |
516 | 516 | } |
517 | 517 | |
518 | 518 | // Save the payment method to the order. |
519 | - update_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id ); |
|
519 | + update_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', $payment_profile_id); |
|
520 | 520 | |
521 | 521 | // Check if this is a subscription or not. |
522 | - $subscription = getpaid_get_invoice_subscription( $invoice ); |
|
523 | - if ( ! empty( $subscription ) ) { |
|
524 | - $this->process_subscription( $invoice, $subscription ); |
|
522 | + $subscription = getpaid_get_invoice_subscription($invoice); |
|
523 | + if (!empty($subscription)) { |
|
524 | + $this->process_subscription($invoice, $subscription); |
|
525 | 525 | } |
526 | 526 | |
527 | 527 | // If it is free, send to the success page. |
528 | - if ( ! $invoice->needs_payment() ) { |
|
528 | + if (!$invoice->needs_payment()) { |
|
529 | 529 | $invoice->mark_paid(); |
530 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
530 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | // Charge the payment profile. |
534 | - $this->process_initial_payment( $invoice ); |
|
534 | + $this->process_initial_payment($invoice); |
|
535 | 535 | |
536 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
536 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
537 | 537 | |
538 | 538 | exit; |
539 | 539 | |
@@ -544,22 +544,22 @@ discard block |
||
544 | 544 | * |
545 | 545 | * @param WPInv_Invoice $invoice Invoice. |
546 | 546 | */ |
547 | - protected function process_initial_payment( $invoice ) { |
|
547 | + protected function process_initial_payment($invoice) { |
|
548 | 548 | |
549 | - $payment_profile_id = get_post_meta( $invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
550 | - $customer_profile = get_user_meta( $invoice->get_user_id(), $this->get_customer_profile_meta_name( $invoice ), true ); |
|
551 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $invoice ); |
|
549 | + $payment_profile_id = get_post_meta($invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
550 | + $customer_profile = get_user_meta($invoice->get_user_id(), $this->get_customer_profile_meta_name($invoice), true); |
|
551 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $invoice); |
|
552 | 552 | |
553 | 553 | // Do we have an error? |
554 | - if ( is_wp_error( $result ) ) { |
|
555 | - wpinv_set_error( $result->get_error_code(), $result->get_error_message() ); |
|
554 | + if (is_wp_error($result)) { |
|
555 | + wpinv_set_error($result->get_error_code(), $result->get_error_message()); |
|
556 | 556 | wpinv_send_back_to_checkout(); |
557 | 557 | } |
558 | 558 | |
559 | 559 | // Process the response. |
560 | - $this->process_charge_response( $result, $invoice ); |
|
560 | + $this->process_charge_response($result, $invoice); |
|
561 | 561 | |
562 | - if ( wpinv_get_errors() ) { |
|
562 | + if (wpinv_get_errors()) { |
|
563 | 563 | wpinv_send_back_to_checkout(); |
564 | 564 | } |
565 | 565 | |
@@ -571,24 +571,24 @@ discard block |
||
571 | 571 | * @param WPInv_Invoice $invoice Invoice. |
572 | 572 | * @param WPInv_Subscription $subscription Subscription. |
573 | 573 | */ |
574 | - public function process_subscription( $invoice, $subscription ) { |
|
574 | + public function process_subscription($invoice, $subscription) { |
|
575 | 575 | |
576 | 576 | // Check if there is an initial amount to charge. |
577 | - if ( (float) $invoice->get_total() > 0 ) { |
|
578 | - $this->process_initial_payment( $invoice ); |
|
577 | + if ((float) $invoice->get_total() > 0) { |
|
578 | + $this->process_initial_payment($invoice); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | // Activate the subscription. |
582 | - $duration = strtotime( $subscription->get_expiration() ) - strtotime( $subscription->get_date_created() ); |
|
583 | - $expiry = date( 'Y-m-d H:i:s', ( current_time( 'timestamp' ) + $duration ) ); |
|
582 | + $duration = strtotime($subscription->get_expiration()) - strtotime($subscription->get_date_created()); |
|
583 | + $expiry = date('Y-m-d H:i:s', (current_time('timestamp') + $duration)); |
|
584 | 584 | |
585 | - $subscription->set_next_renewal_date( $expiry ); |
|
586 | - $subscription->set_date_created( current_time( 'mysql' ) ); |
|
587 | - $subscription->set_profile_id( $invoice->generate_key() ); |
|
585 | + $subscription->set_next_renewal_date($expiry); |
|
586 | + $subscription->set_date_created(current_time('mysql')); |
|
587 | + $subscription->set_profile_id($invoice->generate_key()); |
|
588 | 588 | $subscription->activate(); |
589 | 589 | |
590 | 590 | // Redirect to the success page. |
591 | - wpinv_send_to_success_page( array( 'invoice_key' => $invoice->get_key() ) ); |
|
591 | + wpinv_send_to_success_page(array('invoice_key' => $invoice->get_key())); |
|
592 | 592 | |
593 | 593 | } |
594 | 594 | |
@@ -599,20 +599,20 @@ discard block |
||
599 | 599 | * @param bool $should_expire |
600 | 600 | * @param WPInv_Subscription $subscription |
601 | 601 | */ |
602 | - public function maybe_renew_subscription( $should_expire, $subscription ) { |
|
602 | + public function maybe_renew_subscription($should_expire, $subscription) { |
|
603 | 603 | |
604 | 604 | // Ensure its our subscription && it's active. |
605 | - if ( $this->id != $subscription->get_gateway() || ! $subscription->has_status( 'active trialling' ) ) { |
|
605 | + if ($this->id != $subscription->get_gateway() || !$subscription->has_status('active trialling')) { |
|
606 | 606 | return $should_expire; |
607 | 607 | } |
608 | 608 | |
609 | 609 | // If this is the last renewal, complete the subscription. |
610 | - if ( $subscription->is_last_renewal() ) { |
|
610 | + if ($subscription->is_last_renewal()) { |
|
611 | 611 | $subscription->complete(); |
612 | 612 | return false; |
613 | 613 | } |
614 | 614 | |
615 | - $this->renew_subscription( $subscription ); |
|
615 | + $this->renew_subscription($subscription); |
|
616 | 616 | |
617 | 617 | return false; |
618 | 618 | |
@@ -623,28 +623,28 @@ discard block |
||
623 | 623 | * |
624 | 624 | * @param WPInv_Subscription $subscription |
625 | 625 | */ |
626 | - public function renew_subscription( $subscription ) { |
|
626 | + public function renew_subscription($subscription) { |
|
627 | 627 | |
628 | 628 | // Generate the renewal invoice. |
629 | 629 | $new_invoice = $subscription->create_payment(); |
630 | 630 | $old_invoice = $subscription->get_parent_payment(); |
631 | 631 | |
632 | - if ( empty( $new_invoice ) ) { |
|
633 | - $old_invoice->add_note( __( 'Error generating a renewal invoice.', 'invoicing' ), false, false, false ); |
|
632 | + if (empty($new_invoice)) { |
|
633 | + $old_invoice->add_note(__('Error generating a renewal invoice.', 'invoicing'), false, false, false); |
|
634 | 634 | $subscription->failing(); |
635 | 635 | return; |
636 | 636 | } |
637 | 637 | |
638 | 638 | // Charge the payment method. |
639 | - $payment_profile_id = get_post_meta( $old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true ); |
|
640 | - $customer_profile = get_user_meta( $old_invoice->get_user_id(), $this->get_customer_profile_meta_name( $old_invoice ), true ); |
|
641 | - $result = $this->charge_customer_payment_profile( $customer_profile, $payment_profile_id, $new_invoice ); |
|
639 | + $payment_profile_id = get_post_meta($old_invoice->get_id(), 'getpaid_authorizenet_profile_id', true); |
|
640 | + $customer_profile = get_user_meta($old_invoice->get_user_id(), $this->get_customer_profile_meta_name($old_invoice), true); |
|
641 | + $result = $this->charge_customer_payment_profile($customer_profile, $payment_profile_id, $new_invoice); |
|
642 | 642 | |
643 | 643 | // Do we have an error? |
644 | - if ( is_wp_error( $result ) ) { |
|
644 | + if (is_wp_error($result)) { |
|
645 | 645 | |
646 | 646 | $old_invoice->add_note( |
647 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), $result->get_error_message() ), |
|
647 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), $result->get_error_message()), |
|
648 | 648 | true, |
649 | 649 | false, |
650 | 650 | true |
@@ -655,12 +655,12 @@ discard block |
||
655 | 655 | } |
656 | 656 | |
657 | 657 | // Process the response. |
658 | - $this->process_charge_response( $result, $new_invoice ); |
|
658 | + $this->process_charge_response($result, $new_invoice); |
|
659 | 659 | |
660 | - if ( wpinv_get_errors() ) { |
|
660 | + if (wpinv_get_errors()) { |
|
661 | 661 | |
662 | 662 | $old_invoice->add_note( |
663 | - sprintf( __( 'Error renewing subscription : ( %s ).', 'invoicing' ), getpaid_get_errors_html() ), |
|
663 | + sprintf(__('Error renewing subscription : ( %s ).', 'invoicing'), getpaid_get_errors_html()), |
|
664 | 664 | true, |
665 | 665 | false, |
666 | 666 | true |
@@ -670,18 +670,18 @@ discard block |
||
670 | 670 | |
671 | 671 | } |
672 | 672 | |
673 | - $subscription->add_payment( array(), $new_invoice ); |
|
673 | + $subscription->add_payment(array(), $new_invoice); |
|
674 | 674 | $subscription->renew(); |
675 | 675 | } |
676 | 676 | |
677 | 677 | /** |
678 | 678 | * Displays a notice on the checkout page if sandbox is enabled. |
679 | 679 | */ |
680 | - public function sandbox_notice( $description, $gateway ) { |
|
680 | + public function sandbox_notice($description, $gateway) { |
|
681 | 681 | |
682 | - if ( $this->id == $gateway && wpinv_is_test_mode( $this->id ) ) { |
|
682 | + if ($this->id == $gateway && wpinv_is_test_mode($this->id)) { |
|
683 | 683 | $description .= '<br> <br>' . sprintf( |
684 | - __( 'SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing' ), |
|
684 | + __('SANDBOX ENABLED. You can use sandbox testing details only. See the %sAuthorize.NET Sandbox Testing Guide%s for more details.', 'invoicing'), |
|
685 | 685 | '<a href="https://developer.authorize.net/hello_world/testing_guide.html">', |
686 | 686 | '</a>' |
687 | 687 | ); |
@@ -695,42 +695,42 @@ discard block |
||
695 | 695 | * |
696 | 696 | * @param array $admin_settings |
697 | 697 | */ |
698 | - public function admin_settings( $admin_settings ) { |
|
698 | + public function admin_settings($admin_settings) { |
|
699 | 699 | |
700 | 700 | $currencies = sprintf( |
701 | - __( 'Supported Currencies: %s', 'invoicing' ), |
|
702 | - implode( ', ', $this->currencies ) |
|
701 | + __('Supported Currencies: %s', 'invoicing'), |
|
702 | + implode(', ', $this->currencies) |
|
703 | 703 | ); |
704 | 704 | |
705 | 705 | $admin_settings['authorizenet_active']['desc'] .= " ($currencies)"; |
706 | - $admin_settings['authorizenet_desc']['std'] = __( 'Pay securely using your credit or debit card.', 'invoicing' ); |
|
706 | + $admin_settings['authorizenet_desc']['std'] = __('Pay securely using your credit or debit card.', 'invoicing'); |
|
707 | 707 | |
708 | 708 | $admin_settings['authorizenet_login_id'] = array( |
709 | 709 | 'type' => 'text', |
710 | 710 | 'id' => 'authorizenet_login_id', |
711 | - 'name' => __( 'API Login ID', 'invoicing' ), |
|
712 | - 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __( 'How do I obtain my API Login ID and Transaction Key?', 'invoicing' ) . '</em></a>', |
|
711 | + 'name' => __('API Login ID', 'invoicing'), |
|
712 | + 'desc' => '<a href="https://support.authorize.net/s/article/How-do-I-obtain-my-API-Login-ID-and-Transaction-Key"><em>' . __('How do I obtain my API Login ID and Transaction Key?', 'invoicing') . '</em></a>', |
|
713 | 713 | ); |
714 | 714 | |
715 | 715 | $admin_settings['authorizenet_transaction_key'] = array( |
716 | 716 | 'type' => 'text', |
717 | 717 | 'id' => 'authorizenet_transaction_key', |
718 | - 'name' => __( 'Transaction Key', 'invoicing' ), |
|
718 | + 'name' => __('Transaction Key', 'invoicing'), |
|
719 | 719 | ); |
720 | 720 | |
721 | 721 | $admin_settings['authorizenet_signature_key'] = array( |
722 | 722 | 'type' => 'text', |
723 | 723 | 'id' => 'authorizenet_signature_key', |
724 | - 'name' => __( 'Signature Key', 'invoicing' ), |
|
725 | - 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
724 | + 'name' => __('Signature Key', 'invoicing'), |
|
725 | + 'desc' => '<a href="https://support.authorize.net/s/article/What-is-a-Signature-Key"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
726 | 726 | ); |
727 | 727 | |
728 | 728 | $admin_settings['authorizenet_ipn_url'] = array( |
729 | 729 | 'type' => 'ipn_url', |
730 | 730 | 'id' => 'authorizenet_ipn_url', |
731 | - 'name' => __( 'Webhook URL', 'invoicing' ), |
|
731 | + 'name' => __('Webhook URL', 'invoicing'), |
|
732 | 732 | 'std' => $this->notify_url, |
733 | - 'desc' => __( 'Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing' ) . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __( 'Learn more.', 'invoicing' ) . '</em></a>', |
|
733 | + 'desc' => __('Create a new webhook using this URL as the endpoint URL and set it to receive all payment events.', 'invoicing') . ' <a href="https://support.authorize.net/s/article/How-do-I-add-edit-Webhook-notification-end-points"><em>' . __('Learn more.', 'invoicing') . '</em></a>', |
|
734 | 734 | 'custom' => 'authorizenet', |
735 | 735 | 'readonly' => true, |
736 | 736 | ); |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined( 'ABSPATH' ) ) { |
3 | - exit; |
|
3 | + exit; |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | /** |
@@ -10,60 +10,60 @@ discard block |
||
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,232 +81,232 @@ discard block |
||
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 float |
|
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 float |
|
139 | - */ |
|
140 | - public function get_recurring_sub_total( $context = 'view' ) { |
|
141 | - |
|
142 | - if ( $this->is_recurring() ) { |
|
143 | - return $this->get_quantity( $context ) * $this->get_price( $context ); |
|
144 | - } |
|
145 | - |
|
146 | - return 0; |
|
147 | - } |
|
148 | - |
|
149 | - /** |
|
150 | - * @deprecated |
|
151 | - */ |
|
152 | - public function get_qantity( $context = 'view' ) { |
|
153 | - return $this->get_quantity( $context ); |
|
154 | - } |
|
155 | - |
|
156 | - /** |
|
157 | - * Get the item quantity. |
|
158 | - * |
|
159 | - * @since 1.0.19 |
|
160 | - * @param string $context View or edit context. |
|
161 | - * @return int |
|
162 | - */ |
|
163 | - public function get_quantity( $context = 'view' ) { |
|
164 | - $quantity = (int) $this->quantity; |
|
165 | - |
|
166 | - if ( empty( $quantity ) || 1 > $quantity ) { |
|
167 | - $quantity = 1; |
|
168 | - } |
|
169 | - |
|
170 | - if ( 'view' == $context ) { |
|
171 | - return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this ); |
|
172 | - } |
|
173 | - |
|
174 | - return $quantity; |
|
175 | - |
|
176 | - } |
|
177 | - |
|
178 | - /** |
|
179 | - * Get the item meta data. |
|
180 | - * |
|
181 | - * @since 1.0.19 |
|
182 | - * @param string $context View or edit context. |
|
183 | - * @return meta |
|
184 | - */ |
|
185 | - public function get_item_meta( $context = 'view' ) { |
|
186 | - $meta = $this->meta; |
|
187 | - |
|
188 | - if ( 'view' == $context ) { |
|
189 | - return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this ); |
|
190 | - } |
|
191 | - |
|
192 | - return $meta; |
|
193 | - |
|
194 | - } |
|
195 | - |
|
196 | - /** |
|
197 | - * Returns whether or not customers can update the item quantity. |
|
198 | - * |
|
199 | - * @since 1.0.19 |
|
200 | - * @param string $context View or edit context. |
|
201 | - * @return bool |
|
202 | - */ |
|
203 | - public function get_allow_quantities( $context = 'view' ) { |
|
204 | - $allow_quantities = (bool) $this->allow_quantities; |
|
205 | - |
|
206 | - if ( 'view' == $context ) { |
|
207 | - return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
208 | - } |
|
209 | - |
|
210 | - return $allow_quantities; |
|
211 | - |
|
212 | - } |
|
213 | - |
|
214 | - /** |
|
215 | - * Returns whether or not the item is required. |
|
216 | - * |
|
217 | - * @since 1.0.19 |
|
218 | - * @param string $context View or edit context. |
|
219 | - * @return bool |
|
220 | - */ |
|
221 | - public function get_is_required( $context = 'view' ) { |
|
222 | - $is_required = (bool) $this->is_required; |
|
223 | - |
|
224 | - if ( 'view' == $context ) { |
|
225 | - return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
226 | - } |
|
227 | - |
|
228 | - return $is_required; |
|
229 | - |
|
230 | - } |
|
231 | - |
|
232 | - /** |
|
233 | - * Prepares form data for use. |
|
234 | - * |
|
235 | - * @since 1.0.19 |
|
236 | - * @return array |
|
237 | - */ |
|
238 | - public function prepare_data_for_use( $required = null ) { |
|
239 | - |
|
240 | - $required = is_null( $required ) ? $this->is_required() : $required; |
|
241 | - return array( |
|
242 | - 'title' => strip_tags( $this->get_name() ), |
|
243 | - 'id' => $this->get_id(), |
|
244 | - 'price' => $this->get_price(), |
|
245 | - 'recurring' => $this->is_recurring(), |
|
246 | - 'description' => $this->get_description(), |
|
247 | - 'allow_quantities' => $this->allows_quantities(), |
|
248 | - 'required' => $required, |
|
249 | - ); |
|
250 | - |
|
251 | - } |
|
252 | - |
|
253 | - /** |
|
254 | - * Prepares form data for ajax use. |
|
255 | - * |
|
256 | - * @since 1.0.19 |
|
257 | - * @return array |
|
258 | - */ |
|
259 | - public function prepare_data_for_invoice_edit_ajax( $currency = '' ) { |
|
260 | - |
|
261 | - $description = getpaid_item_recurring_price_help_text( $this, $currency ); |
|
262 | - |
|
263 | - if ( $description ) { |
|
264 | - $description = "<div class='getpaid-subscription-help-text'>$description</div>"; |
|
265 | - } |
|
266 | - |
|
267 | - return array( |
|
268 | - 'id' => $this->get_id(), |
|
269 | - 'texts' => array( |
|
270 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
271 | - 'item-description' => wp_kses_post( $this->get_description() ) . $description, |
|
272 | - 'item-quantity' => absint( $this->get_quantity() ), |
|
273 | - 'item-price' => wpinv_price( wpinv_format_amount ( $this->get_price() ), $currency ), |
|
274 | - 'item-total' => wpinv_price( wpinv_format_amount( $this->get_sub_total() ), $currency ), |
|
275 | - ), |
|
276 | - 'inputs' => array( |
|
277 | - 'item-id' => $this->get_id(), |
|
278 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
279 | - 'item-description' => wp_kses_post( $this->get_description() ), |
|
280 | - 'item-quantity' => absint( $this->get_quantity() ), |
|
281 | - 'item-price' => $this->get_price(), |
|
282 | - ) |
|
283 | - ); |
|
284 | - |
|
285 | - } |
|
286 | - |
|
287 | - /** |
|
288 | - * Prepares form data for saving (cart_details). |
|
289 | - * |
|
290 | - * @since 1.0.19 |
|
291 | - * @return array |
|
292 | - */ |
|
293 | - public function prepare_data_for_saving() { |
|
294 | - |
|
295 | - return array( |
|
296 | - 'post_id' => $this->invoice_id, |
|
297 | - 'item_id' => $this->get_id(), |
|
298 | - 'item_name' => sanitize_text_field( $this->get_raw_name() ), |
|
299 | - 'item_description' => $this->get_description(), |
|
300 | - 'tax' => $this->item_tax, |
|
301 | - 'item_price' => $this->get_price(), |
|
302 | - 'quantity' => (int) $this->get_quantity(), |
|
303 | - 'discount' => $this->item_discount, |
|
304 | - 'subtotal' => $this->get_sub_total(), |
|
305 | - 'price' => $this->get_sub_total() + $this->item_tax + $this->item_discount, |
|
306 | - 'meta' => $this->get_item_meta(), |
|
307 | - ); |
|
308 | - |
|
309 | - } |
|
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 float |
|
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 float |
|
139 | + */ |
|
140 | + public function get_recurring_sub_total( $context = 'view' ) { |
|
141 | + |
|
142 | + if ( $this->is_recurring() ) { |
|
143 | + return $this->get_quantity( $context ) * $this->get_price( $context ); |
|
144 | + } |
|
145 | + |
|
146 | + return 0; |
|
147 | + } |
|
148 | + |
|
149 | + /** |
|
150 | + * @deprecated |
|
151 | + */ |
|
152 | + public function get_qantity( $context = 'view' ) { |
|
153 | + return $this->get_quantity( $context ); |
|
154 | + } |
|
155 | + |
|
156 | + /** |
|
157 | + * Get the item quantity. |
|
158 | + * |
|
159 | + * @since 1.0.19 |
|
160 | + * @param string $context View or edit context. |
|
161 | + * @return int |
|
162 | + */ |
|
163 | + public function get_quantity( $context = 'view' ) { |
|
164 | + $quantity = (int) $this->quantity; |
|
165 | + |
|
166 | + if ( empty( $quantity ) || 1 > $quantity ) { |
|
167 | + $quantity = 1; |
|
168 | + } |
|
169 | + |
|
170 | + if ( 'view' == $context ) { |
|
171 | + return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this ); |
|
172 | + } |
|
173 | + |
|
174 | + return $quantity; |
|
175 | + |
|
176 | + } |
|
177 | + |
|
178 | + /** |
|
179 | + * Get the item meta data. |
|
180 | + * |
|
181 | + * @since 1.0.19 |
|
182 | + * @param string $context View or edit context. |
|
183 | + * @return meta |
|
184 | + */ |
|
185 | + public function get_item_meta( $context = 'view' ) { |
|
186 | + $meta = $this->meta; |
|
187 | + |
|
188 | + if ( 'view' == $context ) { |
|
189 | + return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this ); |
|
190 | + } |
|
191 | + |
|
192 | + return $meta; |
|
193 | + |
|
194 | + } |
|
195 | + |
|
196 | + /** |
|
197 | + * Returns whether or not customers can update the item quantity. |
|
198 | + * |
|
199 | + * @since 1.0.19 |
|
200 | + * @param string $context View or edit context. |
|
201 | + * @return bool |
|
202 | + */ |
|
203 | + public function get_allow_quantities( $context = 'view' ) { |
|
204 | + $allow_quantities = (bool) $this->allow_quantities; |
|
205 | + |
|
206 | + if ( 'view' == $context ) { |
|
207 | + return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
208 | + } |
|
209 | + |
|
210 | + return $allow_quantities; |
|
211 | + |
|
212 | + } |
|
213 | + |
|
214 | + /** |
|
215 | + * Returns whether or not the item is required. |
|
216 | + * |
|
217 | + * @since 1.0.19 |
|
218 | + * @param string $context View or edit context. |
|
219 | + * @return bool |
|
220 | + */ |
|
221 | + public function get_is_required( $context = 'view' ) { |
|
222 | + $is_required = (bool) $this->is_required; |
|
223 | + |
|
224 | + if ( 'view' == $context ) { |
|
225 | + return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
226 | + } |
|
227 | + |
|
228 | + return $is_required; |
|
229 | + |
|
230 | + } |
|
231 | + |
|
232 | + /** |
|
233 | + * Prepares form data for use. |
|
234 | + * |
|
235 | + * @since 1.0.19 |
|
236 | + * @return array |
|
237 | + */ |
|
238 | + public function prepare_data_for_use( $required = null ) { |
|
239 | + |
|
240 | + $required = is_null( $required ) ? $this->is_required() : $required; |
|
241 | + return array( |
|
242 | + 'title' => strip_tags( $this->get_name() ), |
|
243 | + 'id' => $this->get_id(), |
|
244 | + 'price' => $this->get_price(), |
|
245 | + 'recurring' => $this->is_recurring(), |
|
246 | + 'description' => $this->get_description(), |
|
247 | + 'allow_quantities' => $this->allows_quantities(), |
|
248 | + 'required' => $required, |
|
249 | + ); |
|
250 | + |
|
251 | + } |
|
252 | + |
|
253 | + /** |
|
254 | + * Prepares form data for ajax use. |
|
255 | + * |
|
256 | + * @since 1.0.19 |
|
257 | + * @return array |
|
258 | + */ |
|
259 | + public function prepare_data_for_invoice_edit_ajax( $currency = '' ) { |
|
260 | + |
|
261 | + $description = getpaid_item_recurring_price_help_text( $this, $currency ); |
|
262 | + |
|
263 | + if ( $description ) { |
|
264 | + $description = "<div class='getpaid-subscription-help-text'>$description</div>"; |
|
265 | + } |
|
266 | + |
|
267 | + return array( |
|
268 | + 'id' => $this->get_id(), |
|
269 | + 'texts' => array( |
|
270 | + 'item-name' => sanitize_text_field( $this->get_name() ), |
|
271 | + 'item-description' => wp_kses_post( $this->get_description() ) . $description, |
|
272 | + 'item-quantity' => absint( $this->get_quantity() ), |
|
273 | + 'item-price' => wpinv_price( wpinv_format_amount ( $this->get_price() ), $currency ), |
|
274 | + 'item-total' => wpinv_price( wpinv_format_amount( $this->get_sub_total() ), $currency ), |
|
275 | + ), |
|
276 | + 'inputs' => array( |
|
277 | + 'item-id' => $this->get_id(), |
|
278 | + 'item-name' => sanitize_text_field( $this->get_name() ), |
|
279 | + 'item-description' => wp_kses_post( $this->get_description() ), |
|
280 | + 'item-quantity' => absint( $this->get_quantity() ), |
|
281 | + 'item-price' => $this->get_price(), |
|
282 | + ) |
|
283 | + ); |
|
284 | + |
|
285 | + } |
|
286 | + |
|
287 | + /** |
|
288 | + * Prepares form data for saving (cart_details). |
|
289 | + * |
|
290 | + * @since 1.0.19 |
|
291 | + * @return array |
|
292 | + */ |
|
293 | + public function prepare_data_for_saving() { |
|
294 | + |
|
295 | + return array( |
|
296 | + 'post_id' => $this->invoice_id, |
|
297 | + 'item_id' => $this->get_id(), |
|
298 | + 'item_name' => sanitize_text_field( $this->get_raw_name() ), |
|
299 | + 'item_description' => $this->get_description(), |
|
300 | + 'tax' => $this->item_tax, |
|
301 | + 'item_price' => $this->get_price(), |
|
302 | + 'quantity' => (int) $this->get_quantity(), |
|
303 | + 'discount' => $this->item_discount, |
|
304 | + 'subtotal' => $this->get_sub_total(), |
|
305 | + 'price' => $this->get_sub_total() + $this->item_tax + $this->item_discount, |
|
306 | + 'meta' => $this->get_item_meta(), |
|
307 | + ); |
|
308 | + |
|
309 | + } |
|
310 | 310 | |
311 | 311 | /* |
312 | 312 | |-------------------------------------------------------------------------- |
@@ -318,70 +318,70 @@ discard block |
||
318 | 318 | | object. |
319 | 319 | */ |
320 | 320 | |
321 | - /** |
|
322 | - * Set the item qantity. |
|
323 | - * |
|
324 | - * @since 1.0.19 |
|
325 | - * @param int $quantity The item quantity. |
|
326 | - */ |
|
327 | - public function set_quantity( $quantity ) { |
|
328 | - |
|
329 | - if ( empty( $quantity ) || ! is_numeric( $quantity ) ) { |
|
330 | - $quantity = 1; |
|
331 | - } |
|
332 | - |
|
333 | - $this->quantity = (int) $quantity; |
|
334 | - |
|
335 | - } |
|
336 | - |
|
337 | - /** |
|
338 | - * Set the item meta data. |
|
339 | - * |
|
340 | - * @since 1.0.19 |
|
341 | - * @param array $meta The item meta data. |
|
342 | - */ |
|
343 | - public function set_item_meta( $meta ) { |
|
344 | - $this->meta = maybe_unserialize( $meta ); |
|
345 | - } |
|
346 | - |
|
347 | - /** |
|
348 | - * Set whether or not the quantities are allowed. |
|
349 | - * |
|
350 | - * @since 1.0.19 |
|
351 | - * @param bool $allow_quantities |
|
352 | - */ |
|
353 | - public function set_allow_quantities( $allow_quantities ) { |
|
354 | - $this->allow_quantities = (bool) $allow_quantities; |
|
355 | - } |
|
356 | - |
|
357 | - /** |
|
358 | - * Set whether or not the item is required. |
|
359 | - * |
|
360 | - * @since 1.0.19 |
|
361 | - * @param bool $is_required |
|
362 | - */ |
|
363 | - public function set_is_required( $is_required ) { |
|
364 | - $this->is_required = (bool) $is_required; |
|
365 | - } |
|
366 | - |
|
367 | - /** |
|
368 | - * Sets the custom item description. |
|
369 | - * |
|
370 | - * @since 1.0.19 |
|
371 | - * @param string $description |
|
372 | - */ |
|
373 | - public function set_custom_description( $description ) { |
|
374 | - $this->custom_description = $description; |
|
375 | - } |
|
321 | + /** |
|
322 | + * Set the item qantity. |
|
323 | + * |
|
324 | + * @since 1.0.19 |
|
325 | + * @param int $quantity The item quantity. |
|
326 | + */ |
|
327 | + public function set_quantity( $quantity ) { |
|
328 | + |
|
329 | + if ( empty( $quantity ) || ! is_numeric( $quantity ) ) { |
|
330 | + $quantity = 1; |
|
331 | + } |
|
332 | + |
|
333 | + $this->quantity = (int) $quantity; |
|
334 | + |
|
335 | + } |
|
336 | + |
|
337 | + /** |
|
338 | + * Set the item meta data. |
|
339 | + * |
|
340 | + * @since 1.0.19 |
|
341 | + * @param array $meta The item meta data. |
|
342 | + */ |
|
343 | + public function set_item_meta( $meta ) { |
|
344 | + $this->meta = maybe_unserialize( $meta ); |
|
345 | + } |
|
346 | + |
|
347 | + /** |
|
348 | + * Set whether or not the quantities are allowed. |
|
349 | + * |
|
350 | + * @since 1.0.19 |
|
351 | + * @param bool $allow_quantities |
|
352 | + */ |
|
353 | + public function set_allow_quantities( $allow_quantities ) { |
|
354 | + $this->allow_quantities = (bool) $allow_quantities; |
|
355 | + } |
|
356 | + |
|
357 | + /** |
|
358 | + * Set whether or not the item is required. |
|
359 | + * |
|
360 | + * @since 1.0.19 |
|
361 | + * @param bool $is_required |
|
362 | + */ |
|
363 | + public function set_is_required( $is_required ) { |
|
364 | + $this->is_required = (bool) $is_required; |
|
365 | + } |
|
366 | + |
|
367 | + /** |
|
368 | + * Sets the custom item description. |
|
369 | + * |
|
370 | + * @since 1.0.19 |
|
371 | + * @param string $description |
|
372 | + */ |
|
373 | + public function set_custom_description( $description ) { |
|
374 | + $this->custom_description = $description; |
|
375 | + } |
|
376 | 376 | |
377 | 377 | /** |
378 | 378 | * We do not want to save items to the database. |
379 | 379 | * |
380 | - * @return int item id |
|
380 | + * @return int item id |
|
381 | 381 | */ |
382 | 382 | public function save( $data = array() ) { |
383 | 383 | return $this->get_id(); |
384 | - } |
|
384 | + } |
|
385 | 385 | |
386 | 386 | /* |
387 | 387 | |-------------------------------------------------------------------------- |
@@ -393,23 +393,23 @@ discard block |
||
393 | 393 | */ |
394 | 394 | |
395 | 395 | /** |
396 | - * Checks whether the item has enabled dynamic pricing. |
|
397 | - * |
|
398 | - * @since 1.0.19 |
|
399 | - * @return bool |
|
400 | - */ |
|
401 | - public function is_required() { |
|
396 | + * Checks whether the item has enabled dynamic pricing. |
|
397 | + * |
|
398 | + * @since 1.0.19 |
|
399 | + * @return bool |
|
400 | + */ |
|
401 | + public function is_required() { |
|
402 | 402 | return (bool) $this->get_is_required(); |
403 | - } |
|
404 | - |
|
405 | - /** |
|
406 | - * Checks whether users can edit the quantities. |
|
407 | - * |
|
408 | - * @since 1.0.19 |
|
409 | - * @return bool |
|
410 | - */ |
|
411 | - public function allows_quantities() { |
|
403 | + } |
|
404 | + |
|
405 | + /** |
|
406 | + * Checks whether users can edit the quantities. |
|
407 | + * |
|
408 | + * @since 1.0.19 |
|
409 | + * @return bool |
|
410 | + */ |
|
411 | + public function allows_quantities() { |
|
412 | 412 | return (bool) $this->get_allow_quantities(); |
413 | - } |
|
413 | + } |
|
414 | 414 | |
415 | 415 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | * @param string $context View or edit context. |
88 | 88 | * @return string |
89 | 89 | */ |
90 | - public function get_name( $context = 'view' ) { |
|
91 | - $name = parent::get_name( $context ); |
|
92 | - return $name . wpinv_get_item_suffix( $this ); |
|
90 | + public function get_name($context = 'view') { |
|
91 | + $name = parent::get_name($context); |
|
92 | + return $name . wpinv_get_item_suffix($this); |
|
93 | 93 | } |
94 | 94 | |
95 | 95 | /** |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | * @param string $context View or edit context. |
100 | 100 | * @return string |
101 | 101 | */ |
102 | - public function get_raw_name( $context = 'view' ) { |
|
103 | - return parent::get_name( $context ); |
|
102 | + public function get_raw_name($context = 'view') { |
|
103 | + return parent::get_name($context); |
|
104 | 104 | } |
105 | 105 | |
106 | 106 | /** |
@@ -110,13 +110,13 @@ discard block |
||
110 | 110 | * @param string $context View or edit context. |
111 | 111 | * @return string |
112 | 112 | */ |
113 | - public function get_description( $context = 'view' ) { |
|
113 | + public function get_description($context = 'view') { |
|
114 | 114 | |
115 | - if ( isset( $this->custom_description ) ) { |
|
115 | + if (isset($this->custom_description)) { |
|
116 | 116 | return $this->custom_description; |
117 | 117 | } |
118 | 118 | |
119 | - return parent::get_description( $context ); |
|
119 | + return parent::get_description($context); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | /** |
@@ -126,8 +126,8 @@ discard block |
||
126 | 126 | * @param string $context View or edit context. |
127 | 127 | * @return float |
128 | 128 | */ |
129 | - public function get_sub_total( $context = 'view' ) { |
|
130 | - return $this->get_quantity( $context ) * $this->get_initial_price( $context ); |
|
129 | + public function get_sub_total($context = 'view') { |
|
130 | + return $this->get_quantity($context) * $this->get_initial_price($context); |
|
131 | 131 | } |
132 | 132 | |
133 | 133 | /** |
@@ -137,10 +137,10 @@ discard block |
||
137 | 137 | * @param string $context View or edit context. |
138 | 138 | * @return float |
139 | 139 | */ |
140 | - public function get_recurring_sub_total( $context = 'view' ) { |
|
140 | + public function get_recurring_sub_total($context = 'view') { |
|
141 | 141 | |
142 | - if ( $this->is_recurring() ) { |
|
143 | - return $this->get_quantity( $context ) * $this->get_price( $context ); |
|
142 | + if ($this->is_recurring()) { |
|
143 | + return $this->get_quantity($context) * $this->get_price($context); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | return 0; |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | /** |
150 | 150 | * @deprecated |
151 | 151 | */ |
152 | - public function get_qantity( $context = 'view' ) { |
|
153 | - return $this->get_quantity( $context ); |
|
152 | + public function get_qantity($context = 'view') { |
|
153 | + return $this->get_quantity($context); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | /** |
@@ -160,15 +160,15 @@ discard block |
||
160 | 160 | * @param string $context View or edit context. |
161 | 161 | * @return int |
162 | 162 | */ |
163 | - public function get_quantity( $context = 'view' ) { |
|
163 | + public function get_quantity($context = 'view') { |
|
164 | 164 | $quantity = (int) $this->quantity; |
165 | 165 | |
166 | - if ( empty( $quantity ) || 1 > $quantity ) { |
|
166 | + if (empty($quantity) || 1 > $quantity) { |
|
167 | 167 | $quantity = 1; |
168 | 168 | } |
169 | 169 | |
170 | - if ( 'view' == $context ) { |
|
171 | - return apply_filters( 'getpaid_payment_form_item_quantity', $quantity, $this ); |
|
170 | + if ('view' == $context) { |
|
171 | + return apply_filters('getpaid_payment_form_item_quantity', $quantity, $this); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | return $quantity; |
@@ -182,11 +182,11 @@ discard block |
||
182 | 182 | * @param string $context View or edit context. |
183 | 183 | * @return meta |
184 | 184 | */ |
185 | - public function get_item_meta( $context = 'view' ) { |
|
185 | + public function get_item_meta($context = 'view') { |
|
186 | 186 | $meta = $this->meta; |
187 | 187 | |
188 | - if ( 'view' == $context ) { |
|
189 | - return apply_filters( 'getpaid_payment_form_item_meta', $meta, $this ); |
|
188 | + if ('view' == $context) { |
|
189 | + return apply_filters('getpaid_payment_form_item_meta', $meta, $this); |
|
190 | 190 | } |
191 | 191 | |
192 | 192 | return $meta; |
@@ -200,11 +200,11 @@ discard block |
||
200 | 200 | * @param string $context View or edit context. |
201 | 201 | * @return bool |
202 | 202 | */ |
203 | - public function get_allow_quantities( $context = 'view' ) { |
|
203 | + public function get_allow_quantities($context = 'view') { |
|
204 | 204 | $allow_quantities = (bool) $this->allow_quantities; |
205 | 205 | |
206 | - if ( 'view' == $context ) { |
|
207 | - return apply_filters( 'getpaid_payment_form_item_allow_quantities', $allow_quantities, $this ); |
|
206 | + if ('view' == $context) { |
|
207 | + return apply_filters('getpaid_payment_form_item_allow_quantities', $allow_quantities, $this); |
|
208 | 208 | } |
209 | 209 | |
210 | 210 | return $allow_quantities; |
@@ -218,11 +218,11 @@ discard block |
||
218 | 218 | * @param string $context View or edit context. |
219 | 219 | * @return bool |
220 | 220 | */ |
221 | - public function get_is_required( $context = 'view' ) { |
|
221 | + public function get_is_required($context = 'view') { |
|
222 | 222 | $is_required = (bool) $this->is_required; |
223 | 223 | |
224 | - if ( 'view' == $context ) { |
|
225 | - return apply_filters( 'getpaid_payment_form_item_is_required', $is_required, $this ); |
|
224 | + if ('view' == $context) { |
|
225 | + return apply_filters('getpaid_payment_form_item_is_required', $is_required, $this); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | return $is_required; |
@@ -235,11 +235,11 @@ discard block |
||
235 | 235 | * @since 1.0.19 |
236 | 236 | * @return array |
237 | 237 | */ |
238 | - public function prepare_data_for_use( $required = null ) { |
|
238 | + public function prepare_data_for_use($required = null) { |
|
239 | 239 | |
240 | - $required = is_null( $required ) ? $this->is_required() : $required; |
|
240 | + $required = is_null($required) ? $this->is_required() : $required; |
|
241 | 241 | return array( |
242 | - 'title' => strip_tags( $this->get_name() ), |
|
242 | + 'title' => strip_tags($this->get_name()), |
|
243 | 243 | 'id' => $this->get_id(), |
244 | 244 | 'price' => $this->get_price(), |
245 | 245 | 'recurring' => $this->is_recurring(), |
@@ -256,28 +256,28 @@ discard block |
||
256 | 256 | * @since 1.0.19 |
257 | 257 | * @return array |
258 | 258 | */ |
259 | - public function prepare_data_for_invoice_edit_ajax( $currency = '' ) { |
|
259 | + public function prepare_data_for_invoice_edit_ajax($currency = '') { |
|
260 | 260 | |
261 | - $description = getpaid_item_recurring_price_help_text( $this, $currency ); |
|
261 | + $description = getpaid_item_recurring_price_help_text($this, $currency); |
|
262 | 262 | |
263 | - if ( $description ) { |
|
263 | + if ($description) { |
|
264 | 264 | $description = "<div class='getpaid-subscription-help-text'>$description</div>"; |
265 | 265 | } |
266 | 266 | |
267 | 267 | return array( |
268 | 268 | 'id' => $this->get_id(), |
269 | 269 | 'texts' => array( |
270 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
271 | - 'item-description' => wp_kses_post( $this->get_description() ) . $description, |
|
272 | - 'item-quantity' => absint( $this->get_quantity() ), |
|
273 | - 'item-price' => wpinv_price( wpinv_format_amount ( $this->get_price() ), $currency ), |
|
274 | - 'item-total' => wpinv_price( wpinv_format_amount( $this->get_sub_total() ), $currency ), |
|
270 | + 'item-name' => sanitize_text_field($this->get_name()), |
|
271 | + 'item-description' => wp_kses_post($this->get_description()) . $description, |
|
272 | + 'item-quantity' => absint($this->get_quantity()), |
|
273 | + 'item-price' => wpinv_price(wpinv_format_amount($this->get_price()), $currency), |
|
274 | + 'item-total' => wpinv_price(wpinv_format_amount($this->get_sub_total()), $currency), |
|
275 | 275 | ), |
276 | 276 | 'inputs' => array( |
277 | 277 | 'item-id' => $this->get_id(), |
278 | - 'item-name' => sanitize_text_field( $this->get_name() ), |
|
279 | - 'item-description' => wp_kses_post( $this->get_description() ), |
|
280 | - 'item-quantity' => absint( $this->get_quantity() ), |
|
278 | + 'item-name' => sanitize_text_field($this->get_name()), |
|
279 | + 'item-description' => wp_kses_post($this->get_description()), |
|
280 | + 'item-quantity' => absint($this->get_quantity()), |
|
281 | 281 | 'item-price' => $this->get_price(), |
282 | 282 | ) |
283 | 283 | ); |
@@ -295,7 +295,7 @@ discard block |
||
295 | 295 | return array( |
296 | 296 | 'post_id' => $this->invoice_id, |
297 | 297 | 'item_id' => $this->get_id(), |
298 | - 'item_name' => sanitize_text_field( $this->get_raw_name() ), |
|
298 | + 'item_name' => sanitize_text_field($this->get_raw_name()), |
|
299 | 299 | 'item_description' => $this->get_description(), |
300 | 300 | 'tax' => $this->item_tax, |
301 | 301 | 'item_price' => $this->get_price(), |
@@ -324,9 +324,9 @@ discard block |
||
324 | 324 | * @since 1.0.19 |
325 | 325 | * @param int $quantity The item quantity. |
326 | 326 | */ |
327 | - public function set_quantity( $quantity ) { |
|
327 | + public function set_quantity($quantity) { |
|
328 | 328 | |
329 | - if ( empty( $quantity ) || ! is_numeric( $quantity ) ) { |
|
329 | + if (empty($quantity) || !is_numeric($quantity)) { |
|
330 | 330 | $quantity = 1; |
331 | 331 | } |
332 | 332 | |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | * @since 1.0.19 |
341 | 341 | * @param array $meta The item meta data. |
342 | 342 | */ |
343 | - public function set_item_meta( $meta ) { |
|
344 | - $this->meta = maybe_unserialize( $meta ); |
|
343 | + public function set_item_meta($meta) { |
|
344 | + $this->meta = maybe_unserialize($meta); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * @since 1.0.19 |
351 | 351 | * @param bool $allow_quantities |
352 | 352 | */ |
353 | - public function set_allow_quantities( $allow_quantities ) { |
|
353 | + public function set_allow_quantities($allow_quantities) { |
|
354 | 354 | $this->allow_quantities = (bool) $allow_quantities; |
355 | 355 | } |
356 | 356 | |
@@ -360,7 +360,7 @@ discard block |
||
360 | 360 | * @since 1.0.19 |
361 | 361 | * @param bool $is_required |
362 | 362 | */ |
363 | - public function set_is_required( $is_required ) { |
|
363 | + public function set_is_required($is_required) { |
|
364 | 364 | $this->is_required = (bool) $is_required; |
365 | 365 | } |
366 | 366 | |
@@ -370,7 +370,7 @@ discard block |
||
370 | 370 | * @since 1.0.19 |
371 | 371 | * @param string $description |
372 | 372 | */ |
373 | - public function set_custom_description( $description ) { |
|
373 | + public function set_custom_description($description) { |
|
374 | 374 | $this->custom_description = $description; |
375 | 375 | } |
376 | 376 | |
@@ -379,7 +379,7 @@ discard block |
||
379 | 379 | * |
380 | 380 | * @return int item id |
381 | 381 | */ |
382 | - public function save( $data = array() ) { |
|
382 | + public function save($data = array()) { |
|
383 | 383 | return $this->get_id(); |
384 | 384 | } |
385 | 385 |
@@ -7,18 +7,18 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$watermark = wpinv_watermark( $invoice->get_id() ) |
|
12 | +$watermark = wpinv_watermark($invoice->get_id()) |
|
13 | 13 | |
14 | 14 | ?> |
15 | 15 | |
16 | - <?php do_action( 'getpaid_before_invoice_details_top', $invoice ); ?> |
|
16 | + <?php do_action('getpaid_before_invoice_details_top', $invoice); ?> |
|
17 | 17 | |
18 | - <?php if ( ! empty( $watermark ) ) : ?> |
|
18 | + <?php if (!empty($watermark)) : ?> |
|
19 | 19 | |
20 | 20 | <div class="getpaid-watermark no-print"> |
21 | - <p><?php echo sanitize_text_field( $watermark ) ?></p> |
|
21 | + <p><?php echo sanitize_text_field($watermark) ?></p> |
|
22 | 22 | </div> |
23 | 23 | |
24 | 24 | <?php endif; ?> |
@@ -26,15 +26,15 @@ discard block |
||
26 | 26 | <div class="getpaid-invoice-details-top mb-5"> |
27 | 27 | <div class="row"> |
28 | 28 | <div class="col-12 col-sm-6 text-left"> |
29 | - <?php do_action( 'getpaid_invoice_details_top_left', $invoice ); ?> |
|
29 | + <?php do_action('getpaid_invoice_details_top_left', $invoice); ?> |
|
30 | 30 | </div> |
31 | 31 | |
32 | 32 | <div class="col-12 col-sm-6 text-right"> |
33 | - <?php do_action( 'getpaid_invoice_details_top_right', $invoice ); ?> |
|
33 | + <?php do_action('getpaid_invoice_details_top_right', $invoice); ?> |
|
34 | 34 | </div> |
35 | 35 | </div> |
36 | 36 | </div> |
37 | 37 | |
38 | - <?php do_action( 'getpaid_after_invoice_details_top', $invoice ); ?> |
|
38 | + <?php do_action('getpaid_after_invoice_details_top', $invoice); ?> |
|
39 | 39 | |
40 | 40 | <?php |
@@ -7,51 +7,51 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$class = ! is_singular( 'page' ) ? 'table-sm' : ''; |
|
12 | +$class = !is_singular('page') ? 'table-sm' : ''; |
|
13 | 13 | ?> |
14 | 14 | |
15 | - <?php do_action( 'getpaid_before_invoice_meta', $invoice ); ?> |
|
15 | + <?php do_action('getpaid_before_invoice_meta', $invoice); ?> |
|
16 | 16 | <div class="getpaid-invoice-meta-data"> |
17 | 17 | |
18 | 18 | |
19 | - <?php do_action( 'getpaid_before_invoice_meta_table', $invoice ); ?> |
|
19 | + <?php do_action('getpaid_before_invoice_meta_table', $invoice); ?> |
|
20 | 20 | <table class="table <?php echo $class; ?> table-bordered"> |
21 | 21 | <tbody> |
22 | 22 | |
23 | - <?php do_action( "getpaid_before_invoice_meta_rows", $invoice ); ?> |
|
24 | - <?php foreach ( $meta as $key => $data ) : ?> |
|
23 | + <?php do_action("getpaid_before_invoice_meta_rows", $invoice); ?> |
|
24 | + <?php foreach ($meta as $key => $data) : ?> |
|
25 | 25 | |
26 | - <?php if ( ! empty( $data['value'] ) ) : ?> |
|
26 | + <?php if (!empty($data['value'])) : ?> |
|
27 | 27 | |
28 | - <?php do_action( "getpaid_before_invoice_meta_$key", $invoice, $data ); ?> |
|
28 | + <?php do_action("getpaid_before_invoice_meta_$key", $invoice, $data); ?> |
|
29 | 29 | |
30 | - <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
30 | + <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>"> |
|
31 | 31 | |
32 | 32 | <th> |
33 | - <?php echo sanitize_text_field( $data['label'] ); ?> |
|
33 | + <?php echo sanitize_text_field($data['label']); ?> |
|
34 | 34 | </th> |
35 | 35 | |
36 | 36 | <td> |
37 | - <span class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>-value"><?php echo wp_kses_post( $data['value'] ); ?></span> |
|
37 | + <span class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>-value"><?php echo wp_kses_post($data['value']); ?></span> |
|
38 | 38 | </td> |
39 | 39 | |
40 | 40 | </tr> |
41 | 41 | |
42 | - <?php do_action( "getpaid_after_invoice_meta_$key", $invoice, $data ); ?> |
|
42 | + <?php do_action("getpaid_after_invoice_meta_$key", $invoice, $data); ?> |
|
43 | 43 | |
44 | 44 | <?php endif; ?> |
45 | 45 | |
46 | 46 | <?php endforeach; ?> |
47 | - <?php do_action( "getpaid_after_invoice_meta_rows", $invoice ); ?> |
|
47 | + <?php do_action("getpaid_after_invoice_meta_rows", $invoice); ?> |
|
48 | 48 | |
49 | 49 | </tbody> |
50 | 50 | </table> |
51 | - <?php do_action( 'getpaid_after_invoice_meta_table', $invoice ); ?> |
|
51 | + <?php do_action('getpaid_after_invoice_meta_table', $invoice); ?> |
|
52 | 52 | |
53 | 53 | |
54 | 54 | </div> |
55 | - <?php do_action( 'getpaid_after_invoice_meta', $invoice ); ?> |
|
55 | + <?php do_action('getpaid_after_invoice_meta', $invoice); ?> |
|
56 | 56 | |
57 | 57 | <?php |
@@ -7,35 +7,35 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
14 | 14 | <div class="getpaid-header-right-actions"> |
15 | 15 | |
16 | - <?php if ( $invoice->is_type( 'invoice' ) ) : ?> |
|
16 | + <?php if ($invoice->is_type('invoice')) : ?> |
|
17 | 17 | |
18 | 18 | <a class="btn btn-sm btn-secondary invoice-action-print" onclick="window.print();" href="javascript:void(0)"> |
19 | - <?php _e( 'Print Invoice', 'invoicing' ); ?> |
|
19 | + <?php _e('Print Invoice', 'invoicing'); ?> |
|
20 | 20 | </a> |
21 | 21 | |
22 | - <?php if ( is_user_logged_in() ) : ?> |
|
22 | + <?php if (is_user_logged_in()) : ?> |
|
23 | 23 | |
24 | - <a class="btn btn-sm btn-secondary invoice-action-history" href="<?php echo esc_url( wpinv_get_history_page_uri() ); ?>"> |
|
25 | - <?php _e( 'Invoice History', 'invoicing' ); ?> |
|
24 | + <a class="btn btn-sm btn-secondary invoice-action-history" href="<?php echo esc_url(wpinv_get_history_page_uri()); ?>"> |
|
25 | + <?php _e('Invoice History', 'invoicing'); ?> |
|
26 | 26 | </a> |
27 | 27 | <?php endif; ?> |
28 | 28 | |
29 | - <?php if ( wpinv_current_user_can_manage_invoicing() ) : ?> |
|
29 | + <?php if (wpinv_current_user_can_manage_invoicing()) : ?> |
|
30 | 30 | |
31 | - <a class="btn btn-sm btn-secondary invoice-action-edit" href="<?php echo esc_url( get_edit_post_link( $invoice->get_id() ) ); ?>"> |
|
32 | - <?php _e( 'Edit Invoice', 'invoicing' ); ?> |
|
31 | + <a class="btn btn-sm btn-secondary invoice-action-edit" href="<?php echo esc_url(get_edit_post_link($invoice->get_id())); ?>"> |
|
32 | + <?php _e('Edit Invoice', 'invoicing'); ?> |
|
33 | 33 | </a> |
34 | 34 | <?php endif; ?> |
35 | 35 | |
36 | 36 | <?php endif; ?> |
37 | 37 | |
38 | - <?php do_action('wpinv_invoice_display_right_actions', $invoice ); ?> |
|
38 | + <?php do_action('wpinv_invoice_display_right_actions', $invoice); ?> |
|
39 | 39 | </div> |
40 | 40 | |
41 | 41 | <?php |
@@ -9,9 +9,9 @@ discard block |
||
9 | 9 | * @var array $fee |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | -do_action( 'getpaid_before_invoice_fee_item', $invoice, $fee ); |
|
14 | +do_action('getpaid_before_invoice_fee_item', $invoice, $fee); |
|
15 | 15 | |
16 | 16 | ?> |
17 | 17 | |
@@ -19,61 +19,61 @@ discard block |
||
19 | 19 | |
20 | 20 | <div class="form-row"> |
21 | 21 | |
22 | - <?php foreach ( array_keys( $columns ) as $column ): ?> |
|
22 | + <?php foreach (array_keys($columns) as $column): ?> |
|
23 | 23 | |
24 | - <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class( $column ); ?>"> |
|
24 | + <div class="<?php echo 'name' == $column ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-item-<?php echo sanitize_html_class($column); ?>"> |
|
25 | 25 | |
26 | 26 | <?php |
27 | 27 | |
28 | 28 | // Fires before printing a fee item column. |
29 | - do_action( "getpaid_invoice_fee_item_before_$column", $fee, $invoice ); |
|
29 | + do_action("getpaid_invoice_fee_item_before_$column", $fee, $invoice); |
|
30 | 30 | |
31 | 31 | // Item name. |
32 | - if ( 'name' == $column ) { |
|
32 | + if ('name' == $column) { |
|
33 | 33 | |
34 | 34 | // Display the name. |
35 | - echo '<div class="mb-1">' . sanitize_text_field( $fee['name'] ) . '</div>'; |
|
35 | + echo '<div class="mb-1">' . sanitize_text_field($fee['name']) . '</div>'; |
|
36 | 36 | |
37 | 37 | // And an optional description. |
38 | - $description = esc_html__( 'Fee', 'invoicing' ); |
|
38 | + $description = esc_html__('Fee', 'invoicing'); |
|
39 | 39 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
40 | 40 | |
41 | 41 | } |
42 | 42 | |
43 | 43 | // Item price. |
44 | - if ( 'price' == $column ) { |
|
44 | + if ('price' == $column) { |
|
45 | 45 | |
46 | 46 | // Display the item price (or recurring price if this is a renewal invoice) |
47 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
48 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
47 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
48 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
49 | 49 | } else { |
50 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
50 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | } |
54 | 54 | |
55 | 55 | // Item quantity. |
56 | - if ( 'quantity' == $column ) { |
|
56 | + if ('quantity' == $column) { |
|
57 | 57 | echo "—"; |
58 | 58 | } |
59 | 59 | |
60 | 60 | // Item sub total. |
61 | - if ( 'subtotal' == $column ) { |
|
61 | + if ('subtotal' == $column) { |
|
62 | 62 | |
63 | 63 | // Display the item price (or recurring price if this is a renewal invoice) |
64 | - if ( $invoice->is_recurring() && $invoice->is_renewal() ) { |
|
65 | - echo wpinv_price( $fee['recurring_fee'], $invoice->get_currency() ); |
|
64 | + if ($invoice->is_recurring() && $invoice->is_renewal()) { |
|
65 | + echo wpinv_price($fee['recurring_fee'], $invoice->get_currency()); |
|
66 | 66 | } else { |
67 | - echo wpinv_price( $fee['initial_fee'], $invoice->get_currency() ); |
|
67 | + echo wpinv_price($fee['initial_fee'], $invoice->get_currency()); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | } |
71 | 71 | |
72 | 72 | // Fires when printing a fee item column. |
73 | - do_action( "getpaid_invoice_fee_item_$column", $fee, $invoice ); |
|
73 | + do_action("getpaid_invoice_fee_item_$column", $fee, $invoice); |
|
74 | 74 | |
75 | 75 | // Fires after printing a fee item column. |
76 | - do_action( "getpaid_invoice_fee_item_after_$column", $fee, $invoice ); |
|
76 | + do_action("getpaid_invoice_fee_item_after_$column", $fee, $invoice); |
|
77 | 77 | |
78 | 78 | ?> |
79 | 79 |
@@ -9,26 +9,26 @@ discard block |
||
9 | 9 | * @var WPInv_Invoice $invoice |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | 14 | // Totals rows. |
15 | -$totals = getpaid_invoice_totals_rows( $invoice ); |
|
15 | +$totals = getpaid_invoice_totals_rows($invoice); |
|
16 | 16 | |
17 | -do_action( 'getpaid_before_invoice_line_totals', $invoice, $totals ); |
|
17 | +do_action('getpaid_before_invoice_line_totals', $invoice, $totals); |
|
18 | 18 | |
19 | 19 | ?> |
20 | 20 | <div class='getpaid-invoice-line-totals'> |
21 | 21 | <div class="row"> |
22 | 22 | <div class="col-12 offset-sm-6 col-sm-6 border-left pl-0"> |
23 | 23 | |
24 | - <?php foreach ( $totals as $key => $label ) : ?> |
|
24 | + <?php foreach ($totals as $key => $label) : ?> |
|
25 | 25 | |
26 | - <div class="getpaid-invoice-line-totals-col <?php echo sanitize_html_class( $key ); ?>"> |
|
26 | + <div class="getpaid-invoice-line-totals-col <?php echo sanitize_html_class($key); ?>"> |
|
27 | 27 | |
28 | 28 | <div class="row"> |
29 | 29 | |
30 | 30 | <div class="col-12 col-sm-8 getpaid-invoice-line-totals-label"> |
31 | - <?php echo sanitize_text_field( $label ); ?> |
|
31 | + <?php echo sanitize_text_field($label); ?> |
|
32 | 32 | </div> |
33 | 33 | |
34 | 34 | <div class="col-12 col-sm-2 getpaid-invoice-line-totals-value"> |
@@ -36,32 +36,32 @@ discard block |
||
36 | 36 | <?php |
37 | 37 | |
38 | 38 | // Total tax. |
39 | - if ( 'tax' == $key ) { |
|
40 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_tax() ), $invoice->get_currency() ); |
|
39 | + if ('tax' == $key) { |
|
40 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_tax()), $invoice->get_currency()); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | // Total Fee. |
44 | - if ( 'fee' == $key ) { |
|
45 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_fees() ), $invoice->get_currency() ); |
|
44 | + if ('fee' == $key) { |
|
45 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_fees()), $invoice->get_currency()); |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | // Total discount. |
49 | - if ( 'discount' == $key ) { |
|
50 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total_discount() ), $invoice->get_currency() ); |
|
49 | + if ('discount' == $key) { |
|
50 | + echo wpinv_price(wpinv_format_amount($invoice->get_total_discount()), $invoice->get_currency()); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | // Sub total. |
54 | - if ( 'subtotal' == $key ) { |
|
55 | - echo wpinv_price( wpinv_format_amount( $invoice->get_subtotal() ), $invoice->get_currency() ); |
|
54 | + if ('subtotal' == $key) { |
|
55 | + echo wpinv_price(wpinv_format_amount($invoice->get_subtotal()), $invoice->get_currency()); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | // Total. |
59 | - if ( 'total' == $key ) { |
|
60 | - echo wpinv_price( wpinv_format_amount( $invoice->get_total() ), $invoice->get_currency() ); |
|
59 | + if ('total' == $key) { |
|
60 | + echo wpinv_price(wpinv_format_amount($invoice->get_total()), $invoice->get_currency()); |
|
61 | 61 | } |
62 | 62 | |
63 | 63 | // Fires when printing a cart total. |
64 | - do_action( "getpaid_invoice_cart_totals_$key", $invoice ); |
|
64 | + do_action("getpaid_invoice_cart_totals_$key", $invoice); |
|
65 | 65 | |
66 | 66 | ?> |
67 | 67 | |
@@ -75,4 +75,4 @@ discard block |
||
75 | 75 | </div> |
76 | 76 | </div> <!-- end .getpaid-invoice-line-totals --> |
77 | 77 | |
78 | -<?php do_action( 'getpaid_after_invoice_line_totals', $invoice, $totals ); ?> |
|
78 | +<?php do_action('getpaid_after_invoice_line_totals', $invoice, $totals); ?> |
@@ -8,21 +8,21 @@ discard block |
||
8 | 8 | * @var WPInv_Invoice $invoice |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | 13 | ?> |
14 | 14 | |
15 | -<?php do_action( 'getpaid_invoice_before_line_items', $invoice ); ?> |
|
15 | +<?php do_action('getpaid_invoice_before_line_items', $invoice); ?> |
|
16 | 16 | |
17 | - <h2 class="mt-5 mb-1 h4"><?php echo sprintf( esc_html__( '%s Items', 'invoicing' ), ucfirst( $invoice->get_type() )); ?></h2> |
|
17 | + <h2 class="mt-5 mb-1 h4"><?php echo sprintf(esc_html__('%s Items', 'invoicing'), ucfirst($invoice->get_type())); ?></h2> |
|
18 | 18 | <div class="getpaid-invoice-items mb-4 border"> |
19 | 19 | |
20 | 20 | |
21 | - <div class="getpaid-invoice-items-header <?php echo sanitize_html_class( $invoice->get_template() ); ?>"> |
|
21 | + <div class="getpaid-invoice-items-header <?php echo sanitize_html_class($invoice->get_template()); ?>"> |
|
22 | 22 | <div class="form-row"> |
23 | - <?php foreach ( $columns as $key => $label ) : ?> |
|
24 | - <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-line-item-col-<?php echo esc_attr( $key ); ?>"> |
|
25 | - <?php echo sanitize_text_field( $label ); ?> |
|
23 | + <?php foreach ($columns as $key => $label) : ?> |
|
24 | + <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> getpaid-invoice-line-item-col-<?php echo esc_attr($key); ?>"> |
|
25 | + <?php echo sanitize_text_field($label); ?> |
|
26 | 26 | </div> |
27 | 27 | <?php endforeach; ?> |
28 | 28 | </div> |
@@ -32,20 +32,20 @@ discard block |
||
32 | 32 | <?php |
33 | 33 | |
34 | 34 | // Display the item totals. |
35 | - foreach ( $invoice->get_items() as $item ) { |
|
36 | - wpinv_get_template( 'invoice/line-item.php', compact( 'invoice', 'item', 'columns' ) ); |
|
35 | + foreach ($invoice->get_items() as $item) { |
|
36 | + wpinv_get_template('invoice/line-item.php', compact('invoice', 'item', 'columns')); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | // Display the fee totals. |
40 | - foreach ( $invoice->get_fees() as $fee ) { |
|
41 | - wpinv_get_template( 'invoice/fee-item.php', compact( 'invoice', 'fee', 'columns' ) ); |
|
40 | + foreach ($invoice->get_fees() as $fee) { |
|
41 | + wpinv_get_template('invoice/fee-item.php', compact('invoice', 'fee', 'columns')); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | // Display the cart totals. |
45 | - wpinv_get_template( 'invoice/line-totals.php', compact( 'invoice' ) ); |
|
45 | + wpinv_get_template('invoice/line-totals.php', compact('invoice')); |
|
46 | 46 | |
47 | 47 | ?> |
48 | 48 | |
49 | 49 | </div> |
50 | 50 | |
51 | -<?php do_action( 'getpaid_invoice_after_line_items', $invoice ); ?> |
|
51 | +<?php do_action('getpaid_invoice_after_line_items', $invoice); ?> |