Skip to content

Instantly share code, notes, and snippets.

@memoryleak
Created February 18, 2015 13:44
Show Gist options
  • Save memoryleak/6c77fc10ebf05e57b96d to your computer and use it in GitHub Desktop.
Save memoryleak/6c77fc10ebf05e57b96d to your computer and use it in GitHub Desktop.
Product Group Limits for Magento
<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