Plugin Directory

Changeset 3319787


Ignore:
Timestamp:
06/30/2025 08:49:28 AM (9 months ago)
Author:
wpify
Message:

Update to version 5.0.14

Location:
wpify-woo
Files:
28 edited
1 copied

Legend:

Unmodified
Added
Removed
  • wpify-woo/tags/5.0.14/build/icdic-blocks.asset.php

    r3257809 r3319787  
    1 <?php return array('dependencies' => array('react', 'react-dom', 'wp-data'), 'version' => '62f579dae4bd65d06774');
     1<?php return array('dependencies' => array('react', 'react-dom', 'wp-data'), 'version' => 'ef4718833722d4d04a35');
  • wpify-woo/tags/5.0.14/build/icdic-blocks.js

    r3257809 r3319787  
    1 !function(){"use strict";var e={745:function(e,t,n){var i=n(850);t.s=i.createRoot,i.hydrateRoot},850:function(e){e.exports=window.ReactDOM}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var c=t[i]={exports:{}};return e[i](c,c.exports,n),c.exports}!function(){function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function t(t,n){return function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,c,o,l=[],a=!0,u=!1;try{if(c=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;a=!1}else for(;!(a=(i=c.call(n)).done)&&(l.push(i.value),l.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{if(!a&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw r}}return l}}(t,n)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?e(t,n):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var i=window.React,r=window.wp.data,c=n(745),o=n(850),l=window.wc.wcBlocksData,a=l.CART_STORE_KEY,u=l.CHECKOUT_STORE_KEY,d=(l.COLLECTIONS_STORE_KEY,l.VALIDATION_STORE_KEY),s=function(){var e=window.wc.blocksCheckout.extensionCartUpdate,n=t((0,i.useState)(!1),2),c=n[0],l=n[1],s=t((0,i.useState)(),2),f=s[0],y=s[1],p=t((0,i.useState)(),2),w=p[0],m=p[1],v=t((0,i.useState)(),2),g=v[0],_=v[1],b=t((0,i.useState)(),2),E=b[0],h=b[1],S=((0,r.useSelect)((function(e){return e(a).getCartData()}),[]),(0,r.useSelect)((function(e){return e(a).getCustomerData()}),[])),A=(0,r.useSelect)((function(e){return e(u).getAdditionalFields()}),[]),C=(0,r.useDispatch)(u).setAdditionalFields,T=(0,r.useDispatch)(d),k=(T.showValidationError,T.setValidationErrors,T.showAllValidationErrors,(0,r.useDispatch)(a)),D=k.setBillingAddress,O=k.setShippingAddress,q=(0,r.useSelect)((function(e){return e(d).getValidationError("contact-wpify-dic")}),[]);console.log(q);var I=document.querySelector(".wc-block-components-address-form__wpify-company"),K=document.querySelector(".wc-block-components-address-form__wpify-ic"),L=document.querySelector(".wc-block-components-address-form__wpify-dic"),R=document.querySelector(".wc-block-components-address-form__wpify-dic-dph"),x=document.querySelector(".wc-block-components-address-form__wpify-ic"),U=document.querySelector("#wpify-ares"),j=document.querySelector("#contact-wpify-company"),V=document.querySelector("#contact-wpify-ic"),F=document.querySelector("#contact-wpify-dic"),W=document.querySelector("#contact-wpify-dic-dph");function Y(e){return(e=(e=e.replace(""," ")).replace(/[^a-zA-Z0-9]/g,"").toUpperCase()).match(/^[A-Z]{2}/)?e:S.billingAddress.country+e}function Z(e){return(e=e.replace(""," ")).replace(/\D/g,"")}function N(e,t){return new Promise((function(n,i){fetch(e,t).then((function(e){e.ok?e.json().then(n):e.json().then((function(e){return i(e.message)}))})).catch(i)}))}function P(t){_(null),h(!0),window.wpifyWooIcDic.restUrl&&N(window.wpifyWooIcDic.restUrl+"/icdic-vies?in="+t).then((function(n){var i=n.validation,r=void 0===i?{}:i;"SK"===S.billingAddress.country?A["wpify/dic-dph"]=t:A["wpify/dic"]=t,C(A),e({namespace:"wpify_ic_dic",data:{validation:r,country:S.billingAddress.country}});var c=new CustomEvent("wpify_woo_ic_dic_vies_valid",{detail:{validation:r}});window.dispatchEvent(c)})).catch((function(e){_(e)})).finally((function(){h(!1)}))}(0,i.useEffect)((function(){I&&(R&&(R.style.display="none"),null!=A&&A["wpify/ic_dic_toggle"]?(I.style.display="block",K.style.display="block",L.style.display="block",S.billingAddress.company&&(A["wpify/company"]=S.billingAddress.company)):(I.style.display="none",K.style.display="none",L.style.display="none",A["wpify/company"]="",A["wpify/ic"]="",A["wpify/dic"]="",A["wpify/dic-dph"]="",C(A)),null!=A&&A["wpify/ic_dic_toggle"]&&"SK"===S.billingAddress.country&&(R.style.display="block"),U&&null!=A&&A["wpify/ic_dic_toggle"]&&"CZ"===S.billingAddress.country?U.style.display="block":U&&(U.style.display="none"))}),[A,j,V,F,W,I,K,L,R,S]),(0,i.useEffect)((function(){if(x){var e=document.createElement("div");e.id="wpify-ares",x.appendChild(e),l(!0)}}),[x]),(0,i.useEffect)((function(){if(V&&"CZ"===S.billingAddress.country){var e,t=function(t){clearTimeout(e),e=setTimeout((function(){var e=Z(t.target.value);t.target.value=e,A["wpify/ic"]=e,C(A),B()}),2e3)};return V.addEventListener("input",t),function(){clearTimeout(e),V.removeEventListener("input",t)}}}),[V]),(0,i.useEffect)((function(){if(F||W){var e,t="SK"===S.billingAddress.country?W:F,n=function(t){clearTimeout(e),e=setTimeout((function(){P(Y(t.target.value))}),2e3)};return null==t||t.addEventListener("input",n),function(){clearTimeout(e),null==t||t.removeEventListener("input",n)}}}),[F,W,S.billingAddress.country]);var B=function(){y(null),m(!0);var e=Z(A["wpify/ic"]);N(window.wpifyWooIcDic.restUrl+"/icdic?in="+e).then((function(e){var t=e.details,n=void 0===t?{}:t;A["wpify/company"]=n.billing_company,A["wpify/ic"]=n.billing_ic,A["wpify/dic"]=n.billing_dic,C(A),n.billing_dic&&P(Y(n.billing_dic));var i={company:n.billing_company,address_1:n.billing_address_1,city:n.billing_city,postcode:n.billing_postcode};D(i),O(i);var r=new CustomEvent("wpify_woo_ic_dic_ares_autofilled",{detail:{details:n}});window.dispatchEvent(r)})).catch((function(e){y(e)})).finally((function(){m(!1)}))};return c?(0,i.createElement)("div",null,(0,o.createPortal)((0,i.createElement)(i.Fragment,null,(0,i.createElement)("div",null,(0,i.createElement)("input",{type:"button",className:"button wp-element-button",onClick:function(){return B()},value:window.wpifyWooIcDic.searchAresText}),w&&(0,i.createElement)("div",null,"Loading"),f&&(0,i.createElement)("div",null,f))),U),(0,o.createPortal)((0,i.createElement)(i.Fragment,null,(0,i.createElement)("div",null,E&&(0,i.createElement)("div",null,"Loading"),g&&(0,i.createElement)("div",null,g))),"SK"===S.billingAddress.country?R:L)):null};document.querySelectorAll('[data-app="wpify-ic-dic"]').forEach((function(e){(0,c.s)(e).render((0,i.createElement)(s,null))}))}()}();
     1!function(){"use strict";var e={745:function(e,t,i){var n=i(850);t.s=n.createRoot,n.hydrateRoot},850:function(e){e.exports=window.ReactDOM}},t={};function i(n){var r=t[n];if(void 0!==r)return r.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,i),o.exports}!function(){function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t,i,n){return(i=function(t){var i=function(t){if("object"!=e(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,"string");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(i)?i:i+""}(i))in t?Object.defineProperty(t,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[i]=n,t}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i<t;i++)n[i]=e[i];return n}function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,r,o,c,l=[],a=!0,s=!1;try{if(o=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;a=!1}else for(;!(a=(n=o.call(i)).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){s=!0,r=e}finally{try{if(!a&&null!=i.return&&(c=i.return(),Object(c)!==c))return}finally{if(s)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?n(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var o=window.React,c=window.wp.data,l=i(745),a=i(850);function s(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}var d=window.wc.wcBlocksData,u=d.CART_STORE_KEY,f=d.CHECKOUT_STORE_KEY,y=(d.COLLECTIONS_STORE_KEY,d.VALIDATION_STORE_KEY),p=function(){var e=window.wc.blocksCheckout.extensionCartUpdate,i=r((0,o.useState)(!1),2),n=i[0],l=i[1],d=r((0,o.useState)(),2),p=d[0],w=d[1],m=r((0,o.useState)(),2),b=m[0],g=m[1],v=r((0,o.useState)(),2),A=v[0],_=v[1],h=r((0,o.useState)(),2),E=h[0],S=h[1],D=r((0,o.useState)(),2),O=D[0],C=D[1],I=r((0,o.useState)(),2),T=I[0],j=I[1],x=((0,c.useSelect)((function(e){return e(u).getCartData()}),[]),(0,c.useSelect)((function(e){return e(u).getCustomerData()}),[])),k=(0,c.useSelect)((function(e){return e(f).getAdditionalFields()}),[]),W=(0,c.useDispatch)(f).setAdditionalFields,P=(0,c.useDispatch)(y),K=(P.showValidationError,P.setValidationErrors),q=(P.showAllValidationErrors,(0,c.useDispatch)(u)),V=q.setBillingAddress,R=q.setShippingAddress,L=(0,c.useSelect)((function(e){return e(y).getValidationError("contact-wpify-dic")}),[]);console.log(L);var Z=document.querySelector(".wc-block-components-address-form__wpify-company"),U=document.querySelector(".wc-block-components-address-form__wpify-ic"),Y=document.querySelector(".wc-block-components-address-form__wpify-dic"),z=document.querySelector(".wc-block-components-address-form__wpify-dic-dph"),F=document.querySelector(".wc-block-components-address-form__wpify-ic"),N=document.querySelector("#wpify-ares"),B=document.querySelector("#contact-wpify-company"),M=document.querySelector("#contact-wpify-ic"),H=document.querySelector("#contact-wpify-dic"),$=document.querySelector("#contact-wpify-dic-dph");function G(e){return(e=(e=e.replace(""," ")).replace(/[^a-zA-Z0-9]/g,"").toUpperCase()).match(/^[A-Z]{2}/)?e:x.billingAddress.country+e}function J(e){return(e=e.replace(""," ")).replace(/\D/g,"")}function Q(e,t){return new Promise((function(i,n){fetch(e,t).then((function(e){e.ok?e.json().then(i):e.json().then((function(e){return n(e.message)}))})).catch(n)}))}function X(t){S(null),j(null),window.wpifyWooIcDic.validateVies&&(!t||t.length<4||(C(!0),window.wpifyWooIcDic.restUrl&&Q(window.wpifyWooIcDic.restUrl+"/icdic-vies?in="+t).then((function(i){var n=i.validation||{},r=i.warning||null;"passed"!==n||r?r&&(S(r),j("error")):(S(null),j("success"));var o=t.match(/^[A-Z]{2}/)?t.substring(0,2):x.billingAddress.country;e({namespace:"wpify_ic_dic",data:{validation:n,country:o,dic:t}});var c=new CustomEvent("wpify_woo_ic_dic_vies_valid",{detail:{validation:n,warning:r}});window.dispatchEvent(c)})).catch((function(i){S(i),j("error"),e({namespace:"wpify_ic_dic",data:{validation:"failed",country:x.billingAddress.country,dic:t}})})).finally((function(){C(!1)}))))}(0,o.useEffect)((function(){if(Z)if(z&&(z.style.display="none"),null!=k&&k["wpify/ic_dic_toggle"]?(Z.style.display="block",U.style.display="block",Y.style.display="block",x.billingAddress.company&&(k["wpify/company"]=x.billingAddress.company)):(Z.style.display="none",U.style.display="none",Y.style.display="none",k["wpify/company"]="",k["wpify/ic"]="",k["wpify/dic"]="",k["wpify/dic-dph"]="",W(k)),null!=k&&k["wpify/ic_dic_toggle"]&&"SK"===x.billingAddress.country&&(z.style.display="block"),N&&null!=k&&k["wpify/ic_dic_toggle"]&&"CZ"===x.billingAddress.country){var e=window.wpifyWooIcDic.validateAres&&Array.isArray(window.wpifyWooIcDic.validateAres)&&window.wpifyWooIcDic.validateAres.includes("ic_entered");N.style.display=e?"none":"block"}else N&&(N.style.display="none")}),[k,B,M,H,$,Z,U,Y,z,x]),(0,o.useEffect)((function(){k["wpify/ic"]&&""!==k["wpify/ic"].trim()||(_(null),w(null));var e="SK"===x.billingAddress.country?k["wpify/dic-dph"]:k["wpify/dic"];e&&""!==e.trim()||(j(null),S(null))}),[k,x.billingAddress.country]),(0,o.useEffect)((function(){e({namespace:"wpify_ic_dic",data:{validation:"dic_cleared"}});var t="SK"===x.billingAddress.country?k["wpify/dic-dph"]:k["wpify/dic"];t&&""!==t.trim()&&setTimeout((function(){window.wpifyWooIcDic.validateVies?X(G(t)):e({namespace:"wpify_ic_dic",data:{validation:"passed",country:x.billingAddress.country,dic:t}})}),500)}),[]),(0,o.useEffect)((function(){console.log("Country changed to:",x.billingAddress.country),"CZ"!==x.billingAddress.country&&(w(null),_(null),console.log("Cleared ARES error for non-Czech country")),S(null),j(null),K({});var i=function(e){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?s(Object(n),!0).forEach((function(i){t(e,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},k);"SK"!==x.billingAddress.country&&i["wpify/dic-dph"]&&(i["wpify/dic-dph"]="",W(i));var n="SK"===x.billingAddress.country?i["wpify/dic-dph"]||"":i["wpify/dic"]||"";e({namespace:"wpify_ic_dic",data:{validation:"country_change",country:x.billingAddress.country,dic:n}}),n&&n.length>=4&&window.wpifyWooIcDic.validateVies&&setTimeout((function(){X(G(n))}),300)}),[x.billingAddress.country]),(0,o.useEffect)((function(){if(F){var e=document.createElement("div");e.id="wpify-ares",F.appendChild(e),l(!0)}}),[F]),(0,o.useEffect)((function(){if(M){var e,t=function(t){clearTimeout(e),e=setTimeout((function(){var e=J(t.target.value);t.target.value=e,k["wpify/ic"]=e,W(k),console.log("IC field change:",{country:x.billingAddress.country,value:e,willCallAres:"CZ"===x.billingAddress.country}),"CZ"===x.billingAddress.country?window.wpifyWooIcDic.validateAres&&Array.isArray(window.wpifyWooIcDic.validateAres)&&window.wpifyWooIcDic.validateAres.includes("ic_entered")&&ee():w(null)}),2e3)};return M.addEventListener("input",t),function(){clearTimeout(e),M.removeEventListener("input",t)}}}),[M,x.billingAddress.country]),(0,o.useEffect)((function(){if(H||$){var t,i="SK"===x.billingAddress.country?$:H,n=function(i){clearTimeout(t),t=setTimeout((function(){var t=G(i.target.value);t&&t.length>=4?X(t):e({namespace:"wpify_ic_dic",data:{validation:"dic_cleared"}})}),1500)};return null==i||i.addEventListener("input",n),function(){clearTimeout(t),null==i||i.removeEventListener("input",n)}}}),[H,$,x.billingAddress.country]);var ee=function(){if("CZ"===x.billingAddress.country){w(null),_(null),g(!0);var e=J(k["wpify/ic"]);Q(window.wpifyWooIcDic.restUrl+"/icdic?in="+e).then((function(e){var t=e.details,i=void 0===t?{}:t;k["wpify/company"]=i.billing_company,k["wpify/ic"]=i.billing_ic,k["wpify/dic"]=i.billing_dic,W(k),i.billing_dic&&window.wpifyWooIcDic.validateVies&&setTimeout((function(){X(G(i.billing_dic))}),100);var n={company:i.billing_company,address_1:i.billing_address_1,city:i.billing_city,postcode:i.billing_postcode};V(n),R(n);var r=new CustomEvent("wpify_woo_ic_dic_ares_autofilled",{detail:{details:i}});window.dispatchEvent(r),_("success")})).catch((function(e){w(e),_("error")})).finally((function(){g(!1)}))}},te=function(e){var t=e.isLoading,i=e.status,n=e.error,r=e.fieldValue;return r&&""!==r.trim()?t?(0,o.createElement)("div",{style:{position:"absolute",top:"50%",right:"14px",transform:"translateY(-50%)",color:"#0073aa"}},(0,o.createElement)("span",{style:{display:"inline-block",width:"16px",height:"16px",border:"2px solid #f3f3f3",borderTop:"2px solid #0073aa",borderRadius:"50%",animation:"spin 1s linear infinite"}}),(0,o.createElement)("style",null,"\n\t\t\t\t\t\t@keyframes spin {\n\t\t\t\t\t\t\t0% { transform: rotate(0deg); }\n\t\t\t\t\t\t\t100% { transform: rotate(360deg); }\n\t\t\t\t\t\t}\n\t\t\t\t\t")):"success"===i?(0,o.createElement)("div",{style:{position:"absolute",top:"50%",right:"14px",transform:"translatey(-50%)",color:"#46b450"}},(0,o.createElement)("span",null,"✓")):"error"===i||n?(0,o.createElement)("div",{style:{position:"absolute",top:"50%",right:"14px",transform:"translatey(-50%)",color:"#dc3232"}},(0,o.createElement)("span",null,"!")):null:null};return n?(0,o.createElement)("div",null,U&&(0,a.createPortal)((0,o.createElement)(o.Fragment,null,(0,o.createElement)(te,{isLoading:b,status:A,error:p,fieldValue:k["wpify/ic"]}),p&&k["wpify/ic"]&&(0,o.createElement)("p",{style:{color:"#dc3232",fontSize:"14px",marginTop:"4px"}},p)),U),U&&(null==k?void 0:k["wpify/ic_dic_toggle"])&&"CZ"===x.billingAddress.country&&function(){if(!(window.wpifyWooIcDic.validateAres&&Array.isArray(window.wpifyWooIcDic.validateAres)&&window.wpifyWooIcDic.validateAres.includes("ic_entered"))){var e=document.querySelector(".wpify-ares-button-wrapper");return e||((e=document.createElement("div")).className="wpify-ares-button-wrapper",U.insertAdjacentElement("afterend",e)),(0,a.createPortal)((0,o.createElement)("div",{style:{marginTop:"8px"}},(0,o.createElement)("input",{type:"button",className:"button wp-element-button",onClick:function(){return ee()},value:window.wpifyWooIcDic.searchAresText})),e)}return null}(),(0,a.createPortal)((0,o.createElement)(o.Fragment,null,(0,o.createElement)(te,{isLoading:O,status:T,error:E,fieldValue:"SK"===x.billingAddress.country?k["wpify/dic-dph"]:k["wpify/dic"]}),E&&("SK"===x.billingAddress.country?k["wpify/dic-dph"]:k["wpify/dic"])&&(0,o.createElement)("p",{style:{color:"#dc3232",fontSize:"14px",marginTop:"4px"}},E)),"SK"===x.billingAddress.country?z:Y)):null};document.querySelectorAll('[data-app="wpify-ic-dic"]').forEach((function(e){(0,l.s)(e).render((0,o.createElement)(p,null))}))}()}();
  • wpify-woo/tags/5.0.14/build/icdic.asset.php

    r3257809 r3319787  
    1 <?php return array('dependencies' => array(), 'version' => '6e4d995b05dd68d2e69d');
     1<?php return array('dependencies' => array(), 'version' => '8a3654a2c1c4c8f21284');
  • wpify-woo/tags/5.0.14/build/icdic.js

    r3257809 r3319787  
    1 window.jQuery(document).ready((function(e){window.wpifyWooIcDic=window.wpifyWooIcDic||{changePlaceholder:null,requireCompany:null,moveCompany:null,requireVatFields:null,optionalText:"",restUrl:null,position:""};var n={addEventListener:function(){return null},style:{display:"none"},value:"",placeholder:"",classList:{contains:function(){return!1}},disabled:!1},i=function(){return document.querySelector("#company_details")||n},t=function(){return document.querySelector("#billing_company")||n},o=function(){return document.querySelector("#billing_company_field")||n},c=function(){return document.querySelector("#billing_ic")||n},a=function(){return document.querySelector("#ares_in")||n},l=function(){return document.querySelector("#billing_ic_field")||n},u=function(){return document.querySelector("#billing_dic")||n},r=function(){return document.querySelector("#billing_dic_field")||n},s=function(){return document.querySelector("#billing_dic_dph")||n},d=function(){return document.querySelector("#billing_dic_dph_field")||n},y=function(){return document.querySelector("#wpify-woo-ares-autofill")||n},p=function(){return document.querySelector("#billing_country")||n},f={subscribers:[],data:{companyDetails:!1,ic:"",dic:"",icDph:"",country:"",company:"",aresResult:"",aresLoading:!1,viesResult:"",viesLoading:!1,disableSubmit:!1},get:function(e){return this.data[e]},set:function(e){var n=this;Object.keys(e).forEach((function(i){n.data[i]=e[i]})),this.subscribers.forEach((function(e){return e(n.data)}))},subscribe:function(e){this.subscribers.push(e)},sync:function(){var e={companyDetails:i().checked,ic:c().value,dic:u().value,icDph:s().value,country:p().value,company:t().value};(e.ic||e.dic||void 0===e.companyDetails)&&(e.companyDetails=!0),e.companyDetails||(e.ic="",e.dic="",e.icDph="",e.company=""),this.set(e)}};function m(e){var t,a;if(void 0!==e.companyDetails&&(e.companyDetails?(o().style.display="block",l().style.display="block",r().style.display="block"):(window.wpifyWooIcDic.moveCompany&&(o().style.display="none"),l().style.display="none",r().style.display="none")),"before_customer_details"!==window.wpifyWooIcDic.position&&e.companyDetails&&"CZ"===e.country||"before_customer_details"===window.wpifyWooIcDic.position&&"CZ"===e.country?y().style.display="block":y().style.display="none",e.companyDetails&&"SK"===e.country?d().style.display="block":d().style.display="none",window.wpifyWooIcDic.changePlaceholder&&(c().placeholder="123456789",e.companyDetails&&"SK"===e.country?(u().placeholder="123456789",s().placeholder=e.country+"1234567890"):e.companyDetails&&(u().placeholder=e.country+"123456789",s().placeholder="")),window.wpifyWooIcDic.requireCompany&&(e.companyDetails?v(o()):g(o())),e.companyDetails&&("if_checkbox"===window.wpifyWooIcDic.requireVatFields||"if_company"===window.wpifyWooIcDic.requireVatFields&&""!==e.company)?v(l()):g(l()),i().checked=!!e.companyDetails,document.querySelectorAll(".wpify-woo__ic-error").forEach((function(e){return e.remove()})),e.aresLoading?null===(t=c())||void 0===t||null===(t=t.parentNode)||void 0===t||t.classList.add("loading"):null===(a=c())||void 0===a||null===(a=a.parentNode)||void 0===a||a.classList.remove("loading"),e.aresResult&&!1===e.aresLoading){var p,f=document.createElement("div");f.innerHTML=e.aresResult,f.classList.add("wpify-woo__ic-error"),null===(p=c())||void 0===p||null===(p=p.parentNode)||void 0===p||p.insertBefore(f,c().nextSibling)}var m,b,w="SK"===e.country?s():u();if(e.viesLoading?null==w||null===(m=w.parentNode)||void 0===m||m.classList.add("loading"):null==w||null===(b=w.parentNode)||void 0===b||b.classList.remove("loading"),e.viesResult&&!1===e.viesLoading){var h,_=document.createElement("div");_.innerHTML=e.viesResult,_.classList.add("wpify-woo__ic-error"),null==w||null===(h=w.parentNode)||void 0===h||h.insertBefore(_,w.nextSibling)}(document.querySelector("#place_order")||n).disabled=!!e.disableSubmit}function v(e){if(void 0!==e.querySelector){var n=e.querySelector("label span");e.classList.add("validate-required"),n&&(n.className="required",n.innerText="*")}}function g(e){if(void 0!==e.querySelector){var n=e.querySelector("label span");e.classList.remove("validate-required"),n&&(n.className="optional",n.innerText=wpifyWooIcDic.optionalText)}}function b(e,n){return new Promise((function(i,t){fetch(e,n).then((function(e){e.ok?e.json().then(i):e.json().then((function(e){return t(e.message)}))})).catch(t)}))}function w(){if(window.wpifyWooIcDic.restUrl&&!f.get("aresLoading")){var n=_(c().value||a().value);f.set({aresLoading:!0}),b(window.wpifyWooIcDic.restUrl+"/icdic?in="+n).then((function(n){var i=n.details,t=void 0===i?{}:i;Object.keys(t).forEach((function(n){var i=document.getElementById(n);i.value=t[n],"billing_ic"!==n&&i&&e(i).trigger("change")})),f.set({aresResult:""});var o=new CustomEvent("wpify_woo_ic_dic_ares_autofilled",{detail:{details:t}});window.dispatchEvent(o)})).catch((function(e){f.set({aresResult:e})})).finally((function(){f.set({aresLoading:!1,companyDetails:!0})}))}}function h(e){return(e=e.replace(/[^a-zA-Z0-9]/g,"").toUpperCase()).match(/^[A-Z]{2}/)?e:p().value+e}function _(e){return e.replace(/\D/g,"")}f.subscribe(m);var D=null;function S(){if(window.wpifyWooIcDic.restUrl&&!f.get("viesLoading")){window.clearTimeout(D);var n="SK"===f.get("country")?h(f.get("icDph")):h(f.get("dic"));f.get("viesLastChecked")!==n?(f.set({viesResult:"",viesLoading:!0,disableSubmit:!0}),b(window.wpifyWooIcDic.restUrl+"/icdic-vies?in="+n).then((function(){"SK"===f.get("country")?s().value=n:u().value=n})).catch((function(e){f.set({viesResult:e})})).finally((function(){e(document.body).trigger("update_checkout"),f.set({viesLoading:!1,disableSubmit:!1,viesLastChecked:n})}))):f.set({viesLoading:!1,disableSubmit:!1})}}f.sync(),e(document.body).on("change","input[name=company_details]",(function(n){var i={companyDetails:n.target.checked};i.companyDetails||(i.ic="",i.dic="",i.icDph="",i.company="",c().value="",u().value="",s().value="",t().value="",e(document.body).trigger("update_checkout")),f.set(i)})),e(document.body).on("change","input[name=billing_company]",(function(e){f.set({company:e.target.value})})),e(document.body).on("change","select[name=billing_country]",(function(e){f.set({country:e.target.value})})),e(document.body).on("change","input[name=billing_ic]",(function(e){f.set({ic:e.target.value}),l().classList.contains("wpify-woo-ic--validate")&&("CZ"===f.get("country")&&e.target.value.length>0?w():f.set({aresResult:""}))})),e(document.body).on("keyup change","input[name=billing_ic]",(function(e){a().value=_(e.target.value)})),e(document.body).on("keyup change","#ares_in",(function(e){c().value=_(e.target.value)})),e(document.body).on("click","#wpify-woo-icdic__ares-submit",w),e(document.body).on("change","input[name=billing_dic]",(function(e){f.set({dic:e.target.value}),r().classList.contains("wpify-woo-vies--validate")&&"SK"!==f.get("country")&&e.target.value.length>0&&S()})),e(document.body).on("change","input[name=billing_dic_dph]",(function(e){f.set({icDph:e.target.value}),s().classList.contains("wpify-woo-vies--validate")&&"SK"===f.get("country")&&e.target.value.length>0&&S()})),e(document.body).on("keyup","input[name=billing_dic]",(function(e){r().classList.contains("wpify-woo-vies--validate")&&"SK"!==f.get("country")&&e.target.value.length>0&&(window.clearTimeout(D),f.set({disableSubmit:!0,dic:e.target.value}),window.setTimeout(S,2e3))})),e(document.body).on("keyup","input[name=billing_dic_dph]",(function(e){r().classList.contains("wpify-woo-vies--validate")&&"SK"===f.get("country")&&e.target.value.length>0&&(window.clearTimeout(D),f.set({disableSubmit:!0,icDph:e.target.value}),window.setTimeout(S,2e3))})),e(document.body).on("click","#wpify-woo-icdic__ares-autofill-button",(function(e){e.preventDefault(),document.querySelector(".wpify-woo-icdic__ares-autofill").style.display="block"})),e("form[name=checkout]").on("keydown","input,select,button",(function(e){"Enter"===e.key&&!0===f.get("disableSubmit")&&e.preventDefault()})).on("click","input[type=button],button",(function(e){!0===f.get("disableSubmit")&&e.preventDefault()})),e(document.body).on("updated_checkout",(function(){m(f.data)}))}));
     1window.jQuery(document).ready((function(e){window.wpifyWooIcDic=window.wpifyWooIcDic||{changePlaceholder:null,requireCompany:null,moveCompany:null,requireVatFields:null,optionalText:"",restUrl:null,position:""};var n={addEventListener:function(){return null},style:{display:"none"},value:"",placeholder:"",classList:{contains:function(){return!1}},disabled:!1},i=function(){return document.querySelector("#company_details")||n},t=function(){return document.querySelector("#billing_company")||n},o=function(){return document.querySelector("#billing_company_field")||n},c=function(){return document.querySelector("#billing_ic")||n},a=function(){return document.querySelector("#ares_in")||n},l=function(){return document.querySelector("#billing_ic_field")||n},u=function(){return document.querySelector("#billing_dic")||n},r=function(){return document.querySelector("#billing_dic_field")||n},s=function(){return document.querySelector("#billing_dic_dph")||n},d=function(){return document.querySelector("#billing_dic_dph_field")||n},y=function(){return document.querySelector("#wpify-woo-ares-autofill")||n},p=function(){return document.querySelector("#billing_country")||n},f={subscribers:[],data:{companyDetails:!1,ic:"",dic:"",icDph:"",country:"",company:"",aresResult:"",aresLoading:!1,viesResult:"",viesLoading:!1,disableSubmit:!1},get:function(e){return this.data[e]},set:function(e){var n=this;Object.keys(e).forEach((function(i){n.data[i]=e[i]})),this.subscribers.forEach((function(e){return e(n.data)}))},subscribe:function(e){this.subscribers.push(e)},sync:function(){var e={companyDetails:i().checked,ic:c().value,dic:u().value,icDph:s().value,country:p().value,company:t().value};(e.ic||e.dic||void 0===e.companyDetails)&&(e.companyDetails=!0),e.companyDetails||(e.ic="",e.dic="",e.icDph="",e.company=""),this.set(e)}};function m(e){var t,a;if(void 0!==e.companyDetails&&(e.companyDetails?(o().style.display="block",l().style.display="block",r().style.display="block"):(window.wpifyWooIcDic.moveCompany&&(o().style.display="none"),l().style.display="none",r().style.display="none")),"before_customer_details"!==window.wpifyWooIcDic.position&&e.companyDetails&&"CZ"===e.country||"before_customer_details"===window.wpifyWooIcDic.position&&"CZ"===e.country?y().style.display="block":y().style.display="none",e.companyDetails&&"SK"===e.country?d().style.display="block":d().style.display="none",window.wpifyWooIcDic.changePlaceholder&&(c().placeholder="123456789",e.companyDetails&&"SK"===e.country?(u().placeholder="123456789",s().placeholder=e.country+"1234567890"):e.companyDetails&&(u().placeholder=e.country+"123456789",s().placeholder="")),window.wpifyWooIcDic.requireCompany&&(e.companyDetails?v(o()):g(o())),e.companyDetails&&("if_checkbox"===window.wpifyWooIcDic.requireVatFields||"if_company"===window.wpifyWooIcDic.requireVatFields&&""!==e.company)?v(l()):g(l()),i().checked=!!e.companyDetails,document.querySelectorAll(".wpify-woo__ic-error").forEach((function(e){return e.remove()})),e.aresLoading?null===(t=c())||void 0===t||null===(t=t.parentNode)||void 0===t||t.classList.add("loading"):null===(a=c())||void 0===a||null===(a=a.parentNode)||void 0===a||a.classList.remove("loading"),e.aresResult&&!1===e.aresLoading){var p,f=document.createElement("div");f.innerHTML=e.aresResult,f.classList.add("wpify-woo__ic-error"),null===(p=c())||void 0===p||null===(p=p.parentNode)||void 0===p||p.insertBefore(f,c().nextSibling)}var m,b,w="SK"===e.country?s():u();if(e.viesLoading?null==w||null===(m=w.parentNode)||void 0===m||m.classList.add("loading"):null==w||null===(b=w.parentNode)||void 0===b||b.classList.remove("loading"),e.viesResult&&!1===e.viesLoading){var h,_=document.createElement("div");_.innerHTML=e.viesResult,_.classList.add("wpify-woo__ic-error"),null==w||null===(h=w.parentNode)||void 0===h||h.insertBefore(_,w.nextSibling)}(document.querySelector("#place_order")||n).disabled=!!e.disableSubmit}function v(e){if(void 0!==e.querySelector){var n=e.querySelector("label span");e.classList.add("validate-required"),n&&(n.className="required",n.innerText="*")}}function g(e){if(void 0!==e.querySelector){var n=e.querySelector("label span");e.classList.remove("validate-required"),n&&(n.className="optional",n.innerText=wpifyWooIcDic.optionalText)}}function b(e,n){return new Promise((function(i,t){fetch(e,n).then((function(e){e.ok?e.json().then(i):e.json().then((function(e){return t(e.message)}))})).catch(t)}))}function w(){if(window.wpifyWooIcDic.restUrl&&!f.get("aresLoading")){var n=_(c().value||a().value);f.set({aresLoading:!0}),b(window.wpifyWooIcDic.restUrl+"/icdic?in="+n).then((function(n){var i=n.details,t=void 0===i?{}:i;Object.keys(t).forEach((function(n){var i=document.getElementById(n);i.value=t[n],"billing_ic"!==n&&i&&e(i).trigger("change")})),f.set({aresResult:""});var o=new CustomEvent("wpify_woo_ic_dic_ares_autofilled",{detail:{details:t}});window.dispatchEvent(o)})).catch((function(e){f.set({aresResult:e})})).finally((function(){f.set({aresLoading:!1,companyDetails:!0})}))}}function h(e){return(e=e.replace(/[^a-zA-Z0-9]/g,"").toUpperCase()).match(/^[A-Z]{2}/)?e:p().value+e}function _(e){return e.replace(/\D/g,"")}f.subscribe(m);var D=null;function S(){if(window.wpifyWooIcDic.restUrl&&!f.get("viesLoading")){window.clearTimeout(D);var n="SK"===f.get("country")?h(f.get("icDph")):h(f.get("dic"));f.get("viesLastChecked")!==n?(f.set({viesResult:"",viesLoading:!0,disableSubmit:!0}),b(window.wpifyWooIcDic.restUrl+"/icdic-vies?in="+n).then((function(){"SK"===f.get("country")?s().value=n:u().value=n})).catch((function(e){f.set({viesResult:e})})).finally((function(){e(document.body).trigger("update_checkout"),f.set({viesLoading:!1,disableSubmit:!1,viesLastChecked:n})}))):f.set({viesLoading:!1,disableSubmit:!1})}}f.sync(),e(document.body).on("change","input[name=company_details]",(function(n){var i={companyDetails:n.target.checked};i.companyDetails||(i.ic="",i.dic="",i.icDph="",i.company="",c().value="",u().value="",s().value="",t().value="",e(document.body).trigger("update_checkout")),f.set(i)})),e(document.body).on("change","input[name=billing_company]",(function(e){f.set({company:e.target.value})})),e(document.body).on("change","select[name=billing_country]",(function(e){f.set({country:e.target.value})})),e(document.body).on("change","input[name=billing_ic]",(function(e){f.set({ic:e.target.value}),l().classList.contains("wpify-woo-ic--validate")&&("CZ"===f.get("country")&&e.target.value.length>0?w():f.set({aresResult:""}))})),e(document.body).on("keyup change","input[name=billing_ic]",(function(e){a().value=_(e.target.value)})),e(document.body).on("keyup change","#ares_in",(function(e){c().value=_(e.target.value)})),e(document.body).on("click","#wpify-woo-icdic__ares-submit",w),e(document.body).on("change","input[name=billing_dic]",(function(n){f.set({dic:n.target.value}),r().classList.contains("wpify-woo-vies--validate")&&"SK"!==f.get("country")&&n.target.value.length>0?S():e(document.body).trigger("update_checkout")})),e(document.body).on("change","input[name=billing_dic_dph]",(function(n){f.set({icDph:n.target.value}),s().classList.contains("wpify-woo-vies--validate")&&"SK"===f.get("country")&&n.target.value.length>0?S():e(document.body).trigger("update_checkout")})),e(document.body).on("keyup","input[name=billing_dic]",(function(e){r().classList.contains("wpify-woo-vies--validate")&&"SK"!==f.get("country")&&e.target.value.length>0&&(window.clearTimeout(D),f.set({disableSubmit:!0,dic:e.target.value}),window.setTimeout(S,2e3))})),e(document.body).on("keyup","input[name=billing_dic_dph]",(function(e){r().classList.contains("wpify-woo-vies--validate")&&"SK"===f.get("country")&&e.target.value.length>0&&(window.clearTimeout(D),f.set({disableSubmit:!0,icDph:e.target.value}),window.setTimeout(S,2e3))})),e(document.body).on("click","#wpify-woo-icdic__ares-autofill-button",(function(e){e.preventDefault(),document.querySelector(".wpify-woo-icdic__ares-autofill").style.display="block"})),e("form[name=checkout]").on("keydown","input,select,button",(function(e){"Enter"===e.key&&!0===f.get("disableSubmit")&&e.preventDefault()})).on("click","input[type=button],button",(function(e){!0===f.get("disableSubmit")&&e.preventDefault()})),e(document.body).on("updated_checkout",(function(){m(f.data)}))}));
  • wpify-woo/tags/5.0.14/readme.txt

    r3319782 r3319787  
    55Tested up to: 6.8
    66Requires PHP: 8.1
    7 Stable tag: 5.0.13
     7Stable tag: 5.0.14
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    219219
    220220== Changelog ==
     221= 5.0.14 =
     222* Fix VAT exempt calculation bug in block checkout
     223* Fix VAT exempt timing issue in block checkout
     224* Optimize performance by reducing excessive validation calls during checkout
     225* Add logging for VAT exempt
     226* Improve VAT exempt logic to handle different validation states properly
     227
    221228= 5.0.13 =
    222229* Add global unique id support for EAN in XML feed
  • wpify-woo/tags/5.0.14/src/Modules/IcDic/Api/IcDicApi.php

    r3257809 r3319787  
    118118        }
    119119
    120         if ( ! $this->module->is_valid_dic( $dic ) ) {
     120        // Check if VIES validation is enabled
     121        if ( ! $this->module->get_setting( 'validate_vies' ) ) {
     122            return new WP_REST_Response( array( 'validation' => 'skipped' ), 200 );
     123        }
     124
     125        $is_valid = $this->module->is_valid_dic( $dic );
     126       
     127        // If VIES validation fails and vies_fails is disabled, return error (blocks order)
     128        if ( ! $is_valid && $this->module->get_setting( 'vies_fails' ) !== true ) {
    121129            return new \WP_Error( 'not-found', $error_text );
    122130        }
    123131
     132        // If VIES validation fails but vies_fails is enabled, return passed with warning
     133        if ( ! $is_valid && $this->module->get_setting( 'vies_fails' ) === true ) {
     134            return new WP_REST_Response( array(
     135                'validation' => 'passed',
     136                'warning' => $error_text
     137            ), 200 );
     138        }
     139
     140        // Return validation result - BlockSupport will handle VAT exempt logic
    124141        return new WP_REST_Response( array( 'validation' => 'passed' ), 200 );
    125142    }
  • wpify-woo/tags/5.0.14/src/Modules/IcDic/BlockSupport.php

    r3262059 r3319787  
    1212class BlockSupport {
    1313    public $module = null;
     14    private $current_checkout_country = null;
    1415
    1516    public function __construct( $module ) {
     
    3536        }, 10, 3 );
    3637        add_action( 'woocommerce_validate_additional_field', [ $this, 'validate_ic_dic_fields' ], 10, 3 );
     38        // Hook to capture current country from checkout data during validation
     39        add_action( 'woocommerce_store_api_checkout_update_customer_from_request', [ $this, 'capture_country_before_validation' ], 5, 2 );
     40
     41        // Final VIES validation on order submission (both checkouts)
     42        add_action( 'rest_api_init', [ $this, 'register_block_checkout_vies_validation' ], 5 );
     43
     44        // Ensure VAT exempt is set before order totals calculation
     45        add_action( 'woocommerce_store_api_checkout_update_customer_from_request', [ $this, 'ensure_vat_exempt_from_checkout_data' ], 20, 2 );
     46       
     47        // Log VAT exempt decision after order is created
     48        add_action( 'woocommerce_store_api_checkout_order_processed', [ $this, 'log_order_vat_exempt_decision' ] );
    3749
    3850        $this->register_vat_exempt_callback();
     
    115127    }
    116128
    117     public function sanitize_ic_dic_fields( $value, $key ) {
    118         if ( in_array( $key, array( 'wpify/ic', 'wpify/dic', 'wpify/dic-dph' ) ) ) {
     129    public function sanitize_ic_dic_fields( $value, $key = null ) {
     130        // Handle both old and new callback signatures
     131        if ( $key === null && is_string( $value ) ) {
     132            // New signature: only value is passed, try to determine field from context
    119133            $value = str_replace( ' ', '', $value );
    120134            $value = strtoupper( $value );
     135        } elseif ( $key !== null && in_array( $key, array( 'wpify/ic', 'wpify/dic', 'wpify/dic-dph' ) ) ) {
     136            // Old signature: both value and key are passed
     137            $value = str_replace( ' ', '', $value );
     138            $value = strtoupper( $value );
    121139        }
    122140
     
    126144    public function validate_ic_dic_fields( \WP_Error $errors, $field_key, $field_value ) {
    127145        if ( $field_key !== 'wpify/dic' && $field_key !== 'wpify/dic-dph' && $field_key !== 'wpify/ic' ) {
    128             return;
    129         }
    130 
    131         wc_load_cart();
    132         $country = WC()->session->customer['country'];
    133 
    134 
    135         if ( 'wpify/ic' === $field_key && $this->module->get_setting( 'validate_ares' )
     146            return $errors;
     147        }
     148
     149        // Get country from multiple sources - block checkout may have newer data
     150        $country = null;
     151
     152        // Check php://input for block checkout data first (most reliable)
     153        $input = file_get_contents( 'php://input' );
     154        if ( $input ) {
     155            $input_data = json_decode( $input, true );
     156            if ( ! empty( $input_data['billing_address']['country'] ) ) {
     157                $country = sanitize_text_field( $input_data['billing_address']['country'] );
     158            }
     159        }
     160
     161        // Try captured country from our hook
     162        if ( empty( $country ) && ! empty( $this->current_checkout_country ) ) {
     163            $country = $this->current_checkout_country;
     164        }
     165
     166        // Try to get country from POST data
     167        if ( empty( $country ) && ! empty( $_POST['billing_country'] ) ) {
     168            $country = sanitize_text_field( $_POST['billing_country'] );
     169        }
     170
     171        // Try from additional fields (for block checkout)
     172        if ( empty( $country ) && ! empty( $_POST['wc-additional-fields-data'] ) ) {
     173            $additional_data = json_decode( stripslashes( $_POST['wc-additional-fields-data'] ), true );
     174            if ( ! empty( $additional_data['billing_country'] ) ) {
     175                $country = sanitize_text_field( $additional_data['billing_country'] );
     176            }
     177        }
     178
     179
     180        // Fallback to customer object
     181        if ( empty( $country ) && ! empty( WC()->customer ) ) {
     182            $country = WC()->customer->get_billing_country();
     183        }
     184
     185        // Last resort - session
     186        if ( empty( $country ) ) {
     187            wc_load_cart();
     188            $country = WC()->session->customer['country'] ?? '';
     189        }
     190
     191        // Validation processing - detailed logging moved to order creation
     192
     193        // For IC field, skip server-side validation for block checkout since we can't reliably get current country
     194        if ( 'wpify/ic' === $field_key ) {
     195            return $errors; // Skip IC validation for block checkout - frontend handles it
     196        }
     197
     198        // ARES validation only for Czech IC numbers
     199        if ( 'wpify/ic' === $field_key
     200             && $this->module->get_setting( 'validate_ares' )
    136201             && $country === 'CZ'
    137202             && in_array( 'order_submit', $this->module->get_setting( 'validate_ares' ) )
     203             && ! empty( $field_value )
    138204        ) {
    139205            $ares = ( new AresFactory() )->create();
     
    151217        }
    152218
    153         if ( $this->module->get_setting( 'validate_vies' ) && $this->module->get_setting( 'vies_fails' ) !== true ) {
    154             if ( $country === 'SK' && $field_key !== 'wpify/dic-dph' ) {
    155                 return $errors;
    156             } else if ( $field_key !== 'wpify/dic' ) {
    157                 return $errors;
    158             }
    159 
    160             if ( ! empty( $field_value ) && ! $this->module->is_valid_dic( $field_value ) ) {
    161                 if ( $country === 'SK' ) {
    162                     $errors->add( 'validation', __( 'The entered IN VAT Number has not been found in VIES, please enter valid IN VAT number.', 'wpify-woo' ) );
    163                 } else {
    164                     $errors->add( 'validation', __( 'The entered VAT Number has not been found in VIES, please enter valid VAT number.', 'wpify-woo' ) );
    165                 }
    166             }
    167         }
     219        // VIES validation moved to final order submission - no longer validate during field input
    168220
    169221        return $errors;
     
    212264
    213265    public function set_customer_vat_extempt( $data ) {
    214         if ( isset( $data['validation'] ) && $data['validation'] === 'passed' ) {
    215             WC()->customer->set_is_vat_exempt( true );
     266        // Default: always reset VAT exempt first
     267        WC()->customer->set_is_vat_exempt( false );
     268       
     269        // Handle different validation states first
     270        if ( isset( $data['validation'] ) && ( $data['validation'] === 'dic_cleared' || $data['validation'] === 'failed' ) ) {
     271            // DIC was cleared or validation failed - ensure VAT exempt is false
     272            if ( $data['validation'] === 'dic_cleared' ) {
     273                // Clear meta data only when explicitly cleared, not when validation fails
     274                WC()->customer->delete_meta_data( 'billing_dic' );
     275                WC()->customer->delete_meta_data( 'billing_dic_dph' );
     276                WC()->customer->save();
     277            }
     278            return;
     279        }
     280
     281        // Get current checkout data to determine if VAT exempt should be applied
     282        $vies_fails            = $this->module->get_setting( 'vies_fails' );
     283        $vat_extempt_countries = $this->module->get_setting( 'zero_tax_for_vat_countries' );
     284
     285        // Check if VAT exempt countries are configured
     286        if ( empty( $vat_extempt_countries ) ) {
     287            return;
     288        }
     289
     290        // Get country and DIC from multiple sources to ensure we have the latest data
     291        $country = $data['country'] ?? WC()->customer->get_billing_country();
     292        $dic = null;
     293
     294        // Try to get DIC from the data passed, otherwise from customer meta
     295        if ( isset( $data['dic'] ) ) {
     296            // DIC explicitly provided in data (including empty string)
     297            $dic = $data['dic'];
     298        } else {
     299            // Get DIC from customer meta based on country only if not provided in data
     300            if ( $country === 'SK' ) {
     301                $dic = WC()->customer->get_meta( 'billing_dic_dph' );
     302            } else {
     303                $dic = WC()->customer->get_meta( 'billing_dic' );
     304            }
     305        }
     306
     307        // If we have a DIC, check if VAT exempt should be applied
     308        if ( ! empty( $dic ) ) {
     309            // If VIES validation is strict (vies_fails is false) and validation hasn't passed, don't set VAT exempt
     310            if ( isset( $data['validation'] ) && $data['validation'] === 'passed' ) {
     311                // Validation explicitly passed - proceed with VAT exempt check
     312                $this->apply_vat_exempt_if_valid( $dic, $country );
     313            } elseif ( empty( $vies_fails ) || $vies_fails !== false ) {
     314                // VIES validation is lenient (vies_fails is true) OR not configured - check VAT exempt anyway
     315                $this->apply_vat_exempt_if_valid( $dic, $country );
     316            }
     317            // If VIES is strict and validation hasn't passed, keep VAT exempt false
     318        }
     319        // If no DIC, VAT exempt stays false (already set at the beginning)
     320
     321    }
     322
     323    private function apply_vat_exempt_if_valid( $dic, $country ) {
     324        // For block checkout, use the billing country from DIC validation as shipping country
     325        // since the customer session might not be updated yet with the current country
     326        $shipping_country = WC()->customer->get_shipping_country();
     327        if ( empty( $shipping_country ) || $shipping_country === 'CZ' ) {
     328            // Fallback to the country from DIC validation
     329            $shipping_country = $country;
     330        }
     331
     332        $is_vat_exempt = $this->module->is_vat_extempt( $dic, $shipping_country );
     333        WC()->customer->set_is_vat_exempt( $is_vat_exempt );
     334    }
     335
     336
     337    public function capture_country_before_validation( $customer, $request ) {
     338        // Capture country from request data before validation
     339        $data = $request->get_json_params();
     340        if ( ! empty( $data['billing_address']['country'] ) ) {
     341            $this->current_checkout_country = $data['billing_address']['country'];
     342        }
     343    }
     344
     345    public function ensure_vat_exempt_from_checkout_data( $customer, $request ) {
     346        // This runs during final checkout processing to ensure VAT exempt is correctly applied
     347        $data = $request->get_json_params();
     348        $billing_country = $data['billing_address']['country'] ?? '';
     349        $additional_fields = $data['additional_fields'] ?? array();
     350
     351        // Get DIC based on country
     352        $dic = null;
     353        if ( $billing_country === 'SK' && ! empty( $additional_fields['wpify/dic-dph'] ) ) {
     354            $dic = $additional_fields['wpify/dic-dph'];
     355        } elseif ( $billing_country !== 'SK' && ! empty( $additional_fields['wpify/dic'] ) ) {
     356            $dic = $additional_fields['wpify/dic'];
     357        }
     358
     359        // Always reset VAT exempt first
     360        WC()->customer->set_is_vat_exempt( false );
     361
     362        // Apply VAT exempt only if we have a valid DIC and VAT exempt countries are configured
     363        $vat_extempt_countries = $this->module->get_setting( 'zero_tax_for_vat_countries' );
     364        if ( ! empty( $dic ) && ! empty( $vat_extempt_countries ) ) {
     365            $is_vat_exempt = $this->module->is_vat_extempt( $dic, $billing_country );
     366            WC()->customer->set_is_vat_exempt( $is_vat_exempt );
     367        }
     368    }
     369   
     370    public function ensure_vat_exempt_before_totals( $customer, $request ) {
     371        // This runs late in the checkout process to ensure VAT exempt is applied before final totals
     372        $data = $request->get_json_params();
     373        $billing_country = $data['billing_address']['country'] ?? '';
     374        $additional_fields = $data['additional_fields'] ?? array();
     375
     376        // Get DIC based on country
     377        $dic = null;
     378        if ( $billing_country === 'SK' && ! empty( $additional_fields['wpify/dic-dph'] ) ) {
     379            $dic = $additional_fields['wpify/dic-dph'];
     380        } elseif ( $billing_country !== 'SK' && ! empty( $additional_fields['wpify/dic'] ) ) {
     381            $dic = $additional_fields['wpify/dic'];
     382        }
     383
     384        // Always reset VAT exempt first
     385        WC()->customer->set_is_vat_exempt( false );
     386
     387        // Apply VAT exempt only if we have a valid DIC and VAT exempt countries are configured
     388        $vat_extempt_countries = $this->module->get_setting( 'zero_tax_for_vat_countries' );
     389        if ( ! empty( $dic ) && ! empty( $vat_extempt_countries ) ) {
     390            $this->apply_vat_exempt_if_valid( $dic, $billing_country );
    216391        }
    217392    }
     
    220395        return $cart_errors;
    221396    }
     397
     398    /**
     399     * Register VIES validation for block checkout on final order submission
     400     */
     401    public function register_block_checkout_vies_validation() {
     402        static $registered = false;
     403        if ( $registered ) {
     404            return;
     405        }
     406        $registered = true;
     407
     408        // Register VIES validation on final checkout submission for blocks
     409        add_action( 'rest_pre_dispatch', array( $this, 'validate_vies_before_block_checkout' ), 10, 3 );
     410    }
     411
     412    /**
     413     * Validate VIES before block checkout is processed (only on final submission)
     414     */
     415    public function validate_vies_before_block_checkout( $result, $server, $request ) {
     416        if ( $request->get_route() !== '/wc/store/v1/checkout' || $request->get_method() !== 'POST' ) {
     417            return $result;
     418        }
     419
     420        // Only validate if VIES validation is enabled and vies_fails is false (strict mode)
     421        if ( ! $this->module->get_setting( 'validate_vies' ) || $this->module->get_setting( 'vies_fails' ) === true ) {
     422            return $result;
     423        }
     424
     425        $body = $request->get_json_params();
     426        $additional_fields = $body['additional_fields'] ?? array();
     427        $billing_country = $body['billing_address']['country'] ?? '';
     428
     429        $validation_errors = array();
     430
     431        // Validate DIC fields based on country
     432        if ( $billing_country === 'SK' ) {
     433            // For Slovakia, validate dic-dph field
     434            $dic_dph = $additional_fields['wpify/dic-dph'] ?? '';
     435            if ( ! empty( $dic_dph ) && ! $this->module->is_valid_dic( $dic_dph ) ) {
     436                $validation_errors[] = array(
     437                    'code'    => 'dic_dph_invalid',
     438                    'message' => __( 'The entered IN VAT Number has not been found in VIES, please enter valid IN VAT number.', 'wpify-woo' ),
     439                    'data'    => array( 'field' => 'wpify/dic-dph' )
     440                );
     441            }
     442        } else {
     443            // For other countries, validate dic field
     444            $dic = $additional_fields['wpify/dic'] ?? '';
     445            if ( ! empty( $dic ) && ! $this->module->is_valid_dic( $dic ) ) {
     446                $validation_errors[] = array(
     447                    'code'    => 'dic_invalid',
     448                    'message' => __( 'The entered VAT Number has not been found in VIES, please enter valid VAT number.', 'wpify-woo' ),
     449                    'data'    => array( 'field' => 'wpify/dic' )
     450                );
     451            }
     452        }
     453
     454        if ( ! empty( $validation_errors ) ) {
     455            $combined_messages = array_column( $validation_errors, 'message' );
     456
     457            return new \WP_Error(
     458                'vies_validation_failed',
     459                implode( '<br>', $combined_messages ),
     460                array(
     461                    'status'            => 400,
     462                    'validation_errors' => $validation_errors
     463                )
     464            );
     465        }
     466
     467
     468        return $result;
     469    }
     470
     471    public function log_order_vat_exempt_decision( $order ) {
     472        // Only log if DIC was provided
     473        $billing_country = $order->get_billing_country();
     474        $dic = $billing_country === 'SK'
     475            ? $order->get_meta('_billing_dic_dph')
     476            : $order->get_meta('_billing_dic');
     477
     478        if ( empty( $dic ) ) {
     479            return; // No DIC provided, skip logging
     480        }
     481
     482        // Detect VAT exempt from order - if tax_total is 0 but order has taxable items, likely VAT exempt
     483        $customer_vat_exempt = ($order->get_total_tax() == 0 && $order->get_total() > 0);
     484        $vat_exempt_countries = $this->module->get_setting( 'zero_tax_for_vat_countries' );
     485        $shop_country = wc_get_base_location()['country'];
     486        $shipping_country = $order->get_shipping_country();
     487
     488        // Determine if VAT should be exempt based on current logic
     489        $should_be_vat_exempt = false;
     490        if ( ! empty( $vat_exempt_countries ) ) {
     491            $should_be_vat_exempt = $this->module->is_vat_extempt( $dic, $shipping_country );
     492        }
     493
     494        $this->module->log->info('Order VAT Exempt Decision', [
     495            'order_id' => $order->get_id(),
     496            'order_number' => $order->get_order_number(),
     497            'billing_country' => $billing_country,
     498            'shipping_country' => $shipping_country,
     499            'shop_country' => $shop_country,
     500            'submitted_dic' => $dic,
     501            'customer_vat_exempt' => $customer_vat_exempt,
     502            'should_be_vat_exempt' => $should_be_vat_exempt,
     503            'vat_exempt_countries' => $vat_exempt_countries,
     504            'order_total' => $order->get_total(),
     505            'tax_total' => $order->get_total_tax(),
     506            'context' => 'Order created - Block checkout'
     507        ]);
     508    }
    222509}
  • wpify-woo/tags/5.0.14/src/Modules/IcDic/IcDicModule.php

    r3262059 r3319787  
    1818use WpifyWooDeps\Wpify\Asset\AssetFactory;
    1919use WpifyWooDeps\Wpify\PluginUtils\PluginUtils;
     20use WpifyWooDeps\Wpify\Log\RotatingFileLog;
    2021
    2122/**
     
    3233        private ApiManager $api_manager,
    3334        private WooCommerceIntegration $woo_integration,
     35        public RotatingFileLog $log,
    3436    ) {
    3537        parent::__construct();
     
    5456//      ) );
    5557        add_action( 'woocommerce_after_checkout_validation', array( $this, 'checkout_validation' ), 10, 2 );
     58        add_action( 'woocommerce_checkout_order_processed', array( $this, 'log_order_vat_exempt_decision' ), 10, 3 );
    5659        add_action( 'init', array( $this, 'add_rest_api' ) );
    5760
     
    7881            3
    7982        );
    80         add_action( 'init', array( $this, 'set_customer_vat_extempt' ) );
     83        add_action( 'wp', array( $this, 'set_customer_vat_extempt' ) ); // Only on frontend pages, not admin/ajax
    8184        add_action( 'woocommerce_checkout_update_order_review', array( $this, 'set_vat_extempt_on_order_review' ) );
    8285        add_filter( 'post_class', array( $this, 'add_post_class' ), 10, 3 );
    8386        add_filter( 'woocommerce_ajax_get_customer_details', array( $this, 'autofill_vat_fields_in_admin' ), 10, 3 );
     87       
     88       
    8489        new BlockSupport( $this );
    8590    }
     
    144149                    'changePlaceholder' => $this->get_setting( 'change_placeholder' ),
    145150                    'checkingText'      => __( 'Checking in', 'wpify-woo' ),
     151                    'validateAres'      => $this->get_setting( 'validate_ares' ),
    146152                ),
    147153            ),
     
    163169                        'autofillAresText'  => $this->get_setting( 'autofill_ares_text' ) ?: __( 'Autofill from Ares', 'wpify-woo' ),
    164170                        'searchAresText'    => $this->get_setting( 'submit_ares_text' ) ?: __( 'Search in Ares', 'wpify-woo' ),
     171                        'validateVies'      => $this->get_setting( 'validate_vies' ),
     172                        'viesFails'         => $this->get_setting( 'vies_fails' ),
     173                        'validateAres'      => $this->get_setting( 'validate_ares' ),
    165174                    ),
    166175                ),
     
    651660    public function checkout_validation( $fields, $errors ) {
    652661        $country = $_POST['billing_country'];
     662       
    653663
    654664        if ( $this->get_setting( 'validate_ares' )
     
    718728        }
    719729
     730
    720731        $is_required = '</strong> ' . _x( 'is a required field when purchasing for a company.', 'checkout-validation', 'wpify-woo' );
    721732
     
    760771        }
    761772
     773        if ( empty( $dic ) ) {
     774            return false;
     775        }
     776
    762777        $current_country = substr( $dic, 0, 2 );
    763778        $current_vat_no  = substr( $dic, 2 );
     
    797812
    798813    public function set_customer_vat_extempt() {
    799         if ( is_ajax() || is_admin() ) {
     814        // Only run on frontend pages, skip admin and AJAX
     815        if ( is_admin() || wp_doing_ajax() ) {
     816            return;
     817        }
     818
     819        // Skip if WooCommerce customer is not available
     820        if ( empty( WC()->customer ) ) {
    800821            return;
    801822        }
     
    804825        $vat_extempt_countries = $this->get_setting( 'zero_tax_for_vat_countries' );
    805826
     827        // Skip if VAT exempt functionality is not configured
    806828        if ( empty( $vat_extempt_countries ) ) {
    807829            return;
    808830        }
    809831
    810         $dic = null;
    811 
    812         if ( ! empty( WC()->customer ) ) {
    813             $dic = WC()->customer->get_billing_country() === 'SK'
    814                 ? WC()->customer->get_meta( 'billing_dic_dph' )
    815                 : WC()->customer->get_meta( 'billing_dic' );
    816         }
    817 
    818         if ( ! empty( $vies_fails ) && $vies_fails === true && ! $this->is_valid_dic( $dic ) ) {
    819             if ( ! empty( WC()->customer ) ) {
    820                 WC()->customer->set_is_vat_exempt( false );
    821             }
    822 
     832        $billing_country = WC()->customer->get_billing_country();
     833        $dic = $billing_country === 'SK'
     834            ? WC()->customer->get_meta( 'billing_dic_dph' )
     835            : WC()->customer->get_meta( 'billing_dic' );
     836
     837        // Create cache key based on current data
     838        $cache_key = 'vat_exempt_' . md5( $billing_country . '_' . $dic . '_' . WC()->customer->get_shipping_country() );
     839       
     840        // Check if we already calculated this recently (cache for current session)
     841        $cached_result = WC()->session->get( $cache_key );
     842        $cache_time = WC()->session->get( $cache_key . '_time' );
     843       
     844        // Use cache if it's less than 5 minutes old
     845        if ( $cached_result !== null && $cache_time && ( time() - $cache_time ) < 300 ) {
     846            WC()->customer->set_is_vat_exempt( $cached_result );
    823847            return;
    824848        }
    825849
    826         $is_vat_extempt = null;
    827         $session_key    = 'is_vat_extempt:' . $dic;
    828 
    829         if ( ! empty( WC()->session ) ) {
    830             $is_vat_extempt = WC()->session->get( $session_key );
    831         }
    832 
    833         if ( $is_vat_extempt === null ) {
    834             $is_vat_extempt = $this->is_vat_extempt( $dic );
    835         }
    836 
    837         if ( ! empty( WC()->session ) ) {
    838             WC()->session->set( $session_key, $is_vat_extempt );
    839         }
    840 
    841         if ( ! empty( WC()->customer ) ) {
    842             WC()->customer->set_is_vat_exempt( $is_vat_extempt );
    843         }
     850        // Calculate VAT exempt status
     851        $is_vat_extempt = false;
     852
     853        if ( ! empty( $dic ) ) {
     854            // If VIES fails is enabled and DIC is not valid, set to false
     855            if ( ! empty( $vies_fails ) && $vies_fails === true && ! $this->is_valid_dic( $dic ) ) {
     856                $is_vat_extempt = false;
     857            } else {
     858                $shipping_country = WC()->customer->get_shipping_country() ?: $billing_country;
     859                $is_vat_extempt = $this->is_vat_extempt( $dic, $shipping_country );
     860            }
     861        }
     862
     863        // Cache the result
     864        WC()->session->set( $cache_key, $is_vat_extempt );
     865        WC()->session->set( $cache_key . '_time', time() );
     866
     867        // Set customer VAT exempt status
     868        WC()->customer->set_is_vat_exempt( $is_vat_extempt );
     869    }
     870
     871    public function log_order_vat_exempt_decision( $order_id, $posted_data, $order ) {
     872        // Only log if DIC was provided
     873        $billing_country = $order->get_billing_country();
     874        $dic = $billing_country === 'SK'
     875            ? $order->get_meta('_billing_dic_dph')
     876            : $order->get_meta('_billing_dic');
     877           
     878        if ( empty( $dic ) ) {
     879            return; // No DIC provided, skip logging
     880        }
     881
     882        // Detect VAT exempt from order - if tax_total is 0 but order has taxable items, likely VAT exempt
     883        $customer_vat_exempt = ($order->get_total_tax() == 0 && $order->get_total() > 0);
     884        $vat_exempt_countries = $this->get_setting( 'zero_tax_for_vat_countries' );
     885        $shop_country = wc_get_base_location()['country'];
     886        $shipping_country = $order->get_shipping_country();
     887       
     888        // Determine if VAT should be exempt based on current logic 
     889        $should_be_vat_exempt = false;
     890        if ( ! empty( $vat_exempt_countries ) ) {
     891            $should_be_vat_exempt = $this->is_vat_extempt( $dic, $shipping_country );
     892        }
     893
     894        $this->log->info('Order VAT Exempt Decision', [
     895            'order_id' => $order->get_id(),
     896            'order_number' => $order->get_order_number(),
     897            'billing_country' => $billing_country,
     898            'shipping_country' => $shipping_country,
     899            'shop_country' => $shop_country,
     900            'submitted_dic' => $dic,
     901            'customer_vat_exempt' => $customer_vat_exempt,
     902            'should_be_vat_exempt' => $should_be_vat_exempt,
     903            'vat_exempt_countries' => $vat_exempt_countries,
     904            'order_total' => $order->get_total(),
     905            'tax_total' => $order->get_total_tax(),
     906            'context' => 'Order created - Classic checkout'
     907        ]);
    844908    }
    845909
     
    855919
    856920        $current_country = substr( $dic, 0, 2 );
     921       
     922        // Check applicability FIRST - if not applicable, don't waste time on VIES validation
     923        $is_applicable = $this->is_vat_extempt_applicable( $current_country, $shipping_country );
     924        if ( ! $is_applicable ) {
     925            return false; // Skip expensive VIES validation if result would be false anyway
     926        }
     927
    857928        $current_vat_no  = substr( $dic, 2 );
    858929        $vies            = new Vies();
     930        $is_valid        = false;
    859931
    860932        try {
     
    868940        }
    869941
    870         return $is_valid && $this->is_vat_extempt_applicable( $current_country, $shipping_country );
     942        return $is_valid;
    871943    }
    872944
     
    897969        wp_parse_str( $strdata, $data );
    898970
    899         $country = $data['billing_country'];
     971        $country = $data['billing_country'] ?? '';
    900972        $dic_dph = $country === 'SK'
    901             ? $data['billing_dic_dph']
    902             : $data['billing_dic'];
     973            ? ($data['billing_dic_dph'] ?? '')
     974            : ($data['billing_dic'] ?? '');
    903975
    904976        if ( ! empty( $vies_fails ) && $vies_fails === true && ! empty( $dic_dph ) && ! $this->is_valid_dic( $dic_dph ) ) {
    905977            WC()->customer->set_is_vat_exempt( false );
    906 
    907978            return;
    908979        }
     
    915986             )
    916987        ) {
    917             WC()->customer->set_is_vat_exempt( $this->is_vat_extempt( $dic_dph, $data['shipping_country'] ) );
     988            $vat_exempt_result = $this->is_vat_extempt( $dic_dph, $data['shipping_country'] ?? '' );
     989            WC()->customer->set_is_vat_exempt( $vat_exempt_result );
    918990        } else {
    919991            WC()->customer->set_is_vat_exempt( false );
     
    10051077        return $classes;
    10061078    }
     1079
     1080
     1081
    10071082}
  • wpify-woo/tags/5.0.14/src/Modules/IcDic/assets/icdic-blocks.js

    r3257809 r3319787  
    3939
    4040
    41 
    4241const App = () => {
    4342    const {extensionCartUpdate} = window.wc.blocksCheckout;
     
    4544    const [aresError, setAresError] = useState()
    4645    const [isAresLoading, setIsAresLoading] = useState()
     46    const [aresStatus, setAresStatus] = useState() // 'success', 'error', null
    4747    const [viesError, setViesError] = useState()
    4848    const [isViesLoading, setIsViesLoading] = useState()
     49    const [viesStatus, setViesStatus] = useState() // 'success', 'error', null
    4950    const cart = useCart();
    5051    const customer = useCustomerData();
    5152    const additionalFields = useAdditionalFields();
    5253    const {setAdditionalFields} = useDispatch(CHECKOUT_STORE_KEY);
    53     const { showValidationError, setValidationErrors, showAllValidationErrors } = useDispatch( VALIDATION_STORE_KEY );
     54    const {showValidationError, setValidationErrors, showAllValidationErrors} = useDispatch(VALIDATION_STORE_KEY);
    5455    const {setBillingAddress, setShippingAddress} = useDispatch(CART_STORE_KEY);
    5556
     
    103104        }
    104105
     106        // Show/hide ARES button based on settings and country
    105107        if (aresWrap && additionalFields?.['wpify/ic_dic_toggle'] && customer.billingAddress.country === 'CZ') {
    106             aresWrap.style.display = 'block';
     108            // Check if ARES validation on IC entered is enabled
     109            const aresOnIcEntered = window.wpifyWooIcDic.validateAres &&
     110                Array.isArray(window.wpifyWooIcDic.validateAres) &&
     111                window.wpifyWooIcDic.validateAres.includes('ic_entered');
     112
     113            // Show button only if ARES validation on IC entered is NOT enabled
     114            aresWrap.style.display = !aresOnIcEntered ? 'block' : 'none';
    107115        } else if (aresWrap) {
    108116            aresWrap.style.display = 'none';
     
    110118
    111119    }, [additionalFields, companyField, icField, dicField, dicDphField, companyFieldWrap, icFieldWrap, dicFieldWrap, dicDphFieldWrap, customer]);
     120
     121    // Reset status indicators when fields become empty
     122    useEffect(() => {
     123        // Reset ARES status if IC field is empty
     124        if (!additionalFields['wpify/ic'] || additionalFields['wpify/ic'].trim() === '') {
     125            setAresStatus(null);
     126            setAresError(null);
     127        }
     128
     129        // Reset VIES status if DIC fields are empty
     130        const currentDic = customer.billingAddress.country === 'SK'
     131            ? additionalFields['wpify/dic-dph']
     132            : additionalFields['wpify/dic'];
     133
     134        if (!currentDic || currentDic.trim() === '') {
     135            setViesStatus(null);
     136            setViesError(null);
     137        }
     138    }, [additionalFields, customer.billingAddress.country]);
     139
     140    // Reset VAT exempt on page load - always reset first, then check DIC
     141    useEffect(() => {
     142        // Always reset VAT exempt on page load first
     143        extensionCartUpdate({
     144            namespace: 'wpify_ic_dic',
     145            data: {validation: 'dic_cleared'}
     146        });
     147       
     148        // Then check if there are any DIC values on page load
     149        const currentDic = customer.billingAddress.country === 'SK'
     150            ? additionalFields['wpify/dic-dph']
     151            : additionalFields['wpify/dic'];
     152           
     153        if (currentDic && currentDic.trim() !== '') {
     154            // DIC exists on page load - validate it after a short delay
     155            setTimeout(() => {
     156                if (window.wpifyWooIcDic.validateVies) {
     157                    validateDic(normalizeDic(currentDic));
     158                } else {
     159                    // No VIES validation - just set VAT exempt based on settings
     160                    extensionCartUpdate({
     161                        namespace: 'wpify_ic_dic',
     162                        data: {
     163                            validation: 'passed',
     164                            country: customer.billingAddress.country,
     165                            dic: currentDic
     166                        }
     167                    });
     168                }
     169            }, 500);
     170        }
     171    }, []); // Run only once on component mount
     172
     173    // Clear validation errors and recalculate VAT exempt when country changes
     174    useEffect(() => {
     175        console.log('Country changed to:', customer.billingAddress.country);
     176
     177        // Clear ARES errors when switching away from Czech Republic
     178        if (customer.billingAddress.country !== 'CZ') {
     179            setAresError(null);
     180            setAresStatus(null);
     181            console.log('Cleared ARES error for non-Czech country');
     182        }
     183
     184        // Clear VIES errors when country changes
     185        setViesError(null);
     186        setViesStatus(null);
     187
     188        // Clear any validation errors from the store
     189        setValidationErrors({});
     190
     191        // Clear IČ DPH field when switching away from Slovakia
     192        let updatedFields = {...additionalFields};
     193        if (customer.billingAddress.country !== 'SK' && updatedFields['wpify/dic-dph']) {
     194            updatedFields['wpify/dic-dph'] = '';
     195            setAdditionalFields(updatedFields);
     196        }
     197
     198        // Get current DIC values AFTER clearing fields for country change
     199        const currentDic = customer.billingAddress.country === 'SK'
     200            ? (updatedFields['wpify/dic-dph'] || '')
     201            : (updatedFields['wpify/dic'] || '');
     202       
     203        // Reset VAT exempt on country change with current DIC state
     204        extensionCartUpdate({
     205            namespace: 'wpify_ic_dic',
     206            data: {
     207                validation: 'country_change',
     208                country: customer.billingAddress.country,
     209                dic: currentDic
     210            }
     211        });
     212
     213        // Revalidate existing field values for the new country if any exist
     214        if (currentDic && currentDic.length >= 4 && window.wpifyWooIcDic.validateVies) {
     215            // Revalidate the existing DIC for the new country context
     216            // Add delay to allow country change to process
     217            setTimeout(() => {
     218                validateDic(normalizeDic(currentDic));
     219            }, 300);
     220        }
     221
     222    }, [customer.billingAddress.country]);
    112223
    113224
     
    142253
    143254    useEffect(() => {
    144         if (!icField || customer.billingAddress.country !== 'CZ' ) {
     255        if (!icField) {
    145256            return;
    146257        }
     
    155266                additionalFields['wpify/ic'] = normalizedValue;
    156267                setAdditionalFields(additionalFields);
    157                 autofillAres();
     268
     269                console.log('IC field change:', {
     270                    country: customer.billingAddress.country,
     271                    value: normalizedValue,
     272                    willCallAres: customer.billingAddress.country === 'CZ'
     273                });
     274
     275                // Only call ARES autofill for Czech companies and if ic_entered validation is enabled
     276                if (customer.billingAddress.country === 'CZ') {
     277                    const aresOnIcEntered = window.wpifyWooIcDic.validateAres &&
     278                        Array.isArray(window.wpifyWooIcDic.validateAres) &&
     279                        window.wpifyWooIcDic.validateAres.includes('ic_entered');
     280
     281                    if (aresOnIcEntered) {
     282                        autofillAres();
     283                    }
     284                } else {
     285                    // Clear any previous ARES errors when switching away from CZ
     286                    setAresError(null);
     287                }
    158288            }, 2000);
    159289        };
     
    165295            icField.removeEventListener('input', handleIcInputChange);
    166296        };
    167     }, [icField]);
     297    }, [icField, customer.billingAddress.country]);
    168298
    169299    useEffect(() => {
     
    179309
    180310            typingTimeout = setTimeout(() => {
    181                 validateDic(normalizeDic(e.target.value));
    182             }, 2000);
     311                const normalizedValue = normalizeDic(e.target.value);
     312                // Only validate if there's actually a meaningful value (at least country + some digits)
     313                if (normalizedValue && normalizedValue.length >= 4) {
     314                    validateDic(normalizedValue);
     315                } else {
     316                    // DIC field is empty or too short - reset VAT exempt
     317                    extensionCartUpdate({
     318                        namespace: 'wpify_ic_dic',
     319                        data: {validation: 'dic_cleared'}
     320                    });
     321                }
     322            }, 1500); // Reduced from 2000ms to 1500ms
    183323        };
    184324
     
    208348    function validateDic(dic) {
    209349        setViesError(null);
     350        setViesStatus(null);
     351
     352        // Check if VIES validation is enabled in settings
     353        if (!window.wpifyWooIcDic.validateVies) {
     354            // VIES validation is disabled, don't validate
     355            return;
     356        }
     357
     358        // Skip validation if DIC is empty or too short
     359        if (!dic || dic.length < 4) {
     360            return;
     361        }
     362
    210363        setIsViesLoading(true);
    211364        if (window.wpifyWooIcDic.restUrl) {
    212365            fetchJson(window.wpifyWooIcDic.restUrl + '/icdic-vies?in=' + dic)
    213                 .then(({validation = {}}) => {
    214                     if (customer.billingAddress.country === 'SK') {
    215                         additionalFields['wpify/dic-dph'] = dic;
    216                     } else {
    217                         additionalFields['wpify/dic'] = dic;
     366                .then((response) => {
     367                    const validation = response.validation || {};
     368                    const warning = response.warning || null;
     369
     370                    // Clear previous errors if validation passed, show warning if present
     371                    if (validation === 'passed' && !warning) {
     372                        setViesError(null); // Clear any previous errors
     373                        setViesStatus('success');
     374                    } else if (warning) {
     375                        setViesError(warning);
     376                        setViesStatus('error');
    218377                    }
    219                     setAdditionalFields(additionalFields);
     378
     379                    // Don't overwrite field values - the user already entered the correct value
     380                    // The validation is just confirming it's valid, not changing it
     381                    // Let WooCommerce handle the field values naturally
     382
     383                    // Get country from the validated DIC value instead of customer object to ensure accuracy
     384                    const dicCountry = dic.match(/^[A-Z]{2}/) ? dic.substring(0, 2) : customer.billingAddress.country;
    220385
    221386                    extensionCartUpdate({
     
    223388                        data: {
    224389                            validation: validation,
    225                             country: customer.billingAddress.country
     390                            country: dicCountry,
     391                            dic: dic
    226392                        }
    227393                    })
     
    230396                        detail: {
    231397                            validation: validation,
     398                            warning: warning
    232399                        }
    233400                    });
     
    235402                })
    236403                .catch(error => {
     404                    // Only show error as warning, don't block checkout
     405                    // Final validation will happen server-side
    237406                    setViesError(error);
     407                    setViesStatus('error');
     408                   
     409                    // Reset VAT exempt when VIES validation fails
     410                    extensionCartUpdate({
     411                        namespace: 'wpify_ic_dic',
     412                        data: {
     413                            validation: 'failed',
     414                            country: customer.billingAddress.country,
     415                            dic: dic
     416                        }
     417                    });
    238418                })
    239419                .finally(() => {
     
    244424
    245425    const autofillAres = () => {
     426        // ARES is only for Czech companies
     427        if (customer.billingAddress.country !== 'CZ') {
     428            return;
     429        }
     430
    246431        setAresError(null);
     432        setAresStatus(null);
    247433        setIsAresLoading(true);
    248434        const ic = normalizeIc(additionalFields['wpify/ic']);
     
    255441                setAdditionalFields(additionalFields);
    256442
    257                 if (details.billing_dic) {
    258                     validateDic(normalizeDic(details.billing_dic))
     443                // Only validate DIC if we have one and VIES validation is enabled
     444                if (details.billing_dic && window.wpifyWooIcDic.validateVies) {
     445                    // Add small delay to ensure fields are updated first
     446                    setTimeout(() => {
     447                        validateDic(normalizeDic(details.billing_dic));
     448                    }, 100);
    259449                }
    260450
     
    274464                });
    275465                window.dispatchEvent(evt);
     466                setAresStatus('success');
    276467            })
    277468            .catch(error => {
    278469                setAresError(error);
     470                setAresStatus('error');
    279471            })
    280472            .finally(() => {
     
    283475
    284476    }
     477    // Create status indicator component
     478    const StatusIndicator = ({isLoading, status, error, fieldValue}) => {
     479        // Only show status indicators when field has content
     480        if (!fieldValue || fieldValue.trim() === '') {
     481            return null;
     482        }
     483
     484        if (isLoading) {
     485            return (
     486                <div style={{
     487                    position: 'absolute',
     488                    top: '50%', right: '14px',
     489                    transform: 'translateY(-50%)',
     490                    color: '#0073aa'
     491                }}>
     492                    <span style={{
     493                        display: 'inline-block',
     494                        width: '16px',
     495                        height: '16px',
     496                        border: '2px solid #f3f3f3',
     497                        borderTop: '2px solid #0073aa',
     498                        borderRadius: '50%',
     499                        animation: 'spin 1s linear infinite'
     500                    }}></span>
     501                    <style>{`
     502                        @keyframes spin {
     503                            0% { transform: rotate(0deg); }
     504                            100% { transform: rotate(360deg); }
     505                        }
     506                    `}</style>
     507                </div>
     508            );
     509        }
     510
     511        if (status === 'success') {
     512            return (
     513                <div style={{
     514                    position: 'absolute',
     515                    top: '50%', right: '14px',
     516                    transform: 'translatey(-50%)',
     517                    color: '#46b450'
     518                }}>
     519                    <span>✓</span>
     520                </div>
     521            );
     522        }
     523
     524        if (status === 'error' || error) {
     525            return (
     526                <div style={{
     527                    position: 'absolute',
     528                    top: '50%', right: '14px',
     529                    transform: 'translatey(-50%)',
     530                    color: '#dc3232'}}>
     531                    <span>!</span>
     532                </div>
     533            );
     534        }
     535
     536        return null;
     537    };
     538
    285539    if (!aresAdded) {
    286540        return null;
    287541    }
    288542
    289 
    290543    return (
    291544        <div>
     545            {icFieldWrap && createPortal(
     546                <>
     547                    <StatusIndicator
     548                        isLoading={isAresLoading}
     549                        status={aresStatus}
     550                        error={aresError}
     551                        fieldValue={additionalFields['wpify/ic']}
     552                    />
     553                    {aresError && additionalFields['wpify/ic'] && <p style={{color: '#dc3232', fontSize: '14px', marginTop: '4px'}}>{aresError}</p>}
     554                </>,
     555                icFieldWrap
     556            )}
     557
     558            {/* ARES button positioned after IC field */}
     559            {icFieldWrap && additionalFields?.['wpify/ic_dic_toggle'] && customer.billingAddress.country === 'CZ' && (() => {
     560                const aresOnIcEntered = window.wpifyWooIcDic.validateAres &&
     561                    Array.isArray(window.wpifyWooIcDic.validateAres) &&
     562                    window.wpifyWooIcDic.validateAres.includes('ic_entered');
     563
     564                if (!aresOnIcEntered) {
     565                    // Create a wrapper div that will be positioned right after the IC field
     566                    let aresButtonWrapper = document.querySelector('.wpify-ares-button-wrapper');
     567                    if (!aresButtonWrapper) {
     568                        aresButtonWrapper = document.createElement('div');
     569                        aresButtonWrapper.className = 'wpify-ares-button-wrapper';
     570                        icFieldWrap.insertAdjacentElement('afterend', aresButtonWrapper);
     571                    }
     572                   
     573                    return createPortal(
     574                        <div style={{marginTop: '8px'}}>
     575                            <input type="button" className="button wp-element-button" onClick={() => autofillAres()}
     576                                   value={window.wpifyWooIcDic.searchAresText}
     577                            />
     578                        </div>,
     579                        aresButtonWrapper
     580                    );
     581                }
     582                return null;
     583            })()}
     584
    292585            {createPortal(
    293586                <>
    294                     <div>
    295                         <input type="button" className="button wp-element-button" onClick={() => autofillAres()}
    296                                value={window.wpifyWooIcDic.searchAresText}
    297                         />
    298                         {isAresLoading && <div>Loading</div>}
    299                         {aresError && <div>{aresError}</div>}
    300                     </div>
    301                 </>,
    302                 aresWrap
    303             )}
    304             {createPortal(
    305                 <>
    306                     <div>
    307                         {isViesLoading && <div>Loading</div>}
    308                         {viesError && <div>{viesError}</div>}
    309                     </div>
     587                    <StatusIndicator
     588                        isLoading={isViesLoading}
     589                        status={viesStatus}
     590                        error={viesError}
     591                        fieldValue={customer.billingAddress.country === 'SK' ? additionalFields['wpify/dic-dph'] : additionalFields['wpify/dic']}
     592                    />
     593                    {viesError && (customer.billingAddress.country === 'SK' ? additionalFields['wpify/dic-dph'] : additionalFields['wpify/dic']) && <p style={{color: '#dc3232', fontSize: '14px', marginTop: '4px'}}>{viesError}</p>}
    310594                </>,
    311595                customer.billingAddress.country === 'SK' ? dicDphFieldWrap : dicFieldWrap
  • wpify-woo/tags/5.0.14/src/Modules/IcDic/assets/icdic.js

    r3257809 r3319787  
    438438        if (dom.dicField().classList.contains('wpify-woo-vies--validate') && state.get('country') !== 'SK' && e.target.value.length > 0) {
    439439            validateDic();
     440        } else {
     441            // Trigger update_checkout when field is cleared or validation doesn't run
     442            $(document.body).trigger('update_checkout');
    440443        }
    441444    });
     
    446449        if (dom.icDph().classList.contains('wpify-woo-vies--validate') && state.get('country') === 'SK' && e.target.value.length > 0) {
    447450            validateDic();
     451        } else {
     452            // Trigger update_checkout when field is cleared or validation doesn't run
     453            $(document.body).trigger('update_checkout');
    448454        }
    449455    });
  • wpify-woo/tags/5.0.14/src/Plugin.php

    r3319782 r3319787  
    2323
    2424    /** Plugin version */
    25     public const VERSION = '5.0.13';
     25    public const VERSION = '5.0.14';
    2626
    2727    /** Plugin slug name */
  • wpify-woo/tags/5.0.14/vendor/composer/installed.php

    r3319782 r3319787  
    22    'root' => array(
    33        'name' => 'wpify/woo',
    4         'pretty_version' => '5.0.13',
    5         'version' => '5.0.13.0',
    6         'reference' => '7d1c36c50d5ed21a816195dbd9aa58a5574a024b',
     4        'pretty_version' => '5.0.14',
     5        'version' => '5.0.14.0',
     6        'reference' => 'e4b83614529dec5c7bad5fffc4483b7c721554db',
    77        'type' => 'project',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        'wpify/woo' => array(
    14             'pretty_version' => '5.0.13',
    15             'version' => '5.0.13.0',
    16             'reference' => '7d1c36c50d5ed21a816195dbd9aa58a5574a024b',
     14            'pretty_version' => '5.0.14',
     15            'version' => '5.0.14.0',
     16            'reference' => 'e4b83614529dec5c7bad5fffc4483b7c721554db',
    1717            'type' => 'project',
    1818            'install_path' => __DIR__ . '/../../',
  • wpify-woo/tags/5.0.14/vendor/wpify-woo/composer/installed.php

    r3319782 r3319787  
    33namespace WpifyWooDeps;
    44
    5 return array('root' => array('name' => '__root__', 'pretty_version' => '5.0.13', 'version' => '5.0.13.0', 'reference' => '7d1c36c50d5ed21a816195dbd9aa58a5574a024b', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => \true), 'versions' => array('__root__' => array('pretty_version' => '5.0.13', 'version' => '5.0.13.0', 'reference' => '7d1c36c50d5ed21a816195dbd9aa58a5574a024b', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => \false), 'bacon/bacon-qr-code' => array('pretty_version' => '2.0.8', 'version' => '2.0.8.0', 'reference' => '8674e51bb65af933a5ffaf1c308a660387c35c22', 'type' => 'library', 'install_path' => __DIR__ . '/../bacon/bacon-qr-code', 'aliases' => array(), 'dev_requirement' => \false), 'dasprid/enum' => array('pretty_version' => '1.0.6', 'version' => '1.0.6.0', 'reference' => '8dfd07c6d2cf31c8da90c53b83c026c7696dda90', 'type' => 'library', 'install_path' => __DIR__ . '/../dasprid/enum', 'aliases' => array(), 'dev_requirement' => \false), 'dragonbe/vies' => array('pretty_version' => '2.3.2', 'version' => '2.3.2.0', 'reference' => 'd9193cbaba7e2faefbdc228fb1bf5670f20acf30', 'type' => 'tool', 'install_path' => __DIR__ . '/../dragonbe/vies', 'aliases' => array(), 'dev_requirement' => \false), 'endroid/qr-code' => array('pretty_version' => '4.5.0', 'version' => '4.5.0.0', 'reference' => '36681470bd10352b53bcb9731bdf2270e0d79b22', 'type' => 'library', 'install_path' => __DIR__ . '/../endroid/qr-code', 'aliases' => array(), 'dev_requirement' => \false), 'guzzlehttp/guzzle' => array('pretty_version' => '7.9.3', 'version' => '7.9.3.0', 'reference' => '7b2f29fe81dc4da0ca0ea7d42107a0845946ea77', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/guzzle', 'aliases' => array(), 'dev_requirement' => \false), 'guzzlehttp/promises' => array('pretty_version' => '2.2.0', 'version' => '2.2.0.0', 'reference' => '7c69f28996b0a6920945dd20b3857e499d9ca96c', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/promises', 'aliases' => array(), 'dev_requirement' => \false), 'guzzlehttp/psr7' => array('pretty_version' => '2.7.1', 'version' => '2.7.1.0', 'reference' => 'c2270caaabe631b3b44c85f99e5a04bbb8060d16', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/psr7', 'aliases' => array(), 'dev_requirement' => \false), 'h4kuna/ares' => array('pretty_version' => 'v3.0.13', 'version' => '3.0.13.0', 'reference' => 'd695e8b57b0410738d8eb9d7157bb8c7ec340d72', 'type' => 'library', 'install_path' => __DIR__ . '/../h4kuna/ares', 'aliases' => array(), 'dev_requirement' => \false), 'heureka/inflection' => array('pretty_version' => 'v3.0.4', 'version' => '3.0.4.0', 'reference' => '684ca578eee3ede920d5d3ca8d568fb70e7d9076', 'type' => 'library', 'install_path' => __DIR__ . '/../heureka/inflection', 'aliases' => array(), 'dev_requirement' => \false), 'heureka/overeno-zakazniky' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => 'aa52add431bac32c67b1c00b1969a98709cd611b', 'type' => 'library', 'install_path' => __DIR__ . '/../heureka/overeno-zakazniky', 'aliases' => array(), 'dev_requirement' => \false), 'laravel/serializable-closure' => array('pretty_version' => 'v1.3.7', 'version' => '1.3.7.0', 'reference' => '4f48ade902b94323ca3be7646db16209ec76be3d', 'type' => 'library', 'install_path' => __DIR__ . '/../laravel/serializable-closure', 'aliases' => array(), 'dev_requirement' => \false), 'monolog/monolog' => array('pretty_version' => '2.10.0', 'version' => '2.10.0.0', 'reference' => '5cf826f2991858b54d5c3809bee745560a1042a7', 'type' => 'library', 'install_path' => __DIR__ . '/../monolog/monolog', 'aliases' => array(), 'dev_requirement' => \false), 'nette/utils' => array('pretty_version' => 'v4.0.7', 'version' => '4.0.7.0', 'reference' => 'e67c4061eb40b9c113b218214e42cb5a0dda28f2', 'type' => 'library', 'install_path' => __DIR__ . '/../nette/utils', 'aliases' => array(), 'dev_requirement' => \false), 'php-di/invoker' => array('pretty_version' => '2.3.6', 'version' => '2.3.6.0', 'reference' => '59f15608528d8a8838d69b422a919fd6b16aa576', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/invoker', 'aliases' => array(), 'dev_requirement' => \false), 'php-di/php-di' => array('pretty_version' => '6.4.0', 'version' => '6.4.0.0', 'reference' => 'ae0f1b3b03d8b29dff81747063cbfd6276246cc4', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/php-di', 'aliases' => array(), 'dev_requirement' => \false), 'php-di/phpdoc-reader' => array('pretty_version' => '2.2.1', 'version' => '2.2.1.0', 'reference' => '66daff34cbd2627740ffec9469ffbac9f8c8185c', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/phpdoc-reader', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container' => array('pretty_version' => '1.1.2', 'version' => '1.1.2.0', 'reference' => '513e0666f7216c7459170d56df27dfcefe1689ea', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '^1.0')), 'psr/http-client' => array('pretty_version' => '1.0.3', 'version' => '1.0.3.0', 'reference' => 'bb5906edc1c324c9a05aa0873d40117941e5fa90', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-client', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-client-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/http-factory' => array('pretty_version' => '1.1.0', 'version' => '1.1.0.0', 'reference' => '2b4765fddfe3b508ac62f829e852b1501d3f6e8a', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-factory', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-factory-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/http-message' => array('pretty_version' => '2.0', 'version' => '2.0.0.0', 'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-message', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-message-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/log' => array('pretty_version' => '1.1.4', 'version' => '1.1.4.0', 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/log', 'aliases' => array(), 'dev_requirement' => \false), 'psr/log-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0.0 || 2.0.0 || 3.0.0')), 'ralouphie/getallheaders' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => '120b605dfeb996808c31b6477290a714d356e822', 'type' => 'library', 'install_path' => __DIR__ . '/../ralouphie/getallheaders', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/czqrpayment' => array('pretty_version' => 'v5.3.1', 'version' => '5.3.1.0', 'reference' => 'f8e0ecbbdb6d30bafb50a833cc7cfe4f575b82a4', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/czqrpayment', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/iban' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '7fe69bf9274792c37d5a8d9d38ef5cb000f8377a', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/iban', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/qr-payment-interface' => array('pretty_version' => 'v1.1.0', 'version' => '1.1.0.0', 'reference' => '752f7a6bf1190c7d65ead90b5989f61927436c89', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/qr-payment-interface', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/qr-payment-qr-code-provider' => array('pretty_version' => 'v1.2.0', 'version' => '1.2.0.0', 'reference' => 'd233c4bedeecf2ff7cd7e7d4ec7f4ad4a5eb4b64', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/qr-payment-qr-code-provider', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/skqrpayment' => array('pretty_version' => 'v4.2.2', 'version' => '4.2.2.0', 'reference' => '777fa98caaff3f10fb43f3cf67a8464c547e0550', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/skqrpayment', 'aliases' => array(), 'dev_requirement' => \false), 'spatie/array-to-xml' => array('pretty_version' => '2.17.1', 'version' => '2.17.1.0', 'reference' => '5cbec9c6ab17e320c58a259f0cebe88bde4a7c46', 'type' => 'library', 'install_path' => __DIR__ . '/../spatie/array-to-xml', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/deprecation-contracts' => array('pretty_version' => 'v3.6.0', 'version' => '3.6.0.0', 'reference' => '63afe740e99a13ba87ec199bb07bbdee937a5b62', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'woocommerce/action-scheduler' => array('pretty_version' => '3.9.2', 'version' => '3.9.2.0', 'reference' => 'efbb7953f72a433086335b249292f280dd43ddfe', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../woocommerce/action-scheduler', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/asset' => array('pretty_version' => '1.3.0', 'version' => '1.3.0.0', 'reference' => 'faf957af650b441b49f03cb7ffa42abfe157b43b', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/asset', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/custom-fields' => array('pretty_version' => '4.0.65', 'version' => '4.0.65.0', 'reference' => '2d3de7bbce4c14a524a7babe034a797461a7737c', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/custom-fields', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/license' => array('pretty_version' => '2.0.7', 'version' => '2.0.7.0', 'reference' => '7f8e7fe16a1bb77cdfcd29c694c5a489fc8db1b1', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/license', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/log' => array('pretty_version' => '1.1.1', 'version' => '1.1.1.0', 'reference' => '5b856a623a574d3ba4f2138d5f4d94c0625329ff', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/log', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/model' => array('pretty_version' => '4.1.24', 'version' => '4.1.24.0', 'reference' => 'ebcac0038014dd0a8d7af5b31e3ee1efa542e9ec', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/model', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/plugin-utils' => array('pretty_version' => '1.0.1', 'version' => '1.0.1.0', 'reference' => '0ace7f3a23bdfe3e2b2b05c72af79fa034c7e77a', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/plugin-utils', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/woo-core' => array('pretty_version' => '5.1.20', 'version' => '5.1.20.0', 'reference' => '2d2032c6da6b538079d8e152618b1e5493319409', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/woo-core', 'aliases' => array(), 'dev_requirement' => \false)));
     5return array('root' => array('name' => '__root__', 'pretty_version' => '5.0.14', 'version' => '5.0.14.0', 'reference' => 'e4b83614529dec5c7bad5fffc4483b7c721554db', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => \true), 'versions' => array('__root__' => array('pretty_version' => '5.0.14', 'version' => '5.0.14.0', 'reference' => 'e4b83614529dec5c7bad5fffc4483b7c721554db', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => \false), 'bacon/bacon-qr-code' => array('pretty_version' => '2.0.8', 'version' => '2.0.8.0', 'reference' => '8674e51bb65af933a5ffaf1c308a660387c35c22', 'type' => 'library', 'install_path' => __DIR__ . '/../bacon/bacon-qr-code', 'aliases' => array(), 'dev_requirement' => \false), 'dasprid/enum' => array('pretty_version' => '1.0.6', 'version' => '1.0.6.0', 'reference' => '8dfd07c6d2cf31c8da90c53b83c026c7696dda90', 'type' => 'library', 'install_path' => __DIR__ . '/../dasprid/enum', 'aliases' => array(), 'dev_requirement' => \false), 'dragonbe/vies' => array('pretty_version' => '2.3.2', 'version' => '2.3.2.0', 'reference' => 'd9193cbaba7e2faefbdc228fb1bf5670f20acf30', 'type' => 'tool', 'install_path' => __DIR__ . '/../dragonbe/vies', 'aliases' => array(), 'dev_requirement' => \false), 'endroid/qr-code' => array('pretty_version' => '4.5.0', 'version' => '4.5.0.0', 'reference' => '36681470bd10352b53bcb9731bdf2270e0d79b22', 'type' => 'library', 'install_path' => __DIR__ . '/../endroid/qr-code', 'aliases' => array(), 'dev_requirement' => \false), 'guzzlehttp/guzzle' => array('pretty_version' => '7.9.3', 'version' => '7.9.3.0', 'reference' => '7b2f29fe81dc4da0ca0ea7d42107a0845946ea77', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/guzzle', 'aliases' => array(), 'dev_requirement' => \false), 'guzzlehttp/promises' => array('pretty_version' => '2.2.0', 'version' => '2.2.0.0', 'reference' => '7c69f28996b0a6920945dd20b3857e499d9ca96c', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/promises', 'aliases' => array(), 'dev_requirement' => \false), 'guzzlehttp/psr7' => array('pretty_version' => '2.7.1', 'version' => '2.7.1.0', 'reference' => 'c2270caaabe631b3b44c85f99e5a04bbb8060d16', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/psr7', 'aliases' => array(), 'dev_requirement' => \false), 'h4kuna/ares' => array('pretty_version' => 'v3.0.13', 'version' => '3.0.13.0', 'reference' => 'd695e8b57b0410738d8eb9d7157bb8c7ec340d72', 'type' => 'library', 'install_path' => __DIR__ . '/../h4kuna/ares', 'aliases' => array(), 'dev_requirement' => \false), 'heureka/inflection' => array('pretty_version' => 'v3.0.4', 'version' => '3.0.4.0', 'reference' => '684ca578eee3ede920d5d3ca8d568fb70e7d9076', 'type' => 'library', 'install_path' => __DIR__ . '/../heureka/inflection', 'aliases' => array(), 'dev_requirement' => \false), 'heureka/overeno-zakazniky' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => 'aa52add431bac32c67b1c00b1969a98709cd611b', 'type' => 'library', 'install_path' => __DIR__ . '/../heureka/overeno-zakazniky', 'aliases' => array(), 'dev_requirement' => \false), 'laravel/serializable-closure' => array('pretty_version' => 'v1.3.7', 'version' => '1.3.7.0', 'reference' => '4f48ade902b94323ca3be7646db16209ec76be3d', 'type' => 'library', 'install_path' => __DIR__ . '/../laravel/serializable-closure', 'aliases' => array(), 'dev_requirement' => \false), 'monolog/monolog' => array('pretty_version' => '2.10.0', 'version' => '2.10.0.0', 'reference' => '5cf826f2991858b54d5c3809bee745560a1042a7', 'type' => 'library', 'install_path' => __DIR__ . '/../monolog/monolog', 'aliases' => array(), 'dev_requirement' => \false), 'nette/utils' => array('pretty_version' => 'v4.0.7', 'version' => '4.0.7.0', 'reference' => 'e67c4061eb40b9c113b218214e42cb5a0dda28f2', 'type' => 'library', 'install_path' => __DIR__ . '/../nette/utils', 'aliases' => array(), 'dev_requirement' => \false), 'php-di/invoker' => array('pretty_version' => '2.3.6', 'version' => '2.3.6.0', 'reference' => '59f15608528d8a8838d69b422a919fd6b16aa576', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/invoker', 'aliases' => array(), 'dev_requirement' => \false), 'php-di/php-di' => array('pretty_version' => '6.4.0', 'version' => '6.4.0.0', 'reference' => 'ae0f1b3b03d8b29dff81747063cbfd6276246cc4', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/php-di', 'aliases' => array(), 'dev_requirement' => \false), 'php-di/phpdoc-reader' => array('pretty_version' => '2.2.1', 'version' => '2.2.1.0', 'reference' => '66daff34cbd2627740ffec9469ffbac9f8c8185c', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/phpdoc-reader', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container' => array('pretty_version' => '1.1.2', 'version' => '1.1.2.0', 'reference' => '513e0666f7216c7459170d56df27dfcefe1689ea', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '^1.0')), 'psr/http-client' => array('pretty_version' => '1.0.3', 'version' => '1.0.3.0', 'reference' => 'bb5906edc1c324c9a05aa0873d40117941e5fa90', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-client', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-client-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/http-factory' => array('pretty_version' => '1.1.0', 'version' => '1.1.0.0', 'reference' => '2b4765fddfe3b508ac62f829e852b1501d3f6e8a', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-factory', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-factory-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/http-message' => array('pretty_version' => '2.0', 'version' => '2.0.0.0', 'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-message', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-message-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/log' => array('pretty_version' => '1.1.4', 'version' => '1.1.4.0', 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/log', 'aliases' => array(), 'dev_requirement' => \false), 'psr/log-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0.0 || 2.0.0 || 3.0.0')), 'ralouphie/getallheaders' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => '120b605dfeb996808c31b6477290a714d356e822', 'type' => 'library', 'install_path' => __DIR__ . '/../ralouphie/getallheaders', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/czqrpayment' => array('pretty_version' => 'v5.3.1', 'version' => '5.3.1.0', 'reference' => 'f8e0ecbbdb6d30bafb50a833cc7cfe4f575b82a4', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/czqrpayment', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/iban' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '7fe69bf9274792c37d5a8d9d38ef5cb000f8377a', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/iban', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/qr-payment-interface' => array('pretty_version' => 'v1.1.0', 'version' => '1.1.0.0', 'reference' => '752f7a6bf1190c7d65ead90b5989f61927436c89', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/qr-payment-interface', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/qr-payment-qr-code-provider' => array('pretty_version' => 'v1.2.0', 'version' => '1.2.0.0', 'reference' => 'd233c4bedeecf2ff7cd7e7d4ec7f4ad4a5eb4b64', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/qr-payment-qr-code-provider', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/skqrpayment' => array('pretty_version' => 'v4.2.2', 'version' => '4.2.2.0', 'reference' => '777fa98caaff3f10fb43f3cf67a8464c547e0550', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/skqrpayment', 'aliases' => array(), 'dev_requirement' => \false), 'spatie/array-to-xml' => array('pretty_version' => '2.17.1', 'version' => '2.17.1.0', 'reference' => '5cbec9c6ab17e320c58a259f0cebe88bde4a7c46', 'type' => 'library', 'install_path' => __DIR__ . '/../spatie/array-to-xml', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/deprecation-contracts' => array('pretty_version' => 'v3.6.0', 'version' => '3.6.0.0', 'reference' => '63afe740e99a13ba87ec199bb07bbdee937a5b62', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'woocommerce/action-scheduler' => array('pretty_version' => '3.9.2', 'version' => '3.9.2.0', 'reference' => 'efbb7953f72a433086335b249292f280dd43ddfe', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../woocommerce/action-scheduler', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/asset' => array('pretty_version' => '1.3.0', 'version' => '1.3.0.0', 'reference' => 'faf957af650b441b49f03cb7ffa42abfe157b43b', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/asset', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/custom-fields' => array('pretty_version' => '4.0.65', 'version' => '4.0.65.0', 'reference' => '2d3de7bbce4c14a524a7babe034a797461a7737c', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/custom-fields', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/license' => array('pretty_version' => '2.0.7', 'version' => '2.0.7.0', 'reference' => '7f8e7fe16a1bb77cdfcd29c694c5a489fc8db1b1', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/license', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/log' => array('pretty_version' => '1.1.1', 'version' => '1.1.1.0', 'reference' => '5b856a623a574d3ba4f2138d5f4d94c0625329ff', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/log', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/model' => array('pretty_version' => '4.1.24', 'version' => '4.1.24.0', 'reference' => 'ebcac0038014dd0a8d7af5b31e3ee1efa542e9ec', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/model', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/plugin-utils' => array('pretty_version' => '1.0.1', 'version' => '1.0.1.0', 'reference' => '0ace7f3a23bdfe3e2b2b05c72af79fa034c7e77a', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/plugin-utils', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/woo-core' => array('pretty_version' => '5.1.20', 'version' => '5.1.20.0', 'reference' => '2d2032c6da6b538079d8e152618b1e5493319409', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/woo-core', 'aliases' => array(), 'dev_requirement' => \false)));
  • wpify-woo/tags/5.0.14/wpify-woo.php

    r3319782 r3319787  
    44 * Plugin Name:          WPify Woo
    55 * Description:          Custom functionality for WooCommerce
    6  * Version:              5.0.13
     6 * Version:              5.0.14
    77 * Requires PHP:         8.1.0
    88 * Requires at least:    6.2
  • wpify-woo/trunk/build/icdic-blocks.asset.php

    r3257809 r3319787  
    1 <?php return array('dependencies' => array('react', 'react-dom', 'wp-data'), 'version' => '62f579dae4bd65d06774');
     1<?php return array('dependencies' => array('react', 'react-dom', 'wp-data'), 'version' => 'ef4718833722d4d04a35');
  • wpify-woo/trunk/build/icdic-blocks.js

    r3257809 r3319787  
    1 !function(){"use strict";var e={745:function(e,t,n){var i=n(850);t.s=i.createRoot,i.hydrateRoot},850:function(e){e.exports=window.ReactDOM}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var c=t[i]={exports:{}};return e[i](c,c.exports,n),c.exports}!function(){function e(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,i=Array(t);n<t;n++)i[n]=e[n];return i}function t(t,n){return function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,c,o,l=[],a=!0,u=!1;try{if(c=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;a=!1}else for(;!(a=(i=c.call(n)).done)&&(l.push(i.value),l.length!==t);a=!0);}catch(e){u=!0,r=e}finally{try{if(!a&&null!=n.return&&(o=n.return(),Object(o)!==o))return}finally{if(u)throw r}}return l}}(t,n)||function(t,n){if(t){if("string"==typeof t)return e(t,n);var i={}.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?e(t,n):void 0}}(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var i=window.React,r=window.wp.data,c=n(745),o=n(850),l=window.wc.wcBlocksData,a=l.CART_STORE_KEY,u=l.CHECKOUT_STORE_KEY,d=(l.COLLECTIONS_STORE_KEY,l.VALIDATION_STORE_KEY),s=function(){var e=window.wc.blocksCheckout.extensionCartUpdate,n=t((0,i.useState)(!1),2),c=n[0],l=n[1],s=t((0,i.useState)(),2),f=s[0],y=s[1],p=t((0,i.useState)(),2),w=p[0],m=p[1],v=t((0,i.useState)(),2),g=v[0],_=v[1],b=t((0,i.useState)(),2),E=b[0],h=b[1],S=((0,r.useSelect)((function(e){return e(a).getCartData()}),[]),(0,r.useSelect)((function(e){return e(a).getCustomerData()}),[])),A=(0,r.useSelect)((function(e){return e(u).getAdditionalFields()}),[]),C=(0,r.useDispatch)(u).setAdditionalFields,T=(0,r.useDispatch)(d),k=(T.showValidationError,T.setValidationErrors,T.showAllValidationErrors,(0,r.useDispatch)(a)),D=k.setBillingAddress,O=k.setShippingAddress,q=(0,r.useSelect)((function(e){return e(d).getValidationError("contact-wpify-dic")}),[]);console.log(q);var I=document.querySelector(".wc-block-components-address-form__wpify-company"),K=document.querySelector(".wc-block-components-address-form__wpify-ic"),L=document.querySelector(".wc-block-components-address-form__wpify-dic"),R=document.querySelector(".wc-block-components-address-form__wpify-dic-dph"),x=document.querySelector(".wc-block-components-address-form__wpify-ic"),U=document.querySelector("#wpify-ares"),j=document.querySelector("#contact-wpify-company"),V=document.querySelector("#contact-wpify-ic"),F=document.querySelector("#contact-wpify-dic"),W=document.querySelector("#contact-wpify-dic-dph");function Y(e){return(e=(e=e.replace(""," ")).replace(/[^a-zA-Z0-9]/g,"").toUpperCase()).match(/^[A-Z]{2}/)?e:S.billingAddress.country+e}function Z(e){return(e=e.replace(""," ")).replace(/\D/g,"")}function N(e,t){return new Promise((function(n,i){fetch(e,t).then((function(e){e.ok?e.json().then(n):e.json().then((function(e){return i(e.message)}))})).catch(i)}))}function P(t){_(null),h(!0),window.wpifyWooIcDic.restUrl&&N(window.wpifyWooIcDic.restUrl+"/icdic-vies?in="+t).then((function(n){var i=n.validation,r=void 0===i?{}:i;"SK"===S.billingAddress.country?A["wpify/dic-dph"]=t:A["wpify/dic"]=t,C(A),e({namespace:"wpify_ic_dic",data:{validation:r,country:S.billingAddress.country}});var c=new CustomEvent("wpify_woo_ic_dic_vies_valid",{detail:{validation:r}});window.dispatchEvent(c)})).catch((function(e){_(e)})).finally((function(){h(!1)}))}(0,i.useEffect)((function(){I&&(R&&(R.style.display="none"),null!=A&&A["wpify/ic_dic_toggle"]?(I.style.display="block",K.style.display="block",L.style.display="block",S.billingAddress.company&&(A["wpify/company"]=S.billingAddress.company)):(I.style.display="none",K.style.display="none",L.style.display="none",A["wpify/company"]="",A["wpify/ic"]="",A["wpify/dic"]="",A["wpify/dic-dph"]="",C(A)),null!=A&&A["wpify/ic_dic_toggle"]&&"SK"===S.billingAddress.country&&(R.style.display="block"),U&&null!=A&&A["wpify/ic_dic_toggle"]&&"CZ"===S.billingAddress.country?U.style.display="block":U&&(U.style.display="none"))}),[A,j,V,F,W,I,K,L,R,S]),(0,i.useEffect)((function(){if(x){var e=document.createElement("div");e.id="wpify-ares",x.appendChild(e),l(!0)}}),[x]),(0,i.useEffect)((function(){if(V&&"CZ"===S.billingAddress.country){var e,t=function(t){clearTimeout(e),e=setTimeout((function(){var e=Z(t.target.value);t.target.value=e,A["wpify/ic"]=e,C(A),B()}),2e3)};return V.addEventListener("input",t),function(){clearTimeout(e),V.removeEventListener("input",t)}}}),[V]),(0,i.useEffect)((function(){if(F||W){var e,t="SK"===S.billingAddress.country?W:F,n=function(t){clearTimeout(e),e=setTimeout((function(){P(Y(t.target.value))}),2e3)};return null==t||t.addEventListener("input",n),function(){clearTimeout(e),null==t||t.removeEventListener("input",n)}}}),[F,W,S.billingAddress.country]);var B=function(){y(null),m(!0);var e=Z(A["wpify/ic"]);N(window.wpifyWooIcDic.restUrl+"/icdic?in="+e).then((function(e){var t=e.details,n=void 0===t?{}:t;A["wpify/company"]=n.billing_company,A["wpify/ic"]=n.billing_ic,A["wpify/dic"]=n.billing_dic,C(A),n.billing_dic&&P(Y(n.billing_dic));var i={company:n.billing_company,address_1:n.billing_address_1,city:n.billing_city,postcode:n.billing_postcode};D(i),O(i);var r=new CustomEvent("wpify_woo_ic_dic_ares_autofilled",{detail:{details:n}});window.dispatchEvent(r)})).catch((function(e){y(e)})).finally((function(){m(!1)}))};return c?(0,i.createElement)("div",null,(0,o.createPortal)((0,i.createElement)(i.Fragment,null,(0,i.createElement)("div",null,(0,i.createElement)("input",{type:"button",className:"button wp-element-button",onClick:function(){return B()},value:window.wpifyWooIcDic.searchAresText}),w&&(0,i.createElement)("div",null,"Loading"),f&&(0,i.createElement)("div",null,f))),U),(0,o.createPortal)((0,i.createElement)(i.Fragment,null,(0,i.createElement)("div",null,E&&(0,i.createElement)("div",null,"Loading"),g&&(0,i.createElement)("div",null,g))),"SK"===S.billingAddress.country?R:L)):null};document.querySelectorAll('[data-app="wpify-ic-dic"]').forEach((function(e){(0,c.s)(e).render((0,i.createElement)(s,null))}))}()}();
     1!function(){"use strict";var e={745:function(e,t,i){var n=i(850);t.s=n.createRoot,n.hydrateRoot},850:function(e){e.exports=window.ReactDOM}},t={};function i(n){var r=t[n];if(void 0!==r)return r.exports;var o=t[n]={exports:{}};return e[n](o,o.exports,i),o.exports}!function(){function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e(t)}function t(t,i,n){return(i=function(t){var i=function(t){if("object"!=e(t)||!t)return t;var i=t[Symbol.toPrimitive];if(void 0!==i){var n=i.call(t,"string");if("object"!=e(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==e(i)?i:i+""}(i))in t?Object.defineProperty(t,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[i]=n,t}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var i=0,n=Array(t);i<t;i++)n[i]=e[i];return n}function r(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var n,r,o,c,l=[],a=!0,s=!1;try{if(o=(i=i.call(e)).next,0===t){if(Object(i)!==i)return;a=!1}else for(;!(a=(n=o.call(i)).done)&&(l.push(n.value),l.length!==t);a=!0);}catch(e){s=!0,r=e}finally{try{if(!a&&null!=i.return&&(c=i.return(),Object(c)!==c))return}finally{if(s)throw r}}return l}}(e,t)||function(e,t){if(e){if("string"==typeof e)return n(e,t);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?n(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var o=window.React,c=window.wp.data,l=i(745),a=i(850);function s(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,n)}return i}var d=window.wc.wcBlocksData,u=d.CART_STORE_KEY,f=d.CHECKOUT_STORE_KEY,y=(d.COLLECTIONS_STORE_KEY,d.VALIDATION_STORE_KEY),p=function(){var e=window.wc.blocksCheckout.extensionCartUpdate,i=r((0,o.useState)(!1),2),n=i[0],l=i[1],d=r((0,o.useState)(),2),p=d[0],w=d[1],m=r((0,o.useState)(),2),b=m[0],g=m[1],v=r((0,o.useState)(),2),A=v[0],_=v[1],h=r((0,o.useState)(),2),E=h[0],S=h[1],D=r((0,o.useState)(),2),O=D[0],C=D[1],I=r((0,o.useState)(),2),T=I[0],j=I[1],x=((0,c.useSelect)((function(e){return e(u).getCartData()}),[]),(0,c.useSelect)((function(e){return e(u).getCustomerData()}),[])),k=(0,c.useSelect)((function(e){return e(f).getAdditionalFields()}),[]),W=(0,c.useDispatch)(f).setAdditionalFields,P=(0,c.useDispatch)(y),K=(P.showValidationError,P.setValidationErrors),q=(P.showAllValidationErrors,(0,c.useDispatch)(u)),V=q.setBillingAddress,R=q.setShippingAddress,L=(0,c.useSelect)((function(e){return e(y).getValidationError("contact-wpify-dic")}),[]);console.log(L);var Z=document.querySelector(".wc-block-components-address-form__wpify-company"),U=document.querySelector(".wc-block-components-address-form__wpify-ic"),Y=document.querySelector(".wc-block-components-address-form__wpify-dic"),z=document.querySelector(".wc-block-components-address-form__wpify-dic-dph"),F=document.querySelector(".wc-block-components-address-form__wpify-ic"),N=document.querySelector("#wpify-ares"),B=document.querySelector("#contact-wpify-company"),M=document.querySelector("#contact-wpify-ic"),H=document.querySelector("#contact-wpify-dic"),$=document.querySelector("#contact-wpify-dic-dph");function G(e){return(e=(e=e.replace(""," ")).replace(/[^a-zA-Z0-9]/g,"").toUpperCase()).match(/^[A-Z]{2}/)?e:x.billingAddress.country+e}function J(e){return(e=e.replace(""," ")).replace(/\D/g,"")}function Q(e,t){return new Promise((function(i,n){fetch(e,t).then((function(e){e.ok?e.json().then(i):e.json().then((function(e){return n(e.message)}))})).catch(n)}))}function X(t){S(null),j(null),window.wpifyWooIcDic.validateVies&&(!t||t.length<4||(C(!0),window.wpifyWooIcDic.restUrl&&Q(window.wpifyWooIcDic.restUrl+"/icdic-vies?in="+t).then((function(i){var n=i.validation||{},r=i.warning||null;"passed"!==n||r?r&&(S(r),j("error")):(S(null),j("success"));var o=t.match(/^[A-Z]{2}/)?t.substring(0,2):x.billingAddress.country;e({namespace:"wpify_ic_dic",data:{validation:n,country:o,dic:t}});var c=new CustomEvent("wpify_woo_ic_dic_vies_valid",{detail:{validation:n,warning:r}});window.dispatchEvent(c)})).catch((function(i){S(i),j("error"),e({namespace:"wpify_ic_dic",data:{validation:"failed",country:x.billingAddress.country,dic:t}})})).finally((function(){C(!1)}))))}(0,o.useEffect)((function(){if(Z)if(z&&(z.style.display="none"),null!=k&&k["wpify/ic_dic_toggle"]?(Z.style.display="block",U.style.display="block",Y.style.display="block",x.billingAddress.company&&(k["wpify/company"]=x.billingAddress.company)):(Z.style.display="none",U.style.display="none",Y.style.display="none",k["wpify/company"]="",k["wpify/ic"]="",k["wpify/dic"]="",k["wpify/dic-dph"]="",W(k)),null!=k&&k["wpify/ic_dic_toggle"]&&"SK"===x.billingAddress.country&&(z.style.display="block"),N&&null!=k&&k["wpify/ic_dic_toggle"]&&"CZ"===x.billingAddress.country){var e=window.wpifyWooIcDic.validateAres&&Array.isArray(window.wpifyWooIcDic.validateAres)&&window.wpifyWooIcDic.validateAres.includes("ic_entered");N.style.display=e?"none":"block"}else N&&(N.style.display="none")}),[k,B,M,H,$,Z,U,Y,z,x]),(0,o.useEffect)((function(){k["wpify/ic"]&&""!==k["wpify/ic"].trim()||(_(null),w(null));var e="SK"===x.billingAddress.country?k["wpify/dic-dph"]:k["wpify/dic"];e&&""!==e.trim()||(j(null),S(null))}),[k,x.billingAddress.country]),(0,o.useEffect)((function(){e({namespace:"wpify_ic_dic",data:{validation:"dic_cleared"}});var t="SK"===x.billingAddress.country?k["wpify/dic-dph"]:k["wpify/dic"];t&&""!==t.trim()&&setTimeout((function(){window.wpifyWooIcDic.validateVies?X(G(t)):e({namespace:"wpify_ic_dic",data:{validation:"passed",country:x.billingAddress.country,dic:t}})}),500)}),[]),(0,o.useEffect)((function(){console.log("Country changed to:",x.billingAddress.country),"CZ"!==x.billingAddress.country&&(w(null),_(null),console.log("Cleared ARES error for non-Czech country")),S(null),j(null),K({});var i=function(e){for(var i=1;i<arguments.length;i++){var n=null!=arguments[i]?arguments[i]:{};i%2?s(Object(n),!0).forEach((function(i){t(e,i,n[i])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):s(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}({},k);"SK"!==x.billingAddress.country&&i["wpify/dic-dph"]&&(i["wpify/dic-dph"]="",W(i));var n="SK"===x.billingAddress.country?i["wpify/dic-dph"]||"":i["wpify/dic"]||"";e({namespace:"wpify_ic_dic",data:{validation:"country_change",country:x.billingAddress.country,dic:n}}),n&&n.length>=4&&window.wpifyWooIcDic.validateVies&&setTimeout((function(){X(G(n))}),300)}),[x.billingAddress.country]),(0,o.useEffect)((function(){if(F){var e=document.createElement("div");e.id="wpify-ares",F.appendChild(e),l(!0)}}),[F]),(0,o.useEffect)((function(){if(M){var e,t=function(t){clearTimeout(e),e=setTimeout((function(){var e=J(t.target.value);t.target.value=e,k["wpify/ic"]=e,W(k),console.log("IC field change:",{country:x.billingAddress.country,value:e,willCallAres:"CZ"===x.billingAddress.country}),"CZ"===x.billingAddress.country?window.wpifyWooIcDic.validateAres&&Array.isArray(window.wpifyWooIcDic.validateAres)&&window.wpifyWooIcDic.validateAres.includes("ic_entered")&&ee():w(null)}),2e3)};return M.addEventListener("input",t),function(){clearTimeout(e),M.removeEventListener("input",t)}}}),[M,x.billingAddress.country]),(0,o.useEffect)((function(){if(H||$){var t,i="SK"===x.billingAddress.country?$:H,n=function(i){clearTimeout(t),t=setTimeout((function(){var t=G(i.target.value);t&&t.length>=4?X(t):e({namespace:"wpify_ic_dic",data:{validation:"dic_cleared"}})}),1500)};return null==i||i.addEventListener("input",n),function(){clearTimeout(t),null==i||i.removeEventListener("input",n)}}}),[H,$,x.billingAddress.country]);var ee=function(){if("CZ"===x.billingAddress.country){w(null),_(null),g(!0);var e=J(k["wpify/ic"]);Q(window.wpifyWooIcDic.restUrl+"/icdic?in="+e).then((function(e){var t=e.details,i=void 0===t?{}:t;k["wpify/company"]=i.billing_company,k["wpify/ic"]=i.billing_ic,k["wpify/dic"]=i.billing_dic,W(k),i.billing_dic&&window.wpifyWooIcDic.validateVies&&setTimeout((function(){X(G(i.billing_dic))}),100);var n={company:i.billing_company,address_1:i.billing_address_1,city:i.billing_city,postcode:i.billing_postcode};V(n),R(n);var r=new CustomEvent("wpify_woo_ic_dic_ares_autofilled",{detail:{details:i}});window.dispatchEvent(r),_("success")})).catch((function(e){w(e),_("error")})).finally((function(){g(!1)}))}},te=function(e){var t=e.isLoading,i=e.status,n=e.error,r=e.fieldValue;return r&&""!==r.trim()?t?(0,o.createElement)("div",{style:{position:"absolute",top:"50%",right:"14px",transform:"translateY(-50%)",color:"#0073aa"}},(0,o.createElement)("span",{style:{display:"inline-block",width:"16px",height:"16px",border:"2px solid #f3f3f3",borderTop:"2px solid #0073aa",borderRadius:"50%",animation:"spin 1s linear infinite"}}),(0,o.createElement)("style",null,"\n\t\t\t\t\t\t@keyframes spin {\n\t\t\t\t\t\t\t0% { transform: rotate(0deg); }\n\t\t\t\t\t\t\t100% { transform: rotate(360deg); }\n\t\t\t\t\t\t}\n\t\t\t\t\t")):"success"===i?(0,o.createElement)("div",{style:{position:"absolute",top:"50%",right:"14px",transform:"translatey(-50%)",color:"#46b450"}},(0,o.createElement)("span",null,"✓")):"error"===i||n?(0,o.createElement)("div",{style:{position:"absolute",top:"50%",right:"14px",transform:"translatey(-50%)",color:"#dc3232"}},(0,o.createElement)("span",null,"!")):null:null};return n?(0,o.createElement)("div",null,U&&(0,a.createPortal)((0,o.createElement)(o.Fragment,null,(0,o.createElement)(te,{isLoading:b,status:A,error:p,fieldValue:k["wpify/ic"]}),p&&k["wpify/ic"]&&(0,o.createElement)("p",{style:{color:"#dc3232",fontSize:"14px",marginTop:"4px"}},p)),U),U&&(null==k?void 0:k["wpify/ic_dic_toggle"])&&"CZ"===x.billingAddress.country&&function(){if(!(window.wpifyWooIcDic.validateAres&&Array.isArray(window.wpifyWooIcDic.validateAres)&&window.wpifyWooIcDic.validateAres.includes("ic_entered"))){var e=document.querySelector(".wpify-ares-button-wrapper");return e||((e=document.createElement("div")).className="wpify-ares-button-wrapper",U.insertAdjacentElement("afterend",e)),(0,a.createPortal)((0,o.createElement)("div",{style:{marginTop:"8px"}},(0,o.createElement)("input",{type:"button",className:"button wp-element-button",onClick:function(){return ee()},value:window.wpifyWooIcDic.searchAresText})),e)}return null}(),(0,a.createPortal)((0,o.createElement)(o.Fragment,null,(0,o.createElement)(te,{isLoading:O,status:T,error:E,fieldValue:"SK"===x.billingAddress.country?k["wpify/dic-dph"]:k["wpify/dic"]}),E&&("SK"===x.billingAddress.country?k["wpify/dic-dph"]:k["wpify/dic"])&&(0,o.createElement)("p",{style:{color:"#dc3232",fontSize:"14px",marginTop:"4px"}},E)),"SK"===x.billingAddress.country?z:Y)):null};document.querySelectorAll('[data-app="wpify-ic-dic"]').forEach((function(e){(0,l.s)(e).render((0,o.createElement)(p,null))}))}()}();
  • wpify-woo/trunk/build/icdic.asset.php

    r3257809 r3319787  
    1 <?php return array('dependencies' => array(), 'version' => '6e4d995b05dd68d2e69d');
     1<?php return array('dependencies' => array(), 'version' => '8a3654a2c1c4c8f21284');
  • wpify-woo/trunk/build/icdic.js

    r3257809 r3319787  
    1 window.jQuery(document).ready((function(e){window.wpifyWooIcDic=window.wpifyWooIcDic||{changePlaceholder:null,requireCompany:null,moveCompany:null,requireVatFields:null,optionalText:"",restUrl:null,position:""};var n={addEventListener:function(){return null},style:{display:"none"},value:"",placeholder:"",classList:{contains:function(){return!1}},disabled:!1},i=function(){return document.querySelector("#company_details")||n},t=function(){return document.querySelector("#billing_company")||n},o=function(){return document.querySelector("#billing_company_field")||n},c=function(){return document.querySelector("#billing_ic")||n},a=function(){return document.querySelector("#ares_in")||n},l=function(){return document.querySelector("#billing_ic_field")||n},u=function(){return document.querySelector("#billing_dic")||n},r=function(){return document.querySelector("#billing_dic_field")||n},s=function(){return document.querySelector("#billing_dic_dph")||n},d=function(){return document.querySelector("#billing_dic_dph_field")||n},y=function(){return document.querySelector("#wpify-woo-ares-autofill")||n},p=function(){return document.querySelector("#billing_country")||n},f={subscribers:[],data:{companyDetails:!1,ic:"",dic:"",icDph:"",country:"",company:"",aresResult:"",aresLoading:!1,viesResult:"",viesLoading:!1,disableSubmit:!1},get:function(e){return this.data[e]},set:function(e){var n=this;Object.keys(e).forEach((function(i){n.data[i]=e[i]})),this.subscribers.forEach((function(e){return e(n.data)}))},subscribe:function(e){this.subscribers.push(e)},sync:function(){var e={companyDetails:i().checked,ic:c().value,dic:u().value,icDph:s().value,country:p().value,company:t().value};(e.ic||e.dic||void 0===e.companyDetails)&&(e.companyDetails=!0),e.companyDetails||(e.ic="",e.dic="",e.icDph="",e.company=""),this.set(e)}};function m(e){var t,a;if(void 0!==e.companyDetails&&(e.companyDetails?(o().style.display="block",l().style.display="block",r().style.display="block"):(window.wpifyWooIcDic.moveCompany&&(o().style.display="none"),l().style.display="none",r().style.display="none")),"before_customer_details"!==window.wpifyWooIcDic.position&&e.companyDetails&&"CZ"===e.country||"before_customer_details"===window.wpifyWooIcDic.position&&"CZ"===e.country?y().style.display="block":y().style.display="none",e.companyDetails&&"SK"===e.country?d().style.display="block":d().style.display="none",window.wpifyWooIcDic.changePlaceholder&&(c().placeholder="123456789",e.companyDetails&&"SK"===e.country?(u().placeholder="123456789",s().placeholder=e.country+"1234567890"):e.companyDetails&&(u().placeholder=e.country+"123456789",s().placeholder="")),window.wpifyWooIcDic.requireCompany&&(e.companyDetails?v(o()):g(o())),e.companyDetails&&("if_checkbox"===window.wpifyWooIcDic.requireVatFields||"if_company"===window.wpifyWooIcDic.requireVatFields&&""!==e.company)?v(l()):g(l()),i().checked=!!e.companyDetails,document.querySelectorAll(".wpify-woo__ic-error").forEach((function(e){return e.remove()})),e.aresLoading?null===(t=c())||void 0===t||null===(t=t.parentNode)||void 0===t||t.classList.add("loading"):null===(a=c())||void 0===a||null===(a=a.parentNode)||void 0===a||a.classList.remove("loading"),e.aresResult&&!1===e.aresLoading){var p,f=document.createElement("div");f.innerHTML=e.aresResult,f.classList.add("wpify-woo__ic-error"),null===(p=c())||void 0===p||null===(p=p.parentNode)||void 0===p||p.insertBefore(f,c().nextSibling)}var m,b,w="SK"===e.country?s():u();if(e.viesLoading?null==w||null===(m=w.parentNode)||void 0===m||m.classList.add("loading"):null==w||null===(b=w.parentNode)||void 0===b||b.classList.remove("loading"),e.viesResult&&!1===e.viesLoading){var h,_=document.createElement("div");_.innerHTML=e.viesResult,_.classList.add("wpify-woo__ic-error"),null==w||null===(h=w.parentNode)||void 0===h||h.insertBefore(_,w.nextSibling)}(document.querySelector("#place_order")||n).disabled=!!e.disableSubmit}function v(e){if(void 0!==e.querySelector){var n=e.querySelector("label span");e.classList.add("validate-required"),n&&(n.className="required",n.innerText="*")}}function g(e){if(void 0!==e.querySelector){var n=e.querySelector("label span");e.classList.remove("validate-required"),n&&(n.className="optional",n.innerText=wpifyWooIcDic.optionalText)}}function b(e,n){return new Promise((function(i,t){fetch(e,n).then((function(e){e.ok?e.json().then(i):e.json().then((function(e){return t(e.message)}))})).catch(t)}))}function w(){if(window.wpifyWooIcDic.restUrl&&!f.get("aresLoading")){var n=_(c().value||a().value);f.set({aresLoading:!0}),b(window.wpifyWooIcDic.restUrl+"/icdic?in="+n).then((function(n){var i=n.details,t=void 0===i?{}:i;Object.keys(t).forEach((function(n){var i=document.getElementById(n);i.value=t[n],"billing_ic"!==n&&i&&e(i).trigger("change")})),f.set({aresResult:""});var o=new CustomEvent("wpify_woo_ic_dic_ares_autofilled",{detail:{details:t}});window.dispatchEvent(o)})).catch((function(e){f.set({aresResult:e})})).finally((function(){f.set({aresLoading:!1,companyDetails:!0})}))}}function h(e){return(e=e.replace(/[^a-zA-Z0-9]/g,"").toUpperCase()).match(/^[A-Z]{2}/)?e:p().value+e}function _(e){return e.replace(/\D/g,"")}f.subscribe(m);var D=null;function S(){if(window.wpifyWooIcDic.restUrl&&!f.get("viesLoading")){window.clearTimeout(D);var n="SK"===f.get("country")?h(f.get("icDph")):h(f.get("dic"));f.get("viesLastChecked")!==n?(f.set({viesResult:"",viesLoading:!0,disableSubmit:!0}),b(window.wpifyWooIcDic.restUrl+"/icdic-vies?in="+n).then((function(){"SK"===f.get("country")?s().value=n:u().value=n})).catch((function(e){f.set({viesResult:e})})).finally((function(){e(document.body).trigger("update_checkout"),f.set({viesLoading:!1,disableSubmit:!1,viesLastChecked:n})}))):f.set({viesLoading:!1,disableSubmit:!1})}}f.sync(),e(document.body).on("change","input[name=company_details]",(function(n){var i={companyDetails:n.target.checked};i.companyDetails||(i.ic="",i.dic="",i.icDph="",i.company="",c().value="",u().value="",s().value="",t().value="",e(document.body).trigger("update_checkout")),f.set(i)})),e(document.body).on("change","input[name=billing_company]",(function(e){f.set({company:e.target.value})})),e(document.body).on("change","select[name=billing_country]",(function(e){f.set({country:e.target.value})})),e(document.body).on("change","input[name=billing_ic]",(function(e){f.set({ic:e.target.value}),l().classList.contains("wpify-woo-ic--validate")&&("CZ"===f.get("country")&&e.target.value.length>0?w():f.set({aresResult:""}))})),e(document.body).on("keyup change","input[name=billing_ic]",(function(e){a().value=_(e.target.value)})),e(document.body).on("keyup change","#ares_in",(function(e){c().value=_(e.target.value)})),e(document.body).on("click","#wpify-woo-icdic__ares-submit",w),e(document.body).on("change","input[name=billing_dic]",(function(e){f.set({dic:e.target.value}),r().classList.contains("wpify-woo-vies--validate")&&"SK"!==f.get("country")&&e.target.value.length>0&&S()})),e(document.body).on("change","input[name=billing_dic_dph]",(function(e){f.set({icDph:e.target.value}),s().classList.contains("wpify-woo-vies--validate")&&"SK"===f.get("country")&&e.target.value.length>0&&S()})),e(document.body).on("keyup","input[name=billing_dic]",(function(e){r().classList.contains("wpify-woo-vies--validate")&&"SK"!==f.get("country")&&e.target.value.length>0&&(window.clearTimeout(D),f.set({disableSubmit:!0,dic:e.target.value}),window.setTimeout(S,2e3))})),e(document.body).on("keyup","input[name=billing_dic_dph]",(function(e){r().classList.contains("wpify-woo-vies--validate")&&"SK"===f.get("country")&&e.target.value.length>0&&(window.clearTimeout(D),f.set({disableSubmit:!0,icDph:e.target.value}),window.setTimeout(S,2e3))})),e(document.body).on("click","#wpify-woo-icdic__ares-autofill-button",(function(e){e.preventDefault(),document.querySelector(".wpify-woo-icdic__ares-autofill").style.display="block"})),e("form[name=checkout]").on("keydown","input,select,button",(function(e){"Enter"===e.key&&!0===f.get("disableSubmit")&&e.preventDefault()})).on("click","input[type=button],button",(function(e){!0===f.get("disableSubmit")&&e.preventDefault()})),e(document.body).on("updated_checkout",(function(){m(f.data)}))}));
     1window.jQuery(document).ready((function(e){window.wpifyWooIcDic=window.wpifyWooIcDic||{changePlaceholder:null,requireCompany:null,moveCompany:null,requireVatFields:null,optionalText:"",restUrl:null,position:""};var n={addEventListener:function(){return null},style:{display:"none"},value:"",placeholder:"",classList:{contains:function(){return!1}},disabled:!1},i=function(){return document.querySelector("#company_details")||n},t=function(){return document.querySelector("#billing_company")||n},o=function(){return document.querySelector("#billing_company_field")||n},c=function(){return document.querySelector("#billing_ic")||n},a=function(){return document.querySelector("#ares_in")||n},l=function(){return document.querySelector("#billing_ic_field")||n},u=function(){return document.querySelector("#billing_dic")||n},r=function(){return document.querySelector("#billing_dic_field")||n},s=function(){return document.querySelector("#billing_dic_dph")||n},d=function(){return document.querySelector("#billing_dic_dph_field")||n},y=function(){return document.querySelector("#wpify-woo-ares-autofill")||n},p=function(){return document.querySelector("#billing_country")||n},f={subscribers:[],data:{companyDetails:!1,ic:"",dic:"",icDph:"",country:"",company:"",aresResult:"",aresLoading:!1,viesResult:"",viesLoading:!1,disableSubmit:!1},get:function(e){return this.data[e]},set:function(e){var n=this;Object.keys(e).forEach((function(i){n.data[i]=e[i]})),this.subscribers.forEach((function(e){return e(n.data)}))},subscribe:function(e){this.subscribers.push(e)},sync:function(){var e={companyDetails:i().checked,ic:c().value,dic:u().value,icDph:s().value,country:p().value,company:t().value};(e.ic||e.dic||void 0===e.companyDetails)&&(e.companyDetails=!0),e.companyDetails||(e.ic="",e.dic="",e.icDph="",e.company=""),this.set(e)}};function m(e){var t,a;if(void 0!==e.companyDetails&&(e.companyDetails?(o().style.display="block",l().style.display="block",r().style.display="block"):(window.wpifyWooIcDic.moveCompany&&(o().style.display="none"),l().style.display="none",r().style.display="none")),"before_customer_details"!==window.wpifyWooIcDic.position&&e.companyDetails&&"CZ"===e.country||"before_customer_details"===window.wpifyWooIcDic.position&&"CZ"===e.country?y().style.display="block":y().style.display="none",e.companyDetails&&"SK"===e.country?d().style.display="block":d().style.display="none",window.wpifyWooIcDic.changePlaceholder&&(c().placeholder="123456789",e.companyDetails&&"SK"===e.country?(u().placeholder="123456789",s().placeholder=e.country+"1234567890"):e.companyDetails&&(u().placeholder=e.country+"123456789",s().placeholder="")),window.wpifyWooIcDic.requireCompany&&(e.companyDetails?v(o()):g(o())),e.companyDetails&&("if_checkbox"===window.wpifyWooIcDic.requireVatFields||"if_company"===window.wpifyWooIcDic.requireVatFields&&""!==e.company)?v(l()):g(l()),i().checked=!!e.companyDetails,document.querySelectorAll(".wpify-woo__ic-error").forEach((function(e){return e.remove()})),e.aresLoading?null===(t=c())||void 0===t||null===(t=t.parentNode)||void 0===t||t.classList.add("loading"):null===(a=c())||void 0===a||null===(a=a.parentNode)||void 0===a||a.classList.remove("loading"),e.aresResult&&!1===e.aresLoading){var p,f=document.createElement("div");f.innerHTML=e.aresResult,f.classList.add("wpify-woo__ic-error"),null===(p=c())||void 0===p||null===(p=p.parentNode)||void 0===p||p.insertBefore(f,c().nextSibling)}var m,b,w="SK"===e.country?s():u();if(e.viesLoading?null==w||null===(m=w.parentNode)||void 0===m||m.classList.add("loading"):null==w||null===(b=w.parentNode)||void 0===b||b.classList.remove("loading"),e.viesResult&&!1===e.viesLoading){var h,_=document.createElement("div");_.innerHTML=e.viesResult,_.classList.add("wpify-woo__ic-error"),null==w||null===(h=w.parentNode)||void 0===h||h.insertBefore(_,w.nextSibling)}(document.querySelector("#place_order")||n).disabled=!!e.disableSubmit}function v(e){if(void 0!==e.querySelector){var n=e.querySelector("label span");e.classList.add("validate-required"),n&&(n.className="required",n.innerText="*")}}function g(e){if(void 0!==e.querySelector){var n=e.querySelector("label span");e.classList.remove("validate-required"),n&&(n.className="optional",n.innerText=wpifyWooIcDic.optionalText)}}function b(e,n){return new Promise((function(i,t){fetch(e,n).then((function(e){e.ok?e.json().then(i):e.json().then((function(e){return t(e.message)}))})).catch(t)}))}function w(){if(window.wpifyWooIcDic.restUrl&&!f.get("aresLoading")){var n=_(c().value||a().value);f.set({aresLoading:!0}),b(window.wpifyWooIcDic.restUrl+"/icdic?in="+n).then((function(n){var i=n.details,t=void 0===i?{}:i;Object.keys(t).forEach((function(n){var i=document.getElementById(n);i.value=t[n],"billing_ic"!==n&&i&&e(i).trigger("change")})),f.set({aresResult:""});var o=new CustomEvent("wpify_woo_ic_dic_ares_autofilled",{detail:{details:t}});window.dispatchEvent(o)})).catch((function(e){f.set({aresResult:e})})).finally((function(){f.set({aresLoading:!1,companyDetails:!0})}))}}function h(e){return(e=e.replace(/[^a-zA-Z0-9]/g,"").toUpperCase()).match(/^[A-Z]{2}/)?e:p().value+e}function _(e){return e.replace(/\D/g,"")}f.subscribe(m);var D=null;function S(){if(window.wpifyWooIcDic.restUrl&&!f.get("viesLoading")){window.clearTimeout(D);var n="SK"===f.get("country")?h(f.get("icDph")):h(f.get("dic"));f.get("viesLastChecked")!==n?(f.set({viesResult:"",viesLoading:!0,disableSubmit:!0}),b(window.wpifyWooIcDic.restUrl+"/icdic-vies?in="+n).then((function(){"SK"===f.get("country")?s().value=n:u().value=n})).catch((function(e){f.set({viesResult:e})})).finally((function(){e(document.body).trigger("update_checkout"),f.set({viesLoading:!1,disableSubmit:!1,viesLastChecked:n})}))):f.set({viesLoading:!1,disableSubmit:!1})}}f.sync(),e(document.body).on("change","input[name=company_details]",(function(n){var i={companyDetails:n.target.checked};i.companyDetails||(i.ic="",i.dic="",i.icDph="",i.company="",c().value="",u().value="",s().value="",t().value="",e(document.body).trigger("update_checkout")),f.set(i)})),e(document.body).on("change","input[name=billing_company]",(function(e){f.set({company:e.target.value})})),e(document.body).on("change","select[name=billing_country]",(function(e){f.set({country:e.target.value})})),e(document.body).on("change","input[name=billing_ic]",(function(e){f.set({ic:e.target.value}),l().classList.contains("wpify-woo-ic--validate")&&("CZ"===f.get("country")&&e.target.value.length>0?w():f.set({aresResult:""}))})),e(document.body).on("keyup change","input[name=billing_ic]",(function(e){a().value=_(e.target.value)})),e(document.body).on("keyup change","#ares_in",(function(e){c().value=_(e.target.value)})),e(document.body).on("click","#wpify-woo-icdic__ares-submit",w),e(document.body).on("change","input[name=billing_dic]",(function(n){f.set({dic:n.target.value}),r().classList.contains("wpify-woo-vies--validate")&&"SK"!==f.get("country")&&n.target.value.length>0?S():e(document.body).trigger("update_checkout")})),e(document.body).on("change","input[name=billing_dic_dph]",(function(n){f.set({icDph:n.target.value}),s().classList.contains("wpify-woo-vies--validate")&&"SK"===f.get("country")&&n.target.value.length>0?S():e(document.body).trigger("update_checkout")})),e(document.body).on("keyup","input[name=billing_dic]",(function(e){r().classList.contains("wpify-woo-vies--validate")&&"SK"!==f.get("country")&&e.target.value.length>0&&(window.clearTimeout(D),f.set({disableSubmit:!0,dic:e.target.value}),window.setTimeout(S,2e3))})),e(document.body).on("keyup","input[name=billing_dic_dph]",(function(e){r().classList.contains("wpify-woo-vies--validate")&&"SK"===f.get("country")&&e.target.value.length>0&&(window.clearTimeout(D),f.set({disableSubmit:!0,icDph:e.target.value}),window.setTimeout(S,2e3))})),e(document.body).on("click","#wpify-woo-icdic__ares-autofill-button",(function(e){e.preventDefault(),document.querySelector(".wpify-woo-icdic__ares-autofill").style.display="block"})),e("form[name=checkout]").on("keydown","input,select,button",(function(e){"Enter"===e.key&&!0===f.get("disableSubmit")&&e.preventDefault()})).on("click","input[type=button],button",(function(e){!0===f.get("disableSubmit")&&e.preventDefault()})),e(document.body).on("updated_checkout",(function(){m(f.data)}))}));
  • wpify-woo/trunk/readme.txt

    r3319782 r3319787  
    55Tested up to: 6.8
    66Requires PHP: 8.1
    7 Stable tag: 5.0.13
     7Stable tag: 5.0.14
    88License: GPLv2 or later
    99License URI: https://www.gnu.org/licenses/gpl-2.0.html
     
    219219
    220220== Changelog ==
     221= 5.0.14 =
     222* Fix VAT exempt calculation bug in block checkout
     223* Fix VAT exempt timing issue in block checkout
     224* Optimize performance by reducing excessive validation calls during checkout
     225* Add logging for VAT exempt
     226* Improve VAT exempt logic to handle different validation states properly
     227
    221228= 5.0.13 =
    222229* Add global unique id support for EAN in XML feed
  • wpify-woo/trunk/src/Modules/IcDic/Api/IcDicApi.php

    r3257809 r3319787  
    118118        }
    119119
    120         if ( ! $this->module->is_valid_dic( $dic ) ) {
     120        // Check if VIES validation is enabled
     121        if ( ! $this->module->get_setting( 'validate_vies' ) ) {
     122            return new WP_REST_Response( array( 'validation' => 'skipped' ), 200 );
     123        }
     124
     125        $is_valid = $this->module->is_valid_dic( $dic );
     126       
     127        // If VIES validation fails and vies_fails is disabled, return error (blocks order)
     128        if ( ! $is_valid && $this->module->get_setting( 'vies_fails' ) !== true ) {
    121129            return new \WP_Error( 'not-found', $error_text );
    122130        }
    123131
     132        // If VIES validation fails but vies_fails is enabled, return passed with warning
     133        if ( ! $is_valid && $this->module->get_setting( 'vies_fails' ) === true ) {
     134            return new WP_REST_Response( array(
     135                'validation' => 'passed',
     136                'warning' => $error_text
     137            ), 200 );
     138        }
     139
     140        // Return validation result - BlockSupport will handle VAT exempt logic
    124141        return new WP_REST_Response( array( 'validation' => 'passed' ), 200 );
    125142    }
  • wpify-woo/trunk/src/Modules/IcDic/BlockSupport.php

    r3262059 r3319787  
    1212class BlockSupport {
    1313    public $module = null;
     14    private $current_checkout_country = null;
    1415
    1516    public function __construct( $module ) {
     
    3536        }, 10, 3 );
    3637        add_action( 'woocommerce_validate_additional_field', [ $this, 'validate_ic_dic_fields' ], 10, 3 );
     38        // Hook to capture current country from checkout data during validation
     39        add_action( 'woocommerce_store_api_checkout_update_customer_from_request', [ $this, 'capture_country_before_validation' ], 5, 2 );
     40
     41        // Final VIES validation on order submission (both checkouts)
     42        add_action( 'rest_api_init', [ $this, 'register_block_checkout_vies_validation' ], 5 );
     43
     44        // Ensure VAT exempt is set before order totals calculation
     45        add_action( 'woocommerce_store_api_checkout_update_customer_from_request', [ $this, 'ensure_vat_exempt_from_checkout_data' ], 20, 2 );
     46       
     47        // Log VAT exempt decision after order is created
     48        add_action( 'woocommerce_store_api_checkout_order_processed', [ $this, 'log_order_vat_exempt_decision' ] );
    3749
    3850        $this->register_vat_exempt_callback();
     
    115127    }
    116128
    117     public function sanitize_ic_dic_fields( $value, $key ) {
    118         if ( in_array( $key, array( 'wpify/ic', 'wpify/dic', 'wpify/dic-dph' ) ) ) {
     129    public function sanitize_ic_dic_fields( $value, $key = null ) {
     130        // Handle both old and new callback signatures
     131        if ( $key === null && is_string( $value ) ) {
     132            // New signature: only value is passed, try to determine field from context
    119133            $value = str_replace( ' ', '', $value );
    120134            $value = strtoupper( $value );
     135        } elseif ( $key !== null && in_array( $key, array( 'wpify/ic', 'wpify/dic', 'wpify/dic-dph' ) ) ) {
     136            // Old signature: both value and key are passed
     137            $value = str_replace( ' ', '', $value );
     138            $value = strtoupper( $value );
    121139        }
    122140
     
    126144    public function validate_ic_dic_fields( \WP_Error $errors, $field_key, $field_value ) {
    127145        if ( $field_key !== 'wpify/dic' && $field_key !== 'wpify/dic-dph' && $field_key !== 'wpify/ic' ) {
    128             return;
    129         }
    130 
    131         wc_load_cart();
    132         $country = WC()->session->customer['country'];
    133 
    134 
    135         if ( 'wpify/ic' === $field_key && $this->module->get_setting( 'validate_ares' )
     146            return $errors;
     147        }
     148
     149        // Get country from multiple sources - block checkout may have newer data
     150        $country = null;
     151
     152        // Check php://input for block checkout data first (most reliable)
     153        $input = file_get_contents( 'php://input' );
     154        if ( $input ) {
     155            $input_data = json_decode( $input, true );
     156            if ( ! empty( $input_data['billing_address']['country'] ) ) {
     157                $country = sanitize_text_field( $input_data['billing_address']['country'] );
     158            }
     159        }
     160
     161        // Try captured country from our hook
     162        if ( empty( $country ) && ! empty( $this->current_checkout_country ) ) {
     163            $country = $this->current_checkout_country;
     164        }
     165
     166        // Try to get country from POST data
     167        if ( empty( $country ) && ! empty( $_POST['billing_country'] ) ) {
     168            $country = sanitize_text_field( $_POST['billing_country'] );
     169        }
     170
     171        // Try from additional fields (for block checkout)
     172        if ( empty( $country ) && ! empty( $_POST['wc-additional-fields-data'] ) ) {
     173            $additional_data = json_decode( stripslashes( $_POST['wc-additional-fields-data'] ), true );
     174            if ( ! empty( $additional_data['billing_country'] ) ) {
     175                $country = sanitize_text_field( $additional_data['billing_country'] );
     176            }
     177        }
     178
     179
     180        // Fallback to customer object
     181        if ( empty( $country ) && ! empty( WC()->customer ) ) {
     182            $country = WC()->customer->get_billing_country();
     183        }
     184
     185        // Last resort - session
     186        if ( empty( $country ) ) {
     187            wc_load_cart();
     188            $country = WC()->session->customer['country'] ?? '';
     189        }
     190
     191        // Validation processing - detailed logging moved to order creation
     192
     193        // For IC field, skip server-side validation for block checkout since we can't reliably get current country
     194        if ( 'wpify/ic' === $field_key ) {
     195            return $errors; // Skip IC validation for block checkout - frontend handles it
     196        }
     197
     198        // ARES validation only for Czech IC numbers
     199        if ( 'wpify/ic' === $field_key
     200             && $this->module->get_setting( 'validate_ares' )
    136201             && $country === 'CZ'
    137202             && in_array( 'order_submit', $this->module->get_setting( 'validate_ares' ) )
     203             && ! empty( $field_value )
    138204        ) {
    139205            $ares = ( new AresFactory() )->create();
     
    151217        }
    152218
    153         if ( $this->module->get_setting( 'validate_vies' ) && $this->module->get_setting( 'vies_fails' ) !== true ) {
    154             if ( $country === 'SK' && $field_key !== 'wpify/dic-dph' ) {
    155                 return $errors;
    156             } else if ( $field_key !== 'wpify/dic' ) {
    157                 return $errors;
    158             }
    159 
    160             if ( ! empty( $field_value ) && ! $this->module->is_valid_dic( $field_value ) ) {
    161                 if ( $country === 'SK' ) {
    162                     $errors->add( 'validation', __( 'The entered IN VAT Number has not been found in VIES, please enter valid IN VAT number.', 'wpify-woo' ) );
    163                 } else {
    164                     $errors->add( 'validation', __( 'The entered VAT Number has not been found in VIES, please enter valid VAT number.', 'wpify-woo' ) );
    165                 }
    166             }
    167         }
     219        // VIES validation moved to final order submission - no longer validate during field input
    168220
    169221        return $errors;
     
    212264
    213265    public function set_customer_vat_extempt( $data ) {
    214         if ( isset( $data['validation'] ) && $data['validation'] === 'passed' ) {
    215             WC()->customer->set_is_vat_exempt( true );
     266        // Default: always reset VAT exempt first
     267        WC()->customer->set_is_vat_exempt( false );
     268       
     269        // Handle different validation states first
     270        if ( isset( $data['validation'] ) && ( $data['validation'] === 'dic_cleared' || $data['validation'] === 'failed' ) ) {
     271            // DIC was cleared or validation failed - ensure VAT exempt is false
     272            if ( $data['validation'] === 'dic_cleared' ) {
     273                // Clear meta data only when explicitly cleared, not when validation fails
     274                WC()->customer->delete_meta_data( 'billing_dic' );
     275                WC()->customer->delete_meta_data( 'billing_dic_dph' );
     276                WC()->customer->save();
     277            }
     278            return;
     279        }
     280
     281        // Get current checkout data to determine if VAT exempt should be applied
     282        $vies_fails            = $this->module->get_setting( 'vies_fails' );
     283        $vat_extempt_countries = $this->module->get_setting( 'zero_tax_for_vat_countries' );
     284
     285        // Check if VAT exempt countries are configured
     286        if ( empty( $vat_extempt_countries ) ) {
     287            return;
     288        }
     289
     290        // Get country and DIC from multiple sources to ensure we have the latest data
     291        $country = $data['country'] ?? WC()->customer->get_billing_country();
     292        $dic = null;
     293
     294        // Try to get DIC from the data passed, otherwise from customer meta
     295        if ( isset( $data['dic'] ) ) {
     296            // DIC explicitly provided in data (including empty string)
     297            $dic = $data['dic'];
     298        } else {
     299            // Get DIC from customer meta based on country only if not provided in data
     300            if ( $country === 'SK' ) {
     301                $dic = WC()->customer->get_meta( 'billing_dic_dph' );
     302            } else {
     303                $dic = WC()->customer->get_meta( 'billing_dic' );
     304            }
     305        }
     306
     307        // If we have a DIC, check if VAT exempt should be applied
     308        if ( ! empty( $dic ) ) {
     309            // If VIES validation is strict (vies_fails is false) and validation hasn't passed, don't set VAT exempt
     310            if ( isset( $data['validation'] ) && $data['validation'] === 'passed' ) {
     311                // Validation explicitly passed - proceed with VAT exempt check
     312                $this->apply_vat_exempt_if_valid( $dic, $country );
     313            } elseif ( empty( $vies_fails ) || $vies_fails !== false ) {
     314                // VIES validation is lenient (vies_fails is true) OR not configured - check VAT exempt anyway
     315                $this->apply_vat_exempt_if_valid( $dic, $country );
     316            }
     317            // If VIES is strict and validation hasn't passed, keep VAT exempt false
     318        }
     319        // If no DIC, VAT exempt stays false (already set at the beginning)
     320
     321    }
     322
     323    private function apply_vat_exempt_if_valid( $dic, $country ) {
     324        // For block checkout, use the billing country from DIC validation as shipping country
     325        // since the customer session might not be updated yet with the current country
     326        $shipping_country = WC()->customer->get_shipping_country();
     327        if ( empty( $shipping_country ) || $shipping_country === 'CZ' ) {
     328            // Fallback to the country from DIC validation
     329            $shipping_country = $country;
     330        }
     331
     332        $is_vat_exempt = $this->module->is_vat_extempt( $dic, $shipping_country );
     333        WC()->customer->set_is_vat_exempt( $is_vat_exempt );
     334    }
     335
     336
     337    public function capture_country_before_validation( $customer, $request ) {
     338        // Capture country from request data before validation
     339        $data = $request->get_json_params();
     340        if ( ! empty( $data['billing_address']['country'] ) ) {
     341            $this->current_checkout_country = $data['billing_address']['country'];
     342        }
     343    }
     344
     345    public function ensure_vat_exempt_from_checkout_data( $customer, $request ) {
     346        // This runs during final checkout processing to ensure VAT exempt is correctly applied
     347        $data = $request->get_json_params();
     348        $billing_country = $data['billing_address']['country'] ?? '';
     349        $additional_fields = $data['additional_fields'] ?? array();
     350
     351        // Get DIC based on country
     352        $dic = null;
     353        if ( $billing_country === 'SK' && ! empty( $additional_fields['wpify/dic-dph'] ) ) {
     354            $dic = $additional_fields['wpify/dic-dph'];
     355        } elseif ( $billing_country !== 'SK' && ! empty( $additional_fields['wpify/dic'] ) ) {
     356            $dic = $additional_fields['wpify/dic'];
     357        }
     358
     359        // Always reset VAT exempt first
     360        WC()->customer->set_is_vat_exempt( false );
     361
     362        // Apply VAT exempt only if we have a valid DIC and VAT exempt countries are configured
     363        $vat_extempt_countries = $this->module->get_setting( 'zero_tax_for_vat_countries' );
     364        if ( ! empty( $dic ) && ! empty( $vat_extempt_countries ) ) {
     365            $is_vat_exempt = $this->module->is_vat_extempt( $dic, $billing_country );
     366            WC()->customer->set_is_vat_exempt( $is_vat_exempt );
     367        }
     368    }
     369   
     370    public function ensure_vat_exempt_before_totals( $customer, $request ) {
     371        // This runs late in the checkout process to ensure VAT exempt is applied before final totals
     372        $data = $request->get_json_params();
     373        $billing_country = $data['billing_address']['country'] ?? '';
     374        $additional_fields = $data['additional_fields'] ?? array();
     375
     376        // Get DIC based on country
     377        $dic = null;
     378        if ( $billing_country === 'SK' && ! empty( $additional_fields['wpify/dic-dph'] ) ) {
     379            $dic = $additional_fields['wpify/dic-dph'];
     380        } elseif ( $billing_country !== 'SK' && ! empty( $additional_fields['wpify/dic'] ) ) {
     381            $dic = $additional_fields['wpify/dic'];
     382        }
     383
     384        // Always reset VAT exempt first
     385        WC()->customer->set_is_vat_exempt( false );
     386
     387        // Apply VAT exempt only if we have a valid DIC and VAT exempt countries are configured
     388        $vat_extempt_countries = $this->module->get_setting( 'zero_tax_for_vat_countries' );
     389        if ( ! empty( $dic ) && ! empty( $vat_extempt_countries ) ) {
     390            $this->apply_vat_exempt_if_valid( $dic, $billing_country );
    216391        }
    217392    }
     
    220395        return $cart_errors;
    221396    }
     397
     398    /**
     399     * Register VIES validation for block checkout on final order submission
     400     */
     401    public function register_block_checkout_vies_validation() {
     402        static $registered = false;
     403        if ( $registered ) {
     404            return;
     405        }
     406        $registered = true;
     407
     408        // Register VIES validation on final checkout submission for blocks
     409        add_action( 'rest_pre_dispatch', array( $this, 'validate_vies_before_block_checkout' ), 10, 3 );
     410    }
     411
     412    /**
     413     * Validate VIES before block checkout is processed (only on final submission)
     414     */
     415    public function validate_vies_before_block_checkout( $result, $server, $request ) {
     416        if ( $request->get_route() !== '/wc/store/v1/checkout' || $request->get_method() !== 'POST' ) {
     417            return $result;
     418        }
     419
     420        // Only validate if VIES validation is enabled and vies_fails is false (strict mode)
     421        if ( ! $this->module->get_setting( 'validate_vies' ) || $this->module->get_setting( 'vies_fails' ) === true ) {
     422            return $result;
     423        }
     424
     425        $body = $request->get_json_params();
     426        $additional_fields = $body['additional_fields'] ?? array();
     427        $billing_country = $body['billing_address']['country'] ?? '';
     428
     429        $validation_errors = array();
     430
     431        // Validate DIC fields based on country
     432        if ( $billing_country === 'SK' ) {
     433            // For Slovakia, validate dic-dph field
     434            $dic_dph = $additional_fields['wpify/dic-dph'] ?? '';
     435            if ( ! empty( $dic_dph ) && ! $this->module->is_valid_dic( $dic_dph ) ) {
     436                $validation_errors[] = array(
     437                    'code'    => 'dic_dph_invalid',
     438                    'message' => __( 'The entered IN VAT Number has not been found in VIES, please enter valid IN VAT number.', 'wpify-woo' ),
     439                    'data'    => array( 'field' => 'wpify/dic-dph' )
     440                );
     441            }
     442        } else {
     443            // For other countries, validate dic field
     444            $dic = $additional_fields['wpify/dic'] ?? '';
     445            if ( ! empty( $dic ) && ! $this->module->is_valid_dic( $dic ) ) {
     446                $validation_errors[] = array(
     447                    'code'    => 'dic_invalid',
     448                    'message' => __( 'The entered VAT Number has not been found in VIES, please enter valid VAT number.', 'wpify-woo' ),
     449                    'data'    => array( 'field' => 'wpify/dic' )
     450                );
     451            }
     452        }
     453
     454        if ( ! empty( $validation_errors ) ) {
     455            $combined_messages = array_column( $validation_errors, 'message' );
     456
     457            return new \WP_Error(
     458                'vies_validation_failed',
     459                implode( '<br>', $combined_messages ),
     460                array(
     461                    'status'            => 400,
     462                    'validation_errors' => $validation_errors
     463                )
     464            );
     465        }
     466
     467
     468        return $result;
     469    }
     470
     471    public function log_order_vat_exempt_decision( $order ) {
     472        // Only log if DIC was provided
     473        $billing_country = $order->get_billing_country();
     474        $dic = $billing_country === 'SK'
     475            ? $order->get_meta('_billing_dic_dph')
     476            : $order->get_meta('_billing_dic');
     477
     478        if ( empty( $dic ) ) {
     479            return; // No DIC provided, skip logging
     480        }
     481
     482        // Detect VAT exempt from order - if tax_total is 0 but order has taxable items, likely VAT exempt
     483        $customer_vat_exempt = ($order->get_total_tax() == 0 && $order->get_total() > 0);
     484        $vat_exempt_countries = $this->module->get_setting( 'zero_tax_for_vat_countries' );
     485        $shop_country = wc_get_base_location()['country'];
     486        $shipping_country = $order->get_shipping_country();
     487
     488        // Determine if VAT should be exempt based on current logic
     489        $should_be_vat_exempt = false;
     490        if ( ! empty( $vat_exempt_countries ) ) {
     491            $should_be_vat_exempt = $this->module->is_vat_extempt( $dic, $shipping_country );
     492        }
     493
     494        $this->module->log->info('Order VAT Exempt Decision', [
     495            'order_id' => $order->get_id(),
     496            'order_number' => $order->get_order_number(),
     497            'billing_country' => $billing_country,
     498            'shipping_country' => $shipping_country,
     499            'shop_country' => $shop_country,
     500            'submitted_dic' => $dic,
     501            'customer_vat_exempt' => $customer_vat_exempt,
     502            'should_be_vat_exempt' => $should_be_vat_exempt,
     503            'vat_exempt_countries' => $vat_exempt_countries,
     504            'order_total' => $order->get_total(),
     505            'tax_total' => $order->get_total_tax(),
     506            'context' => 'Order created - Block checkout'
     507        ]);
     508    }
    222509}
  • wpify-woo/trunk/src/Modules/IcDic/IcDicModule.php

    r3262059 r3319787  
    1818use WpifyWooDeps\Wpify\Asset\AssetFactory;
    1919use WpifyWooDeps\Wpify\PluginUtils\PluginUtils;
     20use WpifyWooDeps\Wpify\Log\RotatingFileLog;
    2021
    2122/**
     
    3233        private ApiManager $api_manager,
    3334        private WooCommerceIntegration $woo_integration,
     35        public RotatingFileLog $log,
    3436    ) {
    3537        parent::__construct();
     
    5456//      ) );
    5557        add_action( 'woocommerce_after_checkout_validation', array( $this, 'checkout_validation' ), 10, 2 );
     58        add_action( 'woocommerce_checkout_order_processed', array( $this, 'log_order_vat_exempt_decision' ), 10, 3 );
    5659        add_action( 'init', array( $this, 'add_rest_api' ) );
    5760
     
    7881            3
    7982        );
    80         add_action( 'init', array( $this, 'set_customer_vat_extempt' ) );
     83        add_action( 'wp', array( $this, 'set_customer_vat_extempt' ) ); // Only on frontend pages, not admin/ajax
    8184        add_action( 'woocommerce_checkout_update_order_review', array( $this, 'set_vat_extempt_on_order_review' ) );
    8285        add_filter( 'post_class', array( $this, 'add_post_class' ), 10, 3 );
    8386        add_filter( 'woocommerce_ajax_get_customer_details', array( $this, 'autofill_vat_fields_in_admin' ), 10, 3 );
     87       
     88       
    8489        new BlockSupport( $this );
    8590    }
     
    144149                    'changePlaceholder' => $this->get_setting( 'change_placeholder' ),
    145150                    'checkingText'      => __( 'Checking in', 'wpify-woo' ),
     151                    'validateAres'      => $this->get_setting( 'validate_ares' ),
    146152                ),
    147153            ),
     
    163169                        'autofillAresText'  => $this->get_setting( 'autofill_ares_text' ) ?: __( 'Autofill from Ares', 'wpify-woo' ),
    164170                        'searchAresText'    => $this->get_setting( 'submit_ares_text' ) ?: __( 'Search in Ares', 'wpify-woo' ),
     171                        'validateVies'      => $this->get_setting( 'validate_vies' ),
     172                        'viesFails'         => $this->get_setting( 'vies_fails' ),
     173                        'validateAres'      => $this->get_setting( 'validate_ares' ),
    165174                    ),
    166175                ),
     
    651660    public function checkout_validation( $fields, $errors ) {
    652661        $country = $_POST['billing_country'];
     662       
    653663
    654664        if ( $this->get_setting( 'validate_ares' )
     
    718728        }
    719729
     730
    720731        $is_required = '</strong> ' . _x( 'is a required field when purchasing for a company.', 'checkout-validation', 'wpify-woo' );
    721732
     
    760771        }
    761772
     773        if ( empty( $dic ) ) {
     774            return false;
     775        }
     776
    762777        $current_country = substr( $dic, 0, 2 );
    763778        $current_vat_no  = substr( $dic, 2 );
     
    797812
    798813    public function set_customer_vat_extempt() {
    799         if ( is_ajax() || is_admin() ) {
     814        // Only run on frontend pages, skip admin and AJAX
     815        if ( is_admin() || wp_doing_ajax() ) {
     816            return;
     817        }
     818
     819        // Skip if WooCommerce customer is not available
     820        if ( empty( WC()->customer ) ) {
    800821            return;
    801822        }
     
    804825        $vat_extempt_countries = $this->get_setting( 'zero_tax_for_vat_countries' );
    805826
     827        // Skip if VAT exempt functionality is not configured
    806828        if ( empty( $vat_extempt_countries ) ) {
    807829            return;
    808830        }
    809831
    810         $dic = null;
    811 
    812         if ( ! empty( WC()->customer ) ) {
    813             $dic = WC()->customer->get_billing_country() === 'SK'
    814                 ? WC()->customer->get_meta( 'billing_dic_dph' )
    815                 : WC()->customer->get_meta( 'billing_dic' );
    816         }
    817 
    818         if ( ! empty( $vies_fails ) && $vies_fails === true && ! $this->is_valid_dic( $dic ) ) {
    819             if ( ! empty( WC()->customer ) ) {
    820                 WC()->customer->set_is_vat_exempt( false );
    821             }
    822 
     832        $billing_country = WC()->customer->get_billing_country();
     833        $dic = $billing_country === 'SK'
     834            ? WC()->customer->get_meta( 'billing_dic_dph' )
     835            : WC()->customer->get_meta( 'billing_dic' );
     836
     837        // Create cache key based on current data
     838        $cache_key = 'vat_exempt_' . md5( $billing_country . '_' . $dic . '_' . WC()->customer->get_shipping_country() );
     839       
     840        // Check if we already calculated this recently (cache for current session)
     841        $cached_result = WC()->session->get( $cache_key );
     842        $cache_time = WC()->session->get( $cache_key . '_time' );
     843       
     844        // Use cache if it's less than 5 minutes old
     845        if ( $cached_result !== null && $cache_time && ( time() - $cache_time ) < 300 ) {
     846            WC()->customer->set_is_vat_exempt( $cached_result );
    823847            return;
    824848        }
    825849
    826         $is_vat_extempt = null;
    827         $session_key    = 'is_vat_extempt:' . $dic;
    828 
    829         if ( ! empty( WC()->session ) ) {
    830             $is_vat_extempt = WC()->session->get( $session_key );
    831         }
    832 
    833         if ( $is_vat_extempt === null ) {
    834             $is_vat_extempt = $this->is_vat_extempt( $dic );
    835         }
    836 
    837         if ( ! empty( WC()->session ) ) {
    838             WC()->session->set( $session_key, $is_vat_extempt );
    839         }
    840 
    841         if ( ! empty( WC()->customer ) ) {
    842             WC()->customer->set_is_vat_exempt( $is_vat_extempt );
    843         }
     850        // Calculate VAT exempt status
     851        $is_vat_extempt = false;
     852
     853        if ( ! empty( $dic ) ) {
     854            // If VIES fails is enabled and DIC is not valid, set to false
     855            if ( ! empty( $vies_fails ) && $vies_fails === true && ! $this->is_valid_dic( $dic ) ) {
     856                $is_vat_extempt = false;
     857            } else {
     858                $shipping_country = WC()->customer->get_shipping_country() ?: $billing_country;
     859                $is_vat_extempt = $this->is_vat_extempt( $dic, $shipping_country );
     860            }
     861        }
     862
     863        // Cache the result
     864        WC()->session->set( $cache_key, $is_vat_extempt );
     865        WC()->session->set( $cache_key . '_time', time() );
     866
     867        // Set customer VAT exempt status
     868        WC()->customer->set_is_vat_exempt( $is_vat_extempt );
     869    }
     870
     871    public function log_order_vat_exempt_decision( $order_id, $posted_data, $order ) {
     872        // Only log if DIC was provided
     873        $billing_country = $order->get_billing_country();
     874        $dic = $billing_country === 'SK'
     875            ? $order->get_meta('_billing_dic_dph')
     876            : $order->get_meta('_billing_dic');
     877           
     878        if ( empty( $dic ) ) {
     879            return; // No DIC provided, skip logging
     880        }
     881
     882        // Detect VAT exempt from order - if tax_total is 0 but order has taxable items, likely VAT exempt
     883        $customer_vat_exempt = ($order->get_total_tax() == 0 && $order->get_total() > 0);
     884        $vat_exempt_countries = $this->get_setting( 'zero_tax_for_vat_countries' );
     885        $shop_country = wc_get_base_location()['country'];
     886        $shipping_country = $order->get_shipping_country();
     887       
     888        // Determine if VAT should be exempt based on current logic 
     889        $should_be_vat_exempt = false;
     890        if ( ! empty( $vat_exempt_countries ) ) {
     891            $should_be_vat_exempt = $this->is_vat_extempt( $dic, $shipping_country );
     892        }
     893
     894        $this->log->info('Order VAT Exempt Decision', [
     895            'order_id' => $order->get_id(),
     896            'order_number' => $order->get_order_number(),
     897            'billing_country' => $billing_country,
     898            'shipping_country' => $shipping_country,
     899            'shop_country' => $shop_country,
     900            'submitted_dic' => $dic,
     901            'customer_vat_exempt' => $customer_vat_exempt,
     902            'should_be_vat_exempt' => $should_be_vat_exempt,
     903            'vat_exempt_countries' => $vat_exempt_countries,
     904            'order_total' => $order->get_total(),
     905            'tax_total' => $order->get_total_tax(),
     906            'context' => 'Order created - Classic checkout'
     907        ]);
    844908    }
    845909
     
    855919
    856920        $current_country = substr( $dic, 0, 2 );
     921       
     922        // Check applicability FIRST - if not applicable, don't waste time on VIES validation
     923        $is_applicable = $this->is_vat_extempt_applicable( $current_country, $shipping_country );
     924        if ( ! $is_applicable ) {
     925            return false; // Skip expensive VIES validation if result would be false anyway
     926        }
     927
    857928        $current_vat_no  = substr( $dic, 2 );
    858929        $vies            = new Vies();
     930        $is_valid        = false;
    859931
    860932        try {
     
    868940        }
    869941
    870         return $is_valid && $this->is_vat_extempt_applicable( $current_country, $shipping_country );
     942        return $is_valid;
    871943    }
    872944
     
    897969        wp_parse_str( $strdata, $data );
    898970
    899         $country = $data['billing_country'];
     971        $country = $data['billing_country'] ?? '';
    900972        $dic_dph = $country === 'SK'
    901             ? $data['billing_dic_dph']
    902             : $data['billing_dic'];
     973            ? ($data['billing_dic_dph'] ?? '')
     974            : ($data['billing_dic'] ?? '');
    903975
    904976        if ( ! empty( $vies_fails ) && $vies_fails === true && ! empty( $dic_dph ) && ! $this->is_valid_dic( $dic_dph ) ) {
    905977            WC()->customer->set_is_vat_exempt( false );
    906 
    907978            return;
    908979        }
     
    915986             )
    916987        ) {
    917             WC()->customer->set_is_vat_exempt( $this->is_vat_extempt( $dic_dph, $data['shipping_country'] ) );
     988            $vat_exempt_result = $this->is_vat_extempt( $dic_dph, $data['shipping_country'] ?? '' );
     989            WC()->customer->set_is_vat_exempt( $vat_exempt_result );
    918990        } else {
    919991            WC()->customer->set_is_vat_exempt( false );
     
    10051077        return $classes;
    10061078    }
     1079
     1080
     1081
    10071082}
  • wpify-woo/trunk/src/Modules/IcDic/assets/icdic-blocks.js

    r3257809 r3319787  
    3939
    4040
    41 
    4241const App = () => {
    4342    const {extensionCartUpdate} = window.wc.blocksCheckout;
     
    4544    const [aresError, setAresError] = useState()
    4645    const [isAresLoading, setIsAresLoading] = useState()
     46    const [aresStatus, setAresStatus] = useState() // 'success', 'error', null
    4747    const [viesError, setViesError] = useState()
    4848    const [isViesLoading, setIsViesLoading] = useState()
     49    const [viesStatus, setViesStatus] = useState() // 'success', 'error', null
    4950    const cart = useCart();
    5051    const customer = useCustomerData();
    5152    const additionalFields = useAdditionalFields();
    5253    const {setAdditionalFields} = useDispatch(CHECKOUT_STORE_KEY);
    53     const { showValidationError, setValidationErrors, showAllValidationErrors } = useDispatch( VALIDATION_STORE_KEY );
     54    const {showValidationError, setValidationErrors, showAllValidationErrors} = useDispatch(VALIDATION_STORE_KEY);
    5455    const {setBillingAddress, setShippingAddress} = useDispatch(CART_STORE_KEY);
    5556
     
    103104        }
    104105
     106        // Show/hide ARES button based on settings and country
    105107        if (aresWrap && additionalFields?.['wpify/ic_dic_toggle'] && customer.billingAddress.country === 'CZ') {
    106             aresWrap.style.display = 'block';
     108            // Check if ARES validation on IC entered is enabled
     109            const aresOnIcEntered = window.wpifyWooIcDic.validateAres &&
     110                Array.isArray(window.wpifyWooIcDic.validateAres) &&
     111                window.wpifyWooIcDic.validateAres.includes('ic_entered');
     112
     113            // Show button only if ARES validation on IC entered is NOT enabled
     114            aresWrap.style.display = !aresOnIcEntered ? 'block' : 'none';
    107115        } else if (aresWrap) {
    108116            aresWrap.style.display = 'none';
     
    110118
    111119    }, [additionalFields, companyField, icField, dicField, dicDphField, companyFieldWrap, icFieldWrap, dicFieldWrap, dicDphFieldWrap, customer]);
     120
     121    // Reset status indicators when fields become empty
     122    useEffect(() => {
     123        // Reset ARES status if IC field is empty
     124        if (!additionalFields['wpify/ic'] || additionalFields['wpify/ic'].trim() === '') {
     125            setAresStatus(null);
     126            setAresError(null);
     127        }
     128
     129        // Reset VIES status if DIC fields are empty
     130        const currentDic = customer.billingAddress.country === 'SK'
     131            ? additionalFields['wpify/dic-dph']
     132            : additionalFields['wpify/dic'];
     133
     134        if (!currentDic || currentDic.trim() === '') {
     135            setViesStatus(null);
     136            setViesError(null);
     137        }
     138    }, [additionalFields, customer.billingAddress.country]);
     139
     140    // Reset VAT exempt on page load - always reset first, then check DIC
     141    useEffect(() => {
     142        // Always reset VAT exempt on page load first
     143        extensionCartUpdate({
     144            namespace: 'wpify_ic_dic',
     145            data: {validation: 'dic_cleared'}
     146        });
     147       
     148        // Then check if there are any DIC values on page load
     149        const currentDic = customer.billingAddress.country === 'SK'
     150            ? additionalFields['wpify/dic-dph']
     151            : additionalFields['wpify/dic'];
     152           
     153        if (currentDic && currentDic.trim() !== '') {
     154            // DIC exists on page load - validate it after a short delay
     155            setTimeout(() => {
     156                if (window.wpifyWooIcDic.validateVies) {
     157                    validateDic(normalizeDic(currentDic));
     158                } else {
     159                    // No VIES validation - just set VAT exempt based on settings
     160                    extensionCartUpdate({
     161                        namespace: 'wpify_ic_dic',
     162                        data: {
     163                            validation: 'passed',
     164                            country: customer.billingAddress.country,
     165                            dic: currentDic
     166                        }
     167                    });
     168                }
     169            }, 500);
     170        }
     171    }, []); // Run only once on component mount
     172
     173    // Clear validation errors and recalculate VAT exempt when country changes
     174    useEffect(() => {
     175        console.log('Country changed to:', customer.billingAddress.country);
     176
     177        // Clear ARES errors when switching away from Czech Republic
     178        if (customer.billingAddress.country !== 'CZ') {
     179            setAresError(null);
     180            setAresStatus(null);
     181            console.log('Cleared ARES error for non-Czech country');
     182        }
     183
     184        // Clear VIES errors when country changes
     185        setViesError(null);
     186        setViesStatus(null);
     187
     188        // Clear any validation errors from the store
     189        setValidationErrors({});
     190
     191        // Clear IČ DPH field when switching away from Slovakia
     192        let updatedFields = {...additionalFields};
     193        if (customer.billingAddress.country !== 'SK' && updatedFields['wpify/dic-dph']) {
     194            updatedFields['wpify/dic-dph'] = '';
     195            setAdditionalFields(updatedFields);
     196        }
     197
     198        // Get current DIC values AFTER clearing fields for country change
     199        const currentDic = customer.billingAddress.country === 'SK'
     200            ? (updatedFields['wpify/dic-dph'] || '')
     201            : (updatedFields['wpify/dic'] || '');
     202       
     203        // Reset VAT exempt on country change with current DIC state
     204        extensionCartUpdate({
     205            namespace: 'wpify_ic_dic',
     206            data: {
     207                validation: 'country_change',
     208                country: customer.billingAddress.country,
     209                dic: currentDic
     210            }
     211        });
     212
     213        // Revalidate existing field values for the new country if any exist
     214        if (currentDic && currentDic.length >= 4 && window.wpifyWooIcDic.validateVies) {
     215            // Revalidate the existing DIC for the new country context
     216            // Add delay to allow country change to process
     217            setTimeout(() => {
     218                validateDic(normalizeDic(currentDic));
     219            }, 300);
     220        }
     221
     222    }, [customer.billingAddress.country]);
    112223
    113224
     
    142253
    143254    useEffect(() => {
    144         if (!icField || customer.billingAddress.country !== 'CZ' ) {
     255        if (!icField) {
    145256            return;
    146257        }
     
    155266                additionalFields['wpify/ic'] = normalizedValue;
    156267                setAdditionalFields(additionalFields);
    157                 autofillAres();
     268
     269                console.log('IC field change:', {
     270                    country: customer.billingAddress.country,
     271                    value: normalizedValue,
     272                    willCallAres: customer.billingAddress.country === 'CZ'
     273                });
     274
     275                // Only call ARES autofill for Czech companies and if ic_entered validation is enabled
     276                if (customer.billingAddress.country === 'CZ') {
     277                    const aresOnIcEntered = window.wpifyWooIcDic.validateAres &&
     278                        Array.isArray(window.wpifyWooIcDic.validateAres) &&
     279                        window.wpifyWooIcDic.validateAres.includes('ic_entered');
     280
     281                    if (aresOnIcEntered) {
     282                        autofillAres();
     283                    }
     284                } else {
     285                    // Clear any previous ARES errors when switching away from CZ
     286                    setAresError(null);
     287                }
    158288            }, 2000);
    159289        };
     
    165295            icField.removeEventListener('input', handleIcInputChange);
    166296        };
    167     }, [icField]);
     297    }, [icField, customer.billingAddress.country]);
    168298
    169299    useEffect(() => {
     
    179309
    180310            typingTimeout = setTimeout(() => {
    181                 validateDic(normalizeDic(e.target.value));
    182             }, 2000);
     311                const normalizedValue = normalizeDic(e.target.value);
     312                // Only validate if there's actually a meaningful value (at least country + some digits)
     313                if (normalizedValue && normalizedValue.length >= 4) {
     314                    validateDic(normalizedValue);
     315                } else {
     316                    // DIC field is empty or too short - reset VAT exempt
     317                    extensionCartUpdate({
     318                        namespace: 'wpify_ic_dic',
     319                        data: {validation: 'dic_cleared'}
     320                    });
     321                }
     322            }, 1500); // Reduced from 2000ms to 1500ms
    183323        };
    184324
     
    208348    function validateDic(dic) {
    209349        setViesError(null);
     350        setViesStatus(null);
     351
     352        // Check if VIES validation is enabled in settings
     353        if (!window.wpifyWooIcDic.validateVies) {
     354            // VIES validation is disabled, don't validate
     355            return;
     356        }
     357
     358        // Skip validation if DIC is empty or too short
     359        if (!dic || dic.length < 4) {
     360            return;
     361        }
     362
    210363        setIsViesLoading(true);
    211364        if (window.wpifyWooIcDic.restUrl) {
    212365            fetchJson(window.wpifyWooIcDic.restUrl + '/icdic-vies?in=' + dic)
    213                 .then(({validation = {}}) => {
    214                     if (customer.billingAddress.country === 'SK') {
    215                         additionalFields['wpify/dic-dph'] = dic;
    216                     } else {
    217                         additionalFields['wpify/dic'] = dic;
     366                .then((response) => {
     367                    const validation = response.validation || {};
     368                    const warning = response.warning || null;
     369
     370                    // Clear previous errors if validation passed, show warning if present
     371                    if (validation === 'passed' && !warning) {
     372                        setViesError(null); // Clear any previous errors
     373                        setViesStatus('success');
     374                    } else if (warning) {
     375                        setViesError(warning);
     376                        setViesStatus('error');
    218377                    }
    219                     setAdditionalFields(additionalFields);
     378
     379                    // Don't overwrite field values - the user already entered the correct value
     380                    // The validation is just confirming it's valid, not changing it
     381                    // Let WooCommerce handle the field values naturally
     382
     383                    // Get country from the validated DIC value instead of customer object to ensure accuracy
     384                    const dicCountry = dic.match(/^[A-Z]{2}/) ? dic.substring(0, 2) : customer.billingAddress.country;
    220385
    221386                    extensionCartUpdate({
     
    223388                        data: {
    224389                            validation: validation,
    225                             country: customer.billingAddress.country
     390                            country: dicCountry,
     391                            dic: dic
    226392                        }
    227393                    })
     
    230396                        detail: {
    231397                            validation: validation,
     398                            warning: warning
    232399                        }
    233400                    });
     
    235402                })
    236403                .catch(error => {
     404                    // Only show error as warning, don't block checkout
     405                    // Final validation will happen server-side
    237406                    setViesError(error);
     407                    setViesStatus('error');
     408                   
     409                    // Reset VAT exempt when VIES validation fails
     410                    extensionCartUpdate({
     411                        namespace: 'wpify_ic_dic',
     412                        data: {
     413                            validation: 'failed',
     414                            country: customer.billingAddress.country,
     415                            dic: dic
     416                        }
     417                    });
    238418                })
    239419                .finally(() => {
     
    244424
    245425    const autofillAres = () => {
     426        // ARES is only for Czech companies
     427        if (customer.billingAddress.country !== 'CZ') {
     428            return;
     429        }
     430
    246431        setAresError(null);
     432        setAresStatus(null);
    247433        setIsAresLoading(true);
    248434        const ic = normalizeIc(additionalFields['wpify/ic']);
     
    255441                setAdditionalFields(additionalFields);
    256442
    257                 if (details.billing_dic) {
    258                     validateDic(normalizeDic(details.billing_dic))
     443                // Only validate DIC if we have one and VIES validation is enabled
     444                if (details.billing_dic && window.wpifyWooIcDic.validateVies) {
     445                    // Add small delay to ensure fields are updated first
     446                    setTimeout(() => {
     447                        validateDic(normalizeDic(details.billing_dic));
     448                    }, 100);
    259449                }
    260450
     
    274464                });
    275465                window.dispatchEvent(evt);
     466                setAresStatus('success');
    276467            })
    277468            .catch(error => {
    278469                setAresError(error);
     470                setAresStatus('error');
    279471            })
    280472            .finally(() => {
     
    283475
    284476    }
     477    // Create status indicator component
     478    const StatusIndicator = ({isLoading, status, error, fieldValue}) => {
     479        // Only show status indicators when field has content
     480        if (!fieldValue || fieldValue.trim() === '') {
     481            return null;
     482        }
     483
     484        if (isLoading) {
     485            return (
     486                <div style={{
     487                    position: 'absolute',
     488                    top: '50%', right: '14px',
     489                    transform: 'translateY(-50%)',
     490                    color: '#0073aa'
     491                }}>
     492                    <span style={{
     493                        display: 'inline-block',
     494                        width: '16px',
     495                        height: '16px',
     496                        border: '2px solid #f3f3f3',
     497                        borderTop: '2px solid #0073aa',
     498                        borderRadius: '50%',
     499                        animation: 'spin 1s linear infinite'
     500                    }}></span>
     501                    <style>{`
     502                        @keyframes spin {
     503                            0% { transform: rotate(0deg); }
     504                            100% { transform: rotate(360deg); }
     505                        }
     506                    `}</style>
     507                </div>
     508            );
     509        }
     510
     511        if (status === 'success') {
     512            return (
     513                <div style={{
     514                    position: 'absolute',
     515                    top: '50%', right: '14px',
     516                    transform: 'translatey(-50%)',
     517                    color: '#46b450'
     518                }}>
     519                    <span>✓</span>
     520                </div>
     521            );
     522        }
     523
     524        if (status === 'error' || error) {
     525            return (
     526                <div style={{
     527                    position: 'absolute',
     528                    top: '50%', right: '14px',
     529                    transform: 'translatey(-50%)',
     530                    color: '#dc3232'}}>
     531                    <span>!</span>
     532                </div>
     533            );
     534        }
     535
     536        return null;
     537    };
     538
    285539    if (!aresAdded) {
    286540        return null;
    287541    }
    288542
    289 
    290543    return (
    291544        <div>
     545            {icFieldWrap && createPortal(
     546                <>
     547                    <StatusIndicator
     548                        isLoading={isAresLoading}
     549                        status={aresStatus}
     550                        error={aresError}
     551                        fieldValue={additionalFields['wpify/ic']}
     552                    />
     553                    {aresError && additionalFields['wpify/ic'] && <p style={{color: '#dc3232', fontSize: '14px', marginTop: '4px'}}>{aresError}</p>}
     554                </>,
     555                icFieldWrap
     556            )}
     557
     558            {/* ARES button positioned after IC field */}
     559            {icFieldWrap && additionalFields?.['wpify/ic_dic_toggle'] && customer.billingAddress.country === 'CZ' && (() => {
     560                const aresOnIcEntered = window.wpifyWooIcDic.validateAres &&
     561                    Array.isArray(window.wpifyWooIcDic.validateAres) &&
     562                    window.wpifyWooIcDic.validateAres.includes('ic_entered');
     563
     564                if (!aresOnIcEntered) {
     565                    // Create a wrapper div that will be positioned right after the IC field
     566                    let aresButtonWrapper = document.querySelector('.wpify-ares-button-wrapper');
     567                    if (!aresButtonWrapper) {
     568                        aresButtonWrapper = document.createElement('div');
     569                        aresButtonWrapper.className = 'wpify-ares-button-wrapper';
     570                        icFieldWrap.insertAdjacentElement('afterend', aresButtonWrapper);
     571                    }
     572                   
     573                    return createPortal(
     574                        <div style={{marginTop: '8px'}}>
     575                            <input type="button" className="button wp-element-button" onClick={() => autofillAres()}
     576                                   value={window.wpifyWooIcDic.searchAresText}
     577                            />
     578                        </div>,
     579                        aresButtonWrapper
     580                    );
     581                }
     582                return null;
     583            })()}
     584
    292585            {createPortal(
    293586                <>
    294                     <div>
    295                         <input type="button" className="button wp-element-button" onClick={() => autofillAres()}
    296                                value={window.wpifyWooIcDic.searchAresText}
    297                         />
    298                         {isAresLoading && <div>Loading</div>}
    299                         {aresError && <div>{aresError}</div>}
    300                     </div>
    301                 </>,
    302                 aresWrap
    303             )}
    304             {createPortal(
    305                 <>
    306                     <div>
    307                         {isViesLoading && <div>Loading</div>}
    308                         {viesError && <div>{viesError}</div>}
    309                     </div>
     587                    <StatusIndicator
     588                        isLoading={isViesLoading}
     589                        status={viesStatus}
     590                        error={viesError}
     591                        fieldValue={customer.billingAddress.country === 'SK' ? additionalFields['wpify/dic-dph'] : additionalFields['wpify/dic']}
     592                    />
     593                    {viesError && (customer.billingAddress.country === 'SK' ? additionalFields['wpify/dic-dph'] : additionalFields['wpify/dic']) && <p style={{color: '#dc3232', fontSize: '14px', marginTop: '4px'}}>{viesError}</p>}
    310594                </>,
    311595                customer.billingAddress.country === 'SK' ? dicDphFieldWrap : dicFieldWrap
  • wpify-woo/trunk/src/Modules/IcDic/assets/icdic.js

    r3257809 r3319787  
    438438        if (dom.dicField().classList.contains('wpify-woo-vies--validate') && state.get('country') !== 'SK' && e.target.value.length > 0) {
    439439            validateDic();
     440        } else {
     441            // Trigger update_checkout when field is cleared or validation doesn't run
     442            $(document.body).trigger('update_checkout');
    440443        }
    441444    });
     
    446449        if (dom.icDph().classList.contains('wpify-woo-vies--validate') && state.get('country') === 'SK' && e.target.value.length > 0) {
    447450            validateDic();
     451        } else {
     452            // Trigger update_checkout when field is cleared or validation doesn't run
     453            $(document.body).trigger('update_checkout');
    448454        }
    449455    });
  • wpify-woo/trunk/src/Plugin.php

    r3319782 r3319787  
    2323
    2424    /** Plugin version */
    25     public const VERSION = '5.0.13';
     25    public const VERSION = '5.0.14';
    2626
    2727    /** Plugin slug name */
  • wpify-woo/trunk/vendor/composer/installed.php

    r3319782 r3319787  
    22    'root' => array(
    33        'name' => 'wpify/woo',
    4         'pretty_version' => '5.0.13',
    5         'version' => '5.0.13.0',
    6         'reference' => '7d1c36c50d5ed21a816195dbd9aa58a5574a024b',
     4        'pretty_version' => '5.0.14',
     5        'version' => '5.0.14.0',
     6        'reference' => 'e4b83614529dec5c7bad5fffc4483b7c721554db',
    77        'type' => 'project',
    88        'install_path' => __DIR__ . '/../../',
     
    1212    'versions' => array(
    1313        'wpify/woo' => array(
    14             'pretty_version' => '5.0.13',
    15             'version' => '5.0.13.0',
    16             'reference' => '7d1c36c50d5ed21a816195dbd9aa58a5574a024b',
     14            'pretty_version' => '5.0.14',
     15            'version' => '5.0.14.0',
     16            'reference' => 'e4b83614529dec5c7bad5fffc4483b7c721554db',
    1717            'type' => 'project',
    1818            'install_path' => __DIR__ . '/../../',
  • wpify-woo/trunk/vendor/wpify-woo/composer/installed.php

    r3319782 r3319787  
    33namespace WpifyWooDeps;
    44
    5 return array('root' => array('name' => '__root__', 'pretty_version' => '5.0.13', 'version' => '5.0.13.0', 'reference' => '7d1c36c50d5ed21a816195dbd9aa58a5574a024b', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => \true), 'versions' => array('__root__' => array('pretty_version' => '5.0.13', 'version' => '5.0.13.0', 'reference' => '7d1c36c50d5ed21a816195dbd9aa58a5574a024b', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => \false), 'bacon/bacon-qr-code' => array('pretty_version' => '2.0.8', 'version' => '2.0.8.0', 'reference' => '8674e51bb65af933a5ffaf1c308a660387c35c22', 'type' => 'library', 'install_path' => __DIR__ . '/../bacon/bacon-qr-code', 'aliases' => array(), 'dev_requirement' => \false), 'dasprid/enum' => array('pretty_version' => '1.0.6', 'version' => '1.0.6.0', 'reference' => '8dfd07c6d2cf31c8da90c53b83c026c7696dda90', 'type' => 'library', 'install_path' => __DIR__ . '/../dasprid/enum', 'aliases' => array(), 'dev_requirement' => \false), 'dragonbe/vies' => array('pretty_version' => '2.3.2', 'version' => '2.3.2.0', 'reference' => 'd9193cbaba7e2faefbdc228fb1bf5670f20acf30', 'type' => 'tool', 'install_path' => __DIR__ . '/../dragonbe/vies', 'aliases' => array(), 'dev_requirement' => \false), 'endroid/qr-code' => array('pretty_version' => '4.5.0', 'version' => '4.5.0.0', 'reference' => '36681470bd10352b53bcb9731bdf2270e0d79b22', 'type' => 'library', 'install_path' => __DIR__ . '/../endroid/qr-code', 'aliases' => array(), 'dev_requirement' => \false), 'guzzlehttp/guzzle' => array('pretty_version' => '7.9.3', 'version' => '7.9.3.0', 'reference' => '7b2f29fe81dc4da0ca0ea7d42107a0845946ea77', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/guzzle', 'aliases' => array(), 'dev_requirement' => \false), 'guzzlehttp/promises' => array('pretty_version' => '2.2.0', 'version' => '2.2.0.0', 'reference' => '7c69f28996b0a6920945dd20b3857e499d9ca96c', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/promises', 'aliases' => array(), 'dev_requirement' => \false), 'guzzlehttp/psr7' => array('pretty_version' => '2.7.1', 'version' => '2.7.1.0', 'reference' => 'c2270caaabe631b3b44c85f99e5a04bbb8060d16', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/psr7', 'aliases' => array(), 'dev_requirement' => \false), 'h4kuna/ares' => array('pretty_version' => 'v3.0.13', 'version' => '3.0.13.0', 'reference' => 'd695e8b57b0410738d8eb9d7157bb8c7ec340d72', 'type' => 'library', 'install_path' => __DIR__ . '/../h4kuna/ares', 'aliases' => array(), 'dev_requirement' => \false), 'heureka/inflection' => array('pretty_version' => 'v3.0.4', 'version' => '3.0.4.0', 'reference' => '684ca578eee3ede920d5d3ca8d568fb70e7d9076', 'type' => 'library', 'install_path' => __DIR__ . '/../heureka/inflection', 'aliases' => array(), 'dev_requirement' => \false), 'heureka/overeno-zakazniky' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => 'aa52add431bac32c67b1c00b1969a98709cd611b', 'type' => 'library', 'install_path' => __DIR__ . '/../heureka/overeno-zakazniky', 'aliases' => array(), 'dev_requirement' => \false), 'laravel/serializable-closure' => array('pretty_version' => 'v1.3.7', 'version' => '1.3.7.0', 'reference' => '4f48ade902b94323ca3be7646db16209ec76be3d', 'type' => 'library', 'install_path' => __DIR__ . '/../laravel/serializable-closure', 'aliases' => array(), 'dev_requirement' => \false), 'monolog/monolog' => array('pretty_version' => '2.10.0', 'version' => '2.10.0.0', 'reference' => '5cf826f2991858b54d5c3809bee745560a1042a7', 'type' => 'library', 'install_path' => __DIR__ . '/../monolog/monolog', 'aliases' => array(), 'dev_requirement' => \false), 'nette/utils' => array('pretty_version' => 'v4.0.7', 'version' => '4.0.7.0', 'reference' => 'e67c4061eb40b9c113b218214e42cb5a0dda28f2', 'type' => 'library', 'install_path' => __DIR__ . '/../nette/utils', 'aliases' => array(), 'dev_requirement' => \false), 'php-di/invoker' => array('pretty_version' => '2.3.6', 'version' => '2.3.6.0', 'reference' => '59f15608528d8a8838d69b422a919fd6b16aa576', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/invoker', 'aliases' => array(), 'dev_requirement' => \false), 'php-di/php-di' => array('pretty_version' => '6.4.0', 'version' => '6.4.0.0', 'reference' => 'ae0f1b3b03d8b29dff81747063cbfd6276246cc4', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/php-di', 'aliases' => array(), 'dev_requirement' => \false), 'php-di/phpdoc-reader' => array('pretty_version' => '2.2.1', 'version' => '2.2.1.0', 'reference' => '66daff34cbd2627740ffec9469ffbac9f8c8185c', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/phpdoc-reader', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container' => array('pretty_version' => '1.1.2', 'version' => '1.1.2.0', 'reference' => '513e0666f7216c7459170d56df27dfcefe1689ea', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '^1.0')), 'psr/http-client' => array('pretty_version' => '1.0.3', 'version' => '1.0.3.0', 'reference' => 'bb5906edc1c324c9a05aa0873d40117941e5fa90', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-client', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-client-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/http-factory' => array('pretty_version' => '1.1.0', 'version' => '1.1.0.0', 'reference' => '2b4765fddfe3b508ac62f829e852b1501d3f6e8a', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-factory', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-factory-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/http-message' => array('pretty_version' => '2.0', 'version' => '2.0.0.0', 'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-message', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-message-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/log' => array('pretty_version' => '1.1.4', 'version' => '1.1.4.0', 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/log', 'aliases' => array(), 'dev_requirement' => \false), 'psr/log-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0.0 || 2.0.0 || 3.0.0')), 'ralouphie/getallheaders' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => '120b605dfeb996808c31b6477290a714d356e822', 'type' => 'library', 'install_path' => __DIR__ . '/../ralouphie/getallheaders', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/czqrpayment' => array('pretty_version' => 'v5.3.1', 'version' => '5.3.1.0', 'reference' => 'f8e0ecbbdb6d30bafb50a833cc7cfe4f575b82a4', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/czqrpayment', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/iban' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '7fe69bf9274792c37d5a8d9d38ef5cb000f8377a', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/iban', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/qr-payment-interface' => array('pretty_version' => 'v1.1.0', 'version' => '1.1.0.0', 'reference' => '752f7a6bf1190c7d65ead90b5989f61927436c89', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/qr-payment-interface', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/qr-payment-qr-code-provider' => array('pretty_version' => 'v1.2.0', 'version' => '1.2.0.0', 'reference' => 'd233c4bedeecf2ff7cd7e7d4ec7f4ad4a5eb4b64', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/qr-payment-qr-code-provider', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/skqrpayment' => array('pretty_version' => 'v4.2.2', 'version' => '4.2.2.0', 'reference' => '777fa98caaff3f10fb43f3cf67a8464c547e0550', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/skqrpayment', 'aliases' => array(), 'dev_requirement' => \false), 'spatie/array-to-xml' => array('pretty_version' => '2.17.1', 'version' => '2.17.1.0', 'reference' => '5cbec9c6ab17e320c58a259f0cebe88bde4a7c46', 'type' => 'library', 'install_path' => __DIR__ . '/../spatie/array-to-xml', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/deprecation-contracts' => array('pretty_version' => 'v3.6.0', 'version' => '3.6.0.0', 'reference' => '63afe740e99a13ba87ec199bb07bbdee937a5b62', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'woocommerce/action-scheduler' => array('pretty_version' => '3.9.2', 'version' => '3.9.2.0', 'reference' => 'efbb7953f72a433086335b249292f280dd43ddfe', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../woocommerce/action-scheduler', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/asset' => array('pretty_version' => '1.3.0', 'version' => '1.3.0.0', 'reference' => 'faf957af650b441b49f03cb7ffa42abfe157b43b', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/asset', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/custom-fields' => array('pretty_version' => '4.0.65', 'version' => '4.0.65.0', 'reference' => '2d3de7bbce4c14a524a7babe034a797461a7737c', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/custom-fields', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/license' => array('pretty_version' => '2.0.7', 'version' => '2.0.7.0', 'reference' => '7f8e7fe16a1bb77cdfcd29c694c5a489fc8db1b1', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/license', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/log' => array('pretty_version' => '1.1.1', 'version' => '1.1.1.0', 'reference' => '5b856a623a574d3ba4f2138d5f4d94c0625329ff', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/log', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/model' => array('pretty_version' => '4.1.24', 'version' => '4.1.24.0', 'reference' => 'ebcac0038014dd0a8d7af5b31e3ee1efa542e9ec', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/model', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/plugin-utils' => array('pretty_version' => '1.0.1', 'version' => '1.0.1.0', 'reference' => '0ace7f3a23bdfe3e2b2b05c72af79fa034c7e77a', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/plugin-utils', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/woo-core' => array('pretty_version' => '5.1.20', 'version' => '5.1.20.0', 'reference' => '2d2032c6da6b538079d8e152618b1e5493319409', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/woo-core', 'aliases' => array(), 'dev_requirement' => \false)));
     5return array('root' => array('name' => '__root__', 'pretty_version' => '5.0.14', 'version' => '5.0.14.0', 'reference' => 'e4b83614529dec5c7bad5fffc4483b7c721554db', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev' => \true), 'versions' => array('__root__' => array('pretty_version' => '5.0.14', 'version' => '5.0.14.0', 'reference' => 'e4b83614529dec5c7bad5fffc4483b7c721554db', 'type' => 'library', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), 'dev_requirement' => \false), 'bacon/bacon-qr-code' => array('pretty_version' => '2.0.8', 'version' => '2.0.8.0', 'reference' => '8674e51bb65af933a5ffaf1c308a660387c35c22', 'type' => 'library', 'install_path' => __DIR__ . '/../bacon/bacon-qr-code', 'aliases' => array(), 'dev_requirement' => \false), 'dasprid/enum' => array('pretty_version' => '1.0.6', 'version' => '1.0.6.0', 'reference' => '8dfd07c6d2cf31c8da90c53b83c026c7696dda90', 'type' => 'library', 'install_path' => __DIR__ . '/../dasprid/enum', 'aliases' => array(), 'dev_requirement' => \false), 'dragonbe/vies' => array('pretty_version' => '2.3.2', 'version' => '2.3.2.0', 'reference' => 'd9193cbaba7e2faefbdc228fb1bf5670f20acf30', 'type' => 'tool', 'install_path' => __DIR__ . '/../dragonbe/vies', 'aliases' => array(), 'dev_requirement' => \false), 'endroid/qr-code' => array('pretty_version' => '4.5.0', 'version' => '4.5.0.0', 'reference' => '36681470bd10352b53bcb9731bdf2270e0d79b22', 'type' => 'library', 'install_path' => __DIR__ . '/../endroid/qr-code', 'aliases' => array(), 'dev_requirement' => \false), 'guzzlehttp/guzzle' => array('pretty_version' => '7.9.3', 'version' => '7.9.3.0', 'reference' => '7b2f29fe81dc4da0ca0ea7d42107a0845946ea77', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/guzzle', 'aliases' => array(), 'dev_requirement' => \false), 'guzzlehttp/promises' => array('pretty_version' => '2.2.0', 'version' => '2.2.0.0', 'reference' => '7c69f28996b0a6920945dd20b3857e499d9ca96c', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/promises', 'aliases' => array(), 'dev_requirement' => \false), 'guzzlehttp/psr7' => array('pretty_version' => '2.7.1', 'version' => '2.7.1.0', 'reference' => 'c2270caaabe631b3b44c85f99e5a04bbb8060d16', 'type' => 'library', 'install_path' => __DIR__ . '/../guzzlehttp/psr7', 'aliases' => array(), 'dev_requirement' => \false), 'h4kuna/ares' => array('pretty_version' => 'v3.0.13', 'version' => '3.0.13.0', 'reference' => 'd695e8b57b0410738d8eb9d7157bb8c7ec340d72', 'type' => 'library', 'install_path' => __DIR__ . '/../h4kuna/ares', 'aliases' => array(), 'dev_requirement' => \false), 'heureka/inflection' => array('pretty_version' => 'v3.0.4', 'version' => '3.0.4.0', 'reference' => '684ca578eee3ede920d5d3ca8d568fb70e7d9076', 'type' => 'library', 'install_path' => __DIR__ . '/../heureka/inflection', 'aliases' => array(), 'dev_requirement' => \false), 'heureka/overeno-zakazniky' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => 'aa52add431bac32c67b1c00b1969a98709cd611b', 'type' => 'library', 'install_path' => __DIR__ . '/../heureka/overeno-zakazniky', 'aliases' => array(), 'dev_requirement' => \false), 'laravel/serializable-closure' => array('pretty_version' => 'v1.3.7', 'version' => '1.3.7.0', 'reference' => '4f48ade902b94323ca3be7646db16209ec76be3d', 'type' => 'library', 'install_path' => __DIR__ . '/../laravel/serializable-closure', 'aliases' => array(), 'dev_requirement' => \false), 'monolog/monolog' => array('pretty_version' => '2.10.0', 'version' => '2.10.0.0', 'reference' => '5cf826f2991858b54d5c3809bee745560a1042a7', 'type' => 'library', 'install_path' => __DIR__ . '/../monolog/monolog', 'aliases' => array(), 'dev_requirement' => \false), 'nette/utils' => array('pretty_version' => 'v4.0.7', 'version' => '4.0.7.0', 'reference' => 'e67c4061eb40b9c113b218214e42cb5a0dda28f2', 'type' => 'library', 'install_path' => __DIR__ . '/../nette/utils', 'aliases' => array(), 'dev_requirement' => \false), 'php-di/invoker' => array('pretty_version' => '2.3.6', 'version' => '2.3.6.0', 'reference' => '59f15608528d8a8838d69b422a919fd6b16aa576', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/invoker', 'aliases' => array(), 'dev_requirement' => \false), 'php-di/php-di' => array('pretty_version' => '6.4.0', 'version' => '6.4.0.0', 'reference' => 'ae0f1b3b03d8b29dff81747063cbfd6276246cc4', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/php-di', 'aliases' => array(), 'dev_requirement' => \false), 'php-di/phpdoc-reader' => array('pretty_version' => '2.2.1', 'version' => '2.2.1.0', 'reference' => '66daff34cbd2627740ffec9469ffbac9f8c8185c', 'type' => 'library', 'install_path' => __DIR__ . '/../php-di/phpdoc-reader', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container' => array('pretty_version' => '1.1.2', 'version' => '1.1.2.0', 'reference' => '513e0666f7216c7459170d56df27dfcefe1689ea', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/container', 'aliases' => array(), 'dev_requirement' => \false), 'psr/container-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '^1.0')), 'psr/http-client' => array('pretty_version' => '1.0.3', 'version' => '1.0.3.0', 'reference' => 'bb5906edc1c324c9a05aa0873d40117941e5fa90', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-client', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-client-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/http-factory' => array('pretty_version' => '1.1.0', 'version' => '1.1.0.0', 'reference' => '2b4765fddfe3b508ac62f829e852b1501d3f6e8a', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-factory', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-factory-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/http-message' => array('pretty_version' => '2.0', 'version' => '2.0.0.0', 'reference' => '402d35bcb92c70c026d1a6a9883f06b2ead23d71', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/http-message', 'aliases' => array(), 'dev_requirement' => \false), 'psr/http-message-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0')), 'psr/log' => array('pretty_version' => '1.1.4', 'version' => '1.1.4.0', 'reference' => 'd49695b909c3b7628b6289db5479a1c204601f11', 'type' => 'library', 'install_path' => __DIR__ . '/../psr/log', 'aliases' => array(), 'dev_requirement' => \false), 'psr/log-implementation' => array('dev_requirement' => \false, 'provided' => array(0 => '1.0.0 || 2.0.0 || 3.0.0')), 'ralouphie/getallheaders' => array('pretty_version' => '3.0.3', 'version' => '3.0.3.0', 'reference' => '120b605dfeb996808c31b6477290a714d356e822', 'type' => 'library', 'install_path' => __DIR__ . '/../ralouphie/getallheaders', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/czqrpayment' => array('pretty_version' => 'v5.3.1', 'version' => '5.3.1.0', 'reference' => 'f8e0ecbbdb6d30bafb50a833cc7cfe4f575b82a4', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/czqrpayment', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/iban' => array('pretty_version' => 'v1.3.0', 'version' => '1.3.0.0', 'reference' => '7fe69bf9274792c37d5a8d9d38ef5cb000f8377a', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/iban', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/qr-payment-interface' => array('pretty_version' => 'v1.1.0', 'version' => '1.1.0.0', 'reference' => '752f7a6bf1190c7d65ead90b5989f61927436c89', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/qr-payment-interface', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/qr-payment-qr-code-provider' => array('pretty_version' => 'v1.2.0', 'version' => '1.2.0.0', 'reference' => 'd233c4bedeecf2ff7cd7e7d4ec7f4ad4a5eb4b64', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/qr-payment-qr-code-provider', 'aliases' => array(), 'dev_requirement' => \false), 'rikudou/skqrpayment' => array('pretty_version' => 'v4.2.2', 'version' => '4.2.2.0', 'reference' => '777fa98caaff3f10fb43f3cf67a8464c547e0550', 'type' => 'library', 'install_path' => __DIR__ . '/../rikudou/skqrpayment', 'aliases' => array(), 'dev_requirement' => \false), 'spatie/array-to-xml' => array('pretty_version' => '2.17.1', 'version' => '2.17.1.0', 'reference' => '5cbec9c6ab17e320c58a259f0cebe88bde4a7c46', 'type' => 'library', 'install_path' => __DIR__ . '/../spatie/array-to-xml', 'aliases' => array(), 'dev_requirement' => \false), 'symfony/deprecation-contracts' => array('pretty_version' => 'v3.6.0', 'version' => '3.6.0.0', 'reference' => '63afe740e99a13ba87ec199bb07bbdee937a5b62', 'type' => 'library', 'install_path' => __DIR__ . '/../symfony/deprecation-contracts', 'aliases' => array(), 'dev_requirement' => \false), 'woocommerce/action-scheduler' => array('pretty_version' => '3.9.2', 'version' => '3.9.2.0', 'reference' => 'efbb7953f72a433086335b249292f280dd43ddfe', 'type' => 'wordpress-plugin', 'install_path' => __DIR__ . '/../woocommerce/action-scheduler', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/asset' => array('pretty_version' => '1.3.0', 'version' => '1.3.0.0', 'reference' => 'faf957af650b441b49f03cb7ffa42abfe157b43b', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/asset', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/custom-fields' => array('pretty_version' => '4.0.65', 'version' => '4.0.65.0', 'reference' => '2d3de7bbce4c14a524a7babe034a797461a7737c', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/custom-fields', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/license' => array('pretty_version' => '2.0.7', 'version' => '2.0.7.0', 'reference' => '7f8e7fe16a1bb77cdfcd29c694c5a489fc8db1b1', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/license', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/log' => array('pretty_version' => '1.1.1', 'version' => '1.1.1.0', 'reference' => '5b856a623a574d3ba4f2138d5f4d94c0625329ff', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/log', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/model' => array('pretty_version' => '4.1.24', 'version' => '4.1.24.0', 'reference' => 'ebcac0038014dd0a8d7af5b31e3ee1efa542e9ec', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/model', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/plugin-utils' => array('pretty_version' => '1.0.1', 'version' => '1.0.1.0', 'reference' => '0ace7f3a23bdfe3e2b2b05c72af79fa034c7e77a', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/plugin-utils', 'aliases' => array(), 'dev_requirement' => \false), 'wpify/woo-core' => array('pretty_version' => '5.1.20', 'version' => '5.1.20.0', 'reference' => '2d2032c6da6b538079d8e152618b1e5493319409', 'type' => 'library', 'install_path' => __DIR__ . '/../wpify/woo-core', 'aliases' => array(), 'dev_requirement' => \false)));
  • wpify-woo/trunk/wpify-woo.php

    r3319782 r3319787  
    44 * Plugin Name:          WPify Woo
    55 * Description:          Custom functionality for WooCommerce
    6  * Version:              5.0.13
     6 * Version:              5.0.14
    77 * Requires PHP:         8.1.0
    88 * Requires at least:    6.2
Note: See TracChangeset for help on using the changeset viewer.