Answer the question
In order to leave comments, you need to log in
How to fix product count switching in js OpenCart category?
Need to switch the number of products in a category when adding to cart. Works only on the first product, further +- does not work.
How can I fix it, I'm not friends with js. Help pliz
Code:
<div class="quantity-box quantity_category">
<input type="button" id="minus" value="-" class="form-control">
<input type="text" name="quantity" value="1" size="2" id="input-quantity-<?php echo $product['product_id']; ?>" class="form-control input-quantity">
<input type="button" id="plus" value="+" class="form-control">
</div>
<script type="text/javascript"><!--
var minimum = 1;
$(".input-quantity").change(function(){
if ($(this).val() < minimum) {
alert("Minimum Quantity: "+minimum);
$(".input-quantity").val(minimum);
}
});
// increase number of product
function minus(minimum){
var currentval = parseInt($(".input-quantity").val());
$(".input-quantity").val(currentval-1);
if($(".input-quantity").val() <= 0 || $(".input-quantity").val() < minimum){
alert("Minimum Quantity: "+minimum);
$(".input-quantity").val(minimum);
}
};
// decrease of product
function plus(){
var currentval = parseInt($(".input-quantity").val());
$(".input-quantity").val(currentval+1);
};
$('#minus').click(function(){
minus(minimum);
});
$('#plus').click(function(){
plus();
});
//--></script>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question