Skip to content

Commit

Permalink
Add compaibility with autofill
Browse files Browse the repository at this point in the history
  • Loading branch information
vyskoczilova committed Nov 14, 2023
1 parent 366ed0c commit 0070708
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 5 deletions.
7 changes: 6 additions & 1 deletion assets/js/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,12 @@
woolab_add_class_ok(ico_class);

if (woolab.ares_fill) {
// Update values
// Compatibility with Fluid Checkout for WooCommerce – Lite
if ($('#billing_same_as_shipping') && $('#billing_same_as_shipping').is(':checked')) {
$('#billing_same_as_shipping').click();
} // Update values


$('#billing_company').val(data.spolecnost).attr('readonly', true);
$('#billing_dic').val(data.dic).attr('readonly', true);
$('#billing_address_1').val(data.adresa).attr('readonly', true);
Expand Down
2 changes: 1 addition & 1 deletion assets/js/public.min.js

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

21 changes: 18 additions & 3 deletions includes/settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@
add_filter('woocommerce_general_settings', 'woolab_icdic_icdic_general_settings');
function woolab_icdic_icdic_general_settings($settings) {

$vies_check_disabled = false;
$vat_check_disabled = false;

if ( class_exists('SoapClient') ) {
$vies_desc = __( 'Enable validation of VAT number in EU database VIES.', 'woolab-ic-dic' );
$vies_check = 'yes';
} else {
$vies_desc = '<span style="color:#ca4a1f">' . __( 'To enable this feature, turn on Soap Client (ask your hosting).', 'woolab-ic-dic' ) . '</span> ' . __( 'Enable validation of VAT number in EU database VIES.', 'woolab-ic-dic' ) ;
$vies_check = 'yes';
$vies_check_disabled = true;
}

$vat_desc = __( 'Enable VAT exemption for valid EU VAT numbers', 'woolab-ic-dic' );
Expand All @@ -17,6 +21,7 @@ function woolab_icdic_icdic_general_settings($settings) {
} else {
$vat_desc = $vat_desc . '<br><span style="color:#ca4a1f">' . __( 'To enable this feature, turn on taxes in your store.', 'woolab-ic-dic' ) . '</span>';
$vat_check = 'no';
$vat_check_disabled = true;

$wc_countries = new WC_Countries();
$vat_countries = $wc_countries->get_european_union_countries('eu_vat');
Expand All @@ -27,6 +32,12 @@ function woolab_icdic_icdic_general_settings($settings) {
}
}

if (class_exists("FluidCheckout")) {
$fluid_checkout = true;
} else {
$fluid_checkout = false;
}

$settings[] = array( 'title' => __( 'Kybernaut IČO DIČ options', 'woolab-ic-dic' ), 'type' => 'title', 'desc' => __( 'The following options affect how Business ID and VAT number behaves.', 'woolab-ic-dic' ), 'id' => 'woolab_icdic_options' );
$settings[] = array(
'title' => __( 'CZ: Validate Business ID in ARES', 'woolab-ic-dic' ),
Expand All @@ -48,27 +59,31 @@ function woolab_icdic_icdic_general_settings($settings) {
'id' => 'woolab_icdic_vies_check',
'default' => $vies_check,
'type' => 'checkbox',
'disabled' => $vies_check_disabled,
);
$settings[] = array(
'title' => __( 'EU: VAT exempt', 'woolab-ic-dic' ),
'desc' => $vat_desc,
'id' => 'woolab_icdic_vat_exempt_switch',
'default' => $vat_check,
'type' => 'checkbox',
'disabled' => $vat_check_disabled,
);
$settings[] = array(
'title' => __( 'Toggle fields visibility', 'woolab-ic-dic' ),
'desc' => __( 'Enable toggle switch to show/hide input fields', 'woolab-ic-dic' ),
'id' => 'woolab_icdic_toggle_switch',
'desc' => __( 'Enable toggle switch to show/hide input fields', 'woolab-ic-dic' ) . ( class_exists("FluidCheckout") ? ' <br><span style="color:#ca4a1f">' . __("This feature is not compatible with Fluid Checkout for WooCommerce.", 'woolab-ic-dic') . '</span>': ""),
'id' => 'woolab_icdic_toggle_swithch',
'default' => 'no',
'type' => 'checkbox',
'disabled' => class_exists("FluidCheckout") ? true : false,
);
$settings[] = array(
'title' => __( 'Move Country to top', 'woolab-ic-dic' ),
'desc' => __( 'Move Country field above the "Buying as a company" toggle', 'woolab-ic-dic' ),
'desc' => __( 'Move Country field above the "Buying as a company" toggle', 'woolab-ic-dic' ) . ( class_exists("FluidCheckout") ? ' <br><span style="color:#ca4a1f">' . __("This feature is not compatible with Fluid Checkout for WooCommerce.", 'woolab-ic-dic') . '</span>': ""),
'id' => 'woolab_icdic_country_switch',
'default' => 'no',
'type' => 'checkbox',
'disabled' => class_exists("FluidCheckout") ? true : false,
);
$settings[] = array( 'type' => 'sectionend', 'id' => 'woolab_icdic_options' );

Expand Down
6 changes: 6 additions & 0 deletions src/js/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,12 @@

if ( woolab.ares_fill ) {

// Compatibility with Fluid Checkout for WooCommerce – Lite
if ($('#billing_same_as_shipping') && $('#billing_same_as_shipping').is(':checked')) {
$('#billing_same_as_shipping').click();
$('#fc-expansible-form-section__toggle-plus--billing_company').click();
}

// Update values
$('#billing_company').val(data.spolecnost).attr('readonly', true);
$('#billing_dic').val(data.dic).attr('readonly', true);
Expand Down

0 comments on commit 0070708

Please sign in to comment.