PageSourceSearch

https://www.shox.sk/wp-content/themes/shox/scripts/woocommerce.js

js shox.sk collected 2026-10-08 20:50:36 UTC 3,597 bytes, 134 lines download raw bytes

1// Scope global vars
2window.woocommerce = window.woocommerce || {};
3
4(function ($, woocommerce) {
5
6    'use strict';
7
8    woocommerce = woocommerce || {};
9
10    /**
11     * addToCart
12     *
13     * Add product to cart
14     *
15     * @param container HTML element of the add to cart form
16     */
17    //woocommerce.addToCart = function (form) {
18    //    var formData = $(form).serialize();
19    //    formData += '&action=add_to_cart';
20    //
21    //    $.ajax({
22    //        url: woocommerce.wp.ajaxURL,
23    //        type: 'POST',
24    //        data: formData,
25    //        dataType: 'json',
26    //        success: function (data) {
27    //            if (data.success === true) {
28    //                woocommerce.updateMiniCart(data);
29    //            }
30    //            woocommerce.showPopup(data.message);
31    //        },
32    //        error: function () {
33    //
34    //        },
35    //        complete: function () {
36    //        }
37    //    });
38    //    return false;
39    //};
40
41    /**
42     * updateCartProductCount
43     *
44     * Update cart
45     *
46     * @param input HTML element of the input number element
47     */
48    woocommerce.updateCartProductCount = function (input) {
49        var form = $(input).parents('form').first(),
50            productID = parseInt($(input).data('product-id'), 10),
51            formData = 'product_id=' + productID + '&action=update_cart_product_count';
52
53        $.ajax({
54            url: woocommerce.wp.ajaxURL,
55            type: 'POST',
56            data: formData,
57            dataType: 'json',
58            success: function (data) {
59                if (data.success === true) {
60                    woocommerce.updateMiniCart(data);
61                }
62                woocommerce.showPopup(data.message);
63            },
64            error: function () {
65
66            },
67            complete: function () {
68            }
69        });
70        return false;
71    };
72
73    /**
74     * updateMiniCart
75     *
76     * Update mini cart widget
77     *
78     * @param data Data returned from AJAX call
79     */
80    woocommerce.updateMiniCart = function (data) {
81        if ($('#shop-basket').length && data) {
82          $('#shop-basket .purchase .price').html(data.subtotal);
83          $('#shop-basket .purchase .count').html(data.count);
84        }
85    };
86
87    /**
88     * showPopup
89     *
90     * Show popup
91     *
92     * @param data Data returned from AJAX call
93     */
94    woocommerce.showPopup = function (data) {
95        if (data && window.swal) {
96            swal({
97                title: data.title,
98                text: data.text,
99                type: data.type,
100                allowOutsideClick: true,
101                showCancelButton: false,
102                showConfirmButton: false,
103                customClass: 'woocommerce-popup ' + data.type
104            });
105            window.setTimeout(function(){
106                swal.close();
107            }, 2500)
108        }
109    };
110
111    woocommerce.wp = {};
112    if (typeof woocommerceGlobals !== 'undefined') {
113        woocommerce.wp.ajaxURL = woocommerceGlobals.ajaxURL;
114    } else {
115        woocommerce.wp.ajaxURL = '/';
116    }
117
118    //$(document).on({
119    //    click: function () {
120    //        var form = $(this)[0].form;
121    //        woocommerce.addToCart(form);
122    //        return false;
123    //    }
124    //}, 'form.product-filter .button-cart');
125
126    // $(document).on({
127    //     change: function () {
128    //         var input = this;
129    //         woocommerce.updateCartProductCount(input);
130    //         return false;
131    //     }
132    // }, 'form.order input[type="number"]');
133
134})(jQuery, window.woocommerce);

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.