Advertisement
BackuPs-nl

woocommerce jquery-quantity-increment.min.js

Nov 16th, 2018
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.03 KB | None | 0 0
  1. jQuery(function(i){function t(){i("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" />')}String.prototype.getDecimals||(String.prototype.getDecimals=function(){var t=(""+this).match(/(?:\.(\d+))?(?:[eE]([+-]?\d+))?$/);return t?Math.max(0,(t[1]?t[1].length:0)-(t[2]?+t[2]:0)):0}),i(document).on("updated_wc_div",function(){t()}),i(document).on("cart_page_refreshed",function(){t()}),i(document).on("click",".plus, .minus",function(){var t=i(this).closest(".quantity").find(".qty"),a=parseFloat(t.val()),e=parseFloat(t.attr("max")),n=parseFloat(t.attr("min")),o=t.attr("step");a&&""!==a&&"NaN"!==a||(a=0),""!==e&&"NaN"!==e||(e=""),""!==n&&"NaN"!==n||(n=0),"any"!==o&&""!==o&&void 0!==o&&"NaN"!==parseFloat(o)||(o=1),i(this).is(".plus")?e&&e<=a?t.val(e):t.val((a+parseFloat(o)).toFixed(o.getDecimals())):n&&a<=n?t.val(n):0<a&&t.val((a-parseFloat(o)).toFixed(o.getDecimals())),t.trigger("change")}),t()});
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement