diff --git a/assets/js/public.js b/assets/js/public.js index 6a07408..5a3d24f 100644 --- a/assets/js/public.js +++ b/assets/js/public.js @@ -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 diff --git a/assets/js/public.min.js b/assets/js/public.min.js index 40c601e..9f060f3 100644 --- a/assets/js/public.min.js +++ b/assets/js/public.min.js @@ -1 +1 @@ -"use strict";!function(i){var l="";function e(){var e;switch(woolab.ares_fill&&(i(".woolab-ic-dic-tip").remove(),c()),i("#billing_ic_field").slideDown(),i("#billing_dic_field").slideDown(),i("#billing_country").val()){case"SK":i("#billing_dic_dph_field").slideDown(),i("#billing_dic_field > label").addClass("woolab-ic-dic-required");break;case"CZ":i("#billing_dic_dph_field").slideUp(),i("#billing_dic_field > label").removeClass("woolab-ic-dic-required");break;default:i("#billing_dic_dph_field").slideUp(),i("#billing_dic_field > label").removeClass("woolab-ic-dic-required")}woolab.ares_check&&(t(e=i("#billing_ic")),i(document.body).on("focusin","#billing_ic",function(){l=e.val()}),e.donetyping(function(){(e=i("#billing_ic")).val()!==l&&t(e)},500)),i("#billing_company_field").slideDown()}function n(){var l="SK"==i("#billing_country").val()?"billing_dic_dph":"billing_dic";i("#billing_company, #billing_ic, #billing_dic, #billing_dic_dph").each(function(e,n){n.getAttribute("data-value")&&(n.value=n.getAttribute("data-value"),n.id==l&&n.value.length&&i(document.body).trigger("update_checkout"))})}function o(i){i.removeClass("kbnt-wrong").removeClass("woocommerce-invalid")}function a(i){i.addClass("kbnt-wrong").addClass("woocommerce-invalid").removeClass("woocommerce-validated")}function c(){i("#billing_company").removeAttr("readonly"),i("#billing_dic").removeAttr("readonly"),i("#billing_postcode").removeAttr("readonly"),i("#billing_city").removeAttr("readonly"),i("#billing_address_1").removeAttr("readonly")}function t(e){if("CZ"===i("#billing_country").val()){var n=e.val();if(n!==l){var t=i("#billing_ic_field"),r=''+woolab.l18n_not_valid+"";i(".woolab-ic-dic-tip").remove(),o(t),t.removeClass("kbnt-ok").removeClass("woocommerce-validated"),7!=n.length&&8!=n.length||null==n.match(/^[0-9]+$/)?(c(),n.length>0?a(t):o(t)):i.ajax({url:woolab.ajaxurl,data:{action:"ajaxAres",ico:n},beforeSend:function(){t.addClass("kbnt-validating"),t.append(''+woolab.l18n_validating+"")},success:function(l){(t.removeClass("kbnt-validating"),l)?0==(l=JSON.parse(l)).error?(i(".woolab-ic-dic-tip").remove(),t.addClass("kbnt-ok").addClass("woocommerce-validated").removeClass("woocommerce-invalid"),woolab.ares_fill&&(i("#billing_same_as_shipping")&&i("#billing_same_as_shipping").is(":checked")&&i("#billing_same_as_shipping").click(),i("#billing_company").val(l.spolecnost).attr("readonly",!0),i("#billing_dic").val(l.dic).attr("readonly",!0),i("#billing_address_1").val(l.adresa).attr("readonly",!0),i("#billing_postcode").val(l.psc).attr("readonly",!0),i("#billing_city").val(l.mesto).attr("readonly",!0),t.append(''+woolab.l18n_ok+""),i("body").trigger("update_checkout"))):(d(t),i(".woolab-ic-dic-tip").length>0&&i(".woolab-ic-dic-tip").remove(),c(),t.append(''+l.error+"")):(d(t),0==i(".woolab-ic-dic-tip").length&&(c(),t.append(r)))},error:function(l){0==i(".woolab-ic-dic-tip").length&&(e.val(""),d(t),t.append(''+woolab.l18n_error+""))}}),l=e.val()}}}function d(l){woolab.ares_fill&&(i("#billing_company").val(""),i("#billing_dic").val(""),i("#billing_postcode").val(""),i("#billing_city").val(""),i("#billing_address_1").val(""),c()),a(l)}i.fn.extend({donetyping:function(l,e){e=e||1e3;var n,o=function(i){n&&(n=null,l.call(i))};return this.each(function(l,a){var c=i(a);c.is(":input")&&i(document.body).on("keyup keypress paste",a,function(i){"keyup"==i.type&&8!=i.keyCode||(n&&clearTimeout(n),n=setTimeout(function(){o(a)},e))}),c.is(":input")&&i(document.body).on("blur",a,function(){o(a)})})}}),i(document).ready(function(){i(document.body).on("input",".woolab-ic-dic-no_spaces input",function(){i(this).val(function(i,l){return l.replace(/\s+/g,"")})});var l=i("#billing_iscomp");l.length&&!l.prop("checked")||(n(),e()),i(document.body).on("change","#billing_country, #billing_iscomp",function(){var l,o=i("#billing_iscomp");!o.length||o.prop("checked")?(n(),e()):(i(".woolab-ic-dic-toggle").slideUp(),l="SK"==i("#billing_country").val()?"billing_dic_dph":"billing_dic",i("#billing_company, #billing_ic, #billing_dic, #billing_dic_dph").each(function(e,n){n.setAttribute("data-value",n.value),n.id==l&&n.value.length&&i(document.body).trigger("update_checkout"),n.value=""}))}),i("#billing_dic, #billing_dic_dph").donetyping(function(){var l=i("#billing_country").val();"SK"!=l&&"billing_dic"==this.id&&i(document.body).trigger("update_checkout"),"SK"==l&&"billing_dic_dph"==this.id&&i(document.body).trigger("update_checkout")},750)})}(jQuery); \ No newline at end of file +"use strict";!function(i){var l="";function e(){var e;switch(woolab.ares_fill&&(i(".woolab-ic-dic-tip").remove(),c()),i("#billing_ic_field").slideDown(),i("#billing_dic_field").slideDown(),i("#billing_country").val()){case"SK":i("#billing_dic_dph_field").slideDown(),i("#billing_dic_field > label").addClass("woolab-ic-dic-required");break;case"CZ":i("#billing_dic_dph_field").slideUp(),i("#billing_dic_field > label").removeClass("woolab-ic-dic-required");break;default:i("#billing_dic_dph_field").slideUp(),i("#billing_dic_field > label").removeClass("woolab-ic-dic-required")}woolab.ares_check&&(t(e=i("#billing_ic")),i(document.body).on("focusin","#billing_ic",function(){l=e.val()}),e.donetyping(function(){(e=i("#billing_ic")).val()!==l&&t(e)},500)),i("#billing_company_field").slideDown()}function o(){var l="SK"==i("#billing_country").val()?"billing_dic_dph":"billing_dic";i("#billing_company, #billing_ic, #billing_dic, #billing_dic_dph").each(function(e,o){o.getAttribute("data-value")&&(o.value=o.getAttribute("data-value"),o.id==l&&o.value.length&&i(document.body).trigger("update_checkout"))})}function n(i){i.removeClass("kbnt-wrong").removeClass("woocommerce-invalid")}function a(i){i.addClass("kbnt-wrong").addClass("woocommerce-invalid").removeClass("woocommerce-validated")}function c(){i("#billing_company").removeAttr("readonly"),i("#billing_dic").removeAttr("readonly"),i("#billing_postcode").removeAttr("readonly"),i("#billing_city").removeAttr("readonly"),i("#billing_address_1").removeAttr("readonly")}function t(e){if("CZ"===i("#billing_country").val()){var o=e.val();if(o!==l){var t=i("#billing_ic_field"),r=''+woolab.l18n_not_valid+"";i(".woolab-ic-dic-tip").remove(),n(t),t.removeClass("kbnt-ok").removeClass("woocommerce-validated"),7!=o.length&&8!=o.length||null==o.match(/^[0-9]+$/)?(c(),o.length>0?a(t):n(t)):i.ajax({url:woolab.ajaxurl,data:{action:"ajaxAres",ico:o},beforeSend:function(){t.addClass("kbnt-validating"),t.append(''+woolab.l18n_validating+"")},success:function(l){if(t.removeClass("kbnt-validating"),l)if(0==(l=JSON.parse(l)).error){if(i(".woolab-ic-dic-tip").remove(),t.addClass("kbnt-ok").addClass("woocommerce-validated").removeClass("woocommerce-invalid"),woolab.ares_fill){if(i("#billing_same_as_shipping")&&i("#billing_same_as_shipping").is(":checked")&&window.CollapsibleBlock){document.querySelector("#billing_same_as_shipping").checked=!1;var e=document.querySelector("#woocommerce-billing-fields__field-wrapper");e&&CollapsibleBlock.expand(e);var o=document.querySelector("#fc-expansible-form-section__toggle-plus--billing_company"),n=document.querySelector("#fc-expansible-form-section__content--billing_company");o&&CollapsibleBlock.collapse(o),n&&CollapsibleBlock.expand(n);var a=document.querySelector("#fc-expansible-form-section__toggle-plus--billing_dic"),s=document.querySelector("#fc-expansible-form-section__content--billing_dic");a&&CollapsibleBlock.collapse(a),s&&CollapsibleBlock.expand(s)}i("#billing_company").val(l.spolecnost).attr("readonly",!0),i("#billing_dic").val(l.dic).attr("readonly",!0),i("#billing_address_1").val(l.adresa).attr("readonly",!0),i("#billing_postcode").val(l.psc).attr("readonly",!0),i("#billing_city").val(l.mesto).attr("readonly",!0),t.append(''+woolab.l18n_ok+""),i("body").trigger("update_checkout")}}else d(t),i(".woolab-ic-dic-tip").length>0&&i(".woolab-ic-dic-tip").remove(),c(),t.append(''+l.error+"");else d(t),0==i(".woolab-ic-dic-tip").length&&(c(),t.append(r))},error:function(l){0==i(".woolab-ic-dic-tip").length&&(e.val(""),d(t),t.append(''+woolab.l18n_error+""))}}),l=e.val()}}}function d(l){woolab.ares_fill&&(i("#billing_company").val(""),i("#billing_dic").val(""),i("#billing_postcode").val(""),i("#billing_city").val(""),i("#billing_address_1").val(""),c()),a(l)}i.fn.extend({donetyping:function(l,e){e=e||1e3;var o,n=function(i){o&&(o=null,l.call(i))};return this.each(function(l,a){var c=i(a);c.is(":input")&&i(document.body).on("keyup keypress paste",a,function(i){"keyup"==i.type&&8!=i.keyCode||(o&&clearTimeout(o),o=setTimeout(function(){n(a)},e))}),c.is(":input")&&i(document.body).on("blur",a,function(){n(a)})})}}),i(document).ready(function(){i(document.body).on("input",".woolab-ic-dic-no_spaces input",function(){i(this).val(function(i,l){return l.replace(/\s+/g,"")})});var l=i("#billing_iscomp");l.length&&!l.prop("checked")||(o(),e()),i(document.body).on("change","#billing_country, #billing_iscomp",function(){var l,n=i("#billing_iscomp");!n.length||n.prop("checked")?(o(),e()):(i(".woolab-ic-dic-toggle").slideUp(),l="SK"==i("#billing_country").val()?"billing_dic_dph":"billing_dic",i("#billing_company, #billing_ic, #billing_dic, #billing_dic_dph").each(function(e,o){o.setAttribute("data-value",o.value),o.id==l&&o.value.length&&i(document.body).trigger("update_checkout"),o.value=""}))}),i("#billing_dic, #billing_dic_dph").donetyping(function(){var l=i("#billing_country").val();"SK"!=l&&"billing_dic"==this.id&&i(document.body).trigger("update_checkout"),"SK"==l&&"billing_dic_dph"==this.id&&i(document.body).trigger("update_checkout")},750)})}(jQuery); \ No newline at end of file diff --git a/includes/compatibility/fluidcheckout.php b/includes/compatibility/fluidcheckout.php new file mode 100644 index 0000000..cdeee4d --- /dev/null +++ b/includes/compatibility/fluidcheckout.php @@ -0,0 +1,13 @@ +