PageSourceSearch

https://www.rcicreview.com/wp-content/themes/rehub-theme/js/ajaxcart.js?ver=14.8.2

js rcicreview.com collected 2026-10-04 05:27:33 UTC 4,151 bytes, 105 lines download raw bytes

1jQuery(document).ready(function($) {
2   'use strict';     
3
4    var rh_ajax_add_to_cart = function() {
5
6        if ( 'undefined' === typeof wc_add_to_cart_params ) {
7            // The add to cart params are not present.
8            return false;
9        }
10
11        $.fn.DataserializeArray = function () {
12            var rdata = /\r?\n/g;
13            return this.map(function () {
14                return this.elements ? jQuery.makeArray(this.elements) : this;
15            }).map(function (i, elem) {
16                var val = jQuery(this).val();
17                if (val == null) {
18                    return val == null
19                } else if (this.type == "checkbox" && this.checked == false) {
20                    return {name: this.name, value: this.checked ? this.value : ''}
21                } else {
22                    return jQuery.isArray(val) ?
23                    jQuery.map(val, function (val, i) {
24                        return {name: elem.name, value: val.replace(rdata, "\r\n")};
25                    }) : {name: elem.name, value: val.replace(rdata, "\r\n")};
26                }
27            }).get();
28        };
29
30        $(document).on('click', '.wooquickviewbtn .single_add_to_cart_button:not(.disabled)', function (e) {
31            e.preventDefault();
32
33            var $thisbutton = $(this),
34            $form = $thisbutton.closest('form.cart'),
35            data = $form.find('input:not([name="product_id"]), select, button, textarea').DataserializeArray() || 0;
36
37            $.each(data, function (i, item) {
38                if ( item.name == 'add-to-cart') {
39                    item.name = 'product_id';
40                    item.value = $form.find('input[name=variation_id]').val() || $thisbutton.val();
41                }
42            });
43
44            $.ajax({
45                type: 'POST',
46                url: wc_add_to_cart_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'add_to_cart' ),
47                data: data,
48                beforeSend: function (response) {
49                    $thisbutton.removeClass('added').addClass('loading');
50                },
51                complete: function (response) {
52                    $thisbutton.addClass('added').removeClass('loading');
53                },
54                success: function (response) {
55
56                    if ( response.error & response.product_url ) {
57                        window.location = response.product_url;
58                        return;
59                    }
60
61                    $(document.body).trigger('added_to_cart', [response.fragments, response.cart_hash, $thisbutton] );
62                },
63                dataType: 'json'
64            });
65       });
66    }; 
67
68    rh_ajax_add_to_cart();
69});
70
71function rh_ajax_woo_cart_loading (el){
72    if(typeof wc_cart_fragments_params === 'undefined'){
73        return false;
74    }
75    var widgetCartContent = el.find(".widget_shopping_cart");
76    widgetCartContent.addClass("loaded re_loadingbefore");
77    jQuery.ajax({
78        type: "post",
79        url: wc_cart_fragments_params.wc_ajax_url.toString().replace('%%endpoint%%', 'get_refreshed_fragments'),
80        data: {
81            time: new Date().getTime()
82        },
83        timeout: wc_cart_fragments_params.request_timeout
84    }).done(function(data){
85        if (data && data.fragments) {
86            widgetCartContent.html(data.fragments["div.widget_shopping_cart_content"]);
87            widgetCartContent.removeClass("re_loadingbefore");
88        }                                   
89    });  
90}
91jQuery(document).on( 'added_to_cart', function ( event, fragments, cart_hash ) {
92    var widget = jQuery('#rh-woo-cart-panel');
93    if ( ! widget.hasClass( 'active' ) ) {
94        widget.addClass( 'active' );
95        rh_ajax_woo_cart_loading(widget); 
96    }
97});
98jQuery(document).on("click", "#main_header .rh_woocartmenu_cell", function(e){
99    e.preventDefault();
100    var widget = jQuery('#rh-woo-cart-panel');
101    if ( ! widget.hasClass( 'active' ) ) {
102        widget.addClass( 'active' );
103        rh_ajax_woo_cart_loading(widget); 
104    }   
105})

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.