Skip to content

Commit

Permalink
v2.9.19
Browse files Browse the repository at this point in the history
  • Loading branch information
kousikmukherjee committed Feb 29, 2024
1 parent c3624df commit 8de8f81
Show file tree
Hide file tree
Showing 6 changed files with 418 additions and 486 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,13 +3,13 @@
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.9.18
Version: 2.9.19
Author: WPFactory
Author URI: https://wpfactory.com/
Text Domain: eu-vat-for-woocommerce
Domain Path: /langs
Copyright: © 2023 WPFactory
WC tested up to: 8.3
WC tested up to: 8.5
License: GNU General Public License v3.0
License URI: http://www.gnu.org/licenses/gpl-3.0.html
*/
Expand All @@ -33,7 +33,7 @@ final class Alg_WC_EU_VAT {
* @var string
* @since 1.0.0
*/
public $version = '2.9.17';
public $version = '2.9.19';
public $core = null;
public $settings = array();

Expand Down
2 changes: 1 addition & 1 deletion includes/class-alg-wc-eu-vat-ajax.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ function enqueue_scripts() {
'progress_text_not_valid' => do_shortcode( get_option( 'alg_wc_eu_vat_progress_text_not_valid', __( 'VAT is not valid.', 'eu-vat-for-woocommerce' ) ) ),
'progress_text_validation_failed' => do_shortcode( get_option( 'alg_wc_eu_vat_progress_text_validation_failed', __( 'Validation failed. Please try again.', 'eu-vat-for-woocommerce' ) ) ),
'text_shipping_billing_countries' => do_shortcode( get_option( 'alg_wc_eu_vat_shipping_billing_countries', __( 'Different shipping & billing countries.', 'eu-vat-for-woocommerce' ) ) ),
'company_name_mismatch' => do_shortcode( get_option( 'alg_wc_eu_vat_company_name_mismatch', __( 'VAT is valid, but registered to %company_name%.', 'eu-vat-for-woocommerce' ) ) ),
'company_name_mismatch' => do_shortcode( get_option( 'alg_wc_eu_vat_company_name_mismatch', __( ' VAT is valid, but registered to %company_name%.', 'eu-vat-for-woocommerce' ) ) ),
'is_required' => get_option( 'alg_wc_eu_vat_field_required', 'no' ),
) );
}
Expand Down
34 changes: 31 additions & 3 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.9.17
* @version 2.9.19
* @since 1.0.0
* @author WPFactory
*/
Expand All @@ -20,7 +20,7 @@ class Alg_WC_EU_VAT_Core {
/**
* Constructor.
*
* @version 2.9.17
* @version 2.9.19
* @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 @@ -914,14 +914,42 @@ function save_eu_vat_number_from_editable_fields( $user_id, $load_address ) {
}
}
}

/**
* is_tax_status_none.
*
* @version 2.9.19
* @since 2.9.18
*/

function is_tax_status_none(){
foreach( WC()->cart->get_cart() as $cart_item ) {

$product_in_cart = $cart_item['product_id'];
$product_info = wc_get_product( $product_in_cart );
$tax_status = $product_info->get_tax_status();
if( $tax_status == 'none' ){
return true;
}

}
return false;
}

/**
* add_eu_vat_checkout_field_to_frontend.
*
* @version 1.7.0
* @version 2.9.19
* @since 1.0.0
*/
function add_eu_vat_checkout_field_to_frontend( $fields ) {

if( 'yes' === get_option( 'alg_wc_eu_vat_field_hide_tax_status_none', 'no' ) ){
if($this->is_tax_status_none()){
return $fields;
}
}

$user_roles = apply_filters( 'alg_wc_eu_vat_show_for_user_roles', array() );
if ( ! empty( $user_roles ) && ! $this->check_current_user_roles( $user_roles ) ) {
return $fields;
Expand Down
13 changes: 11 additions & 2 deletions includes/settings/class-alg-wc-eu-vat-settings-general.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/**
* EU VAT for WooCommerce - General Section Settings
*
* @version 1.7.2
* @version 2.9.19
* @since 1.0.0
* @author WPFactory
*/
Expand Down Expand Up @@ -43,7 +43,7 @@ function get_all_user_roles() {
/**
* get_settings.
*
* @version 1.7.2
* @version 2.9.19
* @since 1.0.0
* @todo [dev] check if `clear` is still working (and if yes - change desc)
* @todo [dev] (maybe) add link to plugin site `'<a target="_blank" href="https://wpfactory.com/item/eu-vat-for-woocommerce/">' . __( 'Visit plugin site', 'eu-vat-for-woocommerce' ) . '</a>'`
Expand Down Expand Up @@ -140,6 +140,15 @@ function get_settings() {
'options' => $this->allcountries()
),

array(
'title' => __( 'Remove the VAT field if the tax status is "none"', 'eu-vat-for-woocommerce' ),
'desc_tip' => __( 'Remove VAT from the checkout if any product in the cart has a tax status of "none".', 'eu-vat-for-woocommerce' ),
'desc' => __( 'Enable', 'eu-vat-for-woocommerce' ),
'id' => 'alg_wc_eu_vat_field_hide_tax_status_none',
'default' => 'no',
'type' => 'checkbox',
),

array(
'title' => __( 'Confirmation notice', 'eu-vat-for-woocommerce' ),
'desc_tip' => __( 'Will add an additional confirmation notice on the checkout on <strong>empty VAT ID</strong>. <br> For example you can enable this if EU VAT field is not required, but you still want to display a confirmation notice to the customer when no VAT ID was entered.', 'eu-vat-for-woocommerce' ),
Expand Down
Loading

0 comments on commit 8de8f81

Please sign in to comment.