1 line
1004 B
JavaScript
1 line
1004 B
JavaScript
jQuery(function(e){e(".woocommerce-ordering").on("change","select.orderby",function(){e(this).closest("form").submit()});e("div.quantity:not(.buttons_added), td.quantity:not(.buttons_added)").addClass("buttons_added").append('<input type="button" value="+" class="plus" />').prepend('<input type="button" value="-" class="minus" />');e("input.qty:not(.product-quantity input.qty)").each(function(){var t=parseFloat(e(this).attr("min"));if(t&&t>0&&parseFloat(e(this).val())<t){e(this).val(t)}});e(document).on("click",".plus, .minus",function(){var t=e(this).closest(".quantity").find(".qty"),n=parseFloat(t.val()),r=parseFloat(t.attr("max")),i=parseFloat(t.attr("min")),s=t.attr("step");if(!n||n===""||n==="NaN")n=0;if(r===""||r==="NaN")r="";if(i===""||i==="NaN")i=0;if(s==="any"||s===""||s===undefined||parseFloat(s)==="NaN")s=1;if(e(this).is(".plus")){if(r&&(r==n||n>r)){t.val(r)}else{t.val(n+parseFloat(s))}}else{if(i&&(i==n||n<i)){t.val(i)}else if(n>0){t.val(n-parseFloat(s))}}t.trigger("change")})}) |