Answer the question
In order to leave comments, you need to log in
OpenCart: how to increase the quantity of a product by a multiple of the minimum in the product card?
Actually, subject. Wholesale store, sold only in boxes, with a clear number of items in each box.
For OpenCart, there is the Simple module, which does an excellent job, but only with a check-out (purchase confirmation: +/- number of products is also possible on this page).
Answer the question
In order to leave comments, you need to log in
The issue was resolved by the code:
HTML:
<button class="counter counter-minus material-design-horizontal39" href='#'></button>
<input type="text" data-minimum="<?php echo $minimum; ?>" name="quantity" size="3" value="<?php echo $minimum; ?>" />
<input type="hidden" name="product_id" value="<?php echo $product_id; ?>"/>
<button class="counter counter-plus material-design-add186" href='#'></button>
;(function ($) {
$(document).on('click', '.counter-minus, .counter-plus', function(e) {
e.preventDefault();
var input = $(this).parent().find('input[name*="quantity"]'),
value = 1;
var minimum = $(input).data('minimum');
if ($(this).hasClass('counter-minus') && input.val() > minimum) {
value = parseInt(input.val()) - minimum;
} else if ($(this).hasClass('counter-plus')) {
value = parseInt(input.val()) + minimum;
}
input.val(value);
});
})(jQuery);
In simplecheckout.js, see the increaseProductQuantity and decreaseProductQuantity functions.
As far as I can see, it adds / subtracts a multiple of the minimum amount.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question