Advertisement
peter_shep

jQuery Cart

Jan 31st, 2012
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         jQuery("form[ID^=product_form]").submit(function() {
  2.  
  3.             jQuery('span#update_icon').css('visibility', 'visible');
  4.    
  5.             // use current url so empty basket keeps you on the same page
  6.             // then remove any additional request on the url incase someone has emptied the basket and then trys to add product again
  7.             var s = js_data.current_url;
  8.             var n = s.indexOf('?');
  9.             var current_url_stripped  = s.substring(0, n != -1 ? n : s.length);
  10.            
  11.             form_values = jQuery(this).serialize();
  12.             jQuery.post(current_url_stripped+"?ajax=true", form_values, function(returned_data) {
  13.                
  14.                 if (returned_data.indexOf("bullet") >= 0) {
  15.                     // remove - validate the drop down menus if false exit
  16.                     jQuery('p.prod_form_required').remove();
  17.                     jQuery('p.added_note').remove();
  18.                     jQuery('div.dpsc-shopping-cart').html(returned_data);
  19.                     jQuery('span#update_icon').css('visibility', 'hidden');
  20.                     jQuery('div.added_note').show('blind');
  21.  
  22.                 } else {
  23.                
  24.                     jQuery('.prod_form_required').fadeOut();
  25.                     jQuery('div#product_form_wrap').append('<p class="prod_form_required">Please complete the \'required\' options above</p>');
  26.                     jQuery('span#update_icon').css('visibility', 'hidden');
  27.  
  28.                 }
  29.                
  30.             });
  31.            
  32.             return false;
  33.            
  34.         });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement