PageSourceSearch

https://www.starrett.co.uk/wp-content/plugins/woocommerce-tax/assets/js/wcvat.js?ver=100

js starrett.co.uk collected 2026-10-04 23:17:54 UTC 5,154 bytes, 122 lines download raw bytes

1jQuery(window).load(function ($) {
2    // Code here will be executed on document ready. Use $ as normal.
3
4    jQuery(function ($) {
5
6        // Vars
7        var showTaxVar;
8        currentCurrency = $(".active").attr("data-currencycode");
9
10        if (Cookies.get('woocommerce_show_tax') === undefined || Cookies.get('woocommerce_show_tax') === null) {
11
12            console.log('WC Tax JS Loaded');
13
14            if (woocommerce_tax_display_shop == 'incl') {
15                showTaxVar = 'true';
16            } else {
17                showTaxVar = 'false';
18            }
19
20            Cookies.set('woocommerce_show_tax', showTaxVar, {
21                expires: 7,
22                path: '/'
23            });
24        } else {
25            showTaxVar = Cookies.get('woocommerce_show_tax');
26        }
27
28        //convert string into Boolean
29        showTaxVar === "true" ? showTaxVar = true : showTaxVar = false;
30        showTaxVar === true ? $("#wcvat-toggle.wcvat-toggle-product").toggleClass("on") : $("#wcvat-toggle.wcvat-toggle-product").toggleClass("");
31        showTaxVar === true ? $("body:not(.woocommerce-cart) .switch .slider").toggleClass("on") : $("body:not(.woocommerce-cart) .switch .slider").toggleClass("");
32        showTaxVar === true ? $("#wcvat-toggle.wcvat-toggle-cart").toggleClass("on") : $("#wcvat-toggle.wcvat-toggle-cart").toggleClass("");
33        showTaxVar === true ? $("body.woocommerce-cart .switch .slider").toggleClass("on") : $("body.woocommerce-cart .switch .slider").toggleClass("");
34
35        if (showTaxVar === true) {
36            showTax();
37            $('.cart_totals  .tax-rate').show();
38            $('.cart_totals  .order-total').show();
39        }
40
41
42        $("#wcvat-toggle.wcvat-toggle-cart, body.woocommerce-cart .switch .slider").click(function () {
43            showTaxVar = !showTaxVar;
44            Cookies.set('woocommerce_show_tax', showTaxVar, {
45                expires: 7,
46                path: '/'
47            });
48            $('.cart_totals  .tax-rate').toggle();
49            $('.cart_totals  .tax-total').toggle();
50            $('.cart_totals  .order-total').toggle();
51            showTaxVar === true ? $('#wcvat-toggle.wcvat-toggle-cart').toggleClass("on") : $('#wcvat-toggle.wcvat-toggle-cart').toggleClass("on");
52            showTaxVar === true ? $('body.woocommerce-cart .switch .slider').toggleClass("on") : $('body.woocommerce-cart .switch .slider').toggleClass("on");
53        });
54
55        $("#wcvat-toggle.wcvat-toggle-product, body:not(.woocommerce-cart) .switch .slider").click(function () {
56            showTaxVar = !showTaxVar;
57            Cookies.set('woocommerce_show_tax', showTaxVar, {
58                expires: 7,
59                path: '/'
60            });
61            $('.product-tax').toggle();
62            showTaxVar === true ? $('#wcvat-toggle.wcvat-toggle-product').toggleClass("on") : $('#wcvat-toggle.wcvat-toggle-product').toggleClass("on");
63            showTaxVar === true ? $('body:not(.woocommerce-cart) .switch .slider').toggleClass("on") : $('body:not(.woocommerce-cart) .switch .slider').toggleClass("on");
64        });
65
66        $('.currency_switcher a').click(function () {
67            setTimeout(function () {}, 0);
68        });
69
70        $(document).ajaxComplete(function () {
71            if (showTaxVar === true) {
72                showTax();
73
74                $('.cart_totals  .tax-rate').show();
75                $('.cart_totals  .tax-total').show();
76                $('.cart_totals  .order-total').show();
77            }
78        });
79
80        $('body').on('wc_fragments_loaded wc_fragments_refreshed', function () {
81            setTimeout(function () {
82                $('ul.currency_switcher li a.active').trigger('click');
83            }, 0);
84        });
85
86        // Hook to the show_variation trigger and append the tax to the price
87        // right after the price is appended and displayed
88        $('.variations_form').on('show_variation', function (matching_variations) {
89            setTimeout(function () {
90                setTaxOnVariationPrice();
91            }, 0);
92        });
93
94        /*
95         * Append the Tax excl/incl only for the variations price.
96         * The Variations price is removed and added for every selection, so this check needs to be done.
97         */
98        function setTaxOnVariationPrice() {
99            display = $(".single_variation span.price .product-tax-on").css("display");
100
101            if (showTaxVar === true) {
102                if (display === "none") {
103                    $(".single_variation span.price .product-tax-off").css("display", "none");
104                    $(".single_variation span.price .product-tax-on").css("display", "inline");
105                }
106            }
107        }
108
109        function showTax() {
110            $(".product-tax").each(function (index, product) {
111                if ($($(".product-tax-on")[index]).css("display") === "none") {
112                    //toggle didn't work here - manual implementation
113                    $($(".product-tax-off")[index]).css("display", "none");
114                    $($(".product-tax-on")[index]).css("display", "inline");
115                }
116            });
117        }
118
119    });
120
121
122});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.