1 2 3(function ($) { 4 "use strict"; 5 jQuery(function($) { 6 var noticesHtml; 7 8 $(document).on('click', 'a.ajax_add_to_cart', function(e){ 9 e.preventDefault(); 10 var $thisbutton = $(this); 11 var formData = new FormData(); 12 formData.append('add-to-cart', $thisbutton.attr( 'data-product_id' )); 13 $( document.body ).trigger( 'adding_to_cart', [ $thisbutton, formData ] ); 14 $.ajax({ 15 url: wc_add_to_cart_params.wc_ajax_url.toString().replace( '%%endpoint%%', 'ace_add_to_cart' ), 16 data: formData, 17 type: 'POST', 18 processData: false, 19 contentType: false, 20 complete: function( response ) { 21 response = response.responseJSON; 22 if ( ! response ) { 23 return; 24 } 25 if ( response.error && response.product_url ) { 26 window.location = response.product_url; 27 return; 28 } 29 if ( wc_add_to_cart_params.cart_redirect_after_add === 'yes' ) { 30 window.location = wc_add_to_cart_params.cart_url; 31 return; 32 } 33 $( document.body ).trigger( 'added_to_cart', [ response.fragments, response.cart_hash, $thisbutton ] ); 34 noticesHtml = response.fragments.notices_html; 35 $(noticesHtml).appendTo('.cart_notice').delay(800).fadeOut(800, function(){ 36 $(this).remove(); 37 }); 38 $('.cartnotice_close').on('click', function(){ 39 $(this).closest('.woocommerce-message, .woocommerce-error').remove(); 40 }); 41 }, 42 dataType: 'json' 43 }); 44 }); 45 46 47 }); 48}(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.