1jQuery(function ($) { 2 3 $(".bodycommerce-minicart").prependTo(".shop-cart"); 4 5 6 $(".post-type-archive-product").on("click", ".quantity input", function () { 7 return false; 8 }); 9 10 $(".archive").on("change input", ".quantity .qty", function () { 11 var add_to_cart_button = $(this).parents(".product").find(".add_to_cart_button, .ajax_add_to_cart"); 12 add_to_cart_button.data("quantity", $(this).val()); 13 add_to_cart_button.attr("href", "?add-to-cart=" + add_to_cart_button.attr("data-product_id") + "&quantity=" + $(this).val()); 14 15 }); 16 17 18 $(".input-text.qty.text").bind("keyup mouseup", function () { 19 var value = $(this).val(); 20 $(".product_quantity").val(value); 21 }); 22 23 24 if (typeof wc_add_to_cart_params === 'undefined') 25 return false; 26 27 $(".ajax_add_to_cart").removeClass('add_to_cart_button'); 28 29 $(document).on("click", ".ajax_add_to_cart", function (e) { 30 e.preventDefault(); 31 e.stopPropagation(); 32 33 if ( $(this).hasClass('wc-variation-is-unavailable') ) { 34 return; 35 } 36 37 var thisbutton = $(this); 38 var $cartForm = thisbutton.closest('form.cart'); 39 var formdata = $cartForm.serializeArray(); 40 41 if ($(".db_atc_notify_txt").length) { 42 var db_atc_notify_txt = $(".db_atc_notify_txt").val(), 43 db_atc_notify_txt_time = $(".db_atc_notify_txt_time").val(), 44 db_atc_notify_bg_color = $(".db_atc_notify_bg_color").val(), 45 db_atc_notify_text_color = $(".db_atc_notify_text_color").val(), 46 thisbutton_text = thisbutton.text(); 47 thisbutton.attr("style", "color:" + db_atc_notify_text_color + " !important; background-color:" + db_atc_notify_bg_color + " !important;"), 48 thisbutton.text(db_atc_notify_txt), thisbutton.addClass("active"), 49 setTimeout(function () { 50 thisbutton.text(thisbutton_text), thisbutton.removeClass("active"), thisbutton.removeAttr("style"); 51 }, db_atc_notify_txt_time); 52 } 53 54 if ( thisbutton.closest('.et_pb_db_shop_loop').length > 0 ) { 55 $('.et_pb_db_shop_loop').find('.woocommerce-notices-wrapper').removeClass('main'); 56 $('.et_pb_db_shop_loop').find('.woocommerce-notices-wrapper').html(''); 57 thisbutton.closest('.et_pb_db_shop_loop').find('.woocommerce-notices-wrapper').addClass('main'); 58 } 59 60 var grouped_form = $(this).closest('.grouped_form'); 61 var variation_form = $(this).closest('.variations_form'); 62 $(".ajaxerrors").remove(); 63 var item = {}, // was _ 64 check = true; // was s 65 variations = variation_form.find('select[name^=attribute]'); 66 67 if (!variations.length) { 68 variations = variation_form.find('[name^=attribute]:checked'); 69 } 70 71 if (!variations.length) { 72 variations = variation_form.find('input[name^=attribute]'); 73 } 74 75 var ajax_error_text = bc_add_to_cart_params.ajax_error_text; 76 77 variations.each(function () { 78 var $this = $(this), 79 attributeName = $this.attr('name'), 80 attributevalue = $this.val(), 81 index, 82 attributeTaxName; 83 $this.removeClass('error'); 84 85 if (attributevalue.length === 0) { 86 index = attributeName.lastIndexOf('_'); 87 attributeTaxName = attributeName.substring(index + 1); 88 $this 89 .addClass('required error') 90 .before('<div class="ajaxerrors"><p>' + ajax_error_text + ' ' + attributeTaxName + '</p></div>'); 91 check = false; 92 } else { 93 item[attributeName] = attributevalue; 94 } 95 }); 96 97 if (!check) { 98 return false; 99 } 100 101 if (thisbutton.is(".ajax_add_to_cart")) { 102 thisbutton.removeClass('added'); 103 thisbutton.addClass('loading'); 104 105 if ($(this).parents(".variations_form")[0]) { // If variation product 106 // console.log("variation add to cart"); 107 var product_id = variation_form.find('input[name=product_id]').val(); 108 var quantity = variation_form.find('input[name=quantity]').val(); 109 var var_id = variation_form.find('input[name=variation_id]').val(); 110 var data = { 111 action: 'bodycommerce_ajax_add_to_cart_woo', 112 product_id: product_id, 113 quantity: quantity, 114 variation_id: var_id, 115 variation: item 116 }; 117 118 // console.log(data); 119 120 var vanilla_woo = "yes"; 121 122 } else if ($(this).parents(".grouped_form")[0]) { // if grouped product 123 // console.log("Grouped add to cart"); 124 var main_product_id = grouped_form.find('input[name=add-to-cart]').val(); 125 var grouped_items_data = {}; 126 var grouped_items = grouped_form.find('.woocommerce-grouped-product-list-item'); 127 // var quantity = variation_form.find('input[name=quantity]').val(); 128 129 grouped_items.each(function () { 130 var $this = $(this), 131 grouped_product_id = $this.attr('id'), 132 quantity = $this.find('.qty').val(); 133 134 grouped_items_data[grouped_product_id] = quantity; 135 }); 136 137 var data = { 138 action: 'bodycommerce_ajax_add_to_cart_woo_bundle', 139 product_id: main_product_id, 140 quantity: "0", 141 grouped_data: grouped_items_data 142 }; 143 144 var vanilla_woo = "no"; 145 } else if ($cartForm.length && ( 146 $cartForm.hasClass('bundle_form') || 147 $cartForm.hasClass('yith-wcpb-bundle-form') || 148 $cartForm.find('[name^="bundled_items"], [name*="bundled_items["], [name^="yith_bundle_"]').length 149 )) { 150 // WooCommerce Product Bundles + YITH WCPB: send full form as urlencoded POST so bundle fields reach PHP (flat $.post objects can drop or flatten data). 151 var bundlePost = $cartForm.serialize(); 152 var bundlePid = $cartForm.find('input[name="add-to-cart"]').val(); 153 if (typeof bundlePid === 'undefined' || bundlePid === '' || bundlePid === null) { 154 bundlePid = $cartForm.attr('data-product-id'); 155 } 156 if (typeof bundlePid === 'undefined' || bundlePid === '' || bundlePid === null) { 157 bundlePid = typeof $(this).attr('value') !== 'undefined' ? $(this).attr('value') : $(this).val(); 158 } 159 if (bundlePid) { 160 bundlePost += (bundlePost.length ? '&' : '') + 'product_id=' + encodeURIComponent(bundlePid); 161 } 162 bundlePost += (bundlePost.length ? '&' : '') + 'action=' + encodeURIComponent('bodycommerce_ajax_add_to_cart_woo_single'); 163 var data = bundlePost; 164 var vanilla_woo = "bundle_serialized"; 165 } else { 166 // console.log("Single add to cart"); 167 var product_id = $(this).parent().find(".product_id").val(); 168 169 if (typeof product_id === 'undefined') { 170 product_id = $(".et_pb_db_atc_0 .button").val(); 171 } 172 173 if ( typeof product_id === 'undefined' && typeof $(this).attr('value') !== 'undefined' ) { 174 product_id = $(this).attr('value'); 175 } 176 177 if (typeof product_id === 'undefined' || product_id === '' || product_id === null) { 178 product_id = $cartForm.find('input[name="add-to-cart"]').val(); 179 } 180 181 if ( $(this).hasClass('wc-bookings-booking-form-button') ) { 182 product_id = $(this).parent().find('.wc-booking-product-id').val(); 183 } 184 185 var quantity = $(this).parent().find(".qty").val(); 186 var data = { 187 action: 'bodycommerce_ajax_add_to_cart_woo_single', 188 product_id: product_id, 189 quantity: quantity 190 }; 191 var vanilla_woo = "yes"; 192 } 193 194 if (vanilla_woo !== "bundle_serialized") { 195 $.each(formdata, function (key, f_data) { 196 if (f_data.name != 'add-to-cart') { 197 data[f_data.name] = f_data.value; 198 } 199 }); 200 } 201 202 if (vanilla_woo !== "bundle_serialized" && data.hasOwnProperty('subscribe-to-action-input') && data['subscribe-to-action-input'] == 'no') { 203 data['convert_to_sub_' + product_id] = "0"; 204 } 205 206 if (vanilla_woo == "yes" || vanilla_woo == "bundle_serialized") { 207 $('body').trigger('adding_to_cart', [thisbutton, data]); 208 $.post(wc_add_to_cart_params.ajax_url, data, function (response) { 209 if (!response) 210 return; 211 212 if ( typeof response == 'string' ) { 213 response = JSON.parse(response); 214 } 215 216 var this_page = window.location.toString(); 217 this_page = this_page.replace('add-to-cart', 'added-to-cart'); 218 219 if (response.error && response.product_url) { 220 //window.location = response.product_url; 221 //return; 222 if ($('.woocommerce-notices-wrapper.main').length > 0) { 223 $('.woocommerce-notices-wrapper.main').html(response.error_message); 224 } else { 225 if ( $('.et_pb_db_notices').length > 0 ) { 226 $('.et_pb_db_notices').html( '<div class="woocommerce-notices-wrapper">' + response.error_message + '</div>'); 227 } 228 } 229 thisbutton.removeClass('loading'); 230 if(!thisbutton.hasClass('disable_scroll_update')) { 231 // scroll to notices 232 $('html, body').animate({ 233 scrollTop: 0 234 }, 300); 235 } 236 237 return; 238 } 239 240 if (wc_add_to_cart_params.cart_redirect_after_add === 'yes') { 241 window.location = wc_add_to_cart_params.cart_url; 242 return; 243 } else { 244 thisbutton.removeClass('loading'); 245 var fragments = response.fragments; 246 var cart_hash = response.cart_hash; 247 248 if (fragments) { 249 $.each(fragments, function (key) { 250 $(key).addClass('updating'); 251 }); 252 } 253 254 $('.shop_table.cart, .updating, .cart_totals').fadeTo('400', '0.6').block({ 255 message: null, 256 overlayCSS: { 257 opacity: 0.6 258 } 259 }); 260 261 thisbutton.addClass('added'); 262 263 if (fragments) { 264 $.each(fragments, function (key, value) { 265 if ( key == 'div.woocommerce-notices-wrapper.main' ) { 266 if ($('.woocommerce-notices-wrapper.main').length > 0) { 267 $('.woocommerce-notices-wrapper.main').html(value); 268 } else if ( $('.woocommerce-notices-wrapper').length > 0 ) { 269 $('.woocommerce-notices-wrapper').html(value); 270 } else { 271 if ( $('.et_pb_db_notices').length > 0 ) { 272 $('.et_pb_db_notices').html( '<div class="woocommerce-notices-wrapper">' + value + '</div>'); 273 } 274 } 275 } 276 277 $(key).replaceWith(value); 278 }); 279 } 280 281 $('.widget_shopping_cart, .updating').stop(true).css('opacity', '1').unblock(); 282 $('.shop_table.cart').load(this_page + ' .shop_table.cart:eq(0) > *', function () { 283 $('.shop_table.cart').stop(true).css('opacity', '1').unblock(); 284 $(document.body).trigger('cart_page_refreshed'); 285 }); 286 287 $("#bodycommerce_added_to_cart_popup").addClass("active"); 288 $('.cart_totals').load(this_page + ' .cart_totals:eq(0) > *', function () { 289 $('.cart_totals').stop(true).css('opacity', '1').unblock(); 290 }); 291 292 if(!thisbutton.hasClass('disable_scroll_update')) { 293 // scroll to notices 294 $('html, body').animate({ 295 scrollTop: 0 296 }, 300); 297 } 298 299 $(document).trigger('bodycommerce_atc_completed'); 300 } 301 }); 302 return false;
303 } else { 304 305 jQuery.ajax({ 306 url: ajax_object.ajax_url, 307 data: data, 308 type: 'POST', 309 dataType: 'JSON', 310 beforeSend: function (xhr) { 311 }, 312 success: function (response) { 313 // console.log("sucess!"); 314 315 if (!((typeof response.error != 'undefined') && response.error == true)) { 316 var fragments = response.fragments; 317 var cart_hash = response.cart_hash; 318 $('.shop_table.cart, .updating, .cart_totals').fadeTo('400', '0.6').block({ 319 message: null, 320 overlayCSS: { 321 opacity: 0.6 322 } 323 }); 324 325 if (fragments) { 326 $.each(fragments, function (key, value) { 327 $(key).replaceWith(value); 328 }); 329 } 330 331 $('.widget_shopping_cart, .updating').stop(true).css('opacity', '1').unblock(); 332 $('.shop_table.cart').load(this_page + ' .shop_table.cart:eq(0) > *', function () { 333 $('.shop_table.cart').stop(true).css('opacity', '1').unblock(); 334 $(document.body).trigger('cart_page_refreshed'); 335 }); 336 337 $("#bodycommerce_added_to_cart_popup").addClass("active"); 338 339 $('.cart_totals').load(this_page + ' .cart_totals:eq(0) > *', function () { 340 $('.cart_totals').stop(true).css('opacity', '1').unblock(); 341 }); 342 343 344 345 $(document).trigger('bodycommerce_atc_completed'); 346 } else { 347 if ($('.woocommerce-notices-wrapper').length > 0) { 348 $('.woocommerce-notices-wrapper').html(response.error_message); 349 } else { 350 if ( $('.et_pb_db_notices').length > 0 ) { 351 $('.et_pb_db_notices').html( '<div class="woocommerce-notices-wrapper">' + response.error_message + '</div>'); 352 } 353 } 354 } 355 }, 356 error: function (jqXHR, exception) { 357 console.log("error!"); 358 }, 359 }); 360 } 361 } else { 362 return true; 363 } 364 }); 365 366 jQuery(document).on('applied_coupon', function(){ 367 jQuery('html, body').animate({ 368 scrollTop: 0 369 }, 300); 370 }); 371 372 jQuery(document).on('removed_coupon', function(){ 373 jQuery('html, body').animate({ 374 scrollTop: 0 375 }, 300); 376 }); 377 378 jQuery(document).on('applied_coupon_in_checkout', function(){ 379 jQuery('html, body').animate({ 380 scrollTop: 0 381 }, 300); 382 }); 383 jQuery(document).on('removed_coupon_in_checkout', function(){ 384 jQuery('html, body').animate({ 385 scrollTop: 0 386 }, 300); 387 }); 388 389 jQuery(document).on('divi_machine_modal_loaded', function(){ 390 console.log("modal loaded"); 391 setTimeout(function () { 392 console.log("modal loaded 2"); 393 // for each .add_to_cart_button 394 jQuery('.post-modal-cont .et_pb_db_atc button.single_add_to_cart_button.button').each(function (i, obj) { 395 // add class ajax_add_to_cart 396 jQuery(this).addClass('ajax_add_to_cart'); 397 }); 398 }, 500); 399}); 400});
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.