Created
May 4, 2011 21:11
-
-
Save carolineschnapp/956046 to your computer and use it in GitHub Desktop.
Limit to 1 — add at the bottom of cart.liquid
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> | |
if (typeof jQuery === 'undefined') { | |
document.write('<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"><\/script>'); | |
document.write('<script type="text/javascript">jQuery.noConflict();<\/script>'); | |
} | |
</script> | |
<script type="text/javascript"> | |
jQuery(function() { | |
var needs_update = false; | |
jQuery(':text[name^=updates]').each(function() { | |
if (jQuery(this).val() !== '1') { | |
needs_update = true; | |
jQuery(this).val(1); | |
} | |
}); | |
if (needs_update) { | |
jQuery('form[action="/cart"]').get(0).submit(); | |
} | |
jQuery(':text[name^=updates]').change(function() { | |
if (parseInt(jQuery(this).val(), 10) > 1) { | |
jQuery(this).val(1); | |
jQuery('form[action="/cart"]').get(0).submit(); | |
} | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment