Php Magento:添加+;/-list.phtml中的数量增量按钮
我已经在我的产品列表视图页面中添加了一些数量增量按钮,我已经在list.phtml中添加了代码-显示+/-按钮和数量字段,但我只需要将其与“添加到购物车”按钮链接,因为现在如果单击“添加到购物车”,它仍然只添加1个产品。有人能告诉我怎么做吗 以下是PHP:Php Magento:添加+;/-list.phtml中的数量增量按钮,php,jquery,magento,button,increment,Php,Jquery,Magento,Button,Increment,我已经在我的产品列表视图页面中添加了一些数量增量按钮,我已经在list.phtml中添加了代码-显示+/-按钮和数量字段,但我只需要将其与“添加到购物车”按钮链接,因为现在如果单击“添加到购物车”,它仍然只添加1个产品。有人能告诉我怎么做吗 以下是PHP: <div class="quantity"> <input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->get
<div class="quantity">
<input type="text" name="qty" id="qty" maxlength="12" value="<?php echo $this->getMinimalQty($_product) ?>" title="<?php echo $this->__('Qty') ?>" class="input-text qty"/>
</div> <!-- /.quantity -->
<p><button type="button" title="<?php echo $this->__('Add to Cart') ?>" class="button btn-cart" onclick="setLocation('<?php echo $this->getAddToCartUrl($_product) ?>')"><span> <span><?php echo $this->__('Add to Cart') ?></span></span>
</button></p>
您需要将jQuery包装到一个文档中
<script type ="text/javascript">
jQuery(document).ready(function() {
// js here
});
</script>
jQuery(文档).ready(函数(){
//这里是js
});
您的问题不清楚您的jqyery代码是否有效?我的意思是,当你点击+/-按钮时,它是否正确地更新了值?还是你在做这件事时有问题?对于像购物车系统这样的系统,最好将逻辑和表示分离,这样可以提供大量调试支持
<script type ="text/javascript">
jQuery(document).ready(function() {
// js here
});
</script>