Scot Ranney • December 18, 2023
How to check for minimum quantity and show an alert without sending the form if quantity is less than X
l.settings:product:minimum_quantity is set by module or other page coding.
l.settings:product:minimum_quantity
Most miva merchant quantity boxes are forms named "add".
"add"
If your quantity box form is named something else change the js below where it says name="add" to whatever the name of your form is. If there is no name, then you can put one in like the simplified example form below.
name="add"
<form method="post" action="&mvte:urls:BASK:secure;" name="add" onsubmit="return checkMinimum()"> Quantity: <input type="number" name="Quantity"> <button type="submit" class="button">Add to Cart</button> </form>
<script> function checkMinimum() { var total = document.forms["add"]["Quantity"].value; if (total < &mvt:product:minimum_quantity;) { alert('Minimum quantity is &mvt:product:forcemultiples:prefillquantity;. Your current quantity is ' + total + '.'); return false; } }; </script>
mvkb mvkb_products