Plugin Directory

Changeset 3447052


Ignore:
Timestamp:
01/26/2026 11:34:14 AM (2 months ago)
Author:
wijnbergdevelopments
Message:
  • Added compatibility for WooCommerce Dynamic Pricing and Discount Rules
Location:
tax-switch-for-woocommerce
Files:
106 added
9 edited

Legend:

Unmodified
Added
Removed
  • tax-switch-for-woocommerce/trunk/README.txt

    r3444713 r3447052  
    44Requires at least: 5.0
    55Tested up to: 6.9
    6 Stable tag: 1.6.6
     6Stable tag: 1.6.7
    77Requires PHP: 7.2
    88License: GPL-2.0+
     
    206206* Elementor Pro
    207207* YITH WooCommerce Role Based Prices
     208* WooCommerce Dynamic Pricing and Discount Rules
    208209
    209210If 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.
     
    242243
    243244== Changelog ==
     245= 1.6.7 =
     246* Added compatibility for WooCommerce Dynamic Pricing and Discount Rules
     247
    244248= 1.6.6 =
    245249* Improved switch accessibility and mobile UX
  • tax-switch-for-woocommerce/trunk/build/label/block.json

    r3425544 r3447052  
    33  "apiVersion": 3,
    44  "name": "wdevs/tax-switch-label",
    5   "version": "1.6.5",
     5  "version": "1.6.7",
    66  "title": "Tax Switch text label",
    77  "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  
    33  "apiVersion": 3,
    44  "name": "wdevs/tax-switch",
    5   "version": "1.6.5",
     5  "version": "1.6.7",
    66  "title": "Tax Switch for WooCommerce",
    77  "category": "woocommerce",
  • tax-switch-for-woocommerce/trunk/includes/class-wdevs-tax-switch-compatibility.php

    r3417485 r3447052  
    6363            if ( $this->is_plugin_active( 'woocommerce-measurement-price-calculator/woocommerce-measurement-price-calculator.php' ) ) {
    6464                $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' );
    6666
    6767                wp_localize_script(
     
    7878            ] ) ) {
    7979                $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' ] );
    8181
    8282                wp_localize_script(
     
    9090            if ( $this->is_plugin_active( 'woocommerce-product-addons/woocommerce-product-addons.php' ) ) {
    9191                $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' ] );
    9393
    9494                wp_localize_script(
     
    102102            if ( $this->is_plugin_active( 'advanced-product-fields-for-woocommerce-pro/advanced-product-fields-for-woocommerce-pro.php' ) ) {
    103103                $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                ] );
    105108            }
    106109
     
    108111            if ( $this->is_plugin_active( 'woocommerce-quantity-manager-pro/woocommerce-quantity-manager-pro.php' ) ) {
    109112                $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' ] );
    111114
    112115                wp_localize_script(
     
    119122            // Product Extras for Woocommerce (Woocommerce Product Add-Ons Ultimate)
    120123            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....
    123126
    124127                wp_localize_script(
    125128                    $pewc_handle,
    126129                    '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                    ]
    128135                );
    129136            }
    130137
    131138            //Kapee theme
    132             if($this->is_theme_active('Kapee')){
     139            if ( $this->is_theme_active( 'Kapee' ) ) {
    133140                $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                ] );
    135145
    136146                wp_localize_script(
     
    144154            if ( $this->is_plugin_active( 'woocommerce-tm-extra-product-options/tm-woo-extra-product-options.php' ) ) {
    145155                $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' ] );
    147157
    148158                wp_localize_script(
     
    150160                    'wtsCompatibilityObject',
    151161                    [ '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                    ]
    152183                );
    153184            }
     
    160191        ] ) ) {
    161192            $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' );
    163194        }
    164195
     
    166197        if ( $this->is_plugin_active( 'fibofilters-pro/fibofilters.php' ) ) {
    167198            $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' ] );
    169200        }
    170201
     
    172203        if ( $this->is_theme_active( 'woodmart' ) ) {
    173204            $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' );
    175206        }
    176207
     
    178209        if ( $this->is_plugin_active( 'facetwp/index.php' ) ) {
    179210            $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' );
    181212
    182213            // Estimate tax rate for FacetWP (no specific product context available)
     
    260291     * @since 1.5.5
    261292     */
    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 ) {
    264295            return $original_output;
    265296        }
     
    298329     * @since 1.5.11
    299330     */
    300     public function kses_allow_span_classes_for_prices($tags, $context ){
     331    public function kses_allow_span_classes_for_prices( $tags, $context ) {
    301332        //filters and actions
    302333        $allowed_contexts = [
     
    338369
    339370        // 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 );
    350373
    351374        // Get current suffix (may be empty)
     
    367390     *
    368391     * @param bool $loadDynamically Current dynamic loading state.
     392     *
    369393     * @return bool Always true to force dynamic price loading.
    370394     * @since 1.6.0
    371395     */
    372     public function enable_ajax_search_for_woocommerce_dynamic_prices($loadDynamically){
     396    public function enable_ajax_search_for_woocommerce_dynamic_prices( $loadDynamically ) {
    373397        return true;
    374398    }
     
    405429     * Wrap YITH Role Based Prices suffix with alternate tax display.
    406430     *
    407      * @param string                         $suffix Existing suffix HTML.
     431     * @param string $suffix Existing suffix HTML.
    408432     * @param YITH_Role_Based_Prices_Product $yith_product Instance used by YITH.
    409433     *
     
    418442        if ( str_contains( $suffix, 'wts-price-wrapper' ) || str_contains( $suffix, 'wts-price-container' ) ) {
    419443            return $suffix;
    420             }
     444        }
    421445
    422446        if ( $this->should_hide_on_current_page() ) {
     
    426450        $shop_prices_include_tax = $this->shop_displays_price_including_tax_by_default();
    427451
    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 );
    439454
    440455        $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  
    447447    }
    448448
     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
    449476}
  • tax-switch-for-woocommerce/trunk/public/class-wdevs-tax-switch-public.php

    r3425544 r3447052  
    160160
    161161        // 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);
    172164
    173165        //Re-enable this filter and function
  • tax-switch-for-woocommerce/trunk/wdevs-tax-switch.php

    r3444713 r3447052  
    1717 * Plugin URI:           https://wijnberg.dev
    1818 * Description:          Let customers toggle between inclusive and exclusive VAT pricing in your WooCommerce store.
    19  * Version:              1.6.6
     19 * Version:              1.6.7
    2020 * Author:               Wijnberg Developments
    2121 * Author URI:           https://wijnberg.dev/
     
    4141 * Rename this for your plugin and update it as you release new versions.
    4242 */
    43 define( 'WDEVS_TAX_SWITCH_VERSION', '1.6.6' );
     43define( 'WDEVS_TAX_SWITCH_VERSION', '1.6.7' );
    4444
    4545/**
Note: See TracChangeset for help on using the changeset viewer.