Created
February 18, 2015 13:44
-
-
Save memoryleak/6c77fc10ebf05e57b96d to your computer and use it in GitHub Desktop.
Product Group Limits for Magento
This file contains 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 type="text/javascript"> | |
jQuery(document).ready(function() { | |
var maxHeight = <?php echo intval($_product->getMaxHeight()); ?>; | |
jQuery('.qty').change(function(){ | |
var currentHeight = 0; | |
jQuery('.qty').each(function(index) { | |
var height = parseInt(jQuery(this).attr('data-height')); | |
var qty = parseInt(jQuery(this).val()); | |
if(!isNaN(height)) { | |
currentHeight += (height * qty); | |
} | |
}); | |
if(maxHeight < currentHeight) { | |
// Show message that property sum is exceede | |
console.error("Max height exceeded", "Allowed", maxHeight, "Result", currentHeight); | |
} | |
console.log("Current", currentHeight) | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment