@@ -9,17 +9,17 @@ discard block |
||
9 | 9 | * @var WPInv_Subscriptions_Widget $widget |
10 | 10 | */ |
11 | 11 | |
12 | -defined( 'ABSPATH' ) || exit; |
|
12 | +defined('ABSPATH') || exit; |
|
13 | 13 | |
14 | -do_action( 'getpaid_single_subscription_before_notices', $subscription ); |
|
14 | +do_action('getpaid_single_subscription_before_notices', $subscription); |
|
15 | 15 | |
16 | 16 | // Display errors and notices. |
17 | 17 | wpinv_print_errors(); |
18 | 18 | |
19 | -$subscription_groups = getpaid_get_invoice_subscription_groups( $subscription->get_parent_invoice_id() ); |
|
20 | -$subscription_group = getpaid_get_invoice_subscription_group( $subscription->get_parent_invoice_id(), $subscription->get_id() ); |
|
19 | +$subscription_groups = getpaid_get_invoice_subscription_groups($subscription->get_parent_invoice_id()); |
|
20 | +$subscription_group = getpaid_get_invoice_subscription_group($subscription->get_parent_invoice_id(), $subscription->get_id()); |
|
21 | 21 | |
22 | -do_action( 'getpaid_before_single_subscription', $subscription, $subscription_groups ); |
|
22 | +do_action('getpaid_before_single_subscription', $subscription, $subscription_groups); |
|
23 | 23 | |
24 | 24 | ?> |
25 | 25 | |
@@ -31,44 +31,44 @@ discard block |
||
31 | 31 | |
32 | 32 | </style> |
33 | 33 | |
34 | -<h2 class="mb-1 h4"><?php _e( 'Subscription Details', 'invoicing' ); ?></h2> |
|
34 | +<h2 class="mb-1 h4"><?php _e('Subscription Details', 'invoicing'); ?></h2> |
|
35 | 35 | <table class="table table-bordered"> |
36 | 36 | <tbody> |
37 | 37 | |
38 | - <?php foreach ( $widget->get_single_subscription_columns( $subscription ) as $key => $label ) : ?> |
|
38 | + <?php foreach ($widget->get_single_subscription_columns($subscription) as $key => $label) : ?> |
|
39 | 39 | |
40 | - <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
40 | + <tr class="getpaid-subscription-meta-<?php echo sanitize_html_class($key); ?>"> |
|
41 | 41 | |
42 | 42 | <th class="font-weight-bold" style="width: 35%"> |
43 | - <?php echo sanitize_text_field( $label ); ?> |
|
43 | + <?php echo sanitize_text_field($label); ?> |
|
44 | 44 | </th> |
45 | 45 | |
46 | 46 | <td style="width: 65%"> |
47 | 47 | <?php |
48 | 48 | |
49 | - switch ( $key ) { |
|
49 | + switch ($key) { |
|
50 | 50 | |
51 | 51 | case 'status': |
52 | - echo sanitize_text_field( $subscription->get_status_label() ); |
|
52 | + echo sanitize_text_field($subscription->get_status_label()); |
|
53 | 53 | break; |
54 | 54 | |
55 | 55 | case 'start_date': |
56 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_date_created() ) ); |
|
56 | + echo sanitize_text_field(getpaid_format_date_value($subscription->get_date_created())); |
|
57 | 57 | break; |
58 | 58 | |
59 | 59 | case 'expiry_date': |
60 | - echo sanitize_text_field( getpaid_format_date_value( $subscription->get_next_renewal_date() ) ); |
|
60 | + echo sanitize_text_field(getpaid_format_date_value($subscription->get_next_renewal_date())); |
|
61 | 61 | break; |
62 | 62 | |
63 | 63 | case 'initial_amount': |
64 | - echo wpinv_price( $subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
64 | + echo wpinv_price($subscription->get_initial_amount(), $subscription->get_parent_payment()->get_currency()); |
|
65 | 65 | |
66 | - if ( $subscription->has_trial_period() ) { |
|
66 | + if ($subscription->has_trial_period()) { |
|
67 | 67 | |
68 | 68 | echo "<small class='text-muted'> "; |
69 | 69 | printf( |
70 | - _x( '( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing' ), |
|
71 | - sanitize_text_field( $subscription->get_trial_period() ) |
|
70 | + _x('( %1$s trial )', 'Subscription trial period. (e.g.: 1 month trial)', 'invoicing'), |
|
71 | + sanitize_text_field($subscription->get_trial_period()) |
|
72 | 72 | ); |
73 | 73 | echo '</small>'; |
74 | 74 | |
@@ -77,18 +77,18 @@ discard block |
||
77 | 77 | break; |
78 | 78 | |
79 | 79 | case 'recurring_amount': |
80 | - $frequency = getpaid_get_subscription_period_label( $subscription->get_period(), $subscription->get_frequency(), '' ); |
|
81 | - $amount = wpinv_price( $subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency() ); |
|
82 | - echo strtolower( "<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>" ); |
|
80 | + $frequency = getpaid_get_subscription_period_label($subscription->get_period(), $subscription->get_frequency(), ''); |
|
81 | + $amount = wpinv_price($subscription->get_recurring_amount(), $subscription->get_parent_payment()->get_currency()); |
|
82 | + echo strtolower("<strong style='font-weight: 500;'>$amount</strong> / <span class='getpaid-item-recurring-period'>$frequency</span>"); |
|
83 | 83 | break; |
84 | 84 | |
85 | 85 | case 'item': |
86 | 86 | |
87 | - if ( empty( $subscription_group ) ) { |
|
88 | - echo WPInv_Subscriptions_List_Table::generate_item_markup( $subscription->get_product_id() ); |
|
87 | + if (empty($subscription_group)) { |
|
88 | + echo WPInv_Subscriptions_List_Table::generate_item_markup($subscription->get_product_id()); |
|
89 | 89 | } else { |
90 | - $markup = array_map( array( 'WPInv_Subscriptions_List_Table', 'generate_item_markup' ), array_keys( $subscription_group['items'] ) ); |
|
91 | - echo implode( ' | ', $markup ); |
|
90 | + $markup = array_map(array('WPInv_Subscriptions_List_Table', 'generate_item_markup'), array_keys($subscription_group['items'])); |
|
91 | + echo implode(' | ', $markup); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | break; |
@@ -96,12 +96,12 @@ discard block |
||
96 | 96 | case 'payments': |
97 | 97 | |
98 | 98 | $max_activations = (int) $subscription->get_bill_times(); |
99 | - echo (int) $subscription->get_times_billed() . ' / ' . ( empty( $max_activations ) ? "∞" : $max_activations ); |
|
99 | + echo (int) $subscription->get_times_billed() . ' / ' . (empty($max_activations) ? "∞" : $max_activations); |
|
100 | 100 | |
101 | 101 | break; |
102 | 102 | |
103 | 103 | } |
104 | - do_action( "getpaid_render_single_subscription_column_$key", $subscription ); |
|
104 | + do_action("getpaid_render_single_subscription_column_$key", $subscription); |
|
105 | 105 | |
106 | 106 | ?> |
107 | 107 | </td> |
@@ -113,34 +113,34 @@ discard block |
||
113 | 113 | </tbody> |
114 | 114 | </table> |
115 | 115 | |
116 | -<?php if ( ! empty( $subscription_group ) ) : ?> |
|
117 | - <h2 class='mt-5 mb-1 h4'><?php _e( 'Subscription Items', 'invoicing' ); ?></h2> |
|
118 | - <?php getpaid_admin_subscription_item_details_metabox( $subscription ); ?> |
|
116 | +<?php if (!empty($subscription_group)) : ?> |
|
117 | + <h2 class='mt-5 mb-1 h4'><?php _e('Subscription Items', 'invoicing'); ?></h2> |
|
118 | + <?php getpaid_admin_subscription_item_details_metabox($subscription); ?> |
|
119 | 119 | <?php endif; ?> |
120 | 120 | |
121 | -<h2 class='mt-5 mb-1 h4'><?php _e( 'Related Invoices', 'invoicing' ); ?></h2> |
|
121 | +<h2 class='mt-5 mb-1 h4'><?php _e('Related Invoices', 'invoicing'); ?></h2> |
|
122 | 122 | |
123 | -<?php echo getpaid_admin_subscription_invoice_details_metabox( $subscription ); ?> |
|
123 | +<?php echo getpaid_admin_subscription_invoice_details_metabox($subscription); ?> |
|
124 | 124 | |
125 | -<?php if ( 1 < count( $subscription_groups ) ) : ?> |
|
126 | - <h2 class='mt-5 mb-1 h4'><?php _e( 'Related Subscriptions', 'invoicing' ); ?></h2> |
|
127 | - <?php getpaid_admin_subscription_related_subscriptions_metabox( $subscription ); ?> |
|
125 | +<?php if (1 < count($subscription_groups)) : ?> |
|
126 | + <h2 class='mt-5 mb-1 h4'><?php _e('Related Subscriptions', 'invoicing'); ?></h2> |
|
127 | + <?php getpaid_admin_subscription_related_subscriptions_metabox($subscription); ?> |
|
128 | 128 | <?php endif; ?> |
129 | 129 | |
130 | 130 | <span class="form-text"> |
131 | 131 | |
132 | 132 | <?php |
133 | - if ( $subscription->can_cancel() ) { |
|
133 | + if ($subscription->can_cancel()) { |
|
134 | 134 | printf( |
135 | 135 | '<a href="%s" class="btn btn-danger btn-sm" onclick="return confirm(\'%s\')">%s</a> ', |
136 | - esc_url( $subscription->get_cancel_url() ), |
|
137 | - esc_attr__( 'Are you sure you want to cancel this subscription?', 'invoicing' ), |
|
138 | - __( 'Cancel Subscription', 'invoicing' ) |
|
136 | + esc_url($subscription->get_cancel_url()), |
|
137 | + esc_attr__('Are you sure you want to cancel this subscription?', 'invoicing'), |
|
138 | + __('Cancel Subscription', 'invoicing') |
|
139 | 139 | ); |
140 | 140 | } |
141 | 141 | |
142 | - do_action( 'getpaid-single-subscription-page-actions', $subscription ); |
|
142 | + do_action('getpaid-single-subscription-page-actions', $subscription); |
|
143 | 143 | ?> |
144 | 144 | |
145 | - <a href="<?php echo esc_url( getpaid_get_tab_url( 'gp-subscriptions', get_permalink( (int) wpinv_get_option( 'invoice_subscription_page' ) ) ) ); ?>" class="btn btn-secondary btn-sm"><?php _e( 'Go Back', 'invoicing' ); ?></a> |
|
145 | + <a href="<?php echo esc_url(getpaid_get_tab_url('gp-subscriptions', get_permalink((int) wpinv_get_option('invoice_subscription_page')))); ?>" class="btn btn-secondary btn-sm"><?php _e('Go Back', 'invoicing'); ?></a> |
|
146 | 146 | </span> |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'ABSPATH' ) ) { |
|
2 | +if (!defined('ABSPATH')) { |
|
3 | 3 | exit; |
4 | 4 | } |
5 | 5 | |
@@ -149,8 +149,8 @@ discard block |
||
149 | 149 | $this->state = wpinv_get_default_state(); |
150 | 150 | |
151 | 151 | // Do we have an actual submission? |
152 | - if ( isset( $_POST['getpaid_payment_form_submission'] ) ) { |
|
153 | - $this->load_data( $_POST ); |
|
152 | + if (isset($_POST['getpaid_payment_form_submission'])) { |
|
153 | + $this->load_data($_POST); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | } |
@@ -160,19 +160,19 @@ discard block |
||
160 | 160 | * |
161 | 161 | * @param array $data |
162 | 162 | */ |
163 | - public function load_data( $data ) { |
|
163 | + public function load_data($data) { |
|
164 | 164 | |
165 | 165 | // Remove slashes from the submitted data... |
166 | - $data = wp_unslash( $data ); |
|
166 | + $data = wp_unslash($data); |
|
167 | 167 | |
168 | 168 | // Allow plugins to filter the data. |
169 | - $data = apply_filters( 'getpaid_submission_data', $data, $this ); |
|
169 | + $data = apply_filters('getpaid_submission_data', $data, $this); |
|
170 | 170 | |
171 | 171 | // Cache it... |
172 | 172 | $this->data = $data; |
173 | 173 | |
174 | 174 | // Then generate a unique id from the data. |
175 | - $this->id = md5( wp_json_encode( $data ) ); |
|
175 | + $this->id = md5(wp_json_encode($data)); |
|
176 | 176 | |
177 | 177 | // Finally, process the submission. |
178 | 178 | try { |
@@ -182,30 +182,30 @@ discard block |
||
182 | 182 | $processors = apply_filters( |
183 | 183 | 'getpaid_payment_form_submission_processors', |
184 | 184 | array( |
185 | - array( $this, 'process_payment_form' ), |
|
186 | - array( $this, 'process_invoice' ), |
|
187 | - array( $this, 'process_fees' ), |
|
188 | - array( $this, 'process_items' ), |
|
189 | - array( $this, 'process_discount' ), |
|
190 | - array( $this, 'process_taxes' ), |
|
185 | + array($this, 'process_payment_form'), |
|
186 | + array($this, 'process_invoice'), |
|
187 | + array($this, 'process_fees'), |
|
188 | + array($this, 'process_items'), |
|
189 | + array($this, 'process_discount'), |
|
190 | + array($this, 'process_taxes'), |
|
191 | 191 | ), |
192 | 192 | $this |
193 | 193 | ); |
194 | 194 | |
195 | - foreach ( $processors as $processor ) { |
|
196 | - call_user_func_array( $processor, array( &$this ) ); |
|
195 | + foreach ($processors as $processor) { |
|
196 | + call_user_func_array($processor, array(&$this)); |
|
197 | 197 | } |
198 | 198 | |
199 | - } catch( GetPaid_Payment_Exception $e ) { |
|
199 | + } catch (GetPaid_Payment_Exception $e) { |
|
200 | 200 | $this->last_error = $e->getMessage(); |
201 | 201 | $this->last_error_code = $e->getErrorCode(); |
202 | - } catch ( Exception $e ) { |
|
202 | + } catch (Exception $e) { |
|
203 | 203 | $this->last_error = $e->getMessage(); |
204 | 204 | $this->last_error_code = $e->getCode(); |
205 | 205 | } |
206 | 206 | |
207 | 207 | // Fired when we are done processing a submission. |
208 | - do_action_ref_array( 'getpaid_process_submission', array( &$this ) ); |
|
208 | + do_action_ref_array('getpaid_process_submission', array(&$this)); |
|
209 | 209 | |
210 | 210 | } |
211 | 211 | |
@@ -226,18 +226,18 @@ discard block |
||
226 | 226 | public function process_payment_form() { |
227 | 227 | |
228 | 228 | // Every submission needs an active payment form. |
229 | - if ( empty( $this->data['form_id'] ) ) { |
|
230 | - throw new Exception( __( 'Missing payment form', 'invoicing' ) ); |
|
229 | + if (empty($this->data['form_id'])) { |
|
230 | + throw new Exception(__('Missing payment form', 'invoicing')); |
|
231 | 231 | } |
232 | 232 | |
233 | 233 | // Fetch the payment form. |
234 | - $this->payment_form = new GetPaid_Payment_Form( $this->data['form_id'] ); |
|
234 | + $this->payment_form = new GetPaid_Payment_Form($this->data['form_id']); |
|
235 | 235 | |
236 | - if ( ! $this->payment_form->is_active() ) { |
|
237 | - throw new Exception( __( 'Payment form not active', 'invoicing' ) ); |
|
236 | + if (!$this->payment_form->is_active()) { |
|
237 | + throw new Exception(__('Payment form not active', 'invoicing')); |
|
238 | 238 | } |
239 | 239 | |
240 | - do_action_ref_array( 'getpaid_submissions_process_payment_form', array( &$this ) ); |
|
240 | + do_action_ref_array('getpaid_submissions_process_payment_form', array(&$this)); |
|
241 | 241 | } |
242 | 242 | |
243 | 243 | /** |
@@ -267,53 +267,53 @@ discard block |
||
267 | 267 | public function process_invoice() { |
268 | 268 | |
269 | 269 | // Abort if there is no invoice. |
270 | - if ( empty( $this->data['invoice_id'] ) ) { |
|
270 | + if (empty($this->data['invoice_id'])) { |
|
271 | 271 | return; |
272 | 272 | } |
273 | 273 | |
274 | 274 | // If the submission is for an existing invoice, ensure that it exists |
275 | 275 | // and that it is not paid for. |
276 | - $invoice = wpinv_get_invoice( $this->data['invoice_id'] ); |
|
276 | + $invoice = wpinv_get_invoice($this->data['invoice_id']); |
|
277 | 277 | |
278 | - if ( empty( $invoice ) ) { |
|
279 | - throw new Exception( __( 'Invalid invoice', 'invoicing' ) ); |
|
278 | + if (empty($invoice)) { |
|
279 | + throw new Exception(__('Invalid invoice', 'invoicing')); |
|
280 | 280 | } |
281 | 281 | |
282 | - if ( $invoice->is_paid() ) { |
|
283 | - throw new Exception( __( 'This invoice is already paid for.', 'invoicing' ) ); |
|
282 | + if ($invoice->is_paid()) { |
|
283 | + throw new Exception(__('This invoice is already paid for.', 'invoicing')); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | $this->payment_form->invoice = $invoice; |
287 | - if ( ! $this->payment_form->is_default() ) { |
|
287 | + if (!$this->payment_form->is_default()) { |
|
288 | 288 | |
289 | 289 | $items = array(); |
290 | 290 | $item_ids = array(); |
291 | 291 | |
292 | - foreach ( $invoice->get_items() as $item ) { |
|
293 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
292 | + foreach ($invoice->get_items() as $item) { |
|
293 | + if (!in_array($item->get_id(), $item_ids)) { |
|
294 | 294 | $item_ids[] = $item->get_id(); |
295 | 295 | $items[] = $item; |
296 | 296 | } |
297 | 297 | } |
298 | 298 | |
299 | - foreach ( $this->payment_form->get_items() as $item ) { |
|
300 | - if ( ! in_array( $item->get_id(), $item_ids ) ) { |
|
299 | + foreach ($this->payment_form->get_items() as $item) { |
|
300 | + if (!in_array($item->get_id(), $item_ids)) { |
|
301 | 301 | $item_ids[] = $item->get_id(); |
302 | 302 | $items[] = $item; |
303 | 303 | } |
304 | 304 | } |
305 | 305 | |
306 | - $this->payment_form->set_items( $items ); |
|
306 | + $this->payment_form->set_items($items); |
|
307 | 307 | |
308 | 308 | } else { |
309 | - $this->payment_form->set_items( $invoice->get_items() ); |
|
309 | + $this->payment_form->set_items($invoice->get_items()); |
|
310 | 310 | } |
311 | 311 | |
312 | 312 | $this->country = $invoice->get_country(); |
313 | 313 | $this->state = $invoice->get_state(); |
314 | 314 | $this->invoice = $invoice; |
315 | 315 | |
316 | - do_action_ref_array( 'getpaid_submissions_process_invoice', array( &$this ) ); |
|
316 | + do_action_ref_array('getpaid_submissions_process_invoice', array(&$this)); |
|
317 | 317 | } |
318 | 318 | |
319 | 319 | /** |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @return bool |
334 | 334 | */ |
335 | 335 | public function has_invoice() { |
336 | - return ! empty( $this->invoice ); |
|
336 | + return !empty($this->invoice); |
|
337 | 337 | } |
338 | 338 | |
339 | 339 | /* |
@@ -352,13 +352,13 @@ discard block |
||
352 | 352 | */ |
353 | 353 | public function process_items() { |
354 | 354 | |
355 | - $processor = new GetPaid_Payment_Form_Submission_Items( $this ); |
|
355 | + $processor = new GetPaid_Payment_Form_Submission_Items($this); |
|
356 | 356 | |
357 | - foreach ( $processor->items as $item ) { |
|
358 | - $this->add_item( $item ); |
|
357 | + foreach ($processor->items as $item) { |
|
358 | + $this->add_item($item); |
|
359 | 359 | } |
360 | 360 | |
361 | - do_action_ref_array( 'getpaid_submissions_process_items', array( &$this ) ); |
|
361 | + do_action_ref_array('getpaid_submissions_process_items', array(&$this)); |
|
362 | 362 | } |
363 | 363 | |
364 | 364 | /** |
@@ -367,24 +367,24 @@ discard block |
||
367 | 367 | * @since 1.0.19 |
368 | 368 | * @param GetPaid_Form_Item $item |
369 | 369 | */ |
370 | - public function add_item( $item ) { |
|
370 | + public function add_item($item) { |
|
371 | 371 | |
372 | 372 | // Make sure that it is available for purchase. |
373 | - if ( ! $item->can_purchase() || isset( $this->items[ $item->get_id() ] ) ) { |
|
373 | + if (!$item->can_purchase() || isset($this->items[$item->get_id()])) { |
|
374 | 374 | return; |
375 | 375 | } |
376 | 376 | |
377 | 377 | // Each submission can only contain one recurring item. |
378 | - if ( $item->is_recurring() ) { |
|
378 | + if ($item->is_recurring()) { |
|
379 | 379 | $this->has_recurring = $item->get_id(); |
380 | 380 | } |
381 | 381 | |
382 | 382 | // Update the items and totals. |
383 | - $this->items[ $item->get_id() ] = $item; |
|
383 | + $this->items[$item->get_id()] = $item; |
|
384 | 384 | $this->totals['subtotal']['initial'] += $item->get_sub_total(); |
385 | 385 | $this->totals['subtotal']['recurring'] += $item->get_recurring_sub_total(); |
386 | 386 | |
387 | - $this->subscription_groups = getpaid_calculate_subscription_totals( $this ); |
|
387 | + $this->subscription_groups = getpaid_calculate_subscription_totals($this); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | /** |
@@ -395,17 +395,17 @@ discard block |
||
395 | 395 | * |
396 | 396 | * @since 1.0.19 |
397 | 397 | */ |
398 | - public function remove_item( $item_id ) { |
|
398 | + public function remove_item($item_id) { |
|
399 | 399 | |
400 | - if ( isset( $this->items[ $item_id ] ) ) { |
|
401 | - $this->totals['subtotal']['initial'] -= $this->items[ $item_id ]->get_sub_total(); |
|
402 | - $this->totals['subtotal']['recurring'] -= $this->items[ $item_id ]->get_recurring_sub_total(); |
|
400 | + if (isset($this->items[$item_id])) { |
|
401 | + $this->totals['subtotal']['initial'] -= $this->items[$item_id]->get_sub_total(); |
|
402 | + $this->totals['subtotal']['recurring'] -= $this->items[$item_id]->get_recurring_sub_total(); |
|
403 | 403 | |
404 | - if ( $this->items[ $item_id ]->is_recurring() ) { |
|
404 | + if ($this->items[$item_id]->is_recurring()) { |
|
405 | 405 | $this->has_recurring = 0; |
406 | 406 | } |
407 | 407 | |
408 | - unset( $this->items[ $item_id ] ); |
|
408 | + unset($this->items[$item_id]); |
|
409 | 409 | } |
410 | 410 | |
411 | 411 | } |
@@ -417,7 +417,7 @@ discard block |
||
417 | 417 | */ |
418 | 418 | public function get_subtotal() { |
419 | 419 | |
420 | - if ( wpinv_prices_include_tax() ) { |
|
420 | + if (wpinv_prices_include_tax()) { |
|
421 | 421 | return $this->totals['subtotal']['initial'] - $this->totals['taxes']['initial']; |
422 | 422 | } |
423 | 423 | |
@@ -431,7 +431,7 @@ discard block |
||
431 | 431 | */ |
432 | 432 | public function get_recurring_subtotal() { |
433 | 433 | |
434 | - if ( wpinv_prices_include_tax() ) { |
|
434 | + if (wpinv_prices_include_tax()) { |
|
435 | 435 | return $this->totals['subtotal']['recurring'] - $this->totals['taxes']['recurring']; |
436 | 436 | } |
437 | 437 | |
@@ -465,39 +465,39 @@ discard block |
||
465 | 465 | public function process_taxes() { |
466 | 466 | |
467 | 467 | // Abort if we're not using taxes. |
468 | - if ( ! $this->use_taxes() ) { |
|
468 | + if (!$this->use_taxes()) { |
|
469 | 469 | return; |
470 | 470 | } |
471 | 471 | |
472 | 472 | // If a custom country && state has been passed in, use it to calculate taxes. |
473 | - $country = $this->get_field( 'wpinv_country', 'billing' ); |
|
474 | - if ( ! empty( $country ) ) { |
|
473 | + $country = $this->get_field('wpinv_country', 'billing'); |
|
474 | + if (!empty($country)) { |
|
475 | 475 | $this->country = $country; |
476 | 476 | } |
477 | 477 | |
478 | - $state = $this->get_field( 'wpinv_state', 'billing' ); |
|
479 | - if ( ! empty( $state ) ) { |
|
478 | + $state = $this->get_field('wpinv_state', 'billing'); |
|
479 | + if (!empty($state)) { |
|
480 | 480 | $this->state = $state; |
481 | 481 | } |
482 | 482 | |
483 | 483 | // Confirm if the provided country and the ip country are similar. |
484 | - $address_confirmed = $this->get_field( 'confirm-address' ); |
|
485 | - if ( wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty( $address_confirmed ) ) { |
|
486 | - throw new Exception( __( 'The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing' ) ); |
|
484 | + $address_confirmed = $this->get_field('confirm-address'); |
|
485 | + if (wpinv_should_validate_vat_number() && getpaid_get_ip_country() != $this->country && empty($address_confirmed)) { |
|
486 | + throw new Exception(__('The country of your current location must be the same as the country of your billing location or you must confirm the billing address is your home country.', 'invoicing')); |
|
487 | 487 | } |
488 | 488 | |
489 | 489 | // Abort if the country is not taxable. |
490 | - if ( ! wpinv_is_country_taxable( $this->country ) ) { |
|
490 | + if (!wpinv_is_country_taxable($this->country)) { |
|
491 | 491 | return; |
492 | 492 | } |
493 | 493 | |
494 | - $processor = new GetPaid_Payment_Form_Submission_Taxes( $this ); |
|
494 | + $processor = new GetPaid_Payment_Form_Submission_Taxes($this); |
|
495 | 495 | |
496 | - foreach ( $processor->taxes as $tax ) { |
|
497 | - $this->add_tax( $tax ); |
|
496 | + foreach ($processor->taxes as $tax) { |
|
497 | + $this->add_tax($tax); |
|
498 | 498 | } |
499 | 499 | |
500 | - do_action_ref_array( 'getpaid_submissions_process_taxes', array( &$this ) ); |
|
500 | + do_action_ref_array('getpaid_submissions_process_taxes', array(&$this)); |
|
501 | 501 | } |
502 | 502 | |
503 | 503 | /** |
@@ -506,16 +506,16 @@ discard block |
||
506 | 506 | * @param array $tax An array of tax details. name, initial_tax, and recurring_tax are required. |
507 | 507 | * @since 1.0.19 |
508 | 508 | */ |
509 | - public function add_tax( $tax ) { |
|
509 | + public function add_tax($tax) { |
|
510 | 510 | |
511 | - if ( wpinv_round_tax_per_tax_rate() ) { |
|
512 | - $tax['initial_tax'] = wpinv_round_amount( $tax['initial_tax'] ); |
|
513 | - $tax['recurring_tax'] = wpinv_round_amount( $tax['recurring_tax'] ); |
|
511 | + if (wpinv_round_tax_per_tax_rate()) { |
|
512 | + $tax['initial_tax'] = wpinv_round_amount($tax['initial_tax']); |
|
513 | + $tax['recurring_tax'] = wpinv_round_amount($tax['recurring_tax']); |
|
514 | 514 | } |
515 | 515 | |
516 | - $this->taxes[ $tax['name'] ] = $tax; |
|
517 | - $this->totals['taxes']['initial'] += wpinv_sanitize_amount( $tax['initial_tax'] ); |
|
518 | - $this->totals['taxes']['recurring'] += wpinv_sanitize_amount( $tax['recurring_tax'] ); |
|
516 | + $this->taxes[$tax['name']] = $tax; |
|
517 | + $this->totals['taxes']['initial'] += wpinv_sanitize_amount($tax['initial_tax']); |
|
518 | + $this->totals['taxes']['recurring'] += wpinv_sanitize_amount($tax['recurring_tax']); |
|
519 | 519 | |
520 | 520 | } |
521 | 521 | |
@@ -524,12 +524,12 @@ discard block |
||
524 | 524 | * |
525 | 525 | * @since 1.0.19 |
526 | 526 | */ |
527 | - public function remove_tax( $tax_name ) { |
|
527 | + public function remove_tax($tax_name) { |
|
528 | 528 | |
529 | - if ( isset( $this->taxes[ $tax_name ] ) ) { |
|
530 | - $this->totals['taxes']['initial'] -= $this->taxes[ $tax_name ]['initial_tax']; |
|
531 | - $this->totals['taxes']['recurring'] -= $this->taxes[ $tax_name ]['recurring_tax']; |
|
532 | - unset( $this->taxes[ $tax_name ] ); |
|
529 | + if (isset($this->taxes[$tax_name])) { |
|
530 | + $this->totals['taxes']['initial'] -= $this->taxes[$tax_name]['initial_tax']; |
|
531 | + $this->totals['taxes']['recurring'] -= $this->taxes[$tax_name]['recurring_tax']; |
|
532 | + unset($this->taxes[$tax_name]); |
|
533 | 533 | } |
534 | 534 | |
535 | 535 | } |
@@ -543,11 +543,11 @@ discard block |
||
543 | 543 | |
544 | 544 | $use_taxes = wpinv_use_taxes(); |
545 | 545 | |
546 | - if ( $this->has_invoice() && ! $this->invoice->is_taxable() ) { |
|
546 | + if ($this->has_invoice() && !$this->invoice->is_taxable()) { |
|
547 | 547 | $use_taxes = false; |
548 | 548 | } |
549 | 549 | |
550 | - return apply_filters( 'getpaid_submission_use_taxes', $use_taxes, $this ); |
|
550 | + return apply_filters('getpaid_submission_use_taxes', $use_taxes, $this); |
|
551 | 551 | |
552 | 552 | } |
553 | 553 | |
@@ -596,13 +596,13 @@ discard block |
||
596 | 596 | |
597 | 597 | $initial_total = $this->get_subtotal() + $this->get_fee() + $this->get_tax(); |
598 | 598 | $recurring_total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax(); |
599 | - $processor = new GetPaid_Payment_Form_Submission_Discount( $this, $initial_total, $recurring_total ); |
|
599 | + $processor = new GetPaid_Payment_Form_Submission_Discount($this, $initial_total, $recurring_total); |
|
600 | 600 | |
601 | - foreach ( $processor->discounts as $discount ) { |
|
602 | - $this->add_discount( $discount ); |
|
601 | + foreach ($processor->discounts as $discount) { |
|
602 | + $this->add_discount($discount); |
|
603 | 603 | } |
604 | 604 | |
605 | - do_action_ref_array( 'getpaid_submissions_process_discounts', array( &$this ) ); |
|
605 | + do_action_ref_array('getpaid_submissions_process_discounts', array(&$this)); |
|
606 | 606 | } |
607 | 607 | |
608 | 608 | /** |
@@ -611,10 +611,10 @@ discard block |
||
611 | 611 | * @param array $discount An array of discount details. name, initial_discount, and recurring_discount are required. Include discount_code if the discount is from a discount code. |
612 | 612 | * @since 1.0.19 |
613 | 613 | */ |
614 | - public function add_discount( $discount ) { |
|
615 | - $this->discounts[ $discount['name'] ] = $discount; |
|
616 | - $this->totals['discount']['initial'] += wpinv_sanitize_amount( $discount['initial_discount'] ); |
|
617 | - $this->totals['discount']['recurring'] += wpinv_sanitize_amount( $discount['recurring_discount'] ); |
|
614 | + public function add_discount($discount) { |
|
615 | + $this->discounts[$discount['name']] = $discount; |
|
616 | + $this->totals['discount']['initial'] += wpinv_sanitize_amount($discount['initial_discount']); |
|
617 | + $this->totals['discount']['recurring'] += wpinv_sanitize_amount($discount['recurring_discount']); |
|
618 | 618 | } |
619 | 619 | |
620 | 620 | /** |
@@ -622,12 +622,12 @@ discard block |
||
622 | 622 | * |
623 | 623 | * @since 1.0.19 |
624 | 624 | */ |
625 | - public function remove_discount( $name ) { |
|
625 | + public function remove_discount($name) { |
|
626 | 626 | |
627 | - if ( isset( $this->discounts[ $name ] ) ) { |
|
628 | - $this->totals['discount']['initial'] -= $this->discounts[ $name ]['initial_discount']; |
|
629 | - $this->totals['discount']['recurring'] -= $this->discounts[ $name ]['recurring_discount']; |
|
630 | - unset( $this->discounts[ $name ] ); |
|
627 | + if (isset($this->discounts[$name])) { |
|
628 | + $this->totals['discount']['initial'] -= $this->discounts[$name]['initial_discount']; |
|
629 | + $this->totals['discount']['recurring'] -= $this->discounts[$name]['recurring_discount']; |
|
630 | + unset($this->discounts[$name]); |
|
631 | 631 | } |
632 | 632 | |
633 | 633 | } |
@@ -639,7 +639,7 @@ discard block |
||
639 | 639 | * @return bool |
640 | 640 | */ |
641 | 641 | public function has_discount_code() { |
642 | - return ! empty( $this->discounts['discount_code'] ); |
|
642 | + return !empty($this->discounts['discount_code']); |
|
643 | 643 | } |
644 | 644 | |
645 | 645 | /** |
@@ -696,13 +696,13 @@ discard block |
||
696 | 696 | */ |
697 | 697 | public function process_fees() { |
698 | 698 | |
699 | - $fees_processor = new GetPaid_Payment_Form_Submission_Fees( $this ); |
|
699 | + $fees_processor = new GetPaid_Payment_Form_Submission_Fees($this); |
|
700 | 700 | |
701 | - foreach ( $fees_processor->fees as $fee ) { |
|
702 | - $this->add_fee( $fee ); |
|
701 | + foreach ($fees_processor->fees as $fee) { |
|
702 | + $this->add_fee($fee); |
|
703 | 703 | } |
704 | 704 | |
705 | - do_action_ref_array( 'getpaid_submissions_process_fees', array( &$this ) ); |
|
705 | + do_action_ref_array('getpaid_submissions_process_fees', array(&$this)); |
|
706 | 706 | } |
707 | 707 | |
708 | 708 | /** |
@@ -711,11 +711,11 @@ discard block |
||
711 | 711 | * @param array $fee An array of fee details. name, initial_fee, and recurring_fee are required. |
712 | 712 | * @since 1.0.19 |
713 | 713 | */ |
714 | - public function add_fee( $fee ) { |
|
714 | + public function add_fee($fee) { |
|
715 | 715 | |
716 | - $this->fees[ $fee['name'] ] = $fee; |
|
717 | - $this->totals['fees']['initial'] += wpinv_sanitize_amount( $fee['initial_fee'] ); |
|
718 | - $this->totals['fees']['recurring'] += wpinv_sanitize_amount( $fee['recurring_fee'] ); |
|
716 | + $this->fees[$fee['name']] = $fee; |
|
717 | + $this->totals['fees']['initial'] += wpinv_sanitize_amount($fee['initial_fee']); |
|
718 | + $this->totals['fees']['recurring'] += wpinv_sanitize_amount($fee['recurring_fee']); |
|
719 | 719 | |
720 | 720 | } |
721 | 721 | |
@@ -724,12 +724,12 @@ discard block |
||
724 | 724 | * |
725 | 725 | * @since 1.0.19 |
726 | 726 | */ |
727 | - public function remove_fee( $name ) { |
|
727 | + public function remove_fee($name) { |
|
728 | 728 | |
729 | - if ( isset( $this->fees[ $name ] ) ) { |
|
730 | - $this->totals['fees']['initial'] -= $this->fees[ $name ]['initial_fee']; |
|
731 | - $this->totals['fees']['recurring'] -= $this->fees[ $name ]['recurring_fee']; |
|
732 | - unset( $this->fees[ $name ] ); |
|
729 | + if (isset($this->fees[$name])) { |
|
730 | + $this->totals['fees']['initial'] -= $this->fees[$name]['initial_fee']; |
|
731 | + $this->totals['fees']['recurring'] -= $this->fees[$name]['recurring_fee']; |
|
732 | + unset($this->fees[$name]); |
|
733 | 733 | } |
734 | 734 | |
735 | 735 | } |
@@ -768,7 +768,7 @@ discard block |
||
768 | 768 | * @since 1.0.19 |
769 | 769 | */ |
770 | 770 | public function has_fees() { |
771 | - return count( $this->fees ) !== 0; |
|
771 | + return count($this->fees) !== 0; |
|
772 | 772 | } |
773 | 773 | |
774 | 774 | /* |
@@ -786,7 +786,7 @@ discard block |
||
786 | 786 | * @since 1.0.19 |
787 | 787 | */ |
788 | 788 | public function is_initial_fetch() { |
789 | - return empty( $this->data['initial_state'] ); |
|
789 | + return empty($this->data['initial_state']); |
|
790 | 790 | } |
791 | 791 | |
792 | 792 | /** |
@@ -796,7 +796,7 @@ discard block |
||
796 | 796 | */ |
797 | 797 | public function get_total() { |
798 | 798 | $total = $this->get_subtotal() + $this->get_fee() + $this->get_tax() - $this->get_discount(); |
799 | - return max( $total, 0 ); |
|
799 | + return max($total, 0); |
|
800 | 800 | } |
801 | 801 | |
802 | 802 | /** |
@@ -806,7 +806,7 @@ discard block |
||
806 | 806 | */ |
807 | 807 | public function get_recurring_total() { |
808 | 808 | $total = $this->get_recurring_subtotal() + $this->get_recurring_fee() + $this->get_recurring_tax() - $this->get_recurring_discount(); |
809 | - return max( $total, 0 ); |
|
809 | + return max($total, 0); |
|
810 | 810 | } |
811 | 811 | |
812 | 812 | /** |
@@ -818,12 +818,12 @@ discard block |
||
818 | 818 | $initial = $this->get_total(); |
819 | 819 | $recurring = $this->get_recurring_total(); |
820 | 820 | |
821 | - if ( $this->has_recurring == 0 ) { |
|
821 | + if ($this->has_recurring == 0) { |
|
822 | 822 | $recurring = 0; |
823 | 823 | } |
824 | 824 | |
825 | 825 | $collect = $initial > 0 || $recurring > 0; |
826 | - return apply_filters( 'getpaid_submission_should_collect_payment_details', $collect, $this ); |
|
826 | + return apply_filters('getpaid_submission_should_collect_payment_details', $collect, $this); |
|
827 | 827 | } |
828 | 828 | |
829 | 829 | /** |
@@ -832,7 +832,7 @@ discard block |
||
832 | 832 | * @since 1.0.19 |
833 | 833 | */ |
834 | 834 | public function get_billing_email() { |
835 | - return apply_filters( 'getpaid_get_submission_billing_email', $this->get_field( 'billing_email' ), $this ); |
|
835 | + return apply_filters('getpaid_get_submission_billing_email', $this->get_field('billing_email'), $this); |
|
836 | 836 | } |
837 | 837 | |
838 | 838 | /** |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | */ |
843 | 843 | public function has_billing_email() { |
844 | 844 | $billing_email = $this->get_billing_email(); |
845 | - return ! empty( $billing_email ) && is_email( $billing_email ); |
|
845 | + return !empty($billing_email) && is_email($billing_email); |
|
846 | 846 | } |
847 | 847 | |
848 | 848 | /** |
@@ -872,8 +872,8 @@ discard block |
||
872 | 872 | * @since 1.0.19 |
873 | 873 | * @return mixed|null |
874 | 874 | */ |
875 | - public function get_field( $field, $sub_array_key = null ) { |
|
876 | - return getpaid_get_array_field( $this->data, $field, $sub_array_key ); |
|
875 | + public function get_field($field, $sub_array_key = null) { |
|
876 | + return getpaid_get_array_field($this->data, $field, $sub_array_key); |
|
877 | 877 | } |
878 | 878 | |
879 | 879 | /** |
@@ -881,8 +881,8 @@ discard block |
||
881 | 881 | * |
882 | 882 | * @since 1.0.19 |
883 | 883 | */ |
884 | - public function is_required_field_set( $field ) { |
|
885 | - return empty( $field['required'] ) || ! empty( $this->data[ $field['id'] ] ); |
|
884 | + public function is_required_field_set($field) { |
|
885 | + return empty($field['required']) || !empty($this->data[$field['id']]); |
|
886 | 886 | } |
887 | 887 | |
888 | 888 | /** |
@@ -890,8 +890,8 @@ discard block |
||
890 | 890 | * |
891 | 891 | * @since 1.0.19 |
892 | 892 | */ |
893 | - public function format_amount( $amount ) { |
|
894 | - return wpinv_price( $amount, $this->get_currency() ); |
|
893 | + public function format_amount($amount) { |
|
894 | + return wpinv_price($amount, $this->get_currency()); |
|
895 | 895 | } |
896 | 896 | |
897 | 897 | } |
@@ -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 | * Payment form submission refresh prices class |
@@ -23,22 +23,22 @@ discard block |
||
23 | 23 | * |
24 | 24 | * @param GetPaid_Payment_Form_Submission $submission |
25 | 25 | */ |
26 | - public function __construct( $submission ) { |
|
26 | + public function __construct($submission) { |
|
27 | 27 | |
28 | 28 | $this->response = array( |
29 | 29 | 'submission_id' => $submission->id, |
30 | 30 | 'has_recurring' => $submission->has_recurring, |
31 | - 'is_free' => ! $submission->should_collect_payment_details(), |
|
31 | + 'is_free' => !$submission->should_collect_payment_details(), |
|
32 | 32 | ); |
33 | 33 | |
34 | - $this->add_totals( $submission ); |
|
35 | - $this->add_texts( $submission ); |
|
36 | - $this->add_items( $submission ); |
|
37 | - $this->add_fees( $submission ); |
|
38 | - $this->add_discounts( $submission ); |
|
39 | - $this->add_taxes( $submission ); |
|
40 | - $this->add_gateways( $submission ); |
|
41 | - $this->add_data( $submission ); |
|
34 | + $this->add_totals($submission); |
|
35 | + $this->add_texts($submission); |
|
36 | + $this->add_items($submission); |
|
37 | + $this->add_fees($submission); |
|
38 | + $this->add_discounts($submission); |
|
39 | + $this->add_taxes($submission); |
|
40 | + $this->add_gateways($submission); |
|
41 | + $this->add_data($submission); |
|
42 | 42 | |
43 | 43 | } |
44 | 44 | |
@@ -47,30 +47,30 @@ discard block |
||
47 | 47 | * |
48 | 48 | * @param GetPaid_Payment_Form_Submission $submission |
49 | 49 | */ |
50 | - public function add_totals( $submission ) { |
|
50 | + public function add_totals($submission) { |
|
51 | 51 | |
52 | 52 | $this->response = array_merge( |
53 | 53 | $this->response, |
54 | 54 | array( |
55 | 55 | |
56 | 56 | 'totals' => array( |
57 | - 'subtotal' => $submission->format_amount( $submission->get_subtotal() ), |
|
58 | - 'discount' => $submission->format_amount( $submission->get_discount() ), |
|
59 | - 'fees' => $submission->format_amount( $submission->get_fee() ), |
|
60 | - 'tax' => $submission->format_amount( $submission->get_tax() ), |
|
61 | - 'total' => $submission->format_amount( $submission->get_total() ), |
|
62 | - 'raw_total' => html_entity_decode( sanitize_text_field( $submission->format_amount( $submission->get_total() ) ), ENT_QUOTES ), |
|
57 | + 'subtotal' => $submission->format_amount($submission->get_subtotal()), |
|
58 | + 'discount' => $submission->format_amount($submission->get_discount()), |
|
59 | + 'fees' => $submission->format_amount($submission->get_fee()), |
|
60 | + 'tax' => $submission->format_amount($submission->get_tax()), |
|
61 | + 'total' => $submission->format_amount($submission->get_total()), |
|
62 | + 'raw_total' => html_entity_decode(sanitize_text_field($submission->format_amount($submission->get_total())), ENT_QUOTES), |
|
63 | 63 | ), |
64 | 64 | |
65 | 65 | 'recurring' => array( |
66 | - 'subtotal' => $submission->format_amount( $submission->get_recurring_subtotal() ), |
|
67 | - 'discount' => $submission->format_amount( $submission->get_recurring_discount() ), |
|
68 | - 'fees' => $submission->format_amount( $submission->get_recurring_fee() ), |
|
69 | - 'tax' => $submission->format_amount( $submission->get_recurring_tax() ), |
|
70 | - 'total' => $submission->format_amount( $submission->get_recurring_total() ), |
|
66 | + 'subtotal' => $submission->format_amount($submission->get_recurring_subtotal()), |
|
67 | + 'discount' => $submission->format_amount($submission->get_recurring_discount()), |
|
68 | + 'fees' => $submission->format_amount($submission->get_recurring_fee()), |
|
69 | + 'tax' => $submission->format_amount($submission->get_recurring_tax()), |
|
70 | + 'total' => $submission->format_amount($submission->get_recurring_total()), |
|
71 | 71 | ), |
72 | 72 | |
73 | - 'initial_amt' => wpinv_round_amount( $submission->get_total(), null, true ), |
|
73 | + 'initial_amt' => wpinv_round_amount($submission->get_total(), null, true), |
|
74 | 74 | 'currency' => $submission->get_currency(), |
75 | 75 | |
76 | 76 | ) |
@@ -83,22 +83,22 @@ discard block |
||
83 | 83 | * |
84 | 84 | * @param GetPaid_Payment_Form_Submission $submission |
85 | 85 | */ |
86 | - public function add_texts( $submission ) { |
|
86 | + public function add_texts($submission) { |
|
87 | 87 | |
88 | - $payable = $submission->format_amount( $submission->get_total() ); |
|
88 | + $payable = $submission->format_amount($submission->get_total()); |
|
89 | 89 | |
90 | - if ( $submission->has_recurring != 0 && ! getpaid_should_group_subscriptions( $submission ) ) { |
|
90 | + if ($submission->has_recurring != 0 && !getpaid_should_group_subscriptions($submission)) { |
|
91 | 91 | |
92 | - $recurring = new WPInv_Item( $submission->has_recurring ); |
|
93 | - $period = getpaid_get_subscription_period_label( $recurring->get_recurring_period( true ), $recurring->get_recurring_interval(), '' ); |
|
92 | + $recurring = new WPInv_Item($submission->has_recurring); |
|
93 | + $period = getpaid_get_subscription_period_label($recurring->get_recurring_period(true), $recurring->get_recurring_interval(), ''); |
|
94 | 94 | |
95 | - if ( $submission->get_total() == $submission->get_recurring_total() ) { |
|
95 | + if ($submission->get_total() == $submission->get_recurring_total()) { |
|
96 | 96 | $payable = "$payable / $period"; |
97 | 97 | } else { |
98 | 98 | $payable = sprintf( |
99 | - __( '%1$s (renews at %2$s / %3$s)', 'invoicing' ), |
|
100 | - $submission->format_amount( $submission->get_total() ), |
|
101 | - $submission->format_amount( $submission->get_recurring_total() ), |
|
99 | + __('%1$s (renews at %2$s / %3$s)', 'invoicing'), |
|
100 | + $submission->format_amount($submission->get_total()), |
|
101 | + $submission->format_amount($submission->get_recurring_total()), |
|
102 | 102 | $period |
103 | 103 | ); |
104 | 104 | } |
@@ -109,14 +109,14 @@ discard block |
||
109 | 109 | '.getpaid-checkout-total-payable' => $payable, |
110 | 110 | ); |
111 | 111 | |
112 | - foreach ( $submission->get_items() as $item ) { |
|
112 | + foreach ($submission->get_items() as $item) { |
|
113 | 113 | $item_id = $item->get_id(); |
114 | - $initial_price = $submission->format_amount( $this->standardize_price( $item->get_id(), $item->get_sub_total(), $submission->get_discount_code(), false ) ); |
|
115 | - $recurring_price = $submission->format_amount( $this->standardize_price( $item->get_id(), $item->get_recurring_sub_total(), $submission->get_discount_code(), true ) ); |
|
116 | - $texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text( $item, $submission->get_currency(), $initial_price, $recurring_price ); |
|
114 | + $initial_price = $submission->format_amount($this->standardize_price($item->get_id(), $item->get_sub_total(), $submission->get_discount_code(), false)); |
|
115 | + $recurring_price = $submission->format_amount($this->standardize_price($item->get_id(), $item->get_recurring_sub_total(), $submission->get_discount_code(), true)); |
|
116 | + $texts[".item-$item_id .getpaid-form-item-price-desc"] = getpaid_item_recurring_price_help_text($item, $submission->get_currency(), $initial_price, $recurring_price); |
|
117 | 117 | } |
118 | 118 | |
119 | - $this->response = array_merge( $this->response, array( 'texts' => $texts ) ); |
|
119 | + $this->response = array_merge($this->response, array('texts' => $texts)); |
|
120 | 120 | |
121 | 121 | } |
122 | 122 | |
@@ -125,19 +125,19 @@ discard block |
||
125 | 125 | * |
126 | 126 | * @param GetPaid_Payment_Form_Submission $submission |
127 | 127 | */ |
128 | - public function add_items( $submission ) { |
|
128 | + public function add_items($submission) { |
|
129 | 129 | |
130 | 130 | // Add items. |
131 | 131 | $items = array(); |
132 | 132 | |
133 | - foreach ( $submission->get_items() as $item ) { |
|
133 | + foreach ($submission->get_items() as $item) { |
|
134 | 134 | $item_id = $item->get_id(); |
135 | - $items["$item_id"] = $submission->format_amount( $item->get_sub_total() ); |
|
135 | + $items["$item_id"] = $submission->format_amount($item->get_sub_total()); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | $this->response = array_merge( |
139 | 139 | $this->response, |
140 | - array( 'items' => $items ) |
|
140 | + array('items' => $items) |
|
141 | 141 | ); |
142 | 142 | |
143 | 143 | } |
@@ -147,17 +147,17 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @param GetPaid_Payment_Form_Submission $submission |
149 | 149 | */ |
150 | - public function add_fees( $submission ) { |
|
150 | + public function add_fees($submission) { |
|
151 | 151 | |
152 | 152 | $fees = array(); |
153 | 153 | |
154 | - foreach ( $submission->get_fees() as $name => $data ) { |
|
155 | - $fees[$name] = $submission->format_amount( $data['initial_fee'] ); |
|
154 | + foreach ($submission->get_fees() as $name => $data) { |
|
155 | + $fees[$name] = $submission->format_amount($data['initial_fee']); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | $this->response = array_merge( |
159 | 159 | $this->response, |
160 | - array( 'fees' => $fees ) |
|
160 | + array('fees' => $fees) |
|
161 | 161 | ); |
162 | 162 | |
163 | 163 | } |
@@ -167,17 +167,17 @@ discard block |
||
167 | 167 | * |
168 | 168 | * @param GetPaid_Payment_Form_Submission $submission |
169 | 169 | */ |
170 | - public function add_discounts( $submission ) { |
|
170 | + public function add_discounts($submission) { |
|
171 | 171 | |
172 | 172 | $discounts = array(); |
173 | 173 | |
174 | - foreach ( $submission->get_discounts() as $name => $data ) { |
|
175 | - $discounts[$name] = $submission->format_amount( $data['initial_discount'] ); |
|
174 | + foreach ($submission->get_discounts() as $name => $data) { |
|
175 | + $discounts[$name] = $submission->format_amount($data['initial_discount']); |
|
176 | 176 | } |
177 | 177 | |
178 | 178 | $this->response = array_merge( |
179 | 179 | $this->response, |
180 | - array( 'discounts' => $discounts ) |
|
180 | + array('discounts' => $discounts) |
|
181 | 181 | ); |
182 | 182 | |
183 | 183 | } |
@@ -187,24 +187,24 @@ discard block |
||
187 | 187 | * |
188 | 188 | * @param GetPaid_Payment_Form_Submission $submission |
189 | 189 | */ |
190 | - public function add_taxes( $submission ) { |
|
190 | + public function add_taxes($submission) { |
|
191 | 191 | |
192 | 192 | $taxes = array(); |
193 | 193 | $markup = ''; |
194 | - foreach ( $submission->get_taxes() as $name => $data ) { |
|
195 | - $name = sanitize_text_field( $name ); |
|
196 | - $amount = $submission->format_amount( $data['initial_tax'] ); |
|
194 | + foreach ($submission->get_taxes() as $name => $data) { |
|
195 | + $name = sanitize_text_field($name); |
|
196 | + $amount = $submission->format_amount($data['initial_tax']); |
|
197 | 197 | $taxes[$name] = $amount; |
198 | 198 | $markup .= "<small class='form-text'>$name : $amount</small>"; |
199 | 199 | } |
200 | 200 | |
201 | - if ( wpinv_display_individual_tax_rates() && ! empty( $taxes ) ) { |
|
201 | + if (wpinv_display_individual_tax_rates() && !empty($taxes)) { |
|
202 | 202 | $this->response['texts']['.getpaid-form-cart-totals-total-tax'] = $markup; |
203 | 203 | } |
204 | 204 | |
205 | 205 | $this->response = array_merge( |
206 | 206 | $this->response, |
207 | - array( 'taxes' => $taxes ) |
|
207 | + array('taxes' => $taxes) |
|
208 | 208 | ); |
209 | 209 | |
210 | 210 | } |
@@ -214,16 +214,16 @@ discard block |
||
214 | 214 | * |
215 | 215 | * @param GetPaid_Payment_Form_Submission $submission |
216 | 216 | */ |
217 | - public function add_gateways( $submission ) { |
|
217 | + public function add_gateways($submission) { |
|
218 | 218 | |
219 | - $gateways = array_keys( wpinv_get_enabled_payment_gateways() ); |
|
219 | + $gateways = array_keys(wpinv_get_enabled_payment_gateways()); |
|
220 | 220 | |
221 | - if ( $this->response['has_recurring'] ) { |
|
221 | + if ($this->response['has_recurring']) { |
|
222 | 222 | |
223 | - foreach ( $gateways as $i => $gateway ) { |
|
223 | + foreach ($gateways as $i => $gateway) { |
|
224 | 224 | |
225 | - if ( ! wpinv_gateway_support_subscription( $gateway ) ) { |
|
226 | - unset( $gateways[ $i ] ); |
|
225 | + if (!wpinv_gateway_support_subscription($gateway)) { |
|
226 | + unset($gateways[$i]); |
|
227 | 227 | } |
228 | 228 | |
229 | 229 | } |
@@ -231,10 +231,10 @@ discard block |
||
231 | 231 | } |
232 | 232 | |
233 | 233 | |
234 | - $gateways = apply_filters( 'getpaid_submission_gateways', $gateways, $submission ); |
|
234 | + $gateways = apply_filters('getpaid_submission_gateways', $gateways, $submission); |
|
235 | 235 | $this->response = array_merge( |
236 | 236 | $this->response, |
237 | - array( 'gateways' => $gateways ) |
|
237 | + array('gateways' => $gateways) |
|
238 | 238 | ); |
239 | 239 | |
240 | 240 | } |
@@ -247,22 +247,22 @@ discard block |
||
247 | 247 | * @param string $discount_code |
248 | 248 | * @param bool $recurring |
249 | 249 | */ |
250 | - public function standardize_price( $item_id, $item_total, $discount_code, $recurring = false ) { |
|
250 | + public function standardize_price($item_id, $item_total, $discount_code, $recurring = false) { |
|
251 | 251 | |
252 | 252 | $standardadized_price = $item_total; |
253 | 253 | |
254 | 254 | // Do we have a $discount_code? |
255 | - if ( ! empty( $discount_code ) ) { |
|
255 | + if (!empty($discount_code)) { |
|
256 | 256 | |
257 | - $discount = new WPInv_Discount( $discount_code ); |
|
257 | + $discount = new WPInv_Discount($discount_code); |
|
258 | 258 | |
259 | - if ( $discount->exists() && $discount->is_valid_for_items( $item_id ) && ( ! $recurring || $discount->is_recurring() ) ) { |
|
260 | - $standardadized_price = $item_total - $discount->get_discounted_amount( $item_total ); |
|
259 | + if ($discount->exists() && $discount->is_valid_for_items($item_id) && (!$recurring || $discount->is_recurring())) { |
|
260 | + $standardadized_price = $item_total - $discount->get_discounted_amount($item_total); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | } |
264 | 264 | |
265 | - return max( 0, $standardadized_price ); |
|
265 | + return max(0, $standardadized_price); |
|
266 | 266 | |
267 | 267 | } |
268 | 268 | |
@@ -271,7 +271,7 @@ discard block |
||
271 | 271 | * |
272 | 272 | * @param GetPaid_Payment_Form_Submission $submission |
273 | 273 | */ |
274 | - public function add_data( $submission ) { |
|
274 | + public function add_data($submission) { |
|
275 | 275 | |
276 | 276 | $this->response = array_merge( |
277 | 277 | $this->response, |