Changeset 3472745
- Timestamp:
- 03/02/2026 02:03:12 PM (4 weeks ago)
- Location:
- tax-switch-for-woocommerce
- Files:
-
- 111 added
- 7 edited
-
tags/1.6.10 (added)
-
tags/1.6.10/LICENSE.txt (added)
-
tags/1.6.10/README.txt (added)
-
tags/1.6.10/admin (added)
-
tags/1.6.10/admin/class-wdevs-tax-switch-admin.php (added)
-
tags/1.6.10/admin/index.php (added)
-
tags/1.6.10/admin/js (added)
-
tags/1.6.10/admin/js/wdevs-tax-switch-woocommerce.js (added)
-
tags/1.6.10/admin/partials (added)
-
tags/1.6.10/admin/partials/section-wdevs-tax-switch-shortcode.php (added)
-
tags/1.6.10/build (added)
-
tags/1.6.10/build/label (added)
-
tags/1.6.10/build/label/block.json (added)
-
tags/1.6.10/build/label/index-rtl.css (added)
-
tags/1.6.10/build/label/index.asset.php (added)
-
tags/1.6.10/build/label/index.css (added)
-
tags/1.6.10/build/label/index.js (added)
-
tags/1.6.10/build/label/style-index-rtl.css (added)
-
tags/1.6.10/build/label/style-index.css (added)
-
tags/1.6.10/build/label/view.asset.php (added)
-
tags/1.6.10/build/label/view.js (added)
-
tags/1.6.10/build/shared (added)
-
tags/1.6.10/build/shared/shared.asset.php (added)
-
tags/1.6.10/build/shared/shared.js (added)
-
tags/1.6.10/build/switch (added)
-
tags/1.6.10/build/switch/advanced-product-fields-for-woocommerce.asset.php (added)
-
tags/1.6.10/build/switch/advanced-product-fields-for-woocommerce.js (added)
-
tags/1.6.10/build/switch/block.json (added)
-
tags/1.6.10/build/switch/facetwp.asset.php (added)
-
tags/1.6.10/build/switch/facetwp.js (added)
-
tags/1.6.10/build/switch/fibofilters.asset.php (added)
-
tags/1.6.10/build/switch/fibofilters.js (added)
-
tags/1.6.10/build/switch/index-rtl.css (added)
-
tags/1.6.10/build/switch/index.asset.php (added)
-
tags/1.6.10/build/switch/index.css (added)
-
tags/1.6.10/build/switch/index.js (added)
-
tags/1.6.10/build/switch/kapee-theme.asset.php (added)
-
tags/1.6.10/build/switch/kapee-theme.js (added)
-
tags/1.6.10/build/switch/product-extras-for-woocommerce.asset.php (added)
-
tags/1.6.10/build/switch/product-extras-for-woocommerce.js (added)
-
tags/1.6.10/build/switch/style-index-rtl.css (added)
-
tags/1.6.10/build/switch/style-index.css (added)
-
tags/1.6.10/build/switch/view.asset.php (added)
-
tags/1.6.10/build/switch/view.js (added)
-
tags/1.6.10/build/switch/woocommerce-fees-discounts.asset.php (added)
-
tags/1.6.10/build/switch/woocommerce-fees-discounts.js (added)
-
tags/1.6.10/build/switch/woocommerce-measurement-price-calculator.asset.php (added)
-
tags/1.6.10/build/switch/woocommerce-measurement-price-calculator.js (added)
-
tags/1.6.10/build/switch/woocommerce-product-addons.asset.php (added)
-
tags/1.6.10/build/switch/woocommerce-product-addons.js (added)
-
tags/1.6.10/build/switch/woocommerce-quantity-manager.asset.php (added)
-
tags/1.6.10/build/switch/woocommerce-quantity-manager.js (added)
-
tags/1.6.10/build/switch/woocommerce-tiered-price-table.asset.php (added)
-
tags/1.6.10/build/switch/woocommerce-tiered-price-table.js (added)
-
tags/1.6.10/build/switch/woocommerce-tm-extra-product-options.asset.php (added)
-
tags/1.6.10/build/switch/woocommerce-tm-extra-product-options.js (added)
-
tags/1.6.10/build/switch/woodmart-theme.asset.php (added)
-
tags/1.6.10/build/switch/woodmart-theme.js (added)
-
tags/1.6.10/build/switch/wp-grid-builder.asset.php (added)
-
tags/1.6.10/build/switch/wp-grid-builder.js (added)
-
tags/1.6.10/build/switch/yith-woocommerce-product-add-ons.asset.php (added)
-
tags/1.6.10/build/switch/yith-woocommerce-product-add-ons.js (added)
-
tags/1.6.10/includes (added)
-
tags/1.6.10/includes/assets (added)
-
tags/1.6.10/includes/assets/css (added)
-
tags/1.6.10/includes/assets/css/wdevs-tax-switch-shared.css (added)
-
tags/1.6.10/includes/class-wdevs-tax-switch-activator.php (added)
-
tags/1.6.10/includes/class-wdevs-tax-switch-block-label.php (added)
-
tags/1.6.10/includes/class-wdevs-tax-switch-block-shared.php (added)
-
tags/1.6.10/includes/class-wdevs-tax-switch-block-switch.php (added)
-
tags/1.6.10/includes/class-wdevs-tax-switch-block.php (added)
-
tags/1.6.10/includes/class-wdevs-tax-switch-compatibility.php (added)
-
tags/1.6.10/includes/class-wdevs-tax-switch-deactivator.php (added)
-
tags/1.6.10/includes/class-wdevs-tax-switch-loader.php (added)
-
tags/1.6.10/includes/class-wdevs-tax-switch-mini-cart-context.php (added)
-
tags/1.6.10/includes/class-wdevs-tax-switch-woocommerce.php (added)
-
tags/1.6.10/includes/class-wdevs-tax-switch.php (added)
-
tags/1.6.10/includes/index.php (added)
-
tags/1.6.10/includes/trait-wdevs-tax-switch-display.php (added)
-
tags/1.6.10/includes/trait-wdevs-tax-switch-helper.php (added)
-
tags/1.6.10/includes/trait-wdevs-tax-switch-plugins.php (added)
-
tags/1.6.10/languages (added)
-
tags/1.6.10/languages/build.json (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-en_US-0b9526334c88655b7ec3959bb635770d.json (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-en_US-43dcd1c557291b1a502cbd2ea4d36beb.json (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-en_US-a7d03486c29d1d1d1553c783663175ae.json (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-en_US.l10n.php (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-en_US.mo (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-en_US.po (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-nl_NL-0b9526334c88655b7ec3959bb635770d.json (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-nl_NL-43dcd1c557291b1a502cbd2ea4d36beb.json (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-nl_NL-a7d03486c29d1d1d1553c783663175ae.json (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-nl_NL.l10n.php (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-nl_NL.mo (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-nl_NL.po (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-sv_SE-0b9526334c88655b7ec3959bb635770d.json (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-sv_SE-43dcd1c557291b1a502cbd2ea4d36beb.json (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-sv_SE-a7d03486c29d1d1d1553c783663175ae.json (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-sv_SE.l10n.php (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-sv_SE.mo (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce-sv_SE.po (added)
-
tags/1.6.10/languages/tax-switch-for-woocommerce.pot (added)
-
tags/1.6.10/public (added)
-
tags/1.6.10/public/class-wdevs-tax-switch-public.php (added)
-
tags/1.6.10/public/css (added)
-
tags/1.6.10/public/css/wdevs-tax-switch-public.css (added)
-
tags/1.6.10/public/index.php (added)
-
tags/1.6.10/uninstall.php (added)
-
tags/1.6.10/wdevs-tax-switch.php (added)
-
trunk/README.txt (modified) (3 diffs)
-
trunk/build/label/block.json (modified) (1 diff)
-
trunk/build/shared/shared.asset.php (modified) (1 diff)
-
trunk/build/shared/shared.js (modified) (1 diff)
-
trunk/build/switch/block.json (modified) (1 diff)
-
trunk/build/switch/wp-grid-builder.asset.php (added)
-
trunk/build/switch/wp-grid-builder.js (added)
-
trunk/includes/class-wdevs-tax-switch-compatibility.php (modified) (1 diff)
-
trunk/wdevs-tax-switch.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tax-switch-for-woocommerce/trunk/README.txt
r3460537 r3472745 4 4 Requires at least: 5.0 5 5 Tested up to: 6.9 6 Stable tag: 1.6. 96 Stable tag: 1.6.10 7 7 Requires PHP: 7.2 8 8 License: GPL-2.0+ … … 210 210 * WooCommerce Dynamic Pricing and Discount Rules 211 211 * Price Based on Country for WooCommerce 212 * WP Grid Builder 212 213 213 214 If you encounter any compatibility issues with other plugins or themes, please let us know. Your feedback helps us improve the plugin and extend compatibility to more third-party solutions. … … 246 247 247 248 == Changelog == 249 = 1.6.10 = 250 * Added compatibility for WP Grid Builder 251 248 252 = 1.6.9 = 249 253 * Added new option for setting the tax switch aria-label -
tax-switch-for-woocommerce/trunk/build/label/block.json
r3460537 r3472745 3 3 "apiVersion": 3, 4 4 "name": "wdevs/tax-switch-label", 5 "version": "1.6. 9",5 "version": "1.6.10", 6 6 "title": "Tax Switch text label", 7 7 "category": "woocommerce", -
tax-switch-for-woocommerce/trunk/build/shared/shared.asset.php
r3460537 r3472745 1 <?php return array('dependencies' => array(), 'version' => ' 67d6e6021b66ee1ffc4b');1 <?php return array('dependencies' => array(), 'version' => '1d8c1fcff7db2584165b'); -
tax-switch-for-woocommerce/trunk/build/shared/shared.js
r3460537 r3472745 1 "use strict";(globalThis.webpackChunkwdevs_tax_switch=globalThis.webpackChunkwdevs_tax_switch||[]).push([[320],{67:(t,e,s)=>{s.d(e,{A:()=>o});var i=s(87),c=s(143),n=s(159),a=s(75),l=s(790);class r extends i.Component{constructor(t){super(t);const{readOnly:e,isSwitched:s}=this.getInitialState(t);this.state={readOnly:e,isSwitched:s},this.unsubscribe=(0,c.subscribe)(()=>{const t=(0,a.ir)();this.state.isSwitched!==t&&this.setState({isSwitched:t})})}getInitialState(t){const e=n.A.parseBooleanValue(t.readOnly),s=t.originalTaxDisplay||"incl";let i;return i=e?!("incl"===s):(0,a.ir)(),{readOnly:e,isSwitched:i}}componentWillUnmount(){this.unsubscribe&&this.unsubscribe()}displayIncludingVat(){const{originalTaxDisplay:t="incl"}=this.props,{isSwitched:e}=this.state;return n.A.displayIncludingVat(t,e)}getCurrentLabel(){const{labelTextIncl:t,labelTextExcl:e}=this.props;return this.displayIncludingVat()?t||"":e||""}render(){const{labelTextColor:t,labelTextColorChecked:e,labelTextIncl:s,labelTextExcl:i}=this.props;if(!s&&!i)return"";const c=this.displayIncludingVat();return(0,l.jsx)("span",{className:"wdevs-tax-switch-labels "+(c?"wts-price-incl":"wts-price-excl"),style:{"--wts-text-color":t,"--wts-text-color-checked":e},children:(0,l.jsx)("span",{className:"wdevs-tax-switch-label-text",children:this.getCurrentLabel()})})}}const o=/^(38|733)$/.test(s.j)?r:null},75:(t,e,s)=>{s.d(e,{D_:()=>u,WJ:()=>w,ir:()=>d,rj:()=>h,z6:()=>p});var i=s(143);const c="wdevs_tax_switch_is_switched",n="wdevs-tax-switch/store",a="SET_IS_SWITCHED",l="SET_IS_DISABLED",r={setIsSwitched:t=>({type:a,value:t}),saveIsSwitched:t=>(localStorage.setItem(c,JSON.stringify(t)),{type:a,value:t}),setIsDisabled:t=>({type:l,value:t})};let o=(0,i.select)(n);function d(){return(0,i.select)(n).getIsSwitched()}function h(t){return(0,i.dispatch)(n).saveIsSwitched(t)}function w(t){return(0,i.dispatch)(n).setIsSwitched(t)}function u(){return(0,i.select)(n).getIsDisabled()}function p(t){return(0,i.dispatch)(n).setIsDisabled(t)}void 0===o&&(o=(0,i.createReduxStore)(n,{reducer:(t=(()=>{const t=localStorage.getItem(c);return{isSwitched:!!t&&JSON.parse(t),isDisabled:!1}})(),e)=>{switch(e.type){case a:return{...t,isSwitched:e.value};case l:return{...t,isDisabled:e.value};default:return t}},actions:r,selectors:{getIsSwitched:t=>t.isSwitched,getIsDisabled:t=>t.isDisabled}}),(0,i.register)(o))},159:(t,e,s)=>{s.d(e,{A:()=>c});var i=s(75);const c=285!=s.j?class{static togglePriceClasses(t,e){const s=this.displayIncludingVat(t,e);document.querySelectorAll(".wts-price-wrapper").forEach(t=>{const e=t.querySelector(":scope > .wts-price-incl"),i=t.querySelector(":scope > .wts-price-excl");s?(e.classList.remove("wts-inactive"),e.classList.add("wts-active"),i.classList.remove("wts-active"),i.classList.add("wts-inactive")):(e.classList.remove("wts-active"),e.classList.add("wts-inactive"),i.classList.remove("wts-inactive"),i.classList.add("wts-active"))})}static displayIncludingVat(t,e){return null==e&&(e=(0,i.ir)()),"incl"===t&&!e||"excl"===t&&e}static parseBooleanValue(t){return!!t&&JSON.parse(t)}static setPriceClasses(t){return this.togglePriceClasses(t,(0,i.ir)())}static calculateAlternatePrice(t,e,s){if(!t||t<=0||!s)return t;const i=1+s/100;let c;return c="incl"===e?t/i:t*i,Number(c.toFixed(2))}static calculateOriginalPrice(t,e,s){let i="excl";return"excl"===e&&(i="incl"),this.calculateAlternatePrice(t,i,s)}}:null},538:(t,e,s)=>{function i(){return!(window.wtsViewObject||{checkPriceElements:!1}).checkPriceElements||document.querySelectorAll(".wts-price-wrapper").length>0}function c(t){"loading"!==document.readyState?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}s.d(e,{I:()=>i,P:()=>c})},651:(t,e,s)=>{s.d(e,{A:()=>i});const i=/^( 202|285|38|657|733|793|894)$/.test(s.j)?null:class{constructor(t){this.originalTaxDisplay=t}build(t,e,s,i=null){const c=this.getPricesBasedOnTaxDisplay(e,s),n=c.including,a=c.excluding;function l(t){return t?"wts-active":"wts-inactive"}function r(e,s){return`\n <span class="wts-price-${s?"incl":"excl"} ${l(s===t)}">\n ${e}\n </span>\n `}let o=`\n <span class="wts-price-container">\n <span class="wts-price-wrapper">\n ${r(n,!0)}\n ${r(a,!1)}\n </span>\n `;if(i){function d(e,s){return`\n <span class="wts-price-${s?"incl":"excl"} ${l(s===t)}">\n ${e}\n </span>\n `}o+=`\n <span class="wts-price-wrapper">\n ${d(i.including,!0)}\n ${d(i.excluding,!1)}\n </span>\n `}return o+="</span>",o.trim()}getPricesBasedOnTaxDisplay(t,e){return"incl"===this.originalTaxDisplay?{including:t,excluding:e}:{including:e,excluding:t}}static getVatTexts(t=null){const e=document.createTextNode(" ").nodeValue;let s,i;if(window.wtsCompatibilityObject&&window.wtsCompatibilityObject.includingVatText&&window.wtsCompatibilityObject.excludingVatText)return s=window.wtsCompatibilityObject.includingVatText,i=window.wtsCompatibilityObject.excludingVatText,{including:e+`<span class="wts-vat-text">${s}</span>`,excluding:e+`<span class="wts-vat-text">${i}</span>`};if(t){const c=jQuery(t);if(s=c.find(".wts-price-incl .wts-vat-text").first(),i=c.find(".wts-price-excl .wts-vat-text").first(),s.length||i.length)return{including:s.length?e+s.clone().prop("outerHTML"):"",excluding:i.length?e+i.clone().prop("outerHTML"):""}}return s=jQuery(".wts-price-wrapper .wts-price-incl .wts-vat-text").first(),i=jQuery(".wts-price-wrapper .wts-price-excl .wts-vat-text").first(),{including:s.length?e+s.clone().prop("outerHTML"):"",excluding:i.length?e+i.clone().prop("outerHTML"):""}}static getVatTextElement(t,e,s){return`<span class="wts-price-wrapper">\n <span class="wts-price-incl ${t?"wts-active":"wts-inactive"}">\n ${e}\n </span>\n <span class="wts-price-excl ${t?"wts-inactive":"wts-active"}">\n ${s}\n </span>\n </span>\n `}}},983:(t,e,s)=>{s.d(e,{A:()=>d});var i=s(87),c=s(143),n=s(723),a=s(159),l=s(75),r=s(790);class o extends i.Component{constructor(t){super(t);const{readOnly:e,isSwitched:s}=this.getInitialState(t);this.state={readOnly:e,isSwitched:s,isDisabled:(0,l.D_)()},this.handleChange=this.handleChange.bind(this),this.unsubscribe=(0,c.subscribe)(()=>{const t=(0,l.ir)(),e=(0,l.D_)();this.state.isSwitched===t&&this.state.isDisabled===e||this.setState({isSwitched:t,isDisabled:e})})}getInitialState(t){const e=a.A.parseBooleanValue(t.readOnly),s=t.originalTaxDisplay||"incl";let i;return i=e?!("incl"===s):(0,l.ir)(),{readOnly:e,isSwitched:i}}componentWillUnmount(){this.unsubscribe&&this.unsubscribe()}handleChange(){const t=!this.state.isSwitched;this.setState({isSwitched:t},()=>{this.state.readOnly?(0,l.WJ)(t):((0,l.rj)(t),this.fireSwitchChangeEvent(t)),this.togglePriceClasses()})}displayIncludingVat(){const{originalTaxDisplay:t="incl"}=this.props,{isSwitched:e}=this.state;return a.A.displayIncludingVat(t,e)}togglePriceClasses(){const{originalTaxDisplay:t="incl"}=this.props,{isSwitched:e}=this.state;return a.A.togglePriceClasses(t,e)}getToggleSwitchAriaLabel(){const{switchAriaLabel:t,switchLabelIncl:e,switchLabelExcl:s}=this.props;return t||(e&&s?e+" / "+s:(0,n.__)("Switch between prices including and excluding VAT","tax-switch-for-woocommerce"))}getCurrentLabel(){const{switchLabelIncl:t,switchLabelExcl:e}=this.props;return this.displayIncludingVat()?t||"":e||""}fireSwitchChangeEvent(t){const e=new CustomEvent("wdevs-tax-switch-changed",{detail:{isSwitched:t,displayIncludingVat:this.displayIncludingVat()}});document.dispatchEvent(e)}renderButtons(){const{switchColor:t,switchColorChecked:e,switchBackgroundColor:s,switchBackgroundColorChecked:i,switchTextColor:c,switchLabelIncl:a,switchLabelExcl:l}=this.props,o=this.displayIncludingVat(),{isDisabled:d}=this.state;return(0,r.jsxs)("div",{className:"wdevs-tax-switch wdevs-tax-buttons",style:{"--wts-color":t,"--wts-color-checked":e,"--wts-bg-color":s,"--wts-bg-color-checked":i,"--wts-text-color":c},children:[(0,r.jsx)("button",{type:"button",className:"wdevs-tax-button "+(o?"wdevs-tax-button-active":""),disabled:d,onClick:()=>{o||this.handleChange()},children:a||(0,n.__)("Incl. VAT","tax-switch-for-woocommerce")}),(0,r.jsx)("button",{type:"button",className:"wdevs-tax-button "+(o?"":"wdevs-tax-button-active"),disabled:d,onClick:()=>{o&&this.handleChange()},children:l||(0,n.__)("Excl. VAT","tax-switch-for-woocommerce")})]})}renderToggleSwitch(){const{switchColor:t,switchColorChecked:e,switchBackgroundColor:s,switchBackgroundColorChecked:i,switchTextColor:c,switchLabelIncl:n,switchLabelExcl:a}=this.props,l=this.displayIncludingVat(),o=n||a,{isDisabled:d}=this.state;return(0,r.jsxs)("div",{className:"wdevs-tax-switch",style:{"--wts-color":t,"--wts-color-checked":e,"--wts-bg-color":s,"--wts-bg-color-checked":i,"--wts-text-color":c},children:[(0,r.jsxs)("label",{className:"wdevs-tax-switch-label",children:[(0,r.jsx)("input",{type:"checkbox",name:"wdevs-tax-switch-checkbox",onChange:this.handleChange,checked:l,disabled:d,className:"wdevs-tax-switch-checkbox","aria-label":this.getToggleSwitchAriaLabel()}),(0,r.jsx)("span",{className:"wdevs-tax-switch-slider"})]}),o&&(0,r.jsx)("span",{className:"wdevs-tax-switch-label-text",onClick:this.handleChange,role:"button",tabIndex:0,onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleChange())},children:this.getCurrentLabel()})]})}render(){const{switchType:t="switch"}=this.props;return"buttons"===t?this.renderButtons():this.renderToggleSwitch()}}const d=/^(202|793)$/.test(s.j)?o:null}}]);1 "use strict";(globalThis.webpackChunkwdevs_tax_switch=globalThis.webpackChunkwdevs_tax_switch||[]).push([[320],{67:(t,e,s)=>{s.d(e,{A:()=>o});var i=s(87),c=s(143),n=s(159),a=s(75),l=s(790);class r extends i.Component{constructor(t){super(t);const{readOnly:e,isSwitched:s}=this.getInitialState(t);this.state={readOnly:e,isSwitched:s},this.unsubscribe=(0,c.subscribe)(()=>{const t=(0,a.ir)();this.state.isSwitched!==t&&this.setState({isSwitched:t})})}getInitialState(t){const e=n.A.parseBooleanValue(t.readOnly),s=t.originalTaxDisplay||"incl";let i;return i=e?!("incl"===s):(0,a.ir)(),{readOnly:e,isSwitched:i}}componentWillUnmount(){this.unsubscribe&&this.unsubscribe()}displayIncludingVat(){const{originalTaxDisplay:t="incl"}=this.props,{isSwitched:e}=this.state;return n.A.displayIncludingVat(t,e)}getCurrentLabel(){const{labelTextIncl:t,labelTextExcl:e}=this.props;return this.displayIncludingVat()?t||"":e||""}render(){const{labelTextColor:t,labelTextColorChecked:e,labelTextIncl:s,labelTextExcl:i}=this.props;if(!s&&!i)return"";const c=this.displayIncludingVat();return(0,l.jsx)("span",{className:"wdevs-tax-switch-labels "+(c?"wts-price-incl":"wts-price-excl"),style:{"--wts-text-color":t,"--wts-text-color-checked":e},children:(0,l.jsx)("span",{className:"wdevs-tax-switch-label-text",children:this.getCurrentLabel()})})}}const o=/^(38|733)$/.test(s.j)?r:null},75:(t,e,s)=>{s.d(e,{D_:()=>u,WJ:()=>w,ir:()=>d,rj:()=>h,z6:()=>p});var i=s(143);const c="wdevs_tax_switch_is_switched",n="wdevs-tax-switch/store",a="SET_IS_SWITCHED",l="SET_IS_DISABLED",r={setIsSwitched:t=>({type:a,value:t}),saveIsSwitched:t=>(localStorage.setItem(c,JSON.stringify(t)),{type:a,value:t}),setIsDisabled:t=>({type:l,value:t})};let o=(0,i.select)(n);function d(){return(0,i.select)(n).getIsSwitched()}function h(t){return(0,i.dispatch)(n).saveIsSwitched(t)}function w(t){return(0,i.dispatch)(n).setIsSwitched(t)}function u(){return(0,i.select)(n).getIsDisabled()}function p(t){return(0,i.dispatch)(n).setIsDisabled(t)}void 0===o&&(o=(0,i.createReduxStore)(n,{reducer:(t=(()=>{const t=localStorage.getItem(c);return{isSwitched:!!t&&JSON.parse(t),isDisabled:!1}})(),e)=>{switch(e.type){case a:return{...t,isSwitched:e.value};case l:return{...t,isDisabled:e.value};default:return t}},actions:r,selectors:{getIsSwitched:t=>t.isSwitched,getIsDisabled:t=>t.isDisabled}}),(0,i.register)(o))},159:(t,e,s)=>{s.d(e,{A:()=>c});var i=s(75);const c=285!=s.j?class{static togglePriceClasses(t,e){const s=this.displayIncludingVat(t,e);document.querySelectorAll(".wts-price-wrapper").forEach(t=>{const e=t.querySelector(":scope > .wts-price-incl"),i=t.querySelector(":scope > .wts-price-excl");s?(e.classList.remove("wts-inactive"),e.classList.add("wts-active"),i.classList.remove("wts-active"),i.classList.add("wts-inactive")):(e.classList.remove("wts-active"),e.classList.add("wts-inactive"),i.classList.remove("wts-inactive"),i.classList.add("wts-active"))})}static displayIncludingVat(t,e){return null==e&&(e=(0,i.ir)()),"incl"===t&&!e||"excl"===t&&e}static parseBooleanValue(t){return!!t&&JSON.parse(t)}static setPriceClasses(t){return this.togglePriceClasses(t,(0,i.ir)())}static calculateAlternatePrice(t,e,s){if(!t||t<=0||!s)return t;const i=1+s/100;let c;return c="incl"===e?t/i:t*i,Number(c.toFixed(2))}static calculateOriginalPrice(t,e,s){let i="excl";return"excl"===e&&(i="incl"),this.calculateAlternatePrice(t,i,s)}}:null},538:(t,e,s)=>{function i(){return!(window.wtsViewObject||{checkPriceElements:!1}).checkPriceElements||document.querySelectorAll(".wts-price-wrapper").length>0}function c(t){"loading"!==document.readyState?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}s.d(e,{I:()=>i,P:()=>c})},651:(t,e,s)=>{s.d(e,{A:()=>i});const i=/^(154|202|285|38|657|733|793|894)$/.test(s.j)?null:class{constructor(t){this.originalTaxDisplay=t}build(t,e,s,i=null){const c=this.getPricesBasedOnTaxDisplay(e,s),n=c.including,a=c.excluding;function l(t){return t?"wts-active":"wts-inactive"}function r(e,s){return`\n <span class="wts-price-${s?"incl":"excl"} ${l(s===t)}">\n ${e}\n </span>\n `}let o=`\n <span class="wts-price-container">\n <span class="wts-price-wrapper">\n ${r(n,!0)}\n ${r(a,!1)}\n </span>\n `;if(i){function d(e,s){return`\n <span class="wts-price-${s?"incl":"excl"} ${l(s===t)}">\n ${e}\n </span>\n `}o+=`\n <span class="wts-price-wrapper">\n ${d(i.including,!0)}\n ${d(i.excluding,!1)}\n </span>\n `}return o+="</span>",o.trim()}getPricesBasedOnTaxDisplay(t,e){return"incl"===this.originalTaxDisplay?{including:t,excluding:e}:{including:e,excluding:t}}static getVatTexts(t=null){const e=document.createTextNode(" ").nodeValue;let s,i;if(window.wtsCompatibilityObject&&window.wtsCompatibilityObject.includingVatText&&window.wtsCompatibilityObject.excludingVatText)return s=window.wtsCompatibilityObject.includingVatText,i=window.wtsCompatibilityObject.excludingVatText,{including:e+`<span class="wts-vat-text">${s}</span>`,excluding:e+`<span class="wts-vat-text">${i}</span>`};if(t){const c=jQuery(t);if(s=c.find(".wts-price-incl .wts-vat-text").first(),i=c.find(".wts-price-excl .wts-vat-text").first(),s.length||i.length)return{including:s.length?e+s.clone().prop("outerHTML"):"",excluding:i.length?e+i.clone().prop("outerHTML"):""}}return s=jQuery(".wts-price-wrapper .wts-price-incl .wts-vat-text").first(),i=jQuery(".wts-price-wrapper .wts-price-excl .wts-vat-text").first(),{including:s.length?e+s.clone().prop("outerHTML"):"",excluding:i.length?e+i.clone().prop("outerHTML"):""}}static getVatTextElement(t,e,s){return`<span class="wts-price-wrapper">\n <span class="wts-price-incl ${t?"wts-active":"wts-inactive"}">\n ${e}\n </span>\n <span class="wts-price-excl ${t?"wts-inactive":"wts-active"}">\n ${s}\n </span>\n </span>\n `}}},983:(t,e,s)=>{s.d(e,{A:()=>d});var i=s(87),c=s(143),n=s(723),a=s(159),l=s(75),r=s(790);class o extends i.Component{constructor(t){super(t);const{readOnly:e,isSwitched:s}=this.getInitialState(t);this.state={readOnly:e,isSwitched:s,isDisabled:(0,l.D_)()},this.handleChange=this.handleChange.bind(this),this.unsubscribe=(0,c.subscribe)(()=>{const t=(0,l.ir)(),e=(0,l.D_)();this.state.isSwitched===t&&this.state.isDisabled===e||this.setState({isSwitched:t,isDisabled:e})})}getInitialState(t){const e=a.A.parseBooleanValue(t.readOnly),s=t.originalTaxDisplay||"incl";let i;return i=e?!("incl"===s):(0,l.ir)(),{readOnly:e,isSwitched:i}}componentWillUnmount(){this.unsubscribe&&this.unsubscribe()}handleChange(){const t=!this.state.isSwitched;this.setState({isSwitched:t},()=>{this.state.readOnly?(0,l.WJ)(t):((0,l.rj)(t),this.fireSwitchChangeEvent(t)),this.togglePriceClasses()})}displayIncludingVat(){const{originalTaxDisplay:t="incl"}=this.props,{isSwitched:e}=this.state;return a.A.displayIncludingVat(t,e)}togglePriceClasses(){const{originalTaxDisplay:t="incl"}=this.props,{isSwitched:e}=this.state;return a.A.togglePriceClasses(t,e)}getToggleSwitchAriaLabel(){const{switchAriaLabel:t,switchLabelIncl:e,switchLabelExcl:s}=this.props;return t||(e&&s?e+" / "+s:(0,n.__)("Switch between prices including and excluding VAT","tax-switch-for-woocommerce"))}getCurrentLabel(){const{switchLabelIncl:t,switchLabelExcl:e}=this.props;return this.displayIncludingVat()?t||"":e||""}fireSwitchChangeEvent(t){const e=new CustomEvent("wdevs-tax-switch-changed",{detail:{isSwitched:t,displayIncludingVat:this.displayIncludingVat()}});document.dispatchEvent(e)}renderButtons(){const{switchColor:t,switchColorChecked:e,switchBackgroundColor:s,switchBackgroundColorChecked:i,switchTextColor:c,switchLabelIncl:a,switchLabelExcl:l}=this.props,o=this.displayIncludingVat(),{isDisabled:d}=this.state;return(0,r.jsxs)("div",{className:"wdevs-tax-switch wdevs-tax-buttons",style:{"--wts-color":t,"--wts-color-checked":e,"--wts-bg-color":s,"--wts-bg-color-checked":i,"--wts-text-color":c},children:[(0,r.jsx)("button",{type:"button",className:"wdevs-tax-button "+(o?"wdevs-tax-button-active":""),disabled:d,onClick:()=>{o||this.handleChange()},children:a||(0,n.__)("Incl. VAT","tax-switch-for-woocommerce")}),(0,r.jsx)("button",{type:"button",className:"wdevs-tax-button "+(o?"":"wdevs-tax-button-active"),disabled:d,onClick:()=>{o&&this.handleChange()},children:l||(0,n.__)("Excl. VAT","tax-switch-for-woocommerce")})]})}renderToggleSwitch(){const{switchColor:t,switchColorChecked:e,switchBackgroundColor:s,switchBackgroundColorChecked:i,switchTextColor:c,switchLabelIncl:n,switchLabelExcl:a}=this.props,l=this.displayIncludingVat(),o=n||a,{isDisabled:d}=this.state;return(0,r.jsxs)("div",{className:"wdevs-tax-switch",style:{"--wts-color":t,"--wts-color-checked":e,"--wts-bg-color":s,"--wts-bg-color-checked":i,"--wts-text-color":c},children:[(0,r.jsxs)("label",{className:"wdevs-tax-switch-label",children:[(0,r.jsx)("input",{type:"checkbox",name:"wdevs-tax-switch-checkbox",onChange:this.handleChange,checked:l,disabled:d,className:"wdevs-tax-switch-checkbox","aria-label":this.getToggleSwitchAriaLabel()}),(0,r.jsx)("span",{className:"wdevs-tax-switch-slider"})]}),o&&(0,r.jsx)("span",{className:"wdevs-tax-switch-label-text",onClick:this.handleChange,role:"button",tabIndex:0,onKeyDown:t=>{"Enter"!==t.key&&" "!==t.key||(t.preventDefault(),this.handleChange())},children:this.getCurrentLabel()})]})}render(){const{switchType:t="switch"}=this.props;return"buttons"===t?this.renderButtons():this.renderToggleSwitch()}}const d=/^(202|793)$/.test(s.j)?o:null}}]); -
tax-switch-for-woocommerce/trunk/build/switch/block.json
r3460537 r3472745 3 3 "apiVersion": 3, 4 4 "name": "wdevs/tax-switch", 5 "version": "1.6. 9",5 "version": "1.6.10", 6 6 "title": "Tax Switch for WooCommerce", 7 7 "category": "woocommerce", -
tax-switch-for-woocommerce/trunk/includes/class-wdevs-tax-switch-compatibility.php
r3447052 r3472745 220 220 ); 221 221 } 222 223 // WP Grid Builder 224 if ( $this->is_plugin_active( 'wp-grid-builder/wp-grid-builder.php' ) ) { 225 $wp_grid_builder_handle = 'wdevs-tax-switch-wp-grid-builder'; 226 $wp_grid_builder_asset = $this->enqueue_script( $wp_grid_builder_handle, 'switch', 'wp-grid-builder', [ 'wpgb' ] ); 227 } 228 222 229 } 223 230 -
tax-switch-for-woocommerce/trunk/wdevs-tax-switch.php
r3460537 r3472745 17 17 * Plugin URI: https://wijnberg.dev 18 18 * Description: Let customers toggle between inclusive and exclusive VAT pricing in your WooCommerce store. 19 * Version: 1.6. 919 * Version: 1.6.10 20 20 * Author: Wijnberg Developments 21 21 * Author URI: https://wijnberg.dev/ … … 41 41 * Rename this for your plugin and update it as you release new versions. 42 42 */ 43 define( 'WDEVS_TAX_SWITCH_VERSION', '1.6. 9' );43 define( 'WDEVS_TAX_SWITCH_VERSION', '1.6.10' ); 44 44 45 45 /**
Note: See TracChangeset
for help on using the changeset viewer.