@@ -7,50 +7,50 @@ |
||
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' ) ? 'px-1' : ''; |
|
12 | +$class = !is_singular('page') ? 'px-1' : ''; |
|
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 | - <?php do_action( 'getpaid_before_invoice_meta_table', $invoice ); ?> |
|
18 | + <?php do_action('getpaid_before_invoice_meta_table', $invoice); ?> |
|
19 | 19 | <table class="table table-bordered"> |
20 | 20 | <tbody> |
21 | 21 | |
22 | - <?php do_action( "getpaid_before_invoice_meta_rows", $invoice ); ?> |
|
23 | - <?php foreach ( $meta as $key => $data ) : ?> |
|
22 | + <?php do_action("getpaid_before_invoice_meta_rows", $invoice); ?> |
|
23 | + <?php foreach ($meta as $key => $data) : ?> |
|
24 | 24 | |
25 | - <?php if ( ! empty( $data['value'] ) ) : ?> |
|
25 | + <?php if (!empty($data['value'])) : ?> |
|
26 | 26 | |
27 | - <?php do_action( "getpaid_before_invoice_meta_$key", $invoice, $data ); ?> |
|
27 | + <?php do_action("getpaid_before_invoice_meta_$key", $invoice, $data); ?> |
|
28 | 28 | |
29 | - <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>"> |
|
29 | + <tr class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>"> |
|
30 | 30 | |
31 | 31 | <th class="<?php echo $class; ?> font-weight-bold"> |
32 | - <?php echo sanitize_text_field( $data['label'] ); ?> |
|
32 | + <?php echo sanitize_text_field($data['label']); ?> |
|
33 | 33 | </th> |
34 | 34 | |
35 | 35 | <td class="<?php echo $class; ?> <?php echo $key == 'invoice_total' ? 'font-weight-bold' : 'font-weight-normal'; ?> text-break w-75"> |
36 | - <span class="getpaid-invoice-meta-<?php echo sanitize_html_class( $key ); ?>-value"><?php echo wp_kses_post( $data['value'] ); ?></span> |
|
36 | + <span class="getpaid-invoice-meta-<?php echo sanitize_html_class($key); ?>-value"><?php echo wp_kses_post($data['value']); ?></span> |
|
37 | 37 | </td> |
38 | 38 | |
39 | 39 | </tr> |
40 | 40 | |
41 | - <?php do_action( "getpaid_after_invoice_meta_$key", $invoice, $data ); ?> |
|
41 | + <?php do_action("getpaid_after_invoice_meta_$key", $invoice, $data); ?> |
|
42 | 42 | |
43 | 43 | <?php endif; ?> |
44 | 44 | |
45 | 45 | <?php endforeach; ?> |
46 | - <?php do_action( "getpaid_after_invoice_meta_rows", $invoice ); ?> |
|
46 | + <?php do_action("getpaid_after_invoice_meta_rows", $invoice); ?> |
|
47 | 47 | |
48 | 48 | </tbody> |
49 | 49 | </table> |
50 | - <?php do_action( 'getpaid_after_invoice_meta_table', $invoice ); ?> |
|
50 | + <?php do_action('getpaid_after_invoice_meta_table', $invoice); ?> |
|
51 | 51 | |
52 | 52 | |
53 | 53 | </div> |
54 | - <?php do_action( 'getpaid_after_invoice_meta', $invoice ); ?> |
|
54 | + <?php do_action('getpaid_after_invoice_meta', $invoice); ?> |
|
55 | 55 | |
56 | 56 | <?php |
@@ -7,7 +7,7 @@ |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | ?> |
13 | 13 | |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | <div class="modal-dialog modal-dialog-centered modal-lg" role="checkout" style="max-width: 650px;"> |
17 | 17 | <div class="modal-content"> |
18 | 18 | <div class="modal-body"> |
19 | - <button type="button" class="close p-2 getpaid-payment-modal-close d-sm-none" data-dismiss="modal" aria-label="<?php esc_attr__( 'Close', 'invoicing' ); ?>"> |
|
19 | + <button type="button" class="close p-2 getpaid-payment-modal-close d-sm-none" data-dismiss="modal" aria-label="<?php esc_attr__('Close', 'invoicing'); ?>"> |
|
20 | 20 | <i class="fa fa-times" aria-hidden="true"></i> |
21 | 21 | </button> |
22 | 22 | <div class="modal-body-wrapper"></div> |
@@ -7,17 +7,17 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | 12 | // Prepare the company name. |
13 | -$company_name = wpinv_get_option( 'vat_company_name' ); |
|
13 | +$company_name = wpinv_get_option('vat_company_name'); |
|
14 | 14 | |
15 | -if ( empty( $company_name ) ) { |
|
15 | +if (empty($company_name)) { |
|
16 | 16 | $company_name = wpinv_get_business_name(); |
17 | 17 | } |
18 | 18 | |
19 | 19 | // Prepare the VAT number. |
20 | -$vat_number = wpinv_get_option( 'vat_number' ); |
|
20 | +$vat_number = wpinv_get_option('vat_number'); |
|
21 | 21 | |
22 | 22 | ?> |
23 | 23 | <div class="getpaid-company-address form-group"> |
@@ -25,36 +25,36 @@ discard block |
||
25 | 25 | <div class="row"> |
26 | 26 | |
27 | 27 | <div class="invoice-company-address-label col-2"> |
28 | - <strong><?php _e( 'From:', 'invoicing' ) ?></strong> |
|
28 | + <strong><?php _e('From:', 'invoicing') ?></strong> |
|
29 | 29 | </div> |
30 | 30 | |
31 | 31 | <div class="invoice-company-address-value col-10"> |
32 | 32 | |
33 | - <?php do_action( 'getpaid_company_address_top' ); ?> |
|
33 | + <?php do_action('getpaid_company_address_top'); ?> |
|
34 | 34 | |
35 | 35 | <div class="name"> |
36 | - <a target="_blank" class="text-dark" href="<?php echo esc_url( wpinv_get_business_website() ); ?>"> |
|
37 | - <?php echo esc_html( $company_name ); ?> |
|
36 | + <a target="_blank" class="text-dark" href="<?php echo esc_url(wpinv_get_business_website()); ?>"> |
|
37 | + <?php echo esc_html($company_name); ?> |
|
38 | 38 | </a> |
39 | 39 | </div> |
40 | 40 | |
41 | - <?php if ( $address = wpinv_get_business_address() ) { ?> |
|
42 | - <?php echo $address;?> |
|
41 | + <?php if ($address = wpinv_get_business_address()) { ?> |
|
42 | + <?php echo $address; ?> |
|
43 | 43 | <?php } ?> |
44 | 44 | |
45 | - <?php if ( $email_from = wpinv_mail_get_from_address() ) { ?> |
|
45 | + <?php if ($email_from = wpinv_mail_get_from_address()) { ?> |
|
46 | 46 | <div class="email_from"> |
47 | - <?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), $email_from );?> |
|
47 | + <?php echo wp_sprintf(__('Email: %s', 'invoicing'), $email_from); ?> |
|
48 | 48 | </div> |
49 | 49 | <?php } ?> |
50 | 50 | |
51 | - <?php if ( ! empty( $vat_number ) ) { ?> |
|
51 | + <?php if (!empty($vat_number)) { ?> |
|
52 | 52 | <div class="email_from"> |
53 | - <?php echo wp_sprintf( __( 'VAT Number: %s', 'invoicing' ), sanitize_text_field( $vat_number ) );?> |
|
53 | + <?php echo wp_sprintf(__('VAT Number: %s', 'invoicing'), sanitize_text_field($vat_number)); ?> |
|
54 | 54 | </div> |
55 | 55 | <?php } ?> |
56 | 56 | |
57 | - <?php do_action( 'getpaid_company_address_bottom' ); ?> |
|
57 | + <?php do_action('getpaid_company_address_bottom'); ?> |
|
58 | 58 | |
59 | 59 | </div> |
60 | 60 |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -$invoice = new WPInv_Invoice( $invoice ); |
|
13 | -$address_row = wpinv_get_invoice_address_markup( $invoice->get_user_info() ); |
|
12 | +$invoice = new WPInv_Invoice($invoice); |
|
13 | +$address_row = wpinv_get_invoice_address_markup($invoice->get_user_info()); |
|
14 | 14 | $phone = $invoice->get_phone(); |
15 | 15 | $email = $invoice->get_email(); |
16 | 16 | $vat_number = $invoice->get_vat_number(); |
@@ -21,41 +21,41 @@ discard block |
||
21 | 21 | |
22 | 22 | |
23 | 23 | <div class="invoice-billing-address-label col-2"> |
24 | - <strong><?php _e( 'To:', 'invoicing' ) ?></strong> |
|
24 | + <strong><?php _e('To:', 'invoicing') ?></strong> |
|
25 | 25 | </div> |
26 | 26 | |
27 | 27 | |
28 | 28 | <div class="invoice-billing-address-value col-10"> |
29 | 29 | |
30 | - <?php do_action( 'getpaid_billing_address_top' ); ?> |
|
30 | + <?php do_action('getpaid_billing_address_top'); ?> |
|
31 | 31 | |
32 | - <?php if ( ! empty( $address_row ) ) : ?> |
|
32 | + <?php if (!empty($address_row)) : ?> |
|
33 | 33 | <div class="billing-address"> |
34 | 34 | <?php echo $address_row; ?> |
35 | 35 | </div> |
36 | 36 | <?php endif; ?> |
37 | 37 | |
38 | 38 | |
39 | - <?php if ( ! empty( $phone ) ) : ?> |
|
39 | + <?php if (!empty($phone)) : ?> |
|
40 | 40 | <div class="billing-phone"> |
41 | - <?php echo wp_sprintf( __( 'Phone: %s', 'invoicing' ), esc_html( $phone ) ); ?> |
|
41 | + <?php echo wp_sprintf(__('Phone: %s', 'invoicing'), esc_html($phone)); ?> |
|
42 | 42 | </div> |
43 | 43 | <?php endif; ?> |
44 | 44 | |
45 | 45 | |
46 | - <?php if ( ! empty( $email ) ) : ?> |
|
46 | + <?php if (!empty($email)) : ?> |
|
47 | 47 | <div class="billing-email"> |
48 | - <?php echo wp_sprintf( __( 'Email: %s', 'invoicing' ), sanitize_email( $email ) ); ?> |
|
48 | + <?php echo wp_sprintf(__('Email: %s', 'invoicing'), sanitize_email($email)); ?> |
|
49 | 49 | </div> |
50 | 50 | <?php endif; ?> |
51 | 51 | |
52 | - <?php if ( ! empty( $vat_number ) ) : ?> |
|
52 | + <?php if (!empty($vat_number)) : ?> |
|
53 | 53 | <div class="vat-number"> |
54 | - <?php echo wp_sprintf( __( 'Vat Number: %s', 'invoicing' ), sanitize_text_field( $vat_number ) ); ?> |
|
54 | + <?php echo wp_sprintf(__('Vat Number: %s', 'invoicing'), sanitize_text_field($vat_number)); ?> |
|
55 | 55 | </div> |
56 | 56 | <?php endif; ?> |
57 | 57 | |
58 | - <?php do_action( 'getpaid_billing_address_bottom' ); ?> |
|
58 | + <?php do_action('getpaid_billing_address_bottom'); ?> |
|
59 | 59 | |
60 | 60 | </div> |
61 | 61 |
@@ -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-sm-left pl-sm-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="form-row"> |
29 | 29 | |
30 | 30 | <div class="col-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-4 getpaid-invoice-line-totals-value pl-0"> |
@@ -36,15 +36,15 @@ discard block |
||
36 | 36 | <?php |
37 | 37 | |
38 | 38 | // Total tax. |
39 | - if ( 'tax' == $key ) { |
|
40 | - echo wpinv_price( $invoice->get_total_tax(), $invoice->get_currency() ); |
|
39 | + if ('tax' == $key) { |
|
40 | + echo wpinv_price($invoice->get_total_tax(), $invoice->get_currency()); |
|
41 | 41 | |
42 | - if ( wpinv_use_taxes() && ! $invoice->get_disable_taxes() ) { |
|
42 | + if (wpinv_use_taxes() && !$invoice->get_disable_taxes()) { |
|
43 | 43 | |
44 | 44 | $taxes = $invoice->get_total_tax(); |
45 | - if ( empty( $taxes ) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction( $invoice->get_country() ) ) { |
|
45 | + if (empty($taxes) && GetPaid_Payment_Form_Submission_Taxes::is_eu_transaction($invoice->get_country())) { |
|
46 | 46 | echo ' <em class="text-muted small">'; |
47 | - _e( '(Reverse charged)', 'invoicing' ); |
|
47 | + _e('(Reverse charged)', 'invoicing'); |
|
48 | 48 | echo '</em>'; |
49 | 49 | } |
50 | 50 | |
@@ -53,27 +53,27 @@ discard block |
||
53 | 53 | } |
54 | 54 | |
55 | 55 | // Total Fee. |
56 | - if ( 'fee' == $key ) { |
|
57 | - echo wpinv_price( $invoice->get_total_fees(), $invoice->get_currency() ); |
|
56 | + if ('fee' == $key) { |
|
57 | + echo wpinv_price($invoice->get_total_fees(), $invoice->get_currency()); |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | // Total discount. |
61 | - if ( 'discount' == $key ) { |
|
62 | - echo wpinv_price( $invoice->get_total_discount(), $invoice->get_currency() ); |
|
61 | + if ('discount' == $key) { |
|
62 | + echo wpinv_price($invoice->get_total_discount(), $invoice->get_currency()); |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | // Sub total. |
66 | - if ( 'subtotal' == $key ) { |
|
67 | - echo wpinv_price( $invoice->get_subtotal(), $invoice->get_currency() ); |
|
66 | + if ('subtotal' == $key) { |
|
67 | + echo wpinv_price($invoice->get_subtotal(), $invoice->get_currency()); |
|
68 | 68 | } |
69 | 69 | |
70 | 70 | // Total. |
71 | - if ( 'total' == $key ) { |
|
72 | - echo wpinv_price( $invoice->get_total(), $invoice->get_currency() ); |
|
71 | + if ('total' == $key) { |
|
72 | + echo wpinv_price($invoice->get_total(), $invoice->get_currency()); |
|
73 | 73 | } |
74 | 74 | |
75 | 75 | // Fires when printing a cart total. |
76 | - do_action( "getpaid_invoice_cart_totals_$key", $invoice ); |
|
76 | + do_action("getpaid_invoice_cart_totals_$key", $invoice); |
|
77 | 77 | |
78 | 78 | ?> |
79 | 79 | |
@@ -87,4 +87,4 @@ discard block |
||
87 | 87 | </div> |
88 | 88 | </div> <!-- end .getpaid-invoice-line-totals --> |
89 | 89 | |
90 | -<?php do_action( 'getpaid_after_invoice_line_totals', $invoice, $totals ); ?> |
|
90 | +<?php do_action('getpaid_after_invoice_line_totals', $invoice, $totals); ?> |
@@ -8,197 +8,197 @@ discard block |
||
8 | 8 | * @version 1.0.19 |
9 | 9 | */ |
10 | 10 | |
11 | -defined( 'ABSPATH' ) || exit; |
|
11 | +defined('ABSPATH') || exit; |
|
12 | 12 | |
13 | -$pages = wpinv_get_pages( true ); |
|
13 | +$pages = wpinv_get_pages(true); |
|
14 | 14 | |
15 | 15 | $currencies = wpinv_get_currencies(); |
16 | 16 | |
17 | 17 | $currency_code_options = array(); |
18 | -foreach ( $currencies as $code => $name ) { |
|
19 | - $currency_code_options[ $code ] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol( $code ) . ')'; |
|
18 | +foreach ($currencies as $code => $name) { |
|
19 | + $currency_code_options[$code] = $code . ' - ' . $name . ' (' . wpinv_currency_symbol($code) . ')'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | $due_payment_options = array(); |
23 | -$due_payment_options[0] = __( 'Now', 'invoicing' ); |
|
24 | -for ( $i = 1; $i <= 30; $i++ ) { |
|
23 | +$due_payment_options[0] = __('Now', 'invoicing'); |
|
24 | +for ($i = 1; $i <= 30; $i++) { |
|
25 | 25 | $due_payment_options[$i] = $i; |
26 | 26 | } |
27 | 27 | |
28 | 28 | $invoice_number_padd_options = array(); |
29 | -for ( $i = 0; $i <= 20; $i++ ) { |
|
29 | +for ($i = 0; $i <= 20; $i++) { |
|
30 | 30 | $invoice_number_padd_options[$i] = $i; |
31 | 31 | } |
32 | 32 | |
33 | 33 | $currency_symbol = wpinv_currency_symbol(); |
34 | 34 | |
35 | 35 | $last_number = $reset_number = ''; |
36 | -if ( $last_invoice_number = get_option( 'wpinv_last_invoice_number' ) ) { |
|
37 | - $last_invoice_number = preg_replace( '/[^0-9]/', '', $last_invoice_number ); |
|
36 | +if ($last_invoice_number = get_option('wpinv_last_invoice_number')) { |
|
37 | + $last_invoice_number = preg_replace('/[^0-9]/', '', $last_invoice_number); |
|
38 | 38 | |
39 | - if ( !empty( $last_invoice_number ) ) { |
|
40 | - $last_number = ' ' . wp_sprintf( __( "( Last Invoice's sequential number: <b>%s</b> )", 'invoicing' ), $last_invoice_number ); |
|
39 | + if (!empty($last_invoice_number)) { |
|
40 | + $last_number = ' ' . wp_sprintf(__("( Last Invoice's sequential number: <b>%s</b> )", 'invoicing'), $last_invoice_number); |
|
41 | 41 | } |
42 | 42 | |
43 | 43 | $nonce = wp_create_nonce('reset_invoice_count'); |
44 | - $reset_number = '<a href="'.add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)).'" class="btn button">'.__('Force Reset Sequence', 'invoicing' ). '</a>'; |
|
44 | + $reset_number = '<a href="' . add_query_arg(array('reset_invoice_count' => 1, '_nonce' => $nonce)) . '" class="btn button">' . __('Force Reset Sequence', 'invoicing') . '</a>'; |
|
45 | 45 | } |
46 | 46 | |
47 | 47 | $alert_wrapper_start = '<p style="color: #F00">'; |
48 | 48 | $alert_wrapper_close = '</p>'; |
49 | 49 | |
50 | 50 | return array( |
51 | - 'general' => apply_filters( 'wpinv_settings_general', |
|
51 | + 'general' => apply_filters('wpinv_settings_general', |
|
52 | 52 | array( |
53 | 53 | 'main' => array( |
54 | 54 | 'location_settings' => array( |
55 | 55 | 'id' => 'location_settings', |
56 | - 'name' => '<h3>' . __( 'Default Location', 'invoicing' ) . '</h3>', |
|
56 | + 'name' => '<h3>' . __('Default Location', 'invoicing') . '</h3>', |
|
57 | 57 | 'desc' => '', |
58 | 58 | 'type' => 'header', |
59 | 59 | ), |
60 | 60 | 'default_country' => array( |
61 | 61 | 'id' => 'default_country', |
62 | - 'name' => __( 'Default Country', 'invoicing' ), |
|
63 | - 'desc' => __( 'Where does your store operate from?', 'invoicing' ), |
|
62 | + 'name' => __('Default Country', 'invoicing'), |
|
63 | + 'desc' => __('Where does your store operate from?', 'invoicing'), |
|
64 | 64 | 'type' => 'select', |
65 | 65 | 'options' => wpinv_get_country_list(), |
66 | 66 | 'std' => 'GB', |
67 | 67 | 'class' => 'wpi_select2', |
68 | - 'placeholder' => __( 'Select a country', 'invoicing' ), |
|
68 | + 'placeholder' => __('Select a country', 'invoicing'), |
|
69 | 69 | ), |
70 | 70 | 'default_state' => array( |
71 | 71 | 'id' => 'default_state', |
72 | - 'name' => __( 'Default State / Province', 'invoicing' ), |
|
73 | - 'desc' => __( 'What state / province does your store operate from?', 'invoicing' ), |
|
72 | + 'name' => __('Default State / Province', 'invoicing'), |
|
73 | + 'desc' => __('What state / province does your store operate from?', 'invoicing'), |
|
74 | 74 | 'type' => 'country_states', |
75 | 75 | 'class' => 'wpi_select2', |
76 | - 'placeholder' => __( 'Select a state', 'invoicing' ), |
|
76 | + 'placeholder' => __('Select a state', 'invoicing'), |
|
77 | 77 | ), |
78 | 78 | 'store_name' => array( |
79 | 79 | 'id' => 'store_name', |
80 | - 'name' => __( 'Store Name', 'invoicing' ), |
|
81 | - 'desc' => __( 'Store name to print on invoices.', 'invoicing' ), |
|
80 | + 'name' => __('Store Name', 'invoicing'), |
|
81 | + 'desc' => __('Store name to print on invoices.', 'invoicing'), |
|
82 | 82 | 'std' => get_option('blogname'), |
83 | 83 | 'type' => 'text', |
84 | 84 | ), |
85 | 85 | 'logo' => array( |
86 | 86 | 'id' => 'logo', |
87 | - 'name' => __( 'Logo URL', 'invoicing' ), |
|
88 | - 'desc' => __( 'Store logo to print on invoices.', 'invoicing' ), |
|
87 | + 'name' => __('Logo URL', 'invoicing'), |
|
88 | + 'desc' => __('Store logo to print on invoices.', 'invoicing'), |
|
89 | 89 | 'type' => 'text', |
90 | 90 | ), |
91 | 91 | 'store_address' => array( |
92 | 92 | 'id' => 'store_address', |
93 | - 'name' => __( 'Store Address', 'invoicing' ), |
|
94 | - 'desc' => __( 'Enter the store address to display on invoice', 'invoicing' ), |
|
93 | + 'name' => __('Store Address', 'invoicing'), |
|
94 | + 'desc' => __('Enter the store address to display on invoice', 'invoicing'), |
|
95 | 95 | 'type' => 'textarea', |
96 | 96 | ), |
97 | 97 | 'page_settings' => array( |
98 | 98 | 'id' => 'page_settings', |
99 | - 'name' => '<h3>' . __( 'Page Settings', 'invoicing' ) . '</h3>', |
|
99 | + 'name' => '<h3>' . __('Page Settings', 'invoicing') . '</h3>', |
|
100 | 100 | 'desc' => '', |
101 | 101 | 'type' => 'header', |
102 | 102 | ), |
103 | 103 | 'checkout_page' => array( |
104 | 104 | 'id' => 'checkout_page', |
105 | - 'name' => __( 'Checkout Page', 'invoicing' ), |
|
106 | - 'desc' => __( 'This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing' ), |
|
105 | + 'name' => __('Checkout Page', 'invoicing'), |
|
106 | + 'desc' => __('This is the checkout page where buyers will complete their payments. The <b>[wpinv_checkout]</b> short code must be on this page.', 'invoicing'), |
|
107 | 107 | 'type' => 'select', |
108 | 108 | 'options' => $pages, |
109 | 109 | 'class' => 'wpi_select2', |
110 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
110 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
111 | 111 | 'help-tip' => true, |
112 | 112 | ), |
113 | 113 | 'success_page' => array( |
114 | 114 | 'id' => 'success_page', |
115 | - 'name' => __( 'Success Page', 'invoicing' ), |
|
116 | - 'desc' => __( 'This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing' ), |
|
115 | + 'name' => __('Success Page', 'invoicing'), |
|
116 | + 'desc' => __('This is the page buyers are sent to after completing their payments. The <b>[wpinv_receipt]</b> short code should be on this page.', 'invoicing'), |
|
117 | 117 | 'type' => 'select', |
118 | 118 | 'options' => $pages, |
119 | 119 | 'class' => 'wpi_select2', |
120 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
120 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
121 | 121 | 'help-tip' => true, |
122 | 122 | ), |
123 | 123 | 'failure_page' => array( |
124 | 124 | 'id' => 'failure_page', |
125 | - 'name' => __( 'Failed Transaction Page', 'invoicing' ), |
|
126 | - 'desc' => __( 'This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing' ), |
|
125 | + 'name' => __('Failed Transaction Page', 'invoicing'), |
|
126 | + 'desc' => __('This is the page buyers are sent to if their transaction is cancelled or fails.', 'invoicing'), |
|
127 | 127 | 'type' => 'select', |
128 | 128 | 'options' => $pages, |
129 | 129 | 'class' => 'wpi_select2', |
130 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
130 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
131 | 131 | 'help-tip' => true, |
132 | 132 | ), |
133 | 133 | 'invoice_history_page' => array( |
134 | 134 | 'id' => 'invoice_history_page', |
135 | - 'name' => __( 'Invoice History Page', 'invoicing' ), |
|
136 | - 'desc' => __( 'This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing' ), |
|
135 | + 'name' => __('Invoice History Page', 'invoicing'), |
|
136 | + 'desc' => __('This page shows an invoice history for the current user. The <b>[wpinv_history]</b> short code should be on this page.', 'invoicing'), |
|
137 | 137 | 'type' => 'select', |
138 | 138 | 'options' => $pages, |
139 | 139 | 'class' => 'wpi_select2', |
140 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
140 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
141 | 141 | 'help-tip' => true, |
142 | 142 | ), |
143 | 143 | 'invoice_subscription_page' => array( |
144 | 144 | 'id' => 'invoice_subscription_page', |
145 | - 'name' => __( 'Invoice Subscriptions Page', 'invoicing' ), |
|
146 | - 'desc' => __( 'This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing' ), |
|
145 | + 'name' => __('Invoice Subscriptions Page', 'invoicing'), |
|
146 | + 'desc' => __('This page shows subscriptions history for the current user. The <b>[wpinv_subscriptions]</b> short code should be on this page.', 'invoicing'), |
|
147 | 147 | 'type' => 'select', |
148 | 148 | 'options' => $pages, |
149 | 149 | 'class' => 'wpi_select2', |
150 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
150 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
151 | 151 | 'help-tip' => true, |
152 | 152 | ), |
153 | 153 | ), |
154 | 154 | 'currency_section' => array( |
155 | 155 | 'currency_settings' => array( |
156 | 156 | 'id' => 'currency_settings', |
157 | - 'name' => '<h3>' . __( 'Currency Settings', 'invoicing' ) . '</h3>', |
|
157 | + 'name' => '<h3>' . __('Currency Settings', 'invoicing') . '</h3>', |
|
158 | 158 | 'desc' => '', |
159 | 159 | 'type' => 'header', |
160 | 160 | ), |
161 | 161 | 'currency' => array( |
162 | 162 | 'id' => 'currency', |
163 | - 'name' => __( 'Currency', 'invoicing' ), |
|
164 | - 'desc' => __( 'Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing' ), |
|
163 | + 'name' => __('Currency', 'invoicing'), |
|
164 | + 'desc' => __('Choose your currency. Note that some payment gateways have currency restrictions.', 'invoicing'), |
|
165 | 165 | 'type' => 'select', |
166 | 166 | 'class' => 'wpi_select2', |
167 | 167 | 'options' => $currency_code_options, |
168 | 168 | ), |
169 | 169 | 'currency_position' => array( |
170 | 170 | 'id' => 'currency_position', |
171 | - 'name' => __( 'Currency Position', 'invoicing' ), |
|
172 | - 'desc' => __( 'Choose the location of the currency sign.', 'invoicing' ), |
|
171 | + 'name' => __('Currency Position', 'invoicing'), |
|
172 | + 'desc' => __('Choose the location of the currency sign.', 'invoicing'), |
|
173 | 173 | 'type' => 'select', |
174 | 174 | 'class' => 'wpi_select2', |
175 | 175 | 'options' => array( |
176 | - 'left' => __( 'Left', 'invoicing' ) . ' (' . $currency_symbol . wpinv_format_amount( '99.99' ) . ')', |
|
177 | - 'right' => __( 'Right', 'invoicing' ) . ' ('. wpinv_format_amount( '99.99' ) . $currency_symbol . ')', |
|
178 | - 'left_space' => __( 'Left with space', 'invoicing' ) . ' (' . $currency_symbol . ' ' . wpinv_format_amount( '99.99' ) . ')', |
|
179 | - 'right_space' => __( 'Right with space', 'invoicing' ) . ' (' . wpinv_format_amount( '99.99' ) . ' ' . $currency_symbol . ')' |
|
176 | + 'left' => __('Left', 'invoicing') . ' (' . $currency_symbol . wpinv_format_amount('99.99') . ')', |
|
177 | + 'right' => __('Right', 'invoicing') . ' (' . wpinv_format_amount('99.99') . $currency_symbol . ')', |
|
178 | + 'left_space' => __('Left with space', 'invoicing') . ' (' . $currency_symbol . ' ' . wpinv_format_amount('99.99') . ')', |
|
179 | + 'right_space' => __('Right with space', 'invoicing') . ' (' . wpinv_format_amount('99.99') . ' ' . $currency_symbol . ')' |
|
180 | 180 | ) |
181 | 181 | ), |
182 | 182 | 'thousands_separator' => array( |
183 | 183 | 'id' => 'thousands_separator', |
184 | - 'name' => __( 'Thousands Separator', 'invoicing' ), |
|
185 | - 'desc' => __( 'The symbol (usually , or .) to separate thousands', 'invoicing' ), |
|
184 | + 'name' => __('Thousands Separator', 'invoicing'), |
|
185 | + 'desc' => __('The symbol (usually , or .) to separate thousands', 'invoicing'), |
|
186 | 186 | 'type' => 'text', |
187 | 187 | 'size' => 'small', |
188 | 188 | 'std' => ',', |
189 | 189 | ), |
190 | 190 | 'decimal_separator' => array( |
191 | 191 | 'id' => 'decimal_separator', |
192 | - 'name' => __( 'Decimal Separator', 'invoicing' ), |
|
193 | - 'desc' => __( 'The symbol (usually , or .) to separate decimal points', 'invoicing' ), |
|
192 | + 'name' => __('Decimal Separator', 'invoicing'), |
|
193 | + 'desc' => __('The symbol (usually , or .) to separate decimal points', 'invoicing'), |
|
194 | 194 | 'type' => 'text', |
195 | 195 | 'size' => 'small', |
196 | 196 | 'std' => '.', |
197 | 197 | ), |
198 | 198 | 'decimals' => array( |
199 | 199 | 'id' => 'decimals', |
200 | - 'name' => __( 'Number of Decimals', 'invoicing' ), |
|
201 | - 'desc' => __( 'This sets the number of decimal points shown in displayed prices.', 'invoicing' ), |
|
200 | + 'name' => __('Number of Decimals', 'invoicing'), |
|
201 | + 'desc' => __('This sets the number of decimal points shown in displayed prices.', 'invoicing'), |
|
202 | 202 | 'type' => 'number', |
203 | 203 | 'size' => 'small', |
204 | 204 | 'std' => '2', |
@@ -210,21 +210,21 @@ discard block |
||
210 | 210 | 'labels' => array( |
211 | 211 | 'labels' => array( |
212 | 212 | 'id' => 'labels_settings', |
213 | - 'name' => '<h3>' . __( 'Invoice Labels', 'invoicing' ) . '</h3>', |
|
213 | + 'name' => '<h3>' . __('Invoice Labels', 'invoicing') . '</h3>', |
|
214 | 214 | 'desc' => '', |
215 | 215 | 'type' => 'header', |
216 | 216 | ), |
217 | 217 | 'vat_invoice_notice_label' => array( |
218 | 218 | 'id' => 'vat_invoice_notice_label', |
219 | - 'name' => __( 'Invoice Notice Label', 'invoicing' ), |
|
220 | - 'desc' => __( 'Use this to add an invoice notice section (label) to your invoices', 'invoicing' ), |
|
219 | + 'name' => __('Invoice Notice Label', 'invoicing'), |
|
220 | + 'desc' => __('Use this to add an invoice notice section (label) to your invoices', 'invoicing'), |
|
221 | 221 | 'type' => 'text', |
222 | 222 | 'size' => 'regular', |
223 | 223 | ), |
224 | 224 | 'vat_invoice_notice' => array( |
225 | 225 | 'id' => 'vat_invoice_notice', |
226 | - 'name' => __( 'Invoice notice', 'invoicing' ), |
|
227 | - 'desc' => __( 'Use this to add an invoice notice section (description) to your invoices', 'invoicing' ), |
|
226 | + 'name' => __('Invoice notice', 'invoicing'), |
|
227 | + 'desc' => __('Use this to add an invoice notice section (description) to your invoices', 'invoicing'), |
|
228 | 228 | 'type' => 'text', |
229 | 229 | 'size' => 'regular', |
230 | 230 | ), |
@@ -236,22 +236,22 @@ discard block |
||
236 | 236 | 'main' => array( |
237 | 237 | 'gateway_settings' => array( |
238 | 238 | 'id' => 'api_header', |
239 | - 'name' => '<h3>' . __( 'Gateway Settings', 'invoicing' ) . '</h3>', |
|
239 | + 'name' => '<h3>' . __('Gateway Settings', 'invoicing') . '</h3>', |
|
240 | 240 | 'desc' => '', |
241 | 241 | 'type' => 'header', |
242 | 242 | ), |
243 | 243 | 'gateways' => array( |
244 | 244 | 'id' => 'gateways', |
245 | - 'name' => __( 'Payment Gateways', 'invoicing' ), |
|
246 | - 'desc' => __( 'Choose the payment gateways you want to enable.', 'invoicing' ), |
|
245 | + 'name' => __('Payment Gateways', 'invoicing'), |
|
246 | + 'desc' => __('Choose the payment gateways you want to enable.', 'invoicing'), |
|
247 | 247 | 'type' => 'gateways', |
248 | - 'std' => array( 'manual'=>1 ), |
|
248 | + 'std' => array('manual'=>1), |
|
249 | 249 | 'options' => wpinv_get_payment_gateways(), |
250 | 250 | ), |
251 | 251 | 'default_gateway' => array( |
252 | 252 | 'id' => 'default_gateway', |
253 | - 'name' => __( 'Default Gateway', 'invoicing' ), |
|
254 | - 'desc' => __( 'This gateway will be loaded automatically with the checkout page.', 'invoicing' ), |
|
253 | + 'name' => __('Default Gateway', 'invoicing'), |
|
254 | + 'desc' => __('This gateway will be loaded automatically with the checkout page.', 'invoicing'), |
|
255 | 255 | 'type' => 'gateway_select', |
256 | 256 | 'std' => 'manual', |
257 | 257 | 'class' => 'wpi_select2', |
@@ -266,32 +266,32 @@ discard block |
||
266 | 266 | 'main' => array( |
267 | 267 | 'tax_settings' => array( |
268 | 268 | 'id' => 'tax_settings', |
269 | - 'name' => '<h3>' . __( 'Tax Settings', 'invoicing' ) . '</h3>', |
|
269 | + 'name' => '<h3>' . __('Tax Settings', 'invoicing') . '</h3>', |
|
270 | 270 | 'type' => 'header', |
271 | 271 | ), |
272 | 272 | |
273 | 273 | 'enable_taxes' => array( |
274 | 274 | 'id' => 'enable_taxes', |
275 | - 'name' => __( 'Enable Taxes', 'invoicing' ), |
|
276 | - 'desc' => __( 'Enable tax rates and calculations.', 'invoicing' ), |
|
275 | + 'name' => __('Enable Taxes', 'invoicing'), |
|
276 | + 'desc' => __('Enable tax rates and calculations.', 'invoicing'), |
|
277 | 277 | 'type' => 'checkbox', |
278 | 278 | 'std' => 0, |
279 | 279 | ), |
280 | 280 | |
281 | 281 | 'tax_subtotal_rounding' => array( |
282 | 282 | 'id' => 'tax_subtotal_rounding', |
283 | - 'name' => __( 'Rounding', 'invoicing' ), |
|
284 | - 'desc' => __( 'Round tax at subtotal level, instead of rounding per tax rate', 'invoicing' ), |
|
283 | + 'name' => __('Rounding', 'invoicing'), |
|
284 | + 'desc' => __('Round tax at subtotal level, instead of rounding per tax rate', 'invoicing'), |
|
285 | 285 | 'type' => 'checkbox', |
286 | 286 | 'std' => 1, |
287 | 287 | ), |
288 | 288 | |
289 | 289 | 'prices_include_tax' => array( |
290 | 290 | 'id' => 'prices_include_tax', |
291 | - 'name' => __( 'Prices entered with tax', 'invoicing' ), |
|
291 | + 'name' => __('Prices entered with tax', 'invoicing'), |
|
292 | 292 | 'options' => array( |
293 | - 'yes' => __( 'Yes, I will enter prices inclusive of tax', 'invoicing' ), |
|
294 | - 'no' => __( 'No, I will enter prices exclusive of tax', 'invoicing' ), |
|
293 | + 'yes' => __('Yes, I will enter prices inclusive of tax', 'invoicing'), |
|
294 | + 'no' => __('No, I will enter prices exclusive of tax', 'invoicing'), |
|
295 | 295 | ), |
296 | 296 | 'type' => 'select', |
297 | 297 | 'std' => 'no', |
@@ -299,10 +299,10 @@ discard block |
||
299 | 299 | |
300 | 300 | 'tax_base' => array( |
301 | 301 | 'id' => 'tax_base', |
302 | - 'name' => __( 'Calculate tax based on', 'invoicing' ), |
|
302 | + 'name' => __('Calculate tax based on', 'invoicing'), |
|
303 | 303 | 'options' => array( |
304 | - 'billing' => __( 'Customer billing address', 'invoicing' ), |
|
305 | - 'base' => __( 'Shop base address', 'invoicing' ), |
|
304 | + 'billing' => __('Customer billing address', 'invoicing'), |
|
305 | + 'base' => __('Shop base address', 'invoicing'), |
|
306 | 306 | ), |
307 | 307 | 'type' => 'select', |
308 | 308 | 'std' => 'billing', |
@@ -310,10 +310,10 @@ discard block |
||
310 | 310 | |
311 | 311 | 'tax_display_totals' => array( |
312 | 312 | 'id' => 'tax_display_totals', |
313 | - 'name' => __( 'Display tax totals', 'invoicing' ), |
|
313 | + 'name' => __('Display tax totals', 'invoicing'), |
|
314 | 314 | 'options' => array( |
315 | - 'single' => __( 'As a single total', 'invoicing' ), |
|
316 | - 'individual' => __( 'As individual tax rates', 'invoicing' ), |
|
315 | + 'single' => __('As a single total', 'invoicing'), |
|
316 | + 'individual' => __('As individual tax rates', 'invoicing'), |
|
317 | 317 | ), |
318 | 318 | 'type' => 'select', |
319 | 319 | 'std' => 'individual', |
@@ -321,8 +321,8 @@ discard block |
||
321 | 321 | |
322 | 322 | 'tax_rate' => array( |
323 | 323 | 'id' => 'tax_rate', |
324 | - 'name' => __( 'Fallback Tax Rate', 'invoicing' ), |
|
325 | - 'desc' => __( 'Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing' ), |
|
324 | + 'name' => __('Fallback Tax Rate', 'invoicing'), |
|
325 | + 'desc' => __('Enter a percentage, such as 6.5. Customers not in a specific rate will be charged this rate.', 'invoicing'), |
|
326 | 326 | 'type' => 'number', |
327 | 327 | 'size' => 'small', |
328 | 328 | 'min' => '0', |
@@ -334,8 +334,8 @@ discard block |
||
334 | 334 | 'rates' => array( |
335 | 335 | 'tax_rates' => array( |
336 | 336 | 'id' => 'tax_rates', |
337 | - 'name' => '<h3>' . __( 'Tax Rates', 'invoicing' ) . '</h3>', |
|
338 | - 'desc' => __( 'Enter tax rates for specific regions.', 'invoicing' ), |
|
337 | + 'name' => '<h3>' . __('Tax Rates', 'invoicing') . '</h3>', |
|
338 | + 'desc' => __('Enter tax rates for specific regions.', 'invoicing'), |
|
339 | 339 | 'type' => 'tax_rates', |
340 | 340 | ), |
341 | 341 | ), |
@@ -344,45 +344,45 @@ discard block |
||
344 | 344 | |
345 | 345 | 'vat_company_name' => array( |
346 | 346 | 'id' => 'vat_company_name', |
347 | - 'name' => __( 'Company Name', 'invoicing' ), |
|
348 | - 'desc' => wp_sprintf(__( 'Verify your company name and VAT number on the %sEU VIES System.%s', 'invoicing' ), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>' ), |
|
347 | + 'name' => __('Company Name', 'invoicing'), |
|
348 | + 'desc' => wp_sprintf(__('Verify your company name and VAT number on the %sEU VIES System.%s', 'invoicing'), '<a href="http://ec.europa.eu/taxation_customs/vies/" target="_blank">', '</a>'), |
|
349 | 349 | 'type' => 'text', |
350 | 350 | 'size' => 'regular', |
351 | 351 | ), |
352 | 352 | |
353 | 353 | 'vat_number' => array( |
354 | 354 | 'id' => 'vat_number', |
355 | - 'name' => __( 'VAT Number', 'invoicing' ), |
|
356 | - 'desc' => __( 'Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing' ), |
|
355 | + 'name' => __('VAT Number', 'invoicing'), |
|
356 | + 'desc' => __('Enter your VAT number including the country identifier, eg: GB123456789', 'invoicing'), |
|
357 | 357 | 'type' => 'text', |
358 | 358 | 'size' => 'regular', |
359 | 359 | ), |
360 | 360 | |
361 | 361 | 'vat_prevent_b2c_purchase' => array( |
362 | 362 | 'id' => 'vat_prevent_b2c_purchase', |
363 | - 'name' => __( 'Prevent B2C Sales', 'invoicing' ), |
|
364 | - 'desc' => __( 'Require everyone in the EU to provide a VAT number.', 'invoicing' ), |
|
363 | + 'name' => __('Prevent B2C Sales', 'invoicing'), |
|
364 | + 'desc' => __('Require everyone in the EU to provide a VAT number.', 'invoicing'), |
|
365 | 365 | 'type' => 'checkbox' |
366 | 366 | ), |
367 | 367 | |
368 | 368 | 'validate_vat_number' => array( |
369 | 369 | 'id' => 'validate_vat_number', |
370 | - 'name' => __( 'Validate VAT Number', 'invoicing' ), |
|
371 | - 'desc' => __( 'Validate VAT numbers with VIES.', 'invoicing' ), |
|
370 | + 'name' => __('Validate VAT Number', 'invoicing'), |
|
371 | + 'desc' => __('Validate VAT numbers with VIES.', 'invoicing'), |
|
372 | 372 | 'type' => 'checkbox' |
373 | 373 | ), |
374 | 374 | |
375 | 375 | 'vat_same_country_rule' => array( |
376 | 376 | 'id' => 'vat_same_country_rule', |
377 | - 'name' => __( 'Same Country Rule', 'invoicing' ), |
|
378 | - 'desc' => __( 'What should happen if a customer is from the same country as your business?', 'invoicing' ), |
|
377 | + 'name' => __('Same Country Rule', 'invoicing'), |
|
378 | + 'desc' => __('What should happen if a customer is from the same country as your business?', 'invoicing'), |
|
379 | 379 | 'type' => 'select', |
380 | 380 | 'options' => array( |
381 | - 'no' => __( 'Do not charge tax', 'invoicing' ), |
|
382 | - 'always' => __( 'Charge tax unless vat number is validated', 'invoicing' ), |
|
383 | - 'vat_too' => __( 'Charge tax even if vat number is validated', 'invoicing' ) |
|
381 | + 'no' => __('Do not charge tax', 'invoicing'), |
|
382 | + 'always' => __('Charge tax unless vat number is validated', 'invoicing'), |
|
383 | + 'vat_too' => __('Charge tax even if vat number is validated', 'invoicing') |
|
384 | 384 | ), |
385 | - 'placeholder' => __( 'Select an option', 'invoicing' ), |
|
385 | + 'placeholder' => __('Select an option', 'invoicing'), |
|
386 | 386 | 'std' => 'vat_too', |
387 | 387 | ), |
388 | 388 | |
@@ -396,68 +396,68 @@ discard block |
||
396 | 396 | 'main' => array( |
397 | 397 | 'email_settings_header' => array( |
398 | 398 | 'id' => 'email_settings_header', |
399 | - 'name' => '<h3>' . __( 'Email Sender Options', 'invoicing' ) . '</h3>', |
|
399 | + 'name' => '<h3>' . __('Email Sender Options', 'invoicing') . '</h3>', |
|
400 | 400 | 'type' => 'header', |
401 | 401 | ), |
402 | 402 | 'email_from_name' => array( |
403 | 403 | 'id' => 'email_from_name', |
404 | - 'name' => __( 'From Name', 'invoicing' ), |
|
405 | - 'desc' => __( 'Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing' ), |
|
406 | - 'std' => esc_attr( get_bloginfo( 'name', 'display' ) ), |
|
404 | + 'name' => __('From Name', 'invoicing'), |
|
405 | + 'desc' => __('Enter the sender\'s name appears in outgoing invoice emails. This should be your site name.', 'invoicing'), |
|
406 | + 'std' => esc_attr(get_bloginfo('name', 'display')), |
|
407 | 407 | 'type' => 'text', |
408 | 408 | ), |
409 | 409 | 'email_from' => array( |
410 | 410 | 'id' => 'email_from', |
411 | - 'name' => __( 'From Email', 'invoicing' ), |
|
412 | - 'desc' => sprintf (__( 'Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing' ), $alert_wrapper_start, $alert_wrapper_close), |
|
413 | - 'std' => get_option( 'admin_email' ), |
|
411 | + 'name' => __('From Email', 'invoicing'), |
|
412 | + 'desc' => sprintf(__('Email address to send invoice emails from. This will act as the "from" and "reply-to" address. %s If emails are not being sent it may be that your hosting prevents emails being sent if the email domains do not match.%s', 'invoicing'), $alert_wrapper_start, $alert_wrapper_close), |
|
413 | + 'std' => get_option('admin_email'), |
|
414 | 414 | 'type' => 'text', |
415 | 415 | ), |
416 | 416 | 'admin_email' => array( |
417 | 417 | 'id' => 'admin_email', |
418 | - 'name' => __( 'Admin Email', 'invoicing' ), |
|
419 | - 'desc' => __( 'Where should we send admin notifications?', 'invoicing' ), |
|
420 | - 'std' => get_option( 'admin_email' ), |
|
418 | + 'name' => __('Admin Email', 'invoicing'), |
|
419 | + 'desc' => __('Where should we send admin notifications?', 'invoicing'), |
|
420 | + 'std' => get_option('admin_email'), |
|
421 | 421 | 'type' => 'text', |
422 | 422 | ), |
423 | 423 | 'overdue_settings_header' => array( |
424 | 424 | 'id' => 'overdue_settings_header', |
425 | - 'name' => '<h3>' . __( 'Due Date Settings', 'invoicing' ) . '</h3>', |
|
425 | + 'name' => '<h3>' . __('Due Date Settings', 'invoicing') . '</h3>', |
|
426 | 426 | 'type' => 'header', |
427 | 427 | ), |
428 | 428 | 'overdue_active' => array( |
429 | 429 | 'id' => 'overdue_active', |
430 | - 'name' => __( 'Enable Due Date', 'invoicing' ), |
|
431 | - 'desc' => __( 'Check this to enable due date option for invoices.', 'invoicing' ), |
|
430 | + 'name' => __('Enable Due Date', 'invoicing'), |
|
431 | + 'desc' => __('Check this to enable due date option for invoices.', 'invoicing'), |
|
432 | 432 | 'type' => 'checkbox', |
433 | 433 | 'std' => false, |
434 | 434 | ), |
435 | 435 | 'overdue_days' => array( |
436 | 436 | 'id' => 'overdue_days', |
437 | - 'name' => __( 'Default Due Date', 'invoicing' ), |
|
438 | - 'desc' => __( 'Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing' ), |
|
437 | + 'name' => __('Default Due Date', 'invoicing'), |
|
438 | + 'desc' => __('Number of days each Invoice is due after the created date. This will automatically set the date in the "Due Date" field. Can be overridden on individual Invoices.', 'invoicing'), |
|
439 | 439 | 'type' => 'select', |
440 | 440 | 'options' => $due_payment_options, |
441 | 441 | 'std' => 0, |
442 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
442 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
443 | 443 | ), |
444 | 444 | 'email_template_header' => array( |
445 | 445 | 'id' => 'email_template_header', |
446 | - 'name' => '<h3>' . __( 'Email Template', 'invoicing' ) . '</h3>', |
|
446 | + 'name' => '<h3>' . __('Email Template', 'invoicing') . '</h3>', |
|
447 | 447 | 'type' => 'header', |
448 | 448 | ), |
449 | 449 | 'email_header_image' => array( |
450 | 450 | 'id' => 'email_header_image', |
451 | - 'name' => __( 'Header Image', 'invoicing' ), |
|
452 | - 'desc' => __( 'URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing' ), |
|
451 | + 'name' => __('Header Image', 'invoicing'), |
|
452 | + 'desc' => __('URL to an image you want to show in the email header. Upload images using the media uploader (Admin > Media).', 'invoicing'), |
|
453 | 453 | 'std' => '', |
454 | 454 | 'type' => 'text', |
455 | 455 | ), |
456 | 456 | 'email_footer_text' => array( |
457 | 457 | 'id' => 'email_footer_text', |
458 | - 'name' => __( 'Footer Text', 'invoicing' ), |
|
459 | - 'desc' => __( 'The text to appear in the footer of all invoice emails.', 'invoicing' ), |
|
460 | - 'std' => get_bloginfo( 'name', 'display' ) . ' - ' . __( 'Powered by GetPaid', 'invoicing' ), |
|
458 | + 'name' => __('Footer Text', 'invoicing'), |
|
459 | + 'desc' => __('The text to appear in the footer of all invoice emails.', 'invoicing'), |
|
460 | + 'std' => get_bloginfo('name', 'display') . ' - ' . __('Powered by GetPaid', 'invoicing'), |
|
461 | 461 | 'type' => 'textarea', |
462 | 462 | 'class' => 'regular-text', |
463 | 463 | 'rows' => 2, |
@@ -465,29 +465,29 @@ discard block |
||
465 | 465 | ), |
466 | 466 | 'email_base_color' => array( |
467 | 467 | 'id' => 'email_base_color', |
468 | - 'name' => __( 'Base Color', 'invoicing' ), |
|
469 | - 'desc' => __( 'The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing' ), |
|
468 | + 'name' => __('Base Color', 'invoicing'), |
|
469 | + 'desc' => __('The base color for invoice email template. Default <code>#557da2</code>.', 'invoicing'), |
|
470 | 470 | 'std' => '#557da2', |
471 | 471 | 'type' => 'color', |
472 | 472 | ), |
473 | 473 | 'email_background_color' => array( |
474 | 474 | 'id' => 'email_background_color', |
475 | - 'name' => __( 'Background Color', 'invoicing' ), |
|
476 | - 'desc' => __( 'The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing' ), |
|
475 | + 'name' => __('Background Color', 'invoicing'), |
|
476 | + 'desc' => __('The background color of email template. Default <code>#f5f5f5</code>.', 'invoicing'), |
|
477 | 477 | 'std' => '#f5f5f5', |
478 | 478 | 'type' => 'color', |
479 | 479 | ), |
480 | 480 | 'email_body_background_color' => array( |
481 | 481 | 'id' => 'email_body_background_color', |
482 | - 'name' => __( 'Body Background Color', 'invoicing' ), |
|
483 | - 'desc' => __( 'The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing' ), |
|
482 | + 'name' => __('Body Background Color', 'invoicing'), |
|
483 | + 'desc' => __('The main body background color of email template. Default <code>#fdfdfd</code>.', 'invoicing'), |
|
484 | 484 | 'std' => '#fdfdfd', |
485 | 485 | 'type' => 'color', |
486 | 486 | ), |
487 | 487 | 'email_text_color' => array( |
488 | 488 | 'id' => 'email_text_color', |
489 | - 'name' => __( 'Body Text Color', 'invoicing' ), |
|
490 | - 'desc' => __( 'The main body text color. Default <code>#505050</code>.', 'invoicing' ), |
|
489 | + 'name' => __('Body Text Color', 'invoicing'), |
|
490 | + 'desc' => __('The main body text color. Default <code>#505050</code>.', 'invoicing'), |
|
491 | 491 | 'std' => '#505050', |
492 | 492 | 'type' => 'color', |
493 | 493 | ), |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | ), |
503 | 503 | |
504 | 504 | // Integrations. |
505 | - 'integrations' => wp_list_pluck( getpaid_get_integration_settings(), 'settings', 'id' ), |
|
505 | + 'integrations' => wp_list_pluck(getpaid_get_integration_settings(), 'settings', 'id'), |
|
506 | 506 | |
507 | 507 | /** Privacy Settings */ |
508 | 508 | 'privacy' => apply_filters('wpinv_settings_privacy', |
@@ -510,17 +510,17 @@ discard block |
||
510 | 510 | 'main' => array( |
511 | 511 | 'invoicing_privacy_policy_settings' => array( |
512 | 512 | 'id' => 'invoicing_privacy_policy_settings', |
513 | - 'name' => '<h3>' . __( 'Privacy Policy', 'invoicing' ) . '</h3>', |
|
513 | + 'name' => '<h3>' . __('Privacy Policy', 'invoicing') . '</h3>', |
|
514 | 514 | 'type' => 'header', |
515 | 515 | ), |
516 | 516 | 'privacy_page' => array( |
517 | 517 | 'id' => 'privacy_page', |
518 | - 'name' => __( 'Privacy Page', 'invoicing' ), |
|
519 | - 'desc' => __( 'If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing' ), |
|
518 | + 'name' => __('Privacy Page', 'invoicing'), |
|
519 | + 'desc' => __('If no privacy policy page set in Settings->Privacy default settings, this page will be used on checkout page.', 'invoicing'), |
|
520 | 520 | 'type' => 'select', |
521 | - 'options' => wpinv_get_pages( true, __( 'Select a page', 'invoicing' )), |
|
521 | + 'options' => wpinv_get_pages(true, __('Select a page', 'invoicing')), |
|
522 | 522 | 'class' => 'wpi_select2', |
523 | - 'placeholder' => __( 'Select a page', 'invoicing' ), |
|
523 | + 'placeholder' => __('Select a page', 'invoicing'), |
|
524 | 524 | ), |
525 | 525 | ), |
526 | 526 | ) |
@@ -531,19 +531,19 @@ discard block |
||
531 | 531 | 'main' => array( |
532 | 532 | 'invoice_number_format_settings' => array( |
533 | 533 | 'id' => 'invoice_number_format_settings', |
534 | - 'name' => '<h3>' . __( 'Invoice Number', 'invoicing' ) . '</h3>', |
|
534 | + 'name' => '<h3>' . __('Invoice Number', 'invoicing') . '</h3>', |
|
535 | 535 | 'type' => 'header', |
536 | 536 | ), |
537 | 537 | 'sequential_invoice_number' => array( |
538 | 538 | 'id' => 'sequential_invoice_number', |
539 | - 'name' => __( 'Sequential Invoice Numbers', 'invoicing' ), |
|
540 | - 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing' ) . $reset_number, |
|
539 | + 'name' => __('Sequential Invoice Numbers', 'invoicing'), |
|
540 | + 'desc' => __('Check this box to enable sequential invoice numbers.', 'invoicing') . $reset_number, |
|
541 | 541 | 'type' => 'checkbox', |
542 | 542 | ), |
543 | 543 | 'invoice_sequence_start' => array( |
544 | 544 | 'id' => 'invoice_sequence_start', |
545 | - 'name' => __( 'Sequential Starting Number', 'invoicing' ), |
|
546 | - 'desc' => __( 'The number at which the invoice number sequence should begin.', 'invoicing' ) . $last_number, |
|
545 | + 'name' => __('Sequential Starting Number', 'invoicing'), |
|
546 | + 'desc' => __('The number at which the invoice number sequence should begin.', 'invoicing') . $last_number, |
|
547 | 547 | 'type' => 'number', |
548 | 548 | 'size' => 'small', |
549 | 549 | 'std' => '1', |
@@ -551,8 +551,8 @@ discard block |
||
551 | 551 | ), |
552 | 552 | 'invoice_number_padd' => array( |
553 | 553 | 'id' => 'invoice_number_padd', |
554 | - 'name' => __( 'Minimum Digits', 'invoicing' ), |
|
555 | - 'desc' => __( 'If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing' ), |
|
554 | + 'name' => __('Minimum Digits', 'invoicing'), |
|
555 | + 'desc' => __('If the invoice number has less digits than this number, it is left padded with 0s. Ex: invoice number 108 will padded to 00108 if digits set to 5. The default 0 means no padding.', 'invoicing'), |
|
556 | 556 | 'type' => 'select', |
557 | 557 | 'options' => $invoice_number_padd_options, |
558 | 558 | 'std' => 5, |
@@ -560,8 +560,8 @@ discard block |
||
560 | 560 | ), |
561 | 561 | 'invoice_number_prefix' => array( |
562 | 562 | 'id' => 'invoice_number_prefix', |
563 | - 'name' => __( 'Invoice Number Prefix', 'invoicing' ), |
|
564 | - 'desc' => __( 'Prefix for all invoice numbers. Ex: INV-', 'invoicing' ), |
|
563 | + 'name' => __('Invoice Number Prefix', 'invoicing'), |
|
564 | + 'desc' => __('Prefix for all invoice numbers. Ex: INV-', 'invoicing'), |
|
565 | 565 | 'type' => 'text', |
566 | 566 | 'size' => 'regular', |
567 | 567 | 'std' => 'INV-', |
@@ -569,41 +569,41 @@ discard block |
||
569 | 569 | ), |
570 | 570 | 'invoice_number_postfix' => array( |
571 | 571 | 'id' => 'invoice_number_postfix', |
572 | - 'name' => __( 'Invoice Number Postfix', 'invoicing' ), |
|
573 | - 'desc' => __( 'Postfix for all invoice numbers.', 'invoicing' ), |
|
572 | + 'name' => __('Invoice Number Postfix', 'invoicing'), |
|
573 | + 'desc' => __('Postfix for all invoice numbers.', 'invoicing'), |
|
574 | 574 | 'type' => 'text', |
575 | 575 | 'size' => 'regular', |
576 | 576 | 'std' => '' |
577 | 577 | ), |
578 | 578 | 'checkout_settings' => array( |
579 | 579 | 'id' => 'checkout_settings', |
580 | - 'name' => '<h3>' . __( 'Checkout Settings', 'invoicing' ) . '</h3>', |
|
580 | + 'name' => '<h3>' . __('Checkout Settings', 'invoicing') . '</h3>', |
|
581 | 581 | 'type' => 'header', |
582 | 582 | ), |
583 | 583 | 'login_to_checkout' => array( |
584 | 584 | 'id' => 'login_to_checkout', |
585 | - 'name' => __( 'Require Login To Checkout', 'invoicing' ), |
|
586 | - 'desc' => __( 'If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing' ), |
|
585 | + 'name' => __('Require Login To Checkout', 'invoicing'), |
|
586 | + 'desc' => __('If ticked then user needs to be logged in to view or pay invoice, can only view or pay their own invoice. If unticked then anyone can view or pay the invoice.', 'invoicing'), |
|
587 | 587 | 'type' => 'checkbox', |
588 | 588 | ), |
589 | 589 | |
590 | 590 | 'maxmind_license_key' => array( |
591 | 591 | 'id' => 'maxmind_license_key', |
592 | - 'name' => __( 'MaxMind License Key', 'invoicing' ), |
|
592 | + 'name' => __('MaxMind License Key', 'invoicing'), |
|
593 | 593 | 'type' => 'text', |
594 | 594 | 'size' => 'regular', |
595 | - 'desc' => __( "Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing' ) . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __( 'How to generate a free license key.', 'invoicing' ) . '</a>', |
|
595 | + 'desc' => __("Enter you license key if you would like to use MaxMind to automatically detect a customer's country.", 'invoicing') . ' <a href="https://support.maxmind.com/account-faq/license-keys/how-do-i-generate-a-license-key/">' . __('How to generate a free license key.', 'invoicing') . '</a>', |
|
596 | 596 | ), |
597 | 597 | |
598 | 598 | 'uninstall_settings' => array( |
599 | 599 | 'id' => 'uninstall_settings', |
600 | - 'name' => '<h3>' . __( 'Uninstall Settings', 'invoicing' ) . '</h3>', |
|
600 | + 'name' => '<h3>' . __('Uninstall Settings', 'invoicing') . '</h3>', |
|
601 | 601 | 'type' => 'header', |
602 | 602 | ), |
603 | 603 | 'remove_data_on_unistall' => array( |
604 | 604 | 'id' => 'remove_data_on_unistall', |
605 | - 'name' => __( 'Remove Data on Uninstall?', 'invoicing' ), |
|
606 | - 'desc' => __( 'Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing' ), |
|
605 | + 'name' => __('Remove Data on Uninstall?', 'invoicing'), |
|
606 | + 'desc' => __('Check this box if you would like Invoicing plugin to completely remove all of its data when the plugin is deleted/uninstalled.', 'invoicing'), |
|
607 | 607 | 'type' => 'checkbox', |
608 | 608 | 'std' => '' |
609 | 609 | ), |
@@ -612,13 +612,13 @@ discard block |
||
612 | 612 | 'custom-css' => array( |
613 | 613 | 'css_settings' => array( |
614 | 614 | 'id' => 'css_settings', |
615 | - 'name' => '<h3>' . __( 'Custom CSS', 'invoicing' ) . '</h3>', |
|
615 | + 'name' => '<h3>' . __('Custom CSS', 'invoicing') . '</h3>', |
|
616 | 616 | 'type' => 'header', |
617 | 617 | ), |
618 | 618 | 'template_custom_css' => array( |
619 | 619 | 'id' => 'template_custom_css', |
620 | - 'name' => __( 'Invoice Template CSS', 'invoicing' ), |
|
621 | - 'desc' => __( 'Add CSS to modify appearance of the print invoice page.', 'invoicing' ), |
|
620 | + 'name' => __('Invoice Template CSS', 'invoicing'), |
|
621 | + 'desc' => __('Add CSS to modify appearance of the print invoice page.', 'invoicing'), |
|
622 | 622 | 'type' => 'textarea', |
623 | 623 | 'class'=> 'regular-text', |
624 | 624 | 'rows' => 10, |
@@ -632,8 +632,8 @@ discard block |
||
632 | 632 | 'main' => array( |
633 | 633 | 'tool_settings' => array( |
634 | 634 | 'id' => 'tool_settings', |
635 | - 'name' => '<h3>' . __( 'Diagnostic Tools', 'invoicing' ) . '</h3>', |
|
636 | - 'desc' => __( 'Invoicing diagnostic tools', 'invoicing' ), |
|
635 | + 'name' => '<h3>' . __('Diagnostic Tools', 'invoicing') . '</h3>', |
|
636 | + 'desc' => __('Invoicing diagnostic tools', 'invoicing'), |
|
637 | 637 | 'type' => 'tools', |
638 | 638 | ), |
639 | 639 | ), |
@@ -12,229 +12,229 @@ |
||
12 | 12 | */ |
13 | 13 | class GetPaid_Payment_Form_Submission_Taxes { |
14 | 14 | |
15 | - /** |
|
16 | - * Submission taxes. |
|
17 | - * @var array |
|
18 | - */ |
|
19 | - public $taxes = array(); |
|
20 | - |
|
21 | - /** |
|
22 | - * Whether or not we should skip the taxes. |
|
23 | - * @var bool |
|
24 | - */ |
|
25 | - protected $skip_taxes = false; |
|
15 | + /** |
|
16 | + * Submission taxes. |
|
17 | + * @var array |
|
18 | + */ |
|
19 | + public $taxes = array(); |
|
20 | + |
|
21 | + /** |
|
22 | + * Whether or not we should skip the taxes. |
|
23 | + * @var bool |
|
24 | + */ |
|
25 | + protected $skip_taxes = false; |
|
26 | + |
|
27 | + /** |
|
28 | + * Class constructor |
|
29 | + * |
|
30 | + * @param GetPaid_Payment_Form_Submission $submission |
|
31 | + */ |
|
32 | + public function __construct( $submission ) { |
|
33 | + |
|
34 | + // Validate VAT number. |
|
35 | + $this->validate_vat( $submission ); |
|
36 | + |
|
37 | + if ( $this->skip_taxes ) { |
|
38 | + return; |
|
39 | + } |
|
40 | + |
|
41 | + foreach ( $submission->get_items() as $item ) { |
|
42 | + $this->process_item_tax( $item, $submission ); |
|
43 | + } |
|
44 | + |
|
45 | + // Process any existing invoice taxes. |
|
46 | + if ( $submission->has_invoice() ) { |
|
47 | + $this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes ); |
|
48 | + } |
|
49 | + |
|
50 | + } |
|
51 | + |
|
52 | + /** |
|
53 | + * Maybe process tax. |
|
54 | + * |
|
55 | + * @since 1.0.19 |
|
56 | + * @param GetPaid_Form_Item $item |
|
57 | + * @param GetPaid_Payment_Form_Submission $submission |
|
58 | + */ |
|
59 | + public function process_item_tax( $item, $submission ) { |
|
60 | + |
|
61 | + $rates = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state ); |
|
62 | + $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
63 | + $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item->get_id(), $item->get_sub_total(), $submission->get_discount_code(), false ), $rates ); |
|
64 | + $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item->get_id(), $item->get_recurring_sub_total(), $submission->get_discount_code(), true ), $rates ); |
|
65 | + |
|
66 | + foreach ( $taxes as $name => $amount ) { |
|
67 | + $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
68 | + $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
69 | + |
|
70 | + if ( ! isset( $this->taxes[ $name ] ) ) { |
|
71 | + $this->taxes[ $name ] = $tax; |
|
72 | + continue; |
|
73 | + } |
|
74 | + |
|
75 | + $this->taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
76 | + $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
77 | + |
|
78 | + } |
|
79 | + |
|
80 | + } |
|
81 | + |
|
82 | + /** |
|
83 | + * Checks if the submission has a digital item. |
|
84 | + * |
|
85 | + * @param GetPaid_Payment_Form_Submission $submission |
|
86 | + * @since 1.0.19 |
|
87 | + * @return bool |
|
88 | + */ |
|
89 | + public function has_digital_item( $submission ) { |
|
90 | + |
|
91 | + foreach ( $submission->get_items() as $item ) { |
|
92 | + |
|
93 | + if ( 'digital' == $item->get_vat_rule() ) { |
|
94 | + return true; |
|
95 | + } |
|
96 | + |
|
97 | + } |
|
98 | + |
|
99 | + return false; |
|
100 | + } |
|
101 | + |
|
102 | + /** |
|
103 | + * Checks if this is an eu store. |
|
104 | + * |
|
105 | + * @since 1.0.19 |
|
106 | + * @return bool |
|
107 | + */ |
|
108 | + public static function is_eu_store() { |
|
109 | + return self::is_eu_country( wpinv_get_default_country() ); |
|
110 | + } |
|
26 | 111 | |
27 | 112 | /** |
28 | - * Class constructor |
|
29 | - * |
|
30 | - * @param GetPaid_Payment_Form_Submission $submission |
|
31 | - */ |
|
32 | - public function __construct( $submission ) { |
|
33 | - |
|
34 | - // Validate VAT number. |
|
35 | - $this->validate_vat( $submission ); |
|
36 | - |
|
37 | - if ( $this->skip_taxes ) { |
|
38 | - return; |
|
39 | - } |
|
40 | - |
|
41 | - foreach ( $submission->get_items() as $item ) { |
|
42 | - $this->process_item_tax( $item, $submission ); |
|
43 | - } |
|
44 | - |
|
45 | - // Process any existing invoice taxes. |
|
46 | - if ( $submission->has_invoice() ) { |
|
47 | - $this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes ); |
|
48 | - } |
|
49 | - |
|
50 | - } |
|
51 | - |
|
52 | - /** |
|
53 | - * Maybe process tax. |
|
54 | - * |
|
55 | - * @since 1.0.19 |
|
56 | - * @param GetPaid_Form_Item $item |
|
57 | - * @param GetPaid_Payment_Form_Submission $submission |
|
58 | - */ |
|
59 | - public function process_item_tax( $item, $submission ) { |
|
60 | - |
|
61 | - $rates = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state ); |
|
62 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
63 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item->get_id(), $item->get_sub_total(), $submission->get_discount_code(), false ), $rates ); |
|
64 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item->get_id(), $item->get_recurring_sub_total(), $submission->get_discount_code(), true ), $rates ); |
|
65 | - |
|
66 | - foreach ( $taxes as $name => $amount ) { |
|
67 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
68 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
69 | - |
|
70 | - if ( ! isset( $this->taxes[ $name ] ) ) { |
|
71 | - $this->taxes[ $name ] = $tax; |
|
72 | - continue; |
|
73 | - } |
|
74 | - |
|
75 | - $this->taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
76 | - $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
77 | - |
|
78 | - } |
|
79 | - |
|
80 | - } |
|
81 | - |
|
82 | - /** |
|
83 | - * Checks if the submission has a digital item. |
|
84 | - * |
|
85 | - * @param GetPaid_Payment_Form_Submission $submission |
|
86 | - * @since 1.0.19 |
|
87 | - * @return bool |
|
88 | - */ |
|
89 | - public function has_digital_item( $submission ) { |
|
90 | - |
|
91 | - foreach ( $submission->get_items() as $item ) { |
|
92 | - |
|
93 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
94 | - return true; |
|
95 | - } |
|
96 | - |
|
97 | - } |
|
98 | - |
|
99 | - return false; |
|
100 | - } |
|
101 | - |
|
102 | - /** |
|
103 | - * Checks if this is an eu store. |
|
104 | - * |
|
105 | - * @since 1.0.19 |
|
106 | - * @return bool |
|
107 | - */ |
|
108 | - public static function is_eu_store() { |
|
109 | - return self::is_eu_country( wpinv_get_default_country() ); |
|
110 | - } |
|
111 | - |
|
112 | - /** |
|
113 | - * Checks if this is an eu country. |
|
114 | - * |
|
115 | - * @param string $country |
|
116 | - * @since 1.0.19 |
|
117 | - * @return bool |
|
118 | - */ |
|
119 | - public static function is_eu_country( $country ) { |
|
120 | - return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country ); |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * Checks if this is an eu purchase. |
|
125 | - * |
|
126 | - * @param string $customer_country |
|
127 | - * @since 1.0.19 |
|
128 | - * @return bool |
|
129 | - */ |
|
130 | - public static function is_eu_transaction( $customer_country ) { |
|
131 | - return self::is_eu_country( $customer_country ) && self::is_eu_store(); |
|
132 | - } |
|
133 | - |
|
134 | - /** |
|
135 | - * Retrieves the vat number. |
|
136 | - * |
|
137 | - * @param GetPaid_Payment_Form_Submission $submission |
|
138 | - * @since 1.0.19 |
|
139 | - * @return string |
|
140 | - */ |
|
141 | - public function get_vat_number( $submission ) { |
|
142 | - |
|
143 | - // Retrieve from the posted number. |
|
144 | - $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' ); |
|
145 | - if ( ! empty( $vat_number ) ) { |
|
146 | - return wpinv_clean( $vat_number ); |
|
147 | - } |
|
148 | - |
|
149 | - // Retrieve from the invoice. |
|
150 | - return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : ''; |
|
151 | - } |
|
152 | - |
|
153 | - /** |
|
154 | - * Retrieves the company. |
|
155 | - * |
|
156 | - * @param GetPaid_Payment_Form_Submission $submission |
|
157 | - * @since 1.0.19 |
|
158 | - * @return string |
|
159 | - */ |
|
160 | - public function get_company( $submission ) { |
|
161 | - |
|
162 | - // Retrieve from the posted data. |
|
163 | - $company = $submission->get_field( 'wpinv_company', 'billing' ); |
|
164 | - if ( ! empty( $company ) ) { |
|
165 | - return wpinv_clean( $company ); |
|
166 | - } |
|
167 | - |
|
168 | - // Retrieve from the invoice. |
|
169 | - return $submission->has_invoice() ? $submission->get_invoice()->get_company() : ''; |
|
170 | - } |
|
171 | - |
|
172 | - /** |
|
173 | - * Checks if we require a VAT number. |
|
174 | - * |
|
175 | - * @param bool $ip_in_eu Whether the customer IP is from the EU |
|
176 | - * @param bool $country_in_eu Whether the customer country is from the EU |
|
177 | - * @since 1.0.19 |
|
178 | - * @return string |
|
179 | - */ |
|
180 | - public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
181 | - |
|
182 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
183 | - $prevent_b2c = ! empty( $prevent_b2c ); |
|
184 | - $is_eu = $ip_in_eu || $country_in_eu; |
|
185 | - |
|
186 | - return $prevent_b2c && $is_eu; |
|
187 | - } |
|
188 | - |
|
189 | - /** |
|
190 | - * Validate VAT data. |
|
191 | - * |
|
192 | - * @param GetPaid_Payment_Form_Submission $submission |
|
193 | - * @since 1.0.19 |
|
194 | - */ |
|
195 | - public function validate_vat( $submission ) { |
|
196 | - |
|
197 | - $in_eu = $this->is_eu_transaction( $submission->country ); |
|
198 | - |
|
199 | - // Abort if we are not validating vat numbers. |
|
200 | - if ( ! $in_eu ) { |
|
113 | + * Checks if this is an eu country. |
|
114 | + * |
|
115 | + * @param string $country |
|
116 | + * @since 1.0.19 |
|
117 | + * @return bool |
|
118 | + */ |
|
119 | + public static function is_eu_country( $country ) { |
|
120 | + return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country ); |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * Checks if this is an eu purchase. |
|
125 | + * |
|
126 | + * @param string $customer_country |
|
127 | + * @since 1.0.19 |
|
128 | + * @return bool |
|
129 | + */ |
|
130 | + public static function is_eu_transaction( $customer_country ) { |
|
131 | + return self::is_eu_country( $customer_country ) && self::is_eu_store(); |
|
132 | + } |
|
133 | + |
|
134 | + /** |
|
135 | + * Retrieves the vat number. |
|
136 | + * |
|
137 | + * @param GetPaid_Payment_Form_Submission $submission |
|
138 | + * @since 1.0.19 |
|
139 | + * @return string |
|
140 | + */ |
|
141 | + public function get_vat_number( $submission ) { |
|
142 | + |
|
143 | + // Retrieve from the posted number. |
|
144 | + $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' ); |
|
145 | + if ( ! empty( $vat_number ) ) { |
|
146 | + return wpinv_clean( $vat_number ); |
|
147 | + } |
|
148 | + |
|
149 | + // Retrieve from the invoice. |
|
150 | + return $submission->has_invoice() ? $submission->get_invoice()->get_vat_number() : ''; |
|
151 | + } |
|
152 | + |
|
153 | + /** |
|
154 | + * Retrieves the company. |
|
155 | + * |
|
156 | + * @param GetPaid_Payment_Form_Submission $submission |
|
157 | + * @since 1.0.19 |
|
158 | + * @return string |
|
159 | + */ |
|
160 | + public function get_company( $submission ) { |
|
161 | + |
|
162 | + // Retrieve from the posted data. |
|
163 | + $company = $submission->get_field( 'wpinv_company', 'billing' ); |
|
164 | + if ( ! empty( $company ) ) { |
|
165 | + return wpinv_clean( $company ); |
|
166 | + } |
|
167 | + |
|
168 | + // Retrieve from the invoice. |
|
169 | + return $submission->has_invoice() ? $submission->get_invoice()->get_company() : ''; |
|
170 | + } |
|
171 | + |
|
172 | + /** |
|
173 | + * Checks if we require a VAT number. |
|
174 | + * |
|
175 | + * @param bool $ip_in_eu Whether the customer IP is from the EU |
|
176 | + * @param bool $country_in_eu Whether the customer country is from the EU |
|
177 | + * @since 1.0.19 |
|
178 | + * @return string |
|
179 | + */ |
|
180 | + public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
181 | + |
|
182 | + $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
183 | + $prevent_b2c = ! empty( $prevent_b2c ); |
|
184 | + $is_eu = $ip_in_eu || $country_in_eu; |
|
185 | + |
|
186 | + return $prevent_b2c && $is_eu; |
|
187 | + } |
|
188 | + |
|
189 | + /** |
|
190 | + * Validate VAT data. |
|
191 | + * |
|
192 | + * @param GetPaid_Payment_Form_Submission $submission |
|
193 | + * @since 1.0.19 |
|
194 | + */ |
|
195 | + public function validate_vat( $submission ) { |
|
196 | + |
|
197 | + $in_eu = $this->is_eu_transaction( $submission->country ); |
|
198 | + |
|
199 | + // Abort if we are not validating vat numbers. |
|
200 | + if ( ! $in_eu ) { |
|
201 | 201 | return; |
202 | - } |
|
202 | + } |
|
203 | 203 | |
204 | - // Prepare variables. |
|
205 | - $vat_number = $this->get_vat_number( $submission ); |
|
206 | - $ip_country = getpaid_get_ip_country(); |
|
204 | + // Prepare variables. |
|
205 | + $vat_number = $this->get_vat_number( $submission ); |
|
206 | + $ip_country = getpaid_get_ip_country(); |
|
207 | 207 | $is_eu = $this->is_eu_country( $submission->country ); |
208 | 208 | $is_ip_eu = $this->is_eu_country( $ip_country ); |
209 | 209 | |
210 | - // Maybe abort early for initial fetches. |
|
211 | - if ( $submission->is_initial_fetch() && empty( $vat_number ) ) { |
|
212 | - return; |
|
213 | - } |
|
210 | + // Maybe abort early for initial fetches. |
|
211 | + if ( $submission->is_initial_fetch() && empty( $vat_number ) ) { |
|
212 | + return; |
|
213 | + } |
|
214 | 214 | |
215 | - // If we're preventing business to consumer purchases, |
|
216 | - if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
215 | + // If we're preventing business to consumer purchases, |
|
216 | + if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
217 | 217 | |
218 | - // Ensure that a vat number has been specified. |
|
219 | - throw new Exception( |
|
220 | - __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) |
|
221 | - ); |
|
218 | + // Ensure that a vat number has been specified. |
|
219 | + throw new Exception( |
|
220 | + __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) |
|
221 | + ); |
|
222 | 222 | |
223 | - } |
|
223 | + } |
|
224 | 224 | |
225 | - if ( empty( $vat_number ) ) { |
|
226 | - return; |
|
227 | - } |
|
225 | + if ( empty( $vat_number ) ) { |
|
226 | + return; |
|
227 | + } |
|
228 | 228 | |
229 | - if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) { |
|
230 | - throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) ); |
|
231 | - } |
|
229 | + if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) { |
|
230 | + throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) ); |
|
231 | + } |
|
232 | 232 | |
233 | - if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
234 | - return; |
|
235 | - } |
|
233 | + if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
234 | + return; |
|
235 | + } |
|
236 | 236 | |
237 | - $this->skip_taxes = true; |
|
238 | - } |
|
237 | + $this->skip_taxes = true; |
|
238 | + } |
|
239 | 239 | |
240 | 240 | } |
@@ -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 taxes class |
@@ -29,22 +29,22 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @param GetPaid_Payment_Form_Submission $submission |
31 | 31 | */ |
32 | - public function __construct( $submission ) { |
|
32 | + public function __construct($submission) { |
|
33 | 33 | |
34 | 34 | // Validate VAT number. |
35 | - $this->validate_vat( $submission ); |
|
35 | + $this->validate_vat($submission); |
|
36 | 36 | |
37 | - if ( $this->skip_taxes ) { |
|
37 | + if ($this->skip_taxes) { |
|
38 | 38 | return; |
39 | 39 | } |
40 | 40 | |
41 | - foreach ( $submission->get_items() as $item ) { |
|
42 | - $this->process_item_tax( $item, $submission ); |
|
41 | + foreach ($submission->get_items() as $item) { |
|
42 | + $this->process_item_tax($item, $submission); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | // Process any existing invoice taxes. |
46 | - if ( $submission->has_invoice() ) { |
|
47 | - $this->taxes = array_replace( $submission->get_invoice()->get_taxes(), $this->taxes ); |
|
46 | + if ($submission->has_invoice()) { |
|
47 | + $this->taxes = array_replace($submission->get_invoice()->get_taxes(), $this->taxes); |
|
48 | 48 | } |
49 | 49 | |
50 | 50 | } |
@@ -56,24 +56,24 @@ discard block |
||
56 | 56 | * @param GetPaid_Form_Item $item |
57 | 57 | * @param GetPaid_Payment_Form_Submission $submission |
58 | 58 | */ |
59 | - public function process_item_tax( $item, $submission ) { |
|
59 | + public function process_item_tax($item, $submission) { |
|
60 | 60 | |
61 | - $rates = getpaid_get_item_tax_rates( $item, $submission->country, $submission->state ); |
|
62 | - $rates = getpaid_filter_item_tax_rates( $item, $rates ); |
|
63 | - $taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item->get_id(), $item->get_sub_total(), $submission->get_discount_code(), false ), $rates ); |
|
64 | - $r_taxes = getpaid_calculate_item_taxes( getpaid_get_taxable_amount( $item->get_id(), $item->get_recurring_sub_total(), $submission->get_discount_code(), true ), $rates ); |
|
61 | + $rates = getpaid_get_item_tax_rates($item, $submission->country, $submission->state); |
|
62 | + $rates = getpaid_filter_item_tax_rates($item, $rates); |
|
63 | + $taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item->get_id(), $item->get_sub_total(), $submission->get_discount_code(), false), $rates); |
|
64 | + $r_taxes = getpaid_calculate_item_taxes(getpaid_get_taxable_amount($item->get_id(), $item->get_recurring_sub_total(), $submission->get_discount_code(), true), $rates); |
|
65 | 65 | |
66 | - foreach ( $taxes as $name => $amount ) { |
|
67 | - $recurring = isset( $r_taxes[ $name ] ) ? $r_taxes[ $name ] : 0; |
|
68 | - $tax = getpaid_prepare_item_tax( $item, $name, $amount, $recurring ); |
|
66 | + foreach ($taxes as $name => $amount) { |
|
67 | + $recurring = isset($r_taxes[$name]) ? $r_taxes[$name] : 0; |
|
68 | + $tax = getpaid_prepare_item_tax($item, $name, $amount, $recurring); |
|
69 | 69 | |
70 | - if ( ! isset( $this->taxes[ $name ] ) ) { |
|
71 | - $this->taxes[ $name ] = $tax; |
|
70 | + if (!isset($this->taxes[$name])) { |
|
71 | + $this->taxes[$name] = $tax; |
|
72 | 72 | continue; |
73 | 73 | } |
74 | 74 | |
75 | - $this->taxes[ $name ]['initial_tax'] += $tax['initial_tax']; |
|
76 | - $this->taxes[ $name ]['recurring_tax'] += $tax['recurring_tax']; |
|
75 | + $this->taxes[$name]['initial_tax'] += $tax['initial_tax']; |
|
76 | + $this->taxes[$name]['recurring_tax'] += $tax['recurring_tax']; |
|
77 | 77 | |
78 | 78 | } |
79 | 79 | |
@@ -86,11 +86,11 @@ discard block |
||
86 | 86 | * @since 1.0.19 |
87 | 87 | * @return bool |
88 | 88 | */ |
89 | - public function has_digital_item( $submission ) { |
|
89 | + public function has_digital_item($submission) { |
|
90 | 90 | |
91 | - foreach ( $submission->get_items() as $item ) { |
|
91 | + foreach ($submission->get_items() as $item) { |
|
92 | 92 | |
93 | - if ( 'digital' == $item->get_vat_rule() ) { |
|
93 | + if ('digital' == $item->get_vat_rule()) { |
|
94 | 94 | return true; |
95 | 95 | } |
96 | 96 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | * @return bool |
107 | 107 | */ |
108 | 108 | public static function is_eu_store() { |
109 | - return self::is_eu_country( wpinv_get_default_country() ); |
|
109 | + return self::is_eu_country(wpinv_get_default_country()); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | /** |
@@ -116,8 +116,8 @@ discard block |
||
116 | 116 | * @since 1.0.19 |
117 | 117 | * @return bool |
118 | 118 | */ |
119 | - public static function is_eu_country( $country ) { |
|
120 | - return getpaid_is_eu_state( $country ) || getpaid_is_gst_country( $country ); |
|
119 | + public static function is_eu_country($country) { |
|
120 | + return getpaid_is_eu_state($country) || getpaid_is_gst_country($country); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | /** |
@@ -127,8 +127,8 @@ discard block |
||
127 | 127 | * @since 1.0.19 |
128 | 128 | * @return bool |
129 | 129 | */ |
130 | - public static function is_eu_transaction( $customer_country ) { |
|
131 | - return self::is_eu_country( $customer_country ) && self::is_eu_store(); |
|
130 | + public static function is_eu_transaction($customer_country) { |
|
131 | + return self::is_eu_country($customer_country) && self::is_eu_store(); |
|
132 | 132 | } |
133 | 133 | |
134 | 134 | /** |
@@ -138,12 +138,12 @@ discard block |
||
138 | 138 | * @since 1.0.19 |
139 | 139 | * @return string |
140 | 140 | */ |
141 | - public function get_vat_number( $submission ) { |
|
141 | + public function get_vat_number($submission) { |
|
142 | 142 | |
143 | 143 | // Retrieve from the posted number. |
144 | - $vat_number = $submission->get_field( 'wpinv_vat_number', 'billing' ); |
|
145 | - if ( ! empty( $vat_number ) ) { |
|
146 | - return wpinv_clean( $vat_number ); |
|
144 | + $vat_number = $submission->get_field('wpinv_vat_number', 'billing'); |
|
145 | + if (!empty($vat_number)) { |
|
146 | + return wpinv_clean($vat_number); |
|
147 | 147 | } |
148 | 148 | |
149 | 149 | // Retrieve from the invoice. |
@@ -157,12 +157,12 @@ discard block |
||
157 | 157 | * @since 1.0.19 |
158 | 158 | * @return string |
159 | 159 | */ |
160 | - public function get_company( $submission ) { |
|
160 | + public function get_company($submission) { |
|
161 | 161 | |
162 | 162 | // Retrieve from the posted data. |
163 | - $company = $submission->get_field( 'wpinv_company', 'billing' ); |
|
164 | - if ( ! empty( $company ) ) { |
|
165 | - return wpinv_clean( $company ); |
|
163 | + $company = $submission->get_field('wpinv_company', 'billing'); |
|
164 | + if (!empty($company)) { |
|
165 | + return wpinv_clean($company); |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | // Retrieve from the invoice. |
@@ -177,10 +177,10 @@ discard block |
||
177 | 177 | * @since 1.0.19 |
178 | 178 | * @return string |
179 | 179 | */ |
180 | - public function requires_vat( $ip_in_eu, $country_in_eu ) { |
|
180 | + public function requires_vat($ip_in_eu, $country_in_eu) { |
|
181 | 181 | |
182 | - $prevent_b2c = wpinv_get_option( 'vat_prevent_b2c_purchase' ); |
|
183 | - $prevent_b2c = ! empty( $prevent_b2c ); |
|
182 | + $prevent_b2c = wpinv_get_option('vat_prevent_b2c_purchase'); |
|
183 | + $prevent_b2c = !empty($prevent_b2c); |
|
184 | 184 | $is_eu = $ip_in_eu || $country_in_eu; |
185 | 185 | |
186 | 186 | return $prevent_b2c && $is_eu; |
@@ -192,45 +192,45 @@ discard block |
||
192 | 192 | * @param GetPaid_Payment_Form_Submission $submission |
193 | 193 | * @since 1.0.19 |
194 | 194 | */ |
195 | - public function validate_vat( $submission ) { |
|
195 | + public function validate_vat($submission) { |
|
196 | 196 | |
197 | - $in_eu = $this->is_eu_transaction( $submission->country ); |
|
197 | + $in_eu = $this->is_eu_transaction($submission->country); |
|
198 | 198 | |
199 | 199 | // Abort if we are not validating vat numbers. |
200 | - if ( ! $in_eu ) { |
|
200 | + if (!$in_eu) { |
|
201 | 201 | return; |
202 | 202 | } |
203 | 203 | |
204 | 204 | // Prepare variables. |
205 | - $vat_number = $this->get_vat_number( $submission ); |
|
205 | + $vat_number = $this->get_vat_number($submission); |
|
206 | 206 | $ip_country = getpaid_get_ip_country(); |
207 | - $is_eu = $this->is_eu_country( $submission->country ); |
|
208 | - $is_ip_eu = $this->is_eu_country( $ip_country ); |
|
207 | + $is_eu = $this->is_eu_country($submission->country); |
|
208 | + $is_ip_eu = $this->is_eu_country($ip_country); |
|
209 | 209 | |
210 | 210 | // Maybe abort early for initial fetches. |
211 | - if ( $submission->is_initial_fetch() && empty( $vat_number ) ) { |
|
211 | + if ($submission->is_initial_fetch() && empty($vat_number)) { |
|
212 | 212 | return; |
213 | 213 | } |
214 | 214 | |
215 | 215 | // If we're preventing business to consumer purchases, |
216 | - if ( $this->requires_vat( $is_ip_eu, $is_eu ) && empty( $vat_number ) ) { |
|
216 | + if ($this->requires_vat($is_ip_eu, $is_eu) && empty($vat_number)) { |
|
217 | 217 | |
218 | 218 | // Ensure that a vat number has been specified. |
219 | 219 | throw new Exception( |
220 | - __( 'Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing' ) |
|
220 | + __('Please enter your VAT number to verify your purchase is by an EU business.', 'invoicing') |
|
221 | 221 | ); |
222 | 222 | |
223 | 223 | } |
224 | 224 | |
225 | - if ( empty( $vat_number ) ) { |
|
225 | + if (empty($vat_number)) { |
|
226 | 226 | return; |
227 | 227 | } |
228 | 228 | |
229 | - if ( wpinv_should_validate_vat_number() && ! wpinv_validate_vat_number( $vat_number, $submission->country ) ) { |
|
230 | - throw new Exception( __( 'Your VAT number is invalid', 'invoicing' ) ); |
|
229 | + if (wpinv_should_validate_vat_number() && !wpinv_validate_vat_number($vat_number, $submission->country)) { |
|
230 | + throw new Exception(__('Your VAT number is invalid', 'invoicing')); |
|
231 | 231 | } |
232 | 232 | |
233 | - if ( wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option( 'vat_same_country_rule', 'vat_too' ) ) { |
|
233 | + if (wpinv_default_billing_country() == $submission->country && 'vat_too' == wpinv_get_option('vat_same_country_rule', 'vat_too')) { |
|
234 | 234 | return; |
235 | 235 | } |
236 | 236 |
@@ -24,64 +24,64 @@ discard block |
||
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | - // Fires before printing a line item column. |
|
28 | - do_action( "getpaid_form_cart_item_before_$key", $item, $form ); |
|
27 | + // Fires before printing a line item column. |
|
28 | + do_action( "getpaid_form_cart_item_before_$key", $item, $form ); |
|
29 | 29 | |
30 | - // Item name. |
|
31 | - if ( 'name' == $key ) { |
|
30 | + // Item name. |
|
31 | + if ( 'name' == $key ) { |
|
32 | 32 | |
33 | - // Display the name. |
|
34 | - echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>'; |
|
33 | + // Display the name. |
|
34 | + echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>'; |
|
35 | 35 | |
36 | - // And an optional description. |
|
36 | + // And an optional description. |
|
37 | 37 | $description = $item->get_description(); |
38 | 38 | |
39 | 39 | if ( ! empty( $description ) ) { |
40 | 40 | $description = wp_kses_post( $description ); |
41 | 41 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
42 | - } |
|
42 | + } |
|
43 | 43 | |
44 | - // Price help text. |
|
44 | + // Price help text. |
|
45 | 45 | $description = getpaid_item_recurring_price_help_text( $item, $currency ); |
46 | 46 | if ( $description ) { |
47 | 47 | echo "<small class='getpaid-form-item-price-desc form-text text-muted pr-2 m-0'>$description</small>"; |
48 | - } |
|
48 | + } |
|
49 | 49 | |
50 | - } |
|
50 | + } |
|
51 | 51 | |
52 | - // Item price. |
|
53 | - if ( 'price' == $key ) { |
|
52 | + // Item price. |
|
53 | + if ( 'price' == $key ) { |
|
54 | 54 | |
55 | - // Set the currency position. |
|
56 | - $position = wpinv_currency_position(); |
|
55 | + // Set the currency position. |
|
56 | + $position = wpinv_currency_position(); |
|
57 | 57 | |
58 | - if ( $position == 'left_space' ) { |
|
59 | - $position = 'left'; |
|
60 | - } |
|
58 | + if ( $position == 'left_space' ) { |
|
59 | + $position = 'left'; |
|
60 | + } |
|
61 | 61 | |
62 | - if ( $position == 'right_space' ) { |
|
63 | - $position = 'right'; |
|
64 | - } |
|
62 | + if ( $position == 'right_space' ) { |
|
63 | + $position = 'right'; |
|
64 | + } |
|
65 | 65 | |
66 | - if ( $item->user_can_set_their_price() ) { |
|
67 | - $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() ); |
|
68 | - $minimum = (float) $item->get_minimum_price(); |
|
69 | - $validate_minimum = ''; |
|
70 | - $class = ''; |
|
71 | - $data_minimum = ''; |
|
66 | + if ( $item->user_can_set_their_price() ) { |
|
67 | + $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() ); |
|
68 | + $minimum = (float) $item->get_minimum_price(); |
|
69 | + $validate_minimum = ''; |
|
70 | + $class = ''; |
|
71 | + $data_minimum = ''; |
|
72 | 72 | |
73 | - if ( $minimum > 0 ) { |
|
74 | - $validate_minimum = sprintf( |
|
75 | - esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ), |
|
76 | - sanitize_text_field( wpinv_price( $minimum, $currency ) ) |
|
77 | - ); |
|
73 | + if ( $minimum > 0 ) { |
|
74 | + $validate_minimum = sprintf( |
|
75 | + esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ), |
|
76 | + sanitize_text_field( wpinv_price( $minimum, $currency ) ) |
|
77 | + ); |
|
78 | 78 | |
79 | - $class = 'getpaid-validate-minimum-amount'; |
|
79 | + $class = 'getpaid-validate-minimum-amount'; |
|
80 | 80 | |
81 | - $data_minimum = "data-minimum-amount='$minimum'"; |
|
82 | - } |
|
81 | + $data_minimum = "data-minimum-amount='$minimum'"; |
|
82 | + } |
|
83 | 83 | |
84 | - ?> |
|
84 | + ?> |
|
85 | 85 | <div class="input-group input-group-sm"> |
86 | 86 | <?php if( 'left' == $position ) : ?> |
87 | 87 | <div class="input-group-prepend"> |
@@ -105,37 +105,37 @@ discard block |
||
105 | 105 | </div> |
106 | 106 | |
107 | 107 | <?php |
108 | - } else { |
|
109 | - echo wpinv_price( $item->get_price(), $currency ); |
|
110 | - ?> |
|
108 | + } else { |
|
109 | + echo wpinv_price( $item->get_price(), $currency ); |
|
110 | + ?> |
|
111 | 111 | <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'> |
112 | 112 | <?php |
113 | - } |
|
114 | - } |
|
113 | + } |
|
114 | + } |
|
115 | 115 | |
116 | - // Item quantity. |
|
117 | - if ( 'quantity' == $key ) { |
|
116 | + // Item quantity. |
|
117 | + if ( 'quantity' == $key ) { |
|
118 | 118 | |
119 | - if ( $item->allows_quantities() ) { |
|
120 | - ?> |
|
119 | + if ( $item->allows_quantities() ) { |
|
120 | + ?> |
|
121 | 121 | <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='text' style='width: 64px; line-height: 1; min-height: 35px;' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity(); ?>' min='1' required> |
122 | 122 | <?php |
123 | - } else { |
|
124 | - echo (float) $item->get_quantity(); |
|
125 | - echo ' '; |
|
126 | - ?> |
|
123 | + } else { |
|
124 | + echo (float) $item->get_quantity(); |
|
125 | + echo ' '; |
|
126 | + ?> |
|
127 | 127 | <input type='hidden' name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' class='getpaid-item-quantity-input' value='<?php echo (float) $item->get_quantity(); ?>'> |
128 | 128 | <?php |
129 | - } |
|
130 | - } |
|
129 | + } |
|
130 | + } |
|
131 | 131 | |
132 | - // Item sub total. |
|
133 | - if ( 'subtotal' == $key ) { |
|
134 | - echo wpinv_price( $item->get_sub_total(), $currency ); |
|
135 | - } |
|
132 | + // Item sub total. |
|
133 | + if ( 'subtotal' == $key ) { |
|
134 | + echo wpinv_price( $item->get_sub_total(), $currency ); |
|
135 | + } |
|
136 | 136 | |
137 | - do_action( "getpaid_payment_form_cart_item_$key", $item, $form ); |
|
138 | - ?> |
|
137 | + do_action( "getpaid_payment_form_cart_item_$key", $item, $form ); |
|
138 | + ?> |
|
139 | 139 | |
140 | 140 | </div> |
141 | 141 |
@@ -7,116 +7,116 @@ discard block |
||
7 | 7 | * @version 1.0.19 |
8 | 8 | */ |
9 | 9 | |
10 | -defined( 'ABSPATH' ) || exit; |
|
10 | +defined('ABSPATH') || exit; |
|
11 | 11 | |
12 | -do_action( 'getpaid_before_payment_form_cart_item', $form, $item ); |
|
12 | +do_action('getpaid_before_payment_form_cart_item', $form, $item); |
|
13 | 13 | |
14 | 14 | $currency = $form->get_currency(); |
15 | 15 | |
16 | 16 | ?> |
17 | -<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?> border-bottom py-2 px-3'> |
|
17 | +<div class='getpaid-payment-form-items-cart-item getpaid-<?php echo $item->is_required() ? 'required' : 'selectable'; ?> item-<?php echo $item->get_id(); ?> border-bottom py-2 px-3'> |
|
18 | 18 | |
19 | 19 | <div class="form-row needs-validation"> |
20 | 20 | |
21 | - <?php foreach ( array_keys( $columns ) as $key ) : ?> |
|
21 | + <?php foreach (array_keys($columns) as $key) : ?> |
|
22 | 22 | |
23 | - <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> position-relative getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?> getpaid-form-cart-item-<?php echo sanitize_html_class( $key ); ?>-<?php echo $item->get_id(); ?>"> |
|
23 | + <div class="<?php echo 'name' == $key ? 'col-12 col-sm-6' : 'col-12 col-sm' ?> position-relative getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?> getpaid-form-cart-item-<?php echo sanitize_html_class($key); ?>-<?php echo $item->get_id(); ?>"> |
|
24 | 24 | |
25 | 25 | <?php |
26 | 26 | |
27 | 27 | // Fires before printing a line item column. |
28 | - do_action( "getpaid_form_cart_item_before_$key", $item, $form ); |
|
28 | + do_action("getpaid_form_cart_item_before_$key", $item, $form); |
|
29 | 29 | |
30 | 30 | // Item name. |
31 | - if ( 'name' == $key ) { |
|
31 | + if ('name' == $key) { |
|
32 | 32 | |
33 | 33 | // Display the name. |
34 | - echo '<div class="mb-1">' . sanitize_text_field( $item->get_name() ) . '</div>'; |
|
34 | + echo '<div class="mb-1">' . sanitize_text_field($item->get_name()) . '</div>'; |
|
35 | 35 | |
36 | 36 | // And an optional description. |
37 | 37 | $description = $item->get_description(); |
38 | 38 | |
39 | - if ( ! empty( $description ) ) { |
|
40 | - $description = wp_kses_post( $description ); |
|
39 | + if (!empty($description)) { |
|
40 | + $description = wp_kses_post($description); |
|
41 | 41 | echo "<small class='form-text text-muted pr-2 m-0'>$description</small>"; |
42 | 42 | } |
43 | 43 | |
44 | 44 | // Price help text. |
45 | - $description = getpaid_item_recurring_price_help_text( $item, $currency ); |
|
46 | - if ( $description ) { |
|
45 | + $description = getpaid_item_recurring_price_help_text($item, $currency); |
|
46 | + if ($description) { |
|
47 | 47 | echo "<small class='getpaid-form-item-price-desc form-text text-muted pr-2 m-0'>$description</small>"; |
48 | 48 | } |
49 | 49 | |
50 | 50 | } |
51 | 51 | |
52 | 52 | // Item price. |
53 | - if ( 'price' == $key ) { |
|
53 | + if ('price' == $key) { |
|
54 | 54 | |
55 | 55 | // Set the currency position. |
56 | 56 | $position = wpinv_currency_position(); |
57 | 57 | |
58 | - if ( $position == 'left_space' ) { |
|
58 | + if ($position == 'left_space') { |
|
59 | 59 | $position = 'left'; |
60 | 60 | } |
61 | 61 | |
62 | - if ( $position == 'right_space' ) { |
|
62 | + if ($position == 'right_space') { |
|
63 | 63 | $position = 'right'; |
64 | 64 | } |
65 | 65 | |
66 | - if ( $item->user_can_set_their_price() ) { |
|
67 | - $price = max( (float) $item->get_price(), (float) $item->get_minimum_price() ); |
|
66 | + if ($item->user_can_set_their_price()) { |
|
67 | + $price = max((float) $item->get_price(), (float) $item->get_minimum_price()); |
|
68 | 68 | $minimum = (float) $item->get_minimum_price(); |
69 | 69 | $validate_minimum = ''; |
70 | 70 | $class = ''; |
71 | 71 | $data_minimum = ''; |
72 | 72 | |
73 | - if ( $minimum > 0 ) { |
|
73 | + if ($minimum > 0) { |
|
74 | 74 | $validate_minimum = sprintf( |
75 | - esc_attr__( 'The minimum allowed amount is %s', 'invoicing' ), |
|
76 | - sanitize_text_field( wpinv_price( $minimum, $currency ) ) |
|
75 | + esc_attr__('The minimum allowed amount is %s', 'invoicing'), |
|
76 | + sanitize_text_field(wpinv_price($minimum, $currency)) |
|
77 | 77 | ); |
78 | 78 | |
79 | 79 | $class = 'getpaid-validate-minimum-amount'; |
80 | 80 | |
81 | - $data_minimum = "data-minimum-amount='$minimum'"; |
|
81 | + $data_minimum = "data-minimum-amount='$minimum'"; |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | ?> |
85 | 85 | <div class="input-group input-group-sm"> |
86 | - <?php if( 'left' == $position ) : ?> |
|
86 | + <?php if ('left' == $position) : ?> |
|
87 | 87 | <div class="input-group-prepend"> |
88 | - <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span> |
|
88 | + <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span> |
|
89 | 89 | </div> |
90 | 90 | <?php endif; ?> |
91 | 91 | |
92 | - <input type="text" <?php echo $data_minimum; ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr( $item->get_minimum_price() ); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo $class; ?>" style="width: 64px; line-height: 1; min-height: 35px;"> |
|
92 | + <input type="text" <?php echo $data_minimum; ?> name="getpaid-items[<?php echo (int) $item->get_id(); ?>][price]" value="<?php echo $price; ?>" placeholder="<?php echo esc_attr($item->get_minimum_price()); ?>" class="getpaid-item-price-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border <?php echo $class; ?>" style="width: 64px; line-height: 1; min-height: 35px;"> |
|
93 | 93 | |
94 | - <?php if ( ! empty( $validate_minimum ) ) : ?> |
|
94 | + <?php if (!empty($validate_minimum)) : ?> |
|
95 | 95 | <div class="invalid-tooltip"> |
96 | 96 | <?php echo $validate_minimum; ?> |
97 | 97 | </div> |
98 | 98 | <?php endif; ?> |
99 | 99 | |
100 | - <?php if( 'left' != $position ) : ?> |
|
100 | + <?php if ('left' != $position) : ?> |
|
101 | 101 | <div class="input-group-append"> |
102 | - <span class="input-group-text"><?php echo wpinv_currency_symbol( $currency ); ?></span> |
|
102 | + <span class="input-group-text"><?php echo wpinv_currency_symbol($currency); ?></span> |
|
103 | 103 | </div> |
104 | 104 | <?php endif; ?> |
105 | 105 | </div> |
106 | 106 | |
107 | 107 | <?php |
108 | 108 | } else { |
109 | - echo wpinv_price( $item->get_price(), $currency ); |
|
109 | + echo wpinv_price($item->get_price(), $currency); |
|
110 | 110 | ?> |
111 | - <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr( $item->get_price() ); ?>'> |
|
111 | + <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][price]' type='hidden' class='getpaid-item-price-input' value='<?php echo esc_attr($item->get_price()); ?>'> |
|
112 | 112 | <?php |
113 | 113 | } |
114 | 114 | } |
115 | 115 | |
116 | 116 | // Item quantity. |
117 | - if ( 'quantity' == $key ) { |
|
117 | + if ('quantity' == $key) { |
|
118 | 118 | |
119 | - if ( $item->allows_quantities() ) { |
|
119 | + if ($item->allows_quantities()) { |
|
120 | 120 | ?> |
121 | 121 | <input name='getpaid-items[<?php echo (int) $item->get_id(); ?>][quantity]' type='text' style='width: 64px; line-height: 1; min-height: 35px;' class='getpaid-item-quantity-input p-1 align-middle font-weight-normal shadow-none m-0 rounded-0 text-center border' value='<?php echo (float) $item->get_quantity(); ?>' min='1' required> |
122 | 122 | <?php |
@@ -130,11 +130,11 @@ discard block |
||
130 | 130 | } |
131 | 131 | |
132 | 132 | // Item sub total. |
133 | - if ( 'subtotal' == $key ) { |
|
134 | - echo wpinv_price( $item->get_sub_total(), $currency ); |
|
133 | + if ('subtotal' == $key) { |
|
134 | + echo wpinv_price($item->get_sub_total(), $currency); |
|
135 | 135 | } |
136 | 136 | |
137 | - do_action( "getpaid_payment_form_cart_item_$key", $item, $form ); |
|
137 | + do_action("getpaid_payment_form_cart_item_$key", $item, $form); |
|
138 | 138 | ?> |
139 | 139 | |
140 | 140 | </div> |
@@ -145,4 +145,4 @@ discard block |
||
145 | 145 | |
146 | 146 | </div> |
147 | 147 | <?php |
148 | -do_action( 'getpaid_payment_form_cart_item', $form, $item ); |
|
148 | +do_action('getpaid_payment_form_cart_item', $form, $item); |