PageSourceSearch

https://cholita.gal/wp-content/themes/ciao/assets/js/zoo-woo-ajax.js

js cholita.gal collected 2026-10-08 07:25:20 UTC 16,444 bytes, 328 lines download raw bytes

1(function ($) {
2    "use strict";
3    jQuery(document).ready(function () {
4        if (typeof wc_add_to_cart_params === 'undefined') {
5            return false;
6        }
7        /* Ajax mini cart remove and Revert item remove from cart.*/
8        $(document).on('click', '.woocommerce-mini-cart-item .remove', function (e) {
9            e.preventDefault();
10            var $thisbutton = $(this),
11                $mini_cart = $thisbutton.closest('.widget_shopping_cart_content'),
12                $cart_item = $thisbutton.closest('.woocommerce-mini-cart-item');
13            $cart_item.addClass('loading');
14            if (!$(this).hasClass('revert-cart-item')) {
15                $.post(wc_add_to_cart_params.wc_ajax_url.toString().replace('%%endpoint%%', 'remove_from_cart'), {cart_item_key: $thisbutton.data('cart_item_key')}, function (response) {
16                    if (!response || !response.fragments) {
17                        window.location = $thisbutton.attr('href');
18                        return;
19                    }
20                    $thisbutton.addClass('revert-cart-item');
21
22                    $mini_cart.find('.pre-remove').addClass('removed');
23                    $cart_item.addClass('pre-remove');
24
25                    $mini_cart.find('.woocommerce-mini-cart__total.total .woocommerce-Price-amount').replaceWith(response.fragments.cart_subtotal);
26                    $mini_cart.find('.free-shipping-required-notice').replaceWith(response.fragments.free_shipping_cart_notice);
27                    $thisbutton.closest('.widget_shopping_cart ').find('.total-cart-item').replaceWith(response.fragments['.total-cart-item']);
28
29                    setTimeout(function () {
30                        $mini_cart.find('.removed').remove();
31                    }, 500);
32                    if (response.fragments.cart_count == 0) {
33                        $mini_cart.find('.wrap-bottom-mini-cart').fadeOut();
34                        $('.element-cart-icon').addClass('cart-empty');
35                    }
36
37                    $cart_item.removeClass('loading');
38                    $(document).trigger('zoo_after_remove_product_item', {
39                        "fragments": response.fragments
40                    });
41                }).fail(function () {
42                    window.location = $thisbutton.attr('href');
43                    return;
44                });
45            } else {
46                var cart_item_key = $thisbutton.data('cart_item_key');
47                $.ajax({
48                    type: 'POST',
49                    dataType: 'json',
50                    url: wc_add_to_cart_params.ajax_url,
51                    data: {
52                        action: "restore_cart_item",
53                        cart_item_key: cart_item_key
54                    },
55                    error: function (XMLHttpRequest, textStatus, errorThrown) {
56                        console.log('AJAX Restore ' + errorThrown);
57                        console.log('AJAX Restore ' + cart_item_key);
58                    },
59                    success: function (data) {
60                        $(document).trigger('zoo_after_restore_product_item', {
61                            "fragments": data
62                        });
63                        $thisbutton.removeClass('revert-cart-item');
64
65                        $cart_item.removeClass('pre-remove');
66                        if (!$mini_cart.find('.wrap-bottom-mini-cart').is(":visible")) {
67                            $mini_cart.find('.wrap-bottom-mini-cart').fadeIn();
68                        }
69                        $('.element-cart-icon').removeClass('cart-empty');
70                        $mini_cart.find('.woocommerce-mini-cart__total.total .woocommerce-Price-amount').replaceWith(data.cart_subtotal);
71                        $mini_cart.find('.free-shipping-required-notice').replaceWith(data.free_shipping_cart_notice);
72                        $thisbutton.closest('.widget_shopping_cart ').find('.total-cart-item').replaceWith(data['.total-cart-item']);
73                        $cart_item.removeClass('loading');
74                    }
75                });
76                return false;
77            }
78        });
79
80        //Update mini top cart ajax
81        $(document).on('added_to_cart', function (event, fragments) {
82            $('.element-cart-icon').removeClass('cart-empty');
83            if($('.element-cart-icon:not(.off-canvas)')[0]||!$('.element-cart-icon')[0])
84                zoo_add_to_cart_mess(fragments['zoo_add_to_cart_message']);
85
86        });
87        $(document).on('zoo_single_product_cart_added', function (event, fragments) {
88            $('.element-cart-icon').removeClass('cart-empty');
89        });
90        /* End Ajax cart for shop loop product item*/
91
92        //Function for Add to Cart message
93        function zoo_add_to_cart_mess($zoo_mess) {
94            if (!!$zoo_mess && $zoo_mess!=undefined) {
95                if ($('#zoo-add-to-cart-message')[0]) {
96                    $('#zoo-add-to-cart-message').replaceWith($zoo_mess);
97                } else {
98                    $('body').append($zoo_mess);
99                }
100                setTimeout(function () {
101                    $('#zoo-add-to-cart-message').addClass('active');
102                }, 100);
103                setTimeout(function () {
104                    $('#zoo-add-to-cart-message').removeClass('active');
105                }, 3500);
106            }
107        }
108        //Refresh variations_form button added to cart when change option.
109        $( "form.variations_form" ).on( "woocommerce_variation_select_change", function () {
110            $(this).find('.cart-added').removeClass('cart-added');
111        } );
112
113        /* Ajax Add to Cart for Single Product */
114        $(document).on('click', 'button.single_add_to_cart_button:not(.disabled)', function (event) {
115            var $this = $(this);
116            var $productForm = $this.closest('form');
117            if ($this.hasClass('cart-added')) {
118                window.location = wc_add_to_cart_params.cart_url;
119                return false;
120            }
121            if($productForm.find('.woocommerce_gc_giftcard_form')[0]){
122                return true;
123            }
124            var max = parseInt($productForm.find('input.qty').attr('max'));
125            var qty = parseInt($productForm.find('input.qty').val());
126            if (!!max && (max < qty)) {
127                return true;
128            } else {
129                var data = {
130                    product_id: $productForm.find("*[name*='add-to-cart']").val(),
131                    product_variation_data: $productForm.serialize()
132                };
133                if (!!data.product_id) {
134                    event.preventDefault();
135                    $this.addClass('loading');
136
137                    if ($('#zoo-quickview-lb')[0]) {
138                        $('.zoo-mask-close').removeClass('mask-quick-view active loading');
139                        $('#zoo-quickview-lb').css({'top': 'calc(50% + 150px)', 'opacity': '0'});
140                        setTimeout(function () {
141                            $('#zoo-quickview-lb').remove();
142                        }, 500);
143                    }
144                    if (!$this.hasClass('zoo-buy-now')) {
145                        $('.wrap-mini-cart').addClass('loading');
146                        //Call event zoo_starting_add_to_cart
147                        $(document).trigger('zoo_starting_add_to_cart');
148                    }
149                    $.ajax({
150                        type: 'POST',
151                        dataType: 'html',
152                        url: normally_url_cart(document.location.search, 'add-to-cart', data.product_id, false),
153                        data: data.product_variation_data,
154                        cache: false,
155                        headers: {'cache-control': 'no-cache'},
156                        error: function (XMLHttpRequest, textStatus, errorThrown) {
157                            console.log('AJAX error - SubmitForm() - ' + errorThrown);
158                            $this.removeClass('loading');
159                        },
160                        success: function (response) {
161                            $this.removeClass('loading');
162                            if (!$this.hasClass('zoo-buy-now')) {
163                                let icon = $this.find('i').clone();
164                                $(document).trigger('zoo_single_product_cart_added', {
165                                    "response": response
166                                });
167                                var $response = $(response);
168                                if ($response.find('.woocommerce-message').html()) {
169                                    var $shopNotices = '<div id="zoo-add-to-cart-message">' + $response.find('.woocommerce-message').html() + '</div>';
170                                    if (!$('.cafe-canvas-cart')[0])
171                                        zoo_add_to_cart_mess($shopNotices);
172                                }
173                                var $cart_content = $response.find('.widget_shopping_cart_content');
174                                if ($cart_content.length > 1) {
175                                    $cart_content = $response.find('.cafe-canvas-cart-content .widget_shopping_cart_content');
176                                }
177                                $('.widget_shopping_cart_content').html($cart_content.html());
178                                $this.addClass('cart-added');
179                                $this.html(wc_add_to_cart_params.i18n_view_cart);
180                                $this.prepend(icon);
181                            } else {
182                                window.location = wc_add_to_cart_params.cart_url;
183                                return false;
184                            }
185                        }
186                    });
187                    return false;
188                }
189            }
190        });
191        /* End Ajax Add to Cart for Single Product */
192
193        /* Quick view js */
194        $(document).on('click', '.product .btn-quick-view', function (e) {
195            e.preventDefault();
196            $('.zoo-mask-close').addClass('loading active mask-quick-view');
197            var load_product_id = $(this).attr('data-productid');
198            var data = {action: 'zoo_quick_view', product_id: load_product_id};
199            $(this).parent().addClass('loading');
200            var $this = $(this);
201            $.ajax({
202                url: ajaxurl,
203                data: data,
204                type: "POST",
205                success: function (response) {
206                    $('body').append(response);
207                    $this.parent().removeClass('loading');
208                    // Variation Form
209                    var form_variation = $(document).find('#zoo-quickview-lb .variations_form');
210                    form_variation.wc_variation_form();
211                    form_variation.trigger('check_variations');
212                    zoo_quick_view_gal();
213                    //Sync button compare/wishlist quickview load.
214                    if($('#zoo-quickview-lb .zoo-wishlist-button')[0]) {
215                        if (window.zooWishlist.model.exists($('#zoo-quickview-lb .zoo-wishlist-button').data('id'))) {
216                            window.zooWishlist.view.renderBrowseButton($('#zoo-quickview-lb .zoo-wishlist-button'));
217                        }
218                    }
219                    if($('#zoo-quickview-lb .zoo-compare-button')[0]) {
220                        if (window.zooProductsCompare.model.exists($('#zoo-quickview-lb .zoo-compare-button').data('id'))) {
221                            window.zooProductsCompare.view.renderBrowseButton($('#zoo-quickview-lb .zoo-compare-button'));
222                        }
223                    }
224                    $('.lazy-img:not(.loaded)').zoo_lazyImg();
225                    setTimeout(function () {
226                        $('#zoo-quickview-lb').css('opacity', '1');
227                        $('#zoo-quickview-lb').css('top', '50%');
228                    }, 100);
229                }
230            });
231        });
232
233        $(document).on('click', '.close-quickview, .zoo-mask-close.mask-quick-view', function (e) {
234            e.preventDefault();
235            zoo_close_quick_view();
236        });
237        //Close Quickview when click to compare/wish list.
238        $(document).on('zoo_browse_wishlist', function () {
239            zoo_close_quick_view();
240        });
241        $(document).on('zoo_browse_compare', function () {
242            zoo_close_quick_view();
243        });
244        //Swatches gallery for quick view
245        $(document).on('cleverswatch_update_gallery', function (event, response) {
246            if ($('#zoo-quickview-lb')[0])
247                zoo_quick_view_gal();
248        });
249
250        //Close Quickview;
251        function zoo_close_quick_view() {
252            $('.zoo-mask-close').removeClass('loading active mask-quick-view');
253            $('#zoo-quickview-lb').css({'top': 'calc(50% + 150px)', 'opacity': '0'});
254            setTimeout(function () {
255                $('#zoo-quickview-lb').remove();
256            }, 500)
257        }
258
259        //Quickview gallery
260        function zoo_quick_view_gal() {
261            if ($('.zoo-product-quick-view .wrap-main-product-gallery')[0]) {
262                let thumb_num = $('.zoo-product-gallery.images').data('columns');
263                $('.zoo-product-quick-view .wrap-main-product-gallery').slick({
264                    slidesToShow: 1,
265                    rows: 0,
266                    slidesToScroll: 1,
267                    focusOnSelect: true,
268                    rtl: $('body.rtl')[0] ? true : false,
269                    asNavFor: $('.wrap-list-thumbnail')[0] ? '.zoo-product-quick-view .wrap-list-thumbnail' : '',
270                    prevArrow: '<span class="zoo-carousel-btn prev-item"><i class="zoo-icon-arrow-left"></i></span>',
271                    nextArrow: '<span class="zoo-carousel-btn next-item"><i class="zoo-icon-arrow-right"></i></span>',
272                });
273                $('.zoo-product-quick-view .wrap-list-thumbnail').slick({
274                    slidesToShow: thumb_num,
275                    rows: 0,
276                    slidesToScroll: 1,
277                    focusOnSelect: true,
278                    rtl: $('body.rtl')[0] ? true : false,
279                    asNavFor: '.zoo-product-quick-view .wrap-main-product-gallery',
280                    prevArrow: '<span class="zoo-carousel-btn prev-item"><i class="zoo-icon-arrow-left"></i></span>',
281                    nextArrow: '<span class="zoo-carousel-btn next-item "><i class="zoo-icon-arrow-right"></i></span>',
282                });
283            }
284        }
285
286        /* End Quick view js */
287
288        //Normally Ajax url, for multi language
289        function normally_url_cart(url, parameterName, parameterValue, atStart) {
290            var replaceDuplicates = true;
291            var urlhash = '';
292            var cl = url.length;
293            if (url.indexOf('#') > 0) {
294                cl = url.indexOf('#');
295                urlhash = url.substring(url.indexOf('#'), url.length);
296            }
297            var sourceUrl = url.substring(0, cl);
298
299            var urlParts = sourceUrl.split("?");
300            var newQueryString = "";
301
302            if (urlParts.length > 1) {
303                var parameters = urlParts[1].split("&");
304                for (var i = 0; (i < parameters.length); i++) {
305                    var parameterParts = parameters[i].split("=");
306                    if (!(replaceDuplicates && parameterParts[0] == parameterName)) {
307                        if (newQueryString == "")
308                            newQueryString = "?";
309                        else
310                            newQueryString += "&";
311                        newQueryString += parameterParts[0] + "=" + (parameterParts[1] ? parameterParts[1] : '');
312                    }
313                }
314            }
315            if (newQueryString == "")
316                newQueryString = "?";
317
318            if (atStart) {
319                newQueryString = '?' + parameterName + "=" + parameterValue + (newQueryString.length > 1 ? '&' + newQueryString.substring(1) : '');
320            } else {
321                if (newQueryString !== "" && newQueryString != '?')
322                    newQueryString += "&";
323                newQueryString += parameterName + "=" + (parameterValue ? parameterValue : '');
324            }
325            return urlParts[0] + newQueryString + urlhash;
326        }
327    })
328})(jQuery);

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.