Skip to content

Commit

Permalink
Updates to 2.8.8
Browse files Browse the repository at this point in the history
  • Loading branch information
WooCommerce committed Nov 7, 2023
1 parent 5c650ee commit 651aba7
Show file tree
Hide file tree
Showing 46 changed files with 5,974 additions and 5,818 deletions.
8 changes: 4 additions & 4 deletions .github/scripts/release.php
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,14 @@ function run( $command, &$result_code = null ) {

line(
sprintf(
'WooCommerce Subscriptions Version: %s',
'WooCommerce EU VAT Number Version: %s',
$version
)
);

line(
sprintf(
'WooCommerce Subscriptions ZIP URL: %s',
'WooCommerce EU VAT Number ZIP URL: %s',
$zip_url
)
);
Expand All @@ -161,9 +161,9 @@ function run( $command, &$result_code = null ) {
mkdir( $archives_dir );
mkdir( $plugins_dir );

$plugin_dir = $plugins_dir . '/woocommerce-subscriptions';
$plugin_dir = $plugins_dir . '/woocommerce-eu-vat-number';

$zip_file = $archives_dir . '/woocommerce-subscriptions-' . $version . '.zip';
$zip_file = $archives_dir . '/woocommerce-eu-vat-number-' . $version . '.zip';

/**
* Download ZIP.
Expand Down
48 changes: 24 additions & 24 deletions assets/css/admin.scss
Original file line number Diff line number Diff line change
@@ -1,25 +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;
#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;
}
20 changes: 10 additions & 10 deletions assets/js/admin.js
Original file line number Diff line number Diff line change
@@ -1,10 +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 ) );
( 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 ) );
148 changes: 74 additions & 74 deletions assets/js/eu-vat.js
Original file line number Diff line number Diff line change
@@ -1,74 +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' );
}
} )
});
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' );
}
} )
});
49 changes: 23 additions & 26 deletions block.json
Original file line number Diff line number Diff line change
@@ -1,26 +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",
"editorScript": "file:./build/index.js",
"editorStyle": "file:./build/index.css",
"style": "file:./build/index.css",
"attributes": {
"lock": {
"type": "object",
"default": {
"remove": true,
"move": false
}
}
}
}
{
"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
}
}
}
}
2 changes: 1 addition & 1 deletion build/frontend.asset.php
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<?php return array('dependencies' => array('wc-blocks-checkout', 'wc-settings', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '87d45ecf17216813b6d1215de074478a');
<?php return array('dependencies' => array('wc-blocks-checkout', 'wc-settings', 'wp-compose', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => 'ece70d3d4ce2de6be1778d017be033ee');
Loading

0 comments on commit 651aba7

Please sign in to comment.