number of quantity to is not working in Opencart

删除回忆录丶 提交于 2019-12-25 07:52:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!