Created
June 4, 2024 11:36
-
-
Save codersaiful/b658a89aee29de9c9757ec84ebde7da2 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
<?php | |
function my_custom_footer_script() { | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($) { | |
var inputBox = $('input.input-text.qty.text.wcmmq-qty-input-box.input-text.qty'); | |
inputBox.attr('type','number'); | |
inputBox.attr('inputmode','numeric'); | |
$(document.body).on('change','input.input-text.qty.text.wcmmq-qty-input-box.input-text.qty',function(){ | |
var thisInputBox = $(this); | |
var min = $(this).attr('min'); | |
min = parseInt(min); | |
var max = $(this).attr('max'); | |
var val = $(this).val(); | |
val = parseInt(val); | |
if( typeof max !== 'undefined' && max != '' && val > max){ | |
thisInputBox.val(max).trigger('click'); | |
} | |
if( typeof min !== 'undefined' && min != '' && val < min){ | |
thisInputBox.val(min).trigger('click'); | |
} | |
}); | |
inputBox.each(function(){ | |
}); | |
}); | |
</script> | |
<?php | |
} | |
add_action('wp_footer', 'my_custom_footer_script'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment