Created
June 14, 2019 19:45
-
-
Save tobymarsden/baa48a6c0d41b198940432cbfee31099 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
window.InstaBuy = window.InstaBuy || {} | |
window.InstaBuy.target = "_self" | |
window.InstaBuy.afterRender = function(el) { | |
var quantityInputs = el.querySelectorAll(".widget-quantity-input:not(.minmaxify)"); | |
for(var i = 0; i < quantityInputs.length; i++) { | |
var input = quantityInputs[i] | |
if(!input.dataset.productHandle || input.dataset.productHandle.length === 0) { continue } | |
var limits = minMaxify && minMaxify.getIndividualLimitsFor && minMaxify.getIndividualLimitsFor({handle: input.dataset.productHandle}); | |
if(limits) { | |
input.className = input.className + ' minmaxify' | |
input.min = limits.min | |
if(limits.max > 0) { input.max = limits.max } | |
input.step = limits.multiple | |
if(limits.min || limits.multiple) { input.value = limits.min || limits.multiple} | |
input.dispatchEvent(new Event("input")) | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment