diff --git a/includes/filters-actions.php b/includes/filters-actions.php index a2a46af..b10f806 100644 --- a/includes/filters-actions.php +++ b/includes/filters-actions.php @@ -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 )) { @@ -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() ) { diff --git a/readme.txt b/readme.txt index 942aba8..2389e32 100644 --- a/readme.txt +++ b/readme.txt @@ -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) = diff --git a/woolab-ic-dic.php b/woolab-ic-dic.php index d069327..e948333 100644 --- a/woolab-ic-dic.php +++ b/woolab-ic-dic.php @@ -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 @@ -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() {