Skip to content

Commit 9f2a98b

Browse files
author
Woo
committed
Updates to 2.9.2
1 parent 5a2dce1 commit 9f2a98b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+6874
-0
lines changed

assets/css/admin.css

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/css/admin.scss

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#wc_eu_vat .inside {
2+
margin: 0;
3+
padding: 0;
4+
}
5+
#wc_eu_vat p {
6+
margin: 12px !important;
7+
}
8+
.wc-eu-vat-table {
9+
width: 100%;
10+
margin: 5px 0;
11+
}
12+
.wc-eu-vat-table th, .wc-eu-vat-table td {
13+
text-align: left;
14+
padding: 7px 12px;
15+
}
16+
.eu-vat-overview {
17+
margin: 0;
18+
}
19+
.column-eu_vat {
20+
width: 10%;
21+
color: #555;
22+
}
23+
.column-eu_vat ul li {
24+
color: #555;
25+
}

assets/js/admin.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
( function( $ ) {
2+
$(document.body).on( 'order-totals-recalculate-before', function( e, data ) {
3+
if( data && $( '#_billing_vat_number' ).length ) {
4+
data._billing_vat_number = $( '#_billing_vat_number' ).val();
5+
data._billing_country = $( '#_billing_country' ).val();
6+
data._shipping_country = $( '#_shipping_country' ).val();
7+
data._billing_postcode = $( '#_billing_postcode' ).val();
8+
}
9+
});
10+
}( jQuery ) );

assets/js/admin.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/eu-vat.js

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
jQuery(function(){
2+
function field_is_required( field, is_required ) {
3+
if ( is_required ) {
4+
field.find( 'label .optional' ).remove();
5+
field.addClass( 'validate-required' );
6+
7+
if ( field.find( 'label .required' ).length === 0 ) {
8+
field.find( 'label' ).append(
9+
'&nbsp;<abbr class="required" title="' +
10+
wc_address_i18n_params.i18n_required_text +
11+
'">*</abbr>'
12+
);
13+
}
14+
} else {
15+
field.find( 'label .required' ).remove();
16+
field.removeClass( 'validate-required woocommerce-invalid woocommerce-invalid-required-field' );
17+
18+
if ( field.find( 'label .optional' ).length === 0 ) {
19+
field.find( 'label' ).append( '&nbsp;<span class="optional">(' + wc_address_i18n_params.i18n_optional_text + ')</span>' );
20+
}
21+
}
22+
}
23+
24+
jQuery( 'form.checkout, form#order_review').on( 'change', '#billing_country', function() {
25+
var country = jQuery( '#billing_country' ).val();
26+
var check_countries = wc_eu_vat_params.eu_countries;
27+
var b2b_enabled = wc_eu_vat_params.b2b_required;
28+
29+
field_is_required( jQuery( '#woocommerce_eu_vat_number_field' ), false );
30+
31+
if ( country && jQuery.inArray( country, check_countries ) >= 0 ) {
32+
jQuery( '#woocommerce_eu_vat_number_field' ).fadeIn();
33+
if ( 'yes' === b2b_enabled ) {
34+
field_is_required( jQuery( '#woocommerce_eu_vat_number_field' ), true );
35+
}
36+
} else {
37+
jQuery( '#woocommerce_eu_vat_number_field' ).fadeOut();
38+
}
39+
});
40+
jQuery( '#billing_country' ).trigger( 'change' );
41+
42+
/* Validate EU VAT Number field only on change event */
43+
jQuery( 'form.checkout, form#order_review' ).on( 'change', '#woocommerce_eu_vat_number', function() {
44+
jQuery( 'body' ).trigger( 'update_checkout' );
45+
} );
46+
47+
/**
48+
* Handles checkout field UI when VAT field validation fails.
49+
*/
50+
jQuery( document.body ).on( 'updated_checkout', function( e, data ) {
51+
$vat_field = jQuery( '#woocommerce_eu_vat_number' );
52+
53+
if ( ! $vat_field.is( ':visible' ) ) {
54+
return;
55+
}
56+
57+
$vat_code = $vat_field.val();
58+
$vat_field_wrapper = $vat_field.closest( '.form-row' );
59+
60+
if ( 'success' === data.result ) {
61+
if ( ! $vat_code.length ) {
62+
$vat_field_wrapper.removeClass( 'woocommerce-validated' );
63+
}
64+
65+
return;
66+
}
67+
68+
/** If the message includes the VAT number, then highlight the VAT field in red. */
69+
if ( data.messages.length && data.messages.includes( $vat_code.toUpperCase() ) ) {
70+
$vat_field_wrapper.removeClass( 'woocommerce-validated' );
71+
$vat_field_wrapper.addClass( 'woocommerce-invalid' );
72+
}
73+
} )
74+
});

assets/js/eu-vat.min.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

block.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"apiVersion": 2,
3+
"name": "woocommerce/eu-vat-number",
4+
"version": "1.0.0",
5+
"title": "EU VAT Number",
6+
"parent": [ "woocommerce/checkout-fields-block" ],
7+
"category": "woocommerce",
8+
"icon": "cart",
9+
"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.",
10+
"supports": {
11+
"html": false
12+
},
13+
"textdomain": "woocommerce-eu-vat-number",
14+
"attributes": {
15+
"lock": {
16+
"type": "object",
17+
"default": {
18+
"remove": true,
19+
"move": false
20+
}
21+
}
22+
}
23+
}

build/frontend.asset.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
<?php return array('dependencies' => array('wc-blocks-checkout', 'wc-settings', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'e3d7d07c67aecd20c69de0d94c963346');

0 commit comments

Comments
 (0)