diff --git a/eu-vat-for-woocommerce.php b/eu-vat-for-woocommerce.php index aeefce1..f79598b 100644 --- a/eu-vat-for-woocommerce.php +++ b/eu-vat-for-woocommerce.php @@ -3,7 +3,7 @@ Plugin Name: EU/UK VAT for WooCommerce Plugin URI: https://wpfactory.com/item/eu-vat-for-woocommerce/ Description: Manage EU VAT in WooCommerce. Beautifully. -Version: 2.12.3 +Version: 2.12.4 Author: WPFactory Author URI: https://wpfactory.com/ Text Domain: eu-vat-for-woocommerce @@ -22,7 +22,7 @@ * Main Alg_WC_EU_VAT Class * * @class Alg_WC_EU_VAT - * @version 2.12.3 + * @version 2.12.4 * @since 1.0.0 */ final class Alg_WC_EU_VAT { @@ -33,7 +33,7 @@ final class Alg_WC_EU_VAT { * @var string * @since 1.0.0 */ - public $version = '2.12.3'; + public $version = '2.12.4'; public $core = null; public $settings = array(); diff --git a/includes/class-alg-wc-eu-vat-ajax.php b/includes/class-alg-wc-eu-vat-ajax.php index dfc0581..ce78c4c 100644 --- a/includes/class-alg-wc-eu-vat-ajax.php +++ b/includes/class-alg-wc-eu-vat-ajax.php @@ -145,6 +145,8 @@ function alg_wc_eu_vat_validate_action( $param ) { $is_shipping_diff = false; $is_preserv = false; + alg_wc_eu_vat_session_set( 'alg_wc_eu_vat_valid_before_preserve', $is_valid ); + if ( $is_valid && 'no' != ( $preserve_option_value_base_country = get_option( 'alg_wc_eu_vat_preserve_in_base_country', 'no' ) ) ) { $selected_country_at_checkout = $_POST['billing_country']; @@ -177,6 +179,7 @@ function alg_wc_eu_vat_validate_action( $param ) { } } + alg_wc_eu_vat_session_set( 'alg_wc_eu_vat_valid', $is_valid ); if ( true === $is_shipping_diff ) { alg_wc_eu_vat_session_set( 'alg_wc_eu_vat_to_check', null ); diff --git a/includes/class-alg-wc-eu-vat-core.php b/includes/class-alg-wc-eu-vat-core.php index 6b79f34..4ca64c9 100644 --- a/includes/class-alg-wc-eu-vat-core.php +++ b/includes/class-alg-wc-eu-vat-core.php @@ -2,7 +2,7 @@ /** * EU VAT for WooCommerce - Core Class * - * @version 2.12.3 + * @version 2.12.4 * @since 1.0.0 * @author WPFactory */ @@ -28,7 +28,7 @@ class Alg_WC_EU_VAT_Core { /** * Constructor. * - * @version 2.11.10 + * @version 2.12.4 * @since 1.0.0 * @todo [dev] (maybe) "eu vat number" to "eu vat" * @todo [feature] `add_eu_vat_verify_button` (`woocommerce_form_field_text`) (`return ( alg_wc_eu_vat_get_field_id() === $key ) ? $field . '' . '[' . __( 'Verify', 'eu-vat-for-woocommerce' ) . ']' . '' : $field;`) @@ -140,10 +140,11 @@ function __construct() { add_action( 'wpo_wcpdf_after_order_details', array( $this, 'add_vat_exempt_text_pdf_footer'), 10, 2 ); } - add_filter('woocommerce_rest_prepare_shop_order_object', array( $this, 'alg_wc_eu_vat_filter_order_response' ), PHP_INT_MAX, 3 ); + add_filter('woocommerce_rest_prepare_shop_order_object', array( $this, 'alg_wc_eu_vat_filter_order_response' ), PHP_INT_MAX, 3 ); + add_filter('yith_ywpi_template_editor_customer_info_placeholders', array( $this, 'alg_wc_eu_vat_support_yith_invoice' ), PHP_INT_MAX, 1 ); // checkout block @@ -170,6 +171,15 @@ function __construct() { } + /* alg_wc_eu_vat_support_yith_invoice. + * + * @version 2.12.4 + * @since 2.12.4 + */ + function alg_wc_eu_vat_support_yith_invoice($fields_billing) { + $fields_billing[] = 'billing_eu_vat_number'; + return $fields_billing; + } /* alg_eu_vat_update_default_value_for_eu_vat_field. * @@ -1439,6 +1449,7 @@ function start_session() { alg_wc_eu_vat_session_set( 'alg_wc_eu_vat_to_check', null ); alg_wc_eu_vat_session_set( 'alg_wc_eu_vat_to_check_company', null ); alg_wc_eu_vat_session_set( 'alg_wc_eu_vat_to_check_company_name', null ); + alg_wc_eu_vat_session_set( 'alg_wc_eu_vat_valid_before_preserve', null ); } } } @@ -1624,13 +1635,14 @@ function maybe_exclude_vat() { /** * filter_available_payment_gateways_allowed. * - * @version 1.7.0 + * @version 2.12.4 * @since 1.0.0 * @todo [fix] (important) mini cart */ function filter_available_payment_gateways_allowed( $available_gateways ) { $gateways = $available_gateways; + $is_vat_valid = false; if ( $this->check_current_user_roles( get_option( 'alg_wc_eu_vat_exempt_for_user_roles', array() ) ) ) { $is_exempt = true; @@ -1642,6 +1654,11 @@ function filter_available_payment_gateways_allowed( $available_gateways ) { $is_exempt = false; } + if(true === alg_wc_eu_vat_session_get( 'alg_wc_eu_vat_valid_before_preserve' )) { + $is_vat_valid = true; + } + + $alg_wc_eu_vat_allowed_payment_gateway = get_option( 'alg_wc_eu_vat_allowed_payment_gateway', array() ); $alg_wc_eu_vat_allow_specific_payment = get_option( 'alg_wc_eu_vat_allow_specific_payment', 'no' ); @@ -1653,9 +1670,9 @@ function filter_available_payment_gateways_allowed( $available_gateways ) { } } - if($is_exempt){ + if( $is_exempt || $is_vat_valid ){ return $gateways; - }else{ + } else { return $available_gateways; } }else{ diff --git a/langs/eu-vat-for-woocommerce.pot b/langs/eu-vat-for-woocommerce.pot index b9fbc97..fcc33b7 100644 --- a/langs/eu-vat-for-woocommerce.pot +++ b/langs/eu-vat-for-woocommerce.pot @@ -2,14 +2,14 @@ # This file is distributed under the GNU General Public License v3.0. msgid "" msgstr "" -"Project-Id-Version: eu-vat-for-woocommerce 2.12.3\n" +"Project-Id-Version: eu-vat-for-woocommerce 2.12.4\n" "Report-Msgid-Bugs-To: https://wordpress.org/support/plugin/eu-vat-for-woocommerce\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"POT-Creation-Date: 2024-07-02T08:00:53+02:00\n" +"POT-Creation-Date: 2024-07-17T18:44:47+02:00\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "X-Generator: WP-CLI 2.9.0\n" "X-Domain: eu-vat-for-woocommerce\n" @@ -37,11 +37,11 @@ msgstr "" #: eu-vat-for-woocommerce-blocks-initialize.php:55 #: includes/admin/class-alg-wc-eu-vat-admin.php:356 -#: includes/class-alg-wc-eu-vat-core.php:1178 -#: includes/class-alg-wc-eu-vat-core.php:1180 -#: includes/class-alg-wc-eu-vat-core.php:1297 -#: includes/class-alg-wc-eu-vat-core.php:1377 -#: includes/class-alg-wc-eu-vat-core.php:1409 +#: includes/class-alg-wc-eu-vat-core.php:1188 +#: includes/class-alg-wc-eu-vat-core.php:1190 +#: includes/class-alg-wc-eu-vat-core.php:1307 +#: includes/class-alg-wc-eu-vat-core.php:1387 +#: includes/class-alg-wc-eu-vat-core.php:1419 #: includes/settings/class-alg-wc-eu-vat-settings-general.php:86 #: includes/settings/class-alg-wc-eu-vat-settings-general.php:94 #: build/eu-vat-for-woocommerce-checkout-eu-vat-field-block.js:1 @@ -169,7 +169,7 @@ msgid "VAT is valid." msgstr "" #: includes/class-alg-wc-eu-vat-ajax.php:55 -#: includes/class-alg-wc-eu-vat-core.php:1824 +#: includes/class-alg-wc-eu-vat-core.php:1841 #: includes/settings/class-alg-wc-eu-vat-settings-validation.php:272 msgid "VAT is not valid." msgstr "" @@ -201,38 +201,38 @@ msgid "(optional)" msgstr "" #: includes/class-alg-wc-eu-vat-ajax.php:125 -#: includes/class-alg-wc-eu-vat-core.php:1551 +#: includes/class-alg-wc-eu-vat-core.php:1562 msgid "Error: Country by IP does not match (%s)" msgstr "" -#: includes/class-alg-wc-eu-vat-core.php:201 -#: includes/class-alg-wc-eu-vat-core.php:365 -#: includes/class-alg-wc-eu-vat-core.php:1720 -#: includes/class-alg-wc-eu-vat-core.php:1789 +#: includes/class-alg-wc-eu-vat-core.php:211 +#: includes/class-alg-wc-eu-vat-core.php:375 +#: includes/class-alg-wc-eu-vat-core.php:1737 +#: includes/class-alg-wc-eu-vat-core.php:1806 #: includes/settings/class-alg-wc-eu-vat-settings-validation.php:70 msgid "EU VAT Number is not valid." msgstr "" -#: includes/class-alg-wc-eu-vat-core.php:334 -#: includes/class-alg-wc-eu-vat-core.php:1767 +#: includes/class-alg-wc-eu-vat-core.php:344 +#: includes/class-alg-wc-eu-vat-core.php:1784 msgid "Success (checkout): VAT ID valid. Matched with prevalidated VAT numbers." msgstr "" -#: includes/class-alg-wc-eu-vat-core.php:360 -#: includes/class-alg-wc-eu-vat-core.php:1797 +#: includes/class-alg-wc-eu-vat-core.php:370 +#: includes/class-alg-wc-eu-vat-core.php:1814 msgid "Error: VAT is not valid (checkout)" msgstr "" -#: includes/class-alg-wc-eu-vat-core.php:427 +#: includes/class-alg-wc-eu-vat-core.php:437 msgid "VAT SHIFTED" msgstr "" -#: includes/class-alg-wc-eu-vat-core.php:989 +#: includes/class-alg-wc-eu-vat-core.php:999 #: includes/settings/class-alg-wc-eu-vat-settings-general.php:163 msgid "You didn't set your VAT ID. Are you sure you want to continue?" msgstr "" -#: includes/class-alg-wc-eu-vat-core.php:989 +#: includes/class-alg-wc-eu-vat-core.php:999 #: includes/settings/class-alg-wc-eu-vat-settings-general.php:171 #: includes/settings/class-alg-wc-eu-vat-settings-general.php:180 #: includes/settings/class-alg-wc-eu-vat-settings-general.php:202 @@ -252,21 +252,21 @@ msgstr "" msgid "Yes" msgstr "" -#: includes/class-alg-wc-eu-vat-core.php:989 +#: includes/class-alg-wc-eu-vat-core.php:999 msgid "No" msgstr "" -#: includes/class-alg-wc-eu-vat-core.php:1101 +#: includes/class-alg-wc-eu-vat-core.php:1111 #: includes/settings/class-alg-wc-eu-vat-settings-general.php:244 msgid "I don't have a VAT ID" msgstr "" -#: includes/class-alg-wc-eu-vat-core.php:1120 +#: includes/class-alg-wc-eu-vat-core.php:1130 #: includes/settings/class-alg-wc-eu-vat-settings-general.php:260 msgid "I have a valid VAT but not exempted" msgstr "" -#: includes/class-alg-wc-eu-vat-core.php:1373 +#: includes/class-alg-wc-eu-vat-core.php:1383 msgid "Customer Decide" msgstr "" diff --git a/readme.txt b/readme.txt index 0d0f16b..ee67a93 100644 --- a/readme.txt +++ b/readme.txt @@ -3,7 +3,7 @@ Contributors: wpcodefactory, omardabbas, karzin, anbinder, algoritmika, kousikmu Tags: EU VAT, UK VAT, tax, vat validation, VAT Requires at least: 6.1 Tested up to: 6.5 -Stable tag: 2.12.3 +Stable tag: 2.12.4 License: GNU General Public License v3.0 License URI: http://www.gnu.org/licenses/gpl-3.0.html @@ -290,6 +290,10 @@ Once activated, access the plugin's settings by navigating to “WooCommerce > S == Changelog == += 2.12.4 - 17/07/2024 = +* Fix - added condition for filter_available_payment_gateways_allowed() for preserved countries. +* Add - Yith invoice eu vat field. + = 2.12.3 - 02/07/2024 = * Fix - eu_vat_admin_footer() for admin order creation.