Skip to content

Commit e674c43

Browse files
author
WooCommerce
committed
Updates to 2.9.14
1 parent 4156f15 commit e674c43

8 files changed

+104
-30
lines changed

changelog.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
*** EU VAT Number Changelog ***
22

3+
2025-02-18 - version 2.9.14
4+
* Fix - VAT application and exemption logic for domestic transactions for shortcode checkout.
5+
* Fix - Add support for Belgian VAT numbers that begin with `1`.
6+
* Dev - Bump WooCommerce "tested up to" version 9.7.
7+
* Dev - Bump WooCommerce minimum supported version to 9.5.
8+
* Dev - Bump WordPress minimum supported version to 6.6.
9+
* Dev - Add the WordPress Plugin Check GitHub Action.
10+
311
2025-01-20 - version 2.9.13
412
* Fix - Resolved PHP notice caused by loading localization code too early on WordPress 6.7.0+.
513
* Dev - Bump WooCommerce "tested up to" version 9.6.

includes/class-wc-eu-vat-admin.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ public static function output() {
243243
<td>
244244
<?php
245245
if ( ! $data->validated ) {
246-
echo '<span class="tips" data-tip="' . wc_sanitize_tooltip( __( 'Validation was not possible', 'woocommerce-eu-vat-number' ) ) . '">?<span>';
246+
echo '<span class="tips" data-tip="' . wc_sanitize_tooltip( __( 'Validation was not possible', 'woocommerce-eu-vat-number' ) ) . '">?<span>'; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
247247
} else {
248248
echo $data->valid ? '&#10004;' : '&#10008;';
249249
}

includes/class-wc-eu-vat-number.php

Lines changed: 70 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class WC_EU_VAT_Number {
3232
*/
3333
private static $country_codes_patterns = array(
3434
'AT' => 'U[A-Z\d]{8}',
35-
'BE' => '0\d{9}',
35+
'BE' => '[01]\d{9}',
3636
'BG' => '\d{9,10}',
3737
'CY' => '\d{8}[A-Z]',
3838
'CZ' => '\d{8,10}',
@@ -294,6 +294,26 @@ public static function get_vat_number_prefix( $country ) {
294294
return $vat_prefix;
295295
}
296296

297+
/**
298+
* Extract the 2-letter country code from a VAT number.
299+
*
300+
* @param string $vat_number The VAT number to extract the country code from.
301+
*
302+
* @return string|null The 2-letter country code if found, or null if not.
303+
*/
304+
public static function get_country_code_from_vat( $vat_number ) {
305+
// Define the regex pattern.
306+
$pattern = '/^[A-Z]{2}/';
307+
308+
// Perform the regex match.
309+
if ( preg_match( $pattern, $vat_number, $matches ) ) {
310+
return $matches[0]; // Return the matched country code.
311+
}
312+
313+
// Return null if no match is found.
314+
return null;
315+
}
316+
297317
/**
298318
* Remove unwanted chars and the prefix from a VAT number.
299319
*
@@ -496,6 +516,52 @@ public static function is_base_country_match( $billing_country, $shipping_countr
496516
return in_array( $base_country, array( $billing_country, $shipping_country ), true );
497517
}
498518

519+
/**
520+
* Set tax exception based on the vat number and store country.
521+
*
522+
* @param string $vat_number VAT Number.
523+
* @param string $exempt Boolean to exempt VAT.
524+
*
525+
* @return void
526+
*/
527+
public static function maybe_apply_vat_exemption( $vat_number = '', $exempt = null ) {
528+
if ( empty( $vat_number ) ) {
529+
return;
530+
}
531+
532+
$vat_country_code = self::get_country_code_from_vat( $vat_number );
533+
534+
if ( ! $vat_country_code ) {
535+
return;
536+
}
537+
538+
$store_country_code = WC()->countries->get_base_country();
539+
540+
/**
541+
* Filters the VAT exception.
542+
*
543+
* @since 2.9.14
544+
*
545+
* @param bool $exempt Is VAT exempt?.
546+
* @param bool $store_country_code Store's location country code.
547+
* @param string $vat_country_code Country code from the VAT number.
548+
*/
549+
$exempt = apply_filters( 'woocommerce_eu_vat_maybe_apply_vat_exemption', $exempt, $store_country_code, $vat_country_code );
550+
$is_valid_condition = $exempt;
551+
552+
$should_deduct_in_base = 'yes' === get_option( 'woocommerce_eu_vat_number_deduct_in_base', 'yes' );
553+
554+
if ( $vat_country_code === $store_country_code && $should_deduct_in_base ) {
555+
$is_valid_condition = true;
556+
} elseif ( $vat_country_code === $store_country_code ) {
557+
$is_valid_condition = false;
558+
}
559+
560+
if ( $is_valid_condition ) {
561+
WC()->customer->set_is_vat_exempt( $exempt );
562+
}
563+
}
564+
499565
/**
500566
* Set tax exception based on countries.
501567
*
@@ -834,14 +900,14 @@ public static function validate_checkout( $data, $doing_checkout = false ) {
834900
self::validate( $billing_vat_number, $country, $postcode );
835901

836902
if ( true === (bool) self::$data['validation']['valid'] ) {
837-
self::maybe_set_vat_exempt( true, $billing_country, $shipping_country );
903+
self::maybe_apply_vat_exemption( $billing_vat_number, true );
838904
} else {
839905
switch ( $fail_handler ) {
840906
case 'accept_with_vat':
841-
self::maybe_set_vat_exempt( false, $billing_country, $shipping_country );
907+
self::maybe_apply_vat_exemption( $billing_vat_number, false );
842908
break;
843909
case 'accept':
844-
self::maybe_set_vat_exempt( true, $billing_country, $shipping_country );
910+
self::maybe_apply_vat_exemption( $billing_vat_number, true );
845911
break;
846912
default:
847913
if ( false === self::$data['validation']['valid'] ) {

includes/class-wc-eu-vat-report-eu-vat.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ public function get_main_chart() {
342342
<th><?php esc_html_e( 'Country', 'woocommerce-eu-vat-number' ); ?></th>
343343
<th><?php esc_html_e( 'Code', 'woocommerce-eu-vat-number' ); ?></th>
344344
<th><?php esc_html_e( 'Tax Rate', 'woocommerce-eu-vat-number' ); ?></th>
345-
<th class="total_row"><?php esc_html_e( 'Amount', 'woocommerce-eu-vat-number-eu-vat' ); ?></th>
345+
<th class="total_row"><?php esc_html_e( 'Amount', 'woocommerce-eu-vat-number' ); ?></th>
346346
<th class="total_row"><?php esc_html_e( 'Refunded Amount', 'woocommerce-eu-vat-number' ); ?></th>
347347
<th class="total_row"><?php esc_html_e( 'Final Amount', 'woocommerce-eu-vat-number' ); ?></th>
348348
<th class="total_row"><?php esc_html_e( 'Tax Amount', 'woocommerce-eu-vat-number' ); ?></th>

includes/class-wc-eu-vat-uk-number-api.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function check_vat_number( $vat_number ) {
5454
);
5555

5656
if ( is_wp_error( $response ) ) {
57-
throw new Exception( $response->get_error_message() );
57+
throw new Exception( esc_html( $response->get_error_message() ) );
5858
}
5959

6060
// Check if VAT number is valid.

includes/class-wc-non-eu-sales-report.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,7 @@ public function get_main_chart() {
322322
<th><?php esc_html_e( 'Country', 'woocommerce-eu-vat-number' ); ?></th>
323323
<th><?php esc_html_e( 'Code', 'woocommerce-eu-vat-number' ); ?></th>
324324
<th><?php esc_html_e( 'Tax Rate', 'woocommerce-eu-vat-number' ); ?></th>
325-
<th class="total_row"><?php esc_html_e( 'Amount', 'woocommerce-eu-vat-number-eu-vat' ); ?></th>
325+
<th class="total_row"><?php esc_html_e( 'Amount', 'woocommerce-eu-vat-number' ); ?></th>
326326
<th class="total_row"><?php esc_html_e( 'Refunded Amount', 'woocommerce-eu-vat-number' ); ?></th>
327327
<th class="total_row"><?php esc_html_e( 'Final Amount', 'woocommerce-eu-vat-number' ); ?></th>
328328
<th class="total_row"><?php esc_html_e( 'Tax Amount', 'woocommerce-eu-vat-number' ); ?></th>

languages/woocommerce-eu-vat-number.pot

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# This file is distributed under the GNU General Public License v3.0.
33
msgid ""
44
msgstr ""
5-
"Project-Id-Version: WooCommerce EU VAT Number 2.9.13\n"
5+
"Project-Id-Version: WooCommerce EU VAT Number 2.9.14\n"
66
"Report-Msgid-Bugs-To: "
77
"https://wordpress.org/support/plugin/woocommerce-eu-vat-number\n"
8-
"POT-Creation-Date: 2025-01-20 13:49:21+00:00\n"
8+
"POT-Creation-Date: 2025-02-18 15:14:58+00:00\n"
99
"MIME-Version: 1.0\n"
1010
"Content-Type: text/plain; charset=utf-8\n"
1111
"Content-Transfer-Encoding: 8bit\n"
@@ -25,8 +25,8 @@ msgstr ""
2525
#: includes/class-wc-eu-vat-my-account.php:276
2626
#: includes/class-wc-eu-vat-my-account.php:293
2727
#: includes/class-wc-eu-vat-number.php:224
28-
#: includes/class-wc-eu-vat-number.php:852
29-
#: includes/class-wc-eu-vat-number.php:875
28+
#: includes/class-wc-eu-vat-number.php:918
29+
#: includes/class-wc-eu-vat-number.php:941
3030
#: includes/class-wc-eu-vat-privacy.php:157
3131
#: includes/class-wc-eu-vat-report-ec-sales-list.php:216
3232
#: templates/my-account/my-vat-number.php:22
@@ -91,15 +91,15 @@ msgstr ""
9191

9292
#: includes/class-wc-eu-vat-admin.php:424
9393
#: includes/class-wc-eu-vat-my-account.php:270
94-
#: includes/class-wc-eu-vat-number.php:854
95-
#: includes/class-wc-eu-vat-number.php:876
94+
#: includes/class-wc-eu-vat-number.php:920
95+
#: includes/class-wc-eu-vat-number.php:942
9696
msgid "billing"
9797
msgstr ""
9898

9999
#: includes/class-wc-eu-vat-admin.php:428
100100
#: includes/class-wc-eu-vat-my-account.php:270
101-
#: includes/class-wc-eu-vat-number.php:854
102-
#: includes/class-wc-eu-vat-number.php:876
101+
#: includes/class-wc-eu-vat-number.php:920
102+
#: includes/class-wc-eu-vat-number.php:942
103103
msgid "shipping"
104104
msgstr ""
105105

@@ -189,45 +189,45 @@ msgstr ""
189189
msgid "VAT number updated successfully!"
190190
msgstr ""
191191

192-
#: includes/class-wc-eu-vat-number.php:337
192+
#: includes/class-wc-eu-vat-number.php:357
193193
msgid "VAT number is required."
194194
msgstr ""
195195

196-
#: includes/class-wc-eu-vat-number.php:355
196+
#: includes/class-wc-eu-vat-number.php:375
197197
msgid "The VAT number is incomplete."
198198
msgstr ""
199199

200-
#: includes/class-wc-eu-vat-number.php:361
200+
#: includes/class-wc-eu-vat-number.php:381
201201
#. translators: %1$s - VAT number field label, %2$s - VAT Number from user,
202202
#. %3$s - Billing country.
203203
msgid ""
204204
"You have entered an invalid country code for %1$s (%2$s) for your country "
205205
"(%3$s)."
206206
msgstr ""
207207

208-
#: includes/class-wc-eu-vat-number.php:375
209-
#: includes/class-wc-eu-vat-number.php:393
208+
#: includes/class-wc-eu-vat-number.php:395
209+
#: includes/class-wc-eu-vat-number.php:413
210210
#: includes/vies/class-vies-client.php:92
211211
msgid "Error communicating with the VAT validation server - please try again."
212212
msgstr ""
213213

214-
#: includes/class-wc-eu-vat-number.php:708
214+
#: includes/class-wc-eu-vat-number.php:774
215215
#. translators: %s: VAT Number
216216
msgid "VAT Number: %s"
217217
msgstr ""
218218

219-
#: includes/class-wc-eu-vat-number.php:851
219+
#: includes/class-wc-eu-vat-number.php:917
220220
#. translators: 1: VAT number field label, 2: VAT Number, 3: Address type, 4:
221221
#. Country
222222
msgid "You have entered an invalid %1$s (%2$s) for your %3$s country (%4$s)."
223223
msgstr ""
224224

225-
#: includes/class-wc-eu-vat-number.php:874
225+
#: includes/class-wc-eu-vat-number.php:940
226226
#. translators: 1: VAT number field label, 2: Address type, 3: Billing country
227227
msgid "%1$s is a required field for your %2$s country (%3$s)."
228228
msgstr ""
229229

230-
#: includes/class-wc-eu-vat-number.php:893
230+
#: includes/class-wc-eu-vat-number.php:959
231231
#. translators: 1: Ip Address.
232232
msgid ""
233233
"Your IP Address (%1$s) does not match your billing country (%2$s). European "

woocommerce-eu-vat-number.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
* Requires Plugins: woocommerce
55
* Plugin URI: https://woocommerce.com/products/eu-vat-number/
66
* Description: The EU VAT Number extension lets you collect and validate EU VAT numbers during checkout to identify B2B transactions verses B2C. IP Addresses can also be validated to ensure they match the billing address. EU businesses with a valid VAT number can have their VAT removed prior to payment.
7-
* Version: 2.9.13
7+
* Version: 2.9.14
88
* Author: WooCommerce
99
* Author URI: https://woocommerce.com/
1010
* Text Domain: woocommerce-eu-vat-number
1111
* Domain Path: /languages
12-
* Requires at least: 6.5
12+
* Requires at least: 6.6
1313
* Tested up to: 6.7
14-
* WC requires at least: 9.4
15-
* WC tested up to: 9.6
14+
* WC requires at least: 9.5
15+
* WC tested up to: 9.7
1616
* Requires PHP: 7.4
1717
* PHP tested up to: 8.3
1818
*
@@ -26,7 +26,7 @@
2626

2727
// phpcs:disable WordPress.Files.FileName
2828

29-
define( 'WC_EU_VAT_VERSION', '2.9.13' ); // WRCS: DEFINED_VERSION.
29+
define( 'WC_EU_VAT_VERSION', '2.9.14' ); // WRCS: DEFINED_VERSION.
3030
define( 'WC_EU_VAT_FILE', __FILE__ );
3131
define( 'WC_EU_ABSPATH', __DIR__ . '/' );
3232
define( 'WC_EU_VAT_PLUGIN_URL', untrailingslashit( plugins_url( basename( plugin_dir_path( __FILE__ ) ), basename( __FILE__ ) ) ) );

0 commit comments

Comments
 (0)