Changeset 3447052
- Timestamp:
- 01/26/2026 11:34:14 AM (2 months ago)
- Location:
- tax-switch-for-woocommerce
- Files:
-
- 106 added
- 9 edited
-
tags/1.6.7 (added)
-
tags/1.6.7/LICENSE.txt (added)
-
tags/1.6.7/README.txt (added)
-
tags/1.6.7/admin (added)
-
tags/1.6.7/admin/class-wdevs-tax-switch-admin.php (added)
-
tags/1.6.7/admin/index.php (added)
-
tags/1.6.7/admin/js (added)
-
tags/1.6.7/admin/js/wdevs-tax-switch-woocommerce.js (added)
-
tags/1.6.7/admin/partials (added)
-
tags/1.6.7/admin/partials/section-wdevs-tax-switch-shortcode.php (added)
-
tags/1.6.7/build (added)
-
tags/1.6.7/build/label (added)
-
tags/1.6.7/build/label/block.json (added)
-
tags/1.6.7/build/label/index-rtl.css (added)
-
tags/1.6.7/build/label/index.asset.php (added)
-
tags/1.6.7/build/label/index.css (added)
-
tags/1.6.7/build/label/index.js (added)
-
tags/1.6.7/build/label/style-index-rtl.css (added)
-
tags/1.6.7/build/label/style-index.css (added)
-
tags/1.6.7/build/label/view.asset.php (added)
-
tags/1.6.7/build/label/view.js (added)
-
tags/1.6.7/build/shared (added)
-
tags/1.6.7/build/shared/shared.asset.php (added)
-
tags/1.6.7/build/shared/shared.js (added)
-
tags/1.6.7/build/switch (added)
-
tags/1.6.7/build/switch/advanced-product-fields-for-woocommerce.asset.php (added)
-
tags/1.6.7/build/switch/advanced-product-fields-for-woocommerce.js (added)
-
tags/1.6.7/build/switch/block.json (added)
-
tags/1.6.7/build/switch/facetwp.asset.php (added)
-
tags/1.6.7/build/switch/facetwp.js (added)
-
tags/1.6.7/build/switch/fibofilters.asset.php (added)
-
tags/1.6.7/build/switch/fibofilters.js (added)
-
tags/1.6.7/build/switch/index-rtl.css (added)
-
tags/1.6.7/build/switch/index.asset.php (added)
-
tags/1.6.7/build/switch/index.css (added)
-
tags/1.6.7/build/switch/index.js (added)
-
tags/1.6.7/build/switch/kapee-theme.asset.php (added)
-
tags/1.6.7/build/switch/kapee-theme.js (added)
-
tags/1.6.7/build/switch/product-extras-for-woocommerce.asset.php (added)
-
tags/1.6.7/build/switch/product-extras-for-woocommerce.js (added)
-
tags/1.6.7/build/switch/style-index-rtl.css (added)
-
tags/1.6.7/build/switch/style-index.css (added)
-
tags/1.6.7/build/switch/view.asset.php (added)
-
tags/1.6.7/build/switch/view.js (added)
-
tags/1.6.7/build/switch/woocommerce-fees-discounts.asset.php (added)
-
tags/1.6.7/build/switch/woocommerce-fees-discounts.js (added)
-
tags/1.6.7/build/switch/woocommerce-measurement-price-calculator.asset.php (added)
-
tags/1.6.7/build/switch/woocommerce-measurement-price-calculator.js (added)
-
tags/1.6.7/build/switch/woocommerce-product-addons.asset.php (added)
-
tags/1.6.7/build/switch/woocommerce-product-addons.js (added)
-
tags/1.6.7/build/switch/woocommerce-quantity-manager.asset.php (added)
-
tags/1.6.7/build/switch/woocommerce-quantity-manager.js (added)
-
tags/1.6.7/build/switch/woocommerce-tiered-price-table.asset.php (added)
-
tags/1.6.7/build/switch/woocommerce-tiered-price-table.js (added)
-
tags/1.6.7/build/switch/woocommerce-tm-extra-product-options.asset.php (added)
-
tags/1.6.7/build/switch/woocommerce-tm-extra-product-options.js (added)
-
tags/1.6.7/build/switch/woodmart-theme.asset.php (added)
-
tags/1.6.7/build/switch/woodmart-theme.js (added)
-
tags/1.6.7/build/switch/yith-woocommerce-product-add-ons.asset.php (added)
-
tags/1.6.7/build/switch/yith-woocommerce-product-add-ons.js (added)
-
tags/1.6.7/includes (added)
-
tags/1.6.7/includes/assets (added)
-
tags/1.6.7/includes/assets/css (added)
-
tags/1.6.7/includes/assets/css/wdevs-tax-switch-shared.css (added)
-
tags/1.6.7/includes/class-wdevs-tax-switch-activator.php (added)
-
tags/1.6.7/includes/class-wdevs-tax-switch-block-label.php (added)
-
tags/1.6.7/includes/class-wdevs-tax-switch-block-shared.php (added)
-
tags/1.6.7/includes/class-wdevs-tax-switch-block-switch.php (added)
-
tags/1.6.7/includes/class-wdevs-tax-switch-block.php (added)
-
tags/1.6.7/includes/class-wdevs-tax-switch-compatibility.php (added)
-
tags/1.6.7/includes/class-wdevs-tax-switch-deactivator.php (added)
-
tags/1.6.7/includes/class-wdevs-tax-switch-loader.php (added)
-
tags/1.6.7/includes/class-wdevs-tax-switch-mini-cart-context.php (added)
-
tags/1.6.7/includes/class-wdevs-tax-switch-woocommerce.php (added)
-
tags/1.6.7/includes/class-wdevs-tax-switch.php (added)
-
tags/1.6.7/includes/index.php (added)
-
tags/1.6.7/includes/trait-wdevs-tax-switch-display.php (added)
-
tags/1.6.7/includes/trait-wdevs-tax-switch-helper.php (added)
-
tags/1.6.7/includes/trait-wdevs-tax-switch-plugins.php (added)
-
tags/1.6.7/languages (added)
-
tags/1.6.7/languages/build.json (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce-en_US-43dcd1c557291b1a502cbd2ea4d36beb.json (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce-en_US-a7d03486c29d1d1d1553c783663175ae.json (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce-en_US.l10n.php (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce-en_US.mo (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce-en_US.po (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce-nl_NL-43dcd1c557291b1a502cbd2ea4d36beb.json (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce-nl_NL-a7d03486c29d1d1d1553c783663175ae.json (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce-nl_NL.l10n.php (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce-nl_NL.mo (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce-nl_NL.po (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce-sv_SE-43dcd1c557291b1a502cbd2ea4d36beb.json (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce-sv_SE-a7d03486c29d1d1d1553c783663175ae.json (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce-sv_SE.l10n.php (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce-sv_SE.mo (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce-sv_SE.po (added)
-
tags/1.6.7/languages/tax-switch-for-woocommerce.pot (added)
-
tags/1.6.7/public (added)
-
tags/1.6.7/public/class-wdevs-tax-switch-public.php (added)
-
tags/1.6.7/public/css (added)
-
tags/1.6.7/public/css/wdevs-tax-switch-public.css (added)
-
tags/1.6.7/public/index.php (added)
-
tags/1.6.7/uninstall.php (added)
-
tags/1.6.7/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/woocommerce-fees-discounts.asset.php (added)
-
trunk/build/switch/woocommerce-fees-discounts.js (added)
-
trunk/includes/class-wdevs-tax-switch-compatibility.php (modified) (19 diffs)
-
trunk/includes/trait-wdevs-tax-switch-helper.php (modified) (1 diff)
-
trunk/public/class-wdevs-tax-switch-public.php (modified) (1 diff)
-
trunk/wdevs-tax-switch.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
tax-switch-for-woocommerce/trunk/README.txt
r3444713 r3447052 4 4 Requires at least: 5.0 5 5 Tested up to: 6.9 6 Stable tag: 1.6. 66 Stable tag: 1.6.7 7 7 Requires PHP: 7.2 8 8 License: GPL-2.0+ … … 206 206 * Elementor Pro 207 207 * YITH WooCommerce Role Based Prices 208 * WooCommerce Dynamic Pricing and Discount Rules 208 209 209 210 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. … … 242 243 243 244 == Changelog == 245 = 1.6.7 = 246 * Added compatibility for WooCommerce Dynamic Pricing and Discount Rules 247 244 248 = 1.6.6 = 245 249 * Improved switch accessibility and mobile UX -
tax-switch-for-woocommerce/trunk/build/label/block.json
r3425544 r3447052 3 3 "apiVersion": 3, 4 4 "name": "wdevs/tax-switch-label", 5 "version": "1.6. 5",5 "version": "1.6.7", 6 6 "title": "Tax Switch text label", 7 7 "category": "woocommerce", -
tax-switch-for-woocommerce/trunk/build/shared/shared.asset.php
r3444713 r3447052 1 <?php return array('dependencies' => array(), 'version' => ' 38a0a02ade79fbf60482');1 <?php return array('dependencies' => array(), 'version' => '6e41829bb611003680aa'); -
tax-switch-for-woocommerce/trunk/build/shared/shared.js
r3444713 r3447052 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),n=s(143),c=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,n.subscribe)(()=>{const t=(0,a.ir)();this.state.isSwitched!==t&&this.setState({isSwitched:t})})}getInitialState(t){const e=c.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 c.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 n=this.displayIncludingVat();return(0,l.jsx)("span",{className:"wdevs-tax-switch-labels "+(n?"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_:()=>w,WJ:()=>u,ir:()=>d,rj:()=>h,z6:()=>p});var i=s(143);const n="wdevs_tax_switch_is_switched",c="wdevs-tax-switch/store",a="SET_IS_SWITCHED",l="SET_IS_DISABLED",r={setIsSwitched:t=>({type:a,value:t}),saveIsSwitched:t=>(localStorage.setItem(n,JSON.stringify(t)),{type:a,value:t}),setIsDisabled:t=>({type:l,value:t})};let o=(0,i.select)(c);function d(){return(0,i.select)(c).getIsSwitched()}function h(t){return(0,i.dispatch)(c).saveIsSwitched(t)}function u(t){return(0,i.dispatch)(c).setIsSwitched(t)}function w(){return(0,i.select)(c).getIsDisabled()}function p(t){return(0,i.dispatch)(c).setIsDisabled(t)}void 0===o&&(o=(0,i.createReduxStore)(c,{reducer:(t=(()=>{const t=localStorage.getItem(n);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:()=>n});var i=s(75);const n=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 n;return n="incl"===e?t/i:t*i,Number(n.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 n(t){"loading"!==document.readyState?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}s.d(e,{I:()=>i,P:()=>n})},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 n=this.getPricesBasedOnTaxDisplay(e,s),c=n.including,a=n.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(c,!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( t){const n=jQuery(t);if(s=n.find(".wts-price-incl .wts-vat-text").first(),i=n.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:()=>o});var i=s(87),n=s(143),c=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,isDisabled:(0,a.D_)()},this.handleChange=this.handleChange.bind(this),this.unsubscribe=(0,n.subscribe)(()=>{const t=(0,a.ir)(),e=(0,a.D_)();this.state.isSwitched===t&&this.state.isDisabled===e||this.setState({isSwitched:t,isDisabled:e})})}getInitialState(t){const e=c.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()}handleChange(){const t=!this.state.isSwitched;this.setState({isSwitched:t},()=>{this.state.readOnly?(0,a.WJ)(t):((0,a.rj)(t),this.fireSwitchChangeEvent(t)),this.togglePriceClasses()})}displayIncludingVat(){const{originalTaxDisplay:t="incl"}=this.props,{isSwitched:e}=this.state;return c.A.displayIncludingVat(t,e)}togglePriceClasses(){const{originalTaxDisplay:t="incl"}=this.props,{isSwitched:e}=this.state;return c.A.togglePriceClasses(t,e)}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:n,switchLabelIncl:c,switchLabelExcl:a}=this.props,r=this.displayIncludingVat(),{isDisabled:o}=this.state;return(0,l.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":n},children:[(0,l.jsx)("button",{type:"button",className:"wdevs-tax-button "+(r?"wdevs-tax-button-active":""),disabled:o,onClick:()=>{r||this.handleChange()},children:c||"Incl. VAT"}),(0,l.jsx)("button",{type:"button",className:"wdevs-tax-button "+(r?"":"wdevs-tax-button-active"),disabled:o,onClick:()=>{r&&this.handleChange()},children:a||"Excl. VAT"})]})}renderToggleSwitch(){const{switchColor:t,switchColorChecked:e,switchBackgroundColor:s,switchBackgroundColorChecked:i,switchTextColor:n,switchLabelIncl:c,switchLabelExcl:a}=this.props,r=this.displayIncludingVat(),o=c||a,{isDisabled:d}=this.state;return(0,l.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":n},children:[(0,l.jsxs)("label",{className:"wdevs-tax-switch-label",children:[(0,l.jsx)("input",{type:"checkbox",name:"wdevs-tax-switch-checkbox",onChange:this.handleChange,checked:r,disabled:d,className:"wdevs-tax-switch-checkbox"}),(0,l.jsx)("span",{className:"wdevs-tax-switch-slider"})]}),o&&(0,l.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 o=/^(202|793)$/.test(s.j)?r: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),n=s(143),c=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,n.subscribe)(()=>{const t=(0,a.ir)();this.state.isSwitched!==t&&this.setState({isSwitched:t})})}getInitialState(t){const e=c.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 c.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 n=this.displayIncludingVat();return(0,l.jsx)("span",{className:"wdevs-tax-switch-labels "+(n?"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_:()=>w,WJ:()=>u,ir:()=>d,rj:()=>h,z6:()=>p});var i=s(143);const n="wdevs_tax_switch_is_switched",c="wdevs-tax-switch/store",a="SET_IS_SWITCHED",l="SET_IS_DISABLED",r={setIsSwitched:t=>({type:a,value:t}),saveIsSwitched:t=>(localStorage.setItem(n,JSON.stringify(t)),{type:a,value:t}),setIsDisabled:t=>({type:l,value:t})};let o=(0,i.select)(c);function d(){return(0,i.select)(c).getIsSwitched()}function h(t){return(0,i.dispatch)(c).saveIsSwitched(t)}function u(t){return(0,i.dispatch)(c).setIsSwitched(t)}function w(){return(0,i.select)(c).getIsDisabled()}function p(t){return(0,i.dispatch)(c).setIsDisabled(t)}void 0===o&&(o=(0,i.createReduxStore)(c,{reducer:(t=(()=>{const t=localStorage.getItem(n);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:()=>n});var i=s(75);const n=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 n;return n="incl"===e?t/i:t*i,Number(n.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 n(t){"loading"!==document.readyState?t():document.addEventListener("DOMContentLoaded",t,{once:!0})}s.d(e,{I:()=>i,P:()=>n})},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 n=this.getPricesBasedOnTaxDisplay(e,s),c=n.including,a=n.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(c,!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 n=jQuery(t);if(s=n.find(".wts-price-incl .wts-vat-text").first(),i=n.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:()=>o});var i=s(87),n=s(143),c=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,isDisabled:(0,a.D_)()},this.handleChange=this.handleChange.bind(this),this.unsubscribe=(0,n.subscribe)(()=>{const t=(0,a.ir)(),e=(0,a.D_)();this.state.isSwitched===t&&this.state.isDisabled===e||this.setState({isSwitched:t,isDisabled:e})})}getInitialState(t){const e=c.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()}handleChange(){const t=!this.state.isSwitched;this.setState({isSwitched:t},()=>{this.state.readOnly?(0,a.WJ)(t):((0,a.rj)(t),this.fireSwitchChangeEvent(t)),this.togglePriceClasses()})}displayIncludingVat(){const{originalTaxDisplay:t="incl"}=this.props,{isSwitched:e}=this.state;return c.A.displayIncludingVat(t,e)}togglePriceClasses(){const{originalTaxDisplay:t="incl"}=this.props,{isSwitched:e}=this.state;return c.A.togglePriceClasses(t,e)}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:n,switchLabelIncl:c,switchLabelExcl:a}=this.props,r=this.displayIncludingVat(),{isDisabled:o}=this.state;return(0,l.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":n},children:[(0,l.jsx)("button",{type:"button",className:"wdevs-tax-button "+(r?"wdevs-tax-button-active":""),disabled:o,onClick:()=>{r||this.handleChange()},children:c||"Incl. VAT"}),(0,l.jsx)("button",{type:"button",className:"wdevs-tax-button "+(r?"":"wdevs-tax-button-active"),disabled:o,onClick:()=>{r&&this.handleChange()},children:a||"Excl. VAT"})]})}renderToggleSwitch(){const{switchColor:t,switchColorChecked:e,switchBackgroundColor:s,switchBackgroundColorChecked:i,switchTextColor:n,switchLabelIncl:c,switchLabelExcl:a}=this.props,r=this.displayIncludingVat(),o=c||a,{isDisabled:d}=this.state;return(0,l.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":n},children:[(0,l.jsxs)("label",{className:"wdevs-tax-switch-label",children:[(0,l.jsx)("input",{type:"checkbox",name:"wdevs-tax-switch-checkbox",onChange:this.handleChange,checked:r,disabled:d,className:"wdevs-tax-switch-checkbox"}),(0,l.jsx)("span",{className:"wdevs-tax-switch-slider"})]}),o&&(0,l.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 o=/^(202|793)$/.test(s.j)?r:null}}]); -
tax-switch-for-woocommerce/trunk/build/switch/block.json
r3425544 r3447052 3 3 "apiVersion": 3, 4 4 "name": "wdevs/tax-switch", 5 "version": "1.6. 5",5 "version": "1.6.7", 6 6 "title": "Tax Switch for WooCommerce", 7 7 "category": "woocommerce", -
tax-switch-for-woocommerce/trunk/includes/class-wdevs-tax-switch-compatibility.php
r3417485 r3447052 63 63 if ( $this->is_plugin_active( 'woocommerce-measurement-price-calculator/woocommerce-measurement-price-calculator.php' ) ) { 64 64 $wmpc_handle = 'wdevs-tax-switch-woocommerce-measurement-price-calculator'; 65 $wmpc_asset = $this->enqueue_script($wmpc_handle, 'switch', 'woocommerce-measurement-price-calculator');65 $wmpc_asset = $this->enqueue_script( $wmpc_handle, 'switch', 'woocommerce-measurement-price-calculator' ); 66 66 67 67 wp_localize_script( … … 78 78 ] ) ) { 79 79 $ywpado_handle = 'wdevs-tax-switch-yith-woocommerce-product-add-ons'; 80 $ywpado_asset = $this->enqueue_script($ywpado_handle, 'switch', 'yith-woocommerce-product-add-ons', [ 'yith_wapo_front' ]);80 $ywpado_asset = $this->enqueue_script( $ywpado_handle, 'switch', 'yith-woocommerce-product-add-ons', [ 'yith_wapo_front' ] ); 81 81 82 82 wp_localize_script( … … 90 90 if ( $this->is_plugin_active( 'woocommerce-product-addons/woocommerce-product-addons.php' ) ) { 91 91 $wpado_handle = 'wdevs-tax-switch-woocommerce-product-addons'; 92 $wpado_asset = $this->enqueue_script($wpado_handle, 'switch', 'woocommerce-product-addons', [ 'accounting' ]);92 $wpado_asset = $this->enqueue_script( $wpado_handle, 'switch', 'woocommerce-product-addons', [ 'accounting' ] ); 93 93 94 94 wp_localize_script( … … 102 102 if ( $this->is_plugin_active( 'advanced-product-fields-for-woocommerce-pro/advanced-product-fields-for-woocommerce-pro.php' ) ) { 103 103 $apffw_handle = 'wdevs-tax-switch-advanced-product-fields-for-woocommerce'; 104 $apffw_asset = $this->enqueue_script($apffw_handle, 'switch', 'advanced-product-fields-for-woocommerce', ['wapf-frontend', 'accounting' ]); 104 $apffw_asset = $this->enqueue_script( $apffw_handle, 'switch', 'advanced-product-fields-for-woocommerce', [ 105 'wapf-frontend', 106 'accounting' 107 ] ); 105 108 } 106 109 … … 108 111 if ( $this->is_plugin_active( 'woocommerce-quantity-manager-pro/woocommerce-quantity-manager-pro.php' ) ) { 109 112 $wqm_handle = 'wdevs-tax-switch-woocommerce-quantity-manager'; 110 $wqm_asset = $this->enqueue_script($wqm_handle, 'switch', 'woocommerce-quantity-manager', [ 'accounting' ]);113 $wqm_asset = $this->enqueue_script( $wqm_handle, 'switch', 'woocommerce-quantity-manager', [ 'accounting' ] ); 111 114 112 115 wp_localize_script( … … 119 122 // Product Extras for Woocommerce (Woocommerce Product Add-Ons Ultimate) 120 123 if ( $this->is_plugin_active( 'product-extras-for-woocommerce/product-extras-for-woocommerce.php' ) ) { 121 $pewc_handle = 'wdevs-tax-switch- woocommerce-quantity-manager';122 $pewc_asset = $this->enqueue_script($pewc_handle, 'switch', 'product-extras-for-woocommerce', [ 'accounting' ]); //'pewc-script',breaks things, but I wonder if that correct....124 $pewc_handle = 'wdevs-tax-switch-product-extras-for-woocommerce'; 125 $pewc_asset = $this->enqueue_script( $pewc_handle, 'switch', 'product-extras-for-woocommerce', [ 'accounting' ] ); //'pewc-script',breaks things, but I wonder if that correct.... 123 126 124 127 wp_localize_script( 125 128 $pewc_handle, 126 129 'wtsCompatibilityObject', 127 [ 'baseTaxRate' => $tax_rate ] 130 [ 131 'baseTaxRate' => $tax_rate, 132 'includingVatText' => $this->get_vat_text( true ), 133 'excludingVatText' => $this->get_alternate_vat_text( true ), 134 ] 128 135 ); 129 136 } 130 137 131 138 //Kapee theme 132 if ($this->is_theme_active('Kapee')){139 if ( $this->is_theme_active( 'Kapee' ) ) { 133 140 $kapee_handle = 'wdevs-tax-switch-kapee-theme'; 134 $kapee_asset = $this->enqueue_script($kapee_handle, 'switch', 'kapee-theme', [ 'accounting', 'kapee-script' ]); 141 $kapee_asset = $this->enqueue_script( $kapee_handle, 'switch', 'kapee-theme', [ 142 'accounting', 143 'kapee-script' 144 ] ); 135 145 136 146 wp_localize_script( … … 144 154 if ( $this->is_plugin_active( 'woocommerce-tm-extra-product-options/tm-woo-extra-product-options.php' ) ) { 145 155 $tmtepo_handle = 'wdevs-tax-switch-woocommerce-tm-extra-product-options'; 146 $tmtepo_asset = $this->enqueue_script($tmtepo_handle, 'switch', 'woocommerce-tm-extra-product-options', [ 'themecomplete-epo' ]);156 $tmtepo_asset = $this->enqueue_script( $tmtepo_handle, 'switch', 'woocommerce-tm-extra-product-options', [ 'themecomplete-epo' ] ); 147 157 148 158 wp_localize_script( … … 150 160 'wtsCompatibilityObject', 151 161 [ 'baseTaxRate' => $tax_rate ] 162 ); 163 } 164 165 // WooCommerce Fees & Discounts 166 if ( $this->is_plugin_active( 'woocommerce-fees-discounts/woocommerce-fees-discounts.php' ) ) { 167 $wcfad_handle = 'wdevs-tax-switch-woocommerce-fees-discounts'; 168 $wcfad_asset = $this->enqueue_script( 169 $wcfad_handle, 170 'switch', 171 'woocommerce-fees-discounts', 172 [ 'wcfad-script' ] 173 ); 174 175 wp_localize_script( 176 $wcfad_handle, 177 'wtsCompatibilityObject', 178 [ 179 'baseTaxRate' => $tax_rate, 180 'includingVatText' => $this->get_vat_text( true ), 181 'excludingVatText' => $this->get_alternate_vat_text( true ), 182 ] 152 183 ); 153 184 } … … 160 191 ] ) ) { 161 192 $wctpt_handle = 'wdevs-tax-switch-woocommerce-tiered-price-table'; 162 $wctpt_asset = $this->enqueue_script($wctpt_handle, 'switch', 'woocommerce-tiered-price-table');193 $wctpt_asset = $this->enqueue_script( $wctpt_handle, 'switch', 'woocommerce-tiered-price-table' ); 163 194 } 164 195 … … 166 197 if ( $this->is_plugin_active( 'fibofilters-pro/fibofilters.php' ) ) { 167 198 $ffilters_handle = 'wdevs-tax-switch-fibofilters'; 168 $ffilters_asset = $this->enqueue_script($ffilters_handle, 'switch', 'fibofilters', [ 'fibofilters' ]);199 $ffilters_asset = $this->enqueue_script( $ffilters_handle, 'switch', 'fibofilters', [ 'fibofilters' ] ); 169 200 } 170 201 … … 172 203 if ( $this->is_theme_active( 'woodmart' ) ) { 173 204 $woodmart_handle = 'wdevs-tax-switch-woodmart-theme'; 174 $woodmart_asset = $this->enqueue_script( $woodmart_handle, 'switch', 'woodmart-theme' );205 $woodmart_asset = $this->enqueue_script( $woodmart_handle, 'switch', 'woodmart-theme' ); 175 206 } 176 207 … … 178 209 if ( $this->is_plugin_active( 'facetwp/index.php' ) ) { 179 210 $facetwp_handle = 'wdevs-tax-switch-facetwp'; 180 $facetwp_asset = $this->enqueue_script( $facetwp_handle, 'switch', 'facetwp' );211 $facetwp_asset = $this->enqueue_script( $facetwp_handle, 'switch', 'facetwp' ); 181 212 182 213 // Estimate tax rate for FacetWP (no specific product context available) … … 260 291 * @since 1.5.5 261 292 */ 262 public function render_pewc_price_field( $original_output, $item, $product, $price=false){263 if (!$price){293 public function render_pewc_price_field( $original_output, $item, $product, $price = false ) { 294 if ( ! $price ) { 264 295 return $original_output; 265 296 } … … 298 329 * @since 1.5.11 299 330 */ 300 public function kses_allow_span_classes_for_prices( $tags, $context ){331 public function kses_allow_span_classes_for_prices( $tags, $context ) { 301 332 //filters and actions 302 333 $allowed_contexts = [ … … 338 369 339 370 // Get VAT text options 340 $incl_vat_text = $this->get_option_text( 'wdevs_tax_switch_incl_vat', __( 'Incl. VAT', 'tax-switch-for-woocommerce' ) ); 341 $excl_vat_text = $this->get_option_text( 'wdevs_tax_switch_excl_vat', __( 'Excl. VAT', 'tax-switch-for-woocommerce' ) ); 342 343 if ( $shop_prices_include_tax ) { 344 $vat_text = $incl_vat_text; 345 $alternate_vat_text = $excl_vat_text; 346 } else { 347 $vat_text = $excl_vat_text; 348 $alternate_vat_text = $incl_vat_text; 349 } 371 $vat_text = $this->get_vat_text( $shop_prices_include_tax ); 372 $alternate_vat_text = $this->get_alternate_vat_text( $shop_prices_include_tax ); 350 373 351 374 // Get current suffix (may be empty) … … 367 390 * 368 391 * @param bool $loadDynamically Current dynamic loading state. 392 * 369 393 * @return bool Always true to force dynamic price loading. 370 394 * @since 1.6.0 371 395 */ 372 public function enable_ajax_search_for_woocommerce_dynamic_prices( $loadDynamically){396 public function enable_ajax_search_for_woocommerce_dynamic_prices( $loadDynamically ) { 373 397 return true; 374 398 } … … 405 429 * Wrap YITH Role Based Prices suffix with alternate tax display. 406 430 * 407 * @param string $suffix Existing suffix HTML.431 * @param string $suffix Existing suffix HTML. 408 432 * @param YITH_Role_Based_Prices_Product $yith_product Instance used by YITH. 409 433 * … … 418 442 if ( str_contains( $suffix, 'wts-price-wrapper' ) || str_contains( $suffix, 'wts-price-container' ) ) { 419 443 return $suffix; 420 }444 } 421 445 422 446 if ( $this->should_hide_on_current_page() ) { … … 426 450 $shop_prices_include_tax = $this->shop_displays_price_including_tax_by_default(); 427 451 428 // Get VAT text options 429 $incl_vat_text = $this->get_option_text( 'wdevs_tax_switch_incl_vat', __( 'Incl. VAT', 'tax-switch-for-woocommerce' ) ); 430 $excl_vat_text = $this->get_option_text( 'wdevs_tax_switch_excl_vat', __( 'Excl. VAT', 'tax-switch-for-woocommerce' ) ); 431 432 if ( $shop_prices_include_tax ) { 433 $vat_text = $incl_vat_text; 434 $alternate_vat_text = $excl_vat_text; 435 } else { 436 $vat_text = $excl_vat_text; 437 $alternate_vat_text = $incl_vat_text; 438 } 452 $vat_text = $this->get_vat_text( $shop_prices_include_tax ); 453 $alternate_vat_text = $this->get_alternate_vat_text( $shop_prices_include_tax ); 439 454 440 455 $html = $this->wrap_price_displays( '', $shop_prices_include_tax, $vat_text, $alternate_vat_text ); -
tax-switch-for-woocommerce/trunk/includes/trait-wdevs-tax-switch-helper.php
r3405724 r3447052 447 447 } 448 448 449 /** 450 * Get the label for the current VAT display status. 451 * 452 * @param bool $shop_prices_include_tax Whether the shop shows prices including tax. 453 * @return string 454 * @since 1.6.7 455 */ 456 public function get_vat_text($shop_prices_include_tax){ 457 if ( $shop_prices_include_tax ) { 458 return $this->get_option_text( 'wdevs_tax_switch_incl_vat', __( 'Incl. VAT', 'tax-switch-for-woocommerce' ) ); 459 } 460 461 return $this->get_option_text( 'wdevs_tax_switch_excl_vat', __( 'Excl. VAT', 'tax-switch-for-woocommerce' ) ); 462 } 463 464 /** 465 * Get the label for the alternate VAT display. 466 * 467 * @param bool $shop_prices_include_tax Whether the shop shows prices including tax. 468 * @return string 469 * @since 1.6.7 470 */ 471 public function get_alternate_vat_text($shop_prices_include_tax){ 472 $shop_prices_exclude_tax = !$shop_prices_include_tax; 473 return $this->get_vat_text($shop_prices_exclude_tax); 474 } 475 449 476 } -
tax-switch-for-woocommerce/trunk/public/class-wdevs-tax-switch-public.php
r3425544 r3447052 160 160 161 161 // Get VAT text options 162 $incl_vat_text = $this->get_option_text( 'wdevs_tax_switch_incl_vat', __( 'Incl. VAT', 'tax-switch-for-woocommerce' ) ); 163 $excl_vat_text = $this->get_option_text( 'wdevs_tax_switch_excl_vat', __( 'Excl. VAT', 'tax-switch-for-woocommerce' ) ); 164 165 if ( $shop_prices_include_tax ) { 166 $vat_text = $incl_vat_text; 167 $alternate_vat_text = $excl_vat_text; 168 } else { 169 $vat_text = $excl_vat_text; 170 $alternate_vat_text = $incl_vat_text; 171 } 162 $vat_text = $this->get_vat_text($shop_prices_include_tax); 163 $alternate_vat_text = $this->get_alternate_vat_text($shop_prices_include_tax); 172 164 173 165 //Re-enable this filter and function -
tax-switch-for-woocommerce/trunk/wdevs-tax-switch.php
r3444713 r3447052 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. 619 * Version: 1.6.7 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. 6' );43 define( 'WDEVS_TAX_SWITCH_VERSION', '1.6.7' ); 44 44 45 45 /**
Note: See TracChangeset
for help on using the changeset viewer.