Skip to content

Commit

Permalink
Updates to 2.9.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Woo committed Apr 22, 2024
1 parent 5a2dce1 commit 9f2a98b
Show file tree
Hide file tree
Showing 51 changed files with 6,874 additions and 0 deletions.
1 change: 1 addition & 0 deletions assets/css/admin.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 25 additions & 0 deletions assets/css/admin.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#wc_eu_vat .inside {
margin: 0;
padding: 0;
}
#wc_eu_vat p {
margin: 12px !important;
}
.wc-eu-vat-table {
width: 100%;
margin: 5px 0;
}
.wc-eu-vat-table th, .wc-eu-vat-table td {
text-align: left;
padding: 7px 12px;
}
.eu-vat-overview {
margin: 0;
}
.column-eu_vat {
width: 10%;
color: #555;
}
.column-eu_vat ul li {
color: #555;
}
10 changes: 10 additions & 0 deletions assets/js/admin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
( function( $ ) {
$(document.body).on( 'order-totals-recalculate-before', function( e, data ) {
if( data && $( '#_billing_vat_number' ).length ) {
data._billing_vat_number = $( '#_billing_vat_number' ).val();
data._billing_country = $( '#_billing_country' ).val();
data._shipping_country = $( '#_shipping_country' ).val();
data._billing_postcode = $( '#_billing_postcode' ).val();
}
});
}( jQuery ) );
1 change: 1 addition & 0 deletions assets/js/admin.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

74 changes: 74 additions & 0 deletions assets/js/eu-vat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
jQuery(function(){
function field_is_required( field, is_required ) {
if ( is_required ) {
field.find( 'label .optional' ).remove();
field.addClass( 'validate-required' );

if ( field.find( 'label .required' ).length === 0 ) {
field.find( 'label' ).append(
'&nbsp;<abbr class="required" title="' +
wc_address_i18n_params.i18n_required_text +
'">*</abbr>'
);
}
} else {
field.find( 'label .required' ).remove();
field.removeClass( 'validate-required woocommerce-invalid woocommerce-invalid-required-field' );

if ( field.find( 'label .optional' ).length === 0 ) {
field.find( 'label' ).append( '&nbsp;<span class="optional">(' + wc_address_i18n_params.i18n_optional_text + ')</span>' );
}
}
}

jQuery( 'form.checkout, form#order_review').on( 'change', '#billing_country', function() {
var country = jQuery( '#billing_country' ).val();
var check_countries = wc_eu_vat_params.eu_countries;
var b2b_enabled = wc_eu_vat_params.b2b_required;

field_is_required( jQuery( '#woocommerce_eu_vat_number_field' ), false );

if ( country && jQuery.inArray( country, check_countries ) >= 0 ) {
jQuery( '#woocommerce_eu_vat_number_field' ).fadeIn();
if ( 'yes' === b2b_enabled ) {
field_is_required( jQuery( '#woocommerce_eu_vat_number_field' ), true );
}
} else {
jQuery( '#woocommerce_eu_vat_number_field' ).fadeOut();
}
});
jQuery( '#billing_country' ).trigger( 'change' );

/* Validate EU VAT Number field only on change event */
jQuery( 'form.checkout, form#order_review' ).on( 'change', '#woocommerce_eu_vat_number', function() {
jQuery( 'body' ).trigger( 'update_checkout' );
} );

/**
* Handles checkout field UI when VAT field validation fails.
*/
jQuery( document.body ).on( 'updated_checkout', function( e, data ) {
$vat_field = jQuery( '#woocommerce_eu_vat_number' );

if ( ! $vat_field.is( ':visible' ) ) {
return;
}

$vat_code = $vat_field.val();
$vat_field_wrapper = $vat_field.closest( '.form-row' );

if ( 'success' === data.result ) {
if ( ! $vat_code.length ) {
$vat_field_wrapper.removeClass( 'woocommerce-validated' );
}

return;
}

/** If the message includes the VAT number, then highlight the VAT field in red. */
if ( data.messages.length && data.messages.includes( $vat_code.toUpperCase() ) ) {
$vat_field_wrapper.removeClass( 'woocommerce-validated' );
$vat_field_wrapper.addClass( 'woocommerce-invalid' );
}
} )
});
1 change: 1 addition & 0 deletions assets/js/eu-vat.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 23 additions & 0 deletions block.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"apiVersion": 2,
"name": "woocommerce/eu-vat-number",
"version": "1.0.0",
"title": "EU VAT Number",
"parent": [ "woocommerce/checkout-fields-block" ],
"category": "woocommerce",
"icon": "cart",
"description": "The EU VAT Number extension lets you collect and validate EU VAT numbers during checkout to identify B2B transactions verses B2C. IP Addresses can also be validated to ensure they match the billing address. EU businesses with a valid VAT number can have their VAT removed prior to payment.",
"supports": {
"html": false
},
"textdomain": "woocommerce-eu-vat-number",
"attributes": {
"lock": {
"type": "object",
"default": {
"remove": true,
"move": false
}
}
}
}
1 change: 1 addition & 0 deletions build/frontend.asset.php
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<?php return array('dependencies' => array('wc-blocks-checkout', 'wc-settings', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'e3d7d07c67aecd20c69de0d94c963346');
Loading

0 comments on commit 9f2a98b

Please sign in to comment.