-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Woo
committed
Apr 22, 2024
1 parent
5a2dce1
commit 9f2a98b
Showing
51 changed files
with
6,874 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ) ); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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( | ||
' <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( ' <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' ); | ||
} | ||
} ) | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |
Oops, something went wrong.