问题描述
在产品视图页面中,我想添加一个加减按钮,以增加和减少产品数量.
In the product view page, I would like to add a plus and minus button that increases and decreases the number of quantity of product.
推荐答案
转到,app \ design \ frontend \ default \ your_theme \ template \ catalog \ product \ view \ addtocart.phml
Go to,app\design\frontend\default\your_theme\template\catalog\product\view\addtocart.phml
在第32行附近搜索
< label for ="qty"><?php echo $ this-> __('Qty:')?></label><输入type ="text" name ="qty" id ="qty" maxlength ="12" value =<?php echo $ this-> getProductDefaultQty()* 1?>"title =<?php echo $ this-> __('Qty')?>"class ="input-text qty"/>
将以上内容替换为
< div>< label for ="qty"><?php echo $ this-> __('Qty:')?></label>< input class ="button-arrow button-up" type ="button" value ='+'></input><输入type ="text" name ="qty" id ="qty" maxlength ="12" value =<?php echo $ this-> getProductDefaultQty()* 1?>"title =<?php echo $ this-> __('Qty')?>"class ="input-text qty"/>< input class ="button-arrow button-down" type ="button" value ='-'></input></div>
.phtml文件粘贴的末尾,
At the end of that .phtml file paste,
< script type ="text/javascript">//& lt;![CDATA [jQuery(函数($){$('.add-to-cart .button-up').click(function(){$ qty = $(this).parent().find('.qty');数量= parseInt($ qty.val())+1;$ qty.val(qty);});$('.add-to-cart .button-down').click(function(){$ qty = $(this).parent().find('.qty');qty = parseInt($ qty.val())-1;如果(数量
这篇关于如何在数量框中添加增加和减少按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!