Plugin Directory

Changeset 3367825


Ignore:
Timestamp:
09/25/2025 12:35:59 PM (6 months ago)
Author:
wijnbergdevelopments
Message:

Improved compatibility for Measurement Price Calculator for WooCommerce

Location:
tax-switch-for-woocommerce
Files:
98 added
9 edited

Legend:

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

    r3363906 r3367825  
    44Requires at least: 5.0
    55Tested up to: 6.8
    6 Stable tag: 1.5.15
     6Stable tag: 1.5.16
    77Requires PHP: 7.2
    88License: GPL-2.0+
     
    233233
    234234== Changelog ==
     235= 1.5.16 =
     236- Improved compatibility for Measurement Price Calculator for WooCommerce
     237
    235238= 1.5.15 =
    236239* Ignore zero tax price check if customer is vat exempt
  • tax-switch-for-woocommerce/trunk/build/label/block.json

    r3363906 r3367825  
    33  "apiVersion": 3,
    44  "name": "wdevs/tax-switch-label",
    5   "version": "1.5.15",
     5  "version": "1.5.16",
    66  "title": "Tax Switch text label",
    77  "category": "woocommerce",
  • tax-switch-for-woocommerce/trunk/build/shared/shared.asset.php

    r3335801 r3367825  
    1 <?php return array('dependencies' => array(), 'version' => '24f116663efc3b8045d8');
     1<?php return array('dependencies' => array(), 'version' => '727a2f70b8f53db5a3f5');
  • tax-switch-for-woocommerce/trunk/build/shared/shared.js

    r3335801 r3367825  
    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),l=s(75),a=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,l.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,l.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,a.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,a.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,{WJ:()=>d,ir:()=>o,rj:()=>h});var i=s(143);const c="wdevs_tax_switch_is_switched",n="wdevs-tax-switch/store",l="SET_IS_SWITCHED",a={setIsSwitched:t=>({type:l,value:t}),saveIsSwitched:t=>(localStorage.setItem(c,JSON.stringify(t)),{type:l,value:t})};let r=(0,i.select)(n);function o(){return(0,i.select)(n).getIsSwitched()}function h(t){return(0,i.dispatch)(n).saveIsSwitched(t)}function d(t){return(0,i.dispatch)(n).setIsSwitched(t)}void 0===r&&(r=(0,i.createReduxStore)(n,{reducer:(t=(()=>{const t=localStorage.getItem(c);return{isSwitched:!!t&&JSON.parse(t)}})(),e)=>e.type===l?{...t,isSwitched:e.value}:t,actions:a,selectors:{getIsSwitched:t=>t.isSwitched}}),(0,i.register)(r))},159:(t,e,s)=>{s.d(e,{A:()=>c});var i=s(75);const c=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))}}},538:(t,e,s)=>{function i(){return!(window.wtsViewObject||{checkPriceElements:!1}).checkPriceElements||document.querySelectorAll(".wts-price-wrapper").length>0}s.d(e,{I:()=>i})},651:(t,e,s)=>{s.d(e,{A:()=>i});const i=/^([29]02|38|657|733|793)$/.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,l=c.excluding;function a(t){return t?"wts-active":"wts-inactive"}function r(e,s){return`\n         <span class="wts-price-${s?"incl":"excl"} ${a(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(l,!1)}\n         </span>\n   `;if(i){function h(e,s){return`\n            <span class="wts-price-${s?"incl":"excl"} ${a(s===t)}">\n               ${e}\n            </span>\n         `}o+=`\n         <span class="wts-price-wrapper">\n            ${h(i.including,!0)}\n            ${h(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 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:()=>o});var i=s(87),c=s(143),n=s(159),l=s(75),a=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.handleChange=this.handleChange.bind(this),this.unsubscribe=(0,c.subscribe)((()=>{const t=(0,l.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,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 n.A.displayIncludingVat(t,e)}togglePriceClasses(){const{originalTaxDisplay:t="incl"}=this.props,{isSwitched:e}=this.state;return n.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:c,switchLabelIncl:n,switchLabelExcl:l}=this.props,r=this.displayIncludingVat();return(0,a.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,a.jsx)("button",{type:"button",className:"wdevs-tax-button "+(r?"wdevs-tax-button-active":""),onClick:()=>{r||this.handleChange()},children:n||"Incl. VAT"}),(0,a.jsx)("button",{type:"button",className:"wdevs-tax-button "+(r?"":"wdevs-tax-button-active"),onClick:()=>{r&&this.handleChange()},children:l||"Excl. VAT"})]})}renderToggleSwitch(){const{switchColor:t,switchColorChecked:e,switchBackgroundColor:s,switchBackgroundColorChecked:i,switchTextColor:c,switchLabelIncl:n,switchLabelExcl:l}=this.props,r=this.displayIncludingVat(),o=n||l;return(0,a.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,a.jsxs)("label",{className:"wdevs-tax-switch-label",children:[(0,a.jsx)("input",{type:"checkbox",name:"wdevs-tax-switch-checkbox",onChange:this.handleChange,checked:r,className:"wdevs-tax-switch-checkbox"}),(0,a.jsx)("span",{className:"wdevs-tax-switch-slider"})]}),o&&(0,a.jsx)("span",{className:"wdevs-tax-switch-label-text",onClick: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),c=s(143),n=s(159),l=s(75),a=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,l.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,l.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,a.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,a.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,{WJ:()=>d,ir:()=>o,rj:()=>h});var i=s(143);const c="wdevs_tax_switch_is_switched",n="wdevs-tax-switch/store",l="SET_IS_SWITCHED",a={setIsSwitched:t=>({type:l,value:t}),saveIsSwitched:t=>(localStorage.setItem(c,JSON.stringify(t)),{type:l,value:t})};let r=(0,i.select)(n);function o(){return(0,i.select)(n).getIsSwitched()}function h(t){return(0,i.dispatch)(n).saveIsSwitched(t)}function d(t){return(0,i.dispatch)(n).setIsSwitched(t)}void 0===r&&(r=(0,i.createReduxStore)(n,{reducer:(t=(()=>{const t=localStorage.getItem(c);return{isSwitched:!!t&&JSON.parse(t)}})(),e)=>e.type===l?{...t,isSwitched:e.value}:t,actions:a,selectors:{getIsSwitched:t=>t.isSwitched}}),(0,i.register)(r))},159:(t,e,s)=>{s.d(e,{A:()=>c});var i=s(75);const c=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))}}},538:(t,e,s)=>{function i(){return!(window.wtsViewObject||{checkPriceElements:!1}).checkPriceElements||document.querySelectorAll(".wts-price-wrapper").length>0}s.d(e,{I:()=>i})},651:(t,e,s)=>{s.d(e,{A:()=>i});const i=/^(202|38|657|733|793)$/.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,l=c.excluding;function a(t){return t?"wts-active":"wts-inactive"}function r(e,s){return`\n         <span class="wts-price-${s?"incl":"excl"} ${a(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(l,!1)}\n         </span>\n   `;if(i){function h(e,s){return`\n            <span class="wts-price-${s?"incl":"excl"} ${a(s===t)}">\n               ${e}\n            </span>\n         `}o+=`\n         <span class="wts-price-wrapper">\n            ${h(i.including,!0)}\n            ${h(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 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:()=>o});var i=s(87),c=s(143),n=s(159),l=s(75),a=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.handleChange=this.handleChange.bind(this),this.unsubscribe=(0,c.subscribe)((()=>{const t=(0,l.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,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 n.A.displayIncludingVat(t,e)}togglePriceClasses(){const{originalTaxDisplay:t="incl"}=this.props,{isSwitched:e}=this.state;return n.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:c,switchLabelIncl:n,switchLabelExcl:l}=this.props,r=this.displayIncludingVat();return(0,a.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,a.jsx)("button",{type:"button",className:"wdevs-tax-button "+(r?"wdevs-tax-button-active":""),onClick:()=>{r||this.handleChange()},children:n||"Incl. VAT"}),(0,a.jsx)("button",{type:"button",className:"wdevs-tax-button "+(r?"":"wdevs-tax-button-active"),onClick:()=>{r&&this.handleChange()},children:l||"Excl. VAT"})]})}renderToggleSwitch(){const{switchColor:t,switchColorChecked:e,switchBackgroundColor:s,switchBackgroundColorChecked:i,switchTextColor:c,switchLabelIncl:n,switchLabelExcl:l}=this.props,r=this.displayIncludingVat(),o=n||l;return(0,a.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,a.jsxs)("label",{className:"wdevs-tax-switch-label",children:[(0,a.jsx)("input",{type:"checkbox",name:"wdevs-tax-switch-checkbox",onChange:this.handleChange,checked:r,className:"wdevs-tax-switch-checkbox"}),(0,a.jsx)("span",{className:"wdevs-tax-switch-slider"})]}),o&&(0,a.jsx)("span",{className:"wdevs-tax-switch-label-text",onClick: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

    r3363906 r3367825  
    33  "apiVersion": 3,
    44  "name": "wdevs/tax-switch",
    5   "version": "1.5.15",
     5  "version": "1.5.16",
    66  "title": "Tax Switch for WooCommerce",
    77  "category": "woocommerce",
  • tax-switch-for-woocommerce/trunk/build/switch/woocommerce-measurement-price-calculator.asset.php

    r3300428 r3367825  
    1 <?php return array('dependencies' => array('jquery', 'wp-data'), 'version' => 'c0938aa0e3c7e25639ff');
     1<?php return array('dependencies' => array('jquery', 'wp-data'), 'version' => 'b6d912d9555198d657d4');
  • tax-switch-for-woocommerce/trunk/build/switch/woocommerce-measurement-price-calculator.js

    r3300428 r3367825  
    1 (()=>{"use strict";var i,r={143:i=>{i.exports=window.wp.data},741:(i,r,t)=>{var e=t(159);const n=window.jQuery;var a=t.n(n),c=t(143);const s=class{constructor(i){this.isSwitched=!1,this.unsubscribe=null,this.originalTaxDisplay=i,this.currentVariation=null}init(){const i=this;i.unsubscribe=(0,c.subscribe)((()=>{const r=(0,c.select)("wdevs-tax-switch/store").getIsSwitched();i.isSwitched!==r&&(i.isSwitched=r,i.handleSwitchChange())})),i.registerWooCommerceEvents()}registerWooCommerceEvents(){const i=this;a()(".single_variation, .single_variation_wrap").bind("show_variation",(function(r,t){setTimeout((function(){if(i.currentVariation=t,window.wc_price_calculator_params){const r=i.getCurrentPrice();window.wc_price_calculator_params.product_price=r,t.price=r,a()(".qty").trigger("change")}}),500)}))}handleSwitchChange(){if(window.wc_price_calculator_params){const i=this.getCurrentPrice();i&&(window.wc_price_calculator_params.product_price=i,a()(".qty").trigger("change"))}}getCurrentPrice(){return this.currentVariation&&this.currentVariation.price_incl_vat&&this.currentVariation.price_excl_vat?e.A.displayIncludingVat(this.originalTaxDisplay)?parseFloat(this.currentVariation.price_incl_vat):parseFloat(this.currentVariation.price_excl_vat):null}cleanup(){this.unsubscribe&&this.unsubscribe()}};window.addEventListener("DOMContentLoaded",(()=>{const i=window.wtsViewObject||{originalTaxDisplay:"incl"};new s(i.originalTaxDisplay).init()}))}},t={};function e(i){var n=t[i];if(void 0!==n)return n.exports;var a=t[i]={exports:{}};return r[i](a,a.exports,e),a.exports}e.m=r,i=[],e.O=(r,t,n,a)=>{if(!t){var c=1/0;for(u=0;u<i.length;u++){for(var[t,n,a]=i[u],s=!0,o=0;o<t.length;o++)(!1&a||c>=a)&&Object.keys(e.O).every((i=>e.O[i](t[o])))?t.splice(o--,1):(s=!1,a<c&&(c=a));if(s){i.splice(u--,1);var l=n();void 0!==l&&(r=l)}}return r}a=a||0;for(var u=i.length;u>0&&i[u-1][2]>a;u--)i[u]=i[u-1];i[u]=[t,n,a]},e.n=i=>{var r=i&&i.__esModule?()=>i.default:()=>i;return e.d(r,{a:r}),r},e.d=(i,r)=>{for(var t in r)e.o(r,t)&&!e.o(i,t)&&Object.defineProperty(i,t,{enumerable:!0,get:r[t]})},e.o=(i,r)=>Object.prototype.hasOwnProperty.call(i,r),e.j=902,(()=>{var i={902:0};e.O.j=r=>0===i[r];var r=(r,t)=>{var n,a,[c,s,o]=t,l=0;if(c.some((r=>0!==i[r]))){for(n in s)e.o(s,n)&&(e.m[n]=s[n]);if(o)var u=o(e)}for(r&&r(t);l<c.length;l++)a=c[l],e.o(i,a)&&i[a]&&i[a][0](),i[a]=0;return e.O(u)},t=globalThis.webpackChunkwdevs_tax_switch=globalThis.webpackChunkwdevs_tax_switch||[];t.forEach(r.bind(null,0)),t.push=r.bind(null,t.push.bind(t))})();var n=e.O(void 0,[320],(()=>e(741)));n=e.O(n)})();
     1(()=>{"use strict";var e,t={143:e=>{e.exports=window.wp.data},741:(e,t,r)=>{var a=r(159),i=r(651);const c=window.jQuery;var n=r.n(c),o=r(143);const s=class{constructor(e,t){this.isSwitched=!1,this.unsubscribe=null,this.originalTaxDisplay=e,this.taxRate=t,this.currentVariation=null,this.taxSwitchElementBuilder=new i.A(this.originalTaxDisplay)}init(){const e=this;e.unsubscribe=(0,o.subscribe)((()=>{const t=(0,o.select)("wdevs-tax-switch/store").getIsSwitched();e.isSwitched!==t&&(e.isSwitched=t,e.handleSwitchChange())})),e.registerWooCommerceEvents(),e.registerWCMeasurementEvents()}registerWooCommerceEvents(){const e=this;n()(".single_variation, .single_variation_wrap").bind("show_variation",(function(t,r){setTimeout((function(){if(e.currentVariation=r,r&&r.tax_rate&&(e.taxRate=r.tax_rate),window.wc_price_calculator_params){const t=e.getCurrentPrice();window.wc_price_calculator_params.product_price=t,r.price=t,n()(".qty").trigger("change")}}),500)}))}handleSwitchChange(){if(window.wc_price_calculator_params){const e=this.getCurrentPrice();e&&(window.wc_price_calculator_params.product_price=e,n()(".qty").trigger("change"))}}registerWCMeasurementEvents(){const e=this;n()(document).on("wc-measurement-price-calculator-total-price-change",(function(t,r,a){if(r&&a){const t=r*a;e.handleTotalPriceUpdate(t)}})),n()(document).on("wc-measurement-price-calculator-quantity-total-price-change",(function(t,r,a){if(r&&a){const t=r*a;e.handleTotalPriceUpdate(t)}}))}handleTotalPriceUpdate(e){if(!e||!this.taxRate)return;const t=a.A.calculateAlternatePrice(e,this.originalTaxDisplay,this.taxRate),r=this.woocommerce_price(e),i=this.woocommerce_price(t);this.replaceTotalPriceDisplay(r,i)}replaceTotalPriceDisplay(e,t){const r=n()(".total_price");if(r.length){const i=a.A.displayIncludingVat(this.originalTaxDisplay),c=this.taxSwitchElementBuilder.build(i,e,t);r.html(c)}}getCurrentPrice(){return this.currentVariation&&this.currentVariation.price_incl_vat&&this.currentVariation.price_excl_vat?a.A.displayIncludingVat(this.originalTaxDisplay)?parseFloat(this.currentVariation.price_incl_vat):parseFloat(this.currentVariation.price_excl_vat):null}cleanup(){this.unsubscribe&&this.unsubscribe()}woocommerce_price(e){let t="";const r=window.wc_price_calculator_params.woocommerce_price_num_decimals,a=window.wc_price_calculator_params.woocommerce_currency_pos,i=window.wc_price_calculator_params.woocommerce_currency_symbol;switch(e=this.number_format(e,r,window.wc_price_calculator_params.woocommerce_price_decimal_sep,window.wc_price_calculator_params.woocommerce_price_thousand_sep),"yes"===window.wc_price_calculator_params.woocommerce_price_trim_zeros&&r>0&&(e=this.woocommerce_trim_zeros(e)),a){case"left":t='<span class="amount">'+i+e+"</span>";break;case"right":t='<span class="amount">'+e+i+"</span>";break;case"left_space":t='<span class="amount">'+i+"&nbsp;"+e+"</span>";break;case"right_space":t='<span class="amount">'+e+"&nbsp;"+i+"</span>"}return t}woocommerce_trim_zeros(e){return e.replace(new RegExp(this.preg_quote(window.wc_price_calculator_params.woocommerce_price_decimal_sep,"/")+"0+$"),"")}number_format(e,t,r,a){e=(e+"").replace(/[^0-9+\-Ee.]/g,"");const i=isFinite(+e)?+e:0,c=isFinite(+t)?Math.abs(t):0,n=void 0===a?",":a,o=void 0===r?".":r;let s="";return s=new BigNumber(i).toFixed(c).split("."),s[0].length>3&&(s[0]=s[0].replace(/\B(?=(?:\d{3})+(?!\d))/g,n)),(s[1]||"").length<c&&(s[1]=s[1]||"",s[1]+=new Array(c-s[1].length+1).join("0")),s.join(o)}preg_quote(e,t){return(e+"").replace(new RegExp("[.\\\\+*?\\[\\^\\]$(){}=!<>|:\\\\"+(t||"")+"-]","g"),"\\$&")}};window.addEventListener("DOMContentLoaded",(()=>{const e=window.wtsViewObject||{originalTaxDisplay:"incl"},t=window.wtsCompatibilityObject||{baseTaxRate:0};new s(e.originalTaxDisplay,t.baseTaxRate).init()}))}},r={};function a(e){var i=r[e];if(void 0!==i)return i.exports;var c=r[e]={exports:{}};return t[e](c,c.exports,a),c.exports}a.m=t,e=[],a.O=(t,r,i,c)=>{if(!r){var n=1/0;for(p=0;p<e.length;p++){for(var[r,i,c]=e[p],o=!0,s=0;s<r.length;s++)(!1&c||n>=c)&&Object.keys(a.O).every((e=>a.O[e](r[s])))?r.splice(s--,1):(o=!1,c<n&&(n=c));if(o){e.splice(p--,1);var l=i();void 0!==l&&(t=l)}}return t}c=c||0;for(var p=e.length;p>0&&e[p-1][2]>c;p--)e[p]=e[p-1];e[p]=[r,i,c]},a.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return a.d(t,{a:t}),t},a.d=(e,t)=>{for(var r in t)a.o(t,r)&&!a.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},a.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),a.j=902,(()=>{var e={902:0};a.O.j=t=>0===e[t];var t=(t,r)=>{var i,c,[n,o,s]=r,l=0;if(n.some((t=>0!==e[t]))){for(i in o)a.o(o,i)&&(a.m[i]=o[i]);if(s)var p=s(a)}for(t&&t(r);l<n.length;l++)c=n[l],a.o(e,c)&&e[c]&&e[c][0](),e[c]=0;return a.O(p)},r=globalThis.webpackChunkwdevs_tax_switch=globalThis.webpackChunkwdevs_tax_switch||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var i=a.O(void 0,[320],(()=>a(741)));i=a.O(i)})();
  • tax-switch-for-woocommerce/trunk/includes/class-wdevs-tax-switch-compatibility.php

    r3348796 r3367825  
    5858    public function enqueue_compatibility_scripts() {
    5959        if ( is_product() ) {
     60            $tax_rate = $this->get_product_tax_rate( wc_get_product() );
     61
    6062            // WooCommerce Measurement Price Calculator
    6163            if ( $this->is_plugin_active( 'woocommerce-measurement-price-calculator/woocommerce-measurement-price-calculator.php' ) ) {
    6264                $wmpc_handle = 'wdevs-tax-switch-woocommerce-measurement-price-calculator';
    63                 $this->enqueue_script($wmpc_handle, 'switch', 'woocommerce-measurement-price-calculator');
    64             }
    65 
    66             $tax_rate = $this->get_product_tax_rate( wc_get_product() );
     65                $wmpc_asset = $this->enqueue_script($wmpc_handle, 'switch', 'woocommerce-measurement-price-calculator');
     66
     67                wp_localize_script(
     68                    $wmpc_handle,
     69                    'wtsCompatibilityObject',
     70                    [ 'baseTaxRate' => $tax_rate ]
     71                );
     72            }
    6773
    6874            // YITH WooCommerce Product Add-Ons (both free and premium)
  • tax-switch-for-woocommerce/trunk/wdevs-tax-switch.php

    r3363906 r3367825  
    1717 * Plugin URI:           https://wijnberg.dev
    1818 * Description:          Let customers toggle between inclusive and exclusive VAT pricing in your WooCommerce store.
    19  * Version:              1.5.15
     19 * Version:              1.5.16
    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.5.15' );
     43define( 'WDEVS_TAX_SWITCH_VERSION', '1.5.16' );
    4444
    4545/**
Note: See TracChangeset for help on using the changeset viewer.