如何在数量框中添加增加和减少按钮 [英] How to add a increase and decrease button to quantity box

查看:56
本文介绍了如何在数量框中添加增加和减少按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在产品视图页面中,我想添加一个加减按钮,以增加和减少产品数量.

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;如果(数量<0)数量= 0;$ qty.val(qty);});});//]]&gt;</script>

这篇关于如何在数量框中添加增加和减少按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆