Skip to content

Commit

Permalink
Fix issue with billing country and ic DPH validation
Browse files Browse the repository at this point in the history
  • Loading branch information
vyskoczilova committed Nov 15, 2023
1 parent 0070708 commit 9baad01
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
18 changes: 12 additions & 6 deletions includes/filters-actions.php
Original file line number Diff line number Diff line change
Expand Up @@ -231,16 +231,16 @@ function woolab_icdic_checkout_field_process() {
// Check if in EU
if ( $countries->isCountryCodeInEU( $country ) ) {

// Match VAT country prefix and country code.
// @since 1.7.3.
if ( substr( $dic, 0, 2) != $country ) {
wc_add_notice( __( 'The billing country does not correspond to the country of the VAT number.', 'woolab-ic-dic' ), 'error' );
}

// If Validate in VIES
// Slovak DIC cannot (and shouldn't) be validated in VIES
if ( woolab_icdic_vies_check() && $country != 'SK' ) {

// Match VAT country prefix and country code.
// @since 1.7.3.
if ( apply_filters( 'woolab_icdic_check_billing_country_and_dic', true ) && substr( $dic, 0, 2) != $country ) {
wc_add_notice( __( 'The billing country does not correspond to the country of the VAT number.', 'woolab-ic-dic' ), 'error' );
}

$validator = new Validator();

if ( ! $validator->validateVatNumberFormat( $dic )) {
Expand Down Expand Up @@ -287,6 +287,12 @@ function woolab_icdic_checkout_field_process() {
$dic = preg_replace('/\s+/', '', $_POST['billing_dic']);
$dic_dph = preg_replace('/\s+/', '', $_POST['billing_dic_dph']);

// Match VAT country prefix and country code.
// @since 1.7.4.
if ( apply_filters( 'woolab_icdic_check_billing_country_and_dic', true ) && substr( $dic_dph, 0, 2) != $country ) {
wc_add_notice( __( 'The billing country does not correspond to the country of the VAT number.', 'woolab-ic-dic' ), 'error' );
}

// Verify IC DPH
// If Validate in VIES
if ( woolab_icdic_vies_check() ) {
Expand Down
2 changes: 2 additions & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,9 @@ Either post it on [GitHub](https://github.com/vyskoczilova/kybernaut-ic-dic) or

= 1.7.4 () =

* Fix: Additional check - billing country and VAT country prefix must match (paid by a supporter) for SK.
* Feature: Added compatibility with [Fluid Checkout for WooCommerce - Lite](https://wordpress.org/plugins/fluid-checkout/).
* Feature: Added a filter `woolab_icdic_check_billing_country_and_dic` allowing to disable the feature introduced in 1.7.3.

= 1.7.3 (2023-10-08) =

Expand Down
4 changes: 2 additions & 2 deletions woolab-ic-dic.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Kybernaut IC DIC
Plugin URI: https://kybernaut.cz/pluginy/kybernaut-ic-dic
Description: Adds Czech Company & VAT numbers (IČO & DIČ) to WooCommerce billing fields and verifies if data are correct.
Version: 1.7.4-rc.1
Version: 1.7.4-rc-2
Author: Karolína Vyskočilová
Author URI: https://kybernaut.cz
Text Domain: woolab-ic-dic
Expand All @@ -29,7 +29,7 @@
define( 'WOOLAB_IC_DIC_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
define( 'WOOLAB_IC_DIC_ABSPATH', dirname( __FILE__ ) . '/' );
define( 'WOOLAB_IC_DIC_URL', plugin_dir_url( __FILE__ ) );
define( 'WOOLAB_IC_DIC_VERSION', '1.7.4-rc.1' );
define( 'WOOLAB_IC_DIC_VERSION', '1.7.4-rc-2' );

// Check if WooCommerce active
function woolab_icdic_init() {
Expand Down

0 comments on commit 9baad01

Please sign in to comment.