PageSourceSearch

https://www.publiteconline.it/wp-content/plugins/wpc-ajax-add-to-cart/assets/js/frontend.js?ver=2.2.4

js publiteconline.it collected 2026-10-02 18:04:50 UTC 5,193 bytes, 147 lines download raw bytes

1(function($) {
2  $.fn.serializeArrayAll = function() {
3    var rCRLF = /\r?\n/g;
4
5    return this.map(function() {
6      return this.elements ? $.makeArray(this.elements) : this;
7    }).map(function(i, elem) {
8      var val = $(this).val();
9
10      if (val == null) {
11        return val == null;
12      } else if (this.type === 'checkbox') {
13        if (this.checked) {
14          return {name: this.name, value: this.checked ? this.value : ''};
15        }
16      } else if (this.type === 'radio') {
17        if (this.checked) {
18          return {name: this.name, value: this.checked ? this.value : ''};
19        }
20      } else {
21        return $.isArray(val) ? $.map(val, function(val, i) {
22          return {name: elem.name, value: val.replace(rCRLF, '\r\n')};
23        }) : {name: elem.name, value: val.replace(rCRLF, '\r\n')};
24      }
25    }).get();
26  };
27
28  $(document).on('wooaa_adding_to_cart', function(e, $btn) {
29    $btn.removeClass('added').addClass('loading');
30  });
31
32  $(document).
33      on('wooaa_added_to_cart', function(e, fragments, cart_hash, $btn) {
34        $btn.removeClass('loading').addClass('added');
35      });
36
37  $(document).
38      on('click',
39          '.single_add_to_cart_button:not(' + wooaa_vars.ignore_btn_class + ')',
40          function(e) {
41            var wooaa = false;
42            var $btn = $(this);
43            var $form = $btn.closest('.wpc_cart').length ? $btn.closest(
44                '.wpc_cart') : $btn.closest('form.cart');
45
46            if (wooaa_vars.product_types !== undefined) {
47              var product_types = wooaa_vars.product_types.split(',');
48
49              if (product_types.includes('all')) {
50                wooaa = true;
51              } else {
52                product_types.forEach(function(item) {
53                  if ($btn.is('.product-type-' + item +
54                      ' .single_add_to_cart_button')) {
55                    wooaa = true;
56                  }
57                });
58              }
59            }
60
61            if (wooaa) {
62              e.preventDefault();
63
64              var data = {};
65              var form_data = $form.find(
66                  'input:not([name="product_id"]), select, button, textarea').
67                  serializeArrayAll() || 0;
68
69              $.each(form_data, function(i, item) {
70                if (item.name === 'add-to-cart') {
71                  item.name = 'product_id';
72                  item.value = $form.find('input[name=variation_id]').val() ||
73                      $form.find('[name=variation_id]').val() ||
74                      $form.find('input.variation_id').val() ||
75                      $form.find('.variation_id').val() ||
76                      $form.find('input[name=add-to-cart]').val() ||
77                      $form.find('[name=add-to-cart]').val() || $btn.val();
78                }
79              });
80
81              $(document.body).
82                  trigger('wooaa_adding_to_cart', [$btn, form_data]);
83              $(document.body).trigger('adding_to_cart', [$btn, form_data]);
84
85              $.each(form_data, function(i, item) {
86                if (item.name !== '') {
87                  data[item.name] = item.value;
88                }
89              });
90
91              if ($btn.is(
92                  '.product-type-variable .single_add_to_cart_button')) {
93                // variable product
94                var attrs = {};
95
96                $form.find('[name^="attribute_"]').each(function() {
97                  var attribute = $(this).attr('name');
98
99                  attrs[attribute] = $(this).val();
100                });
101
102                data.variation = attrs;
103              }
104
105              if ((wooaa_vars.ignore_form_data != undefined) &&
106                  (wooaa_vars.ignore_form_data != '')) {
107                var ignore_form_data = wooaa_vars.ignore_form_data.split(',');
108
109                ignore_form_data.forEach(function(item) {
110                  delete data[item];
111                });
112              }
113
114              data.action = 'wooaa_add_to_cart';
115              data.nonce = wooaa_vars.nonce;
116
117              $.post(wooaa_vars.wc_ajax_url.toString().
118                      replace('%%endpoint%%', 'wooaa_add_to_cart'), data,
119                  function(response) {
120                    if (!response) {
121                      return;
122                    }
123
124                    if (response.error && response.product_url) {
125                      window.location = response.product_url;
126                      return;
127                    }
128
129                    // Redirect to cart option
130                    if (wooaa_vars.cart_redirect_after_add === 'yes') {
131                      window.location = wooaa_vars.cart_url;
132                      return;
133                    }
134
135                    // Trigger event so themes can refresh other areas.
136                    $(document.body).
137                        trigger('added_to_cart', [
138                          response.fragments, response.cart_hash, $btn]);
139                    $(document.body).
140                        trigger('wooaa_added_to_cart', [
141                          response.fragments, response.cart_hash, $btn]);
142                  });
143
144              return false;
145            }
146          });
147})(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.