问题
I added to increase quantity using jquery code
$(".quantity-adder .add-action").click(function () {
if ($(this).hasClass('add-up')) {
var text = $(this).parent().parent().parent().find("[name=quantity]", '.quantity-adder')
text.val(parseInt(text.val()) + 1);
} else {
var text = $(this).parent().parent().parent().find("[name=quantity]", '.quantity-adder')
if (parseInt(text.val()) > 1) {
text.val(parseInt(text.val()) - 1);
}
}
});
when i add this code in product page, and clicking the plus button, quantity increases and when clicked on add to cart its working fine
http://itracktraining.com/optest/index.php?route=product/product&product_id=40
but same thing is not working in homepage featured one
http://itracktraining.com/optest/index.php?route=common/home
can some one let me know what could be the reason
回答1:
Pass quantity parameter in cart.add()
function.
For ex :-
<button type="button" onclick="cart.add('<?php echo $product['product_id']; ?>',$(this).parent().parent().find('input:first').val());"><i class="fa fa-shopping-cart"></i> <span class="hidden-xs hidden-sm hidden-md"><?php echo $button_cart; ?></span></button>
Change corresponding values as per your requirements.
Actual function accepts two parameters
cart.add(product id, quantity);
回答2:
For add quantity selector you need to edit cart.add function that are find in common.js, you can make your own function and add one more parameter in function like :
cart.add('product id','quantity')
or you can find this extension more about here
来源:https://stackoverflow.com/questions/32998210/number-of-quantity-to-is-not-working-in-opencart