1(function ($) { 2 "use strict"; 3 jQuery(function($) { 4 // Simple product ajax add to cart 5 $(document).on('click', 'a.ajax_add_to_cart', function(e){ 6 // Only proceed if it's a simple product 7 if (!$(this).hasClass('product_type_simple')) { 8 return; 9 } 10 11 e.preventDefault(); 12 var $thisbutton = $(this); 13 var formData = new FormData(); 14 formData.append('add-to-cart', $thisbutton.attr('data-product_id')); 15 $( document.body ).trigger('adding_to_cart', [ $thisbutton, formData ]); 16 17 $.ajax({ 18 url: wc_add_to_cart_params.wc_ajax_url.toString().replace('%%endpoint%%', 'ace_add_to_cart'), 19 data: formData, 20 security: nest_cart_action_nonce.nonce, 21 type: 'POST', 22 processData: false, 23 contentType: false, 24 complete: function(response) { 25 response = response.responseJSON; 26 if (!response) return; 27 28 if (response.error && response.product_url) { 29 window.location = response.product_url; 30 return; 31 } 32 33 if (wc_add_to_cart_params.cart_redirect_after_add === 'yes') { 34 window.location = wc_add_to_cart_params.cart_url; 35 return; 36 } 37 38 $( document.body ).trigger('added_to_cart', [ response.fragments, response.cart_hash, $thisbutton ]); 39 $(response.fragments.notices_html).appendTo('.cart_notice').delay(200).fadeOut(5000, function(){ 40 $(this).remove(); 41 }); 42 43 $('.cartnotice_close').on('click', function(){ 44 $(this).closest('.woocommerce-message, .woocommerce-error').remove(); 45 }); 46 }, 47 dataType: 'json' 48 }); 49 }); 50 }); 51 52 // Simple and Variable products add to cart 53 jQuery(document).ready(function () { 54 $('.product-type-simple form.cart, .product-type-variable form.cart').on('submit', function(e) { 55 var $form = $(this); 56 var $submitButton = $(document.activeElement); 57 58 // Don't interfere with buy now button 59 if ($submitButton.hasClass('wpcbn-btn-single')) { 60 return true; 61 } 62 63 e.preventDefault(); 64 65 var formData = new FormData($form[0]); 66 formData.append('add-to-cart', $form.find('[name=add-to-cart]').val()); 67 68 $.ajax({
69 url: wc_add_to_cart_params.wc_ajax_url.toString().replace('%%endpoint%%', 'ace_add_to_cart'), 70 data: formData, 71 security: nest_cart_action_nonce.nonce, 72 type: 'POST', 73 processData: false, 74 contentType: false, 75 complete: function(response) { 76 response = response.responseJSON; 77 if (!response) return; 78 79 if (response.error && response.product_url) { 80 window.location = response.product_url; 81 return; 82 } 83 84 if (wc_add_to_cart_params.cart_redirect_after_add === 'yes') { 85 window.location = wc_add_to_cart_params.cart_url; 86 return; 87 } 88 89 var $thisbutton = $form.find('.single_add_to_cart_button:not(.wpcbn-btn-single)'); 90 $( document.body ).trigger('added_to_cart', [ response.fragments, response.cart_hash, $thisbutton ]); 91 92 $('.woocommerce-error, .woocommerce-message, .woocommerce-info').remove(); 93 94 $(response.fragments.notices_html).appendTo('.cart_notice').delay(200).fadeOut(5000); 95 $('.woocommerce-message, .woocommerce-error').each(function() { 96 if (!$(this).find('.cartnotice_close').length) { 97 $(this).append('<div class="cartnotice_close"><i class="fas fa-times"></i></div>'); 98 } 99 }); 100 101 $('.cartnotice_close').on('click', function(){ 102 $(this).closest('.woocommerce-message, .woocommerce-error').remove(); 103 }); 104 } 105 }); 106 }); 107 }); 108}(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.