Skip to content

Commit

Permalink
Merge branch 'master' into feature/pdf-invoices-and-packing-slips-for…
Browse files Browse the repository at this point in the history
…-woocommerce
  • Loading branch information
vyskoczilova committed Jan 15, 2024
2 parents ff3db03 + e0b47e4 commit 34f2eef
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 6 deletions.
37 changes: 36 additions & 1 deletion assets/js/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,42 @@
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();
// Check whether the CollapsibleBlock library is available
if (window.CollapsibleBlock) {
// Set billing address as different from shipping address
var fc_billing_same_as_shipping_field = document.querySelector('#billing_same_as_shipping');
fc_billing_same_as_shipping_field.checked = false; // Expand the billing address fields

var fc_billing_address_fields_wrapper = document.querySelector('#woocommerce-billing-fields__field-wrapper');

if (fc_billing_address_fields_wrapper) {
CollapsibleBlock.expand(fc_billing_address_fields_wrapper);
} // Get company field toggle and content elements


var fc_billing_company_toggle = document.querySelector('#fc-expansible-form-section__toggle-plus--billing_company');
var fc_billing_company_content = document.querySelector('#fc-expansible-form-section__content--billing_company'); // Expand the billing company field

if (fc_billing_company_toggle) {
CollapsibleBlock.collapse(fc_billing_company_toggle);
}

if (fc_billing_company_content) {
CollapsibleBlock.expand(fc_billing_company_content);
} // Get dic field toggle and content elements


var fc_billing_dic_toggle = document.querySelector('#fc-expansible-form-section__toggle-plus--billing_dic');
var fc_billing_dic_content = document.querySelector('#fc-expansible-form-section__content--billing_dic'); // Expand the billing dic field

if (fc_billing_dic_toggle) {
CollapsibleBlock.collapse(fc_billing_dic_toggle);
}

if (fc_billing_dic_content) {
CollapsibleBlock.expand(fc_billing_dic_content);
}
}
} // Update values


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.

13 changes: 13 additions & 0 deletions includes/compatibility/fluidcheckout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

/**
* Skip hiding optional fields with the "+ add" buttons.
*
* @see https://wordpress.org/support/topic/compatibility-with-kybernaut-ico-dic-plugin/#post-17330291
*/
function woolab_icdic_fluidcheckout_add_optional_fields_skip_list( $skip_list ) {
$skip_list[] = 'billing_ic';
$skip_list[] = 'billing_dic';
return $skip_list;
}
add_filter( 'fc_hide_optional_fields_skip_list', 'woolab_icdic_fluidcheckout_add_optional_fields_skip_list', 10 );
35 changes: 33 additions & 2 deletions src/js/public.js
Original file line number Diff line number Diff line change
Expand Up @@ -226,9 +226,40 @@
if ( woolab.ares_fill ) {

// Compatibility with Fluid Checkout for WooCommerce – Lite
// https://wordpress.org/support/topic/compatibility-with-kybernaut-ico-dic-plugin/
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();

// Check whether the CollapsibleBlock library is available
if ( window.CollapsibleBlock ) {

// Set billing address as different from shipping address
var fc_billing_same_as_shipping_field = document.querySelector( '#billing_same_as_shipping' );
fc_billing_same_as_shipping_field.checked = false;

// Expand the billing address fields
var fc_billing_address_fields_wrapper = document.querySelector( '#woocommerce-billing-fields__field-wrapper' );
if ( fc_billing_address_fields_wrapper ) {
CollapsibleBlock.expand( fc_billing_address_fields_wrapper );
}

// Get company field toggle and content elements
var fc_billing_company_toggle = document.querySelector( '#fc-expansible-form-section__toggle-plus--billing_company' );
var fc_billing_company_content = document.querySelector( '#fc-expansible-form-section__content--billing_company' );

// Expand the billing company field
if ( fc_billing_company_toggle ) { CollapsibleBlock.collapse( fc_billing_company_toggle ); }
if ( fc_billing_company_content ) { CollapsibleBlock.expand( fc_billing_company_content ); }

// Get dic field toggle and content elements
var fc_billing_dic_toggle = document.querySelector( '#fc-expansible-form-section__toggle-plus--billing_dic' );
var fc_billing_dic_content = document.querySelector( '#fc-expansible-form-section__content--billing_dic' );

// Expand the billing dic field
if ( fc_billing_dic_toggle ) { CollapsibleBlock.collapse( fc_billing_dic_toggle ); }
if ( fc_billing_dic_content ) { CollapsibleBlock.expand( fc_billing_dic_content ); }

}

}

// Update values
Expand Down
5 changes: 3 additions & 2 deletions woolab-ic-dic.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Plugin Name: Kybernaut IC DIC
Plugin URI: https://kybernaut.cz/pluginy/kybernaut-ic-dic
Description: Adds Czech Company & VAT numbers (IČO & DIČ) to WooCommerce billing fields and verifies if data are correct.
Version: 1.8.2
Version: 1.8.2-alfa
Author: Karolína Vyskočilová
Author URI: https://kybernaut.cz
Text Domain: woolab-ic-dic
Expand Down Expand Up @@ -33,7 +33,7 @@
define( 'WOOLAB_IC_DIC_PLUGIN_BASENAME', plugin_basename( __FILE__ ) );
define( 'WOOLAB_IC_DIC_ABSPATH', dirname( __FILE__ ) . '/' );
define( 'WOOLAB_IC_DIC_URL', plugin_dir_url( __FILE__ ) );
define( 'WOOLAB_IC_DIC_VERSION', '1.8.2' );
define( 'WOOLAB_IC_DIC_VERSION', '1.8.2-alfa' );

// Check if WooCommerce active
function woolab_icdic_init() {
Expand Down Expand Up @@ -82,6 +82,7 @@ function woolab_icdic_plugin_admin_notice() {
// Compatibility
include_once( WOOLAB_IC_DIC_ABSPATH . 'includes/compatibility/superfaktura.php');
include_once( WOOLAB_IC_DIC_ABSPATH . 'includes/compatibility/pdf-invoices-and-packing-slips-for-woocommerce.php');
// include_once( WOOLAB_IC_DIC_ABSPATH . 'includes/compatibility/fluidcheckout.php'); don't apply globally.

add_filter( 'woocommerce_billing_fields' , 'woolab_icdic_billing_fields', 10, 2 );
add_filter( 'woocommerce_checkout_fields', 'woolab_icdic_checkout_fields', 10, 2);
Expand Down

0 comments on commit 34f2eef

Please sign in to comment.