我使用jquery代码增加了数量。
$(".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);
}
}
});当我在产品页面中添加这段代码并点击加号按钮时,数量会增加,点击add就可以完成它的工作。
id=40
但同样的事情并不适用于首页。
http://itracktraining.com/optest/index.php?route=common/home
有人能让我知道原因是什么吗
发布于 2015-10-23 15:27:37
在cart.add()函数中传递数量参数。
如:- <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>
根据您的需求更改相应的值。
实际函数接受两个参数cart.add(product id, quantity);
发布于 2016-03-25 02:06:16
对于添加数量选择器,您需要编辑在cart.add中找到的common.js函数,您可以创建自己的函数,并在函数中再添加一个参数,如:
Cart.add(“乘积id”,“数量”)
或者您可以找到这个扩展更多关于这里
https://stackoverflow.com/questions/32998210
复制相似问题