Skip to content

Commit

Permalink
v2.12.4
Browse files Browse the repository at this point in the history
  • Loading branch information
kousikmukherjee committed Jul 17, 2024
1 parent 74298e0 commit a6319bf
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 34 deletions.
6 changes: 3 additions & 3 deletions eu-vat-for-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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();

Expand Down
3 changes: 3 additions & 0 deletions includes/class-alg-wc-eu-vat-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down Expand Up @@ -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 );
Expand Down
29 changes: 23 additions & 6 deletions includes/class-alg-wc-eu-vat-core.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* EU VAT for WooCommerce - Core Class
*
* @version 2.12.3
* @version 2.12.4
* @since 1.0.0
* @author WPFactory
*/
Expand All @@ -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 . '<span style="font-size:smaller !important;">' . '[<a name="billing_eu_vat_number_verify" href="">' . __( 'Verify', 'eu-vat-for-woocommerce' ) . '</a>]' . '</span>' : $field;`)
Expand Down Expand Up @@ -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

Expand All @@ -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.
*
Expand Down Expand Up @@ -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 );
}
}
}
Expand Down Expand Up @@ -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;
Expand All @@ -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' );

Expand All @@ -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{
Expand Down
48 changes: 24 additions & 24 deletions langs/eu-vat-for-woocommerce.pot
Original file line number Diff line number Diff line change
Expand Up @@ -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 <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\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"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 ""
Expand Down Expand Up @@ -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 "<strong>EU VAT Number</strong> 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
Expand All @@ -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 ""

Expand Down
6 changes: 5 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.

Expand Down

0 comments on commit a6319bf

Please sign in to comment.