From 99a6e61624c131681ef87b2dcf87cd8dfa72ba83 Mon Sep 17 00:00:00 2001 From: kousikmukherjee Date: Thu, 26 Sep 2024 20:10:39 +0530 Subject: [PATCH] v2.12.14 --- eu-vat-for-woocommerce.php | 6 +-- includes/admin/class-alg-wc-eu-vat-admin.php | 6 +-- includes/class-alg-wc-eu-vat-ajax.php | 13 +++-- includes/class-alg-wc-eu-vat-core.php | 39 ++++++++++++++- langs/eu-vat-for-woocommerce.pot | 50 ++++++++++---------- readme.txt | 6 ++- 6 files changed, 83 insertions(+), 37 deletions(-) diff --git a/eu-vat-for-woocommerce.php b/eu-vat-for-woocommerce.php index 5659a11..e697d17 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.13 +Version: 2.12.14 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.13 + * @version 2.12.14 * @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.13'; + public $version = '2.12.14'; /** * core object. diff --git a/includes/admin/class-alg-wc-eu-vat-admin.php b/includes/admin/class-alg-wc-eu-vat-admin.php index 7d38c45..d85d62c 100644 --- a/includes/admin/class-alg-wc-eu-vat-admin.php +++ b/includes/admin/class-alg-wc-eu-vat-admin.php @@ -2,7 +2,7 @@ /** * EU VAT for WooCommerce - Admin Class * - * @version 2.12.12 + * @version 2.12.14 * @since 1.0.0 * @author WPFactory */ @@ -398,7 +398,7 @@ function add_meta_box() { /** * create_meta_box. * - * @version 2.12.12 + * @version 2.12.14 * @since 1.0.0 * @todo [dev] save actual EU VAT number used on checkout (instead of `get_post_meta( $order_id, '_' . alg_wc_eu_vat_get_field_id(), true )`) * @todo [dev] (maybe) add country flag @@ -458,7 +458,7 @@ function create_meta_box( $object ) { // Output $order_id = $_order->get_id(); echo alg_wc_eu_vat_get_table_html( $table_data, array( 'table_class' => 'widefat striped', 'table_heading_type' => 'vertical' ) ); - echo '

' . '' . + echo '

' . '' . __( 'Validate VAT and remove taxes', 'eu-vat-for-woocommerce' ) . '' . '

'; } diff --git a/includes/class-alg-wc-eu-vat-ajax.php b/includes/class-alg-wc-eu-vat-ajax.php index 17f587b..b8c726d 100644 --- a/includes/class-alg-wc-eu-vat-ajax.php +++ b/includes/class-alg-wc-eu-vat-ajax.php @@ -2,7 +2,7 @@ /** * EU VAT for WooCommerce - AJAX Class * - * @version 2.12.13 + * @version 2.12.14 * @since 1.0.0 * @author WPFactory */ @@ -35,13 +35,13 @@ function __construct() { /** * enqueue_scripts. * - * @version 2.11.11 + * @version 2.12.14 * @since 1.0.0 * @todo [dev] (important) `... && function_exists( 'is_checkout' ) && is_checkout()` */ function enqueue_scripts() { if ( 'yes' === get_option( 'alg_wc_eu_vat_validate', 'yes' ) ) { - if ( ( function_exists( 'is_checkout' ) && is_checkout() ) || is_account_page() ) { + if ( ( function_exists( 'is_checkout' ) && is_checkout() ) || ( is_account_page() && ! is_wc_endpoint_url( 'edit-address' ) ) ) { wp_enqueue_script( 'alg-wc-eu-vat', alg_wc_eu_vat()->plugin_url() . '/includes/js/alg-wc-eu-vat.js', array('jquery'), alg_wc_eu_vat()->version, true ); wp_localize_script( 'alg-wc-eu-vat', 'alg_wc_eu_vat_ajax_object', array( 'ajax_url' => admin_url( 'admin-ajax.php' ), @@ -279,10 +279,15 @@ function alg_wc_eu_vat_validate_action( $param ) { /** * alg_wc_eu_vat_exempt_vat_from_admin. * - * @version 2.12.13 + * @version 2.12.14 * @since 2.12.13 */ function alg_wc_eu_vat_exempt_vat_from_admin( $param ){ + + if ( ! current_user_can('manage_options') || ! wp_verify_nonce( $_POST['nonce'], 'alg-wc-eu-vat-ajax-nonce' ) ) { + exit; + } + if ( isset( $_POST['order_id'] ) && '' != $_POST['order_id'] ) { $orderid = esc_attr($_POST['order_id']); if(isset( $_POST['status'] ) && 'yes' == $_POST['status'] ){ diff --git a/includes/class-alg-wc-eu-vat-core.php b/includes/class-alg-wc-eu-vat-core.php index c544834..ed4c95d 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.13 + * @version 2.12.14 * @since 1.0.0 * @author WPFactory */ @@ -28,7 +28,7 @@ class Alg_WC_EU_VAT_Core { /** * Constructor. * - * @version 2.12.5 + * @version 2.12.14 * @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;`) @@ -144,6 +144,8 @@ function __construct() { add_action( 'wpo_wcpdf_after_order_details', array( $this, 'add_vat_exempt_text_pdf_footer'), 10, 2 ); + add_filter('woocommerce_billing_fields', array( $this, 'add_frontend_edit_billing_fields' ), 10 ); + } add_filter('woocommerce_rest_prepare_shop_order_object', array( $this, 'alg_wc_eu_vat_filter_order_response' ), PHP_INT_MAX, 3 ); @@ -176,6 +178,28 @@ function __construct() { } + /* add_frontend_edit_billing_fields. + * + * @version 2.12.14 + * @since 2.12.14 + */ + function add_frontend_edit_billing_fields( $fields ) { + + $field_id = alg_wc_eu_vat_get_field_id(); + + $fields[$field_id] = array( + 'label' => do_shortcode( get_option( 'alg_wc_eu_vat_field_label', __( 'EU VAT Number', 'eu-vat-for-woocommerce' ) ) ), + 'placeholder' => do_shortcode( get_option( 'alg_wc_eu_vat_field_placeholder', __( 'EU VAT Number', 'eu-vat-for-woocommerce' ) ) ), + 'required' => false, + 'clear' => false, + 'type' => 'text', + 'class' => array('alg-wc-frontend-billing-edit'), + 'priority' => get_option( 'alg_wc_eu_vat_field_priority', 200 ), + ); + + return $fields; + } + /* alg_wc_eu_vat_support_yith_invoice. * * @version 2.12.4 @@ -799,6 +823,14 @@ function eu_vat_wp_footer() { + +